VirtualBox

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

Last change on this file since 2514 was 2514, checked in by vboxsync, 18 years ago

eol

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

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