QWindowsXPStyle Class Reference

#include <qwindowsxpstyle.h>

Inheritance diagram for QWindowsXPStyle:

Inheritance graph
[legend]
Collaboration diagram for QWindowsXPStyle:

Collaboration graph
[legend]
List of all members.

Detailed Description

The QWindowsXPStyle class provides a Microsoft WindowsXP-like look and feel.

Warning:
This style is only available on the Windows XP platform because it makes use of Windows XP's style engine.
Most of the functions are documented in the base classes QWindowsStyle, QCommonStyle, and QStyle, but the QWindowsXPStyle overloads of drawComplexControl(), drawControl(), drawControlMask(), drawPrimitive(), subControlRect(), and sizeFromContents(), are documented here.

qwindowsxpstyle.png

See also:
QMacStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle

Definition at line 36 of file qwindowsxpstyle.h.

Public Member Functions

 QWindowsXPStyle ()
 ~QWindowsXPStyle ()
void unpolish (QApplication *)
void polish (QApplication *)
void polish (QWidget *)
void polish (QPalette &)
void unpolish (QWidget *)
void drawPrimitive (PrimitiveElement pe, const QStyleOption *option, QPainter *p, const QWidget *widget=0) const
void drawControl (ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *wwidget=0) const
QRect subElementRect (SubElement r, const QStyleOption *option, const QWidget *widget=0) const
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget=0) const
void drawComplexControl (ComplexControl cc, const QStyleOptionComplex *option, QPainter *p, const QWidget *widget=0) const
QSize sizeFromContents (ContentsType ct, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=0) const
int pixelMetric (PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
int styleHint (StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
QPalette standardPalette () const
QPixmap standardPixmap (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const

Protected Slots

QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const

Private Attributes

void * reserved

Friends

class QStyleFactory


Constructor & Destructor Documentation

QWindowsXPStyle::QWindowsXPStyle (  ) 

Constructs a QWindowsStyle

Definition at line 1255 of file qwindowsxpstyle.cpp.

01256     : QWindowsStyle(*new QWindowsXPStylePrivate)
01257 {
01258 }

QWindowsXPStyle::~QWindowsXPStyle (  ) 

Destroys the style.

Definition at line 1263 of file qwindowsxpstyle.cpp.

01264 {
01265 }


Member Function Documentation

void QWindowsXPStyle::unpolish ( QApplication app  )  [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1268 of file qwindowsxpstyle.cpp.

References QWindowsStyle::unpolish().

01269 {
01270     QWindowsStyle::unpolish(app);
01271 }

Here is the call graph for this function:

void QWindowsXPStyle::polish ( QApplication app  )  [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1274 of file qwindowsxpstyle.cpp.

References QWindowsStyle::polish(), and QWindowsXPStylePrivate::useXP().

01275 {
01276     QWindowsStyle::polish(app);
01277     if (!QWindowsXPStylePrivate::useXP())
01278         return;
01279 }

Here is the call graph for this function:

void QWindowsXPStyle::polish ( QWidget widget  )  [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1282 of file qwindowsxpstyle.cpp.

References d, XPThemeData::handle(), pGetThemeColor, QWindowsStyle::polish(), qRgb(), TMT_TEXTCOLOR, QWindowsXPStylePrivate::useXP(), Qt::WA_ContentsPropagated, and Qt::WA_Hover.

01283 {
01284     QWindowsStyle::polish(widget);
01285     if (!QWindowsXPStylePrivate::useXP())
01286         return;
01287 
01288     if (qobject_cast<QAbstractButton*>(widget)
01289         || qobject_cast<QToolButton*>(widget)
01290         || qobject_cast<QTabBar*>(widget)
01291         || qobject_cast<QComboBox*>(widget)
01292         || qobject_cast<QScrollBar*>(widget)
01293         || qobject_cast<QSlider*>(widget)
01294         || qobject_cast<QHeaderView*>(widget)
01295         || qobject_cast<QAbstractSpinBox*>(widget)
01296         || qobject_cast<QSpinBox*>(widget)
01297         || widget->inherits("QWorkspaceChild")
01298         || widget->inherits("Q3TitleBar"))
01299         widget->setAttribute(Qt::WA_Hover);
01300 
01301 #ifndef QT_NO_RUBBERBAND
01302     if (qobject_cast<QRubberBand*>(widget)) {
01303         widget->setWindowOpacity(0.6);
01304     }
01305 #endif
01306     if (qobject_cast<QStackedWidget*>(widget) &&
01307                qobject_cast<QTabWidget*>(widget->parent()))
01308         widget->parentWidget()->setAttribute(Qt::WA_ContentsPropagated);
01309 
01310     Q_D(QWindowsXPStyle);
01311     if (!d->hasInitColors) {
01312         // Get text color for groupbox labels
01313         COLORREF cref;
01314         XPThemeData theme(0, 0, "BUTTON", 0, 0);
01315         pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
01316         d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
01317         pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
01318         d->groupBoxTextColorDisabled = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
01319         // Where does this color come from?
01320         //pGetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
01321         d->sliderTickColor = qRgb(165, 162, 148);
01322         d->hasInitColors = true;
01323     }
01324 }

Here is the call graph for this function:

void QWindowsXPStyle::polish ( QPalette pal  )  [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1327 of file qwindowsxpstyle.cpp.

References QPalette::AlternateBase, QPalette::base(), QBrush::color(), QColor::dark(), QWindowsStyle::polish(), and QPalette::setBrush().

01328 {
01329     QWindowsStyle::polish(pal);
01330     pal.setBrush(QPalette::AlternateBase, pal.base().color().dark(110));
01331 }

Here is the call graph for this function:

void QWindowsXPStyle::unpolish ( QWidget widget  )  [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1334 of file qwindowsxpstyle.cpp.

References d, QWindowsStyle::unpolish(), QWindowsXPStylePrivate::useXP(), and Qt::WA_Hover.

01335 {
01336 #ifndef QT_NO_RUBBERBAND
01337     if (qobject_cast<QRubberBand*>(widget)) {
01338         widget->setWindowOpacity(1.0);
01339     }
01340 #endif
01341     Q_D(QWindowsXPStyle);
01342     // Unpolish of widgets is the first thing that
01343     // happens when a theme changes, or the theme
01344     // engine is turned off. So we detect it here.
01345     bool oldState = QWindowsXPStylePrivate::useXP();
01346     bool newState = QWindowsXPStylePrivate::useXP(true);
01347     if ((oldState != newState) && newState) {
01348         d->cleanup(true);
01349         d->init(true);
01350     } else {
01351         // Cleanup handle map, if just changing style,
01352         // or turning it on. In both cases the values
01353         // already in the map might be old (other style).
01354         d->cleanupHandleMap();
01355     }
01356     if (qobject_cast<QAbstractButton*>(widget)
01357         || qobject_cast<QToolButton*>(widget)
01358         || qobject_cast<QTabBar*>(widget)
01359         || qobject_cast<QComboBox*>(widget)
01360         || qobject_cast<QScrollBar*>(widget)
01361         || qobject_cast<QSlider*>(widget)
01362         || qobject_cast<QHeaderView*>(widget)
01363         || qobject_cast<QAbstractSpinBox*>(widget)
01364         || qobject_cast<QSpinBox*>(widget)
01365         || widget->inherits("QWorkspaceChild")
01366         || widget->inherits("Q3TitleBar"))
01367         widget->setAttribute(Qt::WA_Hover, false);
01368     QWindowsStyle::unpolish(widget);
01369 }

Here is the call graph for this function:

void QWindowsXPStyle::drawPrimitive ( PrimitiveElement  pe,
const QStyleOption option,
QPainter p,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1452 of file qwindowsxpstyle.cpp.

References QRect::adjust(), QRect::adjusted(), QPalette::Base, BT_IMAGEFILE, d, Qt::Dense4Pattern, QWindowsStyle::drawPrimitive(), QStyleOptionFrameV2::features, flags, QStyleOptionFrameV2::Flat, XPThemeData::handle(), header(), Qt::Horizontal, QObject::inherits(), XPThemeData::isValid(), XPThemeData::mirrorHorizontally, XPThemeData::mirrorVertically, name, XPThemeData::noBorder, XPThemeData::noContent, p, QObject::parent(), XPThemeData::partId, QStyle::PE_Frame, QStyle::PE_FrameDockWidget, QStyle::PE_FrameGroupBox, QStyle::PE_FrameLineEdit, QStyle::PE_FrameMenu, QStyle::PE_FrameStatusBar, QStyle::PE_FrameTabBarBase, QStyle::PE_FrameTabWidget, QStyle::PE_FrameWindow, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorBranch, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_IndicatorCheckBox, QStyle::PE_IndicatorDockWidgetResizeHandle, QStyle::PE_IndicatorHeaderArrow, QStyle::PE_IndicatorProgressChunk, QStyle::PE_IndicatorRadioButton, QStyle::PE_IndicatorToolBarHandle, QStyle::PE_IndicatorToolBarSeparator, QStyle::PE_IndicatorViewItemCheck, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonTool, QStyle::PE_PanelLineEdit, QStyle::PE_PanelMenuBar, QStyle::PE_Q3DockWindowSeparator, pGetThemeColor, pGetThemeEnumValue, pGetThemePropertyOrigin, pixelMetric(), QStyle::PM_DockWidgetFrameWidth, qRgb(), XPThemeData::rect, QStyleOption::rect, QWidget::rect(), Qt::RightToLeft, XPThemeData::rotate, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, QStyle::SE_TabWidgetTabContents, QStyleOptionHeader::SortDown, QStyleOptionHeader::SortUp, QStyleOption::state, QStyle::State_Active, QStyle::State_Children, QStyle::State_Enabled, QStyle::State_Horizontal, QStyle::State_Item, QStyle::State_MouseOver, QStyle::State_NoChange, QStyle::State_On, QStyle::State_Open, QStyle::State_Raised, QStyle::State_Sibling, QStyle::State_Sunken, XPThemeData::stateId, subElementRect(), TMT_BGTYPE, TMT_FILLCOLOR, QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, QWindowsXPStylePrivate::useXP(), QRect::width(), QRect::x(), and QRect::y().

Referenced by drawComplexControl(), and drawControl().

01454 {
01455     QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
01456 
01457     if (!QWindowsXPStylePrivate::useXP()) {
01458         QWindowsStyle::drawPrimitive(pe, option, p, widget);
01459         return;
01460     }
01461 
01462     QString name;
01463     int partId = 0;
01464     int stateId = 0;
01465     QRect rect = option->rect;
01466     State flags = option->state;
01467     bool hMirrored = false;
01468     bool vMirrored = false;
01469     bool noBorder = false;
01470     bool noContent = false;
01471     int  rotate = 0;
01472 
01473     switch (pe) {
01474     case PE_FrameTabBarBase:
01475         if (const QStyleOptionTabBarBase *tbb
01476                 = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
01477             QRegion region(tbb->rect);
01478             p->save();
01479             switch (tbb->shape) {
01480             case QTabBar::RoundedNorth:
01481                 region -= tbb->selectedTabRect.adjusted(-1, 0 , 1, 0);
01482                 p->setClipRegion(region);
01483                 p->setPen(QPen(tbb->palette.dark(), 0));
01484                 p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
01485                 break;
01486             case QTabBar::RoundedWest:
01487                 region -= tbb->selectedTabRect.adjusted(0, -1 , 0, 1);
01488                 p->setClipRegion(region);
01489                 p->setPen(QPen(tbb->palette.dark(), 0));
01490                 p->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
01491                 break;
01492             case QTabBar::RoundedSouth:
01493                 region -= tbb->selectedTabRect.adjusted(-1, 0 , 1, 0);
01494                 p->setClipRegion(region);
01495                 p->setPen(QPen(tbb->palette.dark(), 0));
01496                 p->drawLine(tbb->rect.left(), tbb->rect.top(),
01497                             tbb->rect.right(), tbb->rect.top());
01498                 break;
01499             case QTabBar::RoundedEast:
01500                 region -= tbb->selectedTabRect.adjusted(0, -1 , 0, 1);
01501                 p->setClipRegion(region);
01502                 p->setPen(QPen(tbb->palette.dark(), 0));
01503                 p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
01504                 break;
01505             case QTabBar::TriangularNorth:
01506             case QTabBar::TriangularEast:
01507             case QTabBar::TriangularWest:
01508             case QTabBar::TriangularSouth:
01509                 p->restore();
01510                 QWindowsStyle::drawPrimitive(pe, option, p, widget);
01511                 return;
01512             }
01513             p->restore();
01514         }
01515         return;
01516     case PE_PanelButtonBevel:
01517         name = "BUTTON";
01518         partId = BP_PUSHBUTTON;
01519         if (!(flags & State_Enabled))
01520             stateId = PBS_DISABLED;
01521         else if ((flags & State_Sunken) || (flags & State_On))
01522             stateId = PBS_PRESSED;
01523         else if (flags & State_MouseOver)
01524             stateId = PBS_HOT;
01525         //else if (flags & State_ButtonDefault)
01526         //    stateId = PBS_DEFAULTED;
01527         else
01528             stateId = PBS_NORMAL;
01529         break;
01530 
01531     case PE_PanelButtonTool:
01532         if (widget && widget->inherits("QDockWidgetTitleButton")) {
01533             if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent()))
01534                 if (dw->isFloating())
01535                     return;
01536         }
01537         name = "TOOLBAR";
01538         partId = TP_BUTTON;
01539         if (!(flags & State_Enabled))
01540             stateId = TS_DISABLED;
01541         else if (flags & State_Sunken)
01542             stateId = TS_PRESSED;
01543         else if (flags & State_MouseOver)
01544             stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
01545         else if (flags & State_On)
01546             stateId = TS_CHECKED;
01547         else
01548             stateId = TS_NORMAL;
01549         break;
01550 
01551     case PE_IndicatorButtonDropDown:
01552         name = "TOOLBAR";
01553         partId = TP_SPLITBUTTONDROPDOWN;
01554         if (!(flags & State_Enabled))
01555             stateId = TS_DISABLED;
01556         else if (flags & State_Sunken)
01557             stateId = TS_PRESSED;
01558         else if (flags & State_MouseOver)
01559             stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
01560         else if (flags & State_On)
01561             stateId = TS_CHECKED;
01562         else
01563             stateId = TS_NORMAL;
01564         break;
01565 
01566     case PE_IndicatorArrowDown:
01567         name = "TOOLBAR";
01568         partId = TP_SPLITBUTTONDROPDOWN;
01569         if (!(flags & State_Enabled))
01570             stateId = TS_DISABLED;
01571         else
01572             stateId = TS_NORMAL;
01573         break;
01574 
01575     case PE_IndicatorCheckBox:
01576         name = "BUTTON";
01577         partId = BP_CHECKBOX;
01578         if (!(flags & State_Enabled))
01579             stateId = CBS_UNCHECKEDDISABLED;
01580         else if (flags & State_Sunken)
01581             stateId = CBS_UNCHECKEDPRESSED;
01582         else if (flags & State_MouseOver)
01583             stateId = CBS_UNCHECKEDHOT;
01584         else
01585             stateId = CBS_UNCHECKEDNORMAL;
01586 
01587         if (flags & State_On)
01588             stateId += CBS_CHECKEDNORMAL-1;
01589         else if (flags & State_NoChange)
01590             stateId += CBS_MIXEDNORMAL-1;
01591 
01592         break;
01593 
01594     case PE_IndicatorRadioButton:
01595         name = "BUTTON";
01596         partId = BP_RADIOBUTTON;
01597         if (!(flags & State_Enabled))
01598             stateId = RBS_UNCHECKEDDISABLED;
01599         else if (flags & State_Sunken)
01600             stateId = RBS_UNCHECKEDPRESSED;
01601         else if (flags & State_MouseOver)
01602             stateId = RBS_UNCHECKEDHOT;
01603         else
01604             stateId = RBS_UNCHECKEDNORMAL;
01605 
01606         if (flags & State_On)
01607             stateId += RBS_CHECKEDNORMAL-1;
01608         break;
01609 
01610     case PE_IndicatorDockWidgetResizeHandle:
01611         return;
01612 
01613     case PE_Frame:
01614         if (flags & State_Raised)
01615             return;
01616         name = "LISTVIEW";
01617         partId = LVP_LISTGROUP;
01618         break;
01619 
01620     case PE_FrameLineEdit:
01621         if (qstyleoption_cast<const QStyleOptionFrame *>(option))
01622         {
01623             name = "EDIT";
01624             partId = EP_EDITTEXT;
01625             noContent = true;
01626             if (!(flags & State_Enabled))
01627                 stateId = ETS_DISABLED;
01628             else
01629                 stateId = ETS_NORMAL;
01630         }
01631         break;
01632 
01633     case PE_PanelLineEdit:
01634         if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
01635             name = "EDIT";
01636             partId = EP_EDITTEXT;
01637             noBorder = true;
01638             QBrush bg;
01639             bool usePalette = false;
01640             bool isEnabled = flags & State_Enabled;
01641             uint resolve_mask = panel->palette.resolve();
01642 
01643             if (resolve_mask & (1 << QPalette::Base)) {
01644                 // Base color is set for this widget, so use it
01645                 bg = panel->palette.brush(QPalette::Base);
01646                 usePalette = true;
01647             }
01648 
01649             stateId = isEnabled ? ETS_NORMAL : ETS_DISABLED;
01650 
01651             if (usePalette) {
01652                 p->fillRect(panel->rect, bg);
01653             } else {
01654                 XPThemeData theme(0, p, name, partId, stateId, rect);
01655                 if (!theme.isValid()) {
01656                     QWindowsStyle::drawPrimitive(pe, option, p, widget);
01657                     return;
01658                 }
01659                 int bgType;
01660                 pGetThemeEnumValue( theme.handle(),
01661                                     partId,
01662                                     stateId,
01663                                     TMT_BGTYPE,
01664                                     &bgType);
01665                 if( bgType == BT_IMAGEFILE ) {
01666                     theme.mirrorHorizontally = hMirrored;
01667                     theme.mirrorVertically = vMirrored;
01668                     theme.noBorder = noBorder;
01669                     theme.noContent = noContent;
01670                     theme.rotate = rotate;
01671                     d->drawBackground(theme);
01672                 } else {
01673                     QBrush fillColor = option->palette.brush(QPalette::Base);
01674 
01675                     if (!isEnabled) {
01676                   PROPERTYORIGIN origin = PO_NOTFOUND;
01677                   pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
01678                   // Use only if the fill property comes from our part
01679                   if ((origin == PO_PART || origin == PO_STATE)) {
01680                             COLORREF bgRef;
01681                             pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
01682                             fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
01683                         }
01684                     }
01685                     p->fillRect(option->rect, fillColor);
01686                 }
01687             }
01688 
01689             if (panel->lineWidth > 0)
01690                 drawPrimitive(PE_FrameLineEdit, panel, p, widget);
01691             return;
01692         }
01693         break;
01694 
01695     case PE_FrameTabWidget:
01696         if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option))
01697         {
01698             name = "TAB";
01699             partId = TABP_PANE;
01700             // This should work, but currently there's an error in the ::drawBackgroundDirectly()
01701             // code, when using the HDC directly..
01702             if (widget) {
01703                 QStyleOptionTabWidgetFrame frameOpt = *tab;
01704                 frameOpt.rect = widget->rect();
01705                 QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget);
01706                 QRegion reg = option->rect;
01707                 reg -= contentsRect;
01708                 p->setClipRegion(reg);
01709                 XPThemeData theme(widget, p, name, partId, stateId, rect);
01710                 theme.mirrorHorizontally = hMirrored;
01711                 theme.mirrorVertically = vMirrored;
01712                 d->drawBackground(theme);
01713                 p->setClipRect(contentsRect);
01714                 partId = TABP_BODY;
01715             }
01716             switch (tab->shape) {
01717             case QTabBar::RoundedNorth:
01718             case QTabBar::TriangularNorth:
01719                 break;
01720             case QTabBar::RoundedSouth:
01721             case QTabBar::TriangularSouth:
01722                 vMirrored = true;
01723                 break;
01724             case QTabBar::RoundedEast:
01725             case QTabBar::TriangularEast:
01726                 rotate = 90;
01727                 break;
01728             case QTabBar::RoundedWest:
01729             case QTabBar::TriangularWest:
01730                 rotate = 90;
01731                 hMirrored = true;
01732                 break;
01733             default:
01734                 break;
01735             }
01736         }
01737         break;
01738 
01739     case PE_FrameMenu:
01740         p->save();
01741         p->setPen(option->palette.dark().color());
01742         p->drawRect(rect.adjusted(0, 0, -1, -1));
01743         p->restore();
01744         return;
01745 
01746     case PE_PanelMenuBar:
01747         break;
01748 
01749  case PE_FrameDockWidget:
01750      if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option))
01751         {
01752             name = "WINDOW";
01753             if (flags & State_Active)
01754                 stateId = FS_ACTIVE;
01755             else
01756                 stateId = FS_INACTIVE;
01757 
01758             int fwidth = pixelMetric(PM_DockWidgetFrameWidth, frm, widget);
01759 
01760             XPThemeData theme(widget, p, name, 0, stateId);
01761             if (!theme.isValid())
01762                 break;
01763             theme.rect = QRect(frm->rect.x(), frm->rect.y(), frm->rect.x()+fwidth, frm->rect.height()-fwidth);           theme.partId = WP_SMALLFRAMELEFT;
01764             d->drawBackground(theme);
01765             theme.rect = QRect(frm->rect.width()-fwidth, frm->rect.y(), fwidth, frm->rect.height()-fwidth);
01766             theme.partId = WP_SMALLFRAMERIGHT;
01767             d->drawBackground(theme);
01768             theme.rect = QRect(frm->rect.x(), frm->rect.bottom()-fwidth+1, frm->rect.width(), fwidth);
01769             theme.partId = WP_SMALLFRAMEBOTTOM;
01770             d->drawBackground(theme);
01771             return;
01772         }
01773         break;
01774 
01775     case PE_IndicatorHeaderArrow:
01776         {
01777 #if 0 // XP theme engine doesn't know about this :(
01778             name = "HEADER";
01779             partId = HP_HEADERSORTARROW;
01780             if (flags & State_Down)
01781                 stateId = HSAS_SORTEDDOWN;
01782             else
01783                 stateId = HSAS_SORTEDUP;
01784 #else
01785             if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
01786                 p->save();
01787                 p->setPen(option->palette.dark().color());
01788                 p->translate(0, option->rect.height()/2 - 4);
01789                 if (header->sortIndicator & QStyleOptionHeader::SortUp) { // invert logic to follow Windows style guide
01790                     p->drawLine(option->rect.x(), option->rect.y(), option->rect.x()+8, option->rect.y());
01791                     p->drawLine(option->rect.x()+1, option->rect.y()+1, option->rect.x()+7, option->rect.y()+1);
01792                     p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2);
01793                     p->drawLine(option->rect.x()+3, option->rect.y()+3, option->rect.x()+5, option->rect.y()+3);
01794                     p->drawPoint(option->rect.x()+4, option->rect.y()+4);
01795                 } else if(header->sortIndicator & QStyleOptionHeader::SortDown) {
01796                     p->drawLine(option->rect.x(), option->rect.y()+4, option->rect.x()+8, option->rect.y()+4);
01797                     p->drawLine(option->rect.x()+1, option->rect.y()+3, option->rect.x()+7, option->rect.y()+3);
01798                     p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2);
01799                     p->drawLine(option->rect.x()+3, option->rect.y()+1, option->rect.x()+5, option->rect.y()+1);
01800                     p->drawPoint(option->rect.x()+4, option->rect.y());
01801                 }
01802                 p->restore();
01803                 return;
01804             }
01805 #endif
01806         }
01807         break;
01808 
01809     case PE_FrameStatusBar:
01810         name = "STATUS";
01811         partId = SP_PANE;
01812         break;
01813 
01814     case PE_FrameGroupBox:
01815         name = "BUTTON";
01816         partId = BP_GROUPBOX;
01817         if (!(flags & State_Enabled))
01818             stateId = GBS_DISABLED;
01819         else
01820             stateId = GBS_NORMAL;
01821         if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
01822             const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(option);
01823             if (frame2->features & QStyleOptionFrameV2::Flat) {
01824                 // Windows XP does not have a theme part for a flat GroupBox, paint it with the windows style
01825                 QRect fr = frame->rect;
01826                 QPoint p1(fr.x(), fr.y() + 1);
01827                 QPoint p2(fr.x() + fr.width(), p1.y() + 1);
01828                 rect = QRect(p1, p2);
01829                 name = "";
01830             }
01831         }
01832         break;
01833 
01834     case PE_IndicatorProgressChunk:
01835         {
01836         Qt::Orientation orient = Qt::Horizontal;
01837         if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
01838             orient = pb2->orientation;
01839         if (orient == Qt::Horizontal) {
01840             partId = PP_CHUNK;
01841             rect = QRect(option->rect.x(), option->rect.y() + 3, option->rect.width(), option->rect.height() - 5);
01842         } else {
01843             partId = PP_CHUNKVERT;
01844             rect = QRect(option->rect.x() + 2, option->rect.y() - 1, option->rect.width() - 5, option->rect.height());
01845         }
01846         name = "PROGRESS";
01847         stateId = 1;
01848         }
01849         break;
01850 
01851     case PE_Q3DockWindowSeparator:
01852         name = "TOOLBAR";
01853         if (flags & State_Horizontal)
01854             partId = TP_SEPARATOR;
01855         else
01856             partId = TP_SEPARATORVERT;
01857         break;
01858 
01859     case PE_FrameWindow:
01860         if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option))
01861         {
01862             name = "WINDOW";
01863             if (flags & State_Active)
01864                 stateId = FS_ACTIVE;
01865             else
01866                 stateId = FS_INACTIVE;
01867 
01868             int fwidth = frm->lineWidth + frm->midLineWidth;
01869 
01870             XPThemeData theme(0, p, name, 0, stateId);
01871             if (!theme.isValid())
01872                 break;
01873 
01874             theme.rect = QRect(option->rect.x(), option->rect.y()+fwidth, option->rect.x()+fwidth, option->rect.height()-fwidth);
01875             theme.partId = WP_FRAMELEFT;
01876             d->drawBackground(theme);
01877             theme.rect = QRect(option->rect.width()-fwidth, option->rect.y()+fwidth, fwidth, option->rect.height()-fwidth);
01878             theme.partId = WP_FRAMERIGHT;
01879             d->drawBackground(theme);
01880             theme.rect = QRect(option->rect.x(), option->rect.height()-fwidth, option->rect.width(), fwidth);
01881             theme.partId = WP_FRAMEBOTTOM;
01882             d->drawBackground(theme);
01883             theme.rect = QRect(option->rect.x()-5, option->rect.y()-5, option->rect.width()+10, option->rect.y()+fwidth+5);
01884             theme.partId = WP_CAPTION;
01885             d->drawBackground(theme);
01886             return;
01887         }
01888         break;
01889 
01890     case PE_IndicatorBranch:
01891         {
01892             static const int decoration_size = 9;
01893             int mid_h = option->rect.x() + option->rect.width() / 2;
01894             int mid_v = option->rect.y() + option->rect.height() / 2;
01895             int bef_h = mid_h;
01896             int bef_v = mid_v;
01897             int aft_h = mid_h;
01898             int aft_v = mid_v;
01899             QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
01900             if (option->state & State_Item) {
01901                 if (option->direction == Qt::RightToLeft)
01902                     p->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
01903                 else
01904                     p->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
01905             }
01906             if (option->state & State_Sibling)
01907                 p->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
01908             if (option->state & (State_Open | State_Children | State_Item | State_Sibling))
01909                 p->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
01910             if (option->state & State_Children) {
01911                 int delta = decoration_size / 2;
01912                 bef_h -= delta;
01913                 bef_v -= delta;
01914                 aft_h += delta;
01915                 aft_v += delta;
01916                 XPThemeData theme(0, p, "TREEVIEW");
01917                 theme.rect = QRect(bef_h, bef_v, decoration_size, decoration_size);
01918                 theme.partId = TVP_GLYPH;
01919                 theme.stateId = flags & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
01920                 d->drawBackground(theme);
01921             }
01922         }
01923         return;
01924 
01925     case PE_IndicatorToolBarSeparator:
01926 
01927         name = "TOOLBAR";
01928         partId = TP_SEPARATOR;
01929 
01930         if (option->state & State_Horizontal)
01931             partId = TP_SEPARATOR;
01932         else
01933             partId = TP_SEPARATORVERT;
01934 
01935         break;
01936 
01937     case PE_IndicatorToolBarHandle:
01938 
01939         name = "REBAR";
01940         partId = RP_GRIPPER;
01941         if (option->state & State_Horizontal) {
01942             partId = RP_GRIPPER;
01943             rect.adjust(0, 0, -2, 0);
01944         }
01945         else {
01946             partId = RP_GRIPPERVERT;
01947             rect.adjust(0, 0, 0, -2);
01948         }
01949         break;
01950 
01951     case PE_IndicatorViewItemCheck: {
01952         QStyleOptionButton button;
01953         button.QStyleOption::operator=(*option);
01954         button.state &= ~State_MouseOver;
01955         drawPrimitive(PE_IndicatorCheckBox, &button, p, widget);
01956         return;
01957     }
01958 
01959     default:
01960         break;
01961     }
01962 
01963     XPThemeData theme(0, p, name, partId, stateId, rect);
01964     if (!theme.isValid()) {
01965         QWindowsStyle::drawPrimitive(pe, option, p, widget);
01966         return;
01967     }
01968     theme.mirrorHorizontally = hMirrored;
01969     theme.mirrorVertically = vMirrored;
01970     theme.noBorder = noBorder;
01971     theme.noContent = noContent;
01972     theme.rotate = rotate;
01973     d->drawBackground(theme);
01974 }

