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

Last change on this file since 10 was 8, checked in by dmik, 20 years ago

Transferred Qt for OS/2 version 3.3.1-rc5 sources from the CVS

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