util/src/gui/styles/qwindowsstyle.cpp
changeset 7 f7bc934e204c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qwindowsstyle.h"
       
    43 #include "qwindowsstyle_p.h"
       
    44 #include <private/qstylehelper_p.h>
       
    45 
       
    46 #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
       
    47 
       
    48 #include "qlibrary.h"
       
    49 #include "qapplication.h"
       
    50 #include "qbitmap.h"
       
    51 #include "qdrawutil.h" // for now
       
    52 #include "qevent.h"
       
    53 #include "qmenu.h"
       
    54 #include "qmenubar.h"
       
    55 #include <private/qmenubar_p.h>
       
    56 #include "qpaintengine.h"
       
    57 #include "qpainter.h"
       
    58 #include "qprogressbar.h"
       
    59 #include "qrubberband.h"
       
    60 #include "qstyleoption.h"
       
    61 #include "qtabbar.h"
       
    62 #include "qwidget.h"
       
    63 #include "qdebug.h"
       
    64 #include "qmainwindow.h"
       
    65 #include "qfile.h"
       
    66 #include "qtextstream.h"
       
    67 #include "qpixmapcache.h"
       
    68 #include "qwizard.h"
       
    69 #include "qlistview.h"
       
    70 #include <private/qmath_p.h>
       
    71 #include <qmath.h>
       
    72 
       
    73 
       
    74 #ifdef Q_WS_X11
       
    75 #include "qfileinfo.h"
       
    76 #include "qdir.h"
       
    77 #include <private/qt_x11_p.h>
       
    78 #endif
       
    79 
       
    80 QT_BEGIN_NAMESPACE
       
    81 
       
    82 #if defined(Q_WS_WIN)
       
    83 
       
    84 QT_BEGIN_INCLUDE_NAMESPACE
       
    85 #include "qt_windows.h"
       
    86 QT_END_INCLUDE_NAMESPACE
       
    87 #  ifndef COLOR_GRADIENTACTIVECAPTION
       
    88 #    define COLOR_GRADIENTACTIVECAPTION     27
       
    89 #  endif
       
    90 #  ifndef COLOR_GRADIENTINACTIVECAPTION
       
    91 #    define COLOR_GRADIENTINACTIVECAPTION   28
       
    92 #  endif
       
    93 
       
    94 
       
    95 typedef struct
       
    96 {
       
    97     DWORD cbSize;
       
    98     HICON hIcon;
       
    99     int   iSysImageIndex;
       
   100     int   iIcon;
       
   101     WCHAR szPath[MAX_PATH];
       
   102 } QSHSTOCKICONINFO;
       
   103 
       
   104 #define _SHGFI_SMALLICON         0x000000001
       
   105 #define _SHGFI_LARGEICON         0x000000000
       
   106 #define _SHGFI_ICON              0x000000100
       
   107 #define _SIID_SHIELD             77
       
   108 
       
   109 typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
       
   110 static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
       
   111 
       
   112 #endif //Q_WS_WIN
       
   113 
       
   114 QT_BEGIN_INCLUDE_NAMESPACE
       
   115 #include <limits.h>
       
   116 QT_END_INCLUDE_NAMESPACE
       
   117 
       
   118 enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
       
   119 
       
   120 /*
       
   121     \internal
       
   122 */
       
   123 QWindowsStylePrivate::QWindowsStylePrivate()
       
   124     : alt_down(false), menuBarTimer(0), animationFps(10), animateTimer(0), animateStep(0)
       
   125 {
       
   126 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
       
   127     if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
       
   128         && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
       
   129         QLibrary shellLib(QLatin1String("shell32"));
       
   130         pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
       
   131     }
       
   132 #endif
       
   133 }
       
   134 
       
   135 // Returns true if the toplevel parent of \a widget has seen the Alt-key
       
   136 bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
       
   137 {
       
   138     widget = widget->window();
       
   139     return seenAlt.contains(widget);
       
   140 }
       
   141 
       
   142 /*!
       
   143     \reimp
       
   144 */
       
   145 void QWindowsStyle::timerEvent(QTimerEvent *event)
       
   146 {
       
   147 #ifndef QT_NO_PROGRESSBAR
       
   148     Q_D(QWindowsStyle);
       
   149     if (event->timerId() == d->animateTimer) {
       
   150         Q_ASSERT(d->animationFps> 0);
       
   151         d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
       
   152         foreach (QProgressBar *bar, d->bars) {
       
   153             if ((bar->minimum() == 0 && bar->maximum() == 0))
       
   154                 bar->update();
       
   155         }
       
   156     }
       
   157 #endif // QT_NO_PROGRESSBAR
       
   158     event->ignore();
       
   159 }
       
   160 
       
   161 /*!
       
   162     \reimp
       
   163 */
       
   164 bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
       
   165 {
       
   166     // Records Alt- and Focus events
       
   167     if (!o->isWidgetType())
       
   168         return QObject::eventFilter(o, e);
       
   169 
       
   170     QWidget *widget = qobject_cast<QWidget*>(o);
       
   171     Q_D(QWindowsStyle);
       
   172     switch(e->type()) {
       
   173     case QEvent::KeyPress:
       
   174         if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
       
   175             widget = widget->window();
       
   176 
       
   177             // Alt has been pressed - find all widgets that care
       
   178             QList<QWidget *> l = qFindChildren<QWidget *>(widget);
       
   179             for (int pos=0 ; pos < l.size() ; ++pos) {
       
   180                 QWidget *w = l.at(pos);
       
   181                 if (w->isWindow() || !w->isVisible() ||
       
   182                     w->style()->styleHint(SH_UnderlineShortcut, 0, w))
       
   183                     l.removeAt(pos);
       
   184             }
       
   185             // Update states before repainting
       
   186             d->seenAlt.append(widget);
       
   187             d->alt_down = true;
       
   188 
       
   189             // Repaint all relevant widgets
       
   190             for (int pos = 0; pos < l.size(); ++pos)
       
   191                 l.at(pos)->update();
       
   192         }
       
   193         break;
       
   194     case QEvent::KeyRelease:
       
   195         if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
       
   196             widget = widget->window();
       
   197 
       
   198             // Update state and repaint the menu bars.
       
   199             d->alt_down = false;
       
   200 #ifndef QT_NO_MENUBAR
       
   201             QList<QMenuBar *> l = qFindChildren<QMenuBar *>(widget);
       
   202             for (int i = 0; i < l.size(); ++i)
       
   203                 l.at(i)->update();
       
   204 #endif
       
   205         }
       
   206         break;
       
   207     case QEvent::Close:
       
   208         // Reset widget when closing
       
   209         d->seenAlt.removeAll(widget);
       
   210         d->seenAlt.removeAll(widget->window());
       
   211         break;
       
   212 #ifndef QT_NO_PROGRESSBAR
       
   213     case QEvent::StyleChange:
       
   214     case QEvent::Show:
       
   215         if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
       
   216             if (!d->bars.contains(bar)) {
       
   217                 d->bars << bar;
       
   218                 if (d->bars.size() == 1) {
       
   219                     Q_ASSERT(d->animationFps> 0);
       
   220                     d->animateTimer = startTimer(1000 / d->animationFps);
       
   221                 }
       
   222             }
       
   223         }
       
   224         break;
       
   225     case QEvent::Destroy:
       
   226     case QEvent::Hide:
       
   227         // reinterpret_cast because there is no type info when getting
       
   228         // the destroy event. We know that it is a QProgressBar.
       
   229         if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
       
   230             d->bars.removeAll(bar);
       
   231             if (d->bars.isEmpty() && d->animateTimer) {
       
   232                 killTimer(d->animateTimer);
       
   233                 d->animateTimer = 0;
       
   234             }
       
   235         }
       
   236         break;
       
   237 #endif // QT_NO_PROGRESSBAR
       
   238     default:
       
   239         break;
       
   240     }
       
   241     return QCommonStyle::eventFilter(o, e);
       
   242 }
       
   243 
       
   244 /*!
       
   245     \class QWindowsStyle
       
   246     \brief The QWindowsStyle class provides a Microsoft Windows-like look and feel.
       
   247 
       
   248     \ingroup appearance
       
   249 
       
   250     This style is Qt's default GUI style on Windows.
       
   251 
       
   252     \img qwindowsstyle.png
       
   253     \sa QWindowsXPStyle, QMacStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
       
   254 */
       
   255 
       
   256 /*!
       
   257     Constructs a QWindowsStyle object.
       
   258 */
       
   259 QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate)
       
   260 {
       
   261 }
       
   262 
       
   263 /*!
       
   264     \internal
       
   265 
       
   266     Constructs a QWindowsStyle object.
       
   267 */
       
   268 QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd)
       
   269 {
       
   270 }
       
   271 
       
   272 
       
   273 /*! Destroys the QWindowsStyle object. */
       
   274 QWindowsStyle::~QWindowsStyle()
       
   275 {
       
   276 }
       
   277 
       
   278 #ifdef Q_WS_WIN
       
   279 static inline QRgb colorref2qrgb(COLORREF col)
       
   280 {
       
   281     return qRgb(GetRValue(col), GetGValue(col), GetBValue(col));
       
   282 }
       
   283 #endif
       
   284 
       
   285 /*! \reimp */
       
   286 void QWindowsStyle::polish(QApplication *app)
       
   287 {
       
   288     QCommonStyle::polish(app);
       
   289     QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
       
   290     // We only need the overhead when shortcuts are sometimes hidden
       
   291     if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
       
   292         app->installEventFilter(this);
       
   293 
       
   294     d->activeCaptionColor = app->palette().highlight().color();
       
   295     d->activeGradientCaptionColor = app->palette().highlight() .color();
       
   296     d->inactiveCaptionColor = app->palette().dark().color();
       
   297     d->inactiveGradientCaptionColor = app->palette().dark().color();
       
   298     d->inactiveCaptionText = app->palette().background().color();
       
   299 
       
   300 #if defined(Q_WS_WIN) //fetch native title bar colors
       
   301     if(app->desktopSettingsAware()){
       
   302         DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
       
   303         DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
       
   304         DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
       
   305         DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
       
   306         DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
       
   307         d->activeCaptionColor = colorref2qrgb(activeCaption);
       
   308         d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
       
   309         d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
       
   310         d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
       
   311         d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
       
   312     }
       
   313 #endif
       
   314 }
       
   315 
       
   316 /*! \reimp */
       
   317 void QWindowsStyle::unpolish(QApplication *app)
       
   318 {
       
   319     QCommonStyle::unpolish(app);
       
   320     app->removeEventFilter(this);
       
   321 }
       
   322 
       
   323 /*! \reimp */
       
   324 void QWindowsStyle::polish(QWidget *widget)
       
   325 {
       
   326     QCommonStyle::polish(widget);
       
   327 #ifndef QT_NO_PROGRESSBAR
       
   328     if (qobject_cast<QProgressBar *>(widget))
       
   329         widget->installEventFilter(this);
       
   330 #endif
       
   331 }
       
   332 
       
   333 /*! \reimp */
       
   334 void QWindowsStyle::unpolish(QWidget *widget)
       
   335 {
       
   336     QCommonStyle::unpolish(widget);
       
   337 #ifndef QT_NO_PROGRESSBAR
       
   338     if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
       
   339         Q_D(QWindowsStyle);
       
   340         widget->removeEventFilter(this);
       
   341         d->bars.removeAll(bar);
       
   342     }
       
   343 #endif
       
   344 }
       
   345 
       
   346 /*!
       
   347   \reimp
       
   348 */
       
   349 void QWindowsStyle::polish(QPalette &pal)
       
   350 {
       
   351     QCommonStyle::polish(pal);
       
   352 }
       
   353 
       
   354 /*!
       
   355   \reimp
       
   356 */
       
   357 int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const
       
   358 {
       
   359     int ret;
       
   360 
       
   361     switch (pm) {
       
   362     case PM_ButtonDefaultIndicator:
       
   363     case PM_ButtonShiftHorizontal:
       
   364     case PM_ButtonShiftVertical:
       
   365     case PM_MenuHMargin:
       
   366     case PM_MenuVMargin:
       
   367         ret = 1;
       
   368         break;
       
   369 #ifndef QT_NO_TABBAR
       
   370     case PM_TabBarTabShiftHorizontal:
       
   371         ret = 0;
       
   372         break;
       
   373     case PM_TabBarTabShiftVertical:
       
   374         ret = 2;
       
   375         break;
       
   376 #endif
       
   377     case PM_MaximumDragDistance:
       
   378 #if defined(Q_WS_WIN)
       
   379         {
       
   380             HDC hdcScreen = GetDC(0);
       
   381             int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
       
   382             ReleaseDC(0, hdcScreen);
       
   383             ret = (int)(dpi * 1.375);
       
   384         }
       
   385 #else
       
   386         ret = 60;
       
   387 #endif
       
   388         break;
       
   389 
       
   390 #ifndef QT_NO_SLIDER
       
   391     case PM_SliderLength:
       
   392         ret = int(QStyleHelper::dpiScaled(11.));
       
   393         break;
       
   394 
       
   395         // Returns the number of pixels to use for the business part of the
       
   396         // slider (i.e., the non-tickmark portion). The remaining space is shared
       
   397         // equally between the tickmark regions.
       
   398     case PM_SliderControlThickness:
       
   399         if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
       
   400             int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
       
   401             int ticks = sl->tickPosition;
       
   402             int n = 0;
       
   403             if (ticks & QSlider::TicksAbove)
       
   404                 ++n;
       
   405             if (ticks & QSlider::TicksBelow)
       
   406                 ++n;
       
   407             if (!n) {
       
   408                 ret = space;
       
   409                 break;
       
   410             }
       
   411 
       
   412             int thick = 6;        // Magic constant to get 5 + 16 + 5
       
   413             if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
       
   414                 thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
       
   415 
       
   416             space -= thick;
       
   417             if (space > 0)
       
   418                 thick += (space * 2) / (n + 2);
       
   419             ret = thick;
       
   420         } else {
       
   421             ret = 0;
       
   422         }
       
   423         break;
       
   424 #endif // QT_NO_SLIDER
       
   425 
       
   426 #ifndef QT_NO_MENU
       
   427     case PM_MenuBarHMargin:
       
   428         ret = 0;
       
   429         break;
       
   430 
       
   431     case PM_MenuBarVMargin:
       
   432         ret = 0;
       
   433         break;
       
   434 
       
   435     case PM_MenuBarPanelWidth:
       
   436         ret = 0;
       
   437         break;
       
   438 
       
   439     case PM_SmallIconSize:
       
   440         ret = int(QStyleHelper::dpiScaled(16.));
       
   441         break;
       
   442 
       
   443     case PM_LargeIconSize:
       
   444         ret = int(QStyleHelper::dpiScaled(32.));
       
   445         break;
       
   446 
       
   447     case PM_IconViewIconSize:
       
   448         ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
       
   449         break;
       
   450 
       
   451     case PM_DockWidgetTitleMargin:
       
   452         ret = int(QStyleHelper::dpiScaled(2.));
       
   453         break;
       
   454     case PM_DockWidgetTitleBarButtonMargin:
       
   455         ret = int(QStyleHelper::dpiScaled(4.));
       
   456         break;
       
   457 #if defined(Q_WS_WIN)
       
   458     case PM_DockWidgetFrameWidth:
       
   459 #if defined(Q_OS_WINCE)
       
   460         ret = GetSystemMetrics(SM_CXDLGFRAME);
       
   461 #else
       
   462         ret = GetSystemMetrics(SM_CXFRAME);
       
   463 #endif
       
   464         break;
       
   465 #else
       
   466     case PM_DockWidgetFrameWidth:
       
   467         ret = 4;
       
   468         break;
       
   469 #endif // Q_WS_WIN
       
   470     break;
       
   471 
       
   472 #endif // QT_NO_MENU
       
   473 
       
   474 
       
   475 #if defined(Q_WS_WIN)
       
   476     case PM_TitleBarHeight:
       
   477 #ifdef QT3_SUPPORT
       
   478         // qt3 dockwindow height should be equal to tool windows
       
   479         if (widget && widget->inherits("Q3DockWindowTitleBar")) {
       
   480             ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
       
   481         } else
       
   482 #endif
       
   483         if (widget && (widget->windowType() == Qt::Tool)) {
       
   484             // MS always use one less than they say
       
   485 #if defined(Q_OS_WINCE)
       
   486             ret = GetSystemMetrics(SM_CYCAPTION) - 1;
       
   487 #else
       
   488             ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
       
   489 #endif
       
   490         } else {
       
   491             ret = GetSystemMetrics(SM_CYCAPTION) - 1;
       
   492         }
       
   493 
       
   494         break;
       
   495 
       
   496     case PM_ScrollBarExtent:
       
   497         {
       
   498 #ifndef Q_OS_WINCE
       
   499             NONCLIENTMETRICS ncm;
       
   500             ncm.cbSize = sizeof(NONCLIENTMETRICS);
       
   501             if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
       
   502                 ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
       
   503             else
       
   504 #endif
       
   505                 ret = QCommonStyle::pixelMetric(pm, opt, widget);
       
   506         }
       
   507         break;
       
   508 #endif // Q_WS_WIN
       
   509 
       
   510     case PM_SplitterWidth:
       
   511         ret = qMax(4, QApplication::globalStrut().width());
       
   512         break;
       
   513 
       
   514 #if defined(Q_WS_WIN)
       
   515     case PM_MdiSubWindowFrameWidth:
       
   516 #if defined(Q_OS_WINCE)
       
   517         ret = GetSystemMetrics(SM_CYDLGFRAME);
       
   518 #else
       
   519         ret = GetSystemMetrics(SM_CYFRAME);
       
   520 #endif
       
   521         break;
       
   522     case PM_TextCursorWidth: {
       
   523         DWORD caretWidth = 1;
       
   524 #if defined(SPI_GETCARETWIDTH)
       
   525         SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0);
       
   526 #endif
       
   527         ret = (int)caretWidth;
       
   528         break; }
       
   529 #endif
       
   530     case PM_ToolBarItemMargin:
       
   531         ret = 1;
       
   532         break;
       
   533     case PM_ToolBarItemSpacing:
       
   534         ret = 0;
       
   535         break;
       
   536     case PM_ToolBarHandleExtent:
       
   537         ret = int(QStyleHelper::dpiScaled(10.));
       
   538         break;
       
   539     default:
       
   540         ret = QCommonStyle::pixelMetric(pm, opt, widget);
       
   541         break;
       
   542     }
       
   543 
       
   544     return ret;
       
   545 }
       
   546 
       
   547 #ifndef QT_NO_IMAGEFORMAT_XPM
       
   548 
       
   549 /* XPM */
       
   550 static const char * const qt_menu_xpm[] = {
       
   551 "16 16 72 1",
       
   552 "  c None",
       
   553 ". c #65AF36",
       
   554 "+ c #66B036",
       
   555 "@ c #77B94C",
       
   556 "# c #A7D28C",
       
   557 "$ c #BADBA4",
       
   558 "% c #A4D088",
       
   559 "& c #72B646",
       
   560 "* c #9ACB7A",
       
   561 "= c #7FBD56",
       
   562 "- c #85C05F",
       
   563 "; c #F4F9F0",
       
   564 "> c #FFFFFF",
       
   565 ", c #E5F1DC",
       
   566 "' c #ECF5E7",
       
   567 ") c #7ABA50",
       
   568 "! c #83BF5C",
       
   569 "~ c #AED595",
       
   570 "{ c #D7EACA",
       
   571 "] c #A9D28D",
       
   572 "^ c #BCDDA8",
       
   573 "/ c #C4E0B1",
       
   574 "( c #81BE59",
       
   575 "_ c #D0E7C2",
       
   576 ": c #D4E9C6",
       
   577 "< c #6FB542",
       
   578 "[ c #6EB440",
       
   579 "} c #88C162",
       
   580 "| c #98CA78",
       
   581 "1 c #F4F9F1",
       
   582 "2 c #8FC56C",
       
   583 "3 c #F1F8EC",
       
   584 "4 c #E8F3E1",
       
   585 "5 c #D4E9C7",
       
   586 "6 c #74B748",
       
   587 "7 c #80BE59",
       
   588 "8 c #73B747",
       
   589 "9 c #6DB43F",
       
   590 "0 c #CBE4BA",
       
   591 "a c #80BD58",
       
   592 "b c #6DB33F",
       
   593 "c c #FEFFFE",
       
   594 "d c #68B138",
       
   595 "e c #F9FCF7",
       
   596 "f c #91C66F",
       
   597 "g c #E8F3E0",
       
   598 "h c #DCEDD0",
       
   599 "i c #91C66E",
       
   600 "j c #A3CF86",
       
   601 "k c #C9E3B8",
       
   602 "l c #B0D697",
       
   603 "m c #E3F0DA",
       
   604 "n c #95C873",
       
   605 "o c #E6F2DE",
       
   606 "p c #9ECD80",
       
   607 "q c #BEDEAA",
       
   608 "r c #C7E2B6",
       
   609 "s c #79BA4F",
       
   610 "t c #6EB441",
       
   611 "u c #BCDCA7",
       
   612 "v c #FAFCF8",
       
   613 "w c #F6FAF3",
       
   614 "x c #84BF5D",
       
   615 "y c #EDF6E7",
       
   616 "z c #FAFDF9",
       
   617 "A c #88C263",
       
   618 "B c #98CA77",
       
   619 "C c #CDE5BE",
       
   620 "D c #67B037",
       
   621 "E c #D9EBCD",
       
   622 "F c #6AB23C",
       
   623 "G c #77B94D",
       
   624 " .++++++++++++++",
       
   625 ".+++++++++++++++",
       
   626 "+++@#$%&+++*=+++",
       
   627 "++-;>,>')+!>~+++",
       
   628 "++{>]+^>/(_>:~<+",
       
   629 "+[>>}+|>123>456+",
       
   630 "+7>>8+->>90>~+++",
       
   631 "+a>>b+a>c[0>~+++",
       
   632 "+de>=+f>g+0>~+++",
       
   633 "++h>i+j>k+0>~+++",
       
   634 "++l>mno>p+q>rst+",
       
   635 "++duv>wl++xy>zA+",
       
   636 "++++B>Cb++++&D++",
       
   637 "+++++0zE++++++++",
       
   638 "++++++FG+++++++.",
       
   639 "++++++++++++++. "};
       
   640 
       
   641 static const char * const qt_close_xpm[] = {
       
   642 "10 10 2 1",
       
   643 "# c #000000",
       
   644 ". c None",
       
   645 "..........",
       
   646 ".##....##.",
       
   647 "..##..##..",
       
   648 "...####...",
       
   649 "....##....",
       
   650 "...####...",
       
   651 "..##..##..",
       
   652 ".##....##.",
       
   653 "..........",
       
   654 ".........."};
       
   655 
       
   656 static const char * const qt_maximize_xpm[]={
       
   657 "10 10 2 1",
       
   658 "# c #000000",
       
   659 ". c None",
       
   660 "#########.",
       
   661 "#########.",
       
   662 "#.......#.",
       
   663 "#.......#.",
       
   664 "#.......#.",
       
   665 "#.......#.",
       
   666 "#.......#.",
       
   667 "#.......#.",
       
   668 "#########.",
       
   669 ".........."};
       
   670 
       
   671 static const char * const qt_minimize_xpm[] = {
       
   672 "10 10 2 1",
       
   673 "# c #000000",
       
   674 ". c None",
       
   675 "..........",
       
   676 "..........",
       
   677 "..........",
       
   678 "..........",
       
   679 "..........",
       
   680 "..........",
       
   681 "..........",
       
   682 ".#######..",
       
   683 ".#######..",
       
   684 ".........."};
       
   685 
       
   686 static const char * const qt_normalizeup_xpm[] = {
       
   687 "10 10 2 1",
       
   688 "# c #000000",
       
   689 ". c None",
       
   690 "...######.",
       
   691 "...######.",
       
   692 "...#....#.",
       
   693 ".######.#.",
       
   694 ".######.#.",
       
   695 ".#....###.",
       
   696 ".#....#...",
       
   697 ".#....#...",
       
   698 ".######...",
       
   699 ".........."};
       
   700 
       
   701 static const char * const qt_help_xpm[] = {
       
   702 "10 10 2 1",
       
   703 ". c None",
       
   704 "# c #000000",
       
   705 "..........",
       
   706 "..######..",
       
   707 ".##....##.",
       
   708 "......##..",
       
   709 ".....##...",
       
   710 "....##....",
       
   711 "....##....",
       
   712 "..........",
       
   713 "....##....",
       
   714 ".........."};
       
   715 
       
   716 static const char * const qt_shade_xpm[] = {
       
   717 "10 10 2 1",
       
   718 "# c #000000",
       
   719 ". c None",
       
   720 "..........",
       
   721 "..........",
       
   722 "..........",
       
   723 "..........",
       
   724 "....#.....",
       
   725 "...###....",
       
   726 "..#####...",
       
   727 ".#######..",
       
   728 "..........",
       
   729 ".........."};
       
   730 
       
   731 static const char * const qt_unshade_xpm[] = {
       
   732 "10 10 2 1",
       
   733 "# c #000000",
       
   734 ". c None",
       
   735 "..........",
       
   736 "..........",
       
   737 "..........",
       
   738 ".#######..",
       
   739 "..#####...",
       
   740 "...###....",
       
   741 "....#.....",
       
   742 "..........",
       
   743 "..........",
       
   744 ".........."};
       
   745 
       
   746 static const char * dock_widget_close_xpm[] = {
       
   747 "8 8 2 1",
       
   748 "# c #000000",
       
   749 ". c None",
       
   750 "........",
       
   751 ".##..##.",
       
   752 "..####..",
       
   753 "...##...",
       
   754 "..####..",
       
   755 ".##..##.",
       
   756 "........",
       
   757 "........"};
       
   758 
       
   759 /* XPM */
       
   760 static const char * const information_xpm[]={
       
   761 "32 32 5 1",
       
   762 ". c None",
       
   763 "c c #000000",
       
   764 "* c #999999",
       
   765 "a c #ffffff",
       
   766 "b c #0000ff",
       
   767 "...........********.............",
       
   768 "........***aaaaaaaa***..........",
       
   769 "......**aaaaaaaaaaaaaa**........",
       
   770 ".....*aaaaaaaaaaaaaaaaaa*.......",
       
   771 "....*aaaaaaaabbbbaaaaaaaac......",
       
   772 "...*aaaaaaaabbbbbbaaaaaaaac.....",
       
   773 "..*aaaaaaaaabbbbbbaaaaaaaaac....",
       
   774 ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
       
   775 ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
       
   776 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
       
   777 "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
       
   778 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
       
   779 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
       
   780 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
       
   781 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
       
   782 "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
       
   783 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
       
   784 ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
       
   785 "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
       
   786 "...caaaaaaabbbbbbbbbaaaaaac****.",
       
   787 "....caaaaaaaaaaaaaaaaaaaac****..",
       
   788 ".....caaaaaaaaaaaaaaaaaac****...",
       
   789 "......ccaaaaaaaaaaaaaacc****....",
       
   790 ".......*cccaaaaaaaaccc*****.....",
       
   791 "........***cccaaaac*******......",
       
   792 "..........****caaac*****........",
       
   793 ".............*caaac**...........",
       
   794 "...............caac**...........",
       
   795 "................cac**...........",
       
   796 ".................cc**...........",
       
   797 "..................***...........",
       
   798 "...................**..........."};
       
   799 /* XPM */
       
   800 static const char* const warning_xpm[]={
       
   801 "32 32 4 1",
       
   802 ". c None",
       
   803 "a c #ffff00",
       
   804 "* c #000000",
       
   805 "b c #999999",
       
   806 ".............***................",
       
   807 "............*aaa*...............",
       
   808 "...........*aaaaa*b.............",
       
   809 "...........*aaaaa*bb............",
       
   810 "..........*aaaaaaa*bb...........",
       
   811 "..........*aaaaaaa*bb...........",
       
   812 ".........*aaaaaaaaa*bb..........",
       
   813 ".........*aaaaaaaaa*bb..........",
       
   814 "........*aaaaaaaaaaa*bb.........",
       
   815 "........*aaaa***aaaa*bb.........",
       
   816 ".......*aaaa*****aaaa*bb........",
       
   817 ".......*aaaa*****aaaa*bb........",
       
   818 "......*aaaaa*****aaaaa*bb.......",
       
   819 "......*aaaaa*****aaaaa*bb.......",
       
   820 ".....*aaaaaa*****aaaaaa*bb......",
       
   821 ".....*aaaaaa*****aaaaaa*bb......",
       
   822 "....*aaaaaaaa***aaaaaaaa*bb.....",
       
   823 "....*aaaaaaaa***aaaaaaaa*bb.....",
       
   824 "...*aaaaaaaaa***aaaaaaaaa*bb....",
       
   825 "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
       
   826 "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
       
   827 "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
       
   828 ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
       
   829 ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
       
   830 "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
       
   831 "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
       
   832 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
       
   833 "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
       
   834 ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
       
   835 "..*************************bbbbb",
       
   836 "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
       
   837 ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
       
   838 /* XPM */
       
   839 static const char* const critical_xpm[]={
       
   840 "32 32 4 1",
       
   841 ". c None",
       
   842 "a c #999999",
       
   843 "* c #ff0000",
       
   844 "b c #ffffff",
       
   845 "...........********.............",
       
   846 ".........************...........",
       
   847 ".......****************.........",
       
   848 "......******************........",
       
   849 ".....********************a......",
       
   850 "....**********************a.....",
       
   851 "...************************a....",
       
   852 "..*******b**********b*******a...",
       
   853 "..******bbb********bbb******a...",
       
   854 ".******bbbbb******bbbbb******a..",
       
   855 ".*******bbbbb****bbbbb*******a..",
       
   856 "*********bbbbb**bbbbb*********a.",
       
   857 "**********bbbbbbbbbb**********a.",
       
   858 "***********bbbbbbbb***********aa",
       
   859 "************bbbbbb************aa",
       
   860 "************bbbbbb************aa",
       
   861 "***********bbbbbbbb***********aa",
       
   862 "**********bbbbbbbbbb**********aa",
       
   863 "*********bbbbb**bbbbb*********aa",
       
   864 ".*******bbbbb****bbbbb*******aa.",
       
   865 ".******bbbbb******bbbbb******aa.",
       
   866 "..******bbb********bbb******aaa.",
       
   867 "..*******b**********b*******aa..",
       
   868 "...************************aaa..",
       
   869 "....**********************aaa...",
       
   870 "....a********************aaa....",
       
   871 ".....a******************aaa.....",
       
   872 "......a****************aaa......",
       
   873 ".......aa************aaaa.......",
       
   874 ".........aa********aaaaa........",
       
   875 "...........aaaaaaaaaaa..........",
       
   876 ".............aaaaaaa............"};
       
   877 /* XPM */
       
   878 static const char *const question_xpm[] = {
       
   879 "32 32 5 1",
       
   880 ". c None",
       
   881 "c c #000000",
       
   882 "* c #999999",
       
   883 "a c #ffffff",
       
   884 "b c #0000ff",
       
   885 "...........********.............",
       
   886 "........***aaaaaaaa***..........",
       
   887 "......**aaaaaaaaaaaaaa**........",
       
   888 ".....*aaaaaaaaaaaaaaaaaa*.......",
       
   889 "....*aaaaaaaaaaaaaaaaaaaac......",
       
   890 "...*aaaaaaaabbbbbbaaaaaaaac.....",
       
   891 "..*aaaaaaaabaaabbbbaaaaaaaac....",
       
   892 ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
       
   893 ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
       
   894 "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
       
   895 "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
       
   896 "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
       
   897 "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
       
   898 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
       
   899 "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
       
   900 "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
       
   901 ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
       
   902 ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
       
   903 "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
       
   904 "...caaaaaaaaaabbaaaaaaaaaac****.",
       
   905 "....caaaaaaaaaaaaaaaaaaaac****..",
       
   906 ".....caaaaaaaaaaaaaaaaaac****...",
       
   907 "......ccaaaaaaaaaaaaaacc****....",
       
   908 ".......*cccaaaaaaaaccc*****.....",
       
   909 "........***cccaaaac*******......",
       
   910 "..........****caaac*****........",
       
   911 ".............*caaac**...........",
       
   912 "...............caac**...........",
       
   913 "................cac**...........",
       
   914 ".................cc**...........",
       
   915 "..................***...........",
       
   916 "...................**..........."};
       
   917 
       
   918 #endif //QT_NO_IMAGEFORMAT_XPM
       
   919 
       
   920 #ifdef Q_OS_WIN
       
   921 static QPixmap loadIconFromShell32( int resourceId, int size )
       
   922 {
       
   923 #ifdef Q_OS_WINCE
       
   924     HMODULE hmod = LoadLibrary(L"ceshell.dll");
       
   925 #else
       
   926     HMODULE hmod = LoadLibrary(L"shell32.dll");
       
   927 #endif
       
   928     if( hmod ) {
       
   929         HICON iconHandle = (HICON)LoadImage(hmod, MAKEINTRESOURCE(resourceId), IMAGE_ICON, size, size, 0);
       
   930         if( iconHandle ) {
       
   931             QPixmap iconpixmap = QPixmap::fromWinHICON( iconHandle );
       
   932             DestroyIcon(iconHandle);
       
   933             return iconpixmap;
       
   934         }
       
   935     }
       
   936     return QPixmap();
       
   937 }
       
   938 #endif
       
   939 
       
   940 /*!
       
   941  \reimp
       
   942  */
       
   943 QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
       
   944                                       const QWidget *widget) const
       
   945 {
       
   946 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
       
   947     QPixmap desktopIcon;
       
   948     switch(standardPixmap) {
       
   949     case SP_DriveCDIcon:
       
   950     case SP_DriveDVDIcon:
       
   951         {
       
   952             desktopIcon = loadIconFromShell32(12, 16);
       
   953             break;
       
   954         }
       
   955     case SP_DriveNetIcon:
       
   956         {
       
   957             desktopIcon = loadIconFromShell32(10, 16);
       
   958             break;
       
   959         }
       
   960     case SP_DriveHDIcon:
       
   961         {
       
   962             desktopIcon = loadIconFromShell32(9, 16);
       
   963             break;
       
   964         }
       
   965     case SP_DriveFDIcon:
       
   966         {
       
   967             desktopIcon = loadIconFromShell32(7, 16);
       
   968             break;
       
   969         }
       
   970     case SP_FileIcon:
       
   971         {
       
   972             desktopIcon = loadIconFromShell32(1, 16);
       
   973             break;
       
   974         }
       
   975     case SP_FileLinkIcon:
       
   976         {
       
   977             desktopIcon = loadIconFromShell32(1, 16);
       
   978             QPainter painter(&desktopIcon);
       
   979             QPixmap link = loadIconFromShell32(30, 16);
       
   980             painter.drawPixmap(0, 0, 16, 16, link);
       
   981             break;
       
   982         }
       
   983     case SP_DirLinkIcon:
       
   984         {
       
   985             desktopIcon = loadIconFromShell32(4, 16);
       
   986             QPainter painter(&desktopIcon);
       
   987             QPixmap link = loadIconFromShell32(30, 16);
       
   988             painter.drawPixmap(0, 0, 16, 16, link);
       
   989             break;
       
   990         }
       
   991     case SP_DirClosedIcon:
       
   992         {
       
   993             desktopIcon = loadIconFromShell32(4, 16);
       
   994             break;
       
   995         }
       
   996     case SP_DesktopIcon:
       
   997         {
       
   998             desktopIcon = loadIconFromShell32(35, 16);
       
   999             break;
       
  1000         }
       
  1001     case SP_ComputerIcon:
       
  1002         {
       
  1003             desktopIcon = loadIconFromShell32(16, 16);
       
  1004             break;
       
  1005         }
       
  1006     case SP_DirOpenIcon:
       
  1007         {
       
  1008             desktopIcon = loadIconFromShell32(5, 16);
       
  1009             break;
       
  1010         }
       
  1011     case SP_FileDialogNewFolder:
       
  1012         {
       
  1013             desktopIcon = loadIconFromShell32(319, 16);
       
  1014             break;
       
  1015         }
       
  1016     case SP_DirHomeIcon:
       
  1017         {
       
  1018             desktopIcon = loadIconFromShell32(235, 16);
       
  1019             break;
       
  1020         }
       
  1021     case SP_TrashIcon:
       
  1022         {
       
  1023             desktopIcon = loadIconFromShell32(191, 16);
       
  1024             break;
       
  1025         }
       
  1026     case SP_MessageBoxInformation:
       
  1027         {
       
  1028             HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
       
  1029             desktopIcon = QPixmap::fromWinHICON( iconHandle );
       
  1030             DestroyIcon(iconHandle);
       
  1031             break;
       
  1032         }
       
  1033     case SP_MessageBoxWarning:
       
  1034         {
       
  1035             HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
       
  1036             desktopIcon = QPixmap::fromWinHICON( iconHandle );
       
  1037             DestroyIcon(iconHandle);
       
  1038             break;
       
  1039         }
       
  1040     case SP_MessageBoxCritical:
       
  1041         {
       
  1042             HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
       
  1043             desktopIcon = QPixmap::fromWinHICON( iconHandle );
       
  1044             DestroyIcon(iconHandle);
       
  1045             break;
       
  1046         }
       
  1047     case SP_MessageBoxQuestion:
       
  1048         {
       
  1049             HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
       
  1050             desktopIcon = QPixmap::fromWinHICON( iconHandle );
       
  1051             DestroyIcon(iconHandle);
       
  1052             break;
       
  1053         }
       
  1054     case SP_VistaShield:
       
  1055         {
       
  1056             if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
       
  1057                 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
       
  1058                 && pSHGetStockIconInfo)
       
  1059             {
       
  1060                 QPixmap pixmap;
       
  1061                 QSHSTOCKICONINFO iconInfo;
       
  1062                 memset(&iconInfo, 0, sizeof(iconInfo));
       
  1063                 iconInfo.cbSize = sizeof(iconInfo);
       
  1064                 if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
       
  1065                     pixmap = QPixmap::fromWinHICON(iconInfo.hIcon);
       
  1066                     DestroyIcon(iconInfo.hIcon);
       
  1067                     return pixmap;
       
  1068                 }
       
  1069             }
       
  1070         }
       
  1071         break;
       
  1072     default:
       
  1073         break;
       
  1074     }
       
  1075     if (!desktopIcon.isNull()) {
       
  1076         return desktopIcon;
       
  1077     }
       
  1078 #endif
       
  1079 #ifndef QT_NO_IMAGEFORMAT_XPM
       
  1080     switch (standardPixmap) {
       
  1081     case SP_TitleBarMenuButton:
       
  1082         return QPixmap(qt_menu_xpm);
       
  1083     case SP_TitleBarShadeButton:
       
  1084         return QPixmap(qt_shade_xpm);
       
  1085     case SP_TitleBarUnshadeButton:
       
  1086         return QPixmap(qt_unshade_xpm);
       
  1087     case SP_TitleBarNormalButton:
       
  1088         return QPixmap(qt_normalizeup_xpm);
       
  1089     case SP_TitleBarMinButton:
       
  1090         return QPixmap(qt_minimize_xpm);
       
  1091     case SP_TitleBarMaxButton:
       
  1092         return QPixmap(qt_maximize_xpm);
       
  1093     case SP_TitleBarCloseButton:
       
  1094         return QPixmap(qt_close_xpm);
       
  1095     case SP_TitleBarContextHelpButton:
       
  1096         return QPixmap(qt_help_xpm);
       
  1097     case SP_DockWidgetCloseButton:
       
  1098         return QPixmap(dock_widget_close_xpm);
       
  1099     case SP_MessageBoxInformation:
       
  1100         return QPixmap(information_xpm);
       
  1101     case SP_MessageBoxWarning:
       
  1102         return QPixmap(warning_xpm);
       
  1103     case SP_MessageBoxCritical:
       
  1104         return QPixmap(critical_xpm);
       
  1105     case SP_MessageBoxQuestion:
       
  1106         return QPixmap(question_xpm);
       
  1107     default:
       
  1108         break;
       
  1109     }
       
  1110 #endif //QT_NO_IMAGEFORMAT_XPM
       
  1111     return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
       
  1112 }
       
  1113 
       
  1114 /*! \reimp */
       
  1115 int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
       
  1116                              QStyleHintReturn *returnData) const
       
  1117 {
       
  1118     int ret = 0;
       
  1119 
       
  1120     switch (hint) {
       
  1121     case SH_EtchDisabledText:
       
  1122     case SH_Slider_SnapToValue:
       
  1123     case SH_PrintDialog_RightAlignButtons:
       
  1124     case SH_FontDialog_SelectAssociatedText:
       
  1125     case SH_Menu_AllowActiveAndDisabled:
       
  1126     case SH_MenuBar_AltKeyNavigation:
       
  1127     case SH_MenuBar_MouseTracking:
       
  1128     case SH_Menu_MouseTracking:
       
  1129     case SH_ComboBox_ListMouseTracking:
       
  1130     case SH_ScrollBar_StopMouseOverSlider:
       
  1131     case SH_MainWindow_SpaceBelowMenuBar:
       
  1132         ret = 1;
       
  1133 
       
  1134         break;
       
  1135     case SH_ItemView_ShowDecorationSelected:
       
  1136 #ifndef QT_NO_LISTVIEW
       
  1137         if (qobject_cast<const QListView*>(widget))
       
  1138             ret = 1;
       
  1139 #endif
       
  1140         break;
       
  1141     case SH_ItemView_ChangeHighlightOnFocus:
       
  1142         ret = 1;
       
  1143         break;
       
  1144     case SH_ToolBox_SelectedPageTitleBold:
       
  1145         ret = 0;
       
  1146         break;
       
  1147 
       
  1148 #if defined(Q_WS_WIN)
       
  1149     case SH_UnderlineShortcut:
       
  1150     {
       
  1151         ret = 1;
       
  1152         BOOL cues = false;
       
  1153         SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
       
  1154         ret = int(cues);
       
  1155         // Do nothing if we always paint underlines
       
  1156         Q_D(const QWindowsStyle);
       
  1157         if (!ret && widget && d) {
       
  1158 #ifndef QT_NO_MENUBAR
       
  1159             const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
       
  1160             if (!menuBar && qobject_cast<const QMenu *>(widget)) {
       
  1161                 QWidget *w = QApplication::activeWindow();
       
  1162                 if (w && w != widget)
       
  1163                     menuBar = qFindChild<QMenuBar *>(w);
       
  1164             }
       
  1165             // If we paint a menu bar draw underlines if is in the keyboardState
       
  1166             if (menuBar) {
       
  1167                 if (menuBar->d_func()->keyboardState || d->altDown())
       
  1168                     ret = 1;
       
  1169                 // Otherwise draw underlines if the toplevel widget has seen an alt-press
       
  1170             } else
       
  1171 #endif // QT_NO_MENUBAR
       
  1172             if (d->hasSeenAlt(widget)) {
       
  1173                 ret = 1;
       
  1174             }
       
  1175         }
       
  1176         break;
       
  1177     }
       
  1178 #endif
       
  1179 #ifndef QT_NO_RUBBERBAND
       
  1180     case SH_RubberBand_Mask:
       
  1181         if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
       
  1182             ret = 0;
       
  1183             if (rbOpt->shape == QRubberBand::Rectangle) {
       
  1184                 ret = true;
       
  1185                 if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
       
  1186                     mask->region = opt->rect;
       
  1187                     int size = 1;
       
  1188                     if (widget && widget->isWindow())
       
  1189                         size = 4;
       
  1190                     mask->region -= opt->rect.adjusted(size, size, -size, -size);
       
  1191                 }
       
  1192             }
       
  1193         }
       
  1194         break;
       
  1195 #endif // QT_NO_RUBBERBAND
       
  1196     case SH_LineEdit_PasswordCharacter:
       
  1197         {
       
  1198 #ifdef Q_WS_WIN
       
  1199             if (widget && (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
       
  1200                 const QFontMetrics &fm = widget->fontMetrics();
       
  1201                 if (fm.inFont(QChar(0x25CF)))
       
  1202                     ret = 0x25CF;
       
  1203                 else if (fm.inFont(QChar(0x2022)))
       
  1204                     ret = 0x2022;
       
  1205             }
       
  1206 #endif
       
  1207             if (!ret)
       
  1208                 ret = '*';
       
  1209         }
       
  1210         break;
       
  1211 #ifndef QT_NO_WIZARD
       
  1212     case SH_WizardStyle:
       
  1213         ret = QWizard::ModernStyle;
       
  1214         break;
       
  1215 #endif
       
  1216     case SH_ItemView_ArrowKeysNavigateIntoChildren:
       
  1217         ret = true;
       
  1218         break;
       
  1219     case SH_DialogButtonBox_ButtonsHaveIcons:
       
  1220         ret = 0;
       
  1221         break;
       
  1222     default:
       
  1223         ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
       
  1224         break;
       
  1225     }
       
  1226     return ret;
       
  1227 }
       
  1228 
       
  1229 /*! \reimp */
       
  1230 void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
       
  1231                                   const QWidget *w) const
       
  1232 {
       
  1233     // Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
       
  1234     bool doRestore = false;
       
  1235 
       
  1236     switch (pe) {
       
  1237 #ifndef QT_NO_TOOLBAR
       
  1238   case PE_IndicatorToolBarSeparator:
       
  1239         {
       
  1240             QRect rect = opt->rect;
       
  1241             const int margin = 2;
       
  1242             QPen oldPen = p->pen();
       
  1243             if(opt->state & State_Horizontal){
       
  1244                 const int offset = rect.width()/2;
       
  1245                 p->setPen(QPen(opt->palette.dark().color()));
       
  1246                 p->drawLine(rect.bottomLeft().x() + offset,
       
  1247                             rect.bottomLeft().y() - margin,
       
  1248                             rect.topLeft().x() + offset,
       
  1249                             rect.topLeft().y() + margin);
       
  1250                 p->setPen(QPen(opt->palette.light().color()));
       
  1251                 p->drawLine(rect.bottomLeft().x() + offset + 1,
       
  1252                             rect.bottomLeft().y() - margin,
       
  1253                             rect.topLeft().x() + offset + 1,
       
  1254                             rect.topLeft().y() + margin);
       
  1255             }
       
  1256             else{ //Draw vertical separator
       
  1257                 const int offset = rect.height()/2;
       
  1258                 p->setPen(QPen(opt->palette.dark().color()));
       
  1259                 p->drawLine(rect.topLeft().x() + margin ,
       
  1260                             rect.topLeft().y() + offset,
       
  1261                             rect.topRight().x() - margin,
       
  1262                             rect.topRight().y() + offset);
       
  1263                 p->setPen(QPen(opt->palette.light().color()));
       
  1264                 p->drawLine(rect.topLeft().x() + margin ,
       
  1265                             rect.topLeft().y() + offset + 1,
       
  1266                             rect.topRight().x() - margin,
       
  1267                             rect.topRight().y() + offset + 1);
       
  1268             }
       
  1269             p->setPen(oldPen);
       
  1270         }
       
  1271         break;
       
  1272     case PE_IndicatorToolBarHandle:
       
  1273         p->save();
       
  1274         p->translate(opt->rect.x(), opt->rect.y());
       
  1275         if (opt->state & State_Horizontal) {
       
  1276             int x = opt->rect.width() / 2 - 4;
       
  1277             if (opt->direction == Qt::RightToLeft)
       
  1278                 x -= 2;
       
  1279             if (opt->rect.height() > 4) {
       
  1280                 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
       
  1281                                 opt->palette, false, 1, 0);
       
  1282                 qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
       
  1283                                 opt->palette, false, 1, 0);
       
  1284             }
       
  1285         } else {
       
  1286             if (opt->rect.width() > 4) {
       
  1287                 int y = opt->rect.height() / 2 - 4;
       
  1288                 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
       
  1289                                 opt->palette, false, 1, 0);
       
  1290                 qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
       
  1291                                 opt->palette, false, 1, 0);
       
  1292             }
       
  1293         }
       
  1294         p->restore();
       
  1295         break;
       
  1296 
       
  1297 #endif // QT_NO_TOOLBAR
       
  1298     case PE_FrameButtonTool:
       
  1299     case PE_PanelButtonTool: {
       
  1300         QPen oldPen = p->pen();
       
  1301 #ifndef QT_NO_DOCKWIDGET
       
  1302         if (w && w->inherits("QDockWidgetTitleButton")) {
       
  1303            if (const QWidget *dw = w->parentWidget())
       
  1304                 if (dw->isWindow()){
       
  1305                     qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
       
  1306                            &opt->palette.button());
       
  1307 
       
  1308                     return;
       
  1309                 }
       
  1310         }
       
  1311 #endif // QT_NO_DOCKWIDGET
       
  1312         QBrush fill;
       
  1313         bool stippled;
       
  1314         bool panel = (pe == PE_PanelButtonTool);
       
  1315         if ((!(opt->state & State_Sunken ))
       
  1316             && (!(opt->state & State_Enabled)
       
  1317                 || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
       
  1318             && (opt->state & State_On)) {
       
  1319             fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
       
  1320             stippled = true;
       
  1321         } else {
       
  1322             fill = opt->palette.brush(QPalette::Button);
       
  1323             stippled = false;
       
  1324         }
       
  1325 
       
  1326         if (opt->state & (State_Raised | State_Sunken | State_On)) {
       
  1327             if (opt->state & State_AutoRaise) {
       
  1328                 if(opt->state & (State_Enabled | State_Sunken | State_On)){
       
  1329                     if (panel)
       
  1330                         qDrawShadePanel(p, opt->rect, opt->palette,
       
  1331                                         opt->state & (State_Sunken | State_On), 1, &fill);
       
  1332                     else
       
  1333                         qDrawShadeRect(p, opt->rect, opt->palette,
       
  1334                                        opt->state & (State_Sunken | State_On), 1);
       
  1335                 }
       
  1336                 if (stippled) {
       
  1337                     p->setPen(opt->palette.button().color());
       
  1338                     p->drawRect(opt->rect.adjusted(1,1,-2,-2));
       
  1339                 }
       
  1340             } else {
       
  1341                 qDrawWinButton(p, opt->rect, opt->palette,
       
  1342                                opt->state & (State_Sunken | State_On), panel ? &fill : 0);
       
  1343             }
       
  1344         } else {
       
  1345             p->fillRect(opt->rect, fill);
       
  1346         }
       
  1347         p->setPen(oldPen);
       
  1348         break; }
       
  1349     case PE_PanelButtonCommand:
       
  1350         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
       
  1351             QBrush fill;
       
  1352             State flags = opt->state;
       
  1353             QPalette pal = opt->palette;
       
  1354             QRect r = opt->rect;
       
  1355             if (! (flags & State_Sunken) && (flags & State_On))
       
  1356                 fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
       
  1357             else
       
  1358                 fill = pal.brush(QPalette::Button);
       
  1359 
       
  1360             if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
       
  1361                 p->setPen(pal.dark().color());
       
  1362                 p->setBrush(fill);
       
  1363                 p->drawRect(r.adjusted(0, 0, -1, -1));
       
  1364             } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
       
  1365                 qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
       
  1366                                &fill);
       
  1367             } else {
       
  1368                 p->fillRect(r, fill);
       
  1369             }
       
  1370         }
       
  1371         break;
       
  1372     case PE_FrameDefaultButton: {
       
  1373         QPen oldPen = p->pen();
       
  1374         p->setPen(opt->palette.shadow().color());
       
  1375         QRect rect = opt->rect;
       
  1376         rect.adjust(0, 0, -1, -1);
       
  1377         p->drawRect(rect);
       
  1378         p->setPen(oldPen);
       
  1379         break;
       
  1380     }
       
  1381     case PE_IndicatorArrowUp:
       
  1382     case PE_IndicatorArrowDown:
       
  1383     case PE_IndicatorArrowRight:
       
  1384     case PE_IndicatorArrowLeft:
       
  1385         {
       
  1386             if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
       
  1387                 break;
       
  1388             QRect r = opt->rect;
       
  1389             int size = qMin(r.height(), r.width());
       
  1390             QPixmap pixmap;
       
  1391             QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size))
       
  1392                   + QLatin1Char('-') + QString::number(pe);                               
       
  1393             if (!QPixmapCache::find(pixmapName, pixmap)) {
       
  1394                 int border = size/5;
       
  1395                 int sqsize = 2*(size/2);
       
  1396                 QImage image(sqsize, sqsize, QImage::Format_ARGB32);
       
  1397                 image.fill(Qt::transparent);
       
  1398                 QPainter imagePainter(&image);
       
  1399 
       
  1400                 QPolygon a;
       
  1401                 switch (pe) {
       
  1402                     case PE_IndicatorArrowUp:
       
  1403                         a.setPoints(3, border, sqsize/2,  sqsize/2, border,  sqsize - border, sqsize/2);
       
  1404                         break;
       
  1405                     case PE_IndicatorArrowDown:
       
  1406                         a.setPoints(3, border, sqsize/2,  sqsize/2, sqsize - border,  sqsize - border, sqsize/2);
       
  1407                         break;
       
  1408                     case PE_IndicatorArrowRight:
       
  1409                         a.setPoints(3, sqsize - border, sqsize/2,  sqsize/2, border,  sqsize/2, sqsize - border);
       
  1410                         break;
       
  1411                     case PE_IndicatorArrowLeft:
       
  1412                         a.setPoints(3, border, sqsize/2,  sqsize/2, border,  sqsize/2, sqsize - border);
       
  1413                         break;
       
  1414                     default:
       
  1415                         break;
       
  1416                 }
       
  1417 
       
  1418                 int bsx = 0;
       
  1419                 int bsy = 0;
       
  1420 
       
  1421                 if (opt->state & State_Sunken) {
       
  1422                     bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
       
  1423                     bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
       
  1424                 }
       
  1425 
       
  1426                 QRect bounds = a.boundingRect();
       
  1427                 int sx = sqsize / 2 - bounds.center().x() - 1;
       
  1428                 int sy = sqsize / 2 - bounds.center().y() - 1;
       
  1429                 imagePainter.translate(sx + bsx, sy + bsy);
       
  1430                 imagePainter.setPen(opt->palette.buttonText().color());
       
  1431                 imagePainter.setBrush(opt->palette.buttonText());
       
  1432 
       
  1433                 if (!(opt->state & State_Enabled)) {
       
  1434                     imagePainter.translate(1, 1);
       
  1435                     imagePainter.setBrush(opt->palette.light().color());
       
  1436                     imagePainter.setPen(opt->palette.light().color());
       
  1437                     imagePainter.drawPolygon(a);
       
  1438                     imagePainter.translate(-1, -1);
       
  1439                     imagePainter.setBrush(opt->palette.mid().color());
       
  1440                     imagePainter.setPen(opt->palette.mid().color());
       
  1441                 }
       
  1442 
       
  1443                 imagePainter.drawPolygon(a);
       
  1444                 imagePainter.end();
       
  1445                 pixmap = QPixmap::fromImage(image);
       
  1446                 QPixmapCache::insert(pixmapName, pixmap);
       
  1447             }
       
  1448             int xOffset = r.x() + (r.width() - size)/2;
       
  1449             int yOffset = r.y() + (r.height() - size)/2;
       
  1450             p->drawPixmap(xOffset, yOffset, pixmap);
       
  1451         }
       
  1452         break;
       
  1453     case PE_IndicatorCheckBox: {
       
  1454         QBrush fill;
       
  1455         if (opt->state & State_NoChange)
       
  1456             fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
       
  1457         else if (opt->state & State_Sunken)
       
  1458             fill = opt->palette.button();
       
  1459         else if (opt->state & State_Enabled)
       
  1460             fill = opt->palette.base();
       
  1461         else
       
  1462             fill = opt->palette.background();
       
  1463         p->save();
       
  1464         doRestore = true;
       
  1465         qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
       
  1466         if (opt->state & State_NoChange)
       
  1467             p->setPen(opt->palette.dark().color());
       
  1468         else
       
  1469             p->setPen(opt->palette.text().color());
       
  1470         } // Fall through!
       
  1471     case PE_IndicatorViewItemCheck:
       
  1472     case PE_Q3CheckListIndicator:
       
  1473         if (!doRestore) {
       
  1474             p->save();
       
  1475             doRestore = true;
       
  1476         }
       
  1477         if (pe == PE_Q3CheckListIndicator || pe == PE_IndicatorViewItemCheck) {
       
  1478             const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
       
  1479             p->setPen(itemViewOpt
       
  1480                       && itemViewOpt->showDecorationSelected
       
  1481                       && opt->state & State_Selected
       
  1482                         ? opt->palette.highlightedText().color()
       
  1483                         : opt->palette.text().color());
       
  1484             if (opt->state & State_NoChange)
       
  1485                 p->setBrush(opt->palette.brush(QPalette::Button));
       
  1486             p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
       
  1487         }
       
  1488         if (!(opt->state & State_Off)) {
       
  1489             QLineF lines[7];
       
  1490             int i, xx, yy;
       
  1491             xx = opt->rect.x() + 3;
       
  1492             yy = opt->rect.y() + 5;
       
  1493             for (i = 0; i < 3; ++i) {
       
  1494                 lines[i] = QLineF(xx, yy, xx, yy + 2);
       
  1495                 ++xx;
       
  1496                 ++yy;
       
  1497             }
       
  1498             yy -= 2;
       
  1499             for (i = 3; i < 7; ++i) {
       
  1500                 lines[i] = QLineF(xx, yy, xx, yy + 2);
       
  1501                 ++xx;
       
  1502                 --yy;
       
  1503             }
       
  1504             p->drawLines(lines, 7);
       
  1505         }
       
  1506         if (doRestore)
       
  1507             p->restore();
       
  1508         break;
       
  1509     case PE_FrameFocusRect:
       
  1510         if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
       
  1511             //### check for d->alt_down
       
  1512             if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
       
  1513                 return;
       
  1514             QRect r = opt->rect;
       
  1515             p->save();
       
  1516             p->setBackgroundMode(Qt::TransparentMode);
       
  1517             QColor bg_col = fropt->backgroundColor;
       
  1518             if (!bg_col.isValid())
       
  1519                 bg_col = p->background().color();
       
  1520             // Create an "XOR" color.
       
  1521             QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
       
  1522                               (bg_col.green() ^ 0xff) & 0xff,
       
  1523                               (bg_col.blue() ^ 0xff) & 0xff);
       
  1524             p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
       
  1525             p->setBrushOrigin(r.topLeft());
       
  1526             p->setPen(Qt::NoPen);
       
  1527             p->drawRect(r.left(), r.top(), r.width(), 1);    // Top
       
  1528             p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
       
  1529             p->drawRect(r.left(), r.top(), 1, r.height());   // Left
       
  1530             p->drawRect(r.right(), r.top(), 1, r.height());  // Right
       
  1531             p->restore();
       
  1532         }
       
  1533         break;
       
  1534     case PE_IndicatorRadioButton:
       
  1535         {
       
  1536 #define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
       
  1537             static const QPoint pts1[] = {              // dark lines
       
  1538                 QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
       
  1539                 QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
       
  1540             };
       
  1541             static const QPoint pts2[] = {              // black lines
       
  1542                 QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
       
  1543                 QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
       
  1544             };
       
  1545             static const QPoint pts3[] = {              // background lines
       
  1546                 QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
       
  1547                 QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
       
  1548             };
       
  1549             static const QPoint pts4[] = {              // white lines
       
  1550                 QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
       
  1551                 QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
       
  1552                 QPoint(10, 3), QPoint(10, 2)
       
  1553             };
       
  1554             static const QPoint pts5[] = {              // inner fill
       
  1555                 QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
       
  1556                 QPoint(2, 7), QPoint(2, 4)
       
  1557             };
       
  1558 
       
  1559             // make sure the indicator is square
       
  1560             QRect ir = opt->rect;
       
  1561 
       
  1562             if (opt->rect.width() < opt->rect.height()) {
       
  1563                 ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
       
  1564                 ir.setHeight(opt->rect.width());
       
  1565             } else if (opt->rect.height() < opt->rect.width()) {
       
  1566                 ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
       
  1567                 ir.setWidth(opt->rect.height());
       
  1568             }
       
  1569 
       
  1570             p->save();
       
  1571             bool down = opt->state & State_Sunken;
       
  1572             bool enabled = opt->state & State_Enabled;
       
  1573             bool on = opt->state & State_On;
       
  1574             QPolygon a;
       
  1575 
       
  1576             //center when rect is larger than indicator size
       
  1577             int xOffset = 0;
       
  1578             int yOffset = 0;
       
  1579             int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
       
  1580             int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
       
  1581             if (ir.width() > indicatorWidth)
       
  1582                 xOffset += (ir.width() - indicatorWidth)/2;
       
  1583             if (ir.height() > indicatorHeight)
       
  1584                 yOffset += (ir.height() - indicatorHeight)/2;
       
  1585             p->translate(xOffset, yOffset);
       
  1586 
       
  1587             p->translate(ir.x(), ir.y());
       
  1588 
       
  1589             p->setPen(opt->palette.dark().color());
       
  1590             p->drawPolyline(pts1, PTSARRLEN(pts1));
       
  1591 
       
  1592             p->setPen(opt->palette.shadow().color());
       
  1593             p->drawPolyline(pts2, PTSARRLEN(pts2));
       
  1594 
       
  1595             p->setPen(opt->palette.midlight().color());
       
  1596             p->drawPolyline(pts3, PTSARRLEN(pts3));
       
  1597 
       
  1598             p->setPen(opt->palette.light().color());
       
  1599             p->drawPolyline(pts4, PTSARRLEN(pts4));
       
  1600 
       
  1601             QColor fillColor = (down || !enabled)
       
  1602                                ? opt->palette.button().color()
       
  1603                                : opt->palette.base().color();
       
  1604             p->setPen(fillColor);
       
  1605             p->setBrush(fillColor) ;
       
  1606             p->drawPolygon(pts5, PTSARRLEN(pts5));
       
  1607 
       
  1608             p->translate(-ir.x(), -ir.y()); // restore translate
       
  1609 
       
  1610             if (on) {
       
  1611                 p->setPen(Qt::NoPen);
       
  1612                 p->setBrush(opt->palette.text());
       
  1613                 p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
       
  1614                 p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
       
  1615             }
       
  1616             p->restore();
       
  1617             break;
       
  1618         }
       
  1619 #ifndef QT_NO_FRAME
       
  1620     case PE_Frame:
       
  1621     case PE_FrameMenu:
       
  1622         if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
       
  1623             if (frame->lineWidth == 2 || pe == PE_Frame) {
       
  1624                 QPalette popupPal = frame->palette;
       
  1625                 if (pe == PE_FrameMenu) {
       
  1626                     popupPal.setColor(QPalette::Light, frame->palette.background().color());
       
  1627                     popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
       
  1628                 }
       
  1629                 if (pe == PE_Frame && (frame->state & State_Raised))
       
  1630                     qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
       
  1631                 else if (pe == PE_Frame && (frame->state & State_Sunken))
       
  1632                 {
       
  1633                     popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
       
  1634                     qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
       
  1635                 }
       
  1636                 else
       
  1637                     qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
       
  1638             } else {
       
  1639                 QCommonStyle::drawPrimitive(pe, opt, p, w);
       
  1640             }
       
  1641         } else {
       
  1642             QPalette popupPal = opt->palette;
       
  1643             popupPal.setColor(QPalette::Light, opt->palette.background().color());
       
  1644             popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
       
  1645             qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
       
  1646         }
       
  1647         break;
       
  1648 #endif // QT_NO_FRAME
       
  1649     case PE_IndicatorBranch: {
       
  1650         // This is _way_ too similar to the common style.
       
  1651         static const int decoration_size = 9;
       
  1652         int mid_h = opt->rect.x() + opt->rect.width() / 2;
       
  1653         int mid_v = opt->rect.y() + opt->rect.height() / 2;
       
  1654         int bef_h = mid_h;
       
  1655         int bef_v = mid_v;
       
  1656         int aft_h = mid_h;
       
  1657         int aft_v = mid_v;
       
  1658         if (opt->state & State_Children) {
       
  1659             int delta = decoration_size / 2;
       
  1660             bef_h -= delta;
       
  1661             bef_v -= delta;
       
  1662             aft_h += delta;
       
  1663             aft_v += delta;
       
  1664             p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
       
  1665             if (!(opt->state & State_Open))
       
  1666                 p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
       
  1667             QPen oldPen = p->pen();
       
  1668             p->setPen(opt->palette.dark().color());
       
  1669             p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
       
  1670             p->setPen(oldPen);
       
  1671         }
       
  1672         QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
       
  1673         if (opt->state & State_Item) {
       
  1674             if (opt->direction == Qt::RightToLeft)
       
  1675                 p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
       
  1676             else
       
  1677                 p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
       
  1678         }
       
  1679         if (opt->state & State_Sibling)
       
  1680             p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
       
  1681         if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))
       
  1682             p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
       
  1683         break; }
       
  1684     case PE_FrameButtonBevel:
       
  1685     case PE_PanelButtonBevel: {
       
  1686         QBrush fill;
       
  1687         bool panel = pe != PE_FrameButtonBevel;
       
  1688         p->setBrushOrigin(opt->rect.topLeft());
       
  1689         if (!(opt->state & State_Sunken) && (opt->state & State_On))
       
  1690             fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
       
  1691         else
       
  1692             fill = opt->palette.brush(QPalette::Button);
       
  1693 
       
  1694         if (opt->state & (State_Raised | State_On | State_Sunken)) {
       
  1695             qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
       
  1696                            panel ? &fill : 0);
       
  1697         } else {
       
  1698             if (panel)
       
  1699                 p->fillRect(opt->rect, fill);
       
  1700             else
       
  1701                 p->drawRect(opt->rect);
       
  1702         }
       
  1703         break; }
       
  1704     case PE_FrameWindow: {
       
  1705          QPalette popupPal = opt->palette;
       
  1706          popupPal.setColor(QPalette::Light, opt->palette.background().color());
       
  1707          popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
       
  1708          qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
       
  1709         break; }
       
  1710 #ifndef QT_NO_DOCKWIDGET
       
  1711     case PE_IndicatorDockWidgetResizeHandle: {
       
  1712         QPen oldPen = p->pen();
       
  1713         p->setPen(opt->palette.light().color());
       
  1714         if (opt->state & State_Horizontal) {
       
  1715             p->drawLine(opt->rect.left(),          opt->rect.top(),
       
  1716                         opt->rect.right(), opt->rect.top());
       
  1717             p->setPen(opt->palette.dark().color());
       
  1718             p->drawLine(opt->rect.left(),          opt->rect.bottom() - 1,
       
  1719                         opt->rect.right(), opt->rect.bottom() - 1);
       
  1720             p->setPen(opt->palette.shadow().color());
       
  1721             p->drawLine(opt->rect.left(),          opt->rect.bottom(),
       
  1722                         opt->rect.right(), opt->rect.bottom());
       
  1723         } else {
       
  1724             p->drawLine(opt->rect.left(), opt->rect.top(),
       
  1725                         opt->rect.left(), opt->rect.bottom());
       
  1726             p->setPen(opt->palette.dark().color());
       
  1727             p->drawLine(opt->rect.right() - 1, opt->rect.top(),
       
  1728                         opt->rect.right() - 1, opt->rect.bottom());
       
  1729             p->setPen(opt->palette.shadow().color());
       
  1730             p->drawLine(opt->rect.right(), opt->rect.top(),
       
  1731                         opt->rect.right(), opt->rect.bottom());
       
  1732         }
       
  1733         p->setPen(oldPen);
       
  1734         break; }
       
  1735 case PE_FrameDockWidget:
       
  1736         if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
       
  1737             proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
       
  1738         }
       
  1739     break;
       
  1740 #endif // QT_NO_DOCKWIDGET
       
  1741 
       
  1742     case PE_FrameStatusBarItem:
       
  1743         qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
       
  1744         break;
       
  1745 
       
  1746 #ifndef QT_NO_PROGRESSBAR
       
  1747     case PE_IndicatorProgressChunk:
       
  1748         {
       
  1749             bool vertical = false, inverted = false;
       
  1750             if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
       
  1751                 vertical = (pb2->orientation == Qt::Vertical);
       
  1752                 inverted = pb2->invertedAppearance;
       
  1753             }
       
  1754 
       
  1755             int space = 2;
       
  1756             int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
       
  1757             if (!vertical) {
       
  1758                 if (opt->rect.width() <= chunksize)
       
  1759                     space = 0;
       
  1760 
       
  1761                 if (inverted)
       
  1762                     p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
       
  1763                             opt->palette.brush(QPalette::Highlight));
       
  1764                 else
       
  1765                     p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
       
  1766                                 opt->palette.brush(QPalette::Highlight));
       
  1767             } else {
       
  1768                 if (opt->rect.height() <= chunksize)
       
  1769                     space = 0;
       
  1770 
       
  1771                 if (inverted)
       
  1772                     p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
       
  1773                             opt->palette.brush(QPalette::Highlight));
       
  1774                 else
       
  1775                     p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
       
  1776                                 opt->palette.brush(QPalette::Highlight));
       
  1777             }
       
  1778         }
       
  1779         break;
       
  1780 #endif // QT_NO_PROGRESSBAR
       
  1781 
       
  1782     case PE_FrameTabWidget: {
       
  1783         qDrawWinButton(p, opt->rect, opt->palette, false, 0);
       
  1784         break;
       
  1785     }
       
  1786     default:
       
  1787         QCommonStyle::drawPrimitive(pe, opt, p, w);
       
  1788     }
       
  1789 }
       
  1790 
       
  1791 /*! \reimp */
       
  1792 void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
       
  1793                                 const QWidget *widget) const
       
  1794 {
       
  1795     switch (ce) {
       
  1796 #ifndef QT_NO_RUBBERBAND
       
  1797     case CE_RubberBand:
       
  1798         if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
       
  1799             // ### workaround for slow general painter path
       
  1800             QPixmap tiledPixmap(16, 16);
       
  1801             QPainter pixmapPainter(&tiledPixmap);
       
  1802             pixmapPainter.setPen(Qt::NoPen);
       
  1803             pixmapPainter.setBrush(Qt::Dense4Pattern);
       
  1804             pixmapPainter.setBackground(Qt::white);
       
  1805             pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
       
  1806             pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
       
  1807             pixmapPainter.end();
       
  1808             tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
       
  1809             p->save();
       
  1810             QRect r = opt->rect;
       
  1811             QStyleHintReturnMask mask;
       
  1812             if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
       
  1813                 p->setClipRegion(mask.region);
       
  1814             p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
       
  1815             p->restore();
       
  1816             return;
       
  1817         }
       
  1818         break;
       
  1819 #endif // QT_NO_RUBBERBAND
       
  1820 
       
  1821 #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
       
  1822     case CE_MenuBarEmptyArea:
       
  1823         if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
       
  1824             p->fillRect(opt->rect, opt->palette.button());
       
  1825             QPen oldPen = p->pen();
       
  1826             p->setPen(QPen(opt->palette.dark().color()));
       
  1827             p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
       
  1828             p->setPen(oldPen);
       
  1829         }
       
  1830         break;
       
  1831 #endif
       
  1832 #ifndef QT_NO_MENU
       
  1833     case CE_MenuItem:
       
  1834         if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
       
  1835             int x, y, w, h;
       
  1836             menuitem->rect.getRect(&x, &y, &w, &h);
       
  1837             int tab = menuitem->tabWidth;
       
  1838             bool dis = !(menuitem->state & State_Enabled);
       
  1839             bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
       
  1840                             ? menuitem->checked : false;
       
  1841             bool act = menuitem->state & State_Selected;
       
  1842 
       
  1843             // windows always has a check column, regardless whether we have an icon or not
       
  1844             int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
       
  1845 
       
  1846             QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
       
  1847             p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
       
  1848 
       
  1849             if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
       
  1850                 int yoff = y-1 + h / 2;
       
  1851                 p->setPen(menuitem->palette.dark().color());
       
  1852                 p->drawLine(x + 2, yoff, x + w - 4, yoff);
       
  1853                 p->setPen(menuitem->palette.light().color());
       
  1854                 p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
       
  1855                 return;
       
  1856             }
       
  1857 
       
  1858             QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
       
  1859             if (checked) {
       
  1860                 if (act && !dis) {
       
  1861                     qDrawShadePanel(p, vCheckRect,
       
  1862                                     menuitem->palette, true, 1,
       
  1863                                     &menuitem->palette.brush(QPalette::Button));
       
  1864                 } else {
       
  1865                     QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
       
  1866                     qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
       
  1867                 }
       
  1868             } else if (!act) {
       
  1869                 p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
       
  1870             }
       
  1871 
       
  1872             // On Windows Style, if we have a checkable item and an icon we
       
  1873             // draw the icon recessed to indicate an item is checked. If we
       
  1874             // have no icon, we draw a checkmark instead.
       
  1875             if (!menuitem->icon.isNull()) {
       
  1876                 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
       
  1877                 if (act && !dis)
       
  1878                     mode = QIcon::Active;
       
  1879                 QPixmap pixmap;
       
  1880                 if (checked)
       
  1881                     pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
       
  1882                 else
       
  1883                     pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
       
  1884                 int pixw = pixmap.width();
       
  1885                 int pixh = pixmap.height();
       
  1886                 if (act && !dis && !checked)
       
  1887                     qDrawShadePanel(p, vCheckRect,  menuitem->palette, false, 1,
       
  1888                                     &menuitem->palette.brush(QPalette::Button));
       
  1889                 QRect pmr(0, 0, pixw, pixh);
       
  1890                 pmr.moveCenter(vCheckRect.center());
       
  1891                 p->setPen(menuitem->palette.text().color());
       
  1892                 p->drawPixmap(pmr.topLeft(), pixmap);
       
  1893             } else if (checked) {
       
  1894                 QStyleOptionMenuItem newMi = *menuitem;
       
  1895                 newMi.state = State_None;
       
  1896                 if (!dis)
       
  1897                     newMi.state |= State_Enabled;
       
  1898                 if (act)
       
  1899                     newMi.state |= State_On;
       
  1900                 newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
       
  1901                                                                               menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
       
  1902                                                                               checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
       
  1903                                                                               menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
       
  1904                 proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
       
  1905             }
       
  1906             p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
       
  1907 
       
  1908             QColor discol;
       
  1909             if (dis) {
       
  1910                 discol = menuitem->palette.text().color();
       
  1911                 p->setPen(discol);
       
  1912             }
       
  1913 
       
  1914             int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin;
       
  1915             int xpos = menuitem->rect.x() + xm;
       
  1916             QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
       
  1917                            w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
       
  1918             QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
       
  1919             QString s = menuitem->text;
       
  1920             if (!s.isEmpty()) {                     // draw text
       
  1921                 p->save();
       
  1922                 int t = s.indexOf(QLatin1Char('\t'));
       
  1923                 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
       
  1924                 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
       
  1925                     text_flags |= Qt::TextHideMnemonic;
       
  1926                 text_flags |= Qt::AlignLeft;
       
  1927                 if (t >= 0) {
       
  1928                     QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
       
  1929                         QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
       
  1930                     if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
       
  1931                         p->setPen(menuitem->palette.light().color());
       
  1932                         p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
       
  1933                         p->setPen(discol);
       
  1934                     }
       
  1935                     p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
       
  1936                     s = s.left(t);
       
  1937                 }
       
  1938                 QFont font = menuitem->font;
       
  1939                 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
       
  1940                     font.setBold(true);
       
  1941                 p->setFont(font);
       
  1942                 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
       
  1943                     p->setPen(menuitem->palette.light().color());
       
  1944                     p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
       
  1945                     p->setPen(discol);
       
  1946                 }
       
  1947                 p->drawText(vTextRect, text_flags, s.left(t));
       
  1948                 p->restore();
       
  1949             }
       
  1950             if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
       
  1951                 int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
       
  1952                 PrimitiveElement arrow;
       
  1953                 arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
       
  1954                 xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
       
  1955                 QRect  vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
       
  1956                 QStyleOptionMenuItem newMI = *menuitem;
       
  1957                 newMI.rect = vSubMenuRect;
       
  1958                 newMI.state = dis ? State_None : State_Enabled;
       
  1959                 if (act)
       
  1960                     newMI.palette.setColor(QPalette::ButtonText,
       
  1961                                            newMI.palette.highlightedText().color());
       
  1962                 proxy()->drawPrimitive(arrow, &newMI, p, widget);
       
  1963             }
       
  1964 
       
  1965         }
       
  1966         break;
       
  1967 #endif // QT_NO_MENU
       
  1968 #ifndef QT_NO_MENUBAR
       
  1969     case CE_MenuBarItem:
       
  1970         if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
       
  1971             bool active = mbi->state & State_Selected;
       
  1972             bool hasFocus = mbi->state & State_HasFocus;
       
  1973             bool down = mbi->state & State_Sunken;
       
  1974             QStyleOptionMenuItem newMbi = *mbi;
       
  1975             p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
       
  1976             if (active || hasFocus) {
       
  1977                 QBrush b = mbi->palette.brush(QPalette::Button);
       
  1978                 if (active && down)
       
  1979                     p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
       
  1980                 if (active && hasFocus)
       
  1981                     qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
       
  1982                                    mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
       
  1983                 if (active && down) {
       
  1984                     newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget),
       
  1985                                        proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget));
       
  1986                     p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
       
  1987                 }
       
  1988             }
       
  1989             QCommonStyle::drawControl(ce, &newMbi, p, widget);
       
  1990         }
       
  1991         break;
       
  1992 #endif // QT_NO_MENUBAR
       
  1993 #ifndef QT_NO_TABBAR
       
  1994     case CE_TabBarTabShape:
       
  1995         if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
       
  1996             bool rtlHorTabs = (tab->direction == Qt::RightToLeft
       
  1997                                && (tab->shape == QTabBar::RoundedNorth
       
  1998                                    || tab->shape == QTabBar::RoundedSouth));
       
  1999             bool selected = tab->state & State_Selected;
       
  2000             bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
       
  2001                             || (rtlHorTabs
       
  2002                                 && tab->position == QStyleOptionTab::Beginning));
       
  2003             bool firstTab = ((!rtlHorTabs
       
  2004                                && tab->position == QStyleOptionTab::Beginning)
       
  2005                              || (rtlHorTabs
       
  2006                                  && tab->position == QStyleOptionTab::End));
       
  2007             bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
       
  2008             bool previousSelected =
       
  2009                 ((!rtlHorTabs
       
  2010                   && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
       
  2011                 || (rtlHorTabs
       
  2012                     && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
       
  2013             bool nextSelected =
       
  2014                 ((!rtlHorTabs
       
  2015                   && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
       
  2016                  || (rtlHorTabs
       
  2017                      && tab->selectedPosition
       
  2018                             == QStyleOptionTab::PreviousIsSelected));
       
  2019             int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
       
  2020             bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
       
  2021                                 || (rtlHorTabs
       
  2022                                     && tabBarAlignment == Qt::AlignRight);
       
  2023 
       
  2024             bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
       
  2025                                  || (rtlHorTabs
       
  2026                                          && tabBarAlignment == Qt::AlignLeft);
       
  2027 
       
  2028             QColor light = tab->palette.light().color();
       
  2029             QColor midlight = tab->palette.midlight().color();
       
  2030             QColor dark = tab->palette.dark().color();
       
  2031             QColor shadow = tab->palette.shadow().color();
       
  2032             QColor background = tab->palette.background().color();
       
  2033             int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
       
  2034             if (selected)
       
  2035                 borderThinkness /= 2;
       
  2036             QRect r2(opt->rect);
       
  2037             int x1 = r2.left();
       
  2038             int x2 = r2.right();
       
  2039             int y1 = r2.top();
       
  2040             int y2 = r2.bottom();
       
  2041             switch (tab->shape) {
       
  2042             default:
       
  2043                 QCommonStyle::drawControl(ce, tab, p, widget);
       
  2044                 break;
       
  2045             case QTabBar::RoundedNorth: {
       
  2046                 if (!selected) {
       
  2047                     y1 += 2;
       
  2048                     x1 += onlyOne || firstTab ? borderThinkness : 0;
       
  2049                     x2 -= onlyOne || lastTab ? borderThinkness : 0;
       
  2050                 }
       
  2051 
       
  2052                 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
       
  2053 
       
  2054                 // Delete border
       
  2055                 if (selected) {
       
  2056                     p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
       
  2057                     p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
       
  2058                 }
       
  2059                 // Left
       
  2060                 if (firstTab || selected || onlyOne || !previousSelected) {
       
  2061                     p->setPen(light);
       
  2062                     p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
       
  2063                     p->drawPoint(x1 + 1, y1 + 1);
       
  2064                 }
       
  2065                 // Top
       
  2066                 {
       
  2067                     int beg = x1 + (previousSelected ? 0 : 2);
       
  2068                     int end = x2 - (nextSelected ? 0 : 2);
       
  2069                     p->setPen(light);
       
  2070                     p->drawLine(beg, y1, end, y1);
       
  2071                 }
       
  2072                 // Right
       
  2073                 if (lastTab || selected || onlyOne || !nextSelected) {
       
  2074                     p->setPen(shadow);
       
  2075                     p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
       
  2076                     p->drawPoint(x2 - 1, y1 + 1);
       
  2077                     p->setPen(dark);
       
  2078                     p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
       
  2079                 }
       
  2080                 break; }
       
  2081             case QTabBar::RoundedSouth: {
       
  2082                 if (!selected) {
       
  2083                     y2 -= 2;
       
  2084                     x1 += firstTab ? borderThinkness : 0;
       
  2085                     x2 -= lastTab ? borderThinkness : 0;
       
  2086                 }
       
  2087 
       
  2088                 p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
       
  2089 
       
  2090                 // Delete border
       
  2091                 if (selected) {
       
  2092                     p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
       
  2093                     p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
       
  2094                 }
       
  2095                 // Left
       
  2096                 if (firstTab || selected || onlyOne || !previousSelected) {
       
  2097                     p->setPen(light);
       
  2098                     p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
       
  2099                     p->drawPoint(x1 + 1, y2 - 1);
       
  2100                 }
       
  2101                 // Bottom
       
  2102                 {
       
  2103                     int beg = x1 + (previousSelected ? 0 : 2);
       
  2104                     int end = x2 - (nextSelected ? 0 : 2);
       
  2105                     p->setPen(shadow);
       
  2106                     p->drawLine(beg, y2, end, y2);
       
  2107                     p->setPen(dark);
       
  2108                     p->drawLine(beg, y2 - 1, end, y2 - 1);
       
  2109                 }
       
  2110                 // Right
       
  2111                 if (lastTab || selected || onlyOne || !nextSelected) {
       
  2112                     p->setPen(shadow);
       
  2113                     p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
       
  2114                     p->drawPoint(x2 - 1, y2 - 1);
       
  2115                     p->setPen(dark);
       
  2116                     p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
       
  2117                 }
       
  2118                 break; }
       
  2119             case QTabBar::RoundedWest: {
       
  2120                 if (!selected) {
       
  2121                     x1 += 2;
       
  2122                     y1 += firstTab ? borderThinkness : 0;
       
  2123                     y2 -= lastTab ? borderThinkness : 0;
       
  2124                 }
       
  2125 
       
  2126                 p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
       
  2127 
       
  2128                 // Delete border
       
  2129                 if (selected) {
       
  2130                     p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
       
  2131                     p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
       
  2132                 }
       
  2133                 // Top
       
  2134                 if (firstTab || selected || onlyOne || !previousSelected) {
       
  2135                     p->setPen(light);
       
  2136                     p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
       
  2137                     p->drawPoint(x1 + 1, y1 + 1);
       
  2138                 }
       
  2139                 // Left
       
  2140                 {
       
  2141                     int beg = y1 + (previousSelected ? 0 : 2);
       
  2142                     int end = y2 - (nextSelected ? 0 : 2);
       
  2143                     p->setPen(light);
       
  2144                     p->drawLine(x1, beg, x1, end);
       
  2145                 }
       
  2146                 // Bottom
       
  2147                 if (lastTab || selected || onlyOne || !nextSelected) {
       
  2148                     p->setPen(shadow);
       
  2149                     p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
       
  2150                     p->drawPoint(x1 + 2, y2 - 1);
       
  2151                     p->setPen(dark);
       
  2152                     p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
       
  2153                     p->drawPoint(x1 + 1, y2 - 1);
       
  2154                     p->drawPoint(x1 + 2, y2);
       
  2155                 }
       
  2156                 break; }
       
  2157             case QTabBar::RoundedEast: {
       
  2158                 if (!selected) {
       
  2159                     x2 -= 2;
       
  2160                     y1 += firstTab ? borderThinkness : 0;
       
  2161                     y2 -= lastTab ? borderThinkness : 0;
       
  2162                 }
       
  2163 
       
  2164                 p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
       
  2165 
       
  2166                 // Delete border
       
  2167                 if (selected) {
       
  2168                     p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
       
  2169                     p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
       
  2170                 }
       
  2171                 // Top
       
  2172                 if (firstTab || selected || onlyOne || !previousSelected) {
       
  2173                     p->setPen(light);
       
  2174                     p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
       
  2175                     p->drawPoint(x2 - 1, y1 + 1);
       
  2176                 }
       
  2177                 // Right
       
  2178                 {
       
  2179                     int beg = y1 + (previousSelected ? 0 : 2);
       
  2180                     int end = y2 - (nextSelected ? 0 : 2);
       
  2181                     p->setPen(shadow);
       
  2182                     p->drawLine(x2, beg, x2, end);
       
  2183                     p->setPen(dark);
       
  2184                     p->drawLine(x2 - 1, beg, x2 - 1, end);
       
  2185                 }
       
  2186                 // Bottom
       
  2187                 if (lastTab || selected || onlyOne || !nextSelected) {
       
  2188                     p->setPen(shadow);
       
  2189                     p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
       
  2190                     p->drawPoint(x2 - 1, y2 - 1);
       
  2191                     p->setPen(dark);
       
  2192                     p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
       
  2193                 }
       
  2194                 break; }
       
  2195             }
       
  2196         }
       
  2197         break;
       
  2198 #endif // QT_NO_TABBAR
       
  2199     case CE_ToolBoxTabShape:
       
  2200         qDrawShadePanel(p, opt->rect, opt->palette,
       
  2201                         opt->state & (State_Sunken | State_On), 1,
       
  2202                         &opt->palette.brush(QPalette::Button));
       
  2203         break;
       
  2204 #ifndef QT_NO_SPLITTER
       
  2205     case CE_Splitter:
       
  2206         p->eraseRect(opt->rect);
       
  2207         break;
       
  2208 #endif // QT_NO_SPLITTER
       
  2209 #ifndef QT_NO_SCROLLBAR
       
  2210     case CE_ScrollBarSubLine:
       
  2211     case CE_ScrollBarAddLine: {
       
  2212         if ((opt->state & State_Sunken)) {
       
  2213             p->setPen(opt->palette.dark().color());
       
  2214             p->setBrush(opt->palette.brush(QPalette::Button));
       
  2215             p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
       
  2216         } else {
       
  2217             QStyleOption buttonOpt = *opt;
       
  2218             if (!(buttonOpt.state & State_Sunken))
       
  2219                 buttonOpt.state |= State_Raised;
       
  2220             QPalette pal(opt->palette);
       
  2221             pal.setColor(QPalette::Button, opt->palette.light().color());
       
  2222             pal.setColor(QPalette::Light, opt->palette.button().color());
       
  2223             qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
       
  2224                            &opt->palette.brush(QPalette::Button));
       
  2225         }
       
  2226         PrimitiveElement arrow;
       
  2227         if (opt->state & State_Horizontal) {
       
  2228             if (ce == CE_ScrollBarAddLine)
       
  2229                 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
       
  2230             else
       
  2231                 arrow = opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
       
  2232         } else {
       
  2233             if (ce == CE_ScrollBarAddLine)
       
  2234                 arrow = PE_IndicatorArrowDown;
       
  2235             else
       
  2236                 arrow = PE_IndicatorArrowUp;
       
  2237         }
       
  2238         QStyleOption arrowOpt = *opt;
       
  2239         arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
       
  2240         proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
       
  2241         break; }
       
  2242     case CE_ScrollBarAddPage:
       
  2243     case CE_ScrollBarSubPage: {
       
  2244             QBrush br;
       
  2245             QBrush bg = p->background();
       
  2246             Qt::BGMode bg_mode = p->backgroundMode();
       
  2247             p->setPen(Qt::NoPen);
       
  2248             p->setBackgroundMode(Qt::OpaqueMode);
       
  2249 
       
  2250             if (opt->state & State_Sunken) {
       
  2251                 br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
       
  2252                 p->setBackground(opt->palette.dark().color());
       
  2253                 p->setBrush(br);
       
  2254             } else {
       
  2255                 QPixmap pm = opt->palette.brush(QPalette::Light).texture();
       
  2256                 br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
       
  2257                 p->setBackground(opt->palette.background().color());
       
  2258                 p->setBrush(br);
       
  2259             }
       
  2260             p->drawRect(opt->rect);
       
  2261             p->setBackground(bg);
       
  2262             p->setBackgroundMode(bg_mode);
       
  2263             break; }
       
  2264     case CE_ScrollBarSlider:
       
  2265         if (!(opt->state & State_Enabled)) {
       
  2266             QPixmap pm = opt->palette.brush(QPalette::Light).texture();
       
  2267             QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
       
  2268             p->setPen(Qt::NoPen);
       
  2269             p->setBrush(br);
       
  2270             p->setBackgroundMode(Qt::OpaqueMode);
       
  2271             p->drawRect(opt->rect);
       
  2272         } else {
       
  2273             QStyleOptionButton buttonOpt;
       
  2274             buttonOpt.QStyleOption::operator=(*opt);
       
  2275             buttonOpt.state = State_Enabled | State_Raised;
       
  2276 
       
  2277             QPalette pal(opt->palette);
       
  2278             pal.setColor(QPalette::Button, opt->palette.light().color());
       
  2279             pal.setColor(QPalette::Light, opt->palette.button().color());
       
  2280             qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
       
  2281         }
       
  2282         break;
       
  2283 #endif // QT_NO_SCROLLBAR
       
  2284     case CE_HeaderSection: {
       
  2285         QBrush fill;
       
  2286         if (opt->state & State_On)
       
  2287             fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
       
  2288         else
       
  2289             fill = opt->palette.brush(QPalette::Button);
       
  2290 
       
  2291         if (opt->state & (State_Raised | State_Sunken)) {
       
  2292             qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
       
  2293         } else {
       
  2294             p->fillRect(opt->rect, fill);
       
  2295         }
       
  2296         break; }
       
  2297 #ifndef QT_NO_TOOLBAR
       
  2298     case CE_ToolBar:
       
  2299         if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
       
  2300             QRect rect = opt->rect;
       
  2301 
       
  2302             bool paintLeftBorder = true;
       
  2303             bool paintRightBorder = true;
       
  2304             bool paintBottomBorder = true;
       
  2305 
       
  2306             switch (toolbar->toolBarArea){
       
  2307             case Qt::BottomToolBarArea :
       
  2308                 switch(toolbar->positionOfLine){
       
  2309                 case QStyleOptionToolBar::Beginning:
       
  2310                 case QStyleOptionToolBar::OnlyOne:
       
  2311                     paintBottomBorder = false;
       
  2312                 default:
       
  2313                     break;
       
  2314                 }
       
  2315             case Qt::TopToolBarArea :
       
  2316                 switch(toolbar->positionWithinLine){
       
  2317                 case QStyleOptionToolBar::Beginning:
       
  2318                     paintLeftBorder = false;
       
  2319                     break;
       
  2320                 case QStyleOptionToolBar::End:
       
  2321                     paintRightBorder = false;
       
  2322                     break;
       
  2323                 case QStyleOptionToolBar::OnlyOne:
       
  2324                     paintRightBorder = false;
       
  2325                     paintLeftBorder = false;
       
  2326                 default:
       
  2327                     break;
       
  2328                 }
       
  2329                 if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
       
  2330                     bool tmp = paintLeftBorder;
       
  2331                     paintRightBorder=paintLeftBorder;
       
  2332                     paintLeftBorder=tmp;
       
  2333                 }
       
  2334                 break;
       
  2335             case Qt::RightToolBarArea :
       
  2336                 switch (toolbar->positionOfLine){
       
  2337                 case QStyleOptionToolBar::Beginning:
       
  2338                 case QStyleOptionToolBar::OnlyOne:
       
  2339                     paintRightBorder = false;
       
  2340                     break;
       
  2341                 default:
       
  2342                     break;
       
  2343                 }
       
  2344                 break;
       
  2345             case Qt::LeftToolBarArea :
       
  2346                 switch (toolbar->positionOfLine){
       
  2347                 case QStyleOptionToolBar::Beginning:
       
  2348                 case QStyleOptionToolBar::OnlyOne:
       
  2349                     paintLeftBorder = false;
       
  2350                     break;
       
  2351                 default:
       
  2352                     break;
       
  2353                 }
       
  2354                 break;
       
  2355             default:
       
  2356                 break;
       
  2357             }
       
  2358 
       
  2359 
       
  2360             //draw top border
       
  2361             p->setPen(QPen(opt->palette.light().color()));
       
  2362             p->drawLine(rect.topLeft().x(),
       
  2363                         rect.topLeft().y(),
       
  2364                         rect.topRight().x(),
       
  2365                         rect.topRight().y());
       
  2366 
       
  2367             if (paintLeftBorder){
       
  2368                 p->setPen(QPen(opt->palette.light().color()));
       
  2369                 p->drawLine(rect.topLeft().x(),
       
  2370                             rect.topLeft().y(),
       
  2371                             rect.bottomLeft().x(),
       
  2372                             rect.bottomLeft().y());
       
  2373             }
       
  2374 
       
  2375             if (paintRightBorder){
       
  2376                 p->setPen(QPen(opt->palette.dark().color()));
       
  2377                 p->drawLine(rect.topRight().x(),
       
  2378                             rect.topRight().y(),
       
  2379                             rect.bottomRight().x(),
       
  2380                             rect.bottomRight().y());
       
  2381             }
       
  2382 
       
  2383             if (paintBottomBorder){
       
  2384                 p->setPen(QPen(opt->palette.dark().color()));
       
  2385                 p->drawLine(rect.bottomLeft().x(),
       
  2386                             rect.bottomLeft().y(),
       
  2387                             rect.bottomRight().x(),
       
  2388                             rect.bottomRight().y());
       
  2389             }
       
  2390         }
       
  2391         break;
       
  2392 
       
  2393 
       
  2394 #endif // QT_NO_TOOLBAR
       
  2395 #ifndef QT_NO_PROGRESSBAR
       
  2396     case CE_ProgressBarContents:
       
  2397         if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
       
  2398 
       
  2399             QRect rect = pb->rect;
       
  2400             bool vertical = false;
       
  2401             bool inverted = false;
       
  2402 
       
  2403             // Get extra style options if version 2
       
  2404             const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
       
  2405             if (pb2) {
       
  2406                 vertical = (pb2->orientation == Qt::Vertical);
       
  2407                 inverted = pb2->invertedAppearance;
       
  2408             }
       
  2409             QMatrix m;
       
  2410             if (vertical) {
       
  2411                 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
       
  2412                 m.rotate(90);
       
  2413                 m.translate(0, -(rect.height() + rect.y()*2));
       
  2414             }
       
  2415             QPalette pal2 = pb->palette;
       
  2416             // Correct the highlight color if it is the same as the background
       
  2417             if (pal2.highlight() == pal2.background())
       
  2418                 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
       
  2419                                                                      QPalette::Highlight));
       
  2420             bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
       
  2421             if (inverted)
       
  2422                 reverse = !reverse;
       
  2423             int w = rect.width();
       
  2424             if (pb->minimum == 0 && pb->maximum == 0) {
       
  2425                 Q_D(const QWindowsStyle);
       
  2426                 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
       
  2427                 QStyleOptionProgressBarV2 pbBits = *pb;
       
  2428                 Q_ASSERT(unit_width >0);
       
  2429 
       
  2430                 pbBits.rect = rect;
       
  2431                 pbBits.palette = pal2;
       
  2432 
       
  2433                 int chunkCount = w / unit_width + 1;
       
  2434                 int step = d->animateStep%chunkCount;
       
  2435                 int chunksInRow = 5;
       
  2436                 int myY = pbBits.rect.y();
       
  2437                 int myHeight = pbBits.rect.height();
       
  2438                 int chunksToDraw = chunksInRow;
       
  2439 
       
  2440                 if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
       
  2441                 p->save();
       
  2442                 p->setClipRect(m.mapRect(QRectF(rect)).toRect());
       
  2443 
       
  2444                 int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width  : rect.left() + unit_width * step;
       
  2445                 int x = 0;
       
  2446 
       
  2447                 for (int i = 0; i < chunksToDraw ; ++i) {
       
  2448                     pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
       
  2449                     pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
       
  2450                     proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
       
  2451                     x += reverse ? -unit_width : unit_width;
       
  2452                 }
       
  2453                 //Draw wrap-around chunks
       
  2454                 if( step > chunkCount-5){
       
  2455                     x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
       
  2456                     x = 0;
       
  2457                     int chunksToDraw = step - (chunkCount - chunksInRow);
       
  2458                     for (int i = 0; i < chunksToDraw ; ++i) {
       
  2459                         pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
       
  2460                         pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
       
  2461                         proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);
       
  2462                         x += reverse ? -unit_width : unit_width;
       
  2463                     }
       
  2464                 }
       
  2465                 p->restore(); //restore state
       
  2466             }
       
  2467             else {
       
  2468                 QCommonStyle::drawControl(ce, opt, p, widget);
       
  2469             }
       
  2470         }
       
  2471         break;
       
  2472 #endif // QT_NO_PROGRESSBAR
       
  2473 
       
  2474 #ifndef QT_NO_DOCKWIDGET
       
  2475     case CE_DockWidgetTitle:
       
  2476 
       
  2477         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
       
  2478             Q_D(const QWindowsStyle);
       
  2479 
       
  2480             const QStyleOptionDockWidgetV2 *v2
       
  2481                 = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
       
  2482             bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
       
  2483 
       
  2484             QRect rect = dwOpt->rect;
       
  2485             QRect r = rect;
       
  2486 
       
  2487             if (verticalTitleBar) {
       
  2488                 QSize s = r.size();
       
  2489                 s.transpose();
       
  2490                 r.setSize(s);
       
  2491 
       
  2492                 p->save();
       
  2493                 p->translate(r.left(), r.top() + r.width());
       
  2494                 p->rotate(-90);
       
  2495                 p->translate(-r.left(), -r.top());
       
  2496             }
       
  2497 
       
  2498             bool floating = false;
       
  2499             bool active = dwOpt->state & State_Active;
       
  2500             QColor inactiveCaptionTextColor = d->inactiveCaptionText;
       
  2501             if (dwOpt->movable) {
       
  2502                 QColor left, right;
       
  2503 
       
  2504                 //Titlebar gradient
       
  2505                 if (widget && widget->isWindow()) {
       
  2506                     floating = true;
       
  2507                     if (active) {
       
  2508                         left = d->activeCaptionColor;
       
  2509                         right = d->activeGradientCaptionColor;
       
  2510                     } else {
       
  2511                         left = d->inactiveCaptionColor;
       
  2512                         right = d->inactiveGradientCaptionColor;
       
  2513                     }
       
  2514                     QBrush fillBrush(left);
       
  2515                     if (left != right) {
       
  2516                         QPoint p1(r.x(), r.top() + r.height()/2);
       
  2517                         QPoint p2(rect.right(), r.top() + r.height()/2);
       
  2518                         QLinearGradient lg(p1, p2);
       
  2519                         lg.setColorAt(0, left);
       
  2520                         lg.setColorAt(1, right);
       
  2521                         fillBrush = lg;
       
  2522                     }
       
  2523                     p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
       
  2524                 }
       
  2525                 p->setPen(dwOpt->palette.color(QPalette::Light));
       
  2526                 if (!widget || !widget->isWindow()) {
       
  2527                     p->drawLine(r.topLeft(), r.topRight());
       
  2528                     p->setPen(dwOpt->palette.color(QPalette::Dark));
       
  2529                     p->drawLine(r.bottomLeft(), r.bottomRight());            }
       
  2530             }
       
  2531             if (!dwOpt->title.isEmpty()) {
       
  2532                 QFont oldFont = p->font();
       
  2533                 if (floating) {
       
  2534                     QFont font = oldFont;
       
  2535                     font.setBold(true);
       
  2536                     p->setFont(font);
       
  2537                 }
       
  2538                 QPalette palette = dwOpt->palette;
       
  2539                 palette.setColor(QPalette::Window, inactiveCaptionTextColor);
       
  2540                 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, widget);
       
  2541                 if (verticalTitleBar) {
       
  2542                     titleRect = QRect(r.left() + rect.bottom()
       
  2543                                         - titleRect.bottom(),
       
  2544                                     r.top() + titleRect.left() - rect.left(),
       
  2545                                     titleRect.height(), titleRect.width());
       
  2546                 }
       
  2547                 proxy()->drawItemText(p, titleRect,
       
  2548                             Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
       
  2549                             dwOpt->state & State_Enabled, dwOpt->title,
       
  2550                             floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
       
  2551                 p->setFont(oldFont);
       
  2552             }
       
  2553             if (verticalTitleBar)
       
  2554                 p->restore();
       
  2555         }
       
  2556         return;
       
  2557 #endif // QT_NO_DOCKWIDGET
       
  2558     default:
       
  2559         QCommonStyle::drawControl(ce, opt, p, widget);
       
  2560     }
       
  2561 }
       
  2562 
       
  2563 /*! \reimp */
       
  2564 QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
       
  2565 {
       
  2566     QRect r;
       
  2567     switch (sr) {
       
  2568     case SE_SliderFocusRect:
       
  2569     case SE_ToolBoxTabContents:
       
  2570         r = visualRect(opt->direction, opt->rect, opt->rect);
       
  2571         break;
       
  2572     case SE_DockWidgetTitleBarText: {
       
  2573         r = QCommonStyle::subElementRect(sr, opt, w);
       
  2574         const QStyleOptionDockWidgetV2 *v2
       
  2575             = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
       
  2576         bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
       
  2577         int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
       
  2578         if (verticalTitleBar) {
       
  2579             r.adjust(0, 0, 0, -m);
       
  2580         } else {
       
  2581             if (opt->direction == Qt::LeftToRight)
       
  2582                 r.adjust(m, 0, 0, 0);
       
  2583             else
       
  2584                 r.adjust(0, 0, -m, 0);
       
  2585         }
       
  2586         break;
       
  2587     }
       
  2588     case SE_ProgressBarContents:
       
  2589         r = QCommonStyle::subElementRect(SE_ProgressBarGroove, opt, w);
       
  2590         r.adjust(3, 3, -3, -3);
       
  2591         break;
       
  2592     default:
       
  2593         r = QCommonStyle::subElementRect(sr, opt, w);
       
  2594     }
       
  2595     return r;
       
  2596 }
       
  2597 
       
  2598 #ifdef QT3_SUPPORT
       
  2599 Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalVerticalLine, (1, 129))
       
  2600 Q_GLOBAL_STATIC_WITH_ARGS(QBitmap, globalHorizontalLine, (128, 1))
       
  2601 #endif
       
  2602 
       
  2603 /*! \reimp */
       
  2604 void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
       
  2605                                        QPainter *p, const QWidget *widget) const
       
  2606 {
       
  2607     switch (cc) {
       
  2608 #ifndef QT_NO_SLIDER
       
  2609     case CC_Slider:
       
  2610         if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
       
  2611             int thickness  = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
       
  2612             int len        = proxy()->pixelMetric(PM_SliderLength, slider, widget);
       
  2613             int ticks = slider->tickPosition;
       
  2614             QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
       
  2615             QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
       
  2616 
       
  2617             if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
       
  2618                 int mid = thickness / 2;
       
  2619 
       
  2620                 if (ticks & QSlider::TicksAbove)
       
  2621                     mid += len / 8;
       
  2622                 if (ticks & QSlider::TicksBelow)
       
  2623                     mid -= len / 8;
       
  2624 
       
  2625                 p->setPen(slider->palette.shadow().color());
       
  2626                 if (slider->orientation == Qt::Horizontal) {
       
  2627                     qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
       
  2628                                    groove.width(), 4, slider->palette, true);
       
  2629                     p->drawLine(groove.x() + 1, groove.y() + mid - 1,
       
  2630                                 groove.x() + groove.width() - 3, groove.y() + mid - 1);
       
  2631                 } else {
       
  2632                     qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
       
  2633                                   4, groove.height(), slider->palette, true);
       
  2634                     p->drawLine(groove.x() + mid - 1, groove.y() + 1,
       
  2635                                 groove.x() + mid - 1, groove.y() + groove.height() - 3);
       
  2636                 }
       
  2637             }
       
  2638 
       
  2639             if (slider->subControls & SC_SliderTickmarks) {
       
  2640                 QStyleOptionSlider tmpSlider = *slider;
       
  2641                 tmpSlider.subControls = SC_SliderTickmarks;
       
  2642                 QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
       
  2643             }
       
  2644 
       
  2645             if (slider->subControls & SC_SliderHandle) {
       
  2646                 // 4444440
       
  2647                 // 4333310
       
  2648                 // 4322210
       
  2649                 // 4322210
       
  2650                 // 4322210
       
  2651                 // 4322210
       
  2652                 // *43210*
       
  2653                 // **410**
       
  2654                 // ***0***
       
  2655                 const QColor c0 = slider->palette.shadow().color();
       
  2656                 const QColor c1 = slider->palette.dark().color();
       
  2657                 // const QColor c2 = g.button();
       
  2658                 const QColor c3 = slider->palette.midlight().color();
       
  2659                 const QColor c4 = slider->palette.light().color();
       
  2660                 QBrush handleBrush;
       
  2661 
       
  2662                 if (slider->state & State_Enabled) {
       
  2663                     handleBrush = slider->palette.color(QPalette::Button);
       
  2664                 } else {
       
  2665                     handleBrush = QBrush(slider->palette.color(QPalette::Button),
       
  2666                                          Qt::Dense4Pattern);
       
  2667                 }
       
  2668 
       
  2669 
       
  2670                 int x = handle.x(), y = handle.y(),
       
  2671                    wi = handle.width(), he = handle.height();
       
  2672 
       
  2673                 int x1 = x;
       
  2674                 int x2 = x+wi-1;
       
  2675                 int y1 = y;
       
  2676                 int y2 = y+he-1;
       
  2677 
       
  2678                 Qt::Orientation orient = slider->orientation;
       
  2679                 bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
       
  2680                 bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
       
  2681 
       
  2682                 if (slider->state & State_HasFocus) {
       
  2683                     QStyleOptionFocusRect fropt;
       
  2684                     fropt.QStyleOption::operator=(*slider);
       
  2685                     fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
       
  2686                     proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
       
  2687                 }
       
  2688 
       
  2689                 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
       
  2690                     Qt::BGMode oldMode = p->backgroundMode();
       
  2691                     p->setBackgroundMode(Qt::OpaqueMode);
       
  2692                     qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
       
  2693                                    &handleBrush);
       
  2694                     p->setBackgroundMode(oldMode);
       
  2695                     return;
       
  2696                 }
       
  2697 
       
  2698                 QSliderDirection dir;
       
  2699 
       
  2700                 if (orient == Qt::Horizontal)
       
  2701                     if (tickAbove)
       
  2702                         dir = SlUp;
       
  2703                     else
       
  2704                         dir = SlDown;
       
  2705                 else
       
  2706                     if (tickAbove)
       
  2707                         dir = SlLeft;
       
  2708                     else
       
  2709                         dir = SlRight;
       
  2710 
       
  2711                 QPolygon a;
       
  2712 
       
  2713                 int d = 0;
       
  2714                 switch (dir) {
       
  2715                 case SlUp:
       
  2716                     y1 = y1 + wi/2;
       
  2717                     d =  (wi + 1) / 2 - 1;
       
  2718                     a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
       
  2719                     break;
       
  2720                 case SlDown:
       
  2721                     y2 = y2 - wi/2;
       
  2722                     d =  (wi + 1) / 2 - 1;
       
  2723                     a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
       
  2724                     break;
       
  2725                 case SlLeft:
       
  2726                     d =  (he + 1) / 2 - 1;
       
  2727                     x1 = x1 + he/2;
       
  2728                     a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
       
  2729                     break;
       
  2730                 case SlRight:
       
  2731                     d =  (he + 1) / 2 - 1;
       
  2732                     x2 = x2 - he/2;
       
  2733                     a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
       
  2734                     break;
       
  2735                 }
       
  2736 
       
  2737                 QBrush oldBrush = p->brush();
       
  2738                 p->setPen(Qt::NoPen);
       
  2739                 p->setBrush(handleBrush);
       
  2740                 Qt::BGMode oldMode = p->backgroundMode();
       
  2741                 p->setBackgroundMode(Qt::OpaqueMode);
       
  2742                 p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
       
  2743                 p->drawPolygon(a);
       
  2744                 p->setBrush(oldBrush);
       
  2745                 p->setBackgroundMode(oldMode);
       
  2746 
       
  2747                 if (dir != SlUp) {
       
  2748                     p->setPen(c4);
       
  2749                     p->drawLine(x1, y1, x2, y1);
       
  2750                     p->setPen(c3);
       
  2751                     p->drawLine(x1, y1+1, x2, y1+1);
       
  2752                 }
       
  2753                 if (dir != SlLeft) {
       
  2754                     p->setPen(c3);
       
  2755                     p->drawLine(x1+1, y1+1, x1+1, y2);
       
  2756                     p->setPen(c4);
       
  2757                     p->drawLine(x1, y1, x1, y2);
       
  2758                 }
       
  2759                 if (dir != SlRight) {
       
  2760                     p->setPen(c0);
       
  2761                     p->drawLine(x2, y1, x2, y2);
       
  2762                     p->setPen(c1);
       
  2763                     p->drawLine(x2-1, y1+1, x2-1, y2-1);
       
  2764                 }
       
  2765                 if (dir != SlDown) {
       
  2766                     p->setPen(c0);
       
  2767                     p->drawLine(x1, y2, x2, y2);
       
  2768                     p->setPen(c1);
       
  2769                     p->drawLine(x1+1, y2-1, x2-1, y2-1);
       
  2770                 }
       
  2771 
       
  2772                 switch (dir) {
       
  2773                 case SlUp:
       
  2774                     p->setPen(c4);
       
  2775                     p->drawLine(x1, y1, x1+d, y1-d);
       
  2776                     p->setPen(c0);
       
  2777                     d = wi - d - 1;
       
  2778                     p->drawLine(x2, y1, x2-d, y1-d);
       
  2779                     d--;
       
  2780                     p->setPen(c3);
       
  2781                     p->drawLine(x1+1, y1, x1+1+d, y1-d);
       
  2782                     p->setPen(c1);
       
  2783                     p->drawLine(x2-1, y1, x2-1-d, y1-d);
       
  2784                     break;
       
  2785                 case SlDown:
       
  2786                     p->setPen(c4);
       
  2787                     p->drawLine(x1, y2, x1+d, y2+d);
       
  2788                     p->setPen(c0);
       
  2789                     d = wi - d - 1;
       
  2790                     p->drawLine(x2, y2, x2-d, y2+d);
       
  2791                     d--;
       
  2792                     p->setPen(c3);
       
  2793                     p->drawLine(x1+1, y2, x1+1+d, y2+d);
       
  2794                     p->setPen(c1);
       
  2795                     p->drawLine(x2-1, y2, x2-1-d, y2+d);
       
  2796                     break;
       
  2797                 case SlLeft:
       
  2798                     p->setPen(c4);
       
  2799                     p->drawLine(x1, y1, x1-d, y1+d);
       
  2800                     p->setPen(c0);
       
  2801                     d = he - d - 1;
       
  2802                     p->drawLine(x1, y2, x1-d, y2-d);
       
  2803                     d--;
       
  2804                     p->setPen(c3);
       
  2805                     p->drawLine(x1, y1+1, x1-d, y1+1+d);
       
  2806                     p->setPen(c1);
       
  2807                     p->drawLine(x1, y2-1, x1-d, y2-1-d);
       
  2808                     break;
       
  2809                 case SlRight:
       
  2810                     p->setPen(c4);
       
  2811                     p->drawLine(x2, y1, x2+d, y1+d);
       
  2812                     p->setPen(c0);
       
  2813                     d = he - d - 1;
       
  2814                     p->drawLine(x2, y2, x2+d, y2-d);
       
  2815                     d--;
       
  2816                     p->setPen(c3);
       
  2817                     p->drawLine(x2, y1+1, x2+d, y1+1+d);
       
  2818                     p->setPen(c1);
       
  2819                     p->drawLine(x2, y2-1, x2+d, y2-1-d);
       
  2820                     break;
       
  2821                 }
       
  2822             }
       
  2823         }
       
  2824         break;
       
  2825 #endif // QT_NO_SLIDER
       
  2826 #ifndef QT_NO_SCROLLBAR
       
  2827     case CC_ScrollBar:
       
  2828         if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
       
  2829             QStyleOptionSlider newScrollbar = *scrollbar;
       
  2830             if (scrollbar->minimum == scrollbar->maximum)
       
  2831                 newScrollbar.state &= ~State_Enabled; //do not draw the slider.
       
  2832             QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
       
  2833         }
       
  2834         break;
       
  2835 #endif // QT_NO_SCROLLBAR
       
  2836 #ifdef QT3_SUPPORT
       
  2837     case CC_Q3ListView:
       
  2838         if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
       
  2839             int i;
       
  2840             if (lv->subControls & SC_Q3ListView)
       
  2841                 QCommonStyle::drawComplexControl(cc, lv, p, widget);
       
  2842             if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
       
  2843                 if (lv->items.isEmpty())
       
  2844                     break;
       
  2845                 QStyleOptionQ3ListViewItem item = lv->items.at(0);
       
  2846                 int y = lv->rect.y();
       
  2847                 int c;
       
  2848                 int dotoffset = 0;
       
  2849                 QPolygon dotlines;
       
  2850                 if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand)) {
       
  2851                     c = 2;
       
  2852                     dotlines.resize(2);
       
  2853                     dotlines[0] = QPoint(lv->rect.right(), lv->rect.top());
       
  2854                     dotlines[1] = QPoint(lv->rect.right(), lv->rect.bottom());
       
  2855                 } else {
       
  2856                     int linetop = 0, linebot = 0;
       
  2857                     // each branch needs at most two lines, ie. four end points
       
  2858                     dotoffset = (item.itemY + item.height - y) % 2;
       
  2859                     dotlines.resize(item.childCount * 4);
       
  2860                     c = 0;
       
  2861 
       
  2862                     // skip the stuff above the exposed rectangle
       
  2863                     for (i = 1; i < lv->items.size(); ++i) {
       
  2864                         QStyleOptionQ3ListViewItem child = lv->items.at(i);
       
  2865                         if (child.height + y > 0)
       
  2866                             break;
       
  2867                         y += child.totalHeight;
       
  2868                     }
       
  2869                     int bx = lv->rect.width() / 2;
       
  2870 
       
  2871                     // paint stuff in the magical area
       
  2872                     while (i < lv->items.size() && y < lv->rect.height()) {
       
  2873                         QStyleOptionQ3ListViewItem child = lv->items.at(i);
       
  2874                         if (child.features & QStyleOptionQ3ListViewItem::Visible) {
       
  2875                             int lh;
       
  2876                             if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
       
  2877                                 lh = child.height;
       
  2878                             else
       
  2879                                 lh = p->fontMetrics().height() + 2 * lv->itemMargin;
       
  2880                             lh = qMax(lh, QApplication::globalStrut().height());
       
  2881                             if (lh % 2 > 0)
       
  2882                                 ++lh;
       
  2883                             linebot = y + lh / 2;
       
  2884                             if (child.features & QStyleOptionQ3ListViewItem::Expandable
       
  2885                                 || (child.childCount > 0 && child.height > 0)) {
       
  2886                                 // needs a box
       
  2887                                 p->setPen(lv->palette.mid().color());
       
  2888                                 p->drawRect(bx - 4, linebot - 4, 8, 8);
       
  2889                                 // plus or minus
       
  2890                                 p->setPen(lv->palette.text().color());
       
  2891                                 p->drawLine(bx - 2, linebot, bx + 2, linebot);
       
  2892                                 if (!(child.state & State_Open))
       
  2893                                     p->drawLine(bx, linebot - 2, bx, linebot + 2);
       
  2894                                 // dotlinery
       
  2895                                 p->setPen(lv->palette.mid().color());
       
  2896                                 dotlines[c++] = QPoint(bx, linetop);
       
  2897                                 dotlines[c++] = QPoint(bx, linebot - 4);
       
  2898                                 dotlines[c++] = QPoint(bx + 5, linebot);
       
  2899                                 dotlines[c++] = QPoint(lv->rect.width(), linebot);
       
  2900                                 linetop = linebot + 5;
       
  2901                             } else {
       
  2902                                 // just dotlinery
       
  2903                                 dotlines[c++] = QPoint(bx+1, linebot -1);
       
  2904                                 dotlines[c++] = QPoint(lv->rect.width(), linebot -1);
       
  2905                             }
       
  2906                             y += child.totalHeight;
       
  2907                         }
       
  2908                         ++i;
       
  2909                     }
       
  2910 
       
  2911                     // Expand line height to edge of rectangle if there's any
       
  2912                     // visible child below
       
  2913                     while (i < lv->items.size() && lv->items.at(i).height <= 0)
       
  2914                         ++i;
       
  2915                     if (i < lv->items.size())
       
  2916                         linebot = lv->rect.height();
       
  2917 
       
  2918                     if (linetop < linebot) {
       
  2919                         dotlines[c++] = QPoint(bx, linetop);
       
  2920                         dotlines[c++] = QPoint(bx, linebot);
       
  2921                     }
       
  2922                 }
       
  2923                 p->setPen(lv->palette.text().color());
       
  2924                 QBitmap *verticalLine = globalVerticalLine();
       
  2925                 QBitmap *horizontalLine = globalHorizontalLine();
       
  2926                 static bool isInit = false;
       
  2927                 if (!isInit) {
       
  2928                     isInit = true;
       
  2929                     // make 128*1 and 1*128 bitmaps that can be used for
       
  2930                     // drawing the right sort of lines.
       
  2931                     verticalLine->clear();
       
  2932                     horizontalLine->clear();
       
  2933                     QPolygon a(64);
       
  2934                     QPainter p;
       
  2935                     p.begin(verticalLine);
       
  2936                     for(i = 0; i < 64; ++i)
       
  2937                         a.setPoint(i, 0, i * 2 + 1);
       
  2938                     p.setPen(Qt::color1);
       
  2939                     p.drawPoints(a);
       
  2940                     p.end();
       
  2941                     QApplication::flush();
       
  2942                     verticalLine->setMask(*verticalLine);
       
  2943                     p.begin(horizontalLine);
       
  2944                     for(i = 0; i < 64; ++i)
       
  2945                         a.setPoint(i, i * 2 + 1, 0);
       
  2946                     p.setPen(Qt::color1);
       
  2947                     p.drawPoints(a);
       
  2948                     p.end();
       
  2949                     QApplication::flush();
       
  2950                     horizontalLine->setMask(*horizontalLine);
       
  2951                 }
       
  2952 
       
  2953                 int line; // index into dotlines
       
  2954                 if (lv->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
       
  2955                     // assumptions here: lines are horizontal or vertical.
       
  2956                     // lines always start with the numerically lowest
       
  2957                     // coordinate.
       
  2958 
       
  2959                     // point ... relevant coordinate of current point
       
  2960                     // end ..... same coordinate of the end of the current line
       
  2961                     // other ... the other coordinate of the current point/line
       
  2962                     if (dotlines[line].y() == dotlines[line+1].y()) {
       
  2963                         int end = dotlines[line + 1].x();
       
  2964                         int point = dotlines[line].x();
       
  2965                         int other = dotlines[line].y();
       
  2966                         while (point < end) {
       
  2967                             int i = 128;
       
  2968                             if (i + point > end)
       
  2969                                 i = end-point;
       
  2970                             p->drawPixmap(point, other, *horizontalLine, 0, 0, i, 1);
       
  2971                             point += i;
       
  2972                         }
       
  2973                     } else {
       
  2974                         int end = dotlines[line + 1].y();
       
  2975                         int point = dotlines[line].y();
       
  2976                         int other = dotlines[line].x();
       
  2977                         int pixmapoffset = ((point & 1) != dotoffset) ? 1 : 0;
       
  2978                         while(point < end) {
       
  2979                             int i = 128;
       
  2980                             if (i + point > end)
       
  2981                                 i = end-point;
       
  2982                             p->drawPixmap(other, point, *verticalLine, 0, pixmapoffset, 1, i);
       
  2983                             point += i;
       
  2984                         }
       
  2985                     }
       
  2986                 }
       
  2987             }
       
  2988         }
       
  2989         break;
       
  2990 #endif // QT3_SUPPORT
       
  2991 #ifndef QT_NO_COMBOBOX
       
  2992     case CC_ComboBox:
       
  2993         if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
       
  2994             QBrush editBrush = cmb->palette.brush(QPalette::Base);
       
  2995             if ((cmb->subControls & SC_ComboBoxFrame)) {
       
  2996                 if (cmb->frame) {
       
  2997                     QPalette shadePal = opt->palette;
       
  2998                     shadePal.setColor(QPalette::Midlight, shadePal.button().color());
       
  2999                     qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
       
  3000                 }
       
  3001                 else {
       
  3002                     p->fillRect(opt->rect, editBrush);
       
  3003                 }
       
  3004             }
       
  3005             if (cmb->subControls & SC_ComboBoxArrow) {
       
  3006                 State flags = State_None;
       
  3007 
       
  3008                 QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
       
  3009                 bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
       
  3010                                    && cmb->state & State_Sunken;
       
  3011                 if (sunkenArrow) {
       
  3012                     p->setPen(cmb->palette.dark().color());
       
  3013                     p->setBrush(cmb->palette.brush(QPalette::Button));
       
  3014                     p->drawRect(ar.adjusted(0,0,-1,-1));
       
  3015                 } else {
       
  3016                     // Make qDrawWinButton use the right colors for drawing the shade of the button
       
  3017                     QPalette pal(cmb->palette);
       
  3018                     pal.setColor(QPalette::Button, cmb->palette.light().color());
       
  3019                     pal.setColor(QPalette::Light, cmb->palette.button().color());
       
  3020                     qDrawWinButton(p, ar, pal, false,
       
  3021                                    &cmb->palette.brush(QPalette::Button));
       
  3022                 }
       
  3023 
       
  3024                 ar.adjust(2, 2, -2, -2);
       
  3025                 if (opt->state & State_Enabled)
       
  3026                     flags |= State_Enabled;
       
  3027                 if (opt->state & State_HasFocus)
       
  3028                     flags |= State_HasFocus;
       
  3029 
       
  3030                 if (sunkenArrow)
       
  3031                     flags |= State_Sunken;
       
  3032                 QStyleOption arrowOpt(0);
       
  3033                 arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
       
  3034                 arrowOpt.palette = cmb->palette;
       
  3035                 arrowOpt.state = flags;
       
  3036                 proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
       
  3037             }
       
  3038 
       
  3039             if (cmb->subControls & SC_ComboBoxEditField) {
       
  3040                 QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
       
  3041                 if (cmb->state & State_HasFocus && !cmb->editable)
       
  3042                     p->fillRect(re.x(), re.y(), re.width(), re.height(),
       
  3043                                 cmb->palette.brush(QPalette::Highlight));
       
  3044 
       
  3045                 if (cmb->state & State_HasFocus) {
       
  3046                     p->setPen(cmb->palette.highlightedText().color());
       
  3047                     p->setBackground(cmb->palette.highlight());
       
  3048 
       
  3049                 } else {
       
  3050                     p->setPen(cmb->palette.text().color());
       
  3051                     p->setBackground(cmb->palette.background());
       
  3052                 }
       
  3053 
       
  3054                 if (cmb->state & State_HasFocus && !cmb->editable) {
       
  3055                     QStyleOptionFocusRect focus;
       
  3056                     focus.QStyleOption::operator=(*cmb);
       
  3057                     focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
       
  3058                     focus.state |= State_FocusAtBorder;
       
  3059                     focus.backgroundColor = cmb->palette.highlight().color();
       
  3060                     proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
       
  3061                 }
       
  3062             }
       
  3063         }
       
  3064         break;
       
  3065 #endif // QT_NO_COMBOBOX
       
  3066 #ifndef QT_NO_SPINBOX
       
  3067     case CC_SpinBox:
       
  3068         if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
       
  3069             QStyleOptionSpinBox copy = *sb;
       
  3070             PrimitiveElement pe;
       
  3071             bool enabled = opt->state & State_Enabled;
       
  3072             if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
       
  3073                 QBrush editBrush = sb->palette.brush(QPalette::Base);
       
  3074                 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
       
  3075                 QPalette shadePal = sb->palette;
       
  3076                 shadePal.setColor(QPalette::Midlight, shadePal.button().color());
       
  3077                 qDrawWinPanel(p, r, shadePal, true, &editBrush);
       
  3078             }
       
  3079 
       
  3080             QPalette shadePal(opt->palette);
       
  3081             shadePal.setColor(QPalette::Button, opt->palette.light().color());
       
  3082             shadePal.setColor(QPalette::Light, opt->palette.button().color());
       
  3083 
       
  3084             if (sb->subControls & SC_SpinBoxUp) {
       
  3085                 copy.subControls = SC_SpinBoxUp;
       
  3086                 QPalette pal2 = sb->palette;
       
  3087                 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
       
  3088                     pal2.setCurrentColorGroup(QPalette::Disabled);
       
  3089                     copy.state &= ~State_Enabled;
       
  3090                 }
       
  3091 
       
  3092                 copy.palette = pal2;
       
  3093 
       
  3094                 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
       
  3095                     copy.state |= State_On;
       
  3096                     copy.state |= State_Sunken;
       
  3097                 } else {
       
  3098                     copy.state |= State_Raised;
       
  3099                     copy.state &= ~State_Sunken;
       
  3100                 }
       
  3101                 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
       
  3102                                                                        : PE_IndicatorSpinUp);
       
  3103 
       
  3104                 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
       
  3105                 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
       
  3106                                 &copy.palette.brush(QPalette::Button));
       
  3107                 copy.rect.adjust(4, 1, -5, -1);
       
  3108                 if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) ) {
       
  3109                     QStyleOptionSpinBox lightCopy = copy;
       
  3110                     lightCopy.rect.adjust(1, 1, 1, 1);
       
  3111                     lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
       
  3112                     proxy()->drawPrimitive(pe, &lightCopy, p, widget);
       
  3113                 }
       
  3114                 proxy()->drawPrimitive(pe, &copy, p, widget);
       
  3115             }
       
  3116 
       
  3117             if (sb->subControls & SC_SpinBoxDown) {
       
  3118                 copy.subControls = SC_SpinBoxDown;
       
  3119                 copy.state = sb->state;
       
  3120                 QPalette pal2 = sb->palette;
       
  3121                 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
       
  3122                     pal2.setCurrentColorGroup(QPalette::Disabled);
       
  3123                     copy.state &= ~State_Enabled;
       
  3124                 }
       
  3125                 copy.palette = pal2;
       
  3126 
       
  3127                 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
       
  3128                     copy.state |= State_On;
       
  3129                     copy.state |= State_Sunken;
       
  3130                 } else {
       
  3131                     copy.state |= State_Raised;
       
  3132                     copy.state &= ~State_Sunken;
       
  3133                 }
       
  3134                 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
       
  3135                                                                        : PE_IndicatorSpinDown);
       
  3136 
       
  3137                 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
       
  3138                 qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
       
  3139                                 &copy.palette.brush(QPalette::Button));
       
  3140                 copy.rect.adjust(4, 0, -5, -1);
       
  3141                 if (!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) ) {
       
  3142                     QStyleOptionSpinBox lightCopy = copy;
       
  3143                     lightCopy.rect.adjust(1, 1, 1, 1);
       
  3144                     lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
       
  3145                     proxy()->drawPrimitive(pe, &lightCopy, p, widget);
       
  3146                 }
       
  3147                 proxy()->drawPrimitive(pe, &copy, p, widget);
       
  3148             }
       
  3149         }
       
  3150         break;
       
  3151 #endif // QT_NO_SPINBOX
       
  3152 
       
  3153     default:
       
  3154         QCommonStyle::drawComplexControl(cc, opt, p, widget);
       
  3155     }
       
  3156 }
       
  3157 
       
  3158 /*! \reimp */
       
  3159 QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
       
  3160                                       const QSize &csz, const QWidget *widget) const
       
  3161 {
       
  3162     QSize sz(csz);
       
  3163     switch (ct) {
       
  3164     case CT_PushButton:
       
  3165         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
       
  3166             sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
       
  3167             int w = sz.width(),
       
  3168                 h = sz.height();
       
  3169             int defwidth = 0;
       
  3170             if (btn->features & QStyleOptionButton::AutoDefaultButton)
       
  3171                 defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
       
  3172             int minwidth = int(QStyleHelper::dpiScaled(75.));
       
  3173             int minheight = int(QStyleHelper::dpiScaled(23.));
       
  3174 
       
  3175 #ifndef QT_QWS_SMALL_PUSHBUTTON
       
  3176             if (w < minwidth + defwidth && !btn->text.isEmpty())
       
  3177                 w = minwidth + defwidth;
       
  3178             if (h < minheight + defwidth)
       
  3179                 h = minheight + defwidth;
       
  3180 #endif
       
  3181             sz = QSize(w, h);
       
  3182         }
       
  3183         break;
       
  3184 #ifndef QT_NO_MENU
       
  3185     case CT_MenuItem:
       
  3186         if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
       
  3187             int w = sz.width();
       
  3188             sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
       
  3189 
       
  3190             if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
       
  3191                 sz = QSize(10, QWindowsStylePrivate::windowsSepHeight);
       
  3192             }
       
  3193             else if (mi->icon.isNull()) {
       
  3194                 sz.setHeight(sz.height() - 2);
       
  3195                 w -= 6;
       
  3196             }
       
  3197 
       
  3198             if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
       
  3199                 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
       
  3200                 sz.setHeight(qMax(sz.height(),
       
  3201                                   mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
       
  3202                                   + 2 * QWindowsStylePrivate::windowsItemFrame));
       
  3203             }
       
  3204             int maxpmw = mi->maxIconWidth;
       
  3205             int tabSpacing = 20;
       
  3206             if (mi->text.contains(QLatin1Char('\t')))
       
  3207                 w += tabSpacing;
       
  3208             else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
       
  3209                 w += 2 * QWindowsStylePrivate::windowsArrowHMargin;
       
  3210             else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
       
  3211                 // adjust the font and add the difference in size.
       
  3212                 // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
       
  3213                 QFontMetrics fm(mi->font);
       
  3214                 QFont fontBold = mi->font;
       
  3215                 fontBold.setBold(true);
       
  3216                 QFontMetrics fmBold(fontBold);
       
  3217                 w += fmBold.width(mi->text) - fm.width(mi->text);
       
  3218             }
       
  3219 
       
  3220             int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
       
  3221             w += checkcol;
       
  3222             w += QWindowsStylePrivate::windowsRightBorder + 10;
       
  3223             sz.setWidth(w);
       
  3224         }
       
  3225         break;
       
  3226 #endif // QT_NO_MENU
       
  3227 #ifndef QT_NO_MENUBAR
       
  3228     case CT_MenuBarItem:
       
  3229         if (!sz.isEmpty())
       
  3230             sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
       
  3231         break;
       
  3232 #endif
       
  3233                 // Otherwise, fall through
       
  3234     case CT_ToolButton:
       
  3235         if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
       
  3236             return sz += QSize(7, 6);
       
  3237         // Otherwise, fall through
       
  3238 
       
  3239     default:
       
  3240         sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
       
  3241     }
       
  3242     return sz;
       
  3243 }
       
  3244 
       
  3245 /*!
       
  3246     \internal
       
  3247 */
       
  3248 QIcon QWindowsStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
       
  3249                                                 const QWidget *widget) const
       
  3250 {
       
  3251     QIcon icon;
       
  3252     QPixmap pixmap;
       
  3253 #ifdef Q_OS_WIN
       
  3254     switch (standardIcon) {
       
  3255     case SP_FileDialogNewFolder:
       
  3256     {
       
  3257         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3258             pixmap = loadIconFromShell32(319, size);
       
  3259             icon.addPixmap(pixmap, QIcon::Normal);
       
  3260         }
       
  3261         break;
       
  3262     }
       
  3263     case SP_DirHomeIcon:
       
  3264     {
       
  3265         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3266             pixmap = loadIconFromShell32(235, size);
       
  3267             icon.addPixmap(pixmap, QIcon::Normal);
       
  3268         }
       
  3269         break;
       
  3270     }
       
  3271     case SP_DirIcon:
       
  3272         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3273             pixmap = loadIconFromShell32(4, size);
       
  3274             icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
       
  3275             pixmap = loadIconFromShell32(5, size);
       
  3276             icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
       
  3277         }
       
  3278         break;
       
  3279     case SP_DirLinkIcon:
       
  3280         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3281             QPixmap link = loadIconFromShell32(30, size);
       
  3282             pixmap = loadIconFromShell32(4, size);
       
  3283             if (!pixmap.isNull() && !link.isNull()) {
       
  3284                 QPainter painter(&pixmap);
       
  3285                 painter.drawPixmap(0, 0, size, size, link);
       
  3286                 icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
       
  3287             }
       
  3288             link = loadIconFromShell32(30, size);
       
  3289             pixmap = loadIconFromShell32(5, size);
       
  3290             if (!pixmap.isNull() && !link.isNull()) {
       
  3291                 QPainter painter(&pixmap);
       
  3292                 painter.drawPixmap(0, 0, size, size, link);
       
  3293                 icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
       
  3294             }
       
  3295         }
       
  3296         break;
       
  3297     case SP_FileIcon:
       
  3298         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3299             pixmap = loadIconFromShell32(1, size);
       
  3300             icon.addPixmap(pixmap, QIcon::Normal);
       
  3301         }
       
  3302         break;
       
  3303     case SP_ComputerIcon:
       
  3304         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3305             pixmap = loadIconFromShell32(16, size);
       
  3306             icon.addPixmap(pixmap, QIcon::Normal);
       
  3307         }
       
  3308         break;
       
  3309 
       
  3310     case SP_DesktopIcon:
       
  3311         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3312             pixmap = loadIconFromShell32(35, size);
       
  3313             icon.addPixmap(pixmap, QIcon::Normal);
       
  3314         }
       
  3315         break;
       
  3316     case SP_DriveCDIcon:
       
  3317     case SP_DriveDVDIcon:
       
  3318         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3319             pixmap = loadIconFromShell32(12, size);
       
  3320             icon.addPixmap(pixmap, QIcon::Normal);
       
  3321         }
       
  3322         break;
       
  3323     case SP_DriveNetIcon:
       
  3324         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3325             pixmap = loadIconFromShell32(10, size);
       
  3326             icon.addPixmap(pixmap, QIcon::Normal);
       
  3327         }
       
  3328         break;
       
  3329     case SP_DriveHDIcon:
       
  3330         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3331             pixmap = loadIconFromShell32(9, size);
       
  3332             icon.addPixmap(pixmap, QIcon::Normal);
       
  3333         }
       
  3334         break;
       
  3335     case SP_DriveFDIcon:
       
  3336         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3337             pixmap = loadIconFromShell32(7, size);
       
  3338             icon.addPixmap(pixmap, QIcon::Normal);
       
  3339         }
       
  3340         break;
       
  3341     case SP_FileLinkIcon:
       
  3342         for (int size = 16 ; size <= 32 ; size += 16) {
       
  3343             QPixmap link;
       
  3344             link = loadIconFromShell32(30, size);
       
  3345             pixmap = loadIconFromShell32(1, size);
       
  3346             if (!pixmap.isNull() && !link.isNull()) {
       
  3347                 QPainter painter(&pixmap);
       
  3348                 painter.drawPixmap(0, 0, size, size, link);
       
  3349                 icon.addPixmap(pixmap, QIcon::Normal);
       
  3350             }
       
  3351         }
       
  3352         break;
       
  3353     case SP_VistaShield:
       
  3354         {
       
  3355             if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
       
  3356                 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based
       
  3357                 && pSHGetStockIconInfo)
       
  3358             {
       
  3359                 icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
       
  3360                 QSHSTOCKICONINFO iconInfo; //append large icon
       
  3361                 memset(&iconInfo, 0, sizeof(iconInfo));
       
  3362                 iconInfo.cbSize = sizeof(iconInfo);
       
  3363                 if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
       
  3364                     icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon));
       
  3365                     DestroyIcon(iconInfo.hIcon);
       
  3366                 }
       
  3367             }
       
  3368         }
       
  3369         break;
       
  3370     default:
       
  3371         break;
       
  3372     }
       
  3373 #endif
       
  3374 
       
  3375     if (icon.isNull())
       
  3376         icon = QCommonStyle::standardIconImplementation(standardIcon, option, widget);
       
  3377     return icon;
       
  3378 }
       
  3379 
       
  3380 
       
  3381 
       
  3382 QT_END_NAMESPACE
       
  3383 
       
  3384 #endif // QT_NO_STYLE_WINDOWS