Here is the call graph for this function:

void QWindowsXPStyle::drawControl ( ControlElement  element,
const QStyleOption option,
QPainter p,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1979 of file qwindowsxpstyle.cpp.

References QIcon::Active, QPalette::Active, QRect::adjust(), QRect::adjusted(), Qt::AlignBottom, Qt::AlignCenter, Qt::AlignLeft, Qt::AlignVCenter, QStyleOptionTab::Beginning, QColor::blue, QRect::bottom(), Qt::BottomLeftCorner, Qt::BottomRightCorner, QPalette::Button, QPalette::ButtonText, QStyle::CE_DockWidgetTitle, QStyle::CE_HeaderSection, QStyle::CE_MenuBarItem, QStyle::CE_MenuEmptyArea, QStyle::CE_MenuItem, QStyle::CE_ProgressBarGroove, QStyle::CE_PushButtonBevel, QStyle::CE_RubberBand, QStyle::CE_SizeGrip, QStyle::CE_Splitter, QStyle::CE_TabBarTab, QStyle::CE_TabBarTabShape, center(), QBrush::color(), d, QColor::dark(), QPalette::Dark, QStyleOptionButton::DefaultButton, QStyleOptionMenuItem::DefaultItem, QIcon::Disabled, QWindowsStyle::drawControl(), QStyle::drawItemPixmap(), QStyle::drawItemText(), drawPrimitive(), Qt::ElideRight, QStyleOptionTab::End, flags, QStyleOptionButton::Flat, QRect::getRect(), QColor::green, h, XPThemeData::handle(), QStyleOptionButton::HasMenu, QPixmap::height(), QRect::height(), QPalette::Highlight, QPalette::highlightedText(), QPalette::HighlightedText, Qt::Horizontal, QString::isEmpty(), QDockWidget::isFloating(), QPixmap::isNull(), QWidget::isTopLevel(), XPThemeData::isValid(), QApplication::layoutDirection(), QRect::left(), XPThemeData::mirrorHorizontally, XPThemeData::mirrorVertically, QRect::moveCenter(), name, Qt::NoBrush, QIcon::Normal, QIcon::On, QStyleOptionTab::OnlyOneTab, p, QStyleOption::palette, XPThemeData::partId, QStyle::PE_IndicatorArrowDown, QStyle::PE_IndicatorArrowLeft, QStyle::PE_IndicatorArrowRight, QStyle::PE_IndicatorMenuCheckMark, pGetThemeColor, pGetThemeEnumValue, pGetThemePartSize, pixelMetric(), QIcon::pixmap(), QStyle::PM_DefaultFrameWidth, QStyle::PM_DockWidgetFrameWidth, QStyle::PM_DockWidgetTitleMargin, QStyle::PM_SmallIconSize, QStyle::PM_TabBarTabOverlap, qApp, qMax(), qMin(), qRgb(), XPThemeData::rect, QStyleOption::rect, QColor::red, QRect::right(), Qt::RightToLeft, XPThemeData::rotate, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, s, QStyleOptionMenuItem::Separator, QIcon::serialNumber(), QFont::setBold(), QPalette::setColor(), QStyle::SH_TabBar_Alignment, QStyle::SH_UnderlineShortcut, size, QPixmap::size(), QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton, standardPixmap(), QStyleOption::state, QStyle::State_Active, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_MouseOver, QStyle::State_None, QStyle::State_On, QStyle::State_Selected, QStyle::State_Sunken, XPThemeData::stateId, styleHint(), QStyleOptionMenuItem::SubMenu, t, QPalette::Text, Qt::TextDontClip, Qt::TextHideMnemonic, Qt::TextShowMnemonic, Qt::TextSingleLine, TMT_TEXTSHADOWCOLOR, TMT_TEXTSHADOWTYPE, QRect::top(), QRect::topLeft(), Qt::TopLeftCorner, QRect::topRight(), Qt::TopRightCorner, TST_NONE, QWindowsXPStylePrivate::useXP(), QStyle::visualRect(), w, QPixmap::width(), QRect::width(), QSize::width(), QWidget::windowIcon(), windowsArrowHMargin, windowsItemFrame, windowsItemHMargin, windowsItemVMargin, windowsRightBorder, QPalette::WindowText, x, and y.

Referenced by drawComplexControl().

01981 {
01982   QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
01983     if (!QWindowsXPStylePrivate::useXP()) {
01984         QWindowsStyle::drawControl(element, option, p, widget);
01985         return;
01986     }
01987 
01988     QRect rect(option->rect);
01989     State flags = option->state;
01990 
01991     int rotate = 0;
01992     bool hMirrored = false;
01993     bool vMirrored = false;
01994 
01995     QString name;
01996     int partId = 0;
01997     int stateId = 0;
01998     switch (element) {
01999     case CE_SizeGrip:
02000         {
02001             name = "STATUS";
02002             partId = SP_GRIPPER;
02003             SIZE sz;
02004             XPThemeData theme(0, p, name, partId, 0);
02005             pGetThemePartSize(theme.handle(), 0, partId, 0, 0, TS_TRUE, &sz);
02006             --sz.cy;
02007             if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
02008                 switch (sg->corner) {
02009                     case Qt::BottomRightCorner:
02010                         rect = QRect(rect.right() - sz.cx, rect.bottom() - sz.cy, sz.cx, sz.cy);
02011                         break;
02012                     case Qt::BottomLeftCorner:
02013                         rect = QRect(rect.left() + 1, rect.bottom() - sz.cy, sz.cx, sz.cy);
02014                         hMirrored = true;
02015                         break;
02016                     case Qt::TopRightCorner:
02017                         rect = QRect(rect.right() - sz.cx, rect.top() + 1, sz.cx, sz.cy);
02018                         vMirrored = true;
02019                         break;
02020                     case Qt::TopLeftCorner:
02021                         rect = QRect(rect.left() + 1, rect.top() + 1, sz.cx, sz.cy);
02022                         hMirrored = vMirrored = true;
02023                 }
02024             }
02025         }
02026         break;
02027 
02028     case CE_HeaderSection:
02029         name = "HEADER";
02030         partId = HP_HEADERITEM;
02031         if (flags & State_Sunken)
02032             stateId = HIS_PRESSED;
02033         else if (flags & State_MouseOver)
02034             stateId = HIS_HOT;
02035         else
02036             stateId = HIS_NORMAL;
02037         break;
02038 
02039     case CE_Splitter:
02040         p->eraseRect(option->rect);
02041         return;
02042 
02043     case CE_PushButtonBevel:
02044         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
02045         {
02046             name = "BUTTON";
02047             partId = BP_PUSHBUTTON;
02048             bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken));
02049             if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))
02050                 stateId = PBS_DISABLED;
02051             else if (justFlat)
02052                 ;
02053             else if (flags & (State_Sunken | State_On))
02054                 stateId = PBS_PRESSED;
02055             else if (flags & State_MouseOver)
02056                 stateId = PBS_HOT;
02057             else if (btn->features & QStyleOptionButton::DefaultButton)
02058                 stateId = PBS_DEFAULTED;
02059             else
02060                 stateId = PBS_NORMAL;
02061 
02062             if (!justFlat) {
02063                 XPThemeData theme(widget, p, name, partId, stateId, rect);
02064                 d->drawBackground(theme);
02065             }
02066 
02067             if (btn->features & QStyleOptionButton::HasMenu) {
02068                 int mbiw = 0, mbih = 0;
02069                 XPThemeData theme(widget, 0, "TOOLBAR", TP_SPLITBUTTONDROPDOWN);
02070                 if (theme.isValid()) {
02071                     SIZE size;
02072                     pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
02073                     mbiw = size.cx;
02074                     mbih = size.cy;
02075                 }
02076 
02077                 QRect ir = btn->rect;
02078                 QStyleOptionButton newBtn = *btn;
02079                 newBtn.rect = QRect(ir.right() - mbiw - 1, (ir.height()/2) - (mbih/2), mbiw, mbih);
02080                 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
02081             }
02082             return;
02083         }
02084         break;
02085     case CE_TabBarTab:
02086         if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
02087         {
02088             stateId = tab->state & State_Enabled ? TIS_NORMAL : TIS_DISABLED;
02089         }
02090     break;
02091 
02092     case CE_TabBarTabShape:
02093         if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
02094         {
02095             name = "TAB";
02096             bool isDisabled = !(tab->state & State_Enabled);
02097             bool hasFocus = tab->state & State_HasFocus;
02098             bool isHot = tab->state & State_MouseOver;
02099             bool selected = tab->state & State_Selected;
02100             bool lastTab = tab->position == QStyleOptionTab::End;
02101             bool firstTab = tab->position == QStyleOptionTab::Beginning;
02102             bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
02103             //bool previousSelected = (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected);
02104             //bool nextSelected = (tab->selectedPosition == QStyleOptionTab::NextIsSelected);
02105             bool leftAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft;
02106             bool centerAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter;
02107             //bool rightAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignRight;
02108             int borderThickness = pixelMetric(PM_DefaultFrameWidth, option, widget);
02109             int tabOverlap = onlyOne ? 0 : pixelMetric(PM_TabBarTabOverlap, option, widget);
02110 
02111             if (isDisabled)
02112                 stateId = TIS_DISABLED;
02113             else if (selected)
02114                 stateId = TIS_SELECTED;
02115             else if (hasFocus)
02116                 stateId = TIS_FOCUSED;
02117             else if (isHot)
02118                 stateId = TIS_HOT;
02119             else
02120                 stateId = TIS_NORMAL;
02121 
02122             // Selecting proper part depending on position
02123             if (firstTab || onlyOne) {
02124                 if (leftAligned) {
02125                     partId = TABP_TABITEMLEFTEDGE;
02126                 } else if (centerAligned) {
02127                     partId = TABP_TABITEM;
02128                 } else { // rightAligned
02129                     partId = TABP_TABITEMRIGHTEDGE;
02130                 }
02131             } else {
02132                 partId = TABP_TABITEM;
02133             }
02134 
02135             if (tab->direction == Qt::RightToLeft
02136                 && (tab->shape == QTabBar::RoundedNorth
02137                     || tab->shape == QTabBar::RoundedSouth)) {
02138                 bool temp = firstTab;
02139                 firstTab = lastTab;
02140                 lastTab = temp;
02141             }
02142 
02143             switch (tab->shape) {
02144             case QTabBar::RoundedNorth:
02145                 if (selected)
02146                     rect.adjust(firstTab ? 0 : -tabOverlap, 0, lastTab ? 0 : tabOverlap, borderThickness);
02147                 else
02148                     rect.adjust(0, tabOverlap, 0, 0);
02149                 break;
02150             case QTabBar::RoundedSouth:
02151                 //vMirrored = true;
02152                 rotate = 180; // Not 100% correct, but works
02153                 if (selected)
02154                     rect.adjust(firstTab ? 0 : -tabOverlap , -borderThickness, lastTab ? 0 : tabOverlap, 0);
02155                 else
02156                     rect.adjust(0, 0, 0, -tabOverlap);
02157                 break;
02158             case QTabBar::RoundedEast:
02159                 rotate = 90;
02160                 if (selected) {
02161                     rect.adjust(-borderThickness, firstTab ? 0 : -tabOverlap, 0, lastTab ? 0 : tabOverlap);
02162                 }else{
02163                     rect.adjust(0, 0, -tabOverlap, 0);
02164                 }
02165                 break;
02166             case QTabBar::RoundedWest:
02167                 hMirrored = true;
02168                 rotate = 90;
02169                 if (selected) {
02170                     rect.adjust(0, firstTab ? 0 : -tabOverlap, borderThickness, lastTab ? 0 : tabOverlap);
02171                 }else{
02172                     rect.adjust(tabOverlap, 0, 0, 0);
02173                 }
02174                 break;
02175             default:
02176                 name = "";  // Do our own painting for triangular
02177                 break;
02178             }
02179 
02180             if (!selected) {
02181                 switch (tab->shape) {
02182                 case QTabBar::RoundedNorth:
02183                     rect.adjust(0,0, 0,-1);
02184                     break;
02185                 case QTabBar::RoundedSouth:
02186                     rect.adjust(0,1, 0,0);
02187                     break;
02188                 case QTabBar::RoundedEast:
02189                     rect.adjust( 1,0, 0,0);
02190                     break;
02191                 case QTabBar::RoundedWest:
02192                     rect.adjust(0,0, -1,0);
02193                     break;
02194                 }
02195             }
02196         }
02197         break;
02198 
02199     case CE_ProgressBarGroove:
02200         {
02201         Qt::Orientation orient = Qt::Horizontal;
02202         if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
02203             orient = pb2->orientation;
02204         partId = (orient == Qt::Horizontal) ? PP_BAR : PP_BARVERT;
02205         name = "PROGRESS";
02206         stateId = 1;
02207         }
02208         break;
02209 
02210     case CE_MenuEmptyArea:
02211     case CE_MenuItem:
02212         if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
02213         {
02214             int tab = menuitem->tabWidth;
02215             bool dis = !(menuitem->state & State_Enabled);
02216             bool act = menuitem->state & State_Selected;
02217             bool checkable = menuitem->menuHasCheckableItems;
02218             bool checked = checkable ? menuitem->checked : false;
02219 
02220             // windows always has a check column, regardless whether we have an icon or not
02221             int checkcol = qMax(menuitem->maxIconWidth, 20);
02222 
02223             int x, y, w, h;
02224             rect.getRect(&x, &y, &w, &h);
02225 
02226             QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
02227             p->fillRect(rect, fill);
02228 
02229             if (element == CE_MenuEmptyArea)
02230                 break;
02231 
02232             // draw separator -------------------------------------------------
02233             if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
02234                 int yoff = y-1 + h / 2;
02235                 p->setPen(menuitem->palette.dark().color());
02236                 p->drawLine(x, yoff, x+w, yoff);
02237                 ++yoff;
02238                 p->setPen(menuitem->palette.light().color());
02239                 p->drawLine(x, yoff, x+w, yoff);
02240                 return;
02241             }
02242 
02243             int xpos = x;
02244 
02245             // draw icon ------------------------------------------------------
02246             if (!menuitem->icon.isNull()) {
02247                 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
02248                 if (act && !dis)
02249                     mode = QIcon::Active;
02250                 QPixmap pixmap = checked ?
02251                                  menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On) :
02252                                  menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
02253                 int pixw = pixmap.width();
02254                 int pixh = pixmap.height();
02255                 QRect iconRect(0, 0, pixw, pixh);
02256                 iconRect.moveCenter(QRect(xpos, y, checkcol, h).center());
02257                 QRect vIconRect = visualRect(option->direction, option->rect, iconRect); 
02258                 p->setPen(menuitem->palette.text().color());
02259                 p->setBrush(Qt::NoBrush);
02260                 if (checked)
02261                     p->drawRect(vIconRect.adjusted(-1, -2, 1, 1));
02262                 p->drawPixmap(vIconRect.topLeft(), pixmap);
02263 
02264             // draw checkmark -------------------------------------------------
02265             } else if (checked) {
02266                 QStyleOptionMenuItem newMi = *menuitem;
02267                 newMi.state = State_None;
02268                 if (!dis)
02269                     newMi.state |= State_Enabled;
02270                 if (act)
02271                     newMi.state |= State_On;
02272 
02273                 QRect checkMarkRect = QRect(menuitem->rect.x() + windowsItemFrame, 
02274                                             menuitem->rect.y() + windowsItemFrame,
02275                                             checkcol - 2 * windowsItemFrame, 
02276                                             menuitem->rect.height() - 2*windowsItemFrame);
02277                 newMi.rect = visualRect(option->direction, option->rect, checkMarkRect);
02278                 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
02279             }
02280 
02281             QColor textColor = dis ? menuitem->palette.text().color() :
02282                                act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color();
02283             p->setPen(textColor);
02284 
02285             // draw text ------------------------------------------------------
02286             int xm = windowsItemFrame + checkcol + windowsItemHMargin;
02287             xpos = menuitem->rect.x() + xm;
02288             QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
02289             QRect vTextRect = visualRect(option->direction, option->rect, textRect);
02290             QString s = menuitem->text;
02291             if (!s.isEmpty()) {
02292                 p->save();
02293                 int t = s.indexOf('\t');
02294                 int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine | Qt::AlignLeft;
02295                 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
02296                     text_flags |= Qt::TextHideMnemonic;
02297                 // draw tab text ----------------
02298                 if (t >= 0) {
02299                     QRect vShortcutRect = visualRect(option->direction, option->rect, QRect(textRect.topRight(), menuitem->rect.bottomRight()));
02300                     if (dis && !act) {
02301                         p->setPen(menuitem->palette.light().color());
02302                         p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
02303                         p->setPen(textColor);
02304                     }
02305                     p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
02306                     s = s.left(t);
02307                 }
02308                 QFont font = menuitem->font;
02309                 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
02310                     font.setBold(true);
02311                 p->setFont(font);
02312                 if (dis && !act) {
02313                     p->setPen(menuitem->palette.light().color());
02314                     p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
02315                     p->setPen(textColor);
02316                 }
02317                 p->drawText(vTextRect, text_flags, s);
02318                 p->restore();
02319             }
02320 
02321             // draw sub menu arrow --------------------------------------------
02322             if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
02323                 int dim = (h - 2 * windowsItemFrame) / 2;
02324                 PrimitiveElement arrow;
02325                 arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
02326                 xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
02327                 QRect vSubMenuRect = visualRect(option->direction, option->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
02328                 QStyleOptionMenuItem newMI = *menuitem;
02329                 newMI.rect = vSubMenuRect;
02330                 newMI.state = dis ? State_None : State_Enabled;
02331                 if (act)
02332                     newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color());
02333                 drawPrimitive(arrow, &newMI, p, widget);
02334             }
02335         }
02336         return;
02337 
02338     case CE_MenuBarItem:
02339         if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
02340         {
02341             if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem)
02342                 break;
02343 
02344             bool act = mbi->state & State_Selected;
02345             bool dis = !(mbi->state & State_Enabled);
02346 
02347             QBrush fill = mbi->palette.brush(act ? QPalette::Highlight : QPalette::Button);
02348             QPalette::ColorRole textRole = dis ? QPalette::Text:
02349                                            act ? QPalette::HighlightedText : QPalette::ButtonText;
02350             QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize), QIcon::Normal);
02351 
02352             uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
02353             if (!styleHint(SH_UnderlineShortcut, mbi, widget))
02354                 alignment |= Qt::TextHideMnemonic;
02355 
02356             p->fillRect(rect, fill);
02357             if (!pix.isNull())
02358                 drawItemPixmap(p, mbi->rect, alignment, pix);
02359             else
02360                 drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
02361         }
02362         return;
02363 #ifndef QT_NO_DOCKWIDGET
02364 case CE_DockWidgetTitle:
02365         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
02366         {
02367             int buttonMargin = 4;
02368             int mw = pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
02369             int fw = pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
02370             const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
02371             bool isFloating = dw != 0 && dw->isFloating();
02372             bool isActive = dwOpt->state & State_Active;
02373 
02374             QRect r = option->rect.adjusted(0, 2, -1, -3);
02375             QRect titleRect = r;            
02376 
02377             if (dwOpt->closable) {
02378                 QPixmap pm = standardPixmap(QStyle::SP_TitleBarCloseButton, dwOpt, widget);
02379                 titleRect.adjust(0, 0, -pm.size().width() - mw - buttonMargin, 0);
02380             }
02381 
02382             if (dwOpt->floatable) {
02383                 QPixmap pm = standardPixmap(QStyle::SP_TitleBarMaxButton, dwOpt, widget);
02384                 titleRect.adjust(0, 0, -pm.size().width() - mw - buttonMargin, 0);
02385             }
02386 
02387             if (isFloating) {
02388                 titleRect.adjust(0, -fw, 0, 0);
02389                 if (widget != 0 && widget->windowIcon().serialNumber() != qApp->windowIcon().serialNumber())
02390                     titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
02391             } else {
02392                 titleRect.adjust(mw, 0, 0, 0);
02393                 if (!dwOpt->floatable && !dwOpt->closable)
02394                     titleRect.adjust(0, 0, -mw, 0);
02395             }
02396 
02397             titleRect = visualRect(dwOpt->direction, r, titleRect);
02398 
02399             if (!isFloating) {
02400                 QPen oldPen = p->pen();
02401                 QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
02402                 p->setPen(dwOpt->palette.color(QPalette::Dark));
02403                 p->drawRect(r);
02404 
02405                 if (!titleText.isEmpty()) {
02406                     drawItemText(p, titleRect,
02407                                 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
02408                                 dwOpt->state & State_Enabled, titleText,
02409                                 QPalette::WindowText);
02410                 }
02411 
02412                 p->setPen(oldPen);
02413             } else {
02414                 name = "WINDOW";
02415                 if (isActive)
02416                     stateId = CS_ACTIVE;
02417                 else
02418                     stateId = CS_INACTIVE;
02419 
02420                 int titleHeight = rect.height() - 2;
02421                 rect = rect.adjusted(-fw, -fw, fw, 0);
02422 
02423                 XPThemeData theme(widget, p, name, 0, stateId);
02424                 if (!theme.isValid())
02425                     break;
02426 
02427                 // Draw small type title bar
02428                 theme.rect = rect;
02429                 theme.partId = WP_SMALLCAPTION;
02430                 d->drawBackground(theme);
02431 
02432                 // Figure out maximal button space on title bar
02433 
02434                 QIcon ico = widget->windowIcon();
02435                 bool hasIcon = (ico.serialNumber() != qApp->windowIcon().serialNumber());
02436                 if (hasIcon) {
02437                     QPixmap pxIco = ico.pixmap(titleHeight);
02438                     if (QApplication::layoutDirection() == Qt::RightToLeft)
02439                         p->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco);
02440                     else
02441                         p->drawPixmap(fw, rect.bottom() - titleHeight - 2, pxIco);
02442                 }
02443                 if (!dwOpt->title.isEmpty()) {
02444                     QPen oldPen = p->pen();
02445                     QFont oldFont = p->font();
02446                     QFont titleFont = oldFont;
02447                     titleFont.setBold(true);
02448                     p->setFont(titleFont);
02449                     QString titleText 
02450                         = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
02451 
02452                     int result = TST_NONE;
02453                     pGetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
02454                     if (result != TST_NONE) {
02455                         COLORREF textShadowRef;
02456                         pGetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
02457                         QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
02458                         p->setPen(textShadow);
02459                         drawItemText(p, titleRect.adjusted(1, 1, 1, 1),
02460                                     Qt::AlignLeft | Qt::AlignBottom, dwOpt->palette,
02461                                     dwOpt->state & State_Enabled, titleText);
02462                     }
02463 
02464                     COLORREF captionText = GetSysColor(isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
02465                     QColor textColor = qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
02466                     p->setPen(textColor);
02467                     drawItemText(p, titleRect,
02468                                 Qt::AlignLeft | Qt::AlignBottom, dwOpt->palette,
02469                                 dwOpt->state & State_Enabled, titleText);
02470                     p->setFont(oldFont);
02471                     p->setPen(oldPen);
02472                 }
02473 
02474             }
02475 
02476             return;
02477         }
02478         break;
02479 #endif // QT_NO_DOCKWIDGET
02480 #ifndef QT_NO_RUBBERBAND
02481 case CE_RubberBand:
02482         if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(option)) {
02483             QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
02484             p->save();
02485             QRect r = option->rect;
02486             p->setPen(highlight.dark(120));
02487             QColor dimHighlight(qMin(highlight.red()/2 + 110, 255),
02488                                 qMin(highlight.green()/2 + 110, 255),
02489                                 qMin(highlight.blue()/2 + 110, 255),
02490                                 (widget && widget->isTopLevel())? 255 : 127);
02491             p->setBrush(dimHighlight);
02492             p->drawRect(option->rect.adjusted(0, 0, -1, -1));
02493             p->restore();
02494             return;
02495         }
02496 #endif // QT_NO_RUBBERBAND
02497 
02498 default:
02499         break;
02500     }
02501 
02502     XPThemeData theme(widget, p, name, partId, stateId, rect);
02503     if (!theme.isValid()) {
02504         QWindowsStyle::drawControl(element, option, p, widget);
02505         return;
02506     }
02507 
02508     theme.rotate = rotate;
02509     theme.mirrorHorizontally = hMirrored;
02510     theme.mirrorVertically = vMirrored;
02511     d->drawBackground(theme);
02512 }

