-rw-r--r-- | noncore/styles/metal/metal.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/styles/metal/metal.cpp b/noncore/styles/metal/metal.cpp index 5cb2d22..e13a249 100644 --- a/noncore/styles/metal/metal.cpp +++ b/noncore/styles/metal/metal.cpp | |||
@@ -1,505 +1,504 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | ||
3 | ** | 2 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 4 | ** |
6 | ** This file is part of an example program for Qt. This example | 5 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 6 | ** program may be used, distributed and modified without limitation. |
8 | ** | 7 | ** |
9 | *****************************************************************************/ | 8 | *****************************************************************************/ |
10 | 9 | ||
11 | #include "metal.h" | 10 | #include "metal.h" |
12 | #include <qapplication.h> | 11 | #include <qapplication.h> |
13 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
14 | #include <qscrollbar.h> | 13 | #include <qscrollbar.h> |
15 | #include <limits.h> | 14 | #include <limits.h> |
16 | 15 | ||
17 | 16 | ||
18 | ///////////////////////////////////////////////////////// | 17 | ///////////////////////////////////////////////////////// |
19 | #include "stonedark.xpm" | 18 | #include "stonedark.xpm" |
20 | #include "stone1.xpm" | 19 | #include "stone1.xpm" |
21 | #include "marble.xpm" | 20 | #include "marble.xpm" |
22 | /////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////// |
23 | 22 | ||
24 | 23 | ||
25 | 24 | ||
26 | MetalStyle::MetalStyle() : QWindowsStyle() { } | 25 | MetalStyle::MetalStyle() : QWindowsStyle() { } |
27 | 26 | ||
28 | /*! | 27 | /*! |
29 | Reimplementation from QStyle | 28 | Reimplementation from QStyle |
30 | */ | 29 | */ |
31 | void MetalStyle::polish( QApplication *app) | 30 | void MetalStyle::polish( QApplication *app) |
32 | { | 31 | { |
33 | oldPalette = app->palette(); | 32 | oldPalette = app->palette(); |
34 | 33 | ||
35 | // we simply create a nice QColorGroup with a couple of fancy | 34 | // we simply create a nice QColorGroup with a couple of fancy |
36 | // pixmaps here and apply to it all widgets | 35 | // pixmaps here and apply to it all widgets |
37 | 36 | ||
38 | QFont f("times", app->font().pointSize() ); | 37 | QFont f("times", app->font().pointSize() ); |
39 | f.setBold( TRUE ); | 38 | f.setBold( TRUE ); |
40 | f.setItalic( TRUE ); | 39 | f.setItalic( TRUE ); |
41 | app->setFont( f, TRUE, "QMenuBar"); | 40 | app->setFont( f, TRUE, "QMenuBar"); |
42 | app->setFont( f, TRUE, "QPopupMenu"); | 41 | app->setFont( f, TRUE, "QPopupMenu"); |
43 | 42 | ||
44 | 43 | ||
45 | //QPixmap button( stone1_xpm ); | 44 | //QPixmap button( stone1_xpm ); |
46 | QPixmap button( stonedark_xpm ); | 45 | QPixmap button( stonedark_xpm ); |
47 | QPixmap background(marble_xpm); | 46 | QPixmap background(marble_xpm); |
48 | #if 0 | 47 | #if 0 |
49 | 48 | ||
50 | int i; | 49 | int i; |
51 | for (i=0; i<img.numColors(); i++) { | 50 | for (i=0; i<img.numColors(); i++) { |
52 | QRgb rgb = img.color(i); | 51 | QRgb rgb = img.color(i); |
53 | QColor c(rgb); | 52 | QColor c(rgb); |
54 | rgb = c.dark().rgb(); | 53 | rgb = c.dark().rgb(); |
55 | img.setColor(i,rgb); | 54 | img.setColor(i,rgb); |
56 | } | 55 | } |
57 | QPixmap mid; | 56 | QPixmap mid; |
58 | mid.convertFromImage(img); | 57 | mid.convertFromImage(img); |
59 | 58 | ||
60 | img = orig; | 59 | img = orig; |
61 | for (i=0; i<img.numColors(); i++) { | 60 | for (i=0; i<img.numColors(); i++) { |
62 | QRgb rgb = img.color(i); | 61 | QRgb rgb = img.color(i); |
63 | QColor c(rgb); | 62 | QColor c(rgb); |
64 | rgb = c.light().rgb(); | 63 | rgb = c.light().rgb(); |
65 | img.setColor(i,rgb); | 64 | img.setColor(i,rgb); |
66 | } | 65 | } |
67 | QPixmap light; | 66 | QPixmap light; |
68 | light.convertFromImage(img); | 67 | light.convertFromImage(img); |
69 | 68 | ||
70 | img = orig; | 69 | img = orig; |
71 | for (i=0; i<img.numColors(); i++) { | 70 | for (i=0; i<img.numColors(); i++) { |
72 | QRgb rgb = img.color(i); | 71 | QRgb rgb = img.color(i); |
73 | QColor c(rgb); | 72 | QColor c(rgb); |
74 | rgb = c.dark().rgb(); | 73 | rgb = c.dark().rgb(); |
75 | img.setColor(i,rgb); | 74 | img.setColor(i,rgb); |
76 | } | 75 | } |
77 | QPixmap dark; | 76 | QPixmap dark; |
78 | dark.convertFromImage(img); | 77 | dark.convertFromImage(img); |
79 | #else | 78 | #else |
80 | QPixmap dark( 1, 1 ); dark.fill( red.dark() ); | 79 | QPixmap dark( 1, 1 ); dark.fill( red.dark() ); |
81 | QPixmap mid( stone1_xpm ); | 80 | QPixmap mid( stone1_xpm ); |
82 | QPixmap light( stone1_xpm );//1, 1 ); light.fill( green ); | 81 | QPixmap light( stone1_xpm );//1, 1 ); light.fill( green ); |
83 | #endif | 82 | #endif |
84 | QPalette op = app->palette(); | 83 | QPalette op = app->palette(); |
85 | 84 | ||
86 | QColor backCol( 227,227,227 ); | 85 | QColor backCol( 227,227,227 ); |
87 | 86 | ||
88 | // QPalette op(white); | 87 | // QPalette op(white); |
89 | QColorGroup active (op.normal().foreground(), | 88 | QColorGroup active (op.normal().foreground(), |
90 | QBrush(op.normal().button(),button), | 89 | QBrush(op.normal().button(),button), |
91 | QBrush(op.normal().light(), light), | 90 | QBrush(op.normal().light(), light), |
92 | QBrush(op.normal().dark(), dark), | 91 | QBrush(op.normal().dark(), dark), |
93 | QBrush(op.normal().mid(), mid), | 92 | QBrush(op.normal().mid(), mid), |
94 | op.normal().text(), | 93 | op.normal().text(), |
95 | Qt::white, | 94 | Qt::white, |
96 | op.normal().base(),// QColor(236,182,120), | 95 | op.normal().base(),// QColor(236,182,120), |
97 | QBrush(backCol, background) | 96 | QBrush(backCol, background) |
98 | ); | 97 | ); |
99 | active.setColor( QColorGroup::ButtonText, Qt::white ); | 98 | active.setColor( QColorGroup::ButtonText, Qt::white ); |
100 | active.setColor( QColorGroup::Shadow, Qt::black ); | 99 | active.setColor( QColorGroup::Shadow, Qt::black ); |
101 | QColorGroup disabled (op.disabled().foreground(), | 100 | QColorGroup disabled (op.disabled().foreground(), |
102 | QBrush(op.disabled().button(),button), | 101 | QBrush(op.disabled().button(),button), |
103 | QBrush(op.disabled().light(), light), | 102 | QBrush(op.disabled().light(), light), |
104 | op.disabled().dark(), | 103 | op.disabled().dark(), |
105 | QBrush(op.disabled().mid(), mid), | 104 | QBrush(op.disabled().mid(), mid), |
106 | op.disabled().text(), | 105 | op.disabled().text(), |
107 | Qt::white, | 106 | Qt::white, |
108 | op.disabled().base(),// QColor(236,182,120), | 107 | op.disabled().base(),// QColor(236,182,120), |
109 | QBrush(backCol, background) | 108 | QBrush(backCol, background) |
110 | ); | 109 | ); |
111 | 110 | ||
112 | QPalette newPalette( active, disabled, active ); | 111 | QPalette newPalette( active, disabled, active ); |
113 | app->setPalette( newPalette, TRUE ); | 112 | app->setPalette( newPalette, TRUE ); |
114 | } | 113 | } |
115 | 114 | ||
116 | /*! | 115 | /*! |
117 | Reimplementation from QStyle | 116 | Reimplementation from QStyle |
118 | */ | 117 | */ |
119 | void MetalStyle::unPolish( QApplication *app) | 118 | void MetalStyle::unPolish( QApplication *app) |
120 | { | 119 | { |
121 | app->setPalette(oldPalette, TRUE); | 120 | app->setPalette(oldPalette, TRUE); |
122 | app->setFont( app->font(), TRUE ); | 121 | app->setFont( app->font(), TRUE ); |
123 | } | 122 | } |
124 | 123 | ||
125 | /*! | 124 | /*! |
126 | Reimplementation from QStyle | 125 | Reimplementation from QStyle |
127 | */ | 126 | */ |
128 | void MetalStyle::polish( QWidget* w) | 127 | void MetalStyle::polish( QWidget* w) |
129 | { | 128 | { |
130 | 129 | ||
131 | // the polish function sets some widgets to transparent mode and | 130 | // the polish function sets some widgets to transparent mode and |
132 | // some to translate background mode in order to get the full | 131 | // some to translate background mode in order to get the full |
133 | // benefit from the nice pixmaps in the color group. | 132 | // benefit from the nice pixmaps in the color group. |
134 | 133 | ||
135 | if (w->inherits("QPushButton")){ | 134 | if (w->inherits("QPushButton")){ |
136 | w->setBackgroundMode( QWidget::NoBackground ); | 135 | w->setBackgroundMode( QWidget::NoBackground ); |
137 | return; | 136 | return; |
138 | } | 137 | } |
139 | 138 | ||
140 | if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ | 139 | if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ |
141 | return; | 140 | return; |
142 | } | 141 | } |
143 | 142 | ||
144 | if ( !w->isTopLevel() ) { | 143 | if ( !w->isTopLevel() ) { |
145 | if ( w->inherits("QGroupBox") | 144 | if ( w->inherits("QGroupBox") |
146 | || w->inherits("QTabWidget") ) { | 145 | || w->inherits("QTabWidget") ) { |
147 | w->setAutoMask( TRUE ); | 146 | w->setAutoMask( TRUE ); |
148 | return; | 147 | return; |
149 | } | 148 | } |
150 | if (w->inherits("QLabel") | 149 | if (w->inherits("QLabel") |
151 | || w->inherits("QSlider") | 150 | || w->inherits("QSlider") |
152 | || w->inherits("QButton") | 151 | || w->inherits("QButton") |
153 | || w->inherits("QProgressBar") | 152 | || w->inherits("QProgressBar") |
154 | ){ | 153 | ){ |
155 | w->setBackgroundOrigin( QWidget::ParentOrigin ); | 154 | w->setBackgroundOrigin( QWidget::ParentOrigin ); |
156 | } | 155 | } |
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | void MetalStyle::unPolish( QWidget* w) | 159 | void MetalStyle::unPolish( QWidget* w) |
161 | { | 160 | { |
162 | 161 | ||
163 | // the polish function sets some widgets to transparent mode and | 162 | // the polish function sets some widgets to transparent mode and |
164 | // some to translate background mode in order to get the full | 163 | // some to translate background mode in order to get the full |
165 | // benefit from the nice pixmaps in the color group. | 164 | // benefit from the nice pixmaps in the color group. |
166 | 165 | ||
167 | if (w->inherits("QPushButton")){ | 166 | if (w->inherits("QPushButton")){ |
168 | w->setBackgroundMode( QWidget::PaletteButton ); | 167 | w->setBackgroundMode( QWidget::PaletteButton ); |
169 | return; | 168 | return; |
170 | } | 169 | } |
171 | 170 | ||
172 | if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ | 171 | if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ |
173 | return; | 172 | return; |
174 | } | 173 | } |
175 | 174 | ||
176 | if ( !w->isTopLevel() ) { | 175 | if ( !w->isTopLevel() ) { |
177 | if ( w->inherits("QGroupBox") | 176 | if ( w->inherits("QGroupBox") |
178 | || w->inherits("QTabWidget") ) { | 177 | || w->inherits("QTabWidget") ) { |
179 | w->setAutoMask( FALSE ); | 178 | w->setAutoMask( FALSE ); |
180 | return; | 179 | return; |
181 | } | 180 | } |
182 | if (w->inherits("QLabel") | 181 | if (w->inherits("QLabel") |
183 | || w->inherits("QSlider") | 182 | || w->inherits("QSlider") |
184 | || w->inherits("QButton") | 183 | || w->inherits("QButton") |
185 | || w->inherits("QProgressBar") | 184 | || w->inherits("QProgressBar") |
186 | ){ | 185 | ){ |
187 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); | 186 | w->setBackgroundOrigin( QWidget::WidgetOrigin ); |
188 | } | 187 | } |
189 | } | 188 | } |
190 | 189 | ||
191 | } | 190 | } |
192 | 191 | ||
193 | /*! | 192 | /*! |
194 | Draw a metallic button, sunken if \a sunken is TRUE, horizontal if | 193 | Draw a metallic button, sunken if \a sunken is TRUE, horizontal if |
195 | /a horz is TRUE. | 194 | /a horz is TRUE. |
196 | */ | 195 | */ |
197 | 196 | ||
198 | void MetalStyle::drawMetalButton( QPainter *p, int x, int y, int w, int h, | 197 | void MetalStyle::drawMetalButton( QPainter *p, int x, int y, int w, int h, |
199 | bool sunken, bool horz ) | 198 | bool sunken, bool horz ) |
200 | { | 199 | { |
201 | QColor top1("#878769691515"); | 200 | QColor top1("#878769691515"); |
202 | QColor top2("#C6C6B4B44949"); | 201 | QColor top2("#C6C6B4B44949"); |
203 | 202 | ||
204 | QColor bot2("#70705B5B1414"); | 203 | QColor bot2("#70705B5B1414"); |
205 | QColor bot1("56564A4A0E0E"); //first from the bottom | 204 | QColor bot1("56564A4A0E0E"); //first from the bottom |
206 | 205 | ||
207 | QColor highlight("#E8E8DDDD6565"); | 206 | QColor highlight("#E8E8DDDD6565"); |
208 | QColor subh1("#CECEBDBD5151"); | 207 | QColor subh1("#CECEBDBD5151"); |
209 | QColor subh2("#BFBFACAC4545"); | 208 | QColor subh2("#BFBFACAC4545"); |
210 | 209 | ||
211 | QColor topgrad("#B9B9A5A54040"); | 210 | QColor topgrad("#B9B9A5A54040"); |
212 | QColor botgrad("#89896C6C1A1A"); | 211 | QColor botgrad("#89896C6C1A1A"); |
213 | 212 | ||
214 | 213 | ||
215 | int x2 = x + w - 1; | 214 | int x2 = x + w - 1; |
216 | int y2 = y + h - 1; | 215 | int y2 = y + h - 1; |
217 | 216 | ||
218 | //frame: | 217 | //frame: |
219 | 218 | ||
220 | p->setPen( top1 ); | 219 | p->setPen( top1 ); |
221 | p->drawLine( x, y2, x, y ); | 220 | p->drawLine( x, y2, x, y ); |
222 | p->drawLine( x, y, x2-1, y ); | 221 | p->drawLine( x, y, x2-1, y ); |
223 | p->setPen( top2 ); | 222 | p->setPen( top2 ); |
224 | p->drawLine( x+1, y2 -1, x+1, y+1 ); | 223 | p->drawLine( x+1, y2 -1, x+1, y+1 ); |
225 | p->drawLine( x+1, y+1 , x2-2, y+1 ); | 224 | p->drawLine( x+1, y+1 , x2-2, y+1 ); |
226 | 225 | ||
227 | p->setPen( bot1 ); | 226 | p->setPen( bot1 ); |
228 | p->drawLine( x+1, y2, x2, y2 ); | 227 | p->drawLine( x+1, y2, x2, y2 ); |
229 | p->drawLine( x2, y2, x2, y ); | 228 | p->drawLine( x2, y2, x2, y ); |
230 | p->setPen( bot2 ); | 229 | p->setPen( bot2 ); |
231 | p->drawLine( x+1, y2-1, x2-1, y2-1 ); | 230 | p->drawLine( x+1, y2-1, x2-1, y2-1 ); |
232 | p->drawLine( x2-1, y2-1, x2-1, y+1 ); | 231 | p->drawLine( x2-1, y2-1, x2-1, y+1 ); |
233 | 232 | ||
234 | // highlight: | 233 | // highlight: |
235 | int i = 0; | 234 | int i = 0; |
236 | int x1 = x + 2; | 235 | int x1 = x + 2; |
237 | int y1 = y + 2; | 236 | int y1 = y + 2; |
238 | if ( horz ) | 237 | if ( horz ) |
239 | x2 = x2 - 2; | 238 | x2 = x2 - 2; |
240 | else | 239 | else |
241 | y2 = y2 - 2; | 240 | y2 = y2 - 2; |
242 | // Note that x2/y2 mean something else from this point down... | 241 | // Note that x2/y2 mean something else from this point down... |
243 | 242 | ||
244 | #define DRAWLINE if (horz) \ | 243 | #define DRAWLINE if (horz) \ |
245 | p->drawLine( x1, y1+i, x2, y1+i ); \ | 244 | p->drawLine( x1, y1+i, x2, y1+i ); \ |
246 | else \ | 245 | else \ |
247 | p->drawLine( x1+i, y1, x1+i, y2 ); \ | 246 | p->drawLine( x1+i, y1, x1+i, y2 ); \ |
248 | i++; | 247 | i++; |
249 | 248 | ||
250 | if ( !sunken ) { | 249 | if ( !sunken ) { |
251 | p->setPen( highlight ); | 250 | p->setPen( highlight ); |
252 | DRAWLINE; | 251 | DRAWLINE; |
253 | DRAWLINE; | 252 | DRAWLINE; |
254 | p->setPen( subh1 ); | 253 | p->setPen( subh1 ); |
255 | DRAWLINE; | 254 | DRAWLINE; |
256 | p->setPen( subh2 ); | 255 | p->setPen( subh2 ); |
257 | DRAWLINE; | 256 | DRAWLINE; |
258 | } | 257 | } |
259 | // gradient: | 258 | // gradient: |
260 | int ng = (horz ? h : w) - 8; // how many lines for the gradient? | 259 | int ng = (horz ? h : w) - 8; // how many lines for the gradient? |
261 | 260 | ||
262 | int h1, h2, s1, s2, v1, v2; | 261 | int h1, h2, s1, s2, v1, v2; |
263 | if ( !sunken ) { | 262 | if ( !sunken ) { |
264 | topgrad.hsv( &h1, &s1, &v1 ); | 263 | topgrad.hsv( &h1, &s1, &v1 ); |
265 | botgrad.hsv( &h2, &s2, &v2 ); | 264 | botgrad.hsv( &h2, &s2, &v2 ); |
266 | } else { | 265 | } else { |
267 | botgrad.hsv( &h1, &s1, &v1 ); | 266 | botgrad.hsv( &h1, &s1, &v1 ); |
268 | topgrad.hsv( &h2, &s2, &v2 ); | 267 | topgrad.hsv( &h2, &s2, &v2 ); |
269 | } | 268 | } |
270 | 269 | ||
271 | if ( ng > 1 ) { | 270 | if ( ng > 1 ) { |
272 | 271 | ||
273 | for ( int j =0; j < ng; j++ ) { | 272 | for ( int j =0; j < ng; j++ ) { |
274 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), | 273 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), |
275 | s1 + ((s2-s1)*j)/(ng-1), | 274 | s1 + ((s2-s1)*j)/(ng-1), |
276 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 275 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
277 | DRAWLINE; | 276 | DRAWLINE; |
278 | } | 277 | } |
279 | } else if ( ng == 1 ) { | 278 | } else if ( ng == 1 ) { |
280 | p->setPen( QColor( (h1+h2)/2, (s1+s2)/2, (v1+v2)/2, QColor::Hsv ) ); | 279 | p->setPen( QColor( (h1+h2)/2, (s1+s2)/2, (v1+v2)/2, QColor::Hsv ) ); |
281 | DRAWLINE; | 280 | DRAWLINE; |
282 | } | 281 | } |
283 | if ( sunken ) { | 282 | if ( sunken ) { |
284 | p->setPen( subh2 ); | 283 | p->setPen( subh2 ); |
285 | DRAWLINE; | 284 | DRAWLINE; |
286 | 285 | ||
287 | p->setPen( subh1 ); | 286 | p->setPen( subh1 ); |
288 | DRAWLINE; | 287 | DRAWLINE; |
289 | 288 | ||
290 | p->setPen( highlight ); | 289 | p->setPen( highlight ); |
291 | DRAWLINE; | 290 | DRAWLINE; |
292 | DRAWLINE; | 291 | DRAWLINE; |
293 | } | 292 | } |
294 | 293 | ||
295 | } | 294 | } |
296 | 295 | ||
297 | 296 | ||
298 | 297 | ||
299 | /*! | 298 | /*! |
300 | Reimplementation from QStyle | 299 | Reimplementation from QStyle |
301 | */ | 300 | */ |
302 | void MetalStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 301 | void MetalStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
303 | const QColorGroup &, bool sunken, const QBrush*) | 302 | const QColorGroup &, bool sunken, const QBrush*) |
304 | { | 303 | { |
305 | 304 | ||
306 | drawMetalButton( p, x, y, w, h, sunken, TRUE ); | 305 | drawMetalButton( p, x, y, w, h, sunken, TRUE ); |
307 | } | 306 | } |
308 | 307 | ||
309 | /*! | 308 | /*! |
310 | Reimplementation from QStyle | 309 | Reimplementation from QStyle |
311 | */ | 310 | */ |
312 | void MetalStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 311 | void MetalStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
313 | const QColorGroup &, bool sunken, const QBrush*) | 312 | const QColorGroup &, bool sunken, const QBrush*) |
314 | { | 313 | { |
315 | MetalStyle::drawMetalButton(p, x, y, w, h, sunken, TRUE ); | 314 | MetalStyle::drawMetalButton(p, x, y, w, h, sunken, TRUE ); |
316 | } | 315 | } |
317 | 316 | ||
318 | /*! | 317 | /*! |
319 | Reimplementation from QStyle | 318 | Reimplementation from QStyle |
320 | */ | 319 | */ |
321 | void MetalStyle::drawPushButton( QPushButton* btn, QPainter *p) | 320 | void MetalStyle::drawPushButton( QPushButton* btn, QPainter *p) |
322 | { | 321 | { |
323 | QColorGroup g = btn->colorGroup(); | 322 | QColorGroup g = btn->colorGroup(); |
324 | int x1, y1, x2, y2; | 323 | int x1, y1, x2, y2; |
325 | 324 | ||
326 | btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates | 325 | btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates |
327 | 326 | ||
328 | p->setPen( g.foreground() ); | 327 | p->setPen( g.foreground() ); |
329 | p->setBrush( QBrush(g.button(),NoBrush) ); | 328 | p->setBrush( QBrush(g.button(),NoBrush) ); |
330 | 329 | ||
331 | QBrush fill; | 330 | QBrush fill; |
332 | if ( btn->isDown() ) | 331 | if ( btn->isDown() ) |
333 | fill = g.brush( QColorGroup::Mid ); | 332 | fill = g.brush( QColorGroup::Mid ); |
334 | else if ( btn->isOn() ) | 333 | else if ( btn->isOn() ) |
335 | fill = QBrush( g.mid(), Dense4Pattern ); | 334 | fill = QBrush( g.mid(), Dense4Pattern ); |
336 | else | 335 | else |
337 | fill = g.brush( QColorGroup::Button ); | 336 | fill = g.brush( QColorGroup::Button ); |
338 | 337 | ||
339 | if ( btn->isDefault() ) { | 338 | if ( btn->isDefault() ) { |
340 | QPointArray a; | 339 | QPointArray a; |
341 | a.setPoints( 9, | 340 | a.setPoints( 9, |
342 | x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, | 341 | x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, |
343 | x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1 ); | 342 | x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1 ); |
344 | p->setPen( Qt::black ); | 343 | p->setPen( Qt::black ); |
345 | p->drawPolyline( a ); | 344 | p->drawPolyline( a ); |
346 | x1 += 2; | 345 | x1 += 2; |
347 | y1 += 2; | 346 | y1 += 2; |
348 | x2 -= 2; | 347 | x2 -= 2; |
349 | y2 -= 2; | 348 | y2 -= 2; |
350 | } | 349 | } |
351 | 350 | ||
352 | drawMetalButton( p, x1, y1, x2-x1+1, y2-y1+1, btn->isOn() || btn->isDown(), | 351 | drawMetalButton( p, x1, y1, x2-x1+1, y2-y1+1, btn->isOn() || btn->isDown(), |
353 | TRUE ); // always horizontal | 352 | TRUE ); // always horizontal |
354 | 353 | ||
355 | 354 | ||
356 | if ( btn->isMenuButton() ) { | 355 | if ( btn->isMenuButton() ) { |
357 | int dx = (y1-y2-4)/3; | 356 | int dx = (y1-y2-4)/3; |
358 | drawArrow( p, DownArrow, FALSE, | 357 | drawArrow( p, DownArrow, FALSE, |
359 | x2 - dx, dx, y1, y2 - y1, | 358 | x2 - dx, dx, y1, y2 - y1, |
360 | g, btn->isEnabled() ); | 359 | g, btn->isEnabled() ); |
361 | } | 360 | } |
362 | 361 | ||
363 | if ( p->brush().style() != NoBrush ) | 362 | if ( p->brush().style() != NoBrush ) |
364 | p->setBrush( NoBrush ); | 363 | p->setBrush( NoBrush ); |
365 | 364 | ||
366 | } | 365 | } |
367 | 366 | ||
368 | 367 | ||
369 | /*! | 368 | /*! |
370 | Reimplementation from QStyle | 369 | Reimplementation from QStyle |
371 | */ | 370 | */ |
372 | void MetalStyle::drawPushButtonLabel( QPushButton* btn, QPainter *p) | 371 | void MetalStyle::drawPushButtonLabel( QPushButton* btn, QPainter *p) |
373 | { | 372 | { |
374 | QRect r = btn->rect(); | 373 | QRect r = btn->rect(); |
375 | int x, y, w, h; | 374 | int x, y, w, h; |
376 | r.rect( &x, &y, &w, &h ); | 375 | r.rect( &x, &y, &w, &h ); |
377 | 376 | ||
378 | int x1, y1, x2, y2; | 377 | int x1, y1, x2, y2; |
379 | btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates | 378 | btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates |
380 | int dx = 0; | 379 | int dx = 0; |
381 | int dy = 0; | 380 | int dy = 0; |
382 | if ( btn->isMenuButton() ) | 381 | if ( btn->isMenuButton() ) |
383 | dx = (y2-y1) / 3; | 382 | dx = (y2-y1) / 3; |
384 | if ( btn->isOn() || btn->isDown() ) { | 383 | if ( btn->isOn() || btn->isDown() ) { |
385 | dx--; | 384 | dx--; |
386 | dy--; | 385 | dy--; |
387 | } | 386 | } |
388 | if ( dx || dy ) | 387 | if ( dx || dy ) |
389 | p->translate( dx, dy ); | 388 | p->translate( dx, dy ); |
390 | 389 | ||
391 | x += 2; y += 2; w -= 4; h -= 4; | 390 | x += 2; y += 2; w -= 4; h -= 4; |
392 | QColorGroup g = btn->colorGroup(); | 391 | QColorGroup g = btn->colorGroup(); |
393 | drawItem( p, x, y, w, h, | 392 | drawItem( p, x, y, w, h, |
394 | AlignCenter|ShowPrefix, | 393 | AlignCenter|ShowPrefix, |
395 | g, btn->isEnabled(), | 394 | g, btn->isEnabled(), |
396 | btn->pixmap(), btn->text(), -1, | 395 | btn->pixmap(), btn->text(), -1, |
397 | (btn->isDown() || btn->isOn())?&btn->colorGroup().brightText():&btn->colorGroup().buttonText()); | 396 | (btn->isDown() || btn->isOn())?&btn->colorGroup().brightText():&btn->colorGroup().buttonText()); |
398 | 397 | ||
399 | if ( dx || dy ) | 398 | if ( dx || dy ) |
400 | p->translate( -dx, -dy ); | 399 | p->translate( -dx, -dy ); |
401 | } | 400 | } |
402 | 401 | ||
403 | 402 | ||
404 | void MetalStyle::drawPanel( QPainter *p, int x, int y, int w, int h, | 403 | void MetalStyle::drawPanel( QPainter *p, int x, int y, int w, int h, |
405 | const QColorGroup &g, bool sunken, | 404 | const QColorGroup &g, bool sunken, |
406 | int lineWidth, const QBrush *fill ) | 405 | int lineWidth, const QBrush *fill ) |
407 | { | 406 | { |
408 | 407 | ||
409 | QStyle::drawPanel( p, x, y, w, h, | 408 | QStyle::drawPanel( p, x, y, w, h, |
410 | g, sunken, | 409 | g, sunken, |
411 | lineWidth, fill ); | 410 | lineWidth, fill ); |
412 | } | 411 | } |
413 | 412 | ||
414 | 413 | ||
415 | /*! | 414 | /*! |
416 | Reimplemented | 415 | Reimplemented |
417 | */ | 416 | */ |
418 | 417 | ||
419 | void MetalStyle::drawSlider( QPainter *p, int x, int y, int w, int h, | 418 | void MetalStyle::drawSlider( QPainter *p, int x, int y, int w, int h, |
420 | const QColorGroup &, Orientation orient, | 419 | const QColorGroup &, Orientation orient, |
421 | bool /*tickAbove*/, bool /*tickBelow*/ ) | 420 | bool /*tickAbove*/, bool /*tickBelow*/ ) |
422 | { | 421 | { |
423 | drawMetalButton( p, x, y, w, h, FALSE, orient != Horizontal ); | 422 | drawMetalButton( p, x, y, w, h, FALSE, orient != Horizontal ); |
424 | } | 423 | } |
425 | 424 | ||
426 | 425 | ||
427 | void MetalStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, | 426 | void MetalStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, |
428 | int sliderStart, uint controls, | 427 | int sliderStart, uint controls, |
429 | uint activeControl ) | 428 | uint activeControl ) |
430 | { | 429 | { |
431 | QWindowsStyle::drawScrollBarControls( p, sb, sliderStart, controls & ~(AddLine|SubLine|Slider), | 430 | QWindowsStyle::drawScrollBarControls( p, sb, sliderStart, controls & ~(AddLine|SubLine|Slider), |
432 | activeControl & ~(AddLine|SubLine|Slider) ); | 431 | activeControl & ~(AddLine|SubLine|Slider) ); |
433 | bool horz = sb->orientation() == QScrollBar::Horizontal; | 432 | bool horz = sb->orientation() == QScrollBar::Horizontal; |
434 | int b = 2; | 433 | int b = 2; |
435 | int w = horz ? sb->height() : sb->width(); | 434 | int w = horz ? sb->height() : sb->width(); |
436 | 435 | ||
437 | QColorGroup g = sb->colorGroup(); | 436 | QColorGroup g = sb->colorGroup(); |
438 | 437 | ||
439 | int sliderMin, sliderMax, sliderLength, buttonDim; | 438 | int sliderMin, sliderMax, sliderLength, buttonDim; |
440 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 439 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
441 | 440 | ||
442 | if (sliderStart > sliderMax) { // sanity check | 441 | if (sliderStart > sliderMax) { // sanity check |
443 | sliderStart = sliderMax; | 442 | sliderStart = sliderMax; |
444 | } | 443 | } |
445 | bool maxedOut = (sb->maxValue() == sb->minValue()); | 444 | bool maxedOut = (sb->maxValue() == sb->minValue()); |
446 | 445 | ||
447 | 446 | ||
448 | if ( controls & AddLine ) { | 447 | if ( controls & AddLine ) { |
449 | bool sunken = activeControl & AddLine; | 448 | bool sunken = activeControl & AddLine; |
450 | QRect r( b, b, w-2*b, w-2*b ) ; | 449 | QRect r( b, b, w-2*b, w-2*b ) ; |
451 | if ( horz ) | 450 | if ( horz ) |
452 | r.moveBy( sb->width() - w, 0 ); | 451 | r.moveBy( sb->width() - w, 0 ); |
453 | else | 452 | else |
454 | r.moveBy( 0, sb->height() - w ); | 453 | r.moveBy( 0, sb->height() - w ); |
455 | 454 | ||
456 | drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), | 455 | drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), |
457 | sunken, !horz ); | 456 | sunken, !horz ); |
458 | drawArrow( p, horz ? RightArrow : DownArrow, sunken, | 457 | drawArrow( p, horz ? RightArrow : DownArrow, sunken, |
459 | r.x(), r.y(), r.width(), r.height(), g, !maxedOut ); | 458 | r.x(), r.y(), r.width(), r.height(), g, !maxedOut ); |
460 | 459 | ||
461 | } | 460 | } |
462 | if ( controls & SubLine ) { | 461 | if ( controls & SubLine ) { |
463 | bool sunken = activeControl & SubLine; | 462 | bool sunken = activeControl & SubLine; |
464 | QRect r( b, b, w-2*b, w-2*b ) ; | 463 | QRect r( b, b, w-2*b, w-2*b ) ; |
465 | drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), | 464 | drawMetalButton( p, r.x(), r.y(), r.width(), r.height(), |
466 | sunken, !horz ); | 465 | sunken, !horz ); |
467 | drawArrow( p, horz ? LeftArrow : UpArrow, sunken, | 466 | drawArrow( p, horz ? LeftArrow : UpArrow, sunken, |
468 | r.x(), r.y(), r.width(), r.height(), g, !maxedOut ); | 467 | r.x(), r.y(), r.width(), r.height(), g, !maxedOut ); |
469 | } | 468 | } |
470 | 469 | ||
471 | QRect sliderR; | 470 | QRect sliderR; |
472 | if ( horz ) { | 471 | if ( horz ) { |
473 | sliderR .setRect( sliderStart, b, sliderLength, w-2*b ); | 472 | sliderR .setRect( sliderStart, b, sliderLength, w-2*b ); |
474 | } else { | 473 | } else { |
475 | sliderR .setRect( b, sliderStart, w-2*b, sliderLength ); | 474 | sliderR .setRect( b, sliderStart, w-2*b, sliderLength ); |
476 | } | 475 | } |
477 | if ( controls & Slider ) { | 476 | if ( controls & Slider ) { |
478 | if ( !maxedOut ) { | 477 | if ( !maxedOut ) { |
479 | drawMetalButton( p, sliderR.x(), sliderR.y(), | 478 | drawMetalButton( p, sliderR.x(), sliderR.y(), |
480 | sliderR.width(), sliderR.height(), | 479 | sliderR.width(), sliderR.height(), |
481 | FALSE, horz ); | 480 | FALSE, horz ); |
482 | } | 481 | } |
483 | } | 482 | } |
484 | 483 | ||
485 | } | 484 | } |
486 | 485 | ||
487 | 486 | ||
488 | void MetalStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, | 487 | void MetalStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, |
489 | const QColorGroup &g, bool sunken, | 488 | const QColorGroup &g, bool sunken, |
490 | bool /*editable*/, | 489 | bool /*editable*/, |
491 | bool enabled, | 490 | bool enabled, |
492 | const QBrush *fill) | 491 | const QBrush *fill) |
493 | { | 492 | { |
494 | 493 | ||
495 | qDrawWinPanel(p, x, y, w, h, g, TRUE, | 494 | qDrawWinPanel(p, x, y, w, h, g, TRUE, |
496 | fill?fill:(enabled?&g.brush( QColorGroup::Base ): | 495 | fill?fill:(enabled?&g.brush( QColorGroup::Base ): |
497 | &g.brush( QColorGroup::Background ))); | 496 | &g.brush( QColorGroup::Background ))); |
498 | 497 | ||
499 | 498 | ||
500 | drawMetalButton( p, x+w-2-16, y+2, 16, h-4, sunken, TRUE ); | 499 | drawMetalButton( p, x+w-2-16, y+2, 16, h-4, sunken, TRUE ); |
501 | 500 | ||
502 | drawArrow( p, QStyle::DownArrow, sunken, | 501 | drawArrow( p, QStyle::DownArrow, sunken, |
503 | x+w-2-16+ 2, y+2+ 2, 16- 4, h-4- 4, g, enabled ); | 502 | x+w-2-16+ 2, y+2+ 2, 16- 4, h-4- 4, g, enabled ); |
504 | 503 | ||
505 | } | 504 | } |