source: trunk/src/styles/qwindowsstyle.cpp@ 7

Last change on this file since 7 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 59.8 KB
Line 
1/****************************************************************************
2** $Id: qwindowsstyle.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Implementation of Windows-like style class
5**
6** Created : 981231
7**
8** Copyright (C) 1998-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the widgets module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "qwindowsstyle.h"
39
40#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
41
42#include "qpopupmenu.h"
43#include "qapplication.h"
44#include "qpainter.h"
45#include "qdrawutil.h" // for now
46#include "qpixmap.h" // for now
47#include "qwidget.h"
48#include "qlabel.h"
49#include "qimage.h"
50#include "qpushbutton.h"
51#include "qcombobox.h"
52#include "qlistbox.h"
53#include "qwidget.h"
54#include "qrangecontrol.h"
55#include "qscrollbar.h"
56#include "qslider.h"
57#include "qtabwidget.h"
58#include "qtabbar.h"
59#include "qlistview.h"
60#include "qbitmap.h"
61#include "qcleanuphandler.h"
62#include "qdockwindow.h"
63#include "qobjectlist.h"
64#include "qmenubar.h"
65
66#if defined(Q_WS_WIN)
67#include "qt_windows.h"
68#endif
69
70#include <limits.h>
71
72
73static const int windowsItemFrame = 2; // menu item frame width
74static const int windowsSepHeight = 2; // separator item height
75static const int windowsItemHMargin = 3; // menu item hor text margin
76static const int windowsItemVMargin = 2; // menu item ver text margin
77static const int windowsArrowHMargin = 6; // arrow horizontal margin
78static const int windowsTabSpacing = 12; // space between text and tab
79static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark
80static const int windowsRightBorder = 12; // right border on windows
81static const int windowsCheckMarkWidth = 12; // checkmarks width on windows
82
83static bool use2000style = TRUE;
84
85enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
86
87// A friendly class providing access to QMenuData's protected member.
88class FriendlyMenuData : public QMenuData
89{
90 friend class QWindowsStyle;
91};
92
93// Private class
94class QWindowsStyle::Private : public QObject
95{
96public:
97 Private(QWindowsStyle *parent);
98
99 bool hasSeenAlt(const QWidget *widget) const;
100 bool altDown() const { return alt_down; }
101
102protected:
103 bool eventFilter(QObject *o, QEvent *e);
104
105private:
106 QPtrList<QWidget> seenAlt;
107 bool alt_down;
108 int menuBarTimer;
109};
110
111QWindowsStyle::Private::Private(QWindowsStyle *parent)
112: QObject(parent, "QWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0)
113{
114}
115
116// Returns true if the toplevel parent of \a widget has seen the Alt-key
117bool QWindowsStyle::Private::hasSeenAlt(const QWidget *widget) const
118{
119 widget = widget->topLevelWidget();
120 return seenAlt.contains(widget);
121}
122
123// Records Alt- and Focus events
124bool QWindowsStyle::Private::eventFilter(QObject *o, QEvent *e)
125{
126 if (!o->isWidgetType())
127 return QObject::eventFilter(o, e);
128
129 QWidget *widget = ::qt_cast<QWidget*>(o);
130
131 switch(e->type()) {
132 case QEvent::KeyPress:
133 if (((QKeyEvent*)e)->key() == Key_Alt) {
134 widget = widget->topLevelWidget();
135
136 // Alt has been pressed - find all widgets that care
137 QObjectList *l = widget->queryList("QWidget");
138 QObjectListIt it( *l );
139 QWidget *w;
140 while ( (w = (QWidget*)it.current()) != 0 ) {
141 ++it;
142 if (w->isTopLevel() || !w->isVisible() ||
143 w->style().styleHint(SH_UnderlineAccelerator, w))
144 l->removeRef(w);
145 }
146 // Update states before repainting
147 seenAlt.append(widget);
148 alt_down = TRUE;
149
150 // Repaint all relevant widgets
151 it.toFirst();
152 while ( (w = (QWidget*)it.current()) != 0 ) {
153 ++it;
154 w->repaint(FALSE);
155 }
156 delete l;
157 }
158 break;
159 case QEvent::KeyRelease:
160 if (((QKeyEvent*)e)->key() == Key_Alt) {
161 widget = widget->topLevelWidget();
162
163 // Update state
164 alt_down = FALSE;
165 // Repaint only menubars
166 QObjectList *l = widget->queryList("QMenuBar");
167 QObjectListIt it( *l );
168 QMenuBar *menuBar;
169 while ( (menuBar = (QMenuBar*)it.current()) != 0) {
170 ++it;
171 menuBar->repaint(FALSE);
172 }
173 }
174 break;
175 case QEvent::FocusIn:
176 case QEvent::FocusOut:
177 {
178 // Menubars toggle based on focus
179 QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o);
180 if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker
181 menuBarTimer = menuBar->startTimer(0);
182 }
183 break;
184 case QEvent::Close:
185 // Reset widget when closing
186 seenAlt.removeRef(widget);
187 seenAlt.removeRef(widget->topLevelWidget());
188 break;
189 case QEvent::Timer:
190 {
191 QMenuBar *menuBar = ::qt_cast<QMenuBar*>(o);
192 QTimerEvent *te = (QTimerEvent*)e;
193 if (menuBar && te->timerId() == menuBarTimer) {
194 menuBar->killTimer(te->timerId());
195 menuBarTimer = 0;
196 menuBar->repaint(FALSE);
197 return TRUE;
198 }
199 }
200 break;
201 default:
202 break;
203 }
204
205 return QObject::eventFilter(o, e);
206}
207
208/*!
209 \class QWindowsStyle qwindowsstyle.h
210 \brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
211
212 \ingroup appearance
213
214 This style is Qt's default GUI style on Windows.
215*/
216
217/*!
218 Constructs a QWindowsStyle
219*/
220QWindowsStyle::QWindowsStyle() : QCommonStyle(), d(0)
221{
222#if defined(Q_OS_WIN32)
223 use2000style = qWinVersion() != Qt::WV_NT && qWinVersion() != Qt::WV_95;
224#endif
225}
226
227/*! \reimp */
228QWindowsStyle::~QWindowsStyle()
229{
230 delete d;
231}
232
233/*! \reimp */
234void QWindowsStyle::polish(QApplication *app)
235{
236 // We only need the overhead when shortcuts are sometimes hidden
237 if (!styleHint(SH_UnderlineAccelerator, 0)) {
238 d = new Private(this);
239 app->installEventFilter(d);
240 }
241}
242
243/*! \reimp */
244void QWindowsStyle::unPolish(QApplication *)
245{
246 delete d;
247 d = 0;
248}
249
250/*! \reimp */
251void QWindowsStyle::polish(QWidget *widget)
252{
253 QCommonStyle::polish(widget);
254}
255
256/*! \reimp */
257void QWindowsStyle::unPolish(QWidget *widget)
258{
259 QCommonStyle::polish(widget);
260}
261
262/*! \reimp */
263void QWindowsStyle::polish( QPalette &pal )
264{
265 QCommonStyle::polish(pal);
266}
267
268/*! \reimp */
269void QWindowsStyle::drawPrimitive( PrimitiveElement pe,
270 QPainter *p,
271 const QRect &r,
272 const QColorGroup &cg,
273 SFlags flags,
274 const QStyleOption& opt ) const
275{
276 QRect rr( r );
277 switch (pe) {
278 case PE_ButtonCommand:
279 {
280 QBrush fill;
281
282 if (! (flags & Style_Down) && (flags & Style_On))
283 fill = QBrush(cg.light(), Dense4Pattern);
284 else
285 fill = cg.brush(QColorGroup::Button);
286
287 if (flags & Style_ButtonDefault && flags & Style_Down) {
288 p->setPen(cg.dark());
289 p->setBrush(fill);
290 p->drawRect(r);
291 } else if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
292 qDrawWinButton(p, r, cg, flags & (Style_Sunken | Style_Down |
293 Style_On), &fill);
294 else
295 p->fillRect(r, fill);
296 break;
297 }
298
299 case PE_ButtonBevel:
300 case PE_HeaderSection:
301 {
302 QBrush fill;
303
304 if (! (flags & Style_Down) && (flags & Style_On))
305 fill = QBrush(cg.light(), Dense4Pattern);
306 else
307 fill = cg.brush(QColorGroup::Button);
308
309 if (flags & (Style_Raised | Style_Down | Style_On | Style_Sunken))
310 qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On), &fill);
311 else
312 p->fillRect(r, fill);
313 break;
314 }
315#if defined(Q_WS_WIN)
316 case PE_HeaderArrow:
317 p->save();
318 if ( flags & Style_Up ) { // invert logic to follow Windows style guide
319 QPointArray pa( 3 );
320 p->setPen( cg.light() );
321 p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() );
322 p->setPen( cg.dark() );
323 pa.setPoint( 0, r.x() + r.width() / 2, r.height() );
324 pa.setPoint( 1, r.x(), r.y() );
325 pa.setPoint( 2, r.x() + r.width(), r.y() );
326 p->drawPolyline( pa );
327 } else {
328 QPointArray pa( 3 );
329 p->setPen( cg.light() );
330 pa.setPoint( 0, r.x(), r.height() );
331 pa.setPoint( 1, r.x() + r.width(), r.height() );
332 pa.setPoint( 2, r.x() + r.width() / 2, r.y() );
333 p->drawPolyline( pa );
334 p->setPen( cg.dark() );
335 p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() );
336 }
337 p->restore();
338 break;
339#endif
340
341 case PE_ButtonDefault:
342 p->setPen(cg.shadow());
343 p->drawRect(r);
344 break;
345
346 case PE_ButtonTool:
347 {
348 QBrush fill;
349 bool stippled = FALSE;
350
351 if (! (flags & (Style_Down | Style_MouseOver)) &&
352 (flags & Style_On) &&
353 use2000style) {
354 fill = QBrush(cg.light(), Dense4Pattern);
355 stippled = TRUE;
356 } else
357 fill = cg.brush(QColorGroup::Button);
358
359 if (flags & (Style_Raised | Style_Down | Style_On)) {
360 if (flags & Style_AutoRaise) {
361 qDrawShadePanel(p, r, cg, flags & (Style_Down | Style_On),
362 1, &fill);
363
364 if (stippled) {
365 p->setPen(cg.button());
366 p->drawRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2);
367 }
368 } else
369 qDrawWinButton(p, r, cg, flags & (Style_Down | Style_On),
370 &fill);
371 } else
372 p->fillRect(r, fill);
373
374 break;
375 }
376
377 case PE_FocusRect:
378 if (opt.isDefault())
379 p->drawWinFocusRect(r);
380 else
381 p->drawWinFocusRect(r, opt.color());
382 break;
383
384 case PE_Indicator:
385 {
386 QBrush fill;
387 if (flags & Style_NoChange) {
388 QBrush b = p->brush();
389 QColor c = p->backgroundColor();
390 p->setBackgroundMode( TransparentMode );
391 p->setBackgroundColor( green );
392 fill = QBrush(cg.base(), Dense4Pattern);
393 p->setBackgroundColor( c );
394 p->setBrush( b );
395 } else if (flags & Style_Down)
396 fill = cg.brush( QColorGroup::Button );
397 else if (flags & Style_Enabled)
398 fill = cg.brush( QColorGroup::Base );
399 else
400 fill = cg.brush( QColorGroup::Background );
401
402 qDrawWinPanel( p, r, cg, TRUE, &fill );
403
404 if (flags & Style_NoChange )
405 p->setPen( cg.dark() );
406 else
407 p->setPen( cg.text() );
408 } // FALLTHROUGH
409 case PE_CheckListIndicator:
410 if ( pe == PE_CheckListIndicator ) { //since we fall through from PE_Indicator
411 if ( flags & Style_Enabled )
412 p->setPen( QPen( cg.text(), 1 ) );
413 else
414 p->setPen( QPen( cg.dark(), 1 ) );
415 if ( flags & Style_NoChange )
416 p->setBrush( cg.brush( QColorGroup::Button ) );
417 p->drawRect( r.x()+1, r.y()+1, 11, 11 );
418 }
419 if (! (flags & Style_Off)) {
420 QPointArray a( 7*2 );
421 int i, xx, yy;
422 xx = rr.x() + 3;
423 yy = rr.y() + 5;
424
425 for ( i=0; i<3; i++ ) {
426 a.setPoint( 2*i, xx, yy );
427 a.setPoint( 2*i+1, xx, yy+2 );
428 xx++; yy++;
429 }
430
431 yy -= 2;
432 for ( i=3; i<7; i++ ) {
433 a.setPoint( 2*i, xx, yy );
434 a.setPoint( 2*i+1, xx, yy+2 );
435 xx++; yy--;
436 }
437
438 p->drawLineSegments( a );
439 }
440 break;
441
442 case PE_ExclusiveIndicator:
443 {
444#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
445 static const QCOORD pts1[] = { // dark lines
446 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
447 static const QCOORD pts2[] = { // black lines
448 2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
449 static const QCOORD pts3[] = { // background lines
450 2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
451 static const QCOORD pts4[] = { // white lines
452 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
453 11,4, 10,3, 10,2 };
454 static const QCOORD pts5[] = { // inner fill
455 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
456
457 // make sure the indicator is square
458 QRect ir = r;
459
460 if (r.width() < r.height()) {
461 ir.setTop(r.top() + (r.height() - r.width()) / 2);
462 ir.setHeight(r.width());
463 } else if (r.height() < r.width()) {
464 ir.setLeft(r.left() + (r.width() - r.height()) / 2);
465 ir.setWidth(r.height());
466 }
467
468 p->eraseRect(ir);
469 bool down = flags & Style_Down;
470 bool enabled = flags & Style_Enabled;
471 bool on = flags & Style_On;
472 QPointArray a;
473 a.setPoints( QCOORDARRLEN(pts1), pts1 );
474 a.translate( ir.x(), ir.y() );
475 p->setPen( cg.dark() );
476 p->drawPolyline( a );
477 a.setPoints( QCOORDARRLEN(pts2), pts2 );
478 a.translate( ir.x(), ir.y() );
479 p->setPen( cg.shadow() );
480 p->drawPolyline( a );
481 a.setPoints( QCOORDARRLEN(pts3), pts3 );
482 a.translate( ir.x(), ir.y() );
483 p->setPen( cg.midlight() );
484 p->drawPolyline( a );
485 a.setPoints( QCOORDARRLEN(pts4), pts4 );
486 a.translate( ir.x(), ir.y() );
487 p->setPen( cg.light() );
488 p->drawPolyline( a );
489 a.setPoints( QCOORDARRLEN(pts5), pts5 );
490 a.translate( ir.x(), ir.y() );
491 QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
492 p->setPen( fillColor );
493 p->setBrush( fillColor ) ;
494 p->drawPolygon( a );
495 if ( on ) {
496 p->setPen( NoPen );
497 p->setBrush( cg.text() );
498 p->drawRect( ir.x() + 5, ir.y() + 4, 2, 4 );
499 p->drawRect( ir.x() + 4, ir.y() + 5, 4, 2 );
500 }
501 break;
502 }
503
504 case PE_Panel:
505 case PE_PanelPopup:
506 {
507 int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth)
508 : opt.lineWidth();
509
510 if (lw == 2) {
511 QColorGroup popupCG = cg;
512 if ( pe == PE_PanelPopup ) {
513 popupCG.setColor( QColorGroup::Light, cg.background() );
514 popupCG.setColor( QColorGroup::Midlight, cg.light() );
515 }
516 qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
517 } else {
518 QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
519 }
520 break;
521 }
522
523 case PE_Splitter:
524 {
525 QPen oldPen = p->pen();
526 p->setPen( cg.light() );
527 if ( flags & Style_Horizontal ) {
528 p->drawLine( r.x() + 1, r.y(), r.x() + 1, r.height() );
529 p->setPen( cg.dark() );
530 p->drawLine( r.x(), r.y(), r.x(), r.height() );
531 p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
532 p->setPen( cg.shadow() );
533 p->drawLine( r.right(), r.y(), r.right(), r.height() );
534 } else {
535 p->drawLine( r.x(), r.y() + 1, r.width(), r.y() + 1 );
536 p->setPen( cg.dark() );
537 p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
538 p->setPen( cg.shadow() );
539 p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
540 }
541 p->setPen( oldPen );
542 break;
543 }
544 case PE_DockWindowResizeHandle:
545 {
546 QPen oldPen = p->pen();
547 p->setPen( cg.light() );
548 if ( flags & Style_Horizontal ) {
549 p->drawLine( r.x(), r.y(), r.width(), r.y() );
550 p->setPen( cg.dark() );
551 p->drawLine( r.x(), r.bottom() - 1, r.width(), r.bottom() - 1 );
552 p->setPen( cg.shadow() );
553 p->drawLine( r.x(), r.bottom(), r.width(), r.bottom() );
554 } else {
555 p->drawLine( r.x(), r.y(), r.x(), r.height() );
556 p->setPen( cg.dark() );
557 p->drawLine( r.right()-1, r.y(), r.right()-1, r.height() );
558 p->setPen( cg.shadow() );
559 p->drawLine( r.right(), r.y(), r.right(), r.height() );
560 }
561 p->setPen( oldPen );
562 break;
563 }
564
565 case PE_ScrollBarSubLine:
566 if (use2000style) {
567 if (flags & Style_Down) {
568 p->setPen( cg.dark() );
569 p->setBrush( cg.brush( QColorGroup::Button ) );
570 p->drawRect( r );
571 } else
572 drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
573 } else
574 drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
575 ((flags & Style_Down) ? Style_Down : Style_Raised));
576
577 drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp),
578 p, r, cg, flags);
579 break;
580
581 case PE_ScrollBarAddLine:
582 if (use2000style) {
583 if (flags & Style_Down) {
584 p->setPen( cg.dark() );
585 p->setBrush( cg.brush( QColorGroup::Button ) );
586 p->drawRect( r );
587 } else
588 drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised);
589 } else
590 drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) |
591 ((flags & Style_Down) ? Style_Down : Style_Raised));
592
593 drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown),
594 p, r, cg, flags);
595 break;
596
597 case PE_ScrollBarAddPage:
598 case PE_ScrollBarSubPage:
599 {
600 QBrush br;
601 QColor c = p->backgroundColor();
602
603 p->setPen(NoPen);
604 p->setBackgroundMode(OpaqueMode);
605
606 if (flags & Style_Down) {
607 br = QBrush(cg.shadow(), Dense4Pattern);
608 p->setBackgroundColor( cg.dark() );
609 p->setBrush( QBrush(cg.shadow(), Dense4Pattern) );
610 } else {
611 br = (cg.brush(QColorGroup::Light).pixmap() ?
612 cg.brush(QColorGroup::Light) :
613 QBrush(cg.light(), Dense4Pattern));
614 p->setBrush(br);
615 }
616
617 p->drawRect(r);
618 p->setBackgroundColor(c);
619 break;
620 }
621
622 case PE_ScrollBarSlider:
623 if (! (flags & Style_Enabled)) {
624 QBrush br = (cg.brush(QColorGroup::Light).pixmap() ?
625 cg.brush(QColorGroup::Light) :
626 QBrush(cg.light(), Dense4Pattern));
627 p->setPen(NoPen);
628 p->setBrush(br);
629 p->setBackgroundMode(OpaqueMode);
630 p->drawRect(r);
631 } else
632 drawPrimitive(PE_ButtonBevel, p, r, cg, Style_Enabled | Style_Raised);
633 break;
634
635 case PE_WindowFrame:
636 {
637 QColorGroup popupCG = cg;
638 popupCG.setColor( QColorGroup::Light, cg.background() );
639 popupCG.setColor( QColorGroup::Midlight, cg.light() );
640 qDrawWinPanel(p, r, popupCG, flags & Style_Sunken);
641 }
642 break;
643
644 default:
645 if (pe >= PE_ArrowUp && pe <= PE_ArrowLeft) {
646 QPointArray a;
647
648 switch ( pe ) {
649 case PE_ArrowUp:
650 a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
651 break;
652
653 case PE_ArrowDown:
654 a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
655 break;
656
657 case PE_ArrowRight:
658 a.setPoints( 7, -2,-3, -2,3, -1,-2, -1,2, 0,-1, 0,1, 1,0 );
659 break;
660
661 case PE_ArrowLeft:
662 a.setPoints( 7, 0,-3, 0,3, -1,-2, -1,2, -2,-1, -2,1, -3,0 );
663 break;
664
665 default:
666 break;
667 }
668
669 if (a.isNull())
670 return;
671
672 p->save();
673 if ( flags & Style_Down )
674 p->translate( pixelMetric( PM_ButtonShiftHorizontal ),
675 pixelMetric( PM_ButtonShiftVertical ) );
676
677 if ( flags & Style_Enabled ) {
678 a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 );
679 p->setPen( cg.buttonText() );
680 p->drawLineSegments( a, 0, 3 ); // draw arrow
681 p->drawPoint( a[6] );
682 } else {
683 a.translate( r.x() + r.width() / 2 + 1, r.y() + r.height() / 2 + 1 );
684 p->setPen( cg.light() );
685 p->drawLineSegments( a, 0, 3 ); // draw arrow
686 p->drawPoint( a[6] );
687 a.translate( -1, -1 );
688 p->setPen( cg.mid() );
689 p->drawLineSegments( a, 0, 3 ); // draw arrow
690 p->drawPoint( a[6] );
691 }
692 p->restore();
693 } else
694 QCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt);
695 }
696}
697
698
699/*!
700 \reimp
701*/
702void QWindowsStyle::drawControl( ControlElement element,
703 QPainter *p,
704 const QWidget *widget,
705 const QRect &r,
706 const QColorGroup &cg,
707 SFlags flags,
708 const QStyleOption& opt ) const
709{
710 switch (element) {
711#ifndef QT_NO_TABBAR
712 case CE_TabBarTab:
713 {
714 if ( !widget || !widget->parentWidget() || !opt.tab() )
715 break;
716
717 const QTabBar * tb = (const QTabBar *) widget;
718 const QTab * t = opt.tab();
719 bool selected = flags & Style_Selected;
720 bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ?
721 TRUE : FALSE;
722 QRect r2( r );
723 if ( tb->shape() == QTabBar::RoundedAbove ) {
724 p->setPen( cg.midlight() );
725
726 p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() );
727 p->setPen( cg.light() );
728 p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 );
729 if ( r2.left() == 0 )
730 p->drawPoint( tb->rect().bottomLeft() );
731
732 if ( selected ) {
733 p->fillRect( QRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2),
734 cg.brush( QColorGroup::Background ));
735 p->setPen( cg.background() );
736 p->drawLine( r2.left()+1, r2.bottom(), r2.left()+1, r2.top()+2 );
737 p->setPen( cg.light() );
738 } else {
739 p->setPen( cg.light() );
740 r2.setRect( r2.left() + 2, r2.top() + 2,
741 r2.width() - 4, r2.height() - 2 );
742 }
743
744 int x1, x2;
745 x1 = r2.left();
746 x2 = r2.right() - 2;
747 p->drawLine( x1, r2.bottom()-1, x1, r2.top() + 2 );
748 x1++;
749 p->drawPoint( x1, r2.top() + 1 );
750 x1++;
751 p->drawLine( x1, r2.top(), x2, r2.top() );
752 if ( r2.left() > 0 ) {
753 p->setPen( cg.midlight() );
754 }
755 x1 = r2.left();
756 p->drawPoint( x1, r2.bottom());
757
758 p->setPen( cg.midlight() );
759 x1++;
760 p->drawLine( x1, r2.bottom(), x1, r2.top() + 2 );
761 x1++;
762 p->drawLine( x1, r2.top()+1, x2, r2.top()+1 );
763
764 p->setPen( cg.dark() );
765 x2 = r2.right() - 1;
766 p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - 1 +
767 (selected ? 1:-1) );
768 p->setPen( cg.shadow() );
769 p->drawPoint( x2, r2.top() + 1 );
770 p->drawPoint( x2, r2.top() + 1 );
771 x2++;
772 p->drawLine( x2, r2.top() + 2, x2, r2.bottom() -
773 (selected ? (lastTab ? 0:1) :2));
774 } else if ( tb->shape() == QTabBar::RoundedBelow ) {
775 bool rightAligned = styleHint( SH_TabBar_Alignment, tb ) == AlignRight;
776 bool firstTab = tb->indexOf( t->identifier() ) == 0;
777 if ( selected ) {
778 p->fillRect( QRect( r2.left()+1, r2.top(), r2.width()-3, 1),
779 cg.brush( QColorGroup::Background ));
780 p->setPen( cg.background() );
781 p->drawLine( r2.left()+1, r2.top(), r2.left()+1, r2.bottom()-2 );
782 p->setPen( cg.dark() );
783 } else {
784 p->setPen( cg.shadow() );
785 p->drawLine( r2.left() +
786 (rightAligned && firstTab ? 0 : 1),
787 r2.top() + 1,
788 r2.right() - (lastTab ? 0 : 2),
789 r2.top() + 1 );
790
791 if ( rightAligned && lastTab )
792 p->drawPoint( r2.right(), r2.top() );
793 p->setPen( cg.dark() );
794 p->drawLine( r2.left(), r2.top(), r2.right() - 1,
795 r2.top() );
796 r2.setRect( r2.left() + 2, r2.top(),
797 r2.width() - 4, r2.height() - 2 );
798 }
799
800 p->drawLine( r2.right() - 1, r2.top() + (selected ? 0: 2),
801 r2.right() - 1, r2.bottom() - 2 );
802 p->drawPoint( r2.right() - 2, r2.bottom() - 2 );
803 p->drawLine( r2.right() - 2, r2.bottom() - 1,
804 r2.left() + 1, r2.bottom() - 1 );
805
806 p->setPen( cg.midlight() );
807 p->drawLine( r2.left() + 1, r2.bottom() - 2,
808 r2.left() + 1, r2.top() + (selected ? 0 : 2) );
809
810 p->setPen( cg.shadow() );
811 p->drawLine( r2.right(),
812 r2.top() + (lastTab && rightAligned &&
813 selected) ? 0 : 1,
814 r2.right(), r2.bottom() - 1 );
815 p->drawPoint( r2.right() - 1, r2.bottom() - 1 );
816 p->drawLine( r2.right() - 1, r2.bottom(),
817 r2.left() + 2, r2.bottom() );
818
819 p->setPen( cg.light() );
820 p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2),
821 r2.left(), r2.bottom() - 2 );
822 } else {
823 QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
824 }
825 break;
826 }
827#endif // QT_NO_TABBAR
828 case CE_ToolBoxTab:
829 {
830 qDrawShadePanel( p, r, cg, flags & (Style_Sunken | Style_Down | Style_On) , 1,
831 &cg.brush(QColorGroup::Button));
832 break;
833 }
834
835#ifndef QT_NO_POPUPMENU
836 case CE_PopupMenuItem:
837 {
838 if (! widget || opt.isDefault())
839 break;
840
841 const QPopupMenu *popupmenu = (const QPopupMenu *) widget;
842 QMenuItem *mi = opt.menuItem();
843 if ( !mi )
844 break;
845
846 int tab = opt.tabWidth();
847 int maxpmw = opt.maxIconWidth();
848 bool dis = !(flags&Style_Enabled);
849 bool checkable = popupmenu->isCheckable();
850 bool act = flags & Style_Active;
851 int x, y, w, h;
852
853 r.rect(&x, &y, &w, &h);
854
855 if ( checkable ) {
856 // space for the checkmarks
857 if (use2000style)
858 maxpmw = QMAX( maxpmw, 20 );
859 else
860 maxpmw = QMAX( maxpmw, 12 );
861 }
862
863 int checkcol = maxpmw;
864
865 if ( mi && mi->isSeparator() ) { // draw separator
866 p->setPen( cg.dark() );
867 p->drawLine( x, y, x+w, y );
868 p->setPen( cg.light() );
869 p->drawLine( x, y+1, x+w, y+1 );
870 return;
871 }
872
873 QBrush fill = (act ?
874 cg.brush( QColorGroup::Highlight ) :
875 cg.brush( QColorGroup::Button ));
876 p->fillRect( x, y, w, h, fill);
877
878 if ( !mi )
879 return;
880
881 int xpos = x;
882 QRect vrect = visualRect( QRect( xpos, y, checkcol, h ), r );
883 int xvis = vrect.x();
884 if ( mi->isChecked() ) {
885 if ( act && !dis )
886 qDrawShadePanel( p, xvis, y, checkcol, h,
887 cg, TRUE, 1, &cg.brush( QColorGroup::Button ) );
888 else {
889 QBrush fill( cg.light(), Dense4Pattern );
890 // set the brush origin for the hash pattern to the x/y coordinate
891 // of the menu item's checkmark... this way, the check marks have
892 // a consistent look
893 QPoint origin = p->brushOrigin();
894 p->setBrushOrigin( xvis, y );
895 qDrawShadePanel( p, xvis, y, checkcol, h, cg, TRUE, 1,
896 &fill );
897 // restore the previous brush origin
898 p->setBrushOrigin( origin );
899 }
900 } else if (! act)
901 p->fillRect(xvis, y, checkcol , h, cg.brush( QColorGroup::Button ));
902
903 if ( mi->iconSet() ) { // draw iconset
904 QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
905 if (act && !dis )
906 mode = QIconSet::Active;
907 QPixmap pixmap;
908 if ( checkable && mi->isChecked() )
909 pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode, QIconSet::On );
910 else
911 pixmap = mi->iconSet()->pixmap( QIconSet::Small, mode );
912 int pixw = pixmap.width();
913 int pixh = pixmap.height();
914 if ( act && !dis && !mi->isChecked() )
915 qDrawShadePanel( p, xvis, y, checkcol, h, cg, FALSE, 1,
916 &cg.brush( QColorGroup::Button ) );
917 QRect pmr( 0, 0, pixw, pixh );
918 pmr.moveCenter( vrect.center() );
919 p->setPen( cg.text() );
920 p->drawPixmap( pmr.topLeft(), pixmap );
921
922 fill = (act ?
923 cg.brush( QColorGroup::Highlight ) :
924 cg.brush( QColorGroup::Button ));
925 int xp = xpos + checkcol + 1;
926 p->fillRect( visualRect( QRect( xp, y, w - checkcol - 1, h ), r ), fill);
927 } else if ( checkable ) { // just "checking"...
928 if ( mi->isChecked() ) {
929 int xp = xpos + windowsItemFrame;
930
931 SFlags cflags = Style_Default;
932 if (! dis)
933 cflags |= Style_Enabled;
934 if (act)
935 cflags |= Style_On;
936
937 drawPrimitive(PE_CheckMark, p,
938 visualRect( QRect(xp, y + windowsItemFrame,
939 checkcol - 2*windowsItemFrame,
940 h - 2*windowsItemFrame), r ), cg, cflags);
941 }
942 }
943
944 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
945
946 QColor discol;
947 if ( dis ) {
948 discol = cg.text();
949 p->setPen( discol );
950 }
951
952 int xm = windowsItemFrame + checkcol + windowsItemHMargin;
953 xpos += xm;
954
955 vrect = visualRect( QRect( xpos, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin ), r );
956 xvis = vrect.x();
957 if ( mi->custom() ) {
958 p->save();
959 if ( dis && !act ) {
960 p->setPen( cg.light() );
961 mi->custom()->paint( p, cg, act, !dis,
962 xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin );
963 p->setPen( discol );
964 }
965 mi->custom()->paint( p, cg, act, !dis,
966 xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin );
967 p->restore();
968 }
969 QString s = mi->text();
970 if ( !s.isNull() ) { // draw text
971 int t = s.find( '\t' );
972 int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
973 if (!styleHint(SH_UnderlineAccelerator, widget))
974 text_flags |= NoAccel;
975 text_flags |= (QApplication::reverseLayout() ? AlignRight : AlignLeft );
976 if ( t >= 0 ) { // draw tab text
977 int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1;
978 if ( use2000style )
979 xp -= 20;
980 else
981 xp -= windowsRightBorder;
982 int xoff = visualRect( QRect( xp, y+windowsItemVMargin, tab, h-2*windowsItemVMargin ), r ).x();
983 if ( dis && !act ) {
984 p->setPen( cg.light() );
985 p->drawText( xoff+1, y+windowsItemVMargin+1, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ));
986 p->setPen( discol );
987 }
988 p->drawText( xoff, y+windowsItemVMargin, tab, h-2*windowsItemVMargin, text_flags, s.mid( t+1 ) );
989 s = s.left( t );
990 }
991 if ( dis && !act ) {
992 p->setPen( cg.light() );
993 p->drawText( xvis+1, y+windowsItemVMargin+1, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
994 p->setPen( discol );
995 }
996 p->drawText( xvis, y+windowsItemVMargin, w-xm-tab+1, h-2*windowsItemVMargin, text_flags, s, t );
997 } else if ( mi->pixmap() ) { // draw pixmap
998 QPixmap *pixmap = mi->pixmap();
999 if ( pixmap->depth() == 1 )
1000 p->setBackgroundMode( OpaqueMode );
1001 p->drawPixmap( xvis, y+windowsItemFrame, *pixmap );
1002 if ( pixmap->depth() == 1 )
1003 p->setBackgroundMode( TransparentMode );
1004 }
1005 if ( mi->popup() ) { // draw sub menu arrow
1006 int dim = (h-2*windowsItemFrame) / 2;
1007 PrimitiveElement arrow;
1008 arrow = ( QApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
1009 xpos = x+w - windowsArrowHMargin - windowsItemFrame - dim;
1010 vrect = visualRect( QRect(xpos, y + h / 2 - dim / 2, dim, dim), r );
1011 if ( act ) {
1012 QColorGroup g2 = cg;
1013 g2.setColor( QColorGroup::ButtonText, g2.highlightedText() );
1014 drawPrimitive(arrow, p, vrect,
1015 g2, dis ? Style_Default : Style_Enabled);
1016 } else {
1017 drawPrimitive(arrow, p, vrect,
1018 cg, dis ? Style_Default : Style_Enabled );
1019 }
1020 }
1021
1022 break;
1023 }
1024#endif
1025
1026 case CE_MenuBarItem:
1027 {
1028 bool active = flags & Style_Active;
1029 bool hasFocus = flags & Style_HasFocus;
1030 bool down = flags & Style_Down;
1031 QRect pr = r;
1032
1033 p->fillRect( r, cg.brush( QColorGroup::Button ) );
1034 if ( active || hasFocus ) {
1035 QBrush b = cg.brush( QColorGroup::Button );
1036 if ( active && down )
1037 p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
1038 if ( active && hasFocus )
1039 qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(),
1040 cg, active && down, 1, 0, &b );
1041 if ( active && down ) {
1042 pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, widget),
1043 pixelMetric(PM_ButtonShiftVertical, widget) );
1044 p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
1045 }
1046 }
1047 QCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt);
1048 break;
1049 }
1050
1051 default:
1052 QCommonStyle::drawControl(element, p, widget, r, cg, flags, opt);
1053 }
1054}
1055
1056
1057/*!
1058 \reimp
1059*/
1060int QWindowsStyle::pixelMetric(PixelMetric metric, const QWidget *widget) const
1061{
1062 int ret;
1063
1064 switch (metric) {
1065 case PM_ButtonDefaultIndicator:
1066 case PM_ButtonShiftHorizontal:
1067 case PM_ButtonShiftVertical:
1068 ret = 1;
1069 break;
1070
1071 case PM_MaximumDragDistance:
1072 ret = 60;
1073 break;
1074
1075#ifndef QT_NO_SLIDER
1076 case PM_SliderLength:
1077 ret = 11;
1078 break;
1079
1080 // Returns the number of pixels to use for the business part of the
1081 // slider (i.e., the non-tickmark portion). The remaining space is shared
1082 // equally between the tickmark regions.
1083 case PM_SliderControlThickness:
1084 {
1085 const QSlider * sl = (const QSlider *) widget;
1086 int space = (sl->orientation() == Horizontal) ? sl->height()
1087 : sl->width();
1088 int ticks = sl->tickmarks();
1089 int n = 0;
1090 if ( ticks & QSlider::Above ) n++;
1091 if ( ticks & QSlider::Below ) n++;
1092 if ( !n ) {
1093 ret = space;
1094 break;
1095 }
1096
1097 int thick = 6; // Magic constant to get 5 + 16 + 5
1098 if ( ticks != QSlider::Both && ticks != QSlider::NoMarks )
1099 thick += pixelMetric( PM_SliderLength, sl ) / 4;
1100
1101 space -= thick;
1102 //### the two sides may be unequal in size
1103 if ( space > 0 )
1104 thick += (space * 2) / (n + 2);
1105 ret = thick;
1106 break;
1107 }
1108#endif // QT_NO_SLIDER
1109
1110 case PM_MenuBarFrameWidth:
1111 ret = 0;
1112 break;
1113
1114#if defined(Q_WS_WIN)
1115 case PM_TitleBarHeight:
1116 if ( widget && ( widget->testWFlags( WStyle_Tool ) || ::qt_cast<QDockWindow*>(widget) ) ) {
1117 // MS always use one less than they say
1118#if defined(Q_OS_TEMP)
1119 ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
1120#else
1121 ret = GetSystemMetrics( SM_CYSMCAPTION ) - 1;
1122#endif
1123 } else {
1124 ret = GetSystemMetrics( SM_CYCAPTION ) - 1;
1125 }
1126 break;
1127
1128 case PM_ScrollBarExtent:
1129 {
1130#ifndef Q_OS_TEMP
1131 NONCLIENTMETRICS ncm;
1132 ncm.cbSize = sizeof(NONCLIENTMETRICS);
1133 if ( SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0 ) )
1134 ret = QMAX( ncm.iScrollHeight, ncm.iScrollWidth );
1135 else
1136#endif
1137 ret = QCommonStyle::pixelMetric( metric, widget );
1138 }
1139 break;
1140#endif
1141
1142 case PM_SplitterWidth:
1143 ret = QMAX( 6, QApplication::globalStrut().width() );
1144 break;
1145
1146#if defined(Q_WS_WIN)
1147 case PM_MDIFrameWidth:
1148 ret = GetSystemMetrics(SM_CYFRAME);
1149 break;
1150#endif
1151
1152 default:
1153 ret = QCommonStyle::pixelMetric(metric, widget);
1154 break;
1155 }
1156
1157 return ret;
1158}
1159
1160
1161/*!
1162 \reimp
1163*/
1164QSize QWindowsStyle::sizeFromContents( ContentsType contents,
1165 const QWidget *widget,
1166 const QSize &contentsSize,
1167 const QStyleOption& opt ) const
1168{
1169 QSize sz(contentsSize);
1170
1171 switch (contents) {
1172 case CT_PushButton:
1173 {
1174#ifndef QT_NO_PUSHBUTTON
1175 const QPushButton *button = (const QPushButton *) widget;
1176 sz = QCommonStyle::sizeFromContents(contents, widget, contentsSize, opt);
1177 int w = sz.width(), h = sz.height();
1178
1179 int defwidth = 0;
1180 if (button->isDefault() || button->autoDefault())
1181 defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, widget );
1182
1183 if (w < 80+defwidth && !button->pixmap())
1184 w = 80+defwidth;
1185 if (h < 23+defwidth)
1186 h = 23+defwidth;
1187
1188 sz = QSize(w, h);
1189#endif
1190 break;
1191 }
1192
1193 case CT_PopupMenuItem:
1194 {
1195#ifndef QT_NO_POPUPMENU
1196 if (! widget || opt.isDefault())
1197 break;
1198
1199 const QPopupMenu *popup = (const QPopupMenu *) widget;
1200 bool checkable = popup->isCheckable();
1201 QMenuItem *mi = opt.menuItem();
1202 int maxpmw = opt.maxIconWidth();
1203 int w = sz.width(), h = sz.height();
1204
1205 if (mi->custom()) {
1206 w = mi->custom()->sizeHint().width();
1207 h = mi->custom()->sizeHint().height();
1208 if (! mi->custom()->fullSpan())
1209 h += 2*windowsItemVMargin + 2*windowsItemFrame;
1210 } else if ( mi->widget() ) {
1211 } else if (mi->isSeparator()) {
1212 w = 10; // arbitrary
1213 h = windowsSepHeight;
1214 } else {
1215 if (mi->pixmap())
1216 h = QMAX(h, mi->pixmap()->height() + 2*windowsItemFrame);
1217 else if (! mi->text().isNull())
1218 h = QMAX(h, popup->fontMetrics().height() + 2*windowsItemVMargin +
1219 2*windowsItemFrame);
1220
1221 if (mi->iconSet() != 0)
1222 h = QMAX(h, mi->iconSet()->pixmap(QIconSet::Small,
1223 QIconSet::Normal).height() +
1224 2*windowsItemFrame);
1225 }
1226
1227 if (! mi->text().isNull() && mi->text().find('\t') >= 0) {
1228 if ( use2000style )
1229 w += 20;
1230 else
1231 w += windowsTabSpacing;
1232 } else if (mi->popup()) {
1233 w += 2*windowsArrowHMargin;
1234 }
1235
1236 if (use2000style) {
1237 if (checkable && maxpmw < 20)
1238 w += 20 - maxpmw;
1239 } else {
1240 if (checkable && maxpmw < windowsCheckMarkWidth)
1241 w += windowsCheckMarkWidth - maxpmw;
1242 }
1243 if (checkable || maxpmw > 0)
1244 w += windowsCheckMarkHMargin;
1245 if (use2000style)
1246 w += 20;
1247 else
1248 w += windowsRightBorder;
1249
1250 sz = QSize(w, h);
1251#endif
1252 break;
1253 }
1254
1255 default:
1256 sz = QCommonStyle::sizeFromContents(contents, widget, sz, opt);
1257 break;
1258 }
1259
1260 return sz;
1261}
1262
1263/*! \reimp
1264*/
1265void QWindowsStyle::polishPopupMenu( QPopupMenu* p)
1266{
1267#ifndef QT_NO_POPUPMENU
1268 if ( !p->testWState( WState_Polished ) )
1269 p->setCheckable( TRUE );
1270#endif
1271}
1272
1273#ifndef QT_NO_IMAGEIO_XPM
1274static const char * const qt_close_xpm[] = {
1275"12 12 2 1",
1276"# c #000000",
1277". c None",
1278"............",
1279"............",
1280"..##....##..",
1281"...##..##...",
1282"....####....",
1283".....##.....",
1284"....####....",
1285"...##..##...",
1286"..##....##..",
1287"............",
1288"............",
1289"............"};
1290
1291static const char * const qt_maximize_xpm[]={
1292"12 12 2 1",
1293"# c #000000",
1294". c None",
1295"............",
1296".#########..",
1297".#########..",
1298".#.......#..",
1299".#.......#..",
1300".#.......#..",
1301".#.......#..",
1302".#.......#..",
1303".#.......#..",
1304".#########..",
1305"............",
1306"............"};
1307
1308
1309static const char * const qt_minimize_xpm[] = {
1310"12 12 2 1",
1311"# c #000000",
1312". c None",
1313"............",
1314"............",
1315"............",
1316"............",
1317"............",
1318"............",
1319"............",
1320"............",
1321"..######....",
1322"..######....",
1323"............",
1324"............"};
1325
1326static const char * const qt_normalizeup_xpm[] = {
1327"12 12 2 1",
1328"# c #000000",
1329". c None",
1330"............",
1331"....######..",
1332"....######..",
1333"....#....#..",
1334"..######.#..",
1335"..######.#..",
1336"..#....###..",
1337"..#....#....",
1338"..#....#....",
1339"..######....",
1340"............",
1341"............"};
1342
1343
1344static const char * const qt_shade_xpm[] = {
1345"12 12 2 1",
1346"# c #000000",
1347". c None",
1348"............",
1349"............",
1350"............",
1351"............",
1352"............",
1353".....#......",
1354"....###.....",
1355"...#####....",
1356"..#######...",
1357"............",
1358"............",
1359"............"};
1360
1361static const char * const qt_unshade_xpm[] = {
1362"12 12 2 1",
1363"# c #000000",
1364". c None",
1365"............",
1366"............",
1367"............",
1368"............",
1369"..#######...",
1370"...#####....",
1371"....###.....",
1372".....#......",
1373"............",
1374"............",
1375"............",
1376"............"};
1377
1378static const char * dock_window_close_xpm[] = {
1379"8 8 2 1",
1380"# c #000000",
1381". c None",
1382"........",
1383".##..##.",
1384"..####..",
1385"...##...",
1386"..####..",
1387".##..##.",
1388"........",
1389"........"};
1390
1391/* XPM */
1392static const char * const information_xpm[]={
1393"32 32 5 1",
1394". c None",
1395"c c #000000",
1396"* c #999999",
1397"a c #ffffff",
1398"b c #0000ff",
1399"...........********.............",
1400"........***aaaaaaaa***..........",
1401"......**aaaaaaaaaaaaaa**........",
1402".....*aaaaaaaaaaaaaaaaaa*.......",
1403"....*aaaaaaaabbbbaaaaaaaac......",
1404"...*aaaaaaaabbbbbbaaaaaaaac.....",
1405"..*aaaaaaaaabbbbbbaaaaaaaaac....",
1406".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
1407".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
1408"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
1409"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
1410"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1411"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1412"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1413"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1414"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
1415".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1416".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
1417"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
1418"...caaaaaaabbbbbbbbbaaaaaac****.",
1419"....caaaaaaaaaaaaaaaaaaaac****..",
1420".....caaaaaaaaaaaaaaaaaac****...",
1421"......ccaaaaaaaaaaaaaacc****....",
1422".......*cccaaaaaaaaccc*****.....",
1423"........***cccaaaac*******......",
1424"..........****caaac*****........",
1425".............*caaac**...........",
1426"...............caac**...........",
1427"................cac**...........",
1428".................cc**...........",
1429"..................***...........",
1430"...................**..........."};
1431/* XPM */
1432static const char* const warning_xpm[]={
1433"32 32 4 1",
1434". c None",
1435"a c #ffff00",
1436"* c #000000",
1437"b c #999999",
1438".............***................",
1439"............*aaa*...............",
1440"...........*aaaaa*b.............",
1441"...........*aaaaa*bb............",
1442"..........*aaaaaaa*bb...........",
1443"..........*aaaaaaa*bb...........",
1444".........*aaaaaaaaa*bb..........",
1445".........*aaaaaaaaa*bb..........",
1446"........*aaaaaaaaaaa*bb.........",
1447"........*aaaa***aaaa*bb.........",
1448".......*aaaa*****aaaa*bb........",
1449".......*aaaa*****aaaa*bb........",
1450"......*aaaaa*****aaaaa*bb.......",
1451"......*aaaaa*****aaaaa*bb.......",
1452".....*aaaaaa*****aaaaaa*bb......",
1453".....*aaaaaa*****aaaaaa*bb......",
1454"....*aaaaaaaa***aaaaaaaa*bb.....",
1455"....*aaaaaaaa***aaaaaaaa*bb.....",
1456"...*aaaaaaaaa***aaaaaaaaa*bb....",
1457"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
1458"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
1459"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
1460".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
1461".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
1462"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
1463"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
1464"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1465"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
1466".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
1467"..*************************bbbbb",
1468"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
1469".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
1470/* XPM */
1471static const char* const critical_xpm[]={
1472"32 32 4 1",
1473". c None",
1474"a c #999999",
1475"* c #ff0000",
1476"b c #ffffff",
1477"...........********.............",
1478".........************...........",
1479".......****************.........",
1480"......******************........",
1481".....********************a......",
1482"....**********************a.....",
1483"...************************a....",
1484"..*******b**********b*******a...",
1485"..******bbb********bbb******a...",
1486".******bbbbb******bbbbb******a..",
1487".*******bbbbb****bbbbb*******a..",
1488"*********bbbbb**bbbbb*********a.",
1489"**********bbbbbbbbbb**********a.",
1490"***********bbbbbbbb***********aa",
1491"************bbbbbb************aa",
1492"************bbbbbb************aa",
1493"***********bbbbbbbb***********aa",
1494"**********bbbbbbbbbb**********aa",
1495"*********bbbbb**bbbbb*********aa",
1496".*******bbbbb****bbbbb*******aa.",
1497".******bbbbb******bbbbb******aa.",
1498"..******bbb********bbb******aaa.",
1499"..*******b**********b*******aa..",
1500"...************************aaa..",
1501"....**********************aaa...",
1502"....a********************aaa....",
1503".....a******************aaa.....",
1504"......a****************aaa......",
1505".......aa************aaaa.......",
1506".........aa********aaaaa........",
1507"...........aaaaaaaaaaa..........",
1508".............aaaaaaa............"};
1509/* XPM */
1510static const char *const question_xpm[] = {
1511"32 32 5 1",
1512". c None",
1513"c c #000000",
1514"* c #999999",
1515"a c #ffffff",
1516"b c #0000ff",
1517"...........********.............",
1518"........***aaaaaaaa***..........",
1519"......**aaaaaaaaaaaaaa**........",
1520".....*aaaaaaaaaaaaaaaaaa*.......",
1521"....*aaaaaaaaaaaaaaaaaaaac......",
1522"...*aaaaaaaabbbbbbaaaaaaaac.....",
1523"..*aaaaaaaabaaabbbbaaaaaaaac....",
1524".*aaaaaaaabbaaaabbbbaaaaaaaac...",
1525".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
1526"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
1527"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
1528"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
1529"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
1530"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
1531"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
1532"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
1533".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
1534".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
1535"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
1536"...caaaaaaaaaabbaaaaaaaaaac****.",
1537"....caaaaaaaaaaaaaaaaaaaac****..",
1538".....caaaaaaaaaaaaaaaaaac****...",
1539"......ccaaaaaaaaaaaaaacc****....",
1540".......*cccaaaaaaaaccc*****.....",
1541"........***cccaaaac*******......",
1542"..........****caaac*****........",
1543".............*caaac**...........",
1544"...............caac**...........",
1545"................cac**...........",
1546".................cc**...........",
1547"..................***...........",
1548"...................**...........",
1549};
1550#endif //QT_NO_IMAGEIO_XPM
1551
1552/*!
1553 \reimp
1554 */
1555QPixmap QWindowsStyle::stylePixmap(StylePixmap stylepixmap,
1556 const QWidget *widget,
1557 const QStyleOption& opt) const
1558{
1559#ifndef QT_NO_IMAGEIO_XPM
1560 switch (stylepixmap) {
1561 case SP_TitleBarShadeButton:
1562 return QPixmap( (const char **)qt_shade_xpm );
1563 case SP_TitleBarUnshadeButton:
1564 return QPixmap( (const char **)qt_unshade_xpm );
1565 case SP_TitleBarNormalButton:
1566 return QPixmap( (const char **)qt_normalizeup_xpm );
1567 case SP_TitleBarMinButton:
1568 return QPixmap( (const char **)qt_minimize_xpm );
1569 case SP_TitleBarMaxButton:
1570 return QPixmap( (const char **)qt_maximize_xpm );
1571 case SP_TitleBarCloseButton:
1572 return QPixmap( (const char **)qt_close_xpm );
1573 case SP_DockWindowCloseButton:
1574 return QPixmap( (const char **)dock_window_close_xpm );
1575 case SP_MessageBoxInformation:
1576 return QPixmap( (const char **)information_xpm);
1577 case SP_MessageBoxWarning:
1578 return QPixmap( (const char **)warning_xpm );
1579 case SP_MessageBoxCritical:
1580 return QPixmap( (const char **)critical_xpm );
1581 case SP_MessageBoxQuestion:
1582 return QPixmap( (const char **)question_xpm );
1583 default:
1584 break;
1585 }
1586#endif //QT_NO_IMAGEIO_XPM
1587 return QCommonStyle::stylePixmap(stylepixmap, widget, opt);
1588}
1589
1590/*!\reimp
1591*/
1592void QWindowsStyle::drawComplexControl( ComplexControl ctrl, QPainter *p,
1593 const QWidget *widget,
1594 const QRect &r,
1595 const QColorGroup &cg,
1596 SFlags flags,
1597 SCFlags sub,
1598 SCFlags subActive,
1599 const QStyleOption& opt ) const
1600{
1601 switch (ctrl) {
1602#ifndef QT_NO_LISTVIEW
1603 case CC_ListView:
1604 {
1605 if ( sub & SC_ListView ) {
1606 QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, subActive, opt );
1607 }
1608 if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
1609 if (opt.isDefault())
1610 break;
1611
1612 QListViewItem *item = opt.listViewItem(),
1613 *child = item->firstChild();
1614
1615 int y = r.y();
1616 int c;
1617 int dotoffset = 0;
1618 QPointArray dotlines;
1619 if ( subActive == (uint)SC_All && sub == SC_ListViewExpand ) {
1620 c = 2;
1621 dotlines.resize(2);
1622 dotlines[0] = QPoint( r.right(), r.top() );
1623 dotlines[1] = QPoint( r.right(), r.bottom() );
1624 } else {
1625 int linetop = 0, linebot = 0;
1626 // each branch needs at most two lines, ie. four end points
1627 dotoffset = (item->itemPos() + item->height() - y) %2;
1628 dotlines.resize( item->childCount() * 4 );
1629 c = 0;
1630
1631 // skip the stuff above the exposed rectangle
1632 while ( child && y + child->height() <= 0 ) {
1633 y += child->totalHeight();
1634 child = child->nextSibling();
1635 }
1636
1637 int bx = r.width() / 2;
1638
1639 // paint stuff in the magical area
1640 QListView* v = item->listView();
1641 while ( child && y < r.height() ) {
1642 if (child->isVisible()) {
1643 int lh;
1644 if ( !item->multiLinesEnabled() )
1645 lh = child->height();
1646 else
1647 lh = p->fontMetrics().height() + 2 * v->itemMargin();
1648 lh = QMAX( lh, QApplication::globalStrut().height() );
1649 if ( lh % 2 > 0 )
1650 lh++;
1651 linebot = y + lh/2;
1652 if ( (child->isExpandable() || child->childCount()) &&
1653 (child->height() > 0) ) {
1654 // needs a box
1655 p->setPen( cg.mid() );
1656 p->drawRect( bx-4, linebot-4, 9, 9 );
1657 // plus or minus
1658 p->setPen( cg.text() );
1659 p->drawLine( bx - 2, linebot, bx + 2, linebot );
1660 if ( !child->isOpen() )
1661 p->drawLine( bx, linebot - 2, bx, linebot + 2 );
1662 // dotlinery
1663 p->setPen( cg.mid() );
1664 dotlines[c++] = QPoint( bx, linetop );
1665 dotlines[c++] = QPoint( bx, linebot - 4 );
1666 dotlines[c++] = QPoint( bx + 5, linebot );
1667 dotlines[c++] = QPoint( r.width(), linebot );
1668 linetop = linebot + 5;
1669 } else {
1670 // just dotlinery
1671 dotlines[c++] = QPoint( bx+1, linebot -1);
1672 dotlines[c++] = QPoint( r.width(), linebot -1);
1673 }
1674 y += child->totalHeight();
1675 }
1676 child = child->nextSibling();
1677 }
1678
1679 // Expand line height to edge of rectangle if there's any
1680 // visible child below
1681 while ( child && child->height() <= 0)
1682 child = child->nextSibling();
1683 if ( child )
1684 linebot = r.height();
1685
1686 if ( linetop < linebot ) {
1687 dotlines[c++] = QPoint( bx, linetop );
1688 dotlines[c++] = QPoint( bx, linebot );
1689 }
1690 }
1691 p->setPen( cg.text() );
1692
1693 static QBitmap *verticalLine = 0, *horizontalLine = 0;
1694 static QCleanupHandler<QBitmap> qlv_cleanup_bitmap;
1695 if ( !verticalLine ) {
1696 // make 128*1 and 1*128 bitmaps that can be used for
1697 // drawing the right sort of lines.
1698 verticalLine = new QBitmap( 1, 129, TRUE );
1699 horizontalLine = new QBitmap( 128, 1, TRUE );
1700 QPointArray a( 64 );
1701 QPainter p;
1702 p.begin( verticalLine );
1703 int i;
1704 for( i=0; i<64; i++ )
1705 a.setPoint( i, 0, i*2+1 );
1706 p.setPen( color1 );
1707 p.drawPoints( a );
1708 p.end();
1709 QApplication::flushX();
1710 verticalLine->setMask( *verticalLine );
1711 p.begin( horizontalLine );
1712 for( i=0; i<64; i++ )
1713 a.setPoint( i, i*2+1, 0 );
1714 p.setPen( color1 );
1715 p.drawPoints( a );
1716 p.end();
1717 QApplication::flushX();
1718 horizontalLine->setMask( *horizontalLine );
1719 qlv_cleanup_bitmap.add( &verticalLine );
1720 qlv_cleanup_bitmap.add( &horizontalLine );
1721 }
1722
1723 int line; // index into dotlines
1724 if ( sub & SC_ListViewBranch ) for( line = 0; line < c; line += 2 ) {
1725 // assumptions here: lines are horizontal or vertical.
1726 // lines always start with the numerically lowest
1727 // coordinate.
1728
1729 // point ... relevant coordinate of current point
1730 // end ..... same coordinate of the end of the current line
1731 // other ... the other coordinate of the current point/line
1732 if ( dotlines[line].y() == dotlines[line+1].y() ) {
1733 int end = dotlines[line+1].x();
1734 int point = dotlines[line].x();
1735 int other = dotlines[line].y();
1736 while( point < end ) {
1737 int i = 128;
1738 if ( i+point > end )
1739 i = end-point;
1740 p->drawPixmap( point, other, *horizontalLine,
1741 0, 0, i, 1 );
1742 point += i;
1743 }
1744 } else {
1745 int end = dotlines[line+1].y();
1746 int point = dotlines[line].y();
1747 int other = dotlines[line].x();
1748 int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
1749 while( point < end ) {
1750 int i = 128;
1751 if ( i+point > end )
1752 i = end-point;
1753 p->drawPixmap( other, point, *verticalLine,
1754 0, pixmapoffset, 1, i );
1755 point += i;
1756 }
1757 }
1758 }
1759 }
1760 }
1761 break;
1762#endif //QT_NO_LISTVIEW
1763
1764#ifndef QT_NO_COMBOBOX
1765 case CC_ComboBox:
1766 if ( sub & SC_ComboBoxArrow ) {
1767 SFlags flags = Style_Default;
1768
1769 qDrawWinPanel( p, r, cg, TRUE, widget->isEnabled() ?
1770 &cg.brush( QColorGroup::Base ):
1771 &cg.brush( QColorGroup::Background ) );
1772
1773 QRect ar =
1774 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
1775 SC_ComboBoxArrow ), widget );
1776 if ( subActive == SC_ComboBoxArrow ) {
1777 p->setPen( cg.dark() );
1778 p->setBrush( cg.brush( QColorGroup::Button ) );
1779 p->drawRect( ar );
1780 } else
1781 qDrawWinPanel( p, ar, cg, FALSE,
1782 &cg.brush( QColorGroup::Button ) );
1783
1784 ar.addCoords( 2, 2, -2, -2 );
1785 if ( widget->isEnabled() )
1786 flags |= Style_Enabled;
1787
1788 if ( subActive == SC_ComboBoxArrow ) {
1789 flags |= Style_Sunken;
1790 }
1791 drawPrimitive( PE_ArrowDown, p, ar, cg, flags );
1792 }
1793
1794 if ( sub & SC_ComboBoxEditField ) {
1795 const QComboBox * cb = (const QComboBox *) widget;
1796 QRect re =
1797 QStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget,
1798 SC_ComboBoxEditField ), widget );
1799 if ( cb->hasFocus() && !cb->editable() )
1800 p->fillRect( re.x(), re.y(), re.width(), re.height(),
1801 cg.brush( QColorGroup::Highlight ) );
1802
1803 if ( cb->hasFocus() ) {
1804 p->setPen( cg.highlightedText() );
1805 p->setBackgroundColor( cg.highlight() );
1806
1807 } else {
1808 p->setPen( cg.text() );
1809 p->setBackgroundColor( cg.background() );
1810 }
1811
1812 if ( cb->hasFocus() && !cb->editable() ) {
1813 QRect re =
1814 QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget );
1815 drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, QStyleOption(cg.highlight()));
1816 }
1817 }
1818
1819 break;
1820#endif // QT_NO_COMBOBOX
1821
1822#ifndef QT_NO_SLIDER
1823 case CC_Slider:
1824 {
1825 const QSlider *sl = (const QSlider *) widget;
1826 int thickness = pixelMetric( PM_SliderControlThickness, widget );
1827 int len = pixelMetric( PM_SliderLength, widget );
1828 int ticks = sl->tickmarks();
1829
1830 QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove,
1831 opt),
1832 handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle,
1833 opt);
1834
1835 if ((sub & SC_SliderGroove) && groove.isValid()) {
1836 int mid = thickness / 2;
1837
1838 if ( ticks & QSlider::Above )
1839 mid += len / 8;
1840 if ( ticks & QSlider::Below )
1841 mid -= len / 8;
1842
1843 p->setPen( cg.shadow() );
1844 if ( sl->orientation() == Horizontal ) {
1845 qDrawWinPanel( p, groove.x(), groove.y() + mid - 2,
1846 groove.width(), 4, cg, TRUE );
1847 p->drawLine( groove.x() + 1, groove.y() + mid - 1,
1848 groove.x() + groove.width() - 3, groove.y() + mid - 1 );
1849 } else {
1850 qDrawWinPanel( p, groove.x() + mid - 2, groove.y(),
1851 4, groove.height(), cg, TRUE );
1852 p->drawLine( groove.x() + mid - 1, groove.y() + 1,
1853 groove.x() + mid - 1,
1854 groove.y() + groove.height() - 3 );
1855 }
1856 }
1857
1858 if (sub & SC_SliderTickmarks)
1859 QCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags,
1860 SC_SliderTickmarks, subActive,
1861 opt );
1862
1863 if ( sub & SC_SliderHandle ) {
1864 // 4444440
1865 // 4333310
1866 // 4322210
1867 // 4322210
1868 // 4322210
1869 // 4322210
1870 // *43210*
1871 // **410**
1872 // ***0***
1873 const QColor c0 = cg.shadow();
1874 const QColor c1 = cg.dark();
1875 // const QColor c2 = g.button();
1876 const QColor c3 = cg.midlight();
1877 const QColor c4 = cg.light();
1878
1879 int x = handle.x(), y = handle.y(),
1880 wi = handle.width(), he = handle.height();
1881
1882 int x1 = x;
1883 int x2 = x+wi-1;
1884 int y1 = y;
1885 int y2 = y+he-1;
1886
1887 Orientation orient = sl->orientation();
1888 bool tickAbove = sl->tickmarks() == QSlider::Above;
1889 bool tickBelow = sl->tickmarks() == QSlider::Below;
1890
1891 p->fillRect( x, y, wi, he, cg.brush( QColorGroup::Background ) );
1892
1893 if ( flags & Style_HasFocus ) {
1894 QRect re = subRect( SR_SliderFocusRect, sl );
1895 drawPrimitive( PE_FocusRect, p, re, cg );
1896 }
1897
1898 if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) {
1899 qDrawWinButton( p, QRect(x,y,wi,he), cg, FALSE,
1900 &cg.brush( QColorGroup::Button ) );
1901 return;
1902 }
1903
1904 QSliderDirection dir;
1905
1906 if ( orient == Horizontal )
1907 if ( tickAbove )
1908 dir = SlUp;
1909 else
1910 dir = SlDown;
1911 else
1912 if ( tickAbove )
1913 dir = SlLeft;
1914 else
1915 dir = SlRight;
1916
1917 QPointArray a;
1918
1919 int d = 0;
1920 switch ( dir ) {
1921 case SlUp:
1922 y1 = y1 + wi/2;
1923 d = (wi + 1) / 2 - 1;
1924 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d );
1925 break;
1926 case SlDown:
1927 y2 = y2 - wi/2;
1928 d = (wi + 1) / 2 - 1;
1929 a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1 );
1930 break;
1931 case SlLeft:
1932 d = (he + 1) / 2 - 1;
1933 x1 = x1 + he/2;
1934 a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
1935 break;
1936 case SlRight:
1937 d = (he + 1) / 2 - 1;
1938 x2 = x2 - he/2;
1939 a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1 );
1940 break;
1941 }
1942
1943 QBrush oldBrush = p->brush();
1944 p->setBrush( cg.brush( QColorGroup::Button ) );
1945 p->setPen( NoPen );
1946 p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
1947 p->drawPolygon( a );
1948 p->setBrush( oldBrush );
1949
1950 if ( dir != SlUp ) {
1951 p->setPen( c4 );
1952 p->drawLine( x1, y1, x2, y1 );
1953 p->setPen( c3 );
1954 p->drawLine( x1, y1+1, x2, y1+1 );
1955 }
1956 if ( dir != SlLeft ) {
1957 p->setPen( c3 );
1958 p->drawLine( x1+1, y1+1, x1+1, y2 );
1959 p->setPen( c4 );
1960 p->drawLine( x1, y1, x1, y2 );
1961 }
1962 if ( dir != SlRight ) {
1963 p->setPen( c0 );
1964 p->drawLine( x2, y1, x2, y2 );
1965 p->setPen( c1 );
1966 p->drawLine( x2-1, y1+1, x2-1, y2-1 );
1967 }
1968 if ( dir != SlDown ) {
1969 p->setPen( c0 );
1970 p->drawLine( x1, y2, x2, y2 );
1971 p->setPen( c1 );
1972 p->drawLine( x1+1, y2-1, x2-1, y2-1 );
1973 }
1974
1975 switch ( dir ) {
1976 case SlUp:
1977 p->setPen( c4 );
1978 p->drawLine( x1, y1, x1+d, y1-d);
1979 p->setPen( c0 );
1980 d = wi - d - 1;
1981 p->drawLine( x2, y1, x2-d, y1-d);
1982 d--;
1983 p->setPen( c3 );
1984 p->drawLine( x1+1, y1, x1+1+d, y1-d );
1985 p->setPen( c1 );
1986 p->drawLine( x2-1, y1, x2-1-d, y1-d);
1987 break;
1988 case SlDown:
1989 p->setPen( c4 );
1990 p->drawLine( x1, y2, x1+d, y2+d);
1991 p->setPen( c0 );
1992 d = wi - d - 1;
1993 p->drawLine( x2, y2, x2-d, y2+d);
1994 d--;
1995 p->setPen( c3 );
1996 p->drawLine( x1+1, y2, x1+1+d, y2+d );
1997 p->setPen( c1 );
1998 p->drawLine( x2-1, y2, x2-1-d, y2+d);
1999 break;
2000 case SlLeft:
2001 p->setPen( c4 );
2002 p->drawLine( x1, y1, x1-d, y1+d);
2003 p->setPen( c0 );
2004 d = he - d - 1;
2005 p->drawLine( x1, y2, x1-d, y2-d);
2006 d--;
2007 p->setPen( c3 );
2008 p->drawLine( x1, y1+1, x1-d, y1+1+d );
2009 p->setPen( c1 );
2010 p->drawLine( x1, y2-1, x1-d, y2-1-d);
2011 break;
2012 case SlRight:
2013 p->setPen( c4 );
2014 p->drawLine( x2, y1, x2+d, y1+d);
2015 p->setPen( c0 );
2016 d = he - d - 1;
2017 p->drawLine( x2, y2, x2+d, y2-d);
2018 d--;
2019 p->setPen( c3 );
2020 p->drawLine( x2, y1+1, x2+d, y1+1+d );
2021 p->setPen( c1 );
2022 p->drawLine( x2, y2-1, x2+d, y2-1-d);
2023 break;
2024 }
2025 }
2026
2027 break;
2028 }
2029#endif // QT_NO_SLIDER
2030
2031 default:
2032 QCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub,
2033 subActive, opt );
2034 break;
2035 }
2036}
2037
2038
2039/*! \reimp */
2040int QWindowsStyle::styleHint( StyleHint hint,
2041 const QWidget *widget,
2042 const QStyleOption &opt,
2043 QStyleHintReturn *returnData ) const
2044{
2045 int ret;
2046
2047 switch (hint) {
2048 case SH_EtchDisabledText:
2049 case SH_Slider_SnapToValue:
2050 case SH_PrintDialog_RightAlignButtons:
2051 case SH_MainWindow_SpaceBelowMenuBar:
2052 case SH_FontDialog_SelectAssociatedText:
2053 case SH_PopupMenu_AllowActiveAndDisabled:
2054 case SH_MenuBar_AltKeyNavigation:
2055 case SH_MenuBar_MouseTracking:
2056 case SH_PopupMenu_MouseTracking:
2057 case SH_ComboBox_ListMouseTracking:
2058 case SH_ScrollBar_StopMouseOverSlider:
2059 ret = 1;
2060 break;
2061
2062 case SH_ItemView_ChangeHighlightOnFocus:
2063#if defined(Q_WS_WIN)
2064 if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT )
2065 ret = 1;
2066 else
2067#endif
2068 ret = 0;
2069 break;
2070
2071 case SH_ToolBox_SelectedPageTitleBold:
2072 ret = 0;
2073 break;
2074
2075#if defined(Q_WS_WIN)
2076 case SH_UnderlineAccelerator:
2077 ret = 1;
2078 if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT ) {
2079 BOOL cues;
2080 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
2081 ret = cues ? 1 : 0;
2082 // Do nothing if we always paint underlines
2083 if (!ret && widget && d) {
2084 QMenuBar *menuBar = ::qt_cast<QMenuBar*>(widget);
2085 QPopupMenu *popupMenu = 0;
2086 if (!menuBar)
2087 popupMenu = ::qt_cast<QPopupMenu*>(widget);
2088
2089 // If we paint a menubar draw underlines if it has focus, or if alt is down,
2090 // or if a popup menu belonging to the menubar is active and paints underlines
2091 if (menuBar) {
2092 if (menuBar->hasFocus()) {
2093 ret = 1;
2094 } else if (d->altDown()) {
2095 ret = 1;
2096 } else if (qApp->focusWidget() && qApp->focusWidget()->isPopup()) {
2097 popupMenu = ::qt_cast<QPopupMenu*>(qApp->focusWidget());
2098 QMenuData *pm = popupMenu ? (QMenuData*)popupMenu->qt_cast("QMenuData") : 0;
2099 if (pm && ((FriendlyMenuData*)pm)->parentMenu == menuBar) {
2100 if (d->hasSeenAlt(menuBar))
2101 ret = 1;
2102 }
2103 }
2104 // If we paint a popup menu draw underlines if the respective menubar does
2105 } else if (popupMenu) {
2106 QMenuData *pm = (QMenuData*)popupMenu->qt_cast("QMenuData");
2107 while (pm) {
2108 if (((FriendlyMenuData*)pm)->isMenuBar) {
2109 menuBar = (QMenuBar*)pm;
2110 if (d->hasSeenAlt(menuBar))
2111 ret = 1;
2112 break;
2113 }
2114 pm = ((FriendlyMenuData*)pm)->parentMenu;
2115 }
2116 // Otherwise draw underlines if the toplevel widget has seen an alt-press
2117 } else if (d->hasSeenAlt(widget)) {
2118 ret = 1;
2119 }
2120 }
2121
2122 }
2123 break;
2124#endif
2125
2126 default:
2127 ret = QCommonStyle::styleHint(hint, widget, opt, returnData);
2128 break;
2129 }
2130
2131 return ret;
2132}
2133
2134/*! \reimp */
2135QRect QWindowsStyle::subRect(SubRect r, const QWidget *widget) const
2136{
2137 QRect rect;
2138
2139 switch (r) {
2140#ifndef QT_NO_SLIDER
2141 case SR_SliderFocusRect:
2142 {
2143 rect = widget->rect();
2144 break;
2145 }
2146#endif // QT_NO_SLIDER
2147 case SR_ToolBoxTabContents:
2148 rect = widget->rect();
2149 break;
2150 default:
2151 rect = QCommonStyle::subRect( r, widget );
2152 break;
2153 }
2154
2155 return rect;
2156}
2157
2158#endif
Note: See TracBrowser for help on using the repository browser.