Here is the call graph for this function:

QRect QWindowsXPStyle::subElementRect ( SubElement  sr,
const QStyleOption option,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 1372 of file qwindowsxpstyle.cpp.

References QRect::adjust(), QRect::adjusted(), QStyleOptionButton::DefaultButton, QStyleOption::direction, L, NULL, pGetThemeMargins, pixelMetric(), QStyle::PM_DefaultFrameWidth, QStyle::PM_TabBarBaseOverlap, pOpenThemeData, QStyleOption::rect, Qt::RightToLeft, QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QStyle::SE_PushButtonContents, QStyle::SE_TabWidgetTabBar, QStyle::SE_TabWidgetTabContents, QStyleOptionTab::shape, QStyleOptionTabWidgetFrame::shape, QStyle::State_Enabled, QStyle::State_MouseOver, QStyle::State_Sunken, QWindowsStyle::subElementRect(), TMT_CONTENTMARGINS, QWindowsXPStylePrivate::useXP(), QStyle::visualRect(), and QWindowsXPStylePrivate::winId().

Referenced by drawComplexControl(), and drawPrimitive().

01373 {
01374     if (!QWindowsXPStylePrivate::useXP()) {
01375         return QWindowsStyle::subElementRect(sr, option, widget);
01376     }
01377 
01378     QRect rect(option->rect);
01379     switch(sr) {
01380     case SE_TabWidgetTabContents:
01381         if (qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option))
01382         {
01383             rect = QWindowsStyle::subElementRect(sr, option, widget);
01384             if (sr == SE_TabWidgetTabContents)
01385                    rect.adjust(0, 0, -2, -2);
01386         }
01387         break;
01388     case SE_TabWidgetTabBar: {
01389         rect = QWindowsStyle::subElementRect(sr, option, widget);
01390         const QStyleOptionTabWidgetFrame *twfOption =
01391             qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option);
01392         if (twfOption && twfOption->direction == Qt::RightToLeft
01393             && (twfOption->shape == QTabBar::RoundedNorth
01394                 || twfOption->shape == QTabBar::RoundedSouth))
01395         {
01396             QStyleOptionTab otherOption;
01397             otherOption.shape = (twfOption->shape == QTabBar::RoundedNorth
01398                                 ? QTabBar::RoundedEast : QTabBar::RoundedSouth);
01399             int overlap = pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget);
01400             int borderThickness = pixelMetric(PM_DefaultFrameWidth, option, widget);
01401             rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
01402         }
01403         break;}
01404 
01405     case SE_PushButtonContents:
01406         if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
01407             MARGINS borderSize;
01408             if (widget) {
01409                 HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button");
01410                 if (theme) {
01411                     int stateId;
01412                     if (!(option->state & State_Enabled))
01413                         stateId = PBS_DISABLED;
01414                     else if (option->state & State_Sunken)
01415                         stateId = PBS_PRESSED;
01416                     else if (option->state & State_MouseOver)
01417                         stateId = PBS_HOT;
01418                     else if (btn->features & QStyleOptionButton::DefaultButton)
01419                         stateId = PBS_DEFAULTED;
01420                     else
01421                         stateId = PBS_NORMAL;
01422 
01423                     int border = pixelMetric(PM_DefaultFrameWidth, btn, widget);
01424                     rect = option->rect.adjusted(border, border, -border, -border);
01425 
01426                     int result = pGetThemeMargins(theme,
01427                                                   NULL,
01428                                                   BP_PUSHBUTTON,
01429                                                   stateId,
01430                                                   TMT_CONTENTMARGINS,
01431                                                   NULL,
01432                                                   &borderSize);
01433 
01434                     if (result == S_OK) {
01435                         rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
01436                                     -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
01437                         rect = visualRect(option->direction, option->rect, rect);
01438                     }
01439                 }
01440             }
01441         }
01442         break;
01443     default:
01444         rect = QWindowsStyle::subElementRect(sr, option, widget);
01445     }
01446     return rect;
01447 }

Here is the call graph for this function:

QRect QWindowsXPStyle::subControlRect ( ComplexControl  cc,
const QStyleOptionComplex option,
SubControl  sc,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QCommonStyle.

Definition at line 3433 of file qwindowsxpstyle.cpp.

References QRect::adjust(), buttonVisible(), QStyle::CC_ComboBox, QStyle::CC_TitleBar, QStyleOption::direction, height, QSize::height(), QIcon::Normal, pixelMetric(), QStyle::PM_SmallIconSize, QStyleOption::rect, QStyle::SC_ComboBoxArrow, QStyle::SC_ComboBoxEditField, QStyle::SC_ComboBoxFrame, QStyle::SC_ComboBoxListBoxPopup, QStyle::SC_TitleBarCloseButton, QStyle::SC_TitleBarLabel, QStyle::SC_TitleBarMaxButton, QStyle::SC_TitleBarMinButton, QStyle::SC_TitleBarNormalButton, QStyle::SC_TitleBarShadeButton, QStyle::SC_TitleBarSysMenu, QStyle::SC_TitleBarUnshadeButton, QCommonStyle::subControlRect(), tb, QWindowsXPStylePrivate::useXP(), QStyle::visualRect(), QSize::width(), width, Qt::WindowContextHelpButtonHint, Qt::WindowMaximizeButtonHint, Qt::WindowMinimizeButtonHint, Qt::WindowShadeButtonHint, Qt::WindowSystemMenuHint, x, and y.

Referenced by drawComplexControl().

03435 {
03436     if (!QWindowsXPStylePrivate::useXP())
03437         return QWindowsStyle::subControlRect(cc, option, sc, widget);
03438 
03439     QRect rect;
03440 
03441     switch (cc) {
03442     case CC_TitleBar:
03443         if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
03444             if (!buttonVisible(sc, tb))
03445                 return rect;
03446             const bool isToolTitle = false; // widget->testWFlags(Qt::WA_WState_Tool)
03447             const int height = tb->rect.height();
03448             const int width = tb->rect.width();
03449             const int controlTop = 6; //widget->testWFlags(Qt::WA_WState_Tool) ? 4 : 6;
03450             const int controlHeight = height - controlTop - 3;
03451 
03452             const bool sysmenuHint  = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
03453             const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
03454             const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0;
03455             const bool contextHint = (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) != 0;
03456             const bool shadeHint = (tb->titleBarFlags & Qt::WindowShadeButtonHint) != 0;
03457 
03458             switch (sc) {
03459             case SC_TitleBarLabel:
03460                 rect = QRect(0, 0, width, height);
03461                 if (isToolTitle) {
03462                     if (sysmenuHint)
03463                         rect.adjust(0, 0, -controlHeight-3, 0);
03464                     if (minimizeHint || maximizeHint)
03465                         rect.adjust(0, 0, -controlHeight-2, 0);
03466                 } else {
03467                     if (sysmenuHint)
03468                         rect.adjust(controlHeight+3, 0, -controlHeight-3, 0);
03469                     if (minimizeHint)
03470                         rect.adjust(0, 0, -controlHeight-2, 0);
03471                     if (maximizeHint)
03472                         rect.adjust(0, 0, -controlHeight-2, 0);
03473                     if (contextHint)
03474                         rect.adjust(0, 0, -controlHeight-2, 0);
03475                     if (shadeHint)
03476                         rect.adjust(0, 0, -controlHeight-2, 0);
03477                 }
03478                 break;
03479 
03480             case SC_TitleBarCloseButton:
03481                 rect = QRect(width - (controlHeight + 2) - controlTop, controlTop,
03482                              controlHeight, controlHeight);
03483                 break;
03484 
03485             case SC_TitleBarMaxButton:
03486             case SC_TitleBarShadeButton:
03487             case SC_TitleBarUnshadeButton:
03488                 rect = QRect(width - ((controlHeight + 2) * 2) - controlTop, controlTop,
03489                              controlHeight, controlHeight);
03490                 break;
03491 
03492             case SC_TitleBarMinButton:
03493             case SC_TitleBarNormalButton:
03494                 {
03495                     int offset = controlHeight + 2;
03496                     if (!maximizeHint)
03497                         offset *= 2;
03498                     else
03499                         offset *= 3;
03500                     rect = QRect(width - offset - controlTop, controlTop,
03501                                  controlHeight, controlHeight);
03502                 }
03503                 break;
03504 
03505             case SC_TitleBarSysMenu:
03506                 {
03507                     QSize iconSize = tb->icon.pixmap(pixelMetric(PM_SmallIconSize), QIcon::Normal).size();
03508                     if (tb->icon.isNull())
03509                         iconSize = QSize(controlHeight, controlHeight);
03510                     int hPad = (controlHeight - iconSize.height())/2;
03511                     int vPad = (controlHeight - iconSize.width())/2;
03512                     rect = QRect(3 + vPad, controlTop + hPad, iconSize.width(), controlHeight - hPad);
03513                 }
03514                 break;
03515             }
03516         }
03517         break;
03518 
03519     case CC_ComboBox:
03520         if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
03521             int x = cmb->rect.x(), y = cmb->rect.y(), wi = cmb->rect.width(), he = cmb->rect.height();
03522             int xpos = x;
03523             xpos += wi - 1 - 16;
03524 
03525             switch (sc) {
03526             case SC_ComboBoxFrame:
03527                 rect = cmb->rect;
03528                 break;
03529 
03530             case SC_ComboBoxArrow:
03531                 rect = QRect(xpos, y+1, 16, he-2);
03532                 break;
03533 
03534             case SC_ComboBoxEditField:
03535                 rect = QRect(x+2, y+2, wi-3-16, he-4);
03536                 break;
03537 
03538             case SC_ComboBoxListBoxPopup:
03539                 rect = cmb->rect;
03540                 break;
03541             }
03542         }
03543         break;
03544 
03545     default:
03546         rect = visualRect(option->direction, option->rect,
03547                           QWindowsStyle::subControlRect(cc, option, sc, widget));
03548         break;
03549     }
03550     return visualRect(option->direction, option->rect, rect);
03551 }

Here is the call graph for this function:

void QWindowsXPStyle::drawComplexControl ( ComplexControl  cc,
const QStyleOptionComplex option,
QPainter p,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 2518 of file qwindowsxpstyle.cpp.

References QRect::adjusted(), Qt::AlignCenter, Qt::AlignLeft, Qt::AlignVCenter, QStyleOptionToolButton::Arrow, QWidget::backgroundRole(), QPalette::brush(), CBS_INACTIVE, QStyle::CC_ComboBox, QStyle::CC_ScrollBar, QStyle::CC_Slider, QStyle::CC_SpinBox, QStyle::CC_TitleBar, QStyle::CC_ToolButton, QStyle::CE_ToolButtonLabel, QRect::center(), d, Qt::DownArrow, QWindowsStyle::drawComplexControl(), drawControl(), QStyle::drawItemPixmap(), drawPrimitive(), QStyleOptionToolButton::features, flags, XPThemeData::handle(), QWidget::hasFocus(), QWidget::height(), QRect::height(), Qt::Horizontal, QWidget::isActiveWindow(), QRect::isEmpty(), QWidget::isEnabled(), QRect::left(), Qt::LeftArrow, len, MAXBS_INACTIVE, QAbstractSlider::maximum(), MINBS_INACTIVE, QAbstractSlider::minimum(), XPThemeData::name, XPThemeData::noContent, QAbstractSlider::orientation(), p, QWidget::palette(), XPThemeData::partId, QStyle::PE_FrameFocusRect, QStyle::PE_IndicatorButtonDropDown, QStyle::PE_PanelButtonBevel, QStyle::PE_PanelButtonTool, pGetThemeColor, pGetThemeEnumValue, pGetThemeMargins, pGetThemePartSize, pixelMetric(), QStyle::PM_DefaultFrameWidth, QStyle::PM_SliderControlThickness, QStyle::PM_SliderLength, QStyle::PM_SliderSpaceAvailable, QStyle::PM_SliderTickmarkOffset, qRgb(), qt_win_display_dc(), RBS_INACTIVE, XPThemeData::rect, QStyleOption::rect, QWidget::rect(), Qt::RightArrow, Qt::RightToLeft, QStyle::SC_ComboBoxArrow, QStyle::SC_ComboBoxEditField, QStyle::SC_ScrollBarAddLine, QStyle::SC_ScrollBarAddPage, QStyle::SC_ScrollBarSlider, QStyle::SC_ScrollBarSubLine, QStyle::SC_ScrollBarSubPage, QStyle::SC_SliderGroove, QStyle::SC_SliderHandle, QStyle::SC_SliderTickmarks, QStyle::SC_SpinBoxDown, QStyle::SC_SpinBoxFrame, QStyle::SC_SpinBoxUp, QStyle::SC_TitleBarCloseButton, QStyle::SC_TitleBarLabel, QStyle::SC_TitleBarMaxButton, QStyle::SC_TitleBarMinButton, QStyle::SC_TitleBarNormalButton, QStyle::SC_TitleBarShadeButton, QStyle::SC_TitleBarSysMenu, QStyle::SC_TitleBarUnshadeButton, QStyle::SC_ToolButton, QStyle::SC_ToolButtonMenu, QStyle::SE_SliderFocusRect, QRect::setHeight(), QRect::setLeft(), QRect::setTop(), QRect::setWidth(), size, QStyle::sliderPositionFromValue(), QStyle::SP_TitleBarMenuButton, standardPixmap(), QStyleOption::state, QStyle::State_Active, QStyle::State_AutoRaise, QStyle::State_Enabled, QStyle::State_HasFocus, QStyle::State_Horizontal, QStyle::State_MouseOver, QStyle::State_On, QStyle::State_Raised, QStyle::State_Sunken, XPThemeData::stateId, QAbstractSpinBox::StepDownEnabled, QAbstractSpinBox::StepUpEnabled, subControlRect(), QStyleOptionComplex::subControls, subElementRect(), tb, TBL_STATE, QWidget::testAttribute(), Qt::TextSingleLine, QSlider::TicksAbove, QSlider::TicksBelow, QSlider::TicksLeft, QSlider::TicksRight, TMT_SIZINGMARGINS, TMT_TEXTSHADOWCOLOR, TMT_TEXTSHADOWTYPE, QRect::top(), XPThemeData::toRECT(), TST_NONE, type, QRect::united(), Qt::UpArrow, QWindowsXPStylePrivate::useXP(), Qt::WA_UnderMouse, QRect::width(), QWidget::width(), Qt::WindowMaximizeButtonHint, Qt::WindowMinimizeButtonHint, Qt::WindowMinimized, Qt::WindowShadeButtonHint, Qt::WindowSystemMenuHint, QRect::x(), QPoint::x(), QRect::y(), and QPoint::y().

02520 {
02521     QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
02522 
02523     if (!QWindowsXPStylePrivate::useXP()) {
02524         QWindowsStyle::drawComplexControl(cc, option, p, widget);
02525         return;
02526     }
02527 
02528     State flags = option->state;
02529     SubControls sub = option->subControls;
02530     QRect r = option->rect;
02531 
02532     int partId = 0;
02533     int stateId = 0;
02534     if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
02535         flags |= State_MouseOver;
02536 
02537     switch (cc) {
02538     case CC_SpinBox:
02539         if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
02540         {
02541             XPThemeData theme(widget, p, "SPIN");
02542 
02543             if (sb->frame && (sub & SC_SpinBoxFrame)) {
02544                 partId = EP_EDITTEXT;
02545                 if (!(flags & State_Enabled))
02546                     stateId = ETS_DISABLED;
02547                 else if (flags & State_HasFocus)
02548                     stateId = ETS_FOCUSED;
02549                 else
02550                     stateId = ETS_NORMAL;
02551 
02552                 XPThemeData ftheme(widget, p, "EDIT", partId, stateId, r);
02553                 ftheme.noContent = true;
02554                 d->drawBackground(ftheme);
02555             }
02556             if (sub & SC_SpinBoxUp) {
02557                 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
02558                 partId = SPNP_UP;
02559                 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
02560                     stateId = UPS_DISABLED;
02561                 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
02562                     stateId = UPS_PRESSED;
02563                 else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
02564                     stateId = UPS_HOT;
02565                 else
02566                     stateId = UPS_NORMAL;
02567                 theme.partId = partId;
02568                 theme.stateId = stateId;
02569                 d->drawBackground(theme);
02570             }
02571             if (sub & SC_SpinBoxDown) {
02572                 theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
02573                 partId = SPNP_DOWN;
02574                 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
02575                     stateId = DNS_DISABLED;
02576                 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
02577                     stateId = DNS_PRESSED;
02578                 else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
02579                     stateId = DNS_HOT;
02580                 else
02581                     stateId = DNS_NORMAL;
02582                 theme.partId = partId;
02583                 theme.stateId = stateId;
02584                 d->drawBackground(theme);
02585             }
02586         }
02587         break;
02588 
02589     case CC_ComboBox:
02590         if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
02591         {
02592             if (sub & SC_ComboBoxEditField) {
02593                 partId = EP_EDITTEXT;
02594                 if (!(flags & State_Enabled))
02595                     stateId = ETS_DISABLED;
02596                 else if (flags & State_HasFocus)
02597                     stateId = ETS_FOCUSED;
02598                 else
02599                     stateId = ETS_NORMAL;
02600                 XPThemeData theme(widget, p, "EDIT", partId, stateId, r);
02601 
02602                 d->drawBackground(theme);
02603                 if (!cmb->editable) {
02604                     QRect re = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
02605                     if (widget && widget->hasFocus()) {
02606                         p->fillRect(re, option->palette.highlight());
02607                         p->setPen(option->palette.highlightedText().color());
02608                         p->setBackground(option->palette.highlight());
02609                     } else {
02610                         p->fillRect(re, option->palette.base());
02611                         p->setPen(option->palette.text().color());
02612                         p->setBackground(option->palette.base());
02613                     }
02614                 }
02615             }
02616 
02617             if (sub & SC_ComboBoxArrow) {
02618                 XPThemeData theme(widget, p, "COMBOBOX");
02619                 theme.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
02620                 partId = CP_DROPDOWNBUTTON;
02621 
02622                 if (!(flags & State_Enabled))
02623                     stateId = CBXS_DISABLED;
02624                 else if (cmb->activeSubControls == SC_ComboBoxArrow && (cmb->state & State_Sunken))
02625                     stateId = CBXS_PRESSED;
02626                 else if (cmb->activeSubControls == SC_ComboBoxArrow && (cmb->state & State_MouseOver))
02627                     stateId = CBXS_HOT;
02628                 else
02629                     stateId = CBXS_NORMAL;
02630                 theme.partId = partId;
02631                 theme.stateId = stateId;
02632                 d->drawBackground(theme);
02633             }
02634         }
02635         break;
02636 
02637     case CC_ScrollBar:
02638         if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option))
02639         {
02640             XPThemeData theme(widget, p, "SCROLLBAR");
02641             QScrollBar *bar = (QScrollBar*)widget;
02642             bool maxedOut = (bar->maximum() == bar->minimum());
02643             if (maxedOut)
02644                 flags &= ~State_Enabled;
02645 
02646             bool isHorz = flags & State_Horizontal;
02647             bool isRTL  = option->direction == Qt::RightToLeft;
02648             if (sub & SC_ScrollBarAddLine) {
02649                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
02650                 partId = SBP_ARROWBTN;
02651                 if (!(flags & State_Enabled))
02652                     stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
02653                 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
02654                     stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
02655                 else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
02656                     stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
02657                 else
02658                     stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
02659                 theme.partId = partId;
02660                 theme.stateId = stateId;
02661                 d->drawBackground(theme);
02662             }
02663             if (sub & SC_ScrollBarSubLine) {
02664                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
02665                 partId = SBP_ARROWBTN;
02666                 if (!(flags & State_Enabled))
02667                     stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
02668                 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
02669                     stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
02670                 else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
02671                     stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
02672                 else
02673                     stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
02674                 theme.partId = partId;
02675                 theme.stateId = stateId;
02676                 d->drawBackground(theme);
02677             }
02678             if (maxedOut) {
02679                 theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
02680                 theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
02681                 theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
02682                 partId = bar->orientation() == Qt::Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
02683                 stateId = SCRBS_DISABLED;
02684                 theme.partId = partId;
02685                 theme.stateId = stateId;
02686                 d->drawBackground(theme);
02687             } else {
02688                 if (sub & SC_ScrollBarSubPage) {
02689                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
02690                     partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
02691                     if (!(flags & State_Enabled))
02692                         stateId = SCRBS_DISABLED;
02693                     else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
02694                         stateId = SCRBS_PRESSED;
02695                     else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
02696                         stateId = SCRBS_HOT;
02697                     else
02698                         stateId = SCRBS_NORMAL;
02699                     theme.partId = partId;
02700                     theme.stateId = stateId;
02701                     d->drawBackground(theme);
02702                 }
02703                 if (sub & SC_ScrollBarAddPage) {
02704                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
02705                     partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
02706                     if (!(flags & State_Enabled))
02707                         stateId = SCRBS_DISABLED;
02708                     else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
02709                         stateId = SCRBS_PRESSED;
02710                     else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
02711                         stateId = SCRBS_HOT;
02712                     else
02713                         stateId = SCRBS_NORMAL;
02714                     theme.partId = partId;
02715                     theme.stateId = stateId;
02716                     d->drawBackground(theme);
02717                 }
02718                 if (sub & SC_ScrollBarSlider) {
02719                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
02720                     if (!(flags & State_Enabled))
02721                         stateId = SCRBS_DISABLED;
02722                     else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
02723                         stateId = SCRBS_PRESSED;
02724                     else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
02725                         stateId = SCRBS_HOT;
02726                     else
02727                         stateId = SCRBS_NORMAL;
02728 
02729                     // Draw handle
02730                     theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
02731                     theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
02732                     theme.stateId = stateId;
02733                     d->drawBackground(theme);
02734 
02735                     // Calculate rect of gripper
02736                     const int swidth = theme.rect.width();
02737                     const int sheight = theme.rect.height();
02738 
02739                     MARGINS contentsMargin;
02740                     RECT rect = theme.toRECT(theme.rect);
02741                     pGetThemeMargins(theme.handle(), 0, theme.partId, theme.stateId, TMT_SIZINGMARGINS, &rect, &contentsMargin);
02742 
02743                     SIZE size;
02744                     theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
02745                     pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
02746                     int gw = size.cx, gh = size.cy;
02747 
02748 
02749                     QRect gripperBounds;
02750                     if (flags & State_Horizontal && ((swidth - contentsMargin.cxLeftWidth - contentsMargin.cxRightWidth) > gw)) {
02751                         gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
02752                         gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
02753                         gripperBounds.setWidth(gw);
02754                         gripperBounds.setHeight(gh);
02755                     } else if ((sheight - contentsMargin.cyTopHeight - contentsMargin.cyBottomHeight) > gh) {
02756                         gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
02757                         gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
02758                         gripperBounds.setWidth(gw);
02759                         gripperBounds.setHeight(gh);
02760                     }
02761 
02762                     // Draw gripper if there is enough space
02763                     if (!gripperBounds.isEmpty()) {
02764                         p->save();
02765                         XPThemeData grippBackground = theme;
02766                         grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
02767                         theme.rect = gripperBounds;
02768                         p->setClipRegion(d->region(theme));// Only change inside the region of the gripper
02769                         d->drawBackground(grippBackground);// The gutter is the grippers background
02770                         d->drawBackground(theme);          // Transparent gripper ontop of background
02771                         p->restore();
02772                     }
02773                 }
02774             }
02775         }
02776         break;
02777 
02778 #ifndef QT_NO_SLIDER
02779     case CC_Slider:
02780         if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option))
02781         {
02782             XPThemeData theme(widget, p, "TRACKBAR");
02783             QSlider *sl = (QSlider*)widget;
02784             QRegion tickreg = sl->rect();
02785             if (sub & SC_SliderGroove) {
02786                 theme.rect = subControlRect(CC_Slider, option, SC_SliderGroove, widget);
02787                 if (slider->orientation == Qt::Horizontal) {
02788                     partId = TKP_TRACK;
02789                     stateId = TRS_NORMAL;
02790                     theme.rect = QRect(0, theme.rect.center().y() - 2, sl->width(), 4);
02791                 } else {
02792                     partId = TKP_TRACKVERT;
02793                     stateId = TRVS_NORMAL;
02794                     theme.rect = QRect(theme.rect.center().x() - 2, 0, 4, sl->height());
02795                 }
02796                 theme.partId = partId;
02797                 theme.stateId = stateId;
02798                 d->drawBackground(theme);
02799                 tickreg -= theme.rect;
02800             }
02801             if (sub & SC_SliderTickmarks) {
02802                 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget);
02803                 int ticks = slider->tickPosition;
02804                 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
02805                 int len = pixelMetric(PM_SliderLength, slider, widget);
02806                 int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget);
02807                 int interval = slider->tickInterval;
02808                 if (interval <= 0) {
02809                     interval = slider->singleStep;
02810                     if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
02811                                                         available)
02812                         - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
02813                                                           0, available) < 3)
02814                         interval = slider->pageStep;
02815                 }
02816                 if (!interval)
02817                     interval = 1;
02818                 int fudge = len / 2;
02819                 int pos;
02820                 int bothOffset = (ticks & QSlider::TicksAbove && ticks & QSlider::TicksBelow) ? 1 : 0;
02821                 p->setPen(d->sliderTickColor);
02822                 int v = slider->minimum;
02823                 while (v <= slider->maximum) {
02824                     int tickLength = (v == slider->minimum || v >= slider->maximum) ? 4 : 3;
02825                     pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
02826                                                           v, available) + fudge;
02827                     if (slider->orientation == Qt::Horizontal) {
02828                         if (ticks & QSlider::TicksAbove)
02829                             p->drawLine(pos, tickOffset - 1 - bothOffset,
02830                                         pos, tickOffset - 1 - bothOffset - tickLength);
02831 
02832                         if (ticks & QSlider::TicksBelow)
02833                             p->drawLine(pos, tickOffset + thickness + bothOffset,
02834                                         pos, tickOffset + thickness + bothOffset + tickLength);
02835                     } else {
02836                         if (ticks & QSlider::TicksAbove)
02837                             p->drawLine(tickOffset - 1 - bothOffset, pos,
02838                                         tickOffset - 1 - bothOffset - tickLength, pos);
02839 
02840                         if (ticks & QSlider::TicksBelow)
02841                             p->drawLine(tickOffset + thickness + bothOffset, pos,
02842                                         tickOffset + thickness + bothOffset + tickLength, pos);
02843                     }
02844                     v += interval;
02845                 }
02846             }
02847             if (sub & SC_SliderHandle) {
02848                 theme.rect = subControlRect(CC_Slider, option, SC_SliderHandle, widget);
02849                 p->fillRect(theme.rect, option->palette.background());
02850                 if (slider->orientation == Qt::Horizontal) {
02851                     if (slider->tickPosition == QSlider::TicksAbove)
02852                         partId = TKP_THUMBTOP;
02853                     else if (slider->tickPosition == QSlider::TicksBelow)
02854                         partId = TKP_THUMBBOTTOM;
02855                     else
02856                         partId = TKP_THUMB;
02857 
02858                     if (widget && !widget->isEnabled())
02859                         stateId = TUS_DISABLED;
02860                     else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
02861                         stateId = TUS_PRESSED;
02862                     else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
02863                         stateId = TUS_HOT;
02864                     else if (flags & State_HasFocus)
02865                         stateId = TUS_FOCUSED;
02866                     else
02867                         stateId = TUS_NORMAL;
02868                 } else {
02869                     if (slider->tickPosition == QSlider::TicksLeft)
02870                         partId = TKP_THUMBLEFT;
02871                     else if (slider->tickPosition == QSlider::TicksRight)
02872                         partId = TKP_THUMBRIGHT;
02873                     else
02874                         partId = TKP_THUMBVERT;
02875 
02876                     if (widget && !widget->isEnabled())
02877                         stateId = TUVS_DISABLED;
02878                     else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
02879                         stateId = TUVS_PRESSED;
02880                     else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
02881                         stateId = TUVS_HOT;
02882                     else if (flags & State_HasFocus)
02883                         stateId = TUVS_FOCUSED;
02884                     else
02885                         stateId = TUVS_NORMAL;
02886                 }
02887                 theme.partId = partId;
02888                 theme.stateId = stateId;
02889                 d->drawBackground(theme);
02890             }
02891             if (slider->state & State_HasFocus) {
02892                 QStyleOptionFocusRect fropt;
02893                 fropt.QStyleOption::operator=(*slider);
02894                 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
02895                 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
02896             }
02897         }
02898         break;
02899 #endif
02900 
02901     case CC_ToolButton:
02902         if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option))
02903         {
02904             XPThemeData theme(widget, p, "TOOLBAR");
02905             QToolButton *tb = (QToolButton*)widget;
02906 
02907             QRect button, menuarea;
02908             button = subControlRect(cc, toolbutton, SC_ToolButton, widget);
02909             menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
02910 
02911             State bflags = flags, mflags = flags;
02912 
02913             if (toolbutton->activeSubControls == SC_ToolButton)
02914                 bflags |= State_Sunken;
02915             else if (toolbutton->activeSubControls == SC_ToolButtonMenu)
02916                 mflags |= State_Sunken;
02917 
02918             if (sub & SC_ToolButton) {
02919                 theme.rect = subControlRect(CC_ToolButton, option, SC_ToolButton, widget);
02920                 QWidget *pW = static_cast<QWidget *>(tb->parent());
02921 
02922                 // ########## CE_ToolButtonLabel
02923                 if (toolbutton->features & QStyleOptionToolButton::Arrow) {
02924                     Qt::ArrowType type = toolbutton->arrowType;
02925 
02926 #define TBL_STATE(prefix) \
02927                     if (!tb->isEnabled()) \
02928                         stateId = prefix##_DISABLED; \
02929                     else if (bflags & (State_Sunken | State_On)) \
02930                         stateId = prefix##_PRESSED; \
02931                     else if (bflags & State_MouseOver) \
02932                         stateId = prefix##_HOT; \
02933                     else \
02934                         stateId = prefix##_NORMAL;
02935 
02936                     switch(type)
02937                     {
02938                     case Qt::RightArrow:
02939                         partId = SPNP_UPHORZ;
02940                         TBL_STATE(UPHZS);
02941                         break;
02942                     case Qt::LeftArrow:
02943                         partId = SPNP_DOWNHORZ;
02944                         TBL_STATE(DNHZS);
02945                         break;
02946                     case Qt::UpArrow:
02947                         partId = SPNP_UP;
02948                         TBL_STATE(UPS);
02949                         break;
02950                     case Qt::DownArrow:
02951                     default:
02952                         partId = SPNP_DOWN;
02953                         TBL_STATE(DNS);
02954                         break;
02955                     }
02956                     theme.name = "SPIN";
02957                     theme.partId = partId;
02958                     theme.stateId = stateId;
02959                     d->drawBackground(theme);
02960                 } else if (bflags & (State_Sunken | State_On | State_Raised)) {
02961                     if (sub & SC_ToolButtonMenu) {
02962                         partId = TP_SPLITBUTTON;
02963                         if (!flags & State_Enabled)
02964                             stateId = TS_DISABLED;
02965                         else if (flags & State_Sunken)
02966                             stateId = TS_PRESSED;
02967                         else if (flags & State_MouseOver)
02968                             stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
02969                         else if (flags & State_On)
02970                             stateId = TS_CHECKED;
02971                         else
02972                             stateId = TS_NORMAL;
02973 
02974                         theme.partId = partId;
02975                         theme.stateId = stateId;
02976                         d->drawBackground(theme);
02977                     } else {
02978                         if (widget && !qobject_cast<QToolBar*>(widget->parentWidget()) && !(bflags & State_AutoRaise))
02979                             drawPrimitive(PE_PanelButtonBevel, option, p, widget);
02980                         else
02981                             drawPrimitive(PE_PanelButtonTool, option, p, widget);
02982                     }
02983                 } else if (pW &&
02984                            !pW->palette().brush(pW->backgroundRole()).texture().isNull()) {
02985                     p->drawTiledPixmap(r, pW->palette().brush(pW->backgroundRole()).texture(), tb->pos());
02986                 }
02987             }
02988             if (sub & SC_ToolButtonMenu) {
02989                 QStyleOptionToolButton menuOption = *toolbutton;
02990                 menuOption.state = mflags;
02991                 menuOption.rect = subControlRect(CC_ToolButton, option, SC_ToolButtonMenu, widget);
02992                 drawPrimitive(PE_IndicatorButtonDropDown, &menuOption, p, widget);
02993             }
02994 
02995             QStyleOptionToolButton label = *toolbutton;
02996             int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
02997             label.rect = button.adjusted(fw, fw, -fw, -fw);
02998             label.features &= ~QStyleOptionToolButton::Arrow;
02999             drawControl(CE_ToolButtonLabel, &label, p, widget);
03000             //if (tb->hasFocus() && !tb->focusProxy()) {
03001             //    Q3StyleOptionFocusRect option(0);
03002             //    option.rect = tb->rect();
03003             //    option.rect.adjust(3, 3, -3, -3);
03004             //    option.palette = pal;
03005             //    option.state = State_Default;
03006             //    drawPrimitive(PE_FrameFocusRect, &option, p, tb);
03007             //}
03008         }
03009         break;
03010 
03011     case CC_TitleBar:
03012         {
03013             if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option))
03014             {
03015                 bool isActive = tb->titleBarState & QStyle::State_Active;
03016                 XPThemeData theme(widget, p, "WINDOW");
03017                 if (sub & SC_TitleBarLabel) {
03018                     theme.rect = option->rect;
03019                     partId = WP_CAPTION;
03020                     //partId = (tb->titleBarState & WindowMinimized)(titlebar->window() && titlebar->window()->isMinimized() ? WP_MINCAPTION : WP_CAPTION);
03021                     partId = (tb->titleBarState & Qt::WindowMinimized) ? WP_MINCAPTION : WP_CAPTION;
03022                     if (widget && !widget->isEnabled())
03023                         stateId = CS_DISABLED;
03024                     else if (isActive)
03025                         stateId = CS_ACTIVE;
03026                     else
03027                         stateId = CS_INACTIVE;
03028 
03029                     theme.partId = partId;
03030                     theme.stateId = stateId;
03031                     d->drawBackground(theme);
03032 
03033                     QRect ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
03034 
03035                     int result = TST_NONE;
03036                     pGetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
03037                     if (result != TST_NONE) {
03038                         COLORREF textShadowRef;
03039                         pGetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
03040                         QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
03041                         p->setPen(textShadow);
03042                         p->drawText(ir.x() + 3, ir.y() + 2, ir.width() - 1, ir.height(),
03043                                     Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
03044                     }
03045                     COLORREF captionText = GetSysColor(isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
03046                     QColor textColor = qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
03047                     p->setPen(textColor);
03048                     p->drawText(ir.x() + 2, ir.y() + 1, ir.width() - 2, ir.height(),
03049                                 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
03050                 }
03051                 if (sub & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
03052                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget);
03053                     partId = WP_SYSBUTTON;
03054                     if ((widget && !widget->isEnabled()) || !isActive)
03055                         stateId = SBS_DISABLED;
03056                     else if (option->activeSubControls == SC_TitleBarSysMenu && (option->state & State_Sunken))
03057                         stateId = SBS_PUSHED;
03058                     else if (option->activeSubControls == SC_TitleBarSysMenu && (option->state & State_MouseOver))
03059                         stateId = SBS_HOT;
03060                     else
03061                         stateId = SBS_NORMAL;
03062                     if (!tb->icon.isNull()) {
03063                         tb->icon.paint(p, theme.rect);
03064                     } else {
03065                         theme.partId = partId;
03066                         theme.stateId = stateId;
03067                         SIZE sz;
03068                         pGetThemePartSize(theme.handle(), qt_win_display_dc(), theme.partId, theme.stateId, 0, TS_TRUE, &sz);
03069                         if (sz.cx == 0 || sz.cy == 0) {
03070                             QPixmap pm = standardPixmap(SP_TitleBarMenuButton, tb, widget);
03071                             p->save();
03072                             drawItemPixmap(p, theme.rect, Qt::AlignCenter, pm);
03073                             p->restore();
03074                         } else {
03075                             d->drawBackground(theme);
03076                         }
03077                     }
03078                 }
03079 
03080                 if (sub & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint) {
03081                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget);
03082                     partId = WP_MINBUTTON;
03083                     if (widget && !widget->isEnabled())
03084                         stateId = MINBS_DISABLED;
03085                     else if (option->activeSubControls == SC_TitleBarMinButton && (option->state & State_Sunken))
03086                         stateId = MINBS_PUSHED;
03087                     else if (option->activeSubControls == SC_TitleBarMinButton && (option->state & State_MouseOver))
03088                         stateId = MINBS_HOT;
03089                     else if (!isActive)
03090                         stateId = MINBS_INACTIVE;
03091                     else
03092                         stateId = MINBS_NORMAL;
03093                     theme.partId = partId;
03094                     theme.stateId = stateId;
03095                     d->drawBackground(theme);
03096                 }
03097                 if (sub & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint) {
03098                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget);
03099                     partId = WP_MAXBUTTON;
03100                     if (widget && !widget->isEnabled())
03101                         stateId = MAXBS_DISABLED;
03102                     else if (option->activeSubControls == SC_TitleBarMaxButton && (option->state & State_Sunken))
03103                         stateId = MAXBS_PUSHED;
03104                     else if (option->activeSubControls == SC_TitleBarMaxButton && (option->state & State_MouseOver))
03105                         stateId = MAXBS_HOT;
03106                     else if (!isActive)
03107                         stateId = MAXBS_INACTIVE;
03108                     else
03109                         stateId = MAXBS_NORMAL;
03110                     theme.partId = partId;
03111                     theme.stateId = stateId;
03112                     d->drawBackground(theme);
03113                 }
03114                 if (sub & SC_TitleBarNormalButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint) {
03115                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget);
03116                     partId = WP_RESTOREBUTTON;
03117                     if (widget && !widget->isEnabled())
03118                         stateId = RBS_DISABLED;
03119                     else if (option->activeSubControls == SC_TitleBarNormalButton && (option->state & State_Sunken))
03120                         stateId = RBS_PUSHED;
03121                     else if (option->activeSubControls == SC_TitleBarNormalButton && (option->state & State_MouseOver))
03122                         stateId = RBS_HOT;
03123                     else if (!isActive)
03124                         stateId = RBS_INACTIVE;
03125                     else
03126                         stateId = RBS_NORMAL;
03127                     theme.partId = partId;
03128                     theme.stateId = stateId;
03129                     d->drawBackground(theme);
03130                 }
03131                 if (sub & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint) {
03132                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget);
03133                     partId = WP_MINBUTTON;
03134                     if (widget && !widget->isEnabled())
03135                         stateId = MINBS_DISABLED;
03136                     else if (option->activeSubControls == SC_TitleBarShadeButton && (option->state & State_Sunken))
03137                         stateId = MINBS_PUSHED;
03138                     else if (option->activeSubControls == SC_TitleBarShadeButton && (option->state & State_MouseOver))
03139                         stateId = MINBS_HOT;
03140                     else if (!isActive)
03141                         stateId = MINBS_INACTIVE;
03142                     else
03143                         stateId = MINBS_NORMAL;
03144                     theme.partId = partId;
03145                     theme.stateId = stateId;
03146                     d->drawBackground(theme);
03147                 }
03148                 if (sub & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint) {
03149                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget);
03150                     partId = WP_RESTOREBUTTON;
03151                     if (widget && !widget->isEnabled())
03152                         stateId = RBS_DISABLED;
03153                     else if (option->activeSubControls == SC_TitleBarUnshadeButton && (option->state & State_Sunken))
03154                         stateId = RBS_PUSHED;
03155                     else if (option->activeSubControls == SC_TitleBarUnshadeButton && (option->state & State_MouseOver))
03156                         stateId = RBS_HOT;
03157                     else if (!isActive)
03158                         stateId = RBS_INACTIVE;
03159                     else
03160                         stateId = RBS_NORMAL;
03161                     theme.partId = partId;
03162                     theme.stateId = stateId;
03163                     d->drawBackground(theme);
03164                 }
03165                 if (sub & SC_TitleBarCloseButton) {
03166                     theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget);
03167                     //partId = titlebar->testWFlags(Qt::WA_WState_Tool) ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON;
03168                     partId = WP_CLOSEBUTTON;
03169                     if (widget && !widget->isEnabled())
03170                         stateId = CBS_DISABLED;
03171                     else if (option->activeSubControls == SC_TitleBarCloseButton && (option->state & State_Sunken))
03172                         stateId = CBS_PUSHED;
03173                     else if (option->activeSubControls == SC_TitleBarCloseButton && (option->state & State_MouseOver))
03174                         stateId = CBS_HOT;
03175                     else if (!isActive)
03176                         stateId = CBS_INACTIVE;
03177                     else
03178                         stateId = CBS_NORMAL;
03179                     theme.partId = partId;
03180                     theme.stateId = stateId;
03181                     d->drawBackground(theme);
03182                 }
03183             }
03184         }
03185         break;
03186 
03187     default:
03188         QWindowsStyle::drawComplexControl(cc, option, p, widget);
03189         break;
03190     }
03191 }

Here is the call graph for this function:

QSize QWindowsXPStyle::sizeFromContents ( ContentsType  ct,
const QStyleOption option,
const QSize contentsSize,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 3556 of file qwindowsxpstyle.cpp.

References QStyle::CT_Menu, QStyle::CT_MenuBarItem, QStyle::CT_MenuItem, QStyle::CT_TabWidget, QSize::height(), QSize::isEmpty(), QStyleOptionMenuItem::Separator, QSize::setHeight(), QWindowsStyle::sizeFromContents(), QWindowsXPStylePrivate::useXP(), and windowsItemHMargin.

03558 {
03559     if (!QWindowsXPStylePrivate::useXP())
03560         return QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget);
03561 
03562     QSize sz(contentsSize);
03563 
03564     switch (ct) {
03565     case CT_TabWidget:
03566         sz += QSize(6, 6);
03567         break;
03568     case CT_Menu:
03569         sz -= QSize(1,2);
03570         break;
03571 #ifndef QT_NO_MENUBAR
03572     case CT_MenuBarItem:
03573         if (!sz.isEmpty())
03574             sz += QSize(windowsItemHMargin * 5 + 1, 6);
03575         break;
03576 #endif
03577     case CT_MenuItem:
03578         if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
03579         {
03580             if (menuitem->icon.isNull() && menuitem->menuItemType != QStyleOptionMenuItem::Separator) {
03581                 sz = QWindowsStyle::sizeFromContents(ct, option, sz, widget);
03582                 sz.setHeight(sz.height() - 2);
03583                 return sz;
03584             }
03585         }
03586         // Otherwise, fall through
03587     default:
03588         sz = QWindowsStyle::sizeFromContents(ct, option, sz, widget);
03589         break;
03590     }
03591 
03592     return sz;
03593 }

