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