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