Here is the call graph for this function:

int QWindowsXPStyle::pixelMetric ( PixelMetric  pm,
const QStyleOption option = 0,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 3194 of file qwindowsxpstyle.cpp.

References QApplication::globalStrut(), XPThemeData::handle(), Qt::Horizontal, XPThemeData::isValid(), XPThemeData::partId, pGetThemePartSize, QWindowsStyle::pixelMetric(), QStyle::PM_ButtonShiftHorizontal, QStyle::PM_ButtonShiftVertical, QStyle::PM_DefaultFrameWidth, QStyle::PM_DockWidgetFrameWidth, QStyle::PM_DockWidgetSeparatorExtent, QStyle::PM_DockWidgetTitleMargin, QStyle::PM_ExclusiveIndicatorHeight, QStyle::PM_ExclusiveIndicatorWidth, QStyle::PM_IndicatorHeight, QStyle::PM_IndicatorWidth, QStyle::PM_MDIFrameWidth, QStyle::PM_MDIMinimizedWidth, QStyle::PM_MenuBarPanelWidth, QStyle::PM_MenuButtonIndicator, QStyle::PM_MenuHMargin, QStyle::PM_MenuPanelWidth, QStyle::PM_MenuVMargin, QStyle::PM_ProgressBarChunkWidth, QStyle::PM_ScrollBarExtent, QStyle::PM_SliderThickness, QStyle::PM_SpinBoxFrameWidth, QStyle::PM_SplitterWidth, QStyle::PM_TabBarBaseOverlap, QStyle::PM_TabBarTabOverlap, QStyle::PM_TitleBarHeight, QStyle::PM_ToolBarHandleExtent, qMax(), QTabBar::RoundedEast, QTabBar::RoundedNorth, QTabBar::RoundedSouth, QTabBar::RoundedWest, size, XPThemeData::stateId, QTabBar::TriangularEast, QTabBar::TriangularNorth, QTabBar::TriangularSouth, QTabBar::TriangularWest, QWindowsXPStylePrivate::useXP(), and width.

Referenced by drawComplexControl(), drawControl(), drawPrimitive(), subControlRect(), and subElementRect().

03195 {
03196     if (!QWindowsXPStylePrivate::useXP())
03197         return QWindowsStyle::pixelMetric(pm, option, widget);
03198 
03199     int res = 0;
03200     switch (pm) {
03201     case PM_MenuBarPanelWidth:
03202         res = 0;
03203         break;
03204 
03205     case PM_MenuPanelWidth:
03206     case PM_DefaultFrameWidth:
03207     case PM_SpinBoxFrameWidth:
03208         res = 1;
03209         break;
03210 
03211     case PM_TabBarTabOverlap:
03212     case PM_MenuHMargin:
03213     case PM_MenuVMargin:
03214         res = 2;
03215         break;
03216 
03217     case PM_TabBarBaseOverlap:
03218         if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
03219             switch (tab->shape) {
03220             case QTabBar::RoundedNorth:
03221             case QTabBar::TriangularNorth:
03222                 res = 1;
03223                 break;
03224             case QTabBar::RoundedSouth:
03225             case QTabBar::TriangularSouth:
03226                 res = 3;
03227                 break;
03228             case QTabBar::RoundedEast:
03229             case QTabBar::TriangularEast:
03230                 res = 3;
03231                 break;
03232             case QTabBar::RoundedWest:
03233             case QTabBar::TriangularWest:
03234                 res = 1;
03235                 break;
03236             }
03237         }
03238         break;
03239 
03240     case PM_SplitterWidth:
03241         res = qMax(5, QApplication::globalStrut().width());
03242         break;
03243 
03244     case PM_IndicatorWidth:
03245     case PM_IndicatorHeight:
03246         {
03247             XPThemeData theme(widget, 0, "BUTTON", BP_CHECKBOX, CBS_UNCHECKEDNORMAL);
03248             if (theme.isValid()) {
03249                 SIZE size;
03250                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03251                 res = (pm == PM_IndicatorWidth ? size.cx+2 : res = size.cy+2);
03252             }
03253         }
03254         break;
03255 
03256     case PM_ExclusiveIndicatorWidth:
03257     case PM_ExclusiveIndicatorHeight:
03258         {
03259             XPThemeData theme(widget, 0, "BUTTON", BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL);
03260             if (theme.isValid()) {
03261                 SIZE size;
03262                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03263                 res = (pm == PM_ExclusiveIndicatorWidth ? size.cx+2 : res = size.cy+2);
03264             }
03265         }
03266         break;
03267 
03268     case PM_ProgressBarChunkWidth:
03269         {
03270             Qt::Orientation orient = Qt::Horizontal;
03271             if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
03272                 orient = pb2->orientation;
03273             XPThemeData theme(widget, 0, "PROGRESS", (orient == Qt::Horizontal) ? PP_CHUNK : PP_CHUNKVERT);
03274             if (theme.isValid()) {
03275                 SIZE size;
03276                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03277                 res = (orient == Qt::Horizontal) ? size.cx : size.cy;
03278             }
03279         }
03280         break;
03281 
03282     case PM_ScrollBarExtent:
03283         {
03284             XPThemeData theme(widget, 0, "SCROLLBAR", SBP_SIZEBOX);
03285             if (theme.isValid()) {
03286                 SIZE size;
03287                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03288                 res = size.cy;
03289             }
03290         }
03291         break;
03292 
03293     case PM_SliderThickness:
03294         {
03295             XPThemeData theme(widget, 0, "TRACKBAR", TKP_THUMB);
03296             if (theme.isValid()) {
03297                 SIZE size;
03298                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03299                 res = size.cy;
03300             }
03301         }
03302         break;
03303 
03304     case PM_MenuButtonIndicator:
03305         {
03306             XPThemeData theme(widget, 0, "TOOLBAR", TP_SPLITBUTTONDROPDOWN);
03307             if (theme.isValid()) {
03308                 SIZE size;
03309                 pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03310                 res = size.cx;
03311             }
03312         }
03313         break;
03314 
03315     case PM_TitleBarHeight:
03316         {
03317             XPThemeData theme(widget, 0, "WINDOW", WP_CAPTION, CS_ACTIVE);
03318             if (theme.isValid()) {
03319                 SIZE size;
03320                 pGetThemePartSize(theme.handle(), 0, WP_CAPTION, CS_ACTIVE, 0, TS_TRUE, &size);
03321                 res = size.cy+1;
03322             }
03323         }
03324         break;
03325 
03326     case PM_MDIFrameWidth:
03327         {
03328             XPThemeData theme(widget, 0, "WINDOW", WP_FRAMELEFT, FS_ACTIVE);
03329             if (theme.isValid()) {
03330                 SIZE size;
03331                 pGetThemePartSize(theme.handle(), 0, WP_FRAMELEFT, FS_ACTIVE, 0, TS_TRUE, &size);
03332                 res = size.cx-1;
03333             }
03334         }
03335         break;
03336 
03337     case PM_MDIMinimizedWidth:
03338         res = 160;
03339         break;
03340 
03341 #ifndef QT_NO_TOOLBAR
03342     case PM_ToolBarHandleExtent:
03343         res = 8;
03344         break;
03345 
03346 #endif // QT_NO_TOOLBAR
03347     case PM_DockWidgetFrameWidth:
03348     {
03349         XPThemeData theme(widget, 0, "WINDOW", WP_SMALLFRAMERIGHT, FS_ACTIVE);
03350         if (theme.isValid()) {
03351             SIZE size;
03352             pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03353             res = size.cx;
03354         }
03355     }
03356     break;
03357     case PM_DockWidgetSeparatorExtent:
03358         res = 4;
03359         break;
03360     case PM_DockWidgetTitleMargin:
03361         res = 3;
03362         break;
03363 
03364     case PM_ButtonShiftHorizontal:
03365     case PM_ButtonShiftVertical:
03366         if (qstyleoption_cast<const QStyleOptionToolButton *>(option))
03367             res = 1;
03368         else
03369             res = 0;
03370         break;
03371 
03372     default:
03373         res = QWindowsStyle::pixelMetric(pm, option, widget);
03374     }
03375 
03376     return res;
03377 }

Here is the call graph for this function:

int QWindowsXPStyle::styleHint ( StyleHint  hint,
const QStyleOption option = 0,
const QWidget widget = 0,
QStyleHintReturn returnData = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 3597 of file qwindowsxpstyle.cpp.

References d, QWidget::fontMetrics(), QFontMetrics::inFont(), QWidget::isEnabled(), mask, QStyleOption::rect, QStyle::SH_EtchDisabledText, QStyle::SH_GroupBox_TextLabelColor, QStyle::SH_LineEdit_PasswordCharacter, QStyle::SH_RubberBand_Mask, QStyle::SH_SpinControls_DisableOnBounds, QStyle::SH_Table_GridLineColor, QStyle::SH_TitleBar_AutoRaise, QStyle::SH_TitleBar_NoBorder, QStyle::SH_WindowFrame_Mask, QWindowsStyle::styleHint(), QWindowsXPStylePrivate::useXP(), and Qt::WindowMinimized.

Referenced by drawControl().

03599 {
03600   QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
03601     if (!QWindowsXPStylePrivate::useXP())
03602         return QWindowsStyle::styleHint(hint, option, widget, returnData);
03603 
03604     int res = 0;
03605     switch (hint) {
03606 
03607     case SH_EtchDisabledText:
03608         res = (qobject_cast<const QLabel*>(widget) != 0);
03609         break;
03610 
03611     case SH_SpinControls_DisableOnBounds:
03612         res = 0;
03613         break;
03614 
03615     case SH_TitleBar_AutoRaise:
03616     case SH_TitleBar_NoBorder:
03617         res = 1;
03618         break;
03619 
03620     case SH_GroupBox_TextLabelColor:
03621         if (!widget || (widget && widget->isEnabled()))
03622             res = d->groupBoxTextColor;
03623         else
03624             res = d->groupBoxTextColorDisabled;
03625         break;
03626 
03627     case SH_Table_GridLineColor:
03628         res = 0xC0C0C0;
03629         break;
03630 
03631     case SH_LineEdit_PasswordCharacter:
03632         {
03633             if (widget) {
03634                 const QFontMetrics &fm = widget->fontMetrics();
03635                 if (fm.inFont(QChar(0x25CF)))
03636                     res = 0x25CF;
03637                 else if (fm.inFont(QChar(0x2022)))
03638                     res = 0x2022;
03639             }
03640             if (!res)
03641                 res = '*';
03642         }
03643         break;
03644 
03645     case SH_WindowFrame_Mask:
03646         {
03647             res = 1;
03648             QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData);
03649             const QStyleOptionTitleBar *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(option);
03650             if (mask && titlebar) {
03651                 XPThemeData themeData;
03652                 if (titlebar->titleBarState & Qt::WindowMinimized) {
03653                     themeData = XPThemeData(widget, 0, "WINDOW", WP_MINCAPTION, CS_ACTIVE, option->rect);
03654                 } else
03655                     themeData = XPThemeData(widget, 0, "WINDOW", WP_CAPTION, CS_ACTIVE, option->rect);
03656                 mask->region = d->region(themeData);
03657             }
03658         }
03659         break;
03660 #ifndef QT_NO_RUBBERBAND
03661     case SH_RubberBand_Mask:
03662         if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(option)) {
03663             res = 0;
03664             break;
03665         }
03666 #endif // QT_NO_RUBBERBAND
03667 
03668     default:
03669         res =QWindowsStyle::styleHint(hint, option, widget, returnData);
03670     }
03671 
03672     return res;
03673 }

Here is the call graph for this function:

QPalette QWindowsXPStyle::standardPalette (  )  const [virtual]

Reimplemented from QStyle.

Definition at line 3676 of file qwindowsxpstyle.cpp.

References QStyle::standardPalette().

03677 {
03678     return QWindowsStyle::standardPalette();
03679 }

Here is the call graph for this function:

QPixmap QWindowsXPStyle::standardPixmap ( StandardPixmap  standardPixmap,
const QStyleOption option,
const QWidget widget = 0 
) const [virtual]

Reimplemented from QWindowsStyle.

Definition at line 3684 of file qwindowsxpstyle.cpp.

References pGetThemePartSize, QIcon::pixmap(), QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton, QStyle::standardIcon(), QWindowsStyle::standardPixmap(), and QWindowsXPStylePrivate::useXP().

Referenced by drawComplexControl(), and drawControl().

03686 {
03687     if (!QWindowsXPStylePrivate::useXP())
03688         return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
03689 
03690     switch(standardPixmap) {
03691     case SP_TitleBarMaxButton:
03692     case SP_TitleBarCloseButton:
03693         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
03694         {
03695             if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget)) {
03696                 if (dw->isFloating()) {
03697                     XPThemeData theme(widget, 0, "WINDOW", WP_SMALLCLOSEBUTTON, CBS_NORMAL);
03698                     if (theme.isValid()) {
03699                         SIZE sz;
03700                         pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &sz);
03701                         return QStyle::standardIcon(standardPixmap, option, widget).pixmap(QSize(sz.cx, sz.cy));
03702                     }
03703                 }
03704             }
03705         }
03706         break;
03707     }
03708     return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
03709 }

Here is the call graph for this function:

QIcon QWindowsXPStyle::standardIconImplementation ( StandardPixmap  standardIcon,
const QStyleOption option,
const QWidget widget = 0 
) const [protected, slot]

Since:
4.1
Returns an icon for the given standardIcon.

Reimplement this slot to provide your own icons in a QStyle subclass; because of binary compatibility constraints, the standardIcon() function (introduced in Qt 4.1) is not virtual. Instead, standardIcon() will dynamically detect and call this slot. The default implementation simply calls the standardPixmap() function with the given parameters.

The standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The option argument can be used to pass extra information required when defining the appropriate icon. The widget argument is optional and can also be used to aid the determination of the icon.

See also:
standardIcon()

Reimplemented from QWindowsStyle.

Definition at line 3714 of file qwindowsxpstyle.cpp.

References QIcon::Active, CBS_INACTIVE, d, QIcon::Disabled, XPThemeData::isValid(), MAXBS_INACTIVE, QIcon::Normal, QIcon::Off, QIcon::On, p, XPThemeData::painter, pGetThemePartSize, RBS_INACTIVE, XPThemeData::rect, size, QStyle::SP_TitleBarCloseButton, QStyle::SP_TitleBarMaxButton, QStyle::SP_TitleBarNormalButton, QWindowsStyle::standardIconImplementation(), XPThemeData::stateId, Qt::transparent, and QWindowsXPStylePrivate::useXP().

03717 {
03718     if (!QWindowsXPStylePrivate::useXP()) {
03719         return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
03720     }
03721 
03722     QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
03723     switch(standardIcon) {
03724     case SP_TitleBarMaxButton:
03725         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
03726         {
03727             if (d->dockFloat.isNull()) {
03728                 XPThemeData themeSize(0, 0, "WINDOW", WP_SMALLCLOSEBUTTON, CBS_NORMAL);
03729                 XPThemeData theme(0, 0, "WINDOW", WP_MAXBUTTON, MAXBS_NORMAL);
03730                 if (theme.isValid()) {
03731                     SIZE size;
03732                     pGetThemePartSize(themeSize.handle(), 0, themeSize.partId, themeSize.stateId, 0, TS_TRUE, &size);
03733                     QPixmap pm = QPixmap(size.cx, size.cy);
03734                     pm.fill(Qt::transparent);
03735                     QPainter p(&pm);
03736                     theme.painter = &p;
03737                     theme.rect = QRect(0, 0, size.cx, size.cy);
03738                     d->drawBackground(theme);
03739                     d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off);    // Normal
03740                     pm.fill(Qt::transparent);
03741                     theme.stateId = MAXBS_PUSHED;
03742                     d->drawBackground(theme);
03743                     d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On);     // Pressed
03744                     pm.fill(Qt::transparent);
03745                     theme.stateId = MAXBS_HOT;
03746                     d->drawBackground(theme);
03747                     d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off);    // Hover
03748                     pm.fill(Qt::transparent);
03749                     theme.stateId = MAXBS_INACTIVE;
03750                     d->drawBackground(theme);
03751                     d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off);  // Disabled
03752                 }
03753             }
03754             if (widget)
03755                 if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget))
03756                     if (dw->isFloating())
03757                         return d->dockFloat;
03758 
03759         }
03760         break;
03761     case SP_TitleBarCloseButton:
03762         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
03763         {
03764             if (d->dockClose.isNull()) {
03765                 XPThemeData theme(0, 0, "WINDOW", WP_SMALLCLOSEBUTTON, CBS_NORMAL);
03766                 if (theme.isValid()) {
03767                     SIZE size;
03768                     pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
03769                     QPixmap pm = QPixmap(size.cx, size.cy);
03770                     pm.fill(Qt::transparent);
03771                     QPainter p(&pm);
03772                     theme.painter = &p;
03773                     theme.partId = WP_CLOSEBUTTON; // ####
03774                     theme.rect = QRect(0, 0, size.cx, size.cy);
03775                     d->drawBackground(theme);
03776                     d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::Off);    // Normal
03777                     pm.fill(Qt::transparent);
03778                     theme.stateId = CBS_PUSHED;
03779                     d->drawBackground(theme);
03780                     d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::On);     // Pressed
03781                     pm.fill(Qt::transparent);
03782                     theme.stateId = CBS_HOT;
03783                     d->drawBackground(theme);
03784                     d->dockClose.addPixmap(pm, QIcon::Active, QIcon::Off);    // Hover
03785                     pm.fill(Qt::transparent);
03786                     theme.stateId = CBS_INACTIVE;
03787                     d->drawBackground(theme);
03788                     d->dockClose.addPixmap(pm, QIcon::Disabled, QIcon::Off);  // Disabled
03789                 }
03790             }
03791             if (widget)
03792                 if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget))
03793                     if (dw->isFloating())
03794                         return d->dockClose;
03795         }
03796         break;
03797         case SP_TitleBarNormalButton:
03798         if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
03799         {
03800             if (d->dockFloat.isNull()) {
03801                 XPThemeData themeSize(0, 0, "WINDOW", WP_SMALLCLOSEBUTTON, CBS_NORMAL);
03802                 XPThemeData theme(0, 0, "WINDOW", WP_RESTOREBUTTON, RBS_NORMAL);
03803                 if (theme.isValid()) {
03804                     SIZE size;
03805                     pGetThemePartSize(themeSize.handle(), 0, themeSize.partId, themeSize.stateId, 0, TS_TRUE, &size);
03806                     QPixmap pm = QPixmap(size.cx, size.cy);
03807                     pm.fill(Qt::transparent);
03808                     QPainter p(&pm);
03809                     theme.painter = &p;
03810                     theme.rect = QRect(0, 0, size.cx, size.cy);
03811                     d->drawBackground(theme);
03812                     d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off);    // Normal
03813                     pm.fill(Qt::transparent);
03814                     theme.stateId = RBS_PUSHED;
03815                     d->drawBackground(theme);
03816                     d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On);     // Pressed
03817                     pm.fill(Qt::transparent);
03818                     theme.stateId = RBS_HOT;
03819                     d->drawBackground(theme);
03820                     d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off);    // Hover
03821                     pm.fill(Qt::transparent);
03822                     theme.stateId = RBS_INACTIVE;
03823                     d->drawBackground(theme);
03824                     d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off);  // Disabled
03825                 }
03826             }
03827             if (widget)
03828                 if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget))
03829                     if (dw->isFloating())
03830                         return d->dockFloat;
03831 
03832         }
03833         break;
03834     }
03835 
03836     return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
03837 }


Friends And Related Function Documentation

friend class QStyleFactory [friend]

Definition at line 76 of file qwindowsxpstyle.h.


Member Data Documentation

void* QWindowsXPStyle::reserved [private]

Reimplemented from QWindowsStyle.

Definition at line 77 of file qwindowsxpstyle.h.


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 19:52:52 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1