VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxAquaStyle.cpp@ 28800

Last change on this file since 28800 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.6 KB
Line 
1/** $Id: VBoxAquaStyle.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * Qt GUI - VBox Variation on the QAquaStyle.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "VBoxDefs.h"
19#include "VBoxAquaStyle.h"
20#include <qapplication.h>
21#include <qtoolbutton.h>
22#include <qpushbutton.h>
23#include <qpainter.h>
24#include <qpixmap.h>
25
26
27VBoxAquaStyle *VBoxAquaStyle::sInstance;
28
29/**
30 * Create a VBoxAquaStyle wrapper overloading the specified QAquaStyle instance.
31 * @param parent QAquaStyle instance.
32 */
33VBoxAquaStyle::VBoxAquaStyle(QStyle *parent)
34 : QStyle(),
35 mparent(parent)
36{
37}
38
39/**
40 * Create a VBoxAquaStyle wrapper overloading the specified QAquaStyle instance.
41 * @param parent QAquaStyle instance.
42 */
43VBoxAquaStyle::VBoxAquaStyle(QStyle &parent)
44 : QStyle(),
45 mparent(&parent)
46{
47}
48
49/**
50 * The main purpose here is to make sure the global
51 * instance doesn't die on us.
52 */
53VBoxAquaStyle::~VBoxAquaStyle()
54{
55 //fprintf(stderr, "~VBoxAquaStyle\n");
56 if (this == sInstance)
57 sInstance = NULL;
58 mparent = NULL;
59}
60
61/**
62 * Get the global VBoxAquaStyle instance.
63 */
64/* static */VBoxAquaStyle &VBoxAquaStyle::VBoxAquaStyle::instance()
65{
66 if (!sInstance)
67 sInstance = new VBoxAquaStyle(QApplication::style());
68 return *sInstance;
69}
70
71// The QStyle bits we modify the behaviour of.
72
73void VBoxAquaStyle::drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget,
74 const QRect &r, const QColorGroup &cg, SFlags how/* = Style_Default*/,
75 SCFlags sub/* = (uint)SC_All*/, SCFlags subActive/* = SC_None*/,
76 const QStyleOption &foo/* = QStyleOption::Default*/ ) const
77{
78 //fprintf(stderr, "drawComplexControl %p %x", widget, control);
79 if ( control == CC_ToolButton )
80 {
81 /*
82 * This is for the ugly tool bar buttons.
83 * We just drop the frame unless they are pressed down.
84 */
85 QToolButton *toolbutton = (QToolButton *)widget;
86 //if (toolbutton->isDown()) fprintf(stderr, " down");
87 if (!toolbutton->isDown())
88 {
89 if (toolbutton->hasFocus() && !toolbutton->focusProxy())
90 {
91 QRect fr = toolbutton->rect();
92 fr.addCoords(3, 3, -3, -3);
93 drawPrimitive(PE_FocusRect, p, fr, cg);
94 }
95 //fprintf(stderr, "\n");
96 return;
97 }
98 }
99
100 /* fallback */
101 mparent->drawComplexControl( control, p, widget, r, cg, how, sub, subActive, foo );
102 //fprintf(stderr, "\n");
103}
104
105
106// The QStyle proxying
107
108void VBoxAquaStyle::polish( QWidget *w )
109{
110 //fprintf(stderr, "polish %p\n", w);
111 mparent->polish( w );
112}
113
114void VBoxAquaStyle::unPolish( QWidget *w )
115{
116 //fprintf(stderr, "unPolish %p\n", w);
117 mparent->unPolish( w );
118}
119
120void VBoxAquaStyle::polish( QApplication *app )
121{
122 mparent->polish( app );
123}
124
125void VBoxAquaStyle::unPolish( QApplication *app )
126{
127 mparent->unPolish( app );
128}
129
130void VBoxAquaStyle::polish( QPalette &p )
131{
132 mparent->polish( p );
133}
134
135void VBoxAquaStyle::polishPopupMenu( QPopupMenu *m )
136{
137 mparent->polishPopupMenu( m );
138}
139
140QRect VBoxAquaStyle::itemRect( QPainter *p, const QRect &r, int flags, bool enabled,
141 const QPixmap *pixmap, const QString &text, int len/* = -1*/ ) const
142{
143 return mparent->itemRect( p, r, flags, enabled, pixmap, text, len );
144}
145
146void VBoxAquaStyle::drawItem( QPainter *p, const QRect &r, int flags, const QColorGroup &g, bool enabled,
147 const QPixmap *pixmap, const QString &text, int len/* = -1*/, const QColor *penColor/* = 0*/ ) const
148{
149 //fprintf(stderr, "drawItem %p\n", pixmap);
150 mparent->drawItem( p, r, flags, g, enabled, pixmap, text, len, penColor );
151}
152
153void VBoxAquaStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg,
154 SFlags flags/* = Style_Default*/, const QStyleOption &foo/* = QStyleOption::Default*/ ) const
155{
156 //fprintf(stderr, "drawPrimitive %x\n", pe);
157 mparent->drawPrimitive( pe, p, r, cg, flags, foo);
158}
159
160void VBoxAquaStyle::drawControl( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r,
161 const QColorGroup &cg, SFlags how/* = Style_Default*/, const QStyleOption &foo/* = QStyleOption::Default*/ ) const
162{
163 //fprintf(stderr, "drawControl %p %x\n", widget, element);
164 mparent->drawControl( element, p, widget, r, cg, how, foo );
165}
166
167void VBoxAquaStyle::drawControlMask( ControlElement element, QPainter *p, const QWidget *widget,
168 const QRect &r, const QStyleOption &foo/* = QStyleOption::Default*/ ) const
169{
170 //fprintf(stderr, "drawControlMask %p %x\n", widget, element);
171 mparent->drawControlMask( element, p, widget, r, foo);
172}
173
174QRect VBoxAquaStyle::subRect( SubRect r, const QWidget *widget ) const
175{
176 //fprintf(stderr, "subRect %p", widget);
177 QRect rct = mparent->subRect( r, widget );
178 //fprintf(stderr, " rct(%d,%d,%d,%d)\n", rct.topLeft().x(), rct.topLeft().y(), rct.bottomRight().x(),rct.bottomRight().y());
179 return rct;
180}
181
182int VBoxAquaStyle::pixelMetric( PixelMetric metric, const QWidget *widget/* = 0*/ ) const
183{
184 return mparent->pixelMetric( metric, widget );
185}
186
187QSize VBoxAquaStyle::sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize,
188 const QStyleOption &foo/* = QStyleOption::Default*/ ) const
189{
190 return mparent->sizeFromContents( contents, widget, contentsSize, foo );
191}
192
193int VBoxAquaStyle::styleHint( StyleHint stylehint, const QWidget *widget/* = 0*/,
194 const QStyleOption &foo/* = QStyleOption::Default*/,
195 QStyleHintReturn* returnData/* = 0*/) const
196{
197 return mparent->styleHint( stylehint, widget, foo, returnData );
198}
199
200QPixmap VBoxAquaStyle::stylePixmap( StylePixmap stylepixmap, const QWidget *widget/* = 0*/,
201 const QStyleOption &foo/* = QStyleOption::Default*/ ) const
202{
203 return mparent->stylePixmap( stylepixmap, widget, foo );
204}
205
206
207void VBoxAquaStyle::drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r,
208 const QStyleOption &foo/* = QStyleOption::Default*/ ) const
209{
210 //fprintf(stderr, "drawComplexControl %p %x\n", widget, control);
211 mparent->drawComplexControlMask( control, p, widget, r, foo );
212}
213
214QRect VBoxAquaStyle::querySubControlMetrics( ComplexControl control, const QWidget *widget,
215 SubControl sc, const QStyleOption &foo/* = QStyleOption::Default*/ ) const
216{
217 //fprintf(stderr, "querySubControlMetrics %p %x\n", widget, control);
218 return mparent->querySubControlMetrics( control, widget, sc, foo );
219}
220
221QStyle::SubControl VBoxAquaStyle::querySubControl( ComplexControl control, const QWidget *widget, const QPoint &pos,
222 const QStyleOption &foo/* = QStyleOption::Default*/ ) const
223{
224 //fprintf(stderr, "querySubControl %p %x\n", widget, control);
225 return mparent->querySubControl( control, widget, pos, foo );
226}
227
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette