author | leseb <leseb> | 2002-07-02 21:23:40 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-02 21:23:40 (UTC) |
commit | d83f58a1a4a314a3ef8b25dd78432488922a9e31 (patch) (unidiff) | |
tree | 353b815ff13bb34594fa8db4d15233ed6b8c27e4 | |
parent | 2481ac4013794f95c53580f99b4b761142e4ee8f (diff) | |
download | opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.zip opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.gz opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.bz2 |
Fix QToolButton drawing
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 8 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.h | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp index 61127b8..d97b026 100644 --- a/noncore/styles/theme/othemestyle.cpp +++ b/noncore/styles/theme/othemestyle.cpp | |||
@@ -1,1532 +1,1540 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> | 2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. | 6 | License version 2 as published by the Free Software Foundation. |
7 | 7 | ||
8 | This library is distributed in the hope that it will be useful, | 8 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. | 11 | Library General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 16 | Boston, MA 02111-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include "othemestyle.h" | 19 | #include "othemestyle.h" |
20 | #include "othemebase.h" | 20 | #include "othemebase.h" |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qbitmap.h> | 22 | #include <qbitmap.h> |
23 | #define INCLUDE_MENUITEM_DEF | 23 | #define INCLUDE_MENUITEM_DEF |
24 | #include <qmenudata.h> | 24 | #include <qmenudata.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qtabbar.h> | 26 | #include <qtabbar.h> |
27 | #include <qglobal.h> | 27 | #include <qglobal.h> |
28 | 28 | ||
29 | #include <limits.h> | 29 | #include <limits.h> |
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 32 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
33 | 33 | ||
34 | OThemeStyle::OThemeStyle( const QString &configFile ) | 34 | OThemeStyle::OThemeStyle( const QString &configFile ) |
35 | : OThemeBase( configFile ) | 35 | : OThemeBase( configFile ) |
36 | { | 36 | { |
37 | setScrollBarExtent( getSBExtent(), getSBExtent() ); | 37 | setScrollBarExtent( getSBExtent(), getSBExtent() ); |
38 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! | 38 | setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below! |
39 | } | 39 | } |
40 | 40 | ||
41 | OThemeStyle::~OThemeStyle() | 41 | OThemeStyle::~OThemeStyle() |
42 | {} | 42 | {} |
43 | 43 | ||
44 | void OThemeStyle::polish( QApplication * /*app*/ ) | 44 | void OThemeStyle::polish( QApplication * /*app*/ ) |
45 | {} | 45 | {} |
46 | 46 | ||
47 | void OThemeStyle::polish( QPalette &p ) | 47 | void OThemeStyle::polish( QPalette &p ) |
48 | { | 48 | { |
49 | oldPalette = p; | 49 | oldPalette = p; |
50 | 50 | ||
51 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); | 51 | QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background ); |
52 | 52 | ||
53 | if ( bgcolor. isValid ( )) | 53 | if ( bgcolor. isValid ( )) |
54 | bg = bgcolor; | 54 | bg = bgcolor; |
55 | 55 | ||
56 | if ( isColor ( Background )) | 56 | if ( isColor ( Background )) |
57 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); | 57 | bg = colorGroup ( oldPalette. active ( ), Background )-> background ( ); |
58 | 58 | ||
59 | p = QPalette ( bg, bg ); | 59 | p = QPalette ( bg, bg ); |
60 | 60 | ||
61 | if ( isPixmap( Background ) ) | 61 | if ( isPixmap( Background ) ) |
62 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); | 62 | p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background ))); |
63 | 63 | ||
64 | if ( fgcolor. isValid ( )) { | 64 | if ( fgcolor. isValid ( )) { |
65 | p. setColor ( QColorGroup::Foreground, fgcolor ); | 65 | p. setColor ( QColorGroup::Foreground, fgcolor ); |
66 | p. setColor ( QColorGroup::ButtonText, fgcolor ); | 66 | p. setColor ( QColorGroup::ButtonText, fgcolor ); |
67 | } | 67 | } |
68 | if ( selfgcolor. isValid ( )) | 68 | if ( selfgcolor. isValid ( )) |
69 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); | 69 | p. setColor ( QColorGroup::HighlightedText, selfgcolor ); |
70 | if ( selbgcolor. isValid ( )) | 70 | if ( selbgcolor. isValid ( )) |
71 | p. setColor ( QColorGroup::Highlight, selbgcolor ); | 71 | p. setColor ( QColorGroup::Highlight, selbgcolor ); |
72 | if ( winfgcolor. isValid ( )) | 72 | if ( winfgcolor. isValid ( )) |
73 | p. setColor ( QColorGroup::Text, winfgcolor ); | 73 | p. setColor ( QColorGroup::Text, winfgcolor ); |
74 | if ( winbgcolor. isValid ( )) | 74 | if ( winbgcolor. isValid ( )) |
75 | p. setColor ( QColorGroup::Base, winbgcolor ); | 75 | p. setColor ( QColorGroup::Base, winbgcolor ); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void OThemeStyle::unPolish( QApplication *app ) | 80 | void OThemeStyle::unPolish( QApplication *app ) |
81 | { | 81 | { |
82 | app->setPalette( oldPalette, true ); | 82 | app->setPalette( oldPalette, true ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void OThemeStyle::polish( QWidget *w ) | 85 | void OThemeStyle::polish( QWidget *w ) |
86 | { | 86 | { |
87 | if ( !w->isTopLevel() ) { | 87 | if ( !w->isTopLevel() ) { |
88 | if ( w->inherits( "QGroupBox" ) | 88 | if ( w->inherits( "QGroupBox" ) |
89 | || w->inherits( "QTabWidget" ) ) { | 89 | || w->inherits( "QTabWidget" ) ) { |
90 | w->setAutoMask( TRUE ); | 90 | w->setAutoMask( TRUE ); |
91 | return ; | 91 | return ; |
92 | } | 92 | } |
93 | if ( w->inherits( "QLabel" ) | 93 | if ( w->inherits( "QLabel" ) |
94 | || w->inherits( "QSlider" ) | 94 | || w->inherits( "QSlider" ) |
95 | || w->inherits( "QButton" ) | 95 | || w->inherits( "QButton" ) |
96 | || w->inherits( "QProgressBar" ) | 96 | || w->inherits( "QProgressBar" ) |
97 | ) { | 97 | ) { |
98 | w->setBackgroundOrigin( QWidget::ParentOrigin ); | 98 | w->setBackgroundOrigin( QWidget::ParentOrigin ); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if ( w->inherits( "QPopupMenu" ) ) { | 101 | if ( w->inherits( "QPopupMenu" ) ) { |
102 | popupPalette = w->palette(); | 102 | popupPalette = w->palette(); |
103 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { | 103 | if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) { |
104 | QPalette newPal( w->palette() ); | 104 | QPalette newPal( w->palette() ); |
105 | w->setPalettePropagation( QWidget::SamePalette ); | 105 | w->setPalettePropagation( QWidget::SamePalette ); |
106 | if ( isColor( MenuItem ) ) { | 106 | if ( isColor( MenuItem ) ) { |
107 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); | 107 | newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) ); |
108 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); | 108 | newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) ); |
109 | } | 109 | } |
110 | if ( isColor( MenuItemDown ) ) | 110 | if ( isColor( MenuItemDown ) ) |
111 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); | 111 | newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) ); |
112 | w->setPalette( newPal ); | 112 | w->setPalette( newPal ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | if ( w->inherits( "QCheckBox" ) ) { | 115 | if ( w->inherits( "QCheckBox" ) ) { |
116 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { | 116 | if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) { |
117 | QPalette newPal( w->palette() ); | 117 | QPalette newPal( w->palette() ); |
118 | w->setPalettePropagation( QWidget::SamePalette ); | 118 | w->setPalettePropagation( QWidget::SamePalette ); |
119 | if ( isColor( IndicatorOff ) ) { | 119 | if ( isColor( IndicatorOff ) ) { |
120 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); | 120 | newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) ); |
121 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); | 121 | newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) ); |
122 | } | 122 | } |
123 | if ( isColor( IndicatorOn ) ) | 123 | if ( isColor( IndicatorOn ) ) |
124 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); | 124 | newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) ); |
125 | w->setPalette( newPal ); | 125 | w->setPalette( newPal ); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | if ( w->inherits( "QRadioButton" ) ) { | 128 | if ( w->inherits( "QRadioButton" ) ) { |
129 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { | 129 | if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) { |
130 | QPalette newPal( w->palette() ); | 130 | QPalette newPal( w->palette() ); |
131 | w->setPalettePropagation( QWidget::SamePalette ); | 131 | w->setPalettePropagation( QWidget::SamePalette ); |
132 | if ( isColor( ExIndicatorOff ) ) { | 132 | if ( isColor( ExIndicatorOff ) ) { |
133 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); | 133 | newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) ); |
134 | newPal.setDisabled( *colorGroup( newPal.normal(), | 134 | newPal.setDisabled( *colorGroup( newPal.normal(), |
135 | ExIndicatorOff ) ); | 135 | ExIndicatorOff ) ); |
136 | } | 136 | } |
137 | if ( isColor( ExIndicatorOn ) ) | 137 | if ( isColor( ExIndicatorOn ) ) |
138 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); | 138 | newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) ); |
139 | w->setPalette( newPal ); | 139 | w->setPalette( newPal ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void OThemeStyle::unPolish( QWidget* w ) | 144 | void OThemeStyle::unPolish( QWidget* w ) |
145 | { | 145 | { |
146 | if ( !w->isTopLevel() ) { | 146 | if ( !w->isTopLevel() ) { |
147 | if ( w->inherits( "QGroupBox" ) | 147 | if ( w->inherits( "QGroupBox" ) |
148 | || w->inherits( "QTabWidget" ) ) { | 148 | || w->inherits( "QTabWidget" ) ) { |
149 | w->setAutoMask( FALSE ); | 149 | w->setAutoMask( FALSE ); |
150 | return ; | 150 | return ; |
151 | } | 151 | } |
152 | if ( w->inherits( "QLabel" ) | 152 | if ( w->inherits( "QLabel" ) |
153 | || w->inherits( "QSlider" ) | 153 | || w->inherits( "QSlider" ) |
154 | || w->inherits( "QButton" ) | 154 | || w->inherits( "QButton" ) |
155 | || w->inherits( "QProgressBar" ) | 155 | || w->inherits( "QProgressBar" ) |
156 | ) { | 156 | ) { |
157 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); | 157 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if ( w->inherits( "QPopupMenu" ) ) | 160 | if ( w->inherits( "QPopupMenu" ) ) |
161 | w->unsetPalette(); | 161 | w->unsetPalette(); |
162 | if ( w->inherits( "QCheckBox" ) ) | 162 | if ( w->inherits( "QCheckBox" ) ) |
163 | w->unsetPalette(); | 163 | w->unsetPalette(); |
164 | if ( w->inherits( "QRadioButton" ) ) | 164 | if ( w->inherits( "QRadioButton" ) ) |
165 | w->unsetPalette(); | 165 | w->unsetPalette(); |
166 | } | 166 | } |
167 | 167 | ||
168 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | 168 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, |
169 | const QColorGroup &g, bool sunken, bool | 169 | const QColorGroup &g, bool sunken, bool |
170 | rounded, WidgetType type, const QBrush * ) | 170 | rounded, WidgetType type, const QBrush * ) |
171 | { | 171 | { |
172 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); | 172 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); |
173 | QPen oldPen = p->pen(); | 173 | QPen oldPen = p->pen(); |
174 | 174 | ||
175 | // handle reverse bevel here since it uses decowidth differently | 175 | // handle reverse bevel here since it uses decowidth differently |
176 | if ( gradientHint( type ) == GrReverseBevel ) { | 176 | if ( gradientHint( type ) == GrReverseBevel ) { |
177 | int i; | 177 | int i; |
178 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, | 178 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, |
179 | Qt::CopyROP, true ); | 179 | Qt::CopyROP, true ); |
180 | p->setPen( g.text() ); | 180 | p->setPen( g.text() ); |
181 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) | 181 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) |
182 | p->drawRect( x, y, w, h ); | 182 | p->drawRect( x, y, w, h ); |
183 | } | 183 | } |
184 | // same with KDE style borders | 184 | // same with KDE style borders |
185 | else if ( !borderPixmap( type ) && shade() == KDE ) { | 185 | else if ( !borderPixmap( type ) && shade() == KDE ) { |
186 | qDrawWinButton( p, x, y, w, h, g, sunken ); | 186 | qDrawWinButton( p, x, y, w, h, g, sunken ); |
187 | if ( isPixmap( type ) ) | 187 | if ( isPixmap( type ) ) |
188 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, | 188 | p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6, |
189 | *scalePixmap( w - 6, h - 6, | 189 | *scalePixmap( w - 6, h - 6, |
190 | type ) ); | 190 | type ) ); |
191 | else | 191 | else |
192 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, | 192 | p->fillRect( x + 4, y + 4, w - 6, h - offset * 6, |
193 | g.brush( QColorGroup::Button ) ); | 193 | g.brush( QColorGroup::Button ) ); |
194 | 194 | ||
195 | } | 195 | } |
196 | else { | 196 | else { |
197 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { | 197 | if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) { |
198 | if ( isPixmap( type ) ) | 198 | if ( isPixmap( type ) ) |
199 | if ( rounded ) | 199 | if ( rounded ) |
200 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); | 200 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); |
201 | else | 201 | else |
202 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, | 202 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, |
203 | h - offset * 2, | 203 | h - offset * 2, |
204 | *scalePixmap( w - offset * 2, h - offset * 2, | 204 | *scalePixmap( w - offset * 2, h - offset * 2, |
205 | type ) ); | 205 | type ) ); |
206 | else | 206 | else |
207 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, | 207 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, |
208 | g.brush( QColorGroup::Button ) ); | 208 | g.brush( QColorGroup::Button ) ); |
209 | } | 209 | } |
210 | if ( borderPixmap( type ) ) | 210 | if ( borderPixmap( type ) ) |
211 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, | 211 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, |
212 | Qt::CopyROP, false ); | 212 | Qt::CopyROP, false ); |
213 | else | 213 | else |
214 | drawShade( p, x, y, w, h, g, sunken, rounded, | 214 | drawShade( p, x, y, w, h, g, sunken, rounded, |
215 | highlightWidth( type ), borderWidth( type ), shade() ); | 215 | highlightWidth( type ), borderWidth( type ), shade() ); |
216 | } | 216 | } |
217 | p->setPen( oldPen ); | 217 | p->setPen( oldPen ); |
218 | } | 218 | } |
219 | 219 | ||
220 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 220 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
221 | const QColorGroup &g, bool sunken, | 221 | const QColorGroup &g, bool sunken, |
222 | const QBrush *fill ) | 222 | const QBrush *fill ) |
223 | { | 223 | { |
224 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? | 224 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? |
225 | PushButtonDown : PushButton, fill ); | 225 | PushButtonDown : PushButton, fill ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) | 228 | void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p ) |
229 | { | 229 | { |
230 | bool sunken = btn->isOn() || btn->isDown(); | 230 | bool sunken = btn->isOn() || btn->isDown(); |
231 | int diw = buttonDefaultIndicatorWidth(); | 231 | int diw = buttonDefaultIndicatorWidth(); |
232 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, | 232 | drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw, |
233 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : | 233 | *colorGroup( btn->colorGroup(), sunken ? PushButtonDown : |
234 | PushButton ), sunken, roundButton(), | 234 | PushButton ), sunken, roundButton(), |
235 | sunken ? PushButtonDown : PushButton, NULL ); | 235 | sunken ? PushButtonDown : PushButton, NULL ); |
236 | // TODO if diw, draw fancy default button indicator | 236 | // TODO if diw, draw fancy default button indicator |
237 | } | 237 | } |
238 | 238 | ||
239 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, | 239 | void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h, |
240 | bool round ) | 240 | bool round ) |
241 | { | 241 | { |
242 | // round edge fills | 242 | // round edge fills |
243 | static const QCOORD btm_left_fill[] = { | 243 | static const QCOORD btm_left_fill[] = { |
244 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, | 244 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, |
245 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 | 245 | 1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4 |
246 | }; | 246 | }; |
247 | 247 | ||
248 | static const QCOORD btm_right_fill[] = { | 248 | static const QCOORD btm_right_fill[] = { |
249 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, | 249 | 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, |
250 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 | 250 | 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4 |
251 | }; | 251 | }; |
252 | 252 | ||
253 | static const QCOORD top_left_fill[] = { | 253 | static const QCOORD top_left_fill[] = { |
254 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, | 254 | 3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3, |
255 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 255 | 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static const QCOORD top_right_fill[] = { | 258 | static const QCOORD top_right_fill[] = { |
259 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, | 259 | 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0, |
260 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 | 260 | 3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4 |
261 | }; | 261 | }; |
262 | 262 | ||
263 | QBrush fillBrush( color1, SolidPattern ); | 263 | QBrush fillBrush( color1, SolidPattern ); |
264 | p->setPen( color1 ); | 264 | p->setPen( color1 ); |
265 | if ( round && w > 19 && h > 19 ) { | 265 | if ( round && w > 19 && h > 19 ) { |
266 | int x2 = x + w - 1; | 266 | int x2 = x + w - 1; |
267 | int y2 = y + h - 1; | 267 | int y2 = y + h - 1; |
268 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); | 268 | QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill ); |
269 | a.translate( 1, 1 ); | 269 | a.translate( 1, 1 ); |
270 | p->drawPoints( a ); | 270 | p->drawPoints( a ); |
271 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); | 271 | a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill ); |
272 | a.translate( 1, h - 6 ); | 272 | a.translate( 1, h - 6 ); |
273 | p->drawPoints( a ); | 273 | p->drawPoints( a ); |
274 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); | 274 | a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill ); |
275 | a.translate( w - 6, 1 ); | 275 | a.translate( w - 6, 1 ); |
276 | p->drawPoints( a ); | 276 | p->drawPoints( a ); |
277 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); | 277 | a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill ); |
278 | a.translate( w - 6, h - 6 ); | 278 | a.translate( w - 6, h - 6 ); |
279 | p->drawPoints( a ); | 279 | p->drawPoints( a ); |
280 | 280 | ||
281 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); | 281 | p->fillRect( x + 6, y, w - 12, h, fillBrush ); |
282 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); | 282 | p->fillRect( x, y + 6, x + 6, h - 12, fillBrush ); |
283 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); | 283 | p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush ); |
284 | p->drawLine( x + 6, y, x2 - 6, y ); | 284 | p->drawLine( x + 6, y, x2 - 6, y ); |
285 | p->drawLine( x + 6, y2, x2 - 6, y2 ); | 285 | p->drawLine( x + 6, y2, x2 - 6, y2 ); |
286 | p->drawLine( x, y + 6, x, y2 - 6 ); | 286 | p->drawLine( x, y + 6, x, y2 - 6 ); |
287 | p->drawLine( x2, y + 6, x2, y2 - 6 ); | 287 | p->drawLine( x2, y + 6, x2, y2 - 6 ); |
288 | 288 | ||
289 | } | 289 | } |
290 | else | 290 | else |
291 | p->fillRect( x, y, w, h, fillBrush ); | 291 | p->fillRect( x, y, w, h, fillBrush ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) | 294 | void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h ) |
295 | { | 295 | { |
296 | drawBaseMask( p, x, y, w, h, roundButton() ); | 296 | drawBaseMask( p, x, y, w, h, roundButton() ); |
297 | } | 297 | } |
298 | 298 | ||
299 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) | 299 | void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h ) |
300 | { | 300 | { |
301 | drawBaseMask( p, x, y, w, h, roundComboBox() ); | 301 | drawBaseMask( p, x, y, w, h, roundComboBox() ); |
302 | } | 302 | } |
303 | 303 | ||
304 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 304 | void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
305 | const QColorGroup &g, bool sunken, | 305 | const QColorGroup &g, bool sunken, |
306 | const QBrush * ) | 306 | const QBrush * ) |
307 | { | 307 | { |
308 | WidgetType type = sunken ? BevelDown : Bevel; | 308 | WidgetType type = sunken ? BevelDown : Bevel; |
309 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | 309 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); |
310 | } | 310 | } |
311 | 311 | ||
312 | void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | ||
313 | const QColorGroup &g, bool sunken, | ||
314 | const QBrush * ) | ||
315 | { | ||
316 | WidgetType type = sunken ? ToolButtonDown : ToolButton; | ||
317 | drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type ); | ||
318 | } | ||
319 | |||
312 | #if 0 | 320 | #if 0 |
313 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, | 321 | void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h, |
314 | const QColorGroup &g, bool sunken, | 322 | const QColorGroup &g, bool sunken, |
315 | bool raised, bool enabled, bool popup, | 323 | bool raised, bool enabled, bool popup, |
316 | KToolButtonType type, const QString &btext, | 324 | KToolButtonType type, const QString &btext, |
317 | const QPixmap *pixmap, QFont *font, | 325 | const QPixmap *pixmap, QFont *font, |
318 | QWidget * ) | 326 | QWidget * ) |
319 | { | 327 | { |
320 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); | 328 | QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 ); |
321 | if ( font ) | 329 | if ( font ) |
322 | tmp_font = *font; | 330 | tmp_font = *font; |
323 | QFontMetrics fm( tmp_font ); | 331 | QFontMetrics fm( tmp_font ); |
324 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; | 332 | WidgetType widget = sunken ? ToolButtonDown : ToolButton; |
325 | 333 | ||
326 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, | 334 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false, |
327 | widget ); | 335 | widget ); |
328 | int dx, dy; | 336 | int dx, dy; |
329 | if ( type == Icon ) { // icon only | 337 | if ( type == Icon ) { // icon only |
330 | if ( pixmap ) { | 338 | if ( pixmap ) { |
331 | dx = ( w - pixmap->width() ) / 2; | 339 | dx = ( w - pixmap->width() ) / 2; |
332 | dy = ( h - pixmap->height() ) / 2; | 340 | dy = ( h - pixmap->height() ) / 2; |
333 | if ( sunken ) { | 341 | if ( sunken ) { |
334 | ++dx; | 342 | ++dx; |
335 | ++dy; | 343 | ++dy; |
336 | } | 344 | } |
337 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 345 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
338 | } | 346 | } |
339 | } | 347 | } |
340 | else if ( type == IconTextRight ) { // icon and text (if any) | 348 | else if ( type == IconTextRight ) { // icon and text (if any) |
341 | if ( pixmap ) { | 349 | if ( pixmap ) { |
342 | dx = 4; | 350 | dx = 4; |
343 | dy = ( h - pixmap->height() ) / 2; | 351 | dy = ( h - pixmap->height() ) / 2; |
344 | if ( sunken ) { | 352 | if ( sunken ) { |
345 | ++dx; | 353 | ++dx; |
346 | ++dy; | 354 | ++dy; |
347 | } | 355 | } |
348 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 356 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
349 | } | 357 | } |
350 | if ( !btext.isNull() ) { | 358 | if ( !btext.isNull() ) { |
351 | int tf = AlignVCenter | AlignLeft; | 359 | int tf = AlignVCenter | AlignLeft; |
352 | if ( pixmap ) | 360 | if ( pixmap ) |
353 | dx = 4 + pixmap->width() + 2; | 361 | dx = 4 + pixmap->width() + 2; |
354 | else | 362 | else |
355 | dx = 4; | 363 | dx = 4; |
356 | dy = 0; | 364 | dy = 0; |
357 | if ( sunken ) { | 365 | if ( sunken ) { |
358 | ++dx; | 366 | ++dx; |
359 | ++dy; | 367 | ++dy; |
360 | } | 368 | } |
361 | if ( font ) | 369 | if ( font ) |
362 | p->setFont( *font ); | 370 | p->setFont( *font ); |
363 | if ( raised ) | 371 | if ( raised ) |
364 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 372 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
365 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); | 373 | p->drawText( x + dx, y + dy, w - dx, h, tf, btext ); |
366 | } | 374 | } |
367 | } | 375 | } |
368 | else if ( type == Text ) { // only text, even if there is a icon | 376 | else if ( type == Text ) { // only text, even if there is a icon |
369 | if ( !btext.isNull() ) { | 377 | if ( !btext.isNull() ) { |
370 | int tf = AlignTop | AlignLeft; | 378 | int tf = AlignTop | AlignLeft; |
371 | if ( !enabled ) | 379 | if ( !enabled ) |
372 | p->setPen( g.dark() ); | 380 | p->setPen( g.dark() ); |
373 | dx = ( w - fm.width( btext ) ) / 2; | 381 | dx = ( w - fm.width( btext ) ) / 2; |
374 | dy = ( h - fm.lineSpacing() ) / 2; | 382 | dy = ( h - fm.lineSpacing() ) / 2; |
375 | if ( sunken ) { | 383 | if ( sunken ) { |
376 | ++dx; | 384 | ++dx; |
377 | ++dy; | 385 | ++dy; |
378 | } | 386 | } |
379 | if ( font ) | 387 | if ( font ) |
380 | p->setFont( *font ); | 388 | p->setFont( *font ); |
381 | if ( raised ) | 389 | if ( raised ) |
382 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 390 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
383 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); | 391 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); |
384 | } | 392 | } |
385 | } | 393 | } |
386 | else if ( type == IconTextBottom ) { | 394 | else if ( type == IconTextBottom ) { |
387 | if ( pixmap ) { | 395 | if ( pixmap ) { |
388 | dx = ( w - pixmap->width() ) / 2; | 396 | dx = ( w - pixmap->width() ) / 2; |
389 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; | 397 | dy = ( h - fm.lineSpacing() - pixmap->height() ) / 2; |
390 | if ( sunken ) { | 398 | if ( sunken ) { |
391 | ++dx; | 399 | ++dx; |
392 | ++dy; | 400 | ++dy; |
393 | } | 401 | } |
394 | p->drawPixmap( x + dx, y + dy, *pixmap ); | 402 | p->drawPixmap( x + dx, y + dy, *pixmap ); |
395 | } | 403 | } |
396 | if ( !btext.isNull() ) { | 404 | if ( !btext.isNull() ) { |
397 | int tf = AlignBottom | AlignHCenter; | 405 | int tf = AlignBottom | AlignHCenter; |
398 | dx = ( w - fm.width( btext ) ) / 2; | 406 | dx = ( w - fm.width( btext ) ) / 2; |
399 | dy = h - fm.lineSpacing() - 4; | 407 | dy = h - fm.lineSpacing() - 4; |
400 | if ( sunken ) { | 408 | if ( sunken ) { |
401 | ++dx; | 409 | ++dx; |
402 | ++dy; | 410 | ++dy; |
403 | } | 411 | } |
404 | if ( font ) | 412 | if ( font ) |
405 | p->setFont( *font ); | 413 | p->setFont( *font ); |
406 | if ( raised ) | 414 | if ( raised ) |
407 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); | 415 | p->setPen( KGlobalSettings::toolBarHighlightColor() ); |
408 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); | 416 | p->drawText( x + dx, y + dy, fm.width( btext ), fm.lineSpacing(), tf, btext ); |
409 | } | 417 | } |
410 | } | 418 | } |
411 | if ( popup ) { | 419 | if ( popup ) { |
412 | if ( enabled ) | 420 | if ( enabled ) |
413 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, | 421 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, 0, 0, |
414 | g, true ); | 422 | g, true ); |
415 | else | 423 | else |
416 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, | 424 | qDrawArrow ( p, DownArrow, WindowsStyle, false, w - 5, h - 5, |
417 | 0, 0, g, false ); | 425 | 0, 0, g, false ); |
418 | } | 426 | } |
419 | } | 427 | } |
420 | 428 | ||
421 | void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, | 429 | void OThemeStyle::drawKBarHandle( QPainter *p, int x, int y, int w, int h, |
422 | const QColorGroup &g, KToolBarPos, QBrush * ) | 430 | const QColorGroup &g, KToolBarPos, QBrush * ) |
423 | { | 431 | { |
424 | if ( w > h ) | 432 | if ( w > h ) |
425 | drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, | 433 | drawBaseButton( p, x, y, w, h, *colorGroup( g, HBarHandle ), false, false, |
426 | HBarHandle ); | 434 | HBarHandle ); |
427 | else | 435 | else |
428 | drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, | 436 | drawBaseButton( p, x, y, w, h, *colorGroup( g, VBarHandle ), false, false, |
429 | VBarHandle ); | 437 | VBarHandle ); |
430 | } | 438 | } |
431 | 439 | ||
432 | void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, | 440 | void OThemeStyle::drawKToolBar( QPainter *p, int x, int y, int w, int h, |
433 | const QColorGroup &g, KToolBarPos, QBrush * ) | 441 | const QColorGroup &g, KToolBarPos, QBrush * ) |
434 | { | 442 | { |
435 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, | 443 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ToolBar ), false, false, |
436 | ToolBar ); | 444 | ToolBar ); |
437 | } | 445 | } |
438 | #endif | 446 | #endif |
439 | 447 | ||
440 | QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) | 448 | QRect OThemeStyle::buttonRect( int x, int y, int w, int h ) |
441 | { | 449 | { |
442 | int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? | 450 | int spacing = decoWidth( PushButton ) > decoWidth( PushButtonDown ) ? |
443 | decoWidth( PushButton ) : decoWidth( PushButtonDown ); | 451 | decoWidth( PushButton ) : decoWidth( PushButtonDown ); |
444 | return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); | 452 | return ( QRect( x + spacing, y + spacing, w - ( spacing * 2 ), h - ( spacing * 2 ) ) ); |
445 | } | 453 | } |
446 | 454 | ||
447 | void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, | 455 | void OThemeStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, |
448 | const QColorGroup &g, bool sunken, bool, | 456 | const QColorGroup &g, bool sunken, bool, |
449 | bool, const QBrush * ) | 457 | bool, const QBrush * ) |
450 | { | 458 | { |
451 | WidgetType widget = sunken ? ComboBoxDown : ComboBox; | 459 | WidgetType widget = sunken ? ComboBoxDown : ComboBox; |
452 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, | 460 | drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, |
453 | roundComboBox(), widget ); | 461 | roundComboBox(), widget ); |
454 | if ( !sunken && isPixmap( ComboDeco ) ) | 462 | if ( !sunken && isPixmap( ComboDeco ) ) |
455 | p->drawPixmap( w - uncached( ComboDeco ) ->width() - | 463 | p->drawPixmap( w - uncached( ComboDeco ) ->width() - |
456 | decoWidth( ComboBox ) - 2, | 464 | decoWidth( ComboBox ) - 2, |
457 | y + ( h - uncached( ComboDeco ) -> | 465 | y + ( h - uncached( ComboDeco ) -> |
458 | height() ) / 2, *uncached( ComboDeco ) ); | 466 | height() ) / 2, *uncached( ComboDeco ) ); |
459 | else if ( sunken && isPixmap( ComboDecoDown ) ) | 467 | else if ( sunken && isPixmap( ComboDecoDown ) ) |
460 | p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - | 468 | p->drawPixmap( w - uncached( ComboDecoDown ) ->width() - |
461 | decoWidth( ComboBoxDown ) - 2, | 469 | decoWidth( ComboBoxDown ) - 2, |
462 | y + ( h - uncached( ComboDecoDown ) -> | 470 | y + ( h - uncached( ComboDecoDown ) -> |
463 | height() ) / 2, *uncached( ComboDecoDown ) ); | 471 | height() ) / 2, *uncached( ComboDecoDown ) ); |
464 | else { | 472 | else { |
465 | qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, | 473 | qDrawArrow( p, Qt::DownArrow, Qt::MotifStyle, false, w - 15, y + 6, 10, |
466 | h - 15, *colorGroup( g, widget ), true ); | 474 | h - 15, *colorGroup( g, widget ), true ); |
467 | qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); | 475 | qDrawShadeRect( p, w - 14, y + 7 + ( h - 15 ), 10, 3, *colorGroup( g, widget ) ); |
468 | } | 476 | } |
469 | } | 477 | } |
470 | 478 | ||
471 | void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, | 479 | void OThemeStyle::drawScrollBarControls( QPainter *p, const QScrollBar *sb, |
472 | int sliderStart, uint controls, | 480 | int sliderStart, uint controls, |
473 | uint activeControl ) | 481 | uint activeControl ) |
474 | { | 482 | { |
475 | int sliderMin, sliderMax, sliderLength, buttonDim; | 483 | int sliderMin, sliderMax, sliderLength, buttonDim; |
476 | QRect add | 484 | QRect add |
477 | , sub, addPage, subPage, slider; | 485 | , sub, addPage, subPage, slider; |
478 | int addX, addY, subX, subY; | 486 | int addX, addY, subX, subY; |
479 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; | 487 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; |
480 | int len = ( horizontal ) ? sb->width() : sb->height(); | 488 | int len = ( horizontal ) ? sb->width() : sb->height(); |
481 | int extent = ( horizontal ) ? sb->height() : sb->width(); | 489 | int extent = ( horizontal ) ? sb->height() : sb->width(); |
482 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); | 490 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); |
483 | QColorGroup g = sb->colorGroup(); | 491 | QColorGroup g = sb->colorGroup(); |
484 | 492 | ||
485 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 493 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
486 | if ( sliderStart > sliderMax ) | 494 | if ( sliderStart > sliderMax ) |
487 | sliderStart = sliderMax; | 495 | sliderStart = sliderMax; |
488 | 496 | ||
489 | int sliderEnd = sliderStart + sliderLength; | 497 | int sliderEnd = sliderStart + sliderLength; |
490 | int sliderWidth = extent - offset * 2; | 498 | int sliderWidth = extent - offset * 2; |
491 | 499 | ||
492 | // Scary button placement code >:-P Feel free to improve this if you | 500 | // Scary button placement code >:-P Feel free to improve this if you |
493 | // want. I get a headache just looking at it... (mosfet) | 501 | // want. I get a headache just looking at it... (mosfet) |
494 | if ( scrollBarLayout() == SBOpposite ) { | 502 | if ( scrollBarLayout() == SBOpposite ) { |
495 | if ( horizontal ) { | 503 | if ( horizontal ) { |
496 | subY = addY = ( extent - buttonDim ) / 2; | 504 | subY = addY = ( extent - buttonDim ) / 2; |
497 | subX = offset; | 505 | subX = offset; |
498 | addX = len - buttonDim - offset; | 506 | addX = len - buttonDim - offset; |
499 | } | 507 | } |
500 | else { | 508 | else { |
501 | subX = addX = ( extent - buttonDim ) / 2; | 509 | subX = addX = ( extent - buttonDim ) / 2; |
502 | subY = offset; | 510 | subY = offset; |
503 | addY = len - buttonDim - offset; | 511 | addY = len - buttonDim - offset; |
504 | } | 512 | } |
505 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 513 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
506 | add.setRect( addX, addY, buttonDim, buttonDim ); | 514 | add.setRect( addX, addY, buttonDim, buttonDim ); |
507 | if ( horizontal ) { | 515 | if ( horizontal ) { |
508 | subPage.setRect( sub.right() + 1, offset, | 516 | subPage.setRect( sub.right() + 1, offset, |
509 | sliderStart - sub.right() - 1 , sliderWidth ); | 517 | sliderStart - sub.right() - 1 , sliderWidth ); |
510 | addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); | 518 | addPage.setRect( sliderEnd, offset, addX - sliderEnd, sliderWidth ); |
511 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); | 519 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); |
512 | } | 520 | } |
513 | else { | 521 | else { |
514 | subPage.setRect( offset, sub.bottom() + 1, sliderWidth, | 522 | subPage.setRect( offset, sub.bottom() + 1, sliderWidth, |
515 | sliderStart - sub.bottom() - 1 ); | 523 | sliderStart - sub.bottom() - 1 ); |
516 | addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); | 524 | addPage.setRect( offset, sliderEnd, sliderWidth, addY - sliderEnd ); |
517 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); | 525 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); |
518 | } | 526 | } |
519 | } | 527 | } |
520 | else if ( horizontal ) { | 528 | else if ( horizontal ) { |
521 | subY = addY = ( extent - buttonDim ) / 2; | 529 | subY = addY = ( extent - buttonDim ) / 2; |
522 | if ( scrollBarLayout() == SBBottomLeft ) { | 530 | if ( scrollBarLayout() == SBBottomLeft ) { |
523 | subX = offset; | 531 | subX = offset; |
524 | addX = buttonDim + offset; | 532 | addX = buttonDim + offset; |
525 | subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); | 533 | subPage.setRect( buttonDim * 2, 0, sliderStart - 1, extent ); |
526 | addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); | 534 | addPage.setRect( sliderEnd, 0, len - sliderEnd, extent ); |
527 | slider.setRect( sliderStart, 0, sliderLength, extent ); | 535 | slider.setRect( sliderStart, 0, sliderLength, extent ); |
528 | } | 536 | } |
529 | else { | 537 | else { |
530 | subX = len - buttonDim - buttonDim - offset; | 538 | subX = len - buttonDim - buttonDim - offset; |
531 | addX = len - buttonDim - offset; | 539 | addX = len - buttonDim - offset; |
532 | subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); | 540 | subPage.setRect( offset + 1, offset, sliderStart - 1 , sliderWidth ); |
533 | addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); | 541 | addPage.setRect( sliderEnd, offset, subX - sliderEnd, sliderWidth ); |
534 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); | 542 | slider.setRect( sliderStart, offset, sliderLength, sliderWidth ); |
535 | } | 543 | } |
536 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 544 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
537 | add.setRect( addX, addY, buttonDim, buttonDim ); | 545 | add.setRect( addX, addY, buttonDim, buttonDim ); |
538 | } | 546 | } |
539 | else { // BottomLeft and BottomRight vertical bars are the same. | 547 | else { // BottomLeft and BottomRight vertical bars are the same. |
540 | subX = addX = ( extent - buttonDim ) / 2; | 548 | subX = addX = ( extent - buttonDim ) / 2; |
541 | subY = len - buttonDim - buttonDim - offset; | 549 | subY = len - buttonDim - buttonDim - offset; |
542 | addY = len - buttonDim - offset; | 550 | addY = len - buttonDim - offset; |
543 | subPage.setRect( offset, offset + 1, sliderWidth, | 551 | subPage.setRect( offset, offset + 1, sliderWidth, |
544 | sliderStart - offset - 1 ); | 552 | sliderStart - offset - 1 ); |
545 | addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); | 553 | addPage.setRect( offset, sliderEnd, sliderWidth, subY - sliderEnd ); |
546 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); | 554 | slider.setRect( offset, sliderStart, sliderWidth, sliderLength ); |
547 | sub.setRect( subX, subY, buttonDim, buttonDim ); | 555 | sub.setRect( subX, subY, buttonDim, buttonDim ); |
548 | add.setRect( addX, addY, buttonDim, buttonDim ); | 556 | add.setRect( addX, addY, buttonDim, buttonDim ); |
549 | } | 557 | } |
550 | // End of the button placement code | 558 | // End of the button placement code |
551 | 559 | ||
552 | bool active; | 560 | bool active; |
553 | if ( ( controls & QStyle::SubPage ) ) { | 561 | if ( ( controls & QStyle::SubPage ) ) { |
554 | drawScrollBarGroove( p, sb, horizontal, subPage, g ); | 562 | drawScrollBarGroove( p, sb, horizontal, subPage, g ); |
555 | } | 563 | } |
556 | if ( ( controls & QStyle::AddPage ) ) { | 564 | if ( ( controls & QStyle::AddPage ) ) { |
557 | drawScrollBarGroove( p, sb, horizontal, addPage, g ); | 565 | drawScrollBarGroove( p, sb, horizontal, addPage, g ); |
558 | } | 566 | } |
559 | if ( controls & QStyle::AddLine ) { | 567 | if ( controls & QStyle::AddLine ) { |
560 | active = activeControl == QStyle::AddLine; | 568 | active = activeControl == QStyle::AddLine; |
561 | drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), | 569 | drawBaseButton( p, add.x(), add.y(), add.width(), add.height(), |
562 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), | 570 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), |
563 | active, false, active ? ScrollButtonDown : ScrollButton ); | 571 | active, false, active ? ScrollButtonDown : ScrollButton ); |
564 | drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, | 572 | drawArrow( p, ( horizontal ) ? RightArrow : DownArrow, active, add.x() + 3, |
565 | add.y() + 3, add.width() - 6, add.height() - 6, | 573 | add.y() + 3, add.width() - 6, add.height() - 6, |
566 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); | 574 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); |
567 | } | 575 | } |
568 | if ( controls & QStyle::SubLine ) { | 576 | if ( controls & QStyle::SubLine ) { |
569 | active = activeControl == QStyle::SubLine; | 577 | active = activeControl == QStyle::SubLine; |
570 | p->setPen( g.dark() ); | 578 | p->setPen( g.dark() ); |
571 | p->drawRect( sub ); | 579 | p->drawRect( sub ); |
572 | drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), | 580 | drawBaseButton( p, sub.x(), sub.y(), sub.width(), sub.height(), |
573 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), | 581 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ), |
574 | active, false, active ? ScrollButtonDown : ScrollButton ); | 582 | active, false, active ? ScrollButtonDown : ScrollButton ); |
575 | drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, | 583 | drawArrow( p, ( horizontal ) ? LeftArrow : UpArrow, active, sub.x() + 3, |
576 | sub.y() + 3, sub.width() - 6, sub.height() - 6, | 584 | sub.y() + 3, sub.width() - 6, sub.height() - 6, |
577 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); | 585 | *colorGroup( g, active ? ScrollButtonDown : ScrollButton ) ); |
578 | } | 586 | } |
579 | if ( controls & QStyle::Slider ) { | 587 | if ( controls & QStyle::Slider ) { |
580 | active = activeControl == QStyle::Slider; | 588 | active = activeControl == QStyle::Slider; |
581 | WidgetType widget = horizontal ? | 589 | WidgetType widget = horizontal ? |
582 | active ? HScrollBarSliderDown : HScrollBarSlider : | 590 | active ? HScrollBarSliderDown : HScrollBarSlider : |
583 | active ? VScrollBarSliderDown : VScrollBarSlider; | 591 | active ? VScrollBarSliderDown : VScrollBarSlider; |
584 | 592 | ||
585 | drawBaseButton( p, slider.x(), slider.y(), slider.width(), | 593 | drawBaseButton( p, slider.x(), slider.y(), slider.width(), |
586 | slider.height(), *colorGroup( g, widget ), active, false, | 594 | slider.height(), *colorGroup( g, widget ), active, false, |
587 | widget ); | 595 | widget ); |
588 | int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : | 596 | int spaceW = horizontal ? slider.width() - decoWidth( widget ) - 4 : |
589 | slider.width(); | 597 | slider.width(); |
590 | int spaceH = horizontal ? slider.height() : | 598 | int spaceH = horizontal ? slider.height() : |
591 | slider.height() - decoWidth( widget ) - 4; | 599 | slider.height() - decoWidth( widget ) - 4; |
592 | widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : | 600 | widget = active ? horizontal ? HScrollDecoDown : VScrollDecoDown : |
593 | horizontal ? HScrollDeco : VScrollDeco; | 601 | horizontal ? HScrollDeco : VScrollDeco; |
594 | if ( isPixmap( widget ) ) { | 602 | if ( isPixmap( widget ) ) { |
595 | if ( spaceW >= uncached( widget ) ->width() && | 603 | if ( spaceW >= uncached( widget ) ->width() && |
596 | spaceH >= uncached( widget ) ->height() ) { | 604 | spaceH >= uncached( widget ) ->height() ) { |
597 | p->drawPixmap( slider.x() + ( slider.width() - | 605 | p->drawPixmap( slider.x() + ( slider.width() - |
598 | uncached( widget ) ->width() ) / 2, | 606 | uncached( widget ) ->width() ) / 2, |
599 | slider.y() + ( slider.height() - | 607 | slider.y() + ( slider.height() - |
600 | uncached( widget ) ->height() ) / 2, | 608 | uncached( widget ) ->height() ) / 2, |
601 | *uncached( widget ) ); | 609 | *uncached( widget ) ); |
602 | } | 610 | } |
603 | } | 611 | } |
604 | } | 612 | } |
605 | } | 613 | } |
606 | 614 | ||
607 | void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, | 615 | void OThemeStyle::drawScrollBarGroove( QPainter *p, const QScrollBar *sb, |
608 | bool horizontal, QRect r, QColorGroup g ) | 616 | bool horizontal, QRect r, QColorGroup g ) |
609 | 617 | ||
610 | { | 618 | { |
611 | WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; | 619 | WidgetType widget = ( horizontal ) ? HScrollGroove : VScrollGroove; |
612 | if ( !isPixmap( widget ) ) { | 620 | if ( !isPixmap( widget ) ) { |
613 | p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); | 621 | p->fillRect( r, colorGroup( g, widget ) ->brush( QColorGroup::Background ) ); |
614 | } | 622 | } |
615 | else { | 623 | else { |
616 | // If the groove is pixmapped we make a full-sized image (it gets | 624 | // If the groove is pixmapped we make a full-sized image (it gets |
617 | // cached) then bitBlt it to the appropriate rect. | 625 | // cached) then bitBlt it to the appropriate rect. |
618 | QPixmap buffer( sb->size() ); | 626 | QPixmap buffer( sb->size() ); |
619 | QPainter bPainter( &buffer ); | 627 | QPainter bPainter( &buffer ); |
620 | bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), | 628 | bPainter.drawTiledPixmap( 0, 0, buffer.width(), buffer.height(), |
621 | *scalePixmap( buffer.width(), buffer.height(), | 629 | *scalePixmap( buffer.width(), buffer.height(), |
622 | widget ) ); | 630 | widget ) ); |
623 | bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), | 631 | bitBlt( p->device(), r.x(), r.y(), &buffer, r.x(), r.y(), r.width(), |
624 | r.height(), Qt::CopyROP ); | 632 | r.height(), Qt::CopyROP ); |
625 | } | 633 | } |
626 | // Do the borders and frame | 634 | // Do the borders and frame |
627 | drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), | 635 | drawShade( p, sb->rect().x(), sb->rect().y(), sb->rect().width(), |
628 | sb->rect().height(), *colorGroup( g, widget ), true, false, | 636 | sb->rect().height(), *colorGroup( g, widget ), true, false, |
629 | highlightWidth( widget ), borderWidth( widget ), shade() ); | 637 | highlightWidth( widget ), borderWidth( widget ), shade() ); |
630 | } | 638 | } |
631 | 639 | ||
632 | void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, | 640 | void OThemeStyle::scrollBarMetrics( const QScrollBar *sb, int &sliderMin, |
633 | int &sliderMax, int &sliderLength, | 641 | int &sliderMax, int &sliderLength, |
634 | int &buttonDim ) | 642 | int &buttonDim ) |
635 | { | 643 | { |
636 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; | 644 | bool horizontal = sb->orientation() == QScrollBar::Horizontal; |
637 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); | 645 | int offset = decoWidth( horizontal ? HScrollGroove : VScrollGroove ); |
638 | int maxlen; | 646 | int maxlen; |
639 | int len = horizontal ? sb->width() : sb->height(); | 647 | int len = horizontal ? sb->width() : sb->height(); |
640 | int extent = horizontal ? sb->height() : sb->width(); | 648 | int extent = horizontal ? sb->height() : sb->width(); |
641 | 649 | ||
642 | if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) | 650 | if ( len > ( extent - offset * 2 - 1 ) * 2 + offset * 2 ) |
643 | buttonDim = extent - offset * 2; | 651 | buttonDim = extent - offset * 2; |
644 | else | 652 | else |
645 | buttonDim = ( len - offset * 2 ) / 2 - 1; | 653 | buttonDim = ( len - offset * 2 ) / 2 - 1; |
646 | maxlen = len - offset * 2 - buttonDim * 2 - 1; | 654 | maxlen = len - offset * 2 - buttonDim * 2 - 1; |
647 | 655 | ||
648 | switch ( scrollBarLayout() ) { | 656 | switch ( scrollBarLayout() ) { |
649 | case SBBottomLeft: | 657 | case SBBottomLeft: |
650 | sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; | 658 | sliderMin = ( horizontal ) ? buttonDim * 2 + offset + 1 : offset + 1; |
651 | break; | 659 | break; |
652 | case SBBottomRight: | 660 | case SBBottomRight: |
653 | sliderMin = offset + 1; | 661 | sliderMin = offset + 1; |
654 | break; | 662 | break; |
655 | case SBOpposite: | 663 | case SBOpposite: |
656 | default: | 664 | default: |
657 | sliderMin = offset + buttonDim; | 665 | sliderMin = offset + buttonDim; |
658 | break; | 666 | break; |
659 | } | 667 | } |
660 | if ( sb->maxValue() == sb->minValue() ) | 668 | if ( sb->maxValue() == sb->minValue() ) |
661 | sliderLength = maxlen; | 669 | sliderLength = maxlen; |
662 | else | 670 | else |
663 | sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - | 671 | sliderLength = ( sb->pageStep() * maxlen ) / ( sb->maxValue() - |
664 | sb->minValue() + sb->pageStep() ); | 672 | sb->minValue() + sb->pageStep() ); |
665 | if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) | 673 | if ( sliderLength < 12 || ( sb->maxValue() - sb->minValue() ) > INT_MAX / 2 ) |
666 | sliderLength = 12; | 674 | sliderLength = 12; |
667 | if ( sliderLength > maxlen ) | 675 | if ( sliderLength > maxlen ) |
668 | sliderLength = maxlen; | 676 | sliderLength = maxlen; |
669 | sliderMax = sliderMin + maxlen - sliderLength; | 677 | sliderMax = sliderMin + maxlen - sliderLength; |
670 | } | 678 | } |
671 | 679 | ||
672 | QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb, | 680 | QStyle::ScrollControl OThemeStyle::scrollBarPointOver( const QScrollBar *sb, |
673 | int sliderStart, | 681 | int sliderStart, |
674 | const QPoint &p ) | 682 | const QPoint &p ) |
675 | { | 683 | { |
676 | if ( !sb->rect().contains( p ) ) | 684 | if ( !sb->rect().contains( p ) ) |
677 | return ( QStyle::NoScroll ); | 685 | return ( QStyle::NoScroll ); |
678 | int sliderMin, sliderMax, sliderLength, buttonDim; | 686 | int sliderMin, sliderMax, sliderLength, buttonDim; |
679 | int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y(); | 687 | int pos = ( sb->orientation() == QScrollBar::Horizontal ) ? p.x() : p.y(); |
680 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 688 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
681 | 689 | ||
682 | if ( scrollBarLayout() == SBOpposite ) { | 690 | if ( scrollBarLayout() == SBOpposite ) { |
683 | if ( pos < sliderMin ) | 691 | if ( pos < sliderMin ) |
684 | return QStyle::SubLine; | 692 | return QStyle::SubLine; |
685 | if ( pos < sliderStart ) | 693 | if ( pos < sliderStart ) |
686 | return SubPage; | 694 | return SubPage; |
687 | if ( pos < sliderStart + sliderLength ) | 695 | if ( pos < sliderStart + sliderLength ) |
688 | return QStyle::Slider; | 696 | return QStyle::Slider; |
689 | if ( pos < sliderMax + sliderLength ) | 697 | if ( pos < sliderMax + sliderLength ) |
690 | return QStyle::AddPage; | 698 | return QStyle::AddPage; |
691 | return QStyle::AddLine; | 699 | return QStyle::AddLine; |
692 | } | 700 | } |
693 | if ( scrollBarLayout() == SBBottomLeft && sb->orientation() == | 701 | if ( scrollBarLayout() == SBBottomLeft && sb->orientation() == |
694 | QScrollBar::Horizontal ) { | 702 | QScrollBar::Horizontal ) { |
695 | if ( pos <= buttonDim ) | 703 | if ( pos <= buttonDim ) |
696 | return ( QStyle::SubLine ); | 704 | return ( QStyle::SubLine ); |
697 | else if ( pos <= buttonDim * 2 ) | 705 | else if ( pos <= buttonDim * 2 ) |
698 | return ( QStyle::AddLine ); | 706 | return ( QStyle::AddLine ); |
699 | else if ( pos < sliderStart ) | 707 | else if ( pos < sliderStart ) |
700 | return ( QStyle::SubPage ); | 708 | return ( QStyle::SubPage ); |
701 | else if ( pos < sliderStart + sliderLength ) | 709 | else if ( pos < sliderStart + sliderLength ) |
702 | return ( QStyle::Slider ); | 710 | return ( QStyle::Slider ); |
703 | return ( AddPage ); | 711 | return ( AddPage ); |
704 | } | 712 | } |
705 | else { | 713 | else { |
706 | if ( pos < sliderStart ) | 714 | if ( pos < sliderStart ) |
707 | return QStyle::SubPage; | 715 | return QStyle::SubPage; |
708 | if ( pos < sliderStart + sliderLength ) | 716 | if ( pos < sliderStart + sliderLength ) |
709 | return QStyle::Slider; | 717 | return QStyle::Slider; |
710 | if ( pos < sliderMax + sliderLength ) | 718 | if ( pos < sliderMax + sliderLength ) |
711 | return QStyle::AddPage; | 719 | return QStyle::AddPage; |
712 | if ( pos < sliderMax + sliderLength + buttonDim ) | 720 | if ( pos < sliderMax + sliderLength + buttonDim ) |
713 | return QStyle::SubLine; | 721 | return QStyle::SubLine; |
714 | return QStyle::AddLine; | 722 | return QStyle::AddLine; |
715 | } | 723 | } |
716 | } | 724 | } |
717 | 725 | ||
718 | QSize OThemeStyle::exclusiveIndicatorSize() const | 726 | QSize OThemeStyle::exclusiveIndicatorSize() const |
719 | { | 727 | { |
720 | if ( isPixmap( ExIndicatorOn ) ) | 728 | if ( isPixmap( ExIndicatorOn ) ) |
721 | return ( uncached( ExIndicatorOn ) ->size() ); | 729 | return ( uncached( ExIndicatorOn ) ->size() ); |
722 | else | 730 | else |
723 | return ( QWindowsStyle::exclusiveIndicatorSize() ); | 731 | return ( QWindowsStyle::exclusiveIndicatorSize() ); |
724 | } | 732 | } |
725 | 733 | ||
726 | QSize OThemeStyle::indicatorSize() const | 734 | QSize OThemeStyle::indicatorSize() const |
727 | { | 735 | { |
728 | if ( isPixmap( IndicatorOn ) ) | 736 | if ( isPixmap( IndicatorOn ) ) |
729 | return ( uncached( IndicatorOn ) ->size() ); | 737 | return ( uncached( IndicatorOn ) ->size() ); |
730 | else | 738 | else |
731 | return ( QWindowsStyle::indicatorSize() ); | 739 | return ( QWindowsStyle::indicatorSize() ); |
732 | } | 740 | } |
733 | 741 | ||
734 | void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, | 742 | void OThemeStyle::drawExclusiveIndicator( QPainter* p, int x, int y, int w, |
735 | int h, const QColorGroup &g, bool on, | 743 | int h, const QColorGroup &g, bool on, |
736 | bool down, bool enabled ) | 744 | bool down, bool enabled ) |
737 | { | 745 | { |
738 | if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) { | 746 | if ( isPixmap( ( on || down ) ? ExIndicatorOn : ExIndicatorOff ) ) { |
739 | p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn : | 747 | p->drawPixmap( x, y, *uncached( ( on || down ) ? ExIndicatorOn : |
740 | ExIndicatorOff ) ); | 748 | ExIndicatorOff ) ); |
741 | } | 749 | } |
742 | else { | 750 | else { |
743 | QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h, | 751 | QWindowsStyle::drawExclusiveIndicator( p, x, y, w, h, |
744 | *colorGroup( g, ExIndicatorOn ), | 752 | *colorGroup( g, ExIndicatorOn ), |
745 | on, down, enabled ); | 753 | on, down, enabled ); |
746 | } | 754 | } |
747 | 755 | ||
748 | } | 756 | } |
749 | 757 | ||
750 | void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, | 758 | void OThemeStyle::drawIndicator( QPainter* p, int x, int y, int w, int h, |
751 | const QColorGroup &g, int state, bool down, | 759 | const QColorGroup &g, int state, bool down, |
752 | bool enabled ) | 760 | bool enabled ) |
753 | { | 761 | { |
754 | if ( isPixmap( ( down || state != QButton::Off ) ? | 762 | if ( isPixmap( ( down || state != QButton::Off ) ? |
755 | IndicatorOn : IndicatorOff ) ) { | 763 | IndicatorOn : IndicatorOff ) ) { |
756 | p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ? | 764 | p->drawPixmap( x, y, *uncached( ( down || state != QButton::Off ) ? |
757 | IndicatorOn : IndicatorOff ) ); | 765 | IndicatorOn : IndicatorOff ) ); |
758 | } | 766 | } |
759 | else { | 767 | else { |
760 | QWindowsStyle::drawIndicator( p, x, y, w, h, | 768 | QWindowsStyle::drawIndicator( p, x, y, w, h, |
761 | *colorGroup( g, IndicatorOn ), state, | 769 | *colorGroup( g, IndicatorOn ), state, |
762 | down, enabled ); | 770 | down, enabled ); |
763 | } | 771 | } |
764 | } | 772 | } |
765 | 773 | ||
766 | void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, | 774 | void OThemeStyle::drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, |
767 | int h, bool on ) | 775 | int h, bool on ) |
768 | { | 776 | { |
769 | if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) { | 777 | if ( isPixmap( ( on ) ? ExIndicatorOn : ExIndicatorOff ) ) { |
770 | const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) -> | 778 | const QBitmap * mask = uncached( ( on ) ? ExIndicatorOn : ExIndicatorOff ) -> |
771 | mask(); | 779 | mask(); |
772 | if ( mask ) { | 780 | if ( mask ) { |
773 | p->drawPixmap( x, y, *mask ); | 781 | p->drawPixmap( x, y, *mask ); |
774 | } | 782 | } |
775 | else | 783 | else |
776 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 784 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
777 | } | 785 | } |
778 | else | 786 | else |
779 | QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on ); | 787 | QWindowsStyle::drawExclusiveIndicatorMask( p, x, y, w, h, on ); |
780 | } | 788 | } |
781 | 789 | ||
782 | void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, | 790 | void OThemeStyle::drawIndicatorMask( QPainter *p, int x, int y, int w, int h, |
783 | int state ) | 791 | int state ) |
784 | { | 792 | { |
785 | if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) { | 793 | if ( isPixmap( ( state != QButton::Off ) ? IndicatorOn : IndicatorOff ) ) { |
786 | const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn : | 794 | const QBitmap * mask = uncached( ( state != QButton::Off ) ? IndicatorOn : |
787 | IndicatorOff ) ->mask(); | 795 | IndicatorOff ) ->mask(); |
788 | if ( mask ) | 796 | if ( mask ) |
789 | p->drawPixmap( x, y, *mask ); | 797 | p->drawPixmap( x, y, *mask ); |
790 | else | 798 | else |
791 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 799 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
792 | } | 800 | } |
793 | else | 801 | else |
794 | QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state ); | 802 | QWindowsStyle::drawIndicatorMask( p, x, y, w, h, state ); |
795 | } | 803 | } |
796 | 804 | ||
797 | void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, | 805 | void OThemeStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, |
798 | const QColorGroup& g, QCOORD c, | 806 | const QColorGroup& g, QCOORD c, |
799 | Orientation orient ) | 807 | Orientation orient ) |
800 | { | 808 | { |
801 | if ( roundSlider() ) | 809 | if ( roundSlider() ) |
802 | QWindowsStyle::drawSliderGroove( p, x, y, w, h, | 810 | QWindowsStyle::drawSliderGroove( p, x, y, w, h, |
803 | *colorGroup( g, SliderGroove ), | 811 | *colorGroup( g, SliderGroove ), |
804 | c, orient ); | 812 | c, orient ); |
805 | else | 813 | else |
806 | drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true, | 814 | drawBaseButton( p, x, y, w, h, *colorGroup( g, SliderGroove ), true, |
807 | false, SliderGroove ); | 815 | false, SliderGroove ); |
808 | } | 816 | } |
809 | 817 | ||
810 | void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, | 818 | void OThemeStyle::drawSlider( QPainter *p, int x, int y, int w, int h, |
811 | const QColorGroup &g, Orientation orient, | 819 | const QColorGroup &g, Orientation orient, |
812 | bool tickAbove, bool tickBelow ) | 820 | bool tickAbove, bool tickBelow ) |
813 | { | 821 | { |
814 | if ( isPixmap( Slider ) ) { | 822 | if ( isPixmap( Slider ) ) { |
815 | if ( orient == Qt::Horizontal ) | 823 | if ( orient == Qt::Horizontal ) |
816 | p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2, | 824 | p->drawPixmap( x, y + ( h - uncached( Slider ) ->height() ) / 2, |
817 | *uncached( Slider ) ); | 825 | *uncached( Slider ) ); |
818 | else | 826 | else |
819 | p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2, | 827 | p->drawPixmap( x + ( w - uncached( Slider ) ->width() ) / 2, |
820 | y, *uncached( Slider ) ); | 828 | y, *uncached( Slider ) ); |
821 | } | 829 | } |
822 | else { | 830 | else { |
823 | QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ), | 831 | QWindowsStyle::drawSlider( p, x, y, w, h, *colorGroup( g, Slider ), |
824 | orient, tickAbove, tickBelow ); | 832 | orient, tickAbove, tickBelow ); |
825 | } | 833 | } |
826 | } | 834 | } |
827 | 835 | ||
828 | void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, | 836 | void OThemeStyle::drawSliderMask( QPainter *p, int x, int y, int w, int h, |
829 | Orientation orient, bool tickAbove, | 837 | Orientation orient, bool tickAbove, |
830 | bool tickBelow ) | 838 | bool tickBelow ) |
831 | { | 839 | { |
832 | // This is odd. If we fill in the entire region it still masks the slider | 840 | // This is odd. If we fill in the entire region it still masks the slider |
833 | // properly. I have no idea, this used to be different in Qt betas... | 841 | // properly. I have no idea, this used to be different in Qt betas... |
834 | if ( isPixmap( Slider ) ) | 842 | if ( isPixmap( Slider ) ) |
835 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); | 843 | p->fillRect( x, y, w, h, QBrush( color1, SolidPattern ) ); |
836 | else | 844 | else |
837 | QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, | 845 | QWindowsStyle::drawSliderMask( p, x, y, w, h, orient, tickAbove, |
838 | tickBelow ); | 846 | tickBelow ); |
839 | } | 847 | } |
840 | 848 | ||
841 | int OThemeStyle::defaultFrameWidth() const | 849 | int OThemeStyle::defaultFrameWidth() const |
842 | { | 850 | { |
843 | return ( frameWidth() ); | 851 | return ( frameWidth() ); |
844 | } | 852 | } |
845 | 853 | ||
846 | void OThemeStyle::getButtonShift( int &x, int &y ) | 854 | void OThemeStyle::getButtonShift( int &x, int &y ) |
847 | { | 855 | { |
848 | x = buttonXShift(); | 856 | x = buttonXShift(); |
849 | y = buttonYShift(); | 857 | y = buttonYShift(); |
850 | } | 858 | } |
851 | 859 | ||
852 | int OThemeStyle::sliderLength() const | 860 | int OThemeStyle::sliderLength() const |
853 | { | 861 | { |
854 | return ( sliderButtonLength() ); | 862 | return ( sliderButtonLength() ); |
855 | } | 863 | } |
856 | 864 | ||
857 | void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, | 865 | void OThemeStyle::drawArrow( QPainter *p, Qt::ArrowType type, bool down, int x, |
858 | int y, int w, int h, const QColorGroup &g, | 866 | int y, int w, int h, const QColorGroup &g, |
859 | bool enabled, const QBrush * ) | 867 | bool enabled, const QBrush * ) |
860 | { | 868 | { |
861 | // Handles pixmapped arrows. A little inefficent because you can specify | 869 | // Handles pixmapped arrows. A little inefficent because you can specify |
862 | // some as pixmaps and some as default types. | 870 | // some as pixmaps and some as default types. |
863 | WidgetType widget; | 871 | WidgetType widget; |
864 | switch ( type ) { | 872 | switch ( type ) { |
865 | case UpArrow: | 873 | case UpArrow: |
866 | widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; | 874 | widget = enabled ? down ? SunkenArrowUp : ArrowUp : DisArrowUp; |
867 | break; | 875 | break; |
868 | case DownArrow: | 876 | case DownArrow: |
869 | widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; | 877 | widget = enabled ? down ? SunkenArrowDown : ArrowDown : DisArrowDown; |
870 | break; | 878 | break; |
871 | case LeftArrow: | 879 | case LeftArrow: |
872 | widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; | 880 | widget = enabled ? down ? SunkenArrowLeft : ArrowLeft : DisArrowLeft; |
873 | break; | 881 | break; |
874 | case RightArrow: | 882 | case RightArrow: |
875 | default: | 883 | default: |
876 | widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; | 884 | widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight; |
877 | break; | 885 | break; |
878 | } | 886 | } |
879 | if ( isPixmap( widget ) ) { | 887 | if ( isPixmap( widget ) ) { |
880 | p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, | 888 | p->drawPixmap( x + ( w - uncached( widget ) ->width() ) / 2, |
881 | y + ( h - uncached( widget ) ->height() ) / 2, | 889 | y + ( h - uncached( widget ) ->height() ) / 2, |
882 | *uncached( widget ) ); | 890 | *uncached( widget ) ); |
883 | return ; | 891 | return ; |
884 | } | 892 | } |
885 | const QColorGroup *cg = colorGroup( g, widget ); | 893 | const QColorGroup *cg = colorGroup( g, widget ); |
886 | // Standard arrow types | 894 | // Standard arrow types |
887 | if ( arrowType() == MotifArrow ) | 895 | if ( arrowType() == MotifArrow ) |
888 | qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); | 896 | qDrawArrow( p, type, Qt::MotifStyle, down, x, y, w, h, *cg, enabled ); |
889 | else if ( arrowType() == SmallArrow ) { | 897 | else if ( arrowType() == SmallArrow ) { |
890 | QColorGroup tmp( *cg ); | 898 | QColorGroup tmp( *cg ); |
891 | tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); | 899 | tmp.setBrush( QColorGroup::Button, QBrush( NoBrush ) ); |
892 | QWindowsStyle::drawArrow( p, type, false, x, y, w, h, | 900 | QWindowsStyle::drawArrow( p, type, false, x, y, w, h, |
893 | tmp, true ); | 901 | tmp, true ); |
894 | } | 902 | } |
895 | else { | 903 | else { |
896 | QPointArray a; | 904 | QPointArray a; |
897 | int x2 = x + w - 1, y2 = y + h - 1; | 905 | int x2 = x + w - 1, y2 = y + h - 1; |
898 | switch ( type ) { | 906 | switch ( type ) { |
899 | case Qt::UpArrow: | 907 | case Qt::UpArrow: |
900 | a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); | 908 | a.setPoints( 4, x, y2, x2, y2, x + w / 2, y, x, y2 ); |
901 | break; | 909 | break; |
902 | case Qt::DownArrow: | 910 | case Qt::DownArrow: |
903 | a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); | 911 | a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y ); |
904 | break; | 912 | break; |
905 | case Qt::LeftArrow: | 913 | case Qt::LeftArrow: |
906 | a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); | 914 | a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y ); |
907 | break; | 915 | break; |
908 | default: | 916 | default: |
909 | a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); | 917 | a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y ); |
910 | break; | 918 | break; |
911 | } | 919 | } |
912 | QBrush oldBrush = p->brush(); | 920 | QBrush oldBrush = p->brush(); |
913 | QPen oldPen = p->pen(); | 921 | QPen oldPen = p->pen(); |
914 | p->setBrush( cg->brush( QColorGroup::Shadow ) ); | 922 | p->setBrush( cg->brush( QColorGroup::Shadow ) ); |
915 | p->setPen( cg->shadow() ); | 923 | p->setPen( cg->shadow() ); |
916 | p->drawPolygon( a ); | 924 | p->drawPolygon( a ); |
917 | p->setBrush( oldBrush ); | 925 | p->setBrush( oldBrush ); |
918 | p->setPen( oldPen ); | 926 | p->setPen( oldPen ); |
919 | } | 927 | } |
920 | } | 928 | } |
921 | 929 | ||
922 | /* This is where we draw the borders and highlights. The new round button | 930 | /* This is where we draw the borders and highlights. The new round button |
923 | * code is a pain in the arse. We don't want to be calculating arcs so | 931 | * code is a pain in the arse. We don't want to be calculating arcs so |
924 | * use a whole lotta QPointArray's ;-) The code is made a lot more complex | 932 | * use a whole lotta QPointArray's ;-) The code is made a lot more complex |
925 | * because you can have variable width border and highlights... | 933 | * because you can have variable width border and highlights... |
926 | * I may want to cache this if round buttons are used, but am concerned | 934 | * I may want to cache this if round buttons are used, but am concerned |
927 | * about excessive cache misses. This is a memory/speed tradeoff that I | 935 | * about excessive cache misses. This is a memory/speed tradeoff that I |
928 | * have to test. | 936 | * have to test. |
929 | */ | 937 | */ |
930 | void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, | 938 | void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h, |
931 | const QColorGroup &g, bool sunken, bool rounded, | 939 | const QColorGroup &g, bool sunken, bool rounded, |
932 | int hWidth, int bWidth, ShadeStyle style ) | 940 | int hWidth, int bWidth, ShadeStyle style ) |
933 | { | 941 | { |
934 | int i, sc, bc, x2, y2; | 942 | int i, sc, bc, x2, y2; |
935 | QPen highPen, lowPen; | 943 | QPen highPen, lowPen; |
936 | 944 | ||
937 | if ( style == Motif ) { | 945 | if ( style == Motif ) { |
938 | highPen.setColor( sunken ? g.dark() : g.light() ); | 946 | highPen.setColor( sunken ? g.dark() : g.light() ); |
939 | lowPen.setColor( sunken ? g.light() : g.dark() ); | 947 | lowPen.setColor( sunken ? g.light() : g.dark() ); |
940 | } | 948 | } |
941 | else { | 949 | else { |
942 | highPen.setColor( sunken ? g.shadow() : g.light() ); | 950 | highPen.setColor( sunken ? g.shadow() : g.light() ); |
943 | lowPen.setColor( sunken ? g.light() : g.shadow() ); | 951 | lowPen.setColor( sunken ? g.light() : g.shadow() ); |
944 | } | 952 | } |
945 | 953 | ||
946 | // Advanced round buttons | 954 | // Advanced round buttons |
947 | if ( rounded && w > 19 && h > 19 ) { | 955 | if ( rounded && w > 19 && h > 19 ) { |
948 | x2 = x + w - 1, y2 = y + h - 1; | 956 | x2 = x + w - 1, y2 = y + h - 1; |
949 | QPointArray bPntArray, hPntArray, lPntArray; | 957 | QPointArray bPntArray, hPntArray, lPntArray; |
950 | QPointArray bLineArray, hLineArray, lLineArray; | 958 | QPointArray bLineArray, hLineArray, lLineArray; |
951 | // borders | 959 | // borders |
952 | for ( i = 0, bc = 0; i < bWidth; ++i ) { | 960 | for ( i = 0, bc = 0; i < bWidth; ++i ) { |
953 | bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, | 961 | bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3, |
954 | x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, | 962 | x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, |
955 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, | 963 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1, |
956 | x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, | 964 | x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, |
957 | x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, | 965 | x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, |
958 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); | 966 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); |
959 | bc += 24; | 967 | bc += 24; |
960 | // ellispe edges don't match exactly, so fill in blanks | 968 | // ellispe edges don't match exactly, so fill in blanks |
961 | if ( i < bWidth - 1 || hWidth != 0 ) { | 969 | if ( i < bWidth - 1 || hWidth != 0 ) { |
962 | bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, | 970 | bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3, |
963 | x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, | 971 | x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2, |
964 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, | 972 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1, |
965 | x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, | 973 | x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, |
966 | x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, | 974 | x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6, |
967 | x2 - 2, y + 4 ); | 975 | x2 - 2, y + 4 ); |
968 | bc += 20; | 976 | bc += 20; |
969 | } | 977 | } |
970 | bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, | 978 | bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6, |
971 | x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); | 979 | x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); |
972 | ++x, ++y; | 980 | ++x, ++y; |
973 | --x2, --y2; | 981 | --x2, --y2; |
974 | } | 982 | } |
975 | // highlights | 983 | // highlights |
976 | for ( i = 0, sc = 0; i < hWidth; ++i ) { | 984 | for ( i = 0, sc = 0; i < hWidth; ++i ) { |
977 | hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left | 985 | hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left |
978 | x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, | 986 | x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5, |
979 | x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners | 987 | x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners |
980 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); | 988 | x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 ); |
981 | lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right | 989 | lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right |
982 | x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, | 990 | x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4, |
983 | x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners | 991 | x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners |
984 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); | 992 | x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 ); |
985 | sc += 12; | 993 | sc += 12; |
986 | if ( i < hWidth - 1 ) { | 994 | if ( i < hWidth - 1 ) { |
987 | hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left | 995 | hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left |
988 | x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, | 996 | x + 3, y + 3, x + 2, y + 4, x + 1, y + 6, |
989 | x2 - 6, y + 1, x2 - 4, y + 2, // half corners | 997 | x2 - 6, y + 1, x2 - 4, y + 2, // half corners |
990 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); | 998 | x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 ); |
991 | lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right | 999 | lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right |
992 | x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, | 1000 | x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6, |
993 | x + 6, y2 - 1, x + 4, y2 - 2, // half corners | 1001 | x + 6, y2 - 1, x + 4, y2 - 2, // half corners |
994 | x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); | 1002 | x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 ); |
995 | sc += 10; | 1003 | sc += 10; |
996 | } | 1004 | } |
997 | hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); | 1005 | hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 ); |
998 | lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); | 1006 | lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 ); |
999 | ++x, ++y; | 1007 | ++x, ++y; |
1000 | --x2, --y2; | 1008 | --x2, --y2; |
1001 | } | 1009 | } |
1002 | p->setPen( Qt::black ); | 1010 | p->setPen( Qt::black ); |
1003 | p->drawPoints( bPntArray ); | 1011 | p->drawPoints( bPntArray ); |
1004 | p->drawLineSegments( bLineArray ); | 1012 | p->drawLineSegments( bLineArray ); |
1005 | p->setPen( highPen ); | 1013 | p->setPen( highPen ); |
1006 | p->drawPoints( hPntArray ); | 1014 | p->drawPoints( hPntArray ); |
1007 | p->drawLineSegments( hLineArray ); | 1015 | p->drawLineSegments( hLineArray ); |
1008 | p->setPen( lowPen ); | 1016 | p->setPen( lowPen ); |
1009 | p->drawPoints( lPntArray ); | 1017 | p->drawPoints( lPntArray ); |
1010 | p->drawLineSegments( lLineArray ); | 1018 | p->drawLineSegments( lLineArray ); |
1011 | } | 1019 | } |
1012 | // Rectangular buttons | 1020 | // Rectangular buttons |
1013 | else { | 1021 | else { |
1014 | QPointArray highShade( hWidth * 4 ); | 1022 | QPointArray highShade( hWidth * 4 ); |
1015 | QPointArray lowShade( hWidth * 4 ); | 1023 | QPointArray lowShade( hWidth * 4 ); |
1016 | 1024 | ||
1017 | p->setPen( g.shadow() ); | 1025 | p->setPen( g.shadow() ); |
1018 | for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) | 1026 | for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 ) |
1019 | p->drawRect( x, y , w, h ); | 1027 | p->drawRect( x, y , w, h ); |
1020 | 1028 | ||
1021 | if ( !hWidth ) | 1029 | if ( !hWidth ) |
1022 | return ; | 1030 | return ; |
1023 | 1031 | ||
1024 | x2 = x + w - 1, y2 = y + h - 1; | 1032 | x2 = x + w - 1, y2 = y + h - 1; |
1025 | for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { | 1033 | for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) { |
1026 | highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); | 1034 | highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 ); |
1027 | lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); | 1035 | lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 ); |
1028 | } | 1036 | } |
1029 | if ( style == Windows && hWidth > 1 ) { | 1037 | if ( style == Windows && hWidth > 1 ) { |
1030 | p->setPen( highPen ); | 1038 | p->setPen( highPen ); |
1031 | p->drawLineSegments( highShade, 0, 2 ); | 1039 | p->drawLineSegments( highShade, 0, 2 ); |
1032 | p->setPen( lowPen ); | 1040 | p->setPen( lowPen ); |
1033 | p->drawLineSegments( lowShade, 0, 2 ); | 1041 | p->drawLineSegments( lowShade, 0, 2 ); |
1034 | 1042 | ||
1035 | p->setPen( ( sunken ) ? g.dark() : g.mid() ); | 1043 | p->setPen( ( sunken ) ? g.dark() : g.mid() ); |
1036 | p->drawLineSegments( highShade, 4 ); | 1044 | p->drawLineSegments( highShade, 4 ); |
1037 | p->setPen( ( sunken ) ? g.mid() : g.dark() ); | 1045 | p->setPen( ( sunken ) ? g.mid() : g.dark() ); |
1038 | p->drawLineSegments( lowShade, 4 ); | 1046 | p->drawLineSegments( lowShade, 4 ); |
1039 | } | 1047 | } |
1040 | else { | 1048 | else { |
1041 | p->setPen( ( sunken ) ? g.dark() : g.light() ); | 1049 | p->setPen( ( sunken ) ? g.dark() : g.light() ); |
1042 | p->drawLineSegments( highShade ); | 1050 | p->drawLineSegments( highShade ); |
1043 | p->setPen( ( sunken ) ? g.light() : g.dark() ); | 1051 | p->setPen( ( sunken ) ? g.light() : g.dark() ); |
1044 | p->drawLineSegments( lowShade ); | 1052 | p->drawLineSegments( lowShade ); |
1045 | } | 1053 | } |
1046 | } | 1054 | } |
1047 | } | 1055 | } |
1048 | 1056 | ||
1049 | void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) | 1057 | void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) |
1050 | { | 1058 | { |
1051 | WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : | 1059 | WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown : |
1052 | PushButton; | 1060 | PushButton; |
1053 | const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); | 1061 | const QColorGroup *cg = colorGroup( btn->colorGroup(), widget ); |
1054 | int x, y, w, h; | 1062 | int x, y, w, h; |
1055 | 1063 | ||
1056 | QRect r = btn->rect(); | 1064 | QRect r = btn->rect(); |
1057 | r.rect( &x, &y, &w, &h ); | 1065 | r.rect( &x, &y, &w, &h ); |
1058 | x += decoWidth( widget ); | 1066 | x += decoWidth( widget ); |
1059 | y += decoWidth( widget ); | 1067 | y += decoWidth( widget ); |
1060 | w -= decoWidth( widget ) * 2; | 1068 | w -= decoWidth( widget ) * 2; |
1061 | h -= decoWidth( widget ) * 2; | 1069 | h -= decoWidth( widget ) * 2; |
1062 | bool act = btn->isOn() || btn->isDown(); | 1070 | bool act = btn->isOn() || btn->isDown(); |
1063 | 1071 | ||
1064 | // If this is a button with an associated popup menu, draw an arrow first | 1072 | // If this is a button with an associated popup menu, draw an arrow first |
1065 | if ( btn->popup() ) { | 1073 | if ( btn->popup() ) { |
1066 | int dx = menuButtonIndicatorWidth( btn->height() ); | 1074 | int dx = menuButtonIndicatorWidth( btn->height() ); |
1067 | 1075 | ||
1068 | QColorGroup g( btn->colorGroup() ); | 1076 | QColorGroup g( btn->colorGroup() ); |
1069 | int xx = x + w - dx - 4; | 1077 | int xx = x + w - dx - 4; |
1070 | int yy = y - 3; | 1078 | int yy = y - 3; |
1071 | int hh = h + 6; | 1079 | int hh = h + 6; |
1072 | 1080 | ||
1073 | if ( !act ) { | 1081 | if ( !act ) { |
1074 | p->setPen( g.light() ); | 1082 | p->setPen( g.light() ); |
1075 | p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); | 1083 | p->drawLine( xx, yy + 3, xx, yy + hh - 4 ); |
1076 | } | 1084 | } |
1077 | else { | 1085 | else { |
1078 | p->setPen( g.button() ); | 1086 | p->setPen( g.button() ); |
1079 | p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); | 1087 | p->drawLine( xx, yy + 4, xx, yy + hh - 4 ); |
1080 | } | 1088 | } |
1081 | drawArrow( p, DownArrow, FALSE, | 1089 | drawArrow( p, DownArrow, FALSE, |
1082 | x + w - dx - 2, y + 2, dx, h - 4, | 1090 | x + w - dx - 2, y + 2, dx, h - 4, |
1083 | btn->colorGroup(), | 1091 | btn->colorGroup(), |
1084 | btn->isEnabled() ); | 1092 | btn->isEnabled() ); |
1085 | w -= dx; | 1093 | w -= dx; |
1086 | } | 1094 | } |
1087 | 1095 | ||
1088 | // Next, draw iconset, if any | 1096 | // Next, draw iconset, if any |
1089 | if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { | 1097 | if ( btn->iconSet() && !btn->iconSet() ->isNull() ) { |
1090 | QIconSet::Mode mode = btn->isEnabled() | 1098 | QIconSet::Mode mode = btn->isEnabled() |
1091 | ? QIconSet::Normal : QIconSet::Disabled; | 1099 | ? QIconSet::Normal : QIconSet::Disabled; |
1092 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1100 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1093 | mode = QIconSet::Active; | 1101 | mode = QIconSet::Active; |
1094 | QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); | 1102 | QPixmap pixmap = btn->iconSet() ->pixmap( QIconSet::Small, mode ); |
1095 | int pixw = pixmap.width(); | 1103 | int pixw = pixmap.width(); |
1096 | int pixh = pixmap.height(); | 1104 | int pixh = pixmap.height(); |
1097 | 1105 | ||
1098 | p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); | 1106 | p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap ); |
1099 | x += pixw + 8; | 1107 | x += pixw + 8; |
1100 | w -= pixw + 8; | 1108 | w -= pixw + 8; |
1101 | } | 1109 | } |
1102 | 1110 | ||
1103 | if ( widget == PushButtonDown ) { | 1111 | if ( widget == PushButtonDown ) { |
1104 | drawItem( p, x + buttonXShift(), y + buttonYShift(), | 1112 | drawItem( p, x + buttonXShift(), y + buttonYShift(), |
1105 | w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), | 1113 | w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(), |
1106 | btn->pixmap(), btn->text(), -1, &cg->buttonText() ); | 1114 | btn->pixmap(), btn->text(), -1, &cg->buttonText() ); |
1107 | } | 1115 | } |
1108 | else { | 1116 | else { |
1109 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, | 1117 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg, |
1110 | btn->isEnabled(), btn->pixmap(), btn->text(), -1, | 1118 | btn->isEnabled(), btn->pixmap(), btn->text(), -1, |
1111 | &cg->buttonText() ); | 1119 | &cg->buttonText() ); |
1112 | } | 1120 | } |
1113 | } | 1121 | } |
1114 | 1122 | ||
1115 | int OThemeStyle::splitterWidth() const | 1123 | int OThemeStyle::splitterWidth() const |
1116 | { | 1124 | { |
1117 | return ( splitWidth() ); | 1125 | return ( splitWidth() ); |
1118 | } | 1126 | } |
1119 | 1127 | ||
1120 | void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, | 1128 | void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h, |
1121 | const QColorGroup &g, Orientation ) | 1129 | const QColorGroup &g, Orientation ) |
1122 | { | 1130 | { |
1123 | drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, | 1131 | drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false, |
1124 | Splitter ); | 1132 | Splitter ); |
1125 | } | 1133 | } |
1126 | 1134 | ||
1127 | void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, | 1135 | void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h, |
1128 | const QColorGroup &g, bool act, bool dis ) | 1136 | const QColorGroup &g, bool act, bool dis ) |
1129 | { | 1137 | { |
1130 | if ( isPixmap( CheckMark ) ) { | 1138 | if ( isPixmap( CheckMark ) ) { |
1131 | if ( !dis ) | 1139 | if ( !dis ) |
1132 | p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, | 1140 | p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2, |
1133 | y + ( h - uncached( CheckMark ) ->height() ) / 2, | 1141 | y + ( h - uncached( CheckMark ) ->height() ) / 2, |
1134 | *uncached( CheckMark ) ); | 1142 | *uncached( CheckMark ) ); |
1135 | } | 1143 | } |
1136 | else | 1144 | else |
1137 | QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), | 1145 | QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ), |
1138 | act, dis ); | 1146 | act, dis ); |
1139 | } | 1147 | } |
1140 | 1148 | ||
1141 | int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, | 1149 | int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi, |
1142 | const QFontMetrics &fm ) | 1150 | const QFontMetrics &fm ) |
1143 | { | 1151 | { |
1144 | int h2, h = 0; | 1152 | int h2, h = 0; |
1145 | int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; | 1153 | int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4; |
1146 | 1154 | ||
1147 | if ( mi->isSeparator() ) | 1155 | if ( mi->isSeparator() ) |
1148 | return ( 2 ); | 1156 | return ( 2 ); |
1149 | if ( mi->isChecked() ) | 1157 | if ( mi->isChecked() ) |
1150 | h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : | 1158 | h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset : |
1151 | offset + 16; | 1159 | offset + 16; |
1152 | if ( mi->pixmap() ) { | 1160 | if ( mi->pixmap() ) { |
1153 | h2 = mi->pixmap() ->height() + offset; | 1161 | h2 = mi->pixmap() ->height() + offset; |
1154 | h = h2 > h ? h2 : h; | 1162 | h = h2 > h ? h2 : h; |
1155 | } | 1163 | } |
1156 | if ( mi->iconSet() ) { | 1164 | if ( mi->iconSet() ) { |
1157 | h2 = mi->iconSet() -> | 1165 | h2 = mi->iconSet() -> |
1158 | pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; | 1166 | pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset; |
1159 | h = h2 > h ? h2 : h; | 1167 | h = h2 > h ? h2 : h; |
1160 | } | 1168 | } |
1161 | h2 = fm.height() + offset; | 1169 | h2 = fm.height() + offset; |
1162 | h = h2 > h ? h2 : h; | 1170 | h = h2 > h ? h2 : h; |
1163 | return ( h ); | 1171 | return ( h ); |
1164 | } | 1172 | } |
1165 | 1173 | ||
1166 | void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, | 1174 | void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, |
1167 | int tab, QMenuItem* mi, | 1175 | int tab, QMenuItem* mi, |
1168 | const QPalette& pal, bool act, | 1176 | const QPalette& pal, bool act, |
1169 | bool enabled, int x, int y, int w, int h ) | 1177 | bool enabled, int x, int y, int w, int h ) |
1170 | { | 1178 | { |
1171 | // I changed the following method to be based from Qt's instead of my own | 1179 | // I changed the following method to be based from Qt's instead of my own |
1172 | // wacky code. Works much better now :P (mosfet) | 1180 | // wacky code. Works much better now :P (mosfet) |
1173 | static const int motifItemFrame = 2; // menu item frame width | 1181 | static const int motifItemFrame = 2; // menu item frame width |
1174 | static const int motifItemHMargin = 5; // menu item hor text margin | 1182 | static const int motifItemHMargin = 5; // menu item hor text margin |
1175 | static const int motifItemVMargin = 4; // menu item ver text margin | 1183 | static const int motifItemVMargin = 4; // menu item ver text margin |
1176 | 1184 | ||
1177 | static const int motifArrowHMargin = 6; // arrow horizontal margin | 1185 | static const int motifArrowHMargin = 6; // arrow horizontal margin |
1178 | static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows | 1186 | static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows |
1179 | bool dis = !enabled; | 1187 | bool dis = !enabled; |
1180 | const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : | 1188 | const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) : |
1181 | *colorGroup( pal.normal(), MenuItemDown ); | 1189 | *colorGroup( pal.normal(), MenuItemDown ); |
1182 | 1190 | ||
1183 | QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) | 1191 | QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem ) |
1184 | : act ? *colorGroup( pal.active(), MenuItemDown ) | 1192 | : act ? *colorGroup( pal.active(), MenuItemDown ) |
1185 | : *colorGroup( pal.normal(), MenuItem ); | 1193 | : *colorGroup( pal.normal(), MenuItem ); |
1186 | 1194 | ||
1187 | maxpmw = QMAX( maxpmw, 20 ); | 1195 | maxpmw = QMAX( maxpmw, 20 ); |
1188 | int checkcol = maxpmw; | 1196 | int checkcol = maxpmw; |
1189 | 1197 | ||
1190 | if ( mi && mi->isSeparator() ) { | 1198 | if ( mi && mi->isSeparator() ) { |
1191 | p->setPen( g.dark() ); | 1199 | p->setPen( g.dark() ); |
1192 | p->drawLine( x, y, x + w, y ); | 1200 | p->drawLine( x, y, x + w, y ); |
1193 | p->setPen( g.light() ); | 1201 | p->setPen( g.light() ); |
1194 | p->drawLine( x, y + 1, x + w, y + 1 ); | 1202 | p->drawLine( x, y + 1, x + w, y + 1 ); |
1195 | return ; | 1203 | return ; |
1196 | } | 1204 | } |
1197 | if ( act ) { | 1205 | if ( act ) { |
1198 | drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); | 1206 | drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown ); |
1199 | } | 1207 | } |
1200 | else { | 1208 | else { |
1201 | drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, | 1209 | drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false, |
1202 | highlightWidth( MenuItem ), borderWidth( MenuItem ), | 1210 | highlightWidth( MenuItem ), borderWidth( MenuItem ), |
1203 | shade() ); | 1211 | shade() ); |
1204 | int dw = decoWidth( MenuItem ); | 1212 | int dw = decoWidth( MenuItem ); |
1205 | if ( !isPixmap( MenuItem ) ) | 1213 | if ( !isPixmap( MenuItem ) ) |
1206 | p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, | 1214 | p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2, |
1207 | colorGroup( g, MenuItem ) -> | 1215 | colorGroup( g, MenuItem ) -> |
1208 | brush( QColorGroup::Background ) ); | 1216 | brush( QColorGroup::Background ) ); |
1209 | else { | 1217 | else { |
1210 | // process inactive item pixmaps as one large item | 1218 | // process inactive item pixmaps as one large item |
1211 | p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap | 1219 | p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap |
1212 | // (w, p->window().height(), MenuItem), | 1220 | // (w, p->window().height(), MenuItem), |
1213 | ( w, p->clipRegion().boundingRect().height(), MenuItem ), | 1221 | ( w, p->clipRegion().boundingRect().height(), MenuItem ), |
1214 | x, y ); | 1222 | x, y ); |
1215 | } | 1223 | } |
1216 | 1224 | ||
1217 | if ( checkable && mi && mi->isChecked() ) { | 1225 | if ( checkable && mi && mi->isChecked() ) { |
1218 | // draw 'pressed' border around checkable items | 1226 | // draw 'pressed' border around checkable items |
1219 | // This is extremely important for items that have an iconset | 1227 | // This is extremely important for items that have an iconset |
1220 | // because the checkmark isn't drawn in that case | 1228 | // because the checkmark isn't drawn in that case |
1221 | // An alternative would be superimposing the checkmark over | 1229 | // An alternative would be superimposing the checkmark over |
1222 | // the iconset instead or not drawing the iconset at all. | 1230 | // the iconset instead or not drawing the iconset at all. |
1223 | int mw = checkcol + motifItemFrame; | 1231 | int mw = checkcol + motifItemFrame; |
1224 | drawShade( p, x, y, mw, h, g, true, false, | 1232 | drawShade( p, x, y, mw, h, g, true, false, |
1225 | highlightWidth( MenuItemDown ), | 1233 | highlightWidth( MenuItemDown ), |
1226 | borderWidth( MenuItemDown ), shade() ); | 1234 | borderWidth( MenuItemDown ), shade() ); |
1227 | } | 1235 | } |
1228 | } | 1236 | } |
1229 | if ( !mi ) | 1237 | if ( !mi ) |
1230 | return ; | 1238 | return ; |
1231 | if ( mi->iconSet() ) { | 1239 | if ( mi->iconSet() ) { |
1232 | QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; | 1240 | QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal; |
1233 | if ( act && !dis ) | 1241 | if ( act && !dis ) |
1234 | mode = QIconSet::Active; | 1242 | mode = QIconSet::Active; |
1235 | QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); | 1243 | QPixmap pixmap = mi->iconSet() ->pixmap( QIconSet::Small, mode ); |
1236 | int pixw = pixmap.width(); | 1244 | int pixw = pixmap.width(); |
1237 | int pixh = pixmap.height(); | 1245 | int pixh = pixmap.height(); |
1238 | QRect cr( x, y, checkcol, h ); | 1246 | QRect cr( x, y, checkcol, h ); |
1239 | QRect pmr( 0, 0, pixw, pixh ); | 1247 | QRect pmr( 0, 0, pixw, pixh ); |
1240 | pmr.moveCenter( cr.center() ); | 1248 | pmr.moveCenter( cr.center() ); |
1241 | p->setPen( itemg.text() ); | 1249 | p->setPen( itemg.text() ); |
1242 | p->drawPixmap( pmr.topLeft(), pixmap ); | 1250 | p->drawPixmap( pmr.topLeft(), pixmap ); |
1243 | 1251 | ||
1244 | } | 1252 | } |
1245 | else if ( checkable ) { | 1253 | else if ( checkable ) { |
1246 | int mw = checkcol + motifItemFrame; | 1254 | int mw = checkcol + motifItemFrame; |
1247 | int mh = h - 2 * motifItemFrame; | 1255 | int mh = h - 2 * motifItemFrame; |
1248 | if ( mi->isChecked() ) { | 1256 | if ( mi->isChecked() ) { |
1249 | drawCheckMark( p, x + motifItemFrame, | 1257 | drawCheckMark( p, x + motifItemFrame, |
1250 | y + motifItemFrame, mw, mh, itemg, act, dis ); | 1258 | y + motifItemFrame, mw, mh, itemg, act, dis ); |
1251 | } | 1259 | } |
1252 | } | 1260 | } |
1253 | 1261 | ||
1254 | p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); | 1262 | p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() ); |
1255 | 1263 | ||
1256 | QColor discol; | 1264 | QColor discol; |
1257 | if ( dis ) { | 1265 | if ( dis ) { |
1258 | discol = itemg.text(); | 1266 | discol = itemg.text(); |
1259 | p->setPen( discol ); | 1267 | p->setPen( discol ); |
1260 | } | 1268 | } |
1261 | 1269 | ||
1262 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 1270 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
1263 | 1271 | ||
1264 | QString s = mi->text(); | 1272 | QString s = mi->text(); |
1265 | if ( !s.isNull() ) { | 1273 | if ( !s.isNull() ) { |
1266 | int t = s.find( '\t' ); | 1274 | int t = s.find( '\t' ); |
1267 | int m = motifItemVMargin; | 1275 | int m = motifItemVMargin; |
1268 | const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; | 1276 | const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; |
1269 | if ( t >= 0 ) { | 1277 | if ( t >= 0 ) { |
1270 | if ( dis && !act ) { | 1278 | if ( dis && !act ) { |
1271 | p->setPen( g.light() ); | 1279 | p->setPen( g.light() ); |
1272 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, | 1280 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1, |
1273 | y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); | 1281 | y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); |
1274 | p->setPen( discol ); | 1282 | p->setPen( discol ); |
1275 | } | 1283 | } |
1276 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, | 1284 | p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame, |
1277 | y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); | 1285 | y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) ); |
1278 | } | 1286 | } |
1279 | if ( dis && !act ) { | 1287 | if ( dis && !act ) { |
1280 | p->setPen( g.light() ); | 1288 | p->setPen( g.light() ); |
1281 | p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); | 1289 | p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t ); |
1282 | p->setPen( discol ); | 1290 | p->setPen( discol ); |
1283 | } | 1291 | } |
1284 | p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); | 1292 | p->drawText( x + xm, y + m, w - xm - tab + 1, h - 2 * m, text_flags, s, t ); |
1285 | } | 1293 | } |
1286 | else if ( mi->pixmap() ) { | 1294 | else if ( mi->pixmap() ) { |
1287 | QPixmap * pixmap = mi->pixmap(); | 1295 | QPixmap * pixmap = mi->pixmap(); |
1288 | if ( pixmap->depth() == 1 ) | 1296 | if ( pixmap->depth() == 1 ) |
1289 | p->setBackgroundMode( OpaqueMode ); | 1297 | p->setBackgroundMode( OpaqueMode ); |
1290 | p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); | 1298 | p->drawPixmap( x + xm, y + motifItemFrame, *pixmap ); |
1291 | if ( pixmap->depth() == 1 ) | 1299 | if ( pixmap->depth() == 1 ) |
1292 | p->setBackgroundMode( TransparentMode ); | 1300 | p->setBackgroundMode( TransparentMode ); |
1293 | } | 1301 | } |
1294 | if ( mi->popup() ) { | 1302 | if ( mi->popup() ) { |
1295 | int dim = ( h - 2 * motifItemFrame ) / 2; | 1303 | int dim = ( h - 2 * motifItemFrame ) / 2; |
1296 | if ( act ) { | 1304 | if ( act ) { |
1297 | if ( !dis ) | 1305 | if ( !dis ) |
1298 | discol = colorGroup( g, MenuItemDown ) ->text(); | 1306 | discol = colorGroup( g, MenuItemDown ) ->text(); |
1299 | //discol = white; | 1307 | //discol = white; |
1300 | QColorGroup g2( discol, g.highlight(), | 1308 | QColorGroup g2( discol, g.highlight(), |
1301 | white, white, | 1309 | white, white, |
1302 | dis ? discol : white, | 1310 | dis ? discol : white, |
1303 | discol, white ); | 1311 | discol, white ); |
1304 | drawArrow( p, RightArrow, true, | 1312 | drawArrow( p, RightArrow, true, |
1305 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, | 1313 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, |
1306 | dim, dim, g2, TRUE ); | 1314 | dim, dim, g2, TRUE ); |
1307 | } | 1315 | } |
1308 | else { | 1316 | else { |
1309 | drawArrow( p, RightArrow, | 1317 | drawArrow( p, RightArrow, |
1310 | false, | 1318 | false, |
1311 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, | 1319 | x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2, |
1312 | dim, dim, g, mi->isEnabled() ); | 1320 | dim, dim, g, mi->isEnabled() ); |
1313 | } | 1321 | } |
1314 | } | 1322 | } |
1315 | } | 1323 | } |
1316 | 1324 | ||
1317 | void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, | 1325 | void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r, |
1318 | const QColorGroup &g, const QColor *c, | 1326 | const QColorGroup &g, const QColor *c, |
1319 | bool atBorder ) | 1327 | bool atBorder ) |
1320 | { | 1328 | { |
1321 | p->setPen( g.dark() ); | 1329 | p->setPen( g.dark() ); |
1322 | if ( !is3DFocus() ) | 1330 | if ( !is3DFocus() ) |
1323 | QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); | 1331 | QWindowsStyle::drawFocusRect( p, r, g, c, atBorder ); |
1324 | else { | 1332 | else { |
1325 | int i = focusOffset(); | 1333 | int i = focusOffset(); |
1326 | p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); | 1334 | p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i ); |
1327 | p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); | 1335 | p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i ); |
1328 | p->setPen( g.light() ); | 1336 | p->setPen( g.light() ); |
1329 | p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); | 1337 | p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i ); |
1330 | p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); | 1338 | p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i ); |
1331 | } | 1339 | } |
1332 | } | 1340 | } |
1333 | 1341 | ||
1334 | #if 0 | 1342 | #if 0 |
1335 | void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, | 1343 | void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h, |
1336 | const QColorGroup &g, bool, QBrush * ) | 1344 | const QColorGroup &g, bool, QBrush * ) |
1337 | { | 1345 | { |
1338 | drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, | 1346 | drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false, |
1339 | MenuBar ); | 1347 | MenuBar ); |
1340 | } | 1348 | } |
1341 | 1349 | ||
1342 | void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, | 1350 | void OThemeStyle::drawKMenuItem( QPainter *p, int x, int y, int w, int h, |
1343 | const QColorGroup &g, bool active, | 1351 | const QColorGroup &g, bool active, |
1344 | QMenuItem *mi, QBrush * ) | 1352 | QMenuItem *mi, QBrush * ) |
1345 | { | 1353 | { |
1346 | const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); | 1354 | const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar ); |
1347 | QColor btext = cg->buttonText(); | 1355 | QColor btext = cg->buttonText(); |
1348 | if ( active ) | 1356 | if ( active ) |
1349 | drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); | 1357 | drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem ); |
1350 | //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); | 1358 | //qDrawShadePanel(p, x, y, w, h, *cg, false, 1); |
1351 | 1359 | ||
1352 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, | 1360 | drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine, |
1353 | *cg, mi->isEnabled(), mi->pixmap(), mi->text(), | 1361 | *cg, mi->isEnabled(), mi->pixmap(), mi->text(), |
1354 | -1, &btext ); | 1362 | -1, &btext ); |
1355 | ; | 1363 | ; |
1356 | } | 1364 | } |
1357 | 1365 | ||
1358 | void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, | 1366 | void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h, |
1359 | const QColorGroup &g, QBrush * ) | 1367 | const QColorGroup &g, QBrush * ) |
1360 | { | 1368 | { |
1361 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, | 1369 | drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false, |
1362 | ProgressBar ); | 1370 | ProgressBar ); |
1363 | } | 1371 | } |
1364 | 1372 | ||
1365 | void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) | 1373 | void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg ) |
1366 | { | 1374 | { |
1367 | const QColorGroup * cg = colorGroup( g, ProgressBg ); | 1375 | const QColorGroup * cg = colorGroup( g, ProgressBg ); |
1368 | bg.setColor( cg->color( QColorGroup::Background ) ); | 1376 | bg.setColor( cg->color( QColorGroup::Background ) ); |
1369 | if ( isPixmap( ProgressBg ) ) | 1377 | if ( isPixmap( ProgressBg ) ) |
1370 | bg.setPixmap( *uncached( ProgressBg ) ); | 1378 | bg.setPixmap( *uncached( ProgressBg ) ); |
1371 | } | 1379 | } |
1372 | #endif | 1380 | #endif |
1373 | 1381 | ||
1374 | void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) | 1382 | void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap ) |
1375 | { | 1383 | { |
1376 | QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); | 1384 | QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap ); |
1377 | } | 1385 | } |
1378 | 1386 | ||
1379 | void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , | 1387 | void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t , |
1380 | bool selected ) | 1388 | bool selected ) |
1381 | { | 1389 | { |
1382 | WidgetType widget = selected ? ActiveTab : InactiveTab; | 1390 | WidgetType widget = selected ? ActiveTab : InactiveTab; |
1383 | const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); | 1391 | const QColorGroup *cg = colorGroup( tb->colorGroup(), widget ); |
1384 | int i; | 1392 | int i; |
1385 | int x = t->r.x(), y = t->r.y(); | 1393 | int x = t->r.x(), y = t->r.y(); |
1386 | int x2 = t->r.right(), y2 = t->r.bottom(); | 1394 | int x2 = t->r.right(), y2 = t->r.bottom(); |
1387 | int bWidth = borderWidth( widget ); | 1395 | int bWidth = borderWidth( widget ); |
1388 | int hWidth = highlightWidth( widget ); | 1396 | int hWidth = highlightWidth( widget ); |
1389 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 1397 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
1390 | if ( !selected ) { | 1398 | if ( !selected ) { |
1391 | p->fillRect( x, y, x2 - x + 1, 2, | 1399 | p->fillRect( x, y, x2 - x + 1, 2, |
1392 | tb->palette().normal().brush( QColorGroup::Background ) ); | 1400 | tb->palette().normal().brush( QColorGroup::Background ) ); |
1393 | y += 2; | 1401 | y += 2; |
1394 | } | 1402 | } |
1395 | p->setPen( cg->text() ); | 1403 | p->setPen( cg->text() ); |
1396 | i = 0; | 1404 | i = 0; |
1397 | if ( i < bWidth ) { | 1405 | if ( i < bWidth ) { |
1398 | p->drawLine( x, y + 1, x, y2 ); | 1406 | p->drawLine( x, y + 1, x, y2 ); |
1399 | p->drawLine( x2, y + 1, x2, y2 ); | 1407 | p->drawLine( x2, y + 1, x2, y2 ); |
1400 | p->drawLine( x + 1, y, x2 - 1, y ); | 1408 | p->drawLine( x + 1, y, x2 - 1, y ); |
1401 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1409 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1402 | p->drawLine( x, y2, x2, y2 ); | 1410 | p->drawLine( x, y2, x2, y2 ); |
1403 | --y2; | 1411 | --y2; |
1404 | } | 1412 | } |
1405 | ++i, ++x, ++y, --x2; | 1413 | ++i, ++x, ++y, --x2; |
1406 | } | 1414 | } |
1407 | for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { | 1415 | for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) { |
1408 | p->drawLine( x, y, x, y2 ); | 1416 | p->drawLine( x, y, x, y2 ); |
1409 | p->drawLine( x2, y, x2, y2 ); | 1417 | p->drawLine( x2, y, x2, y2 ); |
1410 | p->drawLine( x, y, x2, y ); | 1418 | p->drawLine( x, y, x2, y ); |
1411 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1419 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1412 | p->drawLine( x, y2, x2, y2 ); | 1420 | p->drawLine( x, y2, x2, y2 ); |
1413 | --y2; | 1421 | --y2; |
1414 | } | 1422 | } |
1415 | } | 1423 | } |
1416 | i = 0; | 1424 | i = 0; |
1417 | if ( i < hWidth && bWidth == 0 ) { | 1425 | if ( i < hWidth && bWidth == 0 ) { |
1418 | p->setPen( cg->light() ); | 1426 | p->setPen( cg->light() ); |
1419 | p->drawLine( x, y + 1, x, y2 ); | 1427 | p->drawLine( x, y + 1, x, y2 ); |
1420 | p->drawLine( x + 1, y, x2 - 1, y ); | 1428 | p->drawLine( x + 1, y, x2 - 1, y ); |
1421 | p->setPen( cg->dark() ); | 1429 | p->setPen( cg->dark() ); |
1422 | p->drawLine( x2, y + 1, x2, y2 ); | 1430 | p->drawLine( x2, y + 1, x2, y2 ); |
1423 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1431 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1424 | p->drawLine( x, y2, x2, y2 ); | 1432 | p->drawLine( x, y2, x2, y2 ); |
1425 | --y2; | 1433 | --y2; |
1426 | } | 1434 | } |
1427 | ++i, ++x, ++y, --x2; | 1435 | ++i, ++x, ++y, --x2; |
1428 | } | 1436 | } |
1429 | for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { | 1437 | for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) { |
1430 | p->setPen( cg->light() ); | 1438 | p->setPen( cg->light() ); |
1431 | p->drawLine( x, y, x, y2 ); | 1439 | p->drawLine( x, y, x, y2 ); |
1432 | p->drawLine( x, y, x2, y ); | 1440 | p->drawLine( x, y, x2, y ); |
1433 | p->setPen( cg->dark() ); | 1441 | p->setPen( cg->dark() ); |
1434 | p->drawLine( x2, y + 1, x2, y2 ); | 1442 | p->drawLine( x2, y + 1, x2, y2 ); |
1435 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1443 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1436 | p->drawLine( x, y2, x2, y2 ); | 1444 | p->drawLine( x, y2, x2, y2 ); |
1437 | --y2; | 1445 | --y2; |
1438 | } | 1446 | } |
1439 | } | 1447 | } |
1440 | if ( isPixmap( widget ) ) | 1448 | if ( isPixmap( widget ) ) |
1441 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, | 1449 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, |
1442 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); | 1450 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); |
1443 | else | 1451 | else |
1444 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); | 1452 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); |
1445 | } | 1453 | } |
1446 | else if ( tb->shape() == QTabBar::RoundedBelow ) { | 1454 | else if ( tb->shape() == QTabBar::RoundedBelow ) { |
1447 | if ( !selected ) { | 1455 | if ( !selected ) { |
1448 | p->fillRect( x, y2 - 2, x2 - x + 1, 2, | 1456 | p->fillRect( x, y2 - 2, x2 - x + 1, 2, |
1449 | tb->palette().normal().brush( QColorGroup::Background ) ); | 1457 | tb->palette().normal().brush( QColorGroup::Background ) ); |
1450 | y2 -= 2; | 1458 | y2 -= 2; |
1451 | } | 1459 | } |
1452 | p->setPen( cg->text() ); | 1460 | p->setPen( cg->text() ); |
1453 | i = 0; | 1461 | i = 0; |
1454 | if ( i < bWidth ) { | 1462 | if ( i < bWidth ) { |
1455 | p->drawLine( x, y, x, y2 - 1 ); | 1463 | p->drawLine( x, y, x, y2 - 1 ); |
1456 | p->drawLine( x2, y, x2, y2 - 1 ); | 1464 | p->drawLine( x2, y, x2, y2 - 1 ); |
1457 | p->drawLine( x + 1, y2, x2 - 1, y2 ); | 1465 | p->drawLine( x + 1, y2, x2 - 1, y2 ); |
1458 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1466 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1459 | p->drawLine( x, y, x2, y ); | 1467 | p->drawLine( x, y, x2, y ); |
1460 | ++y; | 1468 | ++y; |
1461 | } | 1469 | } |
1462 | } | 1470 | } |
1463 | for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { | 1471 | for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) { |
1464 | p->drawLine( x, y, x, y2 ); | 1472 | p->drawLine( x, y, x, y2 ); |
1465 | p->drawLine( x2, y, x2, y2 ); | 1473 | p->drawLine( x2, y, x2, y2 ); |
1466 | p->drawLine( x, y2, x2, y2 ); | 1474 | p->drawLine( x, y2, x2, y2 ); |
1467 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1475 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1468 | p->drawLine( x, y, x2, y ); | 1476 | p->drawLine( x, y, x2, y ); |
1469 | ++y; | 1477 | ++y; |
1470 | } | 1478 | } |
1471 | } | 1479 | } |
1472 | i = 0; | 1480 | i = 0; |
1473 | if ( i < hWidth && bWidth == 0 ) { | 1481 | if ( i < hWidth && bWidth == 0 ) { |
1474 | p->setPen( cg->dark() ); | 1482 | p->setPen( cg->dark() ); |
1475 | p->drawLine( x + 1, y2, x2 - 1, y2 ); | 1483 | p->drawLine( x + 1, y2, x2 - 1, y2 ); |
1476 | p->drawLine( x2, y, x2, y2 - 1 ); | 1484 | p->drawLine( x2, y, x2, y2 - 1 ); |
1477 | p->setPen( cg->light() ); | 1485 | p->setPen( cg->light() ); |
1478 | p->drawLine( x, y, x, y2 - 1 ); | 1486 | p->drawLine( x, y, x, y2 - 1 ); |
1479 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1487 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1480 | p->drawLine( x, y, x2, y ); | 1488 | p->drawLine( x, y, x2, y ); |
1481 | ++y; | 1489 | ++y; |
1482 | } | 1490 | } |
1483 | ++i, ++x, --x2, --y2; | 1491 | ++i, ++x, --x2, --y2; |
1484 | } | 1492 | } |
1485 | for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { | 1493 | for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) { |
1486 | p->setPen( cg->dark() ); | 1494 | p->setPen( cg->dark() ); |
1487 | p->drawLine( x, y2, x2, y2 ); | 1495 | p->drawLine( x, y2, x2, y2 ); |
1488 | p->drawLine( x2, y, x2, y2 ); | 1496 | p->drawLine( x2, y, x2, y2 ); |
1489 | p->setPen( cg->light() ); | 1497 | p->setPen( cg->light() ); |
1490 | p->drawLine( x, y, x, y2 ); | 1498 | p->drawLine( x, y, x, y2 ); |
1491 | if ( selected ? activeTabLine() : inactiveTabLine() ) { | 1499 | if ( selected ? activeTabLine() : inactiveTabLine() ) { |
1492 | p->drawLine( x, y, x2, y ); | 1500 | p->drawLine( x, y, x2, y ); |
1493 | ++y; | 1501 | ++y; |
1494 | } | 1502 | } |
1495 | } | 1503 | } |
1496 | if ( isPixmap( widget ) ) | 1504 | if ( isPixmap( widget ) ) |
1497 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, | 1505 | p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1, |
1498 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); | 1506 | *scalePixmap( x2 - x + 1, y2 - y + 1, widget ) ); |
1499 | else | 1507 | else |
1500 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); | 1508 | p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() ); |
1501 | } | 1509 | } |
1502 | else | 1510 | else |
1503 | QCommonStyle::drawTab( p, tb, t, selected ); | 1511 | QCommonStyle::drawTab( p, tb, t, selected ); |
1504 | } | 1512 | } |
1505 | 1513 | ||
1506 | void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, | 1514 | void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t, |
1507 | bool selected ) | 1515 | bool selected ) |
1508 | { | 1516 | { |
1509 | QRect r( t->r ); | 1517 | QRect r( t->r ); |
1510 | 1518 | ||
1511 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 1519 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
1512 | if ( !selected ) | 1520 | if ( !selected ) |
1513 | r.setTop( r.top() + 2 ); | 1521 | r.setTop( r.top() + 2 ); |
1514 | p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); | 1522 | p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() ); |
1515 | QBrush b( color1, SolidPattern ); | 1523 | QBrush b( color1, SolidPattern ); |
1516 | p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); | 1524 | p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b ); |
1517 | } | 1525 | } |
1518 | else if ( tb->shape() == QTabBar::RoundedBelow ) { | 1526 | else if ( tb->shape() == QTabBar::RoundedBelow ) { |
1519 | if ( !selected ) | 1527 | if ( !selected ) |
1520 | r.setBottom( r.bottom() - 2 ); | 1528 | r.setBottom( r.bottom() - 2 ); |
1521 | p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); | 1529 | p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() ); |
1522 | QBrush b( color1, SolidPattern ); | 1530 | QBrush b( color1, SolidPattern ); |
1523 | p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); | 1531 | p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b ); |
1524 | } | 1532 | } |
1525 | else | 1533 | else |
1526 | QCommonStyle::drawTabMask( p, tb, t, selected ); | 1534 | QCommonStyle::drawTabMask( p, tb, t, selected ); |
1527 | 1535 | ||
1528 | } | 1536 | } |
1529 | 1537 | ||
1530 | 1538 | ||
1531 | //#include "kthemestyle.moc" | 1539 | //#include "kthemestyle.moc" |
1532 | 1540 | ||
diff --git a/noncore/styles/theme/othemestyle.h b/noncore/styles/theme/othemestyle.h index 02bec78..52445c4 100644 --- a/noncore/styles/theme/othemestyle.h +++ b/noncore/styles/theme/othemestyle.h | |||
@@ -1,365 +1,371 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> | 2 | Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License version 2 as published by the Free Software Foundation. | 6 | License version 2 as published by the Free Software Foundation. |
7 | 7 | ||
8 | This library is distributed in the hope that it will be useful, | 8 | This library is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | Library General Public License for more details. | 11 | Library General Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU Library General Public License | 13 | You should have received a copy of the GNU Library General Public License |
14 | along with this library; see the file COPYING.LIB. If not, write to | 14 | along with this library; see the file COPYING.LIB. If not, write to |
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
16 | Boston, MA 02111-1307, USA. | 16 | Boston, MA 02111-1307, USA. |
17 | */ | 17 | */ |
18 | #ifndef __KTHEMESTYLE_H | 18 | #ifndef __KTHEMESTYLE_H |
19 | #define __KTHEMESTYLE_H | 19 | #define __KTHEMESTYLE_H |
20 | 20 | ||
21 | #include "othemebase.h" | 21 | #include "othemebase.h" |
22 | #include <qwindowdefs.h> | 22 | #include <qwindowdefs.h> |
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qbutton.h> | 24 | #include <qbutton.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qscrollbar.h> | 26 | #include <qscrollbar.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | 28 | ||
29 | 29 | ||
30 | /** | 30 | /** |
31 | * KDE themed styles. | 31 | * KDE themed styles. |
32 | * | 32 | * |
33 | * It provides methods for | 33 | * It provides methods for |
34 | * drawing most widgets with user-specified borders, highlights, pixmaps, | 34 | * drawing most widgets with user-specified borders, highlights, pixmaps, |
35 | * etc. It also handles various other settings such as scrollbar types, | 35 | * etc. It also handles various other settings such as scrollbar types, |
36 | * rounded buttons, and shading types. For a full list of parameters this | 36 | * rounded buttons, and shading types. For a full list of parameters this |
37 | * class handles refer to the KDE theme configuration documentation. | 37 | * class handles refer to the KDE theme configuration documentation. |
38 | * | 38 | * |
39 | */ | 39 | */ |
40 | 40 | ||
41 | class OThemeStyle: public OThemeBase | 41 | class OThemeStyle: public OThemeBase |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | /** | 45 | /** |
46 | * Construct a new @ref OThemeStyle object. | 46 | * Construct a new @ref OThemeStyle object. |
47 | * | 47 | * |
48 | * @param configFile A KConfig file to use as the theme configuration. | 48 | * @param configFile A KConfig file to use as the theme configuration. |
49 | * Defaults to ~/.kderc. | 49 | * Defaults to ~/.kderc. |
50 | */ | 50 | */ |
51 | OThemeStyle( const QString &configFile = QString::null ); | 51 | OThemeStyle( const QString &configFile = QString::null ); |
52 | ~OThemeStyle(); | 52 | ~OThemeStyle(); |
53 | virtual void polish( QWidget* ); | 53 | virtual void polish( QWidget* ); |
54 | virtual void unPolish( QWidget* ); | 54 | virtual void unPolish( QWidget* ); |
55 | /** | 55 | /** |
56 | * By default this just sets the background brushes to the pixmapped | 56 | * By default this just sets the background brushes to the pixmapped |
57 | * background. | 57 | * background. |
58 | */ | 58 | */ |
59 | virtual void polish( QApplication *app ); | 59 | virtual void polish( QApplication *app ); |
60 | virtual void unPolish( QApplication* ); | 60 | virtual void unPolish( QApplication* ); |
61 | 61 | ||
62 | /// @internal | 62 | /// @internal |
63 | // to make it possible for derived classes to overload this function | 63 | // to make it possible for derived classes to overload this function |
64 | virtual void polish( QPalette& pal ); | 64 | virtual void polish( QPalette& pal ); |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * This is a convenience method for drawing widgets with | 67 | * This is a convenience method for drawing widgets with |
68 | * borders, highlights, pixmaps, colors, etc... | 68 | * borders, highlights, pixmaps, colors, etc... |
69 | * You specify the widget type and it will draw it according to the | 69 | * You specify the widget type and it will draw it according to the |
70 | * config file settings. | 70 | * config file settings. |
71 | * | 71 | * |
72 | * @param p The QPainter to draw on. | 72 | * @param p The QPainter to draw on. |
73 | * @param g The color group to use. | 73 | * @param g The color group to use. |
74 | * @param rounded @p true if the widget is rounded, @p false if rectangular. | 74 | * @param rounded @p true if the widget is rounded, @p false if rectangular. |
75 | * @param type The widget type to paint. | 75 | * @param type The widget type to paint. |
76 | * @param fill An optional fill brush. Currently ignored (the config file | 76 | * @param fill An optional fill brush. Currently ignored (the config file |
77 | * is used instead). | 77 | * is used instead). |
78 | */ | 78 | */ |
79 | virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h, | 79 | virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h, |
80 | const QColorGroup &g, bool sunken = FALSE, | 80 | const QColorGroup &g, bool sunken = FALSE, |
81 | bool rounded = FALSE, WidgetType type = Bevel, | 81 | bool rounded = FALSE, WidgetType type = Bevel, |
82 | const QBrush *fill = 0 ); | 82 | const QBrush *fill = 0 ); |
83 | /** | 83 | /** |
84 | * Draw a mask with for widgets that may be rounded. | 84 | * Draw a mask with for widgets that may be rounded. |
85 | * | 85 | * |
86 | *Currently used | 86 | *Currently used |
87 | * by pushbuttons and comboboxes. | 87 | * by pushbuttons and comboboxes. |
88 | * | 88 | * |
89 | * @param p The QPainter to draw on. | 89 | * @param p The QPainter to draw on. |
90 | * @param rounded @p true if the widget is rounded, @p false if rectangular. | 90 | * @param rounded @p true if the widget is rounded, @p false if rectangular. |
91 | */ | 91 | */ |
92 | virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h, | 92 | virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h, |
93 | bool rounded ); | 93 | bool rounded ); |
94 | /** | 94 | /** |
95 | * Draw a pushbutton. | 95 | * Draw a pushbutton. |
96 | * | 96 | * |
97 | * This calls @ref drawBaseButton() with @p PushButton as the | 97 | * This calls @ref drawBaseButton() with @p PushButton as the |
98 | * widget type. | 98 | * widget type. |
99 | */ | 99 | */ |
100 | virtual void drawButton( QPainter *p, int x, int y, int w, int h, | 100 | virtual void drawButton( QPainter *p, int x, int y, int w, int h, |
101 | const QColorGroup &g, bool sunken = FALSE, | 101 | const QColorGroup &g, bool sunken = FALSE, |
102 | const QBrush *fill = 0 ); | 102 | const QBrush *fill = 0 ); |
103 | /** | 103 | /** |
104 | * Draw a bevel button. | 104 | * Draw a bevel button. |
105 | * | 105 | * |
106 | * This calls @ref drawBaseButton() with Bevel as the | 106 | * This calls @ref drawBaseButton() with Bevel as the |
107 | * widget type. | 107 | * widget type. |
108 | */ | 108 | */ |
109 | virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h, | 109 | virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h, |
110 | const QColorGroup &g, bool sunken = FALSE, | 110 | const QColorGroup &g, bool sunken = FALSE, |
111 | const QBrush *fill = 0 ); | 111 | const QBrush *fill = 0 ); |
112 | /** | ||
113 | * Draw a toolbar button. | ||
114 | */ | ||
115 | virtual void drawToolButton ( QPainter *p, int x, int y, int w, int h, | ||
116 | const QColorGroup &g, bool sunken = FALSE, | ||
117 | const QBrush *fill = 0 ); | ||
112 | #if 0 | 118 | #if 0 |
113 | /** | 119 | /** |
114 | * Draw a toolbar button. | 120 | * Draw a toolbar button. |
115 | */ | 121 | */ |
116 | virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h, | 122 | virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h, |
117 | const QColorGroup &g, bool sunken = false, | 123 | const QColorGroup &g, bool sunken = false, |
118 | bool raised = true, bool enabled = true, | 124 | bool raised = true, bool enabled = true, |
119 | bool popup = false, KToolButtonType type = Icon, | 125 | bool popup = false, KToolButtonType type = Icon, |
120 | const QString &btext = QString::null, | 126 | const QString &btext = QString::null, |
121 | const QPixmap *icon = NULL, | 127 | const QPixmap *icon = NULL, |
122 | QFont *font = NULL, QWidget *btn = NULL ); | 128 | QFont *font = NULL, QWidget *btn = NULL ); |
123 | /** | 129 | /** |
124 | * Draw the handle used in toolbars. | 130 | * Draw the handle used in toolbars. |
125 | */ | 131 | */ |
126 | void drawKBarHandle( QPainter *p, int x, int y, int w, int h, | 132 | void drawKBarHandle( QPainter *p, int x, int y, int w, int h, |
127 | const QColorGroup &g, | 133 | const QColorGroup &g, |
128 | KToolBarPos type, QBrush *fill = NULL ); | 134 | KToolBarPos type, QBrush *fill = NULL ); |
129 | 135 | ||
130 | /** | 136 | /** |
131 | * Draw a toolbar. | 137 | * Draw a toolbar. |
132 | */ | 138 | */ |
133 | void drawKToolBar( QPainter *p, int x, int y, int w, int h, | 139 | void drawKToolBar( QPainter *p, int x, int y, int w, int h, |
134 | const QColorGroup &g, KToolBarPos type, | 140 | const QColorGroup &g, KToolBarPos type, |
135 | QBrush *fill = NULL ); | 141 | QBrush *fill = NULL ); |
136 | #endif | 142 | #endif |
137 | /** | 143 | /** |
138 | * Return the space available in a pushbutton, taking configurable | 144 | * Return the space available in a pushbutton, taking configurable |
139 | * borders and highlights into account. | 145 | * borders and highlights into account. |
140 | */ | 146 | */ |
141 | virtual QRect buttonRect( int x, int y, int w, int h ); | 147 | virtual QRect buttonRect( int x, int y, int w, int h ); |
142 | /** | 148 | /** |
143 | * Draw an arrow in the style specified by the config file. | 149 | * Draw an arrow in the style specified by the config file. |
144 | */ | 150 | */ |
145 | virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down, | 151 | virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down, |
146 | int x, int y, int w, int h, const QColorGroup &g, | 152 | int x, int y, int w, int h, const QColorGroup &g, |
147 | bool enabled = true, const QBrush *fill = 0 ); | 153 | bool enabled = true, const QBrush *fill = 0 ); |
148 | /** | 154 | /** |
149 | * Return the size of the exclusive indicator pixmap if one is specified | 155 | * Return the size of the exclusive indicator pixmap if one is specified |
150 | * in the config file, otherwise it uses the base style's size. | 156 | * in the config file, otherwise it uses the base style's size. |
151 | */ | 157 | */ |
152 | virtual QSize exclusiveIndicatorSize() const; | 158 | virtual QSize exclusiveIndicatorSize() const; |
153 | /** | 159 | /** |
154 | * Draw an exclusive indicator widget. | 160 | * Draw an exclusive indicator widget. |
155 | * | 161 | * |
156 | * If a pixmap is specified in the | 162 | * If a pixmap is specified in the |
157 | * config file that is used, otherwise the base style's widget is drawn. | 163 | * config file that is used, otherwise the base style's widget is drawn. |
158 | */ | 164 | */ |
159 | virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w, | 165 | virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w, |
160 | int h, const QColorGroup &g, bool on, | 166 | int h, const QColorGroup &g, bool on, |
161 | bool down = FALSE, | 167 | bool down = FALSE, |
162 | bool enabled = TRUE ); | 168 | bool enabled = TRUE ); |
163 | /** | 169 | /** |
164 | * Set the mask of an exclusive indicator widget. | 170 | * Set the mask of an exclusive indicator widget. |
165 | * | 171 | * |
166 | * If a pixmap is specified | 172 | * If a pixmap is specified |
167 | * it is masked according to it's transparent pixels, otherwise the | 173 | * it is masked according to it's transparent pixels, otherwise the |
168 | * base style's mask is used. | 174 | * base style's mask is used. |
169 | */ | 175 | */ |
170 | virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, | 176 | virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w, |
171 | int h, bool on ); | 177 | int h, bool on ); |
172 | /** | 178 | /** |
173 | * Set the mask of an indicator widget. | 179 | * Set the mask of an indicator widget. |
174 | * | 180 | * |
175 | * If a pixmap is specified | 181 | * If a pixmap is specified |
176 | * it is masked according to it's transparent pixels, otherwise the | 182 | * it is masked according to it's transparent pixels, otherwise the |
177 | * base style's mask is used. | 183 | * base style's mask is used. |
178 | */ | 184 | */ |
179 | virtual void drawIndicatorMask( QPainter *p, int x, int y, int w, int h, | 185 | virtual void drawIndicatorMask( QPainter *p, int x, int y, int w, int h, |
180 | int state ); | 186 | int state ); |
181 | /** | 187 | /** |
182 | * Set the mask for pushbuttons. | 188 | * Set the mask for pushbuttons. |
183 | */ | 189 | */ |
184 | virtual void drawButtonMask( QPainter *p, int x, int y, int w, int h ); | 190 | virtual void drawButtonMask( QPainter *p, int x, int y, int w, int h ); |
185 | /** | 191 | /** |
186 | * Set the mask for combo boxes. | 192 | * Set the mask for combo boxes. |
187 | */ | 193 | */ |
188 | virtual void drawComboButtonMask( QPainter *p, int x, int y, int w, int h ); | 194 | virtual void drawComboButtonMask( QPainter *p, int x, int y, int w, int h ); |
189 | /** | 195 | /** |
190 | * Return the size of the indicator pixmap if one is specified | 196 | * Return the size of the indicator pixmap if one is specified |
191 | * in the config file, otherwise it uses the base style's size. | 197 | * in the config file, otherwise it uses the base style's size. |
192 | */ | 198 | */ |
193 | virtual QSize indicatorSize() const; | 199 | virtual QSize indicatorSize() const; |
194 | /** | 200 | /** |
195 | * Draw an indicator widget. | 201 | * Draw an indicator widget. |
196 | * | 202 | * |
197 | * If a pixmap is specified in the | 203 | * If a pixmap is specified in the |
198 | * config file that is used, otherwise the base style's widget is drawn. | 204 | * config file that is used, otherwise the base style's widget is drawn. |
199 | */ | 205 | */ |
200 | virtual void drawIndicator( QPainter* p, int x, int y, int w, int h, | 206 | virtual void drawIndicator( QPainter* p, int x, int y, int w, int h, |
201 | const QColorGroup &g, int state, | 207 | const QColorGroup &g, int state, |
202 | bool down = FALSE, bool enabled = TRUE ); | 208 | bool down = FALSE, bool enabled = TRUE ); |
203 | /** | 209 | /** |
204 | * Draw a combobox. | 210 | * Draw a combobox. |
205 | */ | 211 | */ |
206 | virtual void drawComboButton( QPainter *p, int x, int y, int w, int h, | 212 | virtual void drawComboButton( QPainter *p, int x, int y, int w, int h, |
207 | const QColorGroup &g, bool sunken = FALSE, | 213 | const QColorGroup &g, bool sunken = FALSE, |
208 | bool editable = FALSE, bool enabled = TRUE, | 214 | bool editable = FALSE, bool enabled = TRUE, |
209 | const QBrush *fill = 0 ); | 215 | const QBrush *fill = 0 ); |
210 | /** | 216 | /** |
211 | * Draw a pushbutton. | 217 | * Draw a pushbutton. |
212 | */ | 218 | */ |
213 | virtual void drawPushButton( QPushButton* btn, QPainter *p ); | 219 | virtual void drawPushButton( QPushButton* btn, QPainter *p ); |
214 | /** | 220 | /** |
215 | * Return the amount of button content displacement specified by the | 221 | * Return the amount of button content displacement specified by the |
216 | * config file. | 222 | * config file. |
217 | */ | 223 | */ |
218 | virtual void getButtonShift( int &x, int &y ); | 224 | virtual void getButtonShift( int &x, int &y ); |
219 | /** | 225 | /** |
220 | * Return the frame width. | 226 | * Return the frame width. |
221 | */ | 227 | */ |
222 | virtual int defaultFrameWidth() const; | 228 | virtual int defaultFrameWidth() const; |
223 | /** | 229 | /** |
224 | * Calculate the metrics of the scrollbar controls according to the | 230 | * Calculate the metrics of the scrollbar controls according to the |
225 | * layout specified by the config file. | 231 | * layout specified by the config file. |
226 | */ | 232 | */ |
227 | virtual void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& ); | 233 | virtual void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int& ); |
228 | /** | 234 | /** |
229 | * Draw a themed scrollbar. | 235 | * Draw a themed scrollbar. |
230 | */ | 236 | */ |
231 | virtual void drawScrollBarControls( QPainter*, const QScrollBar*, | 237 | virtual void drawScrollBarControls( QPainter*, const QScrollBar*, |
232 | int sliderStart, uint controls, | 238 | int sliderStart, uint controls, |
233 | uint activeControl ); | 239 | uint activeControl ); |
234 | /** | 240 | /** |
235 | * Return the control that the given point is over according to the | 241 | * Return the control that the given point is over according to the |
236 | * layout in the config file. | 242 | * layout in the config file. |
237 | */ | 243 | */ |
238 | virtual ScrollControl scrollBarPointOver( const QScrollBar*, | 244 | virtual ScrollControl scrollBarPointOver( const QScrollBar*, |
239 | int sliderStart, const QPoint& ); | 245 | int sliderStart, const QPoint& ); |
240 | /** | 246 | /** |
241 | * Return the configurable default slider length. | 247 | * Return the configurable default slider length. |
242 | */ | 248 | */ |
243 | virtual int sliderLength() const; | 249 | virtual int sliderLength() const; |
244 | /** | 250 | /** |
245 | * Draw a slider control. | 251 | * Draw a slider control. |
246 | */ | 252 | */ |
247 | virtual void drawSlider( QPainter *p, int x, int y, int w, int h, | 253 | virtual void drawSlider( QPainter *p, int x, int y, int w, int h, |
248 | const QColorGroup &g, Orientation, bool tickAbove, | 254 | const QColorGroup &g, Orientation, bool tickAbove, |
249 | bool tickBelow ); | 255 | bool tickBelow ); |
250 | /** | 256 | /** |
251 | * Draw a slider groove. | 257 | * Draw a slider groove. |
252 | */ | 258 | */ |
253 | void drawSliderGroove( QPainter *p, int x, int y, int w, int h, | 259 | void drawSliderGroove( QPainter *p, int x, int y, int w, int h, |
254 | const QColorGroup& g, QCOORD c, | 260 | const QColorGroup& g, QCOORD c, |
255 | Orientation ); | 261 | Orientation ); |
256 | /** | 262 | /** |
257 | * Draw the mask for a slider (both the control and groove. | 263 | * Draw the mask for a slider (both the control and groove. |
258 | */ | 264 | */ |
259 | virtual void drawSliderMask( QPainter *p, int x, int y, int w, int h, | 265 | virtual void drawSliderMask( QPainter *p, int x, int y, int w, int h, |
260 | Orientation, bool tickAbove, bool tickBelow ); | 266 | Orientation, bool tickAbove, bool tickBelow ); |
261 | // void drawSliderGrooveMask(QPainter *p,int x, int y, int w, int h, | 267 | // void drawSliderGrooveMask(QPainter *p,int x, int y, int w, int h, |
262 | // QCOORD c, Orientation ); | 268 | // QCOORD c, Orientation ); |
263 | /** | 269 | /** |
264 | * Convience method for drawing themed scrollbar grooves. | 270 | * Convience method for drawing themed scrollbar grooves. |
265 | * | 271 | * |
266 | * Since the | 272 | * Since the |
267 | * grooves may be a scaled pixmap you cannot just bitblt the pixmap at | 273 | * grooves may be a scaled pixmap you cannot just bitblt the pixmap at |
268 | * any offset. This generates a cached pixmap at full size if needed and | 274 | * any offset. This generates a cached pixmap at full size if needed and |
269 | * then copies the requested area. | 275 | * then copies the requested area. |
270 | * | 276 | * |
271 | * @param p The painter to draw on. | 277 | * @param p The painter to draw on. |
272 | * @param sb The scrollbar (usually given by drawScrollBarControls). | 278 | * @param sb The scrollbar (usually given by drawScrollBarControls). |
273 | * @param horizontal Is the scrollBar horizontal? | 279 | * @param horizontal Is the scrollBar horizontal? |
274 | * @param r The rectangle to fill. | 280 | * @param r The rectangle to fill. |
275 | * @param g The color group to use. | 281 | * @param g The color group to use. |
276 | */ | 282 | */ |
277 | virtual void drawScrollBarGroove( QPainter *p, const QScrollBar *sb, | 283 | virtual void drawScrollBarGroove( QPainter *p, const QScrollBar *sb, |
278 | bool horizontal, QRect r, QColorGroup g ); | 284 | bool horizontal, QRect r, QColorGroup g ); |
279 | /** | 285 | /** |
280 | * Draw a shaded rectangle using the given style. | 286 | * Draw a shaded rectangle using the given style. |
281 | * | 287 | * |
282 | * @param p The painter to draw on. | 288 | * @param p The painter to draw on. |
283 | * @param g The color group to use. | 289 | * @param g The color group to use. |
284 | * @param rounded Draws a rounded shape if true. Requires bWidth to be | 290 | * @param rounded Draws a rounded shape if true. Requires bWidth to be |
285 | * at least 1. | 291 | * at least 1. |
286 | * @param hWidth The highlight width. | 292 | * @param hWidth The highlight width. |
287 | * @param bWidth The border width. | 293 | * @param bWidth The border width. |
288 | * @param style The shading style to use. | 294 | * @param style The shading style to use. |
289 | */ | 295 | */ |
290 | virtual void drawShade( QPainter *p, int x, int y, int w, int h, | 296 | virtual void drawShade( QPainter *p, int x, int y, int w, int h, |
291 | const QColorGroup &g, bool sunken, bool rounded, | 297 | const QColorGroup &g, bool sunken, bool rounded, |
292 | int hWidth, int bWidth, ShadeStyle style ); | 298 | int hWidth, int bWidth, ShadeStyle style ); |
293 | /** | 299 | /** |
294 | * Draw the text for a pushbutton. | 300 | * Draw the text for a pushbutton. |
295 | */ | 301 | */ |
296 | virtual void drawPushButtonLabel( QPushButton *btn, QPainter *p ); | 302 | virtual void drawPushButtonLabel( QPushButton *btn, QPainter *p ); |
297 | /** | 303 | /** |
298 | * Draw a menubar. | 304 | * Draw a menubar. |
299 | */ | 305 | */ |
300 | #if 0 | 306 | #if 0 |
301 | 307 | ||
302 | void drawKMenuBar( QPainter *p, int x, int y, int w, int h, | 308 | void drawKMenuBar( QPainter *p, int x, int y, int w, int h, |
303 | const QColorGroup &g, bool macMode, | 309 | const QColorGroup &g, bool macMode, |
304 | QBrush *fill = NULL ); | 310 | QBrush *fill = NULL ); |
305 | #endif | 311 | #endif |
306 | /** | 312 | /** |
307 | * Draw a menubar item. | 313 | * Draw a menubar item. |
308 | */ | 314 | */ |
309 | #if 0 | 315 | #if 0 |
310 | 316 | ||
311 | virtual void drawKMenuItem( QPainter *p, int x, int y, int w, int h, | 317 | virtual void drawKMenuItem( QPainter *p, int x, int y, int w, int h, |
312 | const QColorGroup &g, bool active, | 318 | const QColorGroup &g, bool active, |
313 | QMenuItem *item, QBrush *fill = NULL ); | 319 | QMenuItem *item, QBrush *fill = NULL ); |
314 | #endif | 320 | #endif |
315 | /** | 321 | /** |
316 | * Return the width of the splitter as specified in the config file. | 322 | * Return the width of the splitter as specified in the config file. |
317 | */ | 323 | */ |
318 | virtual int splitterWidth() const; | 324 | virtual int splitterWidth() const; |
319 | /** | 325 | /** |
320 | * Draw a splitter widget. | 326 | * Draw a splitter widget. |
321 | */ | 327 | */ |
322 | virtual void drawSplitter( QPainter *p, int x, int y, int w, int h, | 328 | virtual void drawSplitter( QPainter *p, int x, int y, int w, int h, |
323 | const QColorGroup &g, Orientation ); | 329 | const QColorGroup &g, Orientation ); |
324 | /** | 330 | /** |
325 | * Draw a checkmark. | 331 | * Draw a checkmark. |
326 | */ | 332 | */ |
327 | virtual void drawCheckMark( QPainter *p, int x, int y, int w, int h, | 333 | virtual void drawCheckMark( QPainter *p, int x, int y, int w, int h, |
328 | const QColorGroup &g, bool act, bool dis ); | 334 | const QColorGroup &g, bool act, bool dis ); |
329 | /** | 335 | /** |
330 | * Draw a menu item. | 336 | * Draw a menu item. |
331 | * | 337 | * |
332 | * Note: This method manually handles applying | 338 | * Note: This method manually handles applying |
333 | * inactive menu backgrounds to the entire widget. | 339 | * inactive menu backgrounds to the entire widget. |
334 | */ | 340 | */ |
335 | virtual void drawPopupMenuItem( QPainter *p, bool checkable, int maxpmw, | 341 | virtual void drawPopupMenuItem( QPainter *p, bool checkable, int maxpmw, |
336 | int tab, QMenuItem *mi, const QPalette &pal, | 342 | int tab, QMenuItem *mi, const QPalette &pal, |
337 | bool act, bool enabled, int x, int y, int w, | 343 | bool act, bool enabled, int x, int y, int w, |
338 | int h ); | 344 | int h ); |
339 | int popupMenuItemHeight( bool checkable, QMenuItem *mi, | 345 | int popupMenuItemHeight( bool checkable, QMenuItem *mi, |
340 | const QFontMetrics &fm ); | 346 | const QFontMetrics &fm ); |
341 | /** | 347 | /** |
342 | * Draw the focus rectangle. | 348 | * Draw the focus rectangle. |
343 | */ | 349 | */ |
344 | void drawFocusRect( QPainter *p, const QRect &r, const QColorGroup &g, | 350 | void drawFocusRect( QPainter *p, const QRect &r, const QColorGroup &g, |
345 | const QColor *c = 0, bool atBorder = false ); | 351 | const QColor *c = 0, bool atBorder = false ); |
346 | /** | 352 | /** |
347 | * Draw a @ref KProgess bar. | 353 | * Draw a @ref KProgess bar. |
348 | */ | 354 | */ |
349 | // virtual void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, | 355 | // virtual void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, |
350 | // const QColorGroup &g, QBrush *fill); | 356 | // const QColorGroup &g, QBrush *fill); |
351 | /** | 357 | /** |
352 | * Return the background for @ref KProgress. | 358 | * Return the background for @ref KProgress. |
353 | */ | 359 | */ |
354 | // virtual void getKProgressBackground(const QColorGroup &g, QBrush &bg); | 360 | // virtual void getKProgressBackground(const QColorGroup &g, QBrush &bg); |
355 | virtual void tabbarMetrics( const QTabBar*, int&, int&, int& ); | 361 | virtual void tabbarMetrics( const QTabBar*, int&, int&, int& ); |
356 | virtual void drawTab( QPainter*, const QTabBar*, QTab*, bool selected ); | 362 | virtual void drawTab( QPainter*, const QTabBar*, QTab*, bool selected ); |
357 | virtual void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected ); | 363 | virtual void drawTabMask( QPainter*, const QTabBar*, QTab*, bool selected ); |
358 | protected: | 364 | protected: |
359 | QPalette oldPalette, popupPalette, indiPalette, exIndiPalette; | 365 | QPalette oldPalette, popupPalette, indiPalette, exIndiPalette; |
360 | 366 | ||
361 | class OThemeStylePrivate; | 367 | class OThemeStylePrivate; |
362 | OThemeStylePrivate *d; | 368 | OThemeStylePrivate *d; |
363 | }; | 369 | }; |
364 | 370 | ||
365 | #endif | 371 | #endif |