2 Copyright (c) 2000-2001 Trolltech AS (info@trolltech.com)
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files (the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 DEALINGS IN THE SOFTWARE.
23 #include "lightstyle-v2.h"
25 #include "QtGui/QMenuBar"
26 #include "QtGui/QApplication"
27 #include "QtGui/QPainter"
28 #include "QtGui/QColorGroup"
29 #include "QtGui/QPushButton"
30 #include "QtGui/qdrawutil.h"
31 #include "QtGui/QProgressBar"
32 #include "QtGui/QScrollBar"
33 #include "QtGui/QTabBar"
34 #include "QtCore/QPointer"
35 #include "QtGui/QLayout"
36 #include "QtGui/QLineEdit"
37 #include "QtGui/QImage"
38 #include "QtGui/QComboBox"
39 #include "QtGui/QSlider"
40 #include "QtGui/QStyleFactory"
41 #include <Qt3Support/Q3PointArray>
44 class LightStyleV2Private
50 basestyle
= QStyleFactory::create( "Windows" );
52 basestyle
= QStyleFactory::create( QStyleFactory::keys().first() );
54 qFatal( "LightStyle: could not find a basestyle!" );
57 ~LightStyleV2Private()
66 static LightStyleV2Private
*singleton
= 0;
69 LightStyleV2::LightStyleV2()
70 : KStyle(AllowMenuTransparency
)
73 singleton
= new LightStyleV2Private
;
78 LightStyleV2::~LightStyleV2()
80 if (singleton
&& --singleton
->ref
<= 0) {
86 void LightStyleV2::polishPopupMenu( QMenu
* menu
)
88 KStyle::polishPopupMenu(menu
);
91 static void drawLightBevel(QPainter
*p
, const QRect
&r
, const QColorGroup
&cg
,
92 QStyle::State flags
, const QBrush
*fill
= 0)
95 bool sunken
= (flags
& (QStyle::State_Down
| QStyle::State_On
|
96 QStyle::State_Sunken
));
101 if (flags
& (QStyle::State_Down
| QStyle::State_On
|
102 QStyle::State_Sunken
| QStyle::State_Raised
)) {
107 p
->setPen(cg
.light());
109 p
->drawLine(r
.x() + 1, r
.y() + 2,
110 r
.x() + 1, r
.y() + r
.height() - 3); // left
111 p
->drawLine(r
.x() + 1, r
.y() + 1,
112 r
.x() + r
.width() - 2, r
.y() + 1); // top
115 p
->setPen(cg
.light());
119 p
->drawLine(r
.x() + r
.width() - 2, r
.y() + 2,
120 r
.x() + r
.width() - 2, r
.y() + r
.height() - 3); // right
121 p
->drawLine(r
.x() + 1, r
.y() + r
.height() - 2,
122 r
.x() + r
.width() - 2, r
.y() + r
.height() - 2); // bottom
124 br
.adjust(2, 2, -2, -2);
126 br
.adjust(1, 1, -1, -1);
129 if (fill
) p
->fillRect(br
, *fill
);
132 void LightStyleV2::drawPrimitive( PrimitiveElement pe
,
135 const QColorGroup
&cg
,
137 const QStyleOption
&data
) const
140 case PE_HeaderSection
:
142 flags
= ((flags
| Style_Sunken
) ^ Style_Sunken
) | Style_Raised
;
143 //Don't show pressed too often (as in light 3)
144 QBrush
fill(cg
.background());
145 if (flags
& QStyle::State_Enabled
)
146 fill
.setColor(cg
.button());
148 drawLightBevel(p
, r
, cg
, flags
, &fill
);
149 p
->setPen( cg
.buttonText() );
153 case PE_ButtonCommand
:
158 if (flags
& QStyle::State_Enabled
) {
159 if (flags
& (QStyle::State_Down
|
161 QStyle::State_Sunken
))
162 fill
= &cg
.brush(QPalette::Midlight
);
164 fill
= &cg
.brush(QPalette::Button
);
166 fill
= &cg
.brush(QPalette::Background
);
167 drawLightBevel(p
, r
, cg
, flags
, fill
);
171 case PE_ButtonDropDown
:
175 (flags
& (QStyle::State_Down
| QStyle::State_On
| QStyle::State_Sunken
));
177 if (flags
& QStyle::State_Enabled
) {
179 thefill
= cg
.brush(QPalette::Midlight
);
181 thefill
= cg
.brush(QPalette::Button
);
183 thefill
= cg
.brush(QPalette::Background
);
185 p
->setPen(cg
.dark());
186 p
->drawLine(r
.topLeft(), r
.topRight());
187 p
->drawLine(r
.topRight(), r
.bottomRight());
188 p
->drawLine(r
.bottomRight(), r
.bottomLeft());
190 if (flags
& (QStyle::State_Down
| QStyle::State_On
|
191 QStyle::State_Sunken
| QStyle::State_Raised
)) {
196 p
->setPen(cg
.light());
198 p
->drawLine(r
.x(), r
.y() + 2,
199 r
.x(), r
.y() + r
.height() - 3); // left
200 p
->drawLine(r
.x(), r
.y() + 1,
201 r
.x() + r
.width() - 2, r
.y() + 1); // top
204 p
->setPen(cg
.light());
208 p
->drawLine(r
.x() + r
.width() - 2, r
.y() + 2,
209 r
.x() + r
.width() - 2, r
.y() + r
.height() - 3); // right
210 p
->drawLine(r
.x() + 1, r
.y() + r
.height() - 2,
211 r
.x() + r
.width() - 2, r
.y() + r
.height() - 2); // bottom
214 p
->fillRect(r
.x() + 1, r
.y() + 2, r
.width() - 3, r
.height() - 4, thefill
);
218 case PE_ButtonDefault
:
219 p
->setPen(cg
.dark());
220 p
->setBrush(cg
.light());
226 if (! (flags
& Style_Enabled
))
227 fill
= &cg
.brush(QPalette::Background
);
228 else if (flags
& Style_Down
)
229 fill
= &cg
.brush(QPalette::Mid
);
231 fill
= &cg
.brush(QPalette::Base
);
232 drawLightBevel(p
, r
, cg
, flags
| Style_Sunken
, fill
);
234 p
->setPen(cg
.text());
235 if (flags
& Style_NoChange
) {
236 p
->drawLine(r
.x() + 3, r
.y() + r
.height() / 2,
237 r
.x() + r
.width() - 4, r
.y() + r
.height() / 2);
238 p
->drawLine(r
.x() + 3, r
.y() + 1 + r
.height() / 2,
239 r
.x() + r
.width() - 4, r
.y() + 1 + r
.height() / 2);
240 p
->drawLine(r
.x() + 3, r
.y() - 1 + r
.height() / 2,
241 r
.x() + r
.width() - 4, r
.y() - 1 + r
.height() / 2);
242 } else if (flags
& Style_On
) {
243 p
->drawLine(r
.x() + 4, r
.y() + 3,
244 r
.x() + r
.width() - 4, r
.y() + r
.height() - 5);
245 p
->drawLine(r
.x() + 3, r
.y() + 3,
246 r
.x() + r
.width() - 4, r
.y() + r
.height() - 4);
247 p
->drawLine(r
.x() + 3, r
.y() + 4,
248 r
.x() + r
.width() - 5, r
.y() + r
.height() - 4);
249 p
->drawLine(r
.x() + 3, r
.y() + r
.height() - 5,
250 r
.x() + r
.width() - 5, r
.y() + 3);
251 p
->drawLine(r
.x() + 3, r
.y() + r
.height() - 4,
252 r
.x() + r
.width() - 4, r
.y() + 3);
253 p
->drawLine(r
.x() + 4, r
.y() + r
.height() - 4,
254 r
.x() + r
.width() - 4, r
.y() + 4);
259 case PE_ExclusiveIndicator
:
261 QRect br
= r
, // bevel rect
262 cr
= r
, // contents rect
263 ir
= r
; // indicator rect
264 br
.adjust(1, 1, -1, -1);
265 cr
.adjust(2, 2, -2, -2);
266 ir
.adjust(3, 3, -3, -3);
268 p
->fillRect(r
, cg
.brush(QPalette::Background
));
270 p
->setPen(cg
.dark());
271 p
->drawArc(r
, 0, 16*360);
273 p
->drawArc(br
, 45*16, 180*16);
274 p
->setPen(cg
.light());
275 p
->drawArc(br
, 235*16, 180*16);
277 p
->setPen(flags
& Style_Down
? cg
.mid() :
278 (flags
& Style_Enabled
? cg
.base() : cg
.background()));
279 p
->setBrush(flags
& Style_Down
? cg
.mid() :
280 (flags
& Style_Enabled
? cg
.base() : cg
.background()));
283 if (flags
& Style_On
) {
284 p
->setBrush(cg
.text());
291 case PE_DockWindowHandle
:
294 bool drawTitle
= false;
295 if ( p
&& p
->device()->devType() == QInternal::Widget
) {
296 QWidget
*w
= (QWidget
*) p
->device();
297 QWidget
*p
= w
->parentWidget();
298 if (p
->inherits("QDockWindow") && ! p
->inherits("QToolBar")) {
300 title
= p
->caption();
304 flags
|= Style_Raised
;
305 if (flags
& Style_Horizontal
) {
307 QPixmap
pm(r
.height(), r
.width());
309 p2
.fillRect(0, 0, pm
.width(), pm
.height(),
310 cg
.brush(QPalette::Highlight
));
311 p2
.setPen(cg
.highlightedText());
312 p2
.drawText(0, 0, pm
.width(), pm
.height(), Qt::AlignCenter
, title
);
318 p
->drawPixmap(r
.x(), r
.y(), pm
);
320 p
->fillRect(r
, cg
.background());
321 p
->setPen(cg
.mid().dark());
322 p
->drawLine(r
.right() - 6, r
.top() + 2,
323 r
.right() - 6, r
.bottom() - 2);
324 p
->drawLine(r
.right() - 3, r
.top() + 2,
325 r
.right() - 3, r
.bottom() - 2);
326 p
->setPen(cg
.light());
327 p
->drawLine(r
.right() - 5, r
.top() + 2,
328 r
.right() - 5, r
.bottom() - 2);
329 p
->drawLine(r
.right() - 2, r
.top() + 2,
330 r
.right() - 2, r
.bottom() - 2);
334 p
->fillRect(r
, cg
.brush(QPalette::Highlight
));
335 p
->setPen(cg
.highlightedText());
336 p
->drawText(r
, Qt::AlignCenter
, title
);
338 p
->fillRect(r
, cg
.background());
339 p
->setPen(cg
.mid().dark());
340 p
->drawLine(r
.left() + 2, r
.bottom() - 6,
341 r
.right() - 2, r
.bottom() - 6);
342 p
->drawLine(r
.left() + 2, r
.bottom() - 3,
343 r
.right() - 2, r
.bottom() - 3);
344 p
->setPen(cg
.light());
345 p
->drawLine(r
.left() + 2, r
.bottom() - 5,
346 r
.right() - 2, r
.bottom() - 5);
347 p
->drawLine(r
.left() + 2, r
.bottom() - 2,
348 r
.right() - 2, r
.bottom() - 2);
354 case PE_DockWindowSeparator
:
356 if (r
.width() > 20 || r
.height() > 20) {
357 if (flags
& Style_Horizontal
) {
358 p
->setPen(cg
.mid().dark(120));
359 p
->drawLine(r
.left() + 1, r
.top() + 6, r
.left() + 1, r
.bottom() - 6);
360 p
->setPen(cg
.light());
361 p
->drawLine(r
.left() + 2, r
.top() + 6, r
.left() + 2, r
.bottom() - 6);
363 p
->setPen(cg
.mid().dark(120));
364 p
->drawLine(r
.left() + 6, r
.top() + 1, r
.right() - 6, r
.top() + 1);
365 p
->setPen(cg
.light());
366 p
->drawLine(r
.left() + 6, r
.top() + 2, r
.right() - 6, r
.top() + 2);
369 QCommonStyle::drawPrimitive(pe
, p
, r
, cg
, flags
, data
);
374 if (flags
& Style_Horizontal
)
375 flags
&= ~Style_Horizontal
;
377 flags
|= Style_Horizontal
;
378 // fall through intended
380 case PE_DockWindowResizeHandle
:
382 p
->fillRect(r
, cg
.background());
383 if (flags
& Style_Horizontal
) {
384 p
->setPen(cg
.highlight().light());
385 p
->drawLine(r
.left() + 1, r
.top() + 1, r
.right() - 1, r
.top() + 1);
386 p
->setPen(cg
.highlight());
387 p
->drawLine(r
.left() + 1, r
.top() + 2, r
.right() - 1, r
.top() + 2);
388 p
->setPen(cg
.highlight().dark());
389 p
->drawLine(r
.left() + 1, r
.top() + 3, r
.right() - 1, r
.top() + 3);
391 p
->setPen(cg
.highlight().light());
392 p
->drawLine(r
.left() + 1, r
.top() + 1, r
.left() + 1, r
.bottom() - 1);
393 p
->setPen(cg
.highlight());
394 p
->drawLine(r
.left() + 2, r
.top() + 1, r
.left() + 2, r
.bottom() - 1);
395 p
->setPen(cg
.highlight().dark());
396 p
->drawLine(r
.left() + 3, r
.top() + 1, r
.left() + 3, r
.bottom() - 1);
403 case PE_PanelLineEdit
:
404 case PE_PanelTabWidget
:
407 int lw
= data
.isDefault() ?
408 pixelMetric(PM_DefaultFrameWidth
) : data
.lineWidth();
410 if ( ! ( flags
& Style_Sunken
) )
411 flags
|= Style_Raised
;
413 drawLightBevel(p
, r
, cg
, flags
);
415 QCommonStyle::drawPrimitive(pe
, p
, r
, cg
, flags
, data
);
419 case PE_PanelDockWindow
:
421 int lw
= data
.isDefault() ?
422 pixelMetric(PM_DockWindowFrameWidth
) : data
.lineWidth();
425 drawLightBevel(p
, r
, cg
, flags
| Style_Raised
,
426 &cg
.brush(QPalette::Button
));
428 QCommonStyle::drawPrimitive(pe
, p
, r
, cg
, flags
, data
);
432 case PE_PanelMenuBar
:
434 int lw
= data
.isDefault() ?
435 pixelMetric(PM_MenuBarFrameWidth
) : data
.lineWidth();
438 drawLightBevel(p
, r
, cg
, flags
, &cg
.brush(QPalette::Button
));
440 QCommonStyle::drawPrimitive(pe
, p
, r
, cg
, flags
, data
);
444 case PE_ScrollBarSubLine
:
446 QRect fr
= r
, ar
= r
;
449 p
->setPen(cg
.dark());
450 if (flags
& Style_Horizontal
) {
451 p
->drawLine(r
.topLeft(), r
.topRight());
452 fr
.adjust(0, 1, 0, 0);
453 ar
.adjust(0, 1, 0, 0);
456 p
->drawLine(r
.topLeft(), r
.bottomLeft());
457 fr
.adjust(1, 0, 0, 0);
458 ar
.adjust(2, 0, 0, 0);
462 p
->fillRect(fr
, cg
.brush((flags
& Style_Down
) ?
464 QPalette::Background
));
465 drawPrimitive(pe
, p
, ar
, cg
, flags
);
469 case PE_ScrollBarAddLine
:
471 QRect fr
= r
, ar
= r
;
474 p
->setPen(cg
.dark());
475 if (flags
& Style_Horizontal
) {
476 p
->drawLine(r
.topLeft(), r
.topRight());
477 fr
.adjust(0, 1, 0, 0);
478 ar
.adjust(0, 1, 0, 0);
481 p
->drawLine(r
.topLeft(), r
.bottomLeft());
482 fr
.adjust(1, 0, 0, 0);
483 ar
.adjust(2, 0, 0, 0);
487 p
->fillRect(fr
, cg
.brush((flags
& Style_Down
) ?
489 QPalette::Background
));
490 drawPrimitive(pe
, p
, ar
, cg
, flags
);
494 case PE_ScrollBarSubPage
:
495 case PE_ScrollBarAddPage
:
499 p
->setPen(cg
.dark());
500 if (flags
& Style_Horizontal
) {
501 p
->drawLine(r
.topLeft(), r
.topRight());
502 p
->setPen(cg
.background());
503 p
->drawLine(r
.left(), r
.top() + 1, r
.right(), r
.top() + 1);
504 fr
.adjust(0, 2, 0, 0);
506 p
->drawLine(r
.topLeft(), r
.bottomLeft());
507 p
->setPen(cg
.background());
508 p
->drawLine(r
.left() + 1, r
.top(), r
.left() + 1, r
.bottom());
509 fr
.adjust(2, 0, 0, 0);
512 p
->fillRect(fr
, cg
.brush((flags
& Style_Down
) ?
518 case PE_ScrollBarSlider
:
522 p
->setPen(cg
.dark());
523 if (flags
& Style_Horizontal
) {
524 p
->drawLine(r
.topLeft(), r
.topRight());
525 p
->setPen(cg
.background());
526 p
->drawLine(r
.left(), r
.top() + 1, r
.right(), r
.top() + 1);
527 fr
.adjust(0, 2, 0, -1);
529 p
->drawLine(r
.topLeft(), r
.bottomLeft());
530 p
->setPen(cg
.background());
531 p
->drawLine(r
.left() + 1, r
.top(), r
.left() + 1, r
.bottom());
532 fr
.adjust(2, 0, -1, 0);
535 drawLightBevel(p
, fr
, cg
, ((flags
| Style_Down
) ^ Style_Down
) |
536 ((flags
& Style_Enabled
) ? Style_Raised
: Style_Default
),
537 &cg
.brush(QPalette::Button
));
543 p
->setBrush(Qt::NoBrush
);
544 if (flags
& Style_FocusAtBorder
)
545 p
->setPen(cg
.shadow());
547 p
->setPen(cg
.dark());
552 case PE_ProgressBarChunk
:
553 p
->fillRect(r
.x(), r
.y() + 2, r
.width(), r
.height() - 4, cg
.highlight());
557 if (pe
== PE_HeaderArrow
) {
558 if (flags
& Style_Down
)
565 if (pe
>= PE_ArrowUp
&& pe
<= PE_ArrowLeft
) {
570 a
.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
574 a
.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
578 a
.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
582 a
.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
593 if ( flags
& Style_Enabled
) {
594 a
.translate( r
.x() + r
.width() / 2, r
.y() + r
.height() / 2 );
595 p
->setPen( cg
.buttonText() );
596 p
->drawLineSegments( a
, 0, 3 ); // draw arrow
597 p
->drawPoint( a
[6] );
599 a
.translate( r
.x() + r
.width() / 2 + 1, r
.y() + r
.height() / 2 + 1 );
600 p
->setPen( cg
.light() );
601 p
->drawLineSegments( a
, 0, 3 ); // draw arrow
602 p
->drawPoint( a
[6] );
603 a
.translate( -1, -1 );
604 p
->setPen( cg
.mid() );
605 p
->drawLineSegments( a
, 0, 3 ); // draw arrow
606 p
->drawPoint( a
[6] );
610 QCommonStyle::drawPrimitive(pe
, p
, r
, cg
, flags
, data
);
615 void LightStyleV2::drawControl( ControlElement control
,
617 const QWidget
*widget
,
619 const QColorGroup
&cg
,
621 const QStyleOption
&data
) const
626 const QTabBar
* tb
= static_cast<const QTabBar
*>(widget
);
631 tr
.adjust(0, 0, 0, -1);
632 fr
.adjust(2, 2, -2, -2);
634 if ( tb
->shape() == QTabBar:: RoundedSouth
|| tb
->shape() == QTabBar:: TriangularSouth
) {
635 tr
= r
; tr
.adjust(0, 1, 0, 0);
636 fr
= r
; fr
.adjust(2, 2,-2, -4);
640 if (! (flags
& Style_Selected
)) {
642 tr
.adjust(0, 0, 0, -1);
643 tr
.adjust(0, 0, 0, -1);
645 tr
.adjust(0, 1, 0, 0);
646 fr
.adjust(0, 1, 0, 0);
649 p
->setPen(cg
.dark());
654 p
->drawPoint(tr
.left(), tr
.top() - 1);
656 p
->drawPoint(tr
.left(), tr
.bottom() + 1);
658 p
->setPen(cg
.light());
660 p
->drawLine(tr
.left() + 1, tr
.top() + 1,
661 tr
.left() + 1, tr
.bottom() - 2);
662 p
->drawLine(tr
.left() + 1, tr
.bottom() - 1,
663 tr
.right() - 1, tr
.bottom() - 1);
665 p
->drawLine(tr
.left() + 1, tr
.bottom() - 1,
666 tr
.left() + 1, tr
.top() + 2);
667 p
->drawLine(tr
.left() + 1, tr
.top() + 1,
668 tr
.right() - 1, tr
.top() + 1);
673 p
->drawLine(tr
.left() + 1, tr
.top() - 1,
674 tr
.right(), tr
.top() - 1);
677 p
->setPen(cg
.mid()); //To match lower border of the frame
678 p
->drawLine(tr
.left(), tr
.top() - 1,
679 tr
.right(), tr
.top() - 1);
683 p
->drawLine(tr
.left() + 1, tr
.bottom() + 1,
684 tr
.right(), tr
.bottom() + 1);
686 p
->drawLine(tr
.left(), tr
.bottom() + 1,
687 tr
.right(), tr
.bottom() + 1);
693 p
->drawLine(tr
.right() - 1, tr
.bottom() - 2,
694 tr
.right() - 1, tr
.top() + 1);
696 p
->drawLine(tr
.right() - 1, tr
.top() + 2,
697 tr
.right() - 1, tr
.bottom() - 1);
700 p
->setPen(cg
.dark());
703 p
->drawLine(tr
.left(), tr
.top() - 1,
704 tr
.left(), tr
.bottom() - 1);
706 p
->drawLine(tr
.left(), tr
.bottom() + 1,
707 tr
.left(), tr
.top() + 1);
710 p
->drawLine(tr
.left(), tr
.bottom(),
711 tr
.left(), tr
.top() + 1);
713 p
->drawLine(tr
.left(), tr
.bottom(),
714 tr
.left(), tr
.top() + 1);
717 p
->drawLine(tr
.left(), tr
.bottom(),
718 tr
.right(), tr
.bottom());
719 p
->drawLine(tr
.right(), tr
.bottom() - 1,
720 tr
.right(), tr
.top());
723 p
->drawLine(tr
.left(), tr
.top(),
724 tr
.right(), tr
.top());
725 p
->drawLine(tr
.right(), tr
.top() + 1,
726 tr
.right(), tr
.bottom());
729 p
->setPen(cg
.light());
732 p
->drawLine(tr
.left() + 1, tr
.top() - 2,
733 tr
.left() + 1, tr
.bottom() - 2);
735 p
->drawLine(tr
.left() + 1, tr
.bottom() + 2,
736 tr
.left() + 1, tr
.top() + 2);
739 p
->drawLine(tr
.left() + 1, tr
.top(),
740 tr
.left() + 1, tr
.bottom() - 2);
741 p
->drawPoint(tr
.left(), tr
.top() - 1);
744 p
->drawLine(tr
.left() + 1, tr
.bottom(),
745 tr
.left() + 1, tr
.top() + 2);
746 p
->drawPoint(tr
.left(), tr
.bottom() + 1);
751 p
->drawLine(tr
.left() + 1, tr
.bottom() - 1,
752 tr
.right() - 1, tr
.bottom() - 1);
753 p
->drawPoint(tr
.right(), tr
.top() - 1);
756 p
->drawLine(tr
.right() - 1, tr
.bottom() - 2,
757 tr
.right() - 1, tr
.top());
759 p
->drawLine(tr
.left() + 1, tr
.top() + 1,
760 tr
.right() - 1, tr
.top() + 1);
761 p
->drawPoint(tr
.right(), tr
.bottom() + 1);
764 p
->drawLine(tr
.right() - 1, tr
.top() + 2,
765 tr
.right() - 1, tr
.bottom());
769 p
->fillRect(fr
, ((flags
& Style_Selected
) ?
770 cg
.background() : cg
.mid()));
774 case CE_PopupMenuItem
:
776 if (! widget
|| data
.isDefault())
779 const QMenu
*popupmenu
= (const QMenu
*) widget
;
780 QMenuItem
*mi
= data
.menuItem();
781 int tab
= data
.tabWidth();
782 int maxpmw
= data
.maxIconWidth();
784 if ( mi
&& mi
->isSeparator() ) {
785 // draw separator (bg first, though)
786 if ( widget
->erasePixmap() && !widget
->erasePixmap()->isNull() )
787 p
->drawPixmap( r
.topLeft(), *widget
->erasePixmap(), r
);
789 p
->fillRect(r
, cg
.brush(QPalette::Button
));
791 p
->setPen(cg
.mid().dark(120));
792 p
->drawLine(r
.left() + 12, r
.top() + 1,
793 r
.right() - 12, r
.top() + 1);
794 p
->setPen(cg
.light());
795 p
->drawLine(r
.left() + 12, r
.top() + 2,
796 r
.right() - 12, r
.top() + 2);
800 if (flags
& Style_Active
)
801 qDrawShadePanel(p
, r
, cg
, true, 1,
802 &cg
.brush(QPalette::Midlight
));
803 else if ( widget
->erasePixmap() && !widget
->erasePixmap()->isNull() )
804 p
->drawPixmap( r
.topLeft(), *widget
->erasePixmap(), r
);
806 p
->fillRect(r
, cg
.brush(QPalette::Button
));
811 maxpmw
= qMax(maxpmw
, 16);
813 QRect cr
, ir
, tr
, sr
;
815 cr
.setRect(r
.left(), r
.top(), maxpmw
, r
.height());
816 // submenu indicator column
817 sr
.setCoords(r
.right() - maxpmw
, r
.top(), r
.right(), r
.bottom());
818 // tab/accelerator column
819 tr
.setCoords(sr
.left() - tab
- 4, r
.top(), sr
.left(), r
.bottom());
821 ir
.setCoords(cr
.right() + 4, r
.top(), tr
.right() - 4, r
.bottom());
823 bool reverse
= QApplication::isRightToLeft();
825 cr
= visualRect( cr
, r
);
826 sr
= visualRect( sr
, r
);
827 tr
= visualRect( tr
, r
);
828 ir
= visualRect( ir
, r
);
831 if (mi
->isChecked() &&
832 ! (flags
& Style_Active
) &
833 (flags
& Style_Enabled
))
834 qDrawShadePanel(p
, cr
, cg
, true, 1, &cg
.brush(QPalette::Midlight
));
838 (flags
& Style_Enabled
) ? QIcon::Normal
: QIcon::Disabled
;
839 if ((flags
& Style_Active
) && (flags
& Style_Enabled
))
840 mode
= QIcon::Active
;
842 if (popupmenu
->isCheckable() && mi
->isChecked())
844 mi
->iconSet()->pixmap( QIcon::Small
, mode
, QIcon::On
);
847 mi
->iconSet()->pixmap( QIcon::Small
, mode
);
848 QRect
pmr(QPoint(0, 0), pixmap
.size());
849 pmr
.moveCenter(cr
.center());
850 p
->setPen(cg
.text());
851 p
->drawPixmap(pmr
.topLeft(), pixmap
);
852 } else if (popupmenu
->isCheckable() && mi
->isChecked())
853 drawPrimitive(PE_CheckMark
, p
, cr
, cg
,
854 (flags
& Style_Enabled
) | Style_On
);
858 if (flags
& Style_Active
) {
859 if (! (flags
& Style_Enabled
))
860 textcolor
= cg
.midlight().dark();
862 textcolor
= cg
.buttonText();
863 embosscolor
= cg
.midlight().light();
864 } else if (! (flags
& Style_Enabled
)) {
865 textcolor
= cg
.text();
866 embosscolor
= cg
.light();
868 textcolor
= embosscolor
= cg
.buttonText();
869 p
->setPen(textcolor
);
873 if (! (flags
& Style_Enabled
)) {
874 p
->setPen(cg
.light());
875 mi
->custom()->paint(p
, cg
, flags
& Style_Active
,
876 flags
& Style_Enabled
,
877 ir
.x() + 1, ir
.y() + 1,
878 ir
.width() - 1, ir
.height() - 1);
879 p
->setPen(textcolor
);
881 mi
->custom()->paint(p
, cg
, flags
& Style_Active
,
882 flags
& Style_Enabled
,
884 ir
.width(), ir
.height());
888 QString text
= mi
->text();
889 if (! text
.isNull()) {
890 int t
= text
.find('\t');
892 // draw accelerator/tab-text
894 int alignFlag
= Qt::AlignVCenter
| Qt::TextShowMnemonic
| Qt::TextDontClip
| Qt::TextSingleLine
;
895 alignFlag
|= ( reverse
? Qt::AlignLeft
: Qt::AlignRight
);
896 if (! (flags
& Style_Enabled
)) {
897 p
->setPen(embosscolor
);
899 p
->drawText(tr
, alignFlag
, text
.mid(t
+ 1));
900 tr
.translate(-1, -1);
901 p
->setPen(textcolor
);
904 p
->drawText(tr
, alignFlag
, text
.mid(t
+ 1));
907 int alignFlag
= Qt::AlignVCenter
| Qt::TextShowMnemonic
| Qt::TextDontClip
| Qt::TextSingleLine
;
908 alignFlag
|= ( reverse
? Qt::AlignRight
: Qt::AlignLeft
);
910 if (! (flags
& Style_Enabled
)) {
911 p
->setPen(embosscolor
);
913 p
->drawText(ir
, alignFlag
, text
, t
);
914 ir
.translate(-1, -1);
915 p
->setPen(textcolor
);
918 p
->drawText(ir
, alignFlag
, text
, t
);
919 } else if (mi
->pixmap()) {
920 QPixmap pixmap
= *mi
->pixmap();
921 if (pixmap
.depth() == 1)
922 p
->setBackgroundMode(Qt::OpaqueMode
);
923 p
->drawPixmap(ir
.x(), ir
.y() + (ir
.height() - pixmap
.height()) / 2, pixmap
);
924 if (pixmap
.depth() == 1)
925 p
->setBackgroundMode(Qt::TransparentMode
);
929 drawPrimitive( (reverse
? PE_ArrowLeft
: PE_ArrowRight
), p
, sr
, cg
, flags
);
933 case CE_MenuBarEmptyArea
:
935 p
->fillRect(r
, cg
.brush(QPalette::Button
));
939 case CE_DockWindowEmptyArea
:
941 p
->fillRect(r
, cg
.brush(QPalette::Button
));
948 if (flags
& Style_Active
)
949 qDrawShadePanel(p
, r
, cg
, true, 1, &cg
.brush(QPalette::Midlight
));
951 p
->fillRect(r
, cg
.brush(QPalette::Button
));
953 if (data
.isDefault())
956 QMenuItem
*mi
= data
.menuItem();
957 drawItem(p
, r
, Qt::AlignCenter
| Qt::TextShowMnemonic
| Qt::TextDontClip
| Qt::TextSingleLine
, cg
,
958 flags
& Style_Enabled
, mi
->pixmap(), mi
->text(), -1,
963 case CE_ProgressBarGroove
:
964 drawLightBevel(p
, r
, cg
, Style_Sunken
, &cg
.brush(QPalette::Background
));
968 QCommonStyle::drawControl(control
, p
, widget
, r
, cg
, flags
, data
);
973 void LightStyleV2::drawControlMask( ControlElement control
,
975 const QWidget
*widget
,
977 const QStyleOption
&data
) const
981 p
->fillRect(r
, Qt::color1
);
985 QCommonStyle::drawControlMask(control
, p
, widget
, r
, data
);
990 QRect
LightStyleV2::subRect(SubRect subrect
, const QWidget
*widget
) const
992 QRect rect
, wrect(widget
->rect());
995 case SR_PushButtonFocusRect
:
997 const QPushButton
*button
= (const QPushButton
*) widget
;
998 int dbw1
= 0, dbw2
= 0;
999 if (button
->isDefault() || button
->autoDefault()) {
1000 dbw1
= pixelMetric(PM_ButtonDefaultIndicator
, widget
);
1004 rect
.setRect(wrect
.x() + 3 + dbw1
,
1005 wrect
.y() + 3 + dbw1
,
1006 wrect
.width() - 6 - dbw2
,
1007 wrect
.height() - 6 - dbw2
);
1012 rect
= QCommonStyle::subRect(subrect
, widget
);
1018 void LightStyleV2::drawComplexControl( ComplexControl control
,
1020 const QWidget
* widget
,
1022 const QColorGroup
& cg
,
1026 const QStyleOption
&data
) const
1031 const QComboBox
*combobox
= (const QComboBox
*) widget
;
1032 QRect frame
, arrow
, field
;
1034 QStyle::visualRect(querySubControlMetrics(CC_ComboBox
, widget
,
1035 SC_ComboBoxFrame
, data
),
1038 QStyle::visualRect(querySubControlMetrics(CC_ComboBox
, widget
,
1039 SC_ComboBoxArrow
, data
),
1042 QStyle::visualRect(querySubControlMetrics(CC_ComboBox
, widget
,
1043 SC_ComboBoxEditField
, data
),
1046 if ((controls
& SC_ComboBoxFrame
) && frame
.isValid())
1047 drawLightBevel(p
, frame
, cg
, flags
| Style_Raised
,
1048 &cg
.brush(QPalette::Button
));
1050 if ((controls
& SC_ComboBoxArrow
) && arrow
.isValid()) {
1051 if (active
== SC_ComboBoxArrow
)
1052 p
->fillRect(arrow
, cg
.brush(QPalette::Mid
));
1053 arrow
.adjust(4, 2, -2, -2);
1054 drawPrimitive(PE_ArrowDown
, p
, arrow
, cg
, flags
);
1057 if ((controls
& SC_ComboBoxEditField
) && field
.isValid()) {
1058 p
->setPen(cg
.dark());
1059 if (combobox
->editable()) {
1060 field
.adjust(-1, -1, 1, 1);
1063 p
->drawLine(field
.right() + 1, field
.top(),
1064 field
.right() + 1, field
.bottom());
1066 if (flags
& Style_HasFocus
) {
1067 if (! combobox
->editable()) {
1068 p
->fillRect( field
, cg
.brush( QPalette::Highlight
) );
1070 QStyle::visualRect( subRect( SR_ComboBoxFocusRect
, widget
),
1072 drawPrimitive( PE_FocusRect
, p
, fr
, cg
,
1073 flags
| Style_FocusAtBorder
,
1074 QStyleOption(cg
.highlight()));
1077 p
->setPen(cg
.highlightedText());
1079 p
->setPen(cg
.buttonText());
1087 const Q3SpinWidget
*spinwidget
= (const Q3SpinWidget
*) widget
;
1088 QRect frame
, up
, down
;
1090 frame
= querySubControlMetrics(CC_SpinWidget
, widget
,
1091 SC_SpinWidgetFrame
, data
);
1092 up
= spinwidget
->upRect();
1093 down
= spinwidget
->downRect();
1095 if ((controls
& SC_SpinWidgetFrame
) && frame
.isValid())
1096 drawLightBevel(p
, frame
, cg
, flags
| Style_Sunken
,
1097 &cg
.brush(QPalette::Base
));
1099 if ((controls
& SC_SpinWidgetUp
) && up
.isValid()) {
1100 PrimitiveElement pe
= PE_SpinWidgetUp
;
1101 if ( spinwidget
->buttonSymbols() == Q3SpinWidget::PlusMinus
)
1102 pe
= PE_SpinWidgetPlus
;
1104 p
->setPen(cg
.dark());
1105 p
->drawLine(up
.topLeft(), up
.bottomLeft());
1107 up
.adjust(1, 0, 0, 0);
1108 p
->fillRect(up
, cg
.brush(QPalette::Button
));
1109 if (active
== SC_SpinWidgetUp
)
1110 p
->setPen(cg
.mid());
1112 p
->setPen(cg
.light());
1113 p
->drawLine(up
.left(), up
.top(),
1114 up
.right() - 1, up
.top());
1115 p
->drawLine(up
.left(), up
.top() + 1,
1116 up
.left(), up
.bottom() - 1);
1117 if (active
== SC_SpinWidgetUp
)
1118 p
->setPen(cg
.light());
1120 p
->setPen(cg
.mid());
1121 p
->drawLine(up
.right(), up
.top(),
1122 up
.right(), up
.bottom());
1123 p
->drawLine(up
.left(), up
.bottom(),
1124 up
.right() - 1, up
.bottom());
1126 up
.adjust(1, 0, 0, 0);
1127 drawPrimitive(pe
, p
, up
, cg
, flags
|
1128 ((active
== SC_SpinWidgetUp
) ?
1129 Style_On
| Style_Sunken
: Style_Raised
));
1132 if ((controls
& SC_SpinWidgetDown
) && down
.isValid()) {
1133 PrimitiveElement pe
= PE_SpinWidgetDown
;
1134 if ( spinwidget
->buttonSymbols() == Q3SpinWidget::PlusMinus
)
1135 pe
= PE_SpinWidgetMinus
;
1137 p
->setPen(cg
.dark());
1138 p
->drawLine(down
.topLeft(), down
.bottomLeft());
1140 down
.adjust(1, 0, 0, 0);
1141 p
->fillRect(down
, cg
.brush(QPalette::Button
));
1142 if (active
== SC_SpinWidgetDown
)
1143 p
->setPen(cg
.mid());
1145 p
->setPen(cg
.light());
1146 p
->drawLine(down
.left(), down
.top(),
1147 down
.right() - 1, down
.top());
1148 p
->drawLine(down
.left(), down
.top() + 1,
1149 down
.left(), down
.bottom() - 1);
1150 if (active
== SC_SpinWidgetDown
)
1151 p
->setPen(cg
.light());
1153 p
->setPen(cg
.mid());
1154 p
->drawLine(down
.right(), down
.top(),
1155 down
.right(), down
.bottom());
1156 p
->drawLine(down
.left(), down
.bottom(),
1157 down
.right() - 1, down
.bottom());
1159 down
.adjust(1, 0, 0, 0);
1160 drawPrimitive(pe
, p
, down
, cg
, flags
|
1161 ((active
== SC_SpinWidgetDown
) ?
1162 Style_On
| Style_Sunken
: Style_Raised
));
1170 const QScrollBar
*scrollbar
= (const QScrollBar
*) widget
;
1171 QRect addline
, subline
, subline2
, addpage
, subpage
, slider
, first
, last
;
1172 bool maxedOut
= (scrollbar
->minValue() == scrollbar
->maxValue());
1174 subline
= querySubControlMetrics(control
, widget
, SC_ScrollBarSubLine
, data
);
1175 addline
= querySubControlMetrics(control
, widget
, SC_ScrollBarAddLine
, data
);
1176 subpage
= querySubControlMetrics(control
, widget
, SC_ScrollBarSubPage
, data
);
1177 addpage
= querySubControlMetrics(control
, widget
, SC_ScrollBarAddPage
, data
);
1178 slider
= querySubControlMetrics(control
, widget
, SC_ScrollBarSlider
, data
);
1179 first
= querySubControlMetrics(control
, widget
, SC_ScrollBarFirst
, data
);
1180 last
= querySubControlMetrics(control
, widget
, SC_ScrollBarLast
, data
);
1183 if (scrollbar
->orientation() == Qt::Horizontal
)
1184 subline2
.translate(-addline
.width(), 0);
1186 subline2
.translate(0, -addline
.height());
1188 if ((controls
& SC_ScrollBarSubLine
) && subline
.isValid()) {
1189 drawPrimitive(PE_ScrollBarSubLine
, p
, subline
, cg
,
1190 Style_Enabled
| ((active
== SC_ScrollBarSubLine
) ?
1191 Style_Down
: Style_Default
) |
1192 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1193 Style_Horizontal
: 0));
1195 if (subline2
.isValid())
1196 drawPrimitive(PE_ScrollBarSubLine
, p
, subline2
, cg
,
1197 Style_Enabled
| ((active
== SC_ScrollBarSubLine
) ?
1198 Style_Down
: Style_Default
) |
1199 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1200 Style_Horizontal
: 0));
1202 if ((controls
& SC_ScrollBarAddLine
) && addline
.isValid())
1203 drawPrimitive(PE_ScrollBarAddLine
, p
, addline
, cg
,
1204 Style_Enabled
| ((active
== SC_ScrollBarAddLine
) ?
1205 Style_Down
: Style_Default
) |
1206 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1207 Style_Horizontal
: 0));
1208 if ((controls
& SC_ScrollBarSubPage
) && subpage
.isValid())
1209 drawPrimitive(PE_ScrollBarSubPage
, p
, subpage
, cg
,
1210 Style_Enabled
| ((active
== SC_ScrollBarSubPage
) ?
1211 Style_Down
: Style_Default
) |
1212 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1213 Style_Horizontal
: 0));
1214 if ((controls
& SC_ScrollBarAddPage
) && addpage
.isValid())
1215 drawPrimitive(PE_ScrollBarAddPage
, p
, addpage
, cg
,
1216 ((maxedOut
) ? Style_Default
: Style_Enabled
) |
1217 ((active
== SC_ScrollBarAddPage
) ?
1218 Style_Down
: Style_Default
) |
1219 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1220 Style_Horizontal
: 0));
1221 if ((controls
& SC_ScrollBarFirst
) && first
.isValid())
1222 drawPrimitive(PE_ScrollBarFirst
, p
, first
, cg
,
1223 Style_Enabled
| ((active
== SC_ScrollBarFirst
) ?
1224 Style_Down
: Style_Default
) |
1225 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1226 Style_Horizontal
: 0));
1227 if ((controls
& SC_ScrollBarLast
) && last
.isValid())
1228 drawPrimitive(PE_ScrollBarLast
, p
, last
, cg
,
1229 Style_Enabled
| ((active
== SC_ScrollBarLast
) ?
1230 Style_Down
: Style_Default
) |
1231 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1232 Style_Horizontal
: 0));
1233 if ((controls
& SC_ScrollBarSlider
) && slider
.isValid()) {
1234 drawPrimitive(PE_ScrollBarSlider
, p
, slider
, cg
,
1235 Style_Enabled
| ((active
== SC_ScrollBarSlider
) ?
1236 Style_Down
: Style_Default
) |
1237 ((scrollbar
->orientation() == Qt::Horizontal
) ?
1238 Style_Horizontal
: 0));
1240 // ### perhaps this should not be able to accept focus if maxedOut?
1241 if (scrollbar
->hasFocus()) {
1242 QRect
fr(slider
.x() + 2, slider
.y() + 2,
1243 slider
.width() - 5, slider
.height() - 5);
1244 drawPrimitive(PE_FocusRect
, p
, fr
, cg
, Style_Default
);
1253 const QSlider
*slider
= (const QSlider
*) widget
;
1254 QRect groove
= querySubControlMetrics(CC_Slider
, widget
, SC_SliderGroove
,
1256 handle
= querySubControlMetrics(CC_Slider
, widget
, SC_SliderHandle
,
1259 if ((controls
& SC_SliderGroove
) && groove
.isValid()) {
1260 if (flags
& Style_HasFocus
)
1261 drawPrimitive( PE_FocusRect
, p
, groove
, cg
);
1263 if (slider
->orientation() == Qt::Horizontal
) {
1264 int dh
= (groove
.height() - 5) / 2;
1265 groove
.adjust(0, dh
, 0, -dh
);
1267 int dw
= (groove
.width() - 5) / 2;
1268 groove
.adjust(dw
, 0, -dw
, 0);
1271 drawLightBevel(p
, groove
, cg
, ((flags
| Style_Raised
) ^ Style_Raised
) |
1272 ((flags
& Style_Enabled
) ? Style_Sunken
: Style_Default
),
1273 &cg
.brush(QPalette::Midlight
));
1276 if ((controls
& SC_SliderHandle
) && handle
.isValid()) {
1277 drawLightBevel(p
, handle
, cg
, ((flags
| Style_Down
) ^ Style_Down
) |
1278 ((flags
& Style_Enabled
) ? Style_Raised
: Style_Default
),
1279 &cg
.brush(QPalette::Button
));
1283 if (controls
& SC_SliderTickmarks
)
1284 QCommonStyle::drawComplexControl(control
, p
, widget
, r
, cg
, flags
,
1285 SC_SliderTickmarks
, active
, data
);
1290 // use the base style for CC_ListView
1291 singleton
->basestyle
->drawComplexControl(control
, p
, widget
, r
, cg
, flags
,
1292 controls
, active
, data
);
1296 QCommonStyle::drawComplexControl(control
, p
, widget
, r
, cg
, flags
,
1297 controls
, active
, data
);
1302 QRect
LightStyleV2::querySubControlMetrics( ComplexControl control
,
1303 const QWidget
*widget
,
1305 const QStyleOption
&data
) const
1312 const QScrollBar
*scrollbar
= (const QScrollBar
*) widget
;
1313 int sliderstart
= scrollbar
->sliderStart();
1314 int sbextent
= pixelMetric(PM_ScrollBarExtent
, widget
);
1315 int maxlen
= ((scrollbar
->orientation() == Qt::Horizontal
) ?
1316 scrollbar
->width() : scrollbar
->height()) - (sbextent
* 3);
1319 // calculate slider length
1320 if (scrollbar
->maxValue() != scrollbar
->minValue()) {
1321 uint range
= scrollbar
->maxValue() - scrollbar
->minValue();
1322 sliderlen
= (scrollbar
->pageStep() * maxlen
) /
1323 (range
+ scrollbar
->pageStep());
1325 int slidermin
= pixelMetric( PM_ScrollBarSliderMin
, widget
);
1326 if ( sliderlen
< slidermin
|| range
> INT_MAX
/ 2 )
1327 sliderlen
= slidermin
;
1328 if ( sliderlen
> maxlen
)
1334 case SC_ScrollBarSubLine
:
1336 ret
.setRect(0, 0, sbextent
, sbextent
);
1339 case SC_ScrollBarAddLine
:
1340 // bottom/right button
1341 if (scrollbar
->orientation() == Qt::Horizontal
)
1342 ret
.setRect(scrollbar
->width() - sbextent
, 0, sbextent
, sbextent
);
1344 ret
.setRect(0, scrollbar
->height() - sbextent
, sbextent
, sbextent
);
1347 case SC_ScrollBarSubPage
:
1348 // between top/left button and slider
1349 if (scrollbar
->orientation() == Qt::Horizontal
)
1350 ret
.setRect(sbextent
, 0, sliderstart
- sbextent
, sbextent
);
1352 ret
.setRect(0, sbextent
, sbextent
, sliderstart
- sbextent
);
1355 case SC_ScrollBarAddPage
:
1356 // between bottom/right button and slider
1357 if (scrollbar
->orientation() == Qt::Horizontal
)
1358 ret
.setRect(sliderstart
+ sliderlen
, 0,
1359 maxlen
- sliderstart
- sliderlen
+ sbextent
, sbextent
);
1361 ret
.setRect(0, sliderstart
+ sliderlen
,
1362 sbextent
, maxlen
- sliderstart
- sliderlen
+ sbextent
);
1365 case SC_ScrollBarGroove
:
1366 if (scrollbar
->orientation() == Qt::Horizontal
)
1367 ret
.setRect(sbextent
, 0, scrollbar
->width() - sbextent
* 3,
1368 scrollbar
->height());
1370 ret
.setRect(0, sbextent
, scrollbar
->width(),
1371 scrollbar
->height() - sbextent
* 3);
1374 case SC_ScrollBarSlider
:
1375 if (scrollbar
->orientation() == Qt::Horizontal
)
1376 ret
.setRect(sliderstart
, 0, sliderlen
, sbextent
);
1378 ret
.setRect(0, sliderstart
, sbextent
, sliderlen
);
1389 ret
= QCommonStyle::querySubControlMetrics(control
, widget
, sc
, data
);
1396 QStyle::SubControl
LightStyleV2::querySubControl( ComplexControl control
,
1397 const QWidget
*widget
,
1399 const QStyleOption
&data
) const
1401 QStyle::SubControl ret
= QCommonStyle::querySubControl(control
, widget
, pos
, data
);
1403 // this is an ugly hack, but i really don't care, it's the quickest way to
1404 // enabled the third button
1405 if (control
== CC_ScrollBar
&&
1407 ret
= SC_ScrollBarSubLine
;
1412 int LightStyleV2::pixelMetric( PixelMetric metric
,
1413 const QWidget
*widget
) const
1418 case PM_ButtonMargin
:
1422 case PM_ButtonShiftHorizontal
:
1423 case PM_ButtonShiftVertical
:
1427 case PM_ButtonDefaultIndicator
:
1428 case PM_DefaultFrameWidth
:
1432 case PM_IndicatorWidth
:
1433 case PM_IndicatorHeight
:
1434 case PM_ExclusiveIndicatorWidth
:
1435 case PM_ExclusiveIndicatorHeight
:
1439 case PM_TabBarTabOverlap
:
1443 case PM_ScrollBarExtent
:
1444 case PM_ScrollBarSliderMin
:
1448 case PM_MenuBarFrameWidth
:
1452 case PM_ProgressBarChunkWidth
:
1456 case PM_DockWindowSeparatorExtent
:
1460 case PM_SplitterWidth
:
1465 case PM_SliderLength
:
1466 case PM_SliderControlThickness
:
1467 ret
= singleton
->basestyle
->pixelMetric( metric
, widget
);
1470 case PM_MaximumDragDistance
:
1475 ret
= QCommonStyle::pixelMetric(metric
, widget
);
1482 QSize
LightStyleV2::sizeFromContents( ContentsType contents
,
1483 const QWidget
*widget
,
1484 const QSize
&contentsSize
,
1485 const QStyleOption
&data
) const
1492 const QPushButton
*button
= (const QPushButton
*) widget
;
1493 ret
= QCommonStyle::sizeFromContents( contents
, widget
, contentsSize
, data
);
1494 int w
= ret
.width(), h
= ret
.height();
1496 // only expand the button if we are displaying text...
1497 if ( ! button
->text().isEmpty() ) {
1498 if ( button
->isDefault() || button
->autoDefault() ) {
1499 // default button minimum size
1505 // regular button minimum size
1513 ret
= QSize( w
, h
);
1517 case CT_PopupMenuItem
:
1519 if (! widget
|| data
.isDefault())
1522 QMenuItem
*mi
= data
.menuItem();
1523 const QMenu
*popupmenu
= (const QMenu
*) widget
;
1524 int maxpmw
= data
.maxIconWidth();
1525 int w
= contentsSize
.width(), h
= contentsSize
.height();
1528 w
= mi
->custom()->sizeHint().width();
1529 h
= mi
->custom()->sizeHint().height();
1530 if (! mi
->custom()->fullSpan() && h
< 22)
1532 } else if(mi
->widget()) {
1533 } else if (mi
->isSeparator()) {
1537 // check is at least 16x16
1541 h
= qMax(h
, mi
->pixmap()->height());
1542 else if (! mi
->text().isNull())
1543 h
= qMax(h
, popupmenu
->fontMetrics().height() + 2);
1544 if (mi
->iconSet() != 0)
1545 h
= qMax(h
, mi
->iconSet()->pixmap(QIcon::Small
,
1546 QIcon::Normal
).height());
1550 // check | 4 pixels | item | 8 pixels | accel | 4 pixels | check
1552 // check is at least 16x16
1553 maxpmw
= qMax(maxpmw
, 16);
1554 w
+= (maxpmw
* 2) + 8;
1556 if (! mi
->text().isNull() && mi
->text().find('\t') >= 0)
1562 case CT_ProgressBar
:
1564 const QProgressBar
* pb
= static_cast<const QProgressBar
*>(widget
);
1566 //If we have to display the indicator, and we do it on RHS, give some more room
1567 //for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents
1568 //sizing in QCommonStyle.
1569 if (pb
->percentageVisible() &&
1570 (pb
->indicatorFollowsStyle() || ! pb
->centerIndicator()))
1572 int addw
= pb
->fontMetrics().width("100%") + 6;
1573 return QSize(contentsSize
.width() + addw
, contentsSize
.height());
1576 return contentsSize
; //Otherwise leave unchanged
1582 ret
= QCommonStyle::sizeFromContents(contents
, widget
, contentsSize
, data
);
1589 int LightStyleV2::styleHint( StyleHint stylehint
,
1590 const QWidget
*widget
,
1591 const QStyleOption
&option
,
1592 QStyleHintReturn
* returnData
) const
1596 switch (stylehint
) {
1597 case SH_EtchDisabledText
:
1598 case SH_Slider_SnapToValue
:
1599 case SH_PrintDialog_RightAlignButtons
:
1600 case SH_FontDialog_SelectAssociatedText
:
1601 case SH_MenuBar_AltKeyNavigation
:
1602 case SH_MenuBar_MouseTracking
:
1603 case SH_PopupMenu_MouseTracking
:
1604 case SH_ComboBox_ListMouseTracking
:
1605 case SH_ScrollBar_MiddleClickAbsolutePosition
:
1609 case SH_MainWindow_SpaceBelowMenuBar
:
1614 ret
= QCommonStyle::styleHint(stylehint
, widget
, option
, returnData
);
1621 QPixmap
LightStyleV2::stylePixmap( StylePixmap stylepixmap
,
1622 const QWidget
*widget
,
1623 const QStyleOption
&data
) const
1625 return singleton
->basestyle
->stylePixmap( stylepixmap
, widget
, data
);
1627 #include "lightstyle-v2.moc"