Qt 4.8
Public Functions | Protected Slots | Friends | List of all members
QWindowsVistaStyle Class Reference

The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows Vista. More...

#include <qwindowsvistastyle.h>

Inheritance diagram for QWindowsVistaStyle:
QWindowsXPStyle QWindowsStyle QCommonStyle QStyle QObject

Public Functions

void drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
 
void drawControl (ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
 
void drawPrimitive (PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
 
bool event (QEvent *event)
 
SubControl hitTestComplexControl (ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=0) const
 
int pixelMetric (PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
 
void polish (QWidget *widget)
 
void polish (QPalette &pal)
 
void polish (QApplication *app)
 
 QWindowsVistaStyle ()
 Constructs a QWindowsVistaStyle object. More...
 
QSize sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
 
QPalette standardPalette () const
 
QPixmap standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
 
int styleHint (StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
 
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
 
QRect subElementRect (SubElement element, const QStyleOption *option, const QWidget *widget) const
 
void unpolish (QWidget *widget)
 
void unpolish (QApplication *app)
 
- Public Functions inherited from QWindowsXPStyle
void drawComplexControl (ComplexControl cc, const QStyleOptionComplex *option, QPainter *p, const QWidget *widget=0) const
 Reimplemented Function More...
 
void drawControl (ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *wwidget=0) const
 Reimplemented Function More...
 
void drawPrimitive (PrimitiveElement pe, const QStyleOption *option, QPainter *p, const QWidget *widget=0) const
 Reimplemented Function More...
 
int pixelMetric (PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
 Reimplemented Function More...
 
void polish (QApplication *)
 Reimplemented Function More...
 
void polish (QWidget *)
 Reimplemented Function More...
 
void polish (QPalette &)
 Reimplemented Function More...
 
 QWindowsXPStyle ()
 Constructs a QWindowsStyle. More...
 
 QWindowsXPStyle (QWindowsXPStylePrivate &dd)
 Constructs a QWindowsXPStyle object. More...
 
QSize sizeFromContents (ContentsType ct, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=0) const
 Reimplemented Function More...
 
QPalette standardPalette () const
 Reimplemented Function More...
 
QPixmap standardPixmap (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
 Reimplemented Function More...
 
int styleHint (StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
 Reimplemented Function More...
 
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget=0) const
 Reimplemented Function More...
 
QRect subElementRect (SubElement r, const QStyleOption *option, const QWidget *widget=0) const
 Reimplemented Function More...
 
void unpolish (QApplication *)
 Reimplemented Function More...
 
void unpolish (QWidget *)
 Reimplemented Function More...
 
 ~QWindowsXPStyle ()
 Destroys the style. More...
 
- Public Functions inherited from QWindowsStyle
 QWindowsStyle ()
 Constructs a QWindowsStyle object. More...
 
 ~QWindowsStyle ()
 Destroys the QWindowsStyle object. More...
 
- Public Functions inherited from QCommonStyle
QPixmap generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
 Reimplemented Function More...
 
 QCommonStyle ()
 Constructs a QCommonStyle. More...
 
 ~QCommonStyle ()
 Destroys the style. More...
 
- Public Functions inherited from QStyle
int combinedLayoutSpacing (QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=0, QWidget *widget=0) const
 Returns the spacing that should be used between controls1 and controls2 in a layout. More...
 
virtual void drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
 Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter. More...
 
virtual void drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
 Draws the given text in the specified rectangle using the provided painter and palette. More...
 
virtual QRect itemPixmapRect (const QRect &r, int flags, const QPixmap &pixmap) const
 Returns the area within the given rectangle in which to draw the specified pixmap according to the defined alignment. More...
 
virtual QRect itemTextRect (const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
 Returns the area within the given rectangle in which to draw the provided text according to the specified font metrics and alignment. More...
 
int layoutSpacing (QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=0, const QWidget *widget=0) const
 Returns the spacing that should be used between control1 and control2 in a layout. More...
 
const QStyleproxy () const
 
 QStyle ()
 Constructs a style object. More...
 
QIcon standardIcon (StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
 Returns an icon for the given standardIcon. More...
 
virtual ~QStyle ()
 Destroys the style object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Slots

QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
 
- Protected Slots inherited from QWindowsXPStyle
QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
 
- Protected Slots inherited from QWindowsStyle
QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
 
- Protected Slots inherited from QCommonStyle
QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
 
- Protected Slots inherited from QStyle
int layoutSpacingImplementation (QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=0, const QWidget *widget=0) const
 This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout. More...
 
QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
 Returns an icon for the given standardIcon. More...
 

Friends

class QStyleFactory
 

Additional Inherited Members

- Public Types inherited from QStyle
enum  ComplexControl {
  CC_SpinBox, CC_ComboBox, CC_ScrollBar, CC_Slider,
  CC_ToolButton, CC_TitleBar, CC_Q3ListView, CC_Dial,
  CC_GroupBox, CC_MdiControls, CC_CustomBase = 0xf0000000
}
 This enum describes the available complex controls. More...
 
enum  ContentsType {
  CT_PushButton, CT_CheckBox, CT_RadioButton, CT_ToolButton,
  CT_ComboBox, CT_Splitter, CT_Q3DockWindow, CT_ProgressBar,
  CT_MenuItem, CT_MenuBarItem, CT_MenuBar, CT_Menu,
  CT_TabBarTab, CT_Slider, CT_ScrollBar, CT_Q3Header,
  CT_LineEdit, CT_SpinBox, CT_SizeGrip, CT_TabWidget,
  CT_DialogButtons, CT_HeaderSection, CT_GroupBox, CT_MdiControls,
  CT_ItemViewItem, CT_CustomBase = 0xf0000000
}
 This enum describes the available contents types. More...
 
enum  ControlElement {
  CE_PushButton, CE_PushButtonBevel, CE_PushButtonLabel, CE_CheckBox,
  CE_CheckBoxLabel, CE_RadioButton, CE_RadioButtonLabel, CE_TabBarTab,
  CE_TabBarTabShape, CE_TabBarTabLabel, CE_ProgressBar, CE_ProgressBarGroove,
  CE_ProgressBarContents, CE_ProgressBarLabel, CE_MenuItem, CE_MenuScroller,
  CE_MenuVMargin, CE_MenuHMargin, CE_MenuTearoff, CE_MenuEmptyArea,
  CE_MenuBarItem, CE_MenuBarEmptyArea, CE_ToolButtonLabel, CE_Header,
  CE_HeaderSection, CE_HeaderLabel, CE_Q3DockWindowEmptyArea, CE_ToolBoxTab,
  CE_SizeGrip, CE_Splitter, CE_RubberBand, CE_DockWidgetTitle,
  CE_ScrollBarAddLine, CE_ScrollBarSubLine, CE_ScrollBarAddPage, CE_ScrollBarSubPage,
  CE_ScrollBarSlider, CE_ScrollBarFirst, CE_ScrollBarLast, CE_FocusFrame,
  CE_ComboBoxLabel, CE_ToolBar, CE_ToolBoxTabShape, CE_ToolBoxTabLabel,
  CE_HeaderEmptyArea, CE_ColumnViewGrip, CE_ItemViewItem, CE_ShapedFrame,
  CE_CustomBase = 0xf0000000
}
 This enum represents a control element. More...
 
enum  PixelMetric {
  PM_ButtonMargin, PM_ButtonDefaultIndicator, PM_MenuButtonIndicator, PM_ButtonShiftHorizontal,
  PM_ButtonShiftVertical, PM_DefaultFrameWidth, PM_SpinBoxFrameWidth, PM_ComboBoxFrameWidth,
  PM_MaximumDragDistance, PM_ScrollBarExtent, PM_ScrollBarSliderMin, PM_SliderThickness,
  PM_SliderControlThickness, PM_SliderLength, PM_SliderTickmarkOffset, PM_SliderSpaceAvailable,
  PM_DockWidgetSeparatorExtent, PM_DockWidgetHandleExtent, PM_DockWidgetFrameWidth, PM_TabBarTabOverlap,
  PM_TabBarTabHSpace, PM_TabBarTabVSpace, PM_TabBarBaseHeight, PM_TabBarBaseOverlap,
  PM_ProgressBarChunkWidth, PM_SplitterWidth, PM_TitleBarHeight, PM_MenuScrollerHeight,
  PM_MenuHMargin, PM_MenuVMargin, PM_MenuPanelWidth, PM_MenuTearoffHeight,
  PM_MenuDesktopFrameWidth, PM_MenuBarPanelWidth, PM_MenuBarItemSpacing, PM_MenuBarVMargin,
  PM_MenuBarHMargin, PM_IndicatorWidth, PM_IndicatorHeight, PM_ExclusiveIndicatorWidth,
  PM_ExclusiveIndicatorHeight, PM_CheckListButtonSize, PM_CheckListControllerSize, PM_DialogButtonsSeparator,
  PM_DialogButtonsButtonWidth, PM_DialogButtonsButtonHeight, PM_MdiSubWindowFrameWidth, PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth,
  PM_MdiSubWindowMinimizedWidth, PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, PM_HeaderMargin, PM_HeaderMarkSize,
  PM_HeaderGripMargin, PM_TabBarTabShiftHorizontal, PM_TabBarTabShiftVertical, PM_TabBarScrollButtonWidth,
  PM_ToolBarFrameWidth, PM_ToolBarHandleExtent, PM_ToolBarItemSpacing, PM_ToolBarItemMargin,
  PM_ToolBarSeparatorExtent, PM_ToolBarExtensionExtent, PM_SpinBoxSliderHeight, PM_DefaultTopLevelMargin,
  PM_DefaultChildMargin, PM_DefaultLayoutSpacing, PM_ToolBarIconSize, PM_ListViewIconSize,
  PM_IconViewIconSize, PM_SmallIconSize, PM_LargeIconSize, PM_FocusFrameVMargin,
  PM_FocusFrameHMargin, PM_ToolTipLabelFrameWidth, PM_CheckBoxLabelSpacing, PM_TabBarIconSize,
  PM_SizeGripSize, PM_DockWidgetTitleMargin, PM_MessageBoxIconSize, PM_ButtonIconSize,
  PM_DockWidgetTitleBarButtonMargin, PM_RadioButtonLabelSpacing, PM_LayoutLeftMargin, PM_LayoutTopMargin,
  PM_LayoutRightMargin, PM_LayoutBottomMargin, PM_LayoutHorizontalSpacing, PM_LayoutVerticalSpacing,
  PM_TabBar_ScrollButtonOverlap, PM_TextCursorWidth, PM_TabCloseIndicatorWidth, PM_TabCloseIndicatorHeight,
  PM_ScrollView_ScrollBarSpacing, PM_SubMenuOverlap, PM_CustomBase = 0xf0000000
}
 This enum describes the various available pixel metrics. More...
 
enum  PrimitiveElement {
  PE_Q3CheckListController, PE_Q3CheckListExclusiveIndicator, PE_Q3CheckListIndicator, PE_Q3DockWindowSeparator,
  PE_Q3Separator, PE_Frame, PE_FrameDefaultButton, PE_FrameDockWidget,
  PE_FrameFocusRect, PE_FrameGroupBox, PE_FrameLineEdit, PE_FrameMenu,
  PE_FrameStatusBar, PE_FrameStatusBarItem = PE_FrameStatusBar, PE_FrameTabWidget, PE_FrameWindow,
  PE_FrameButtonBevel, PE_FrameButtonTool, PE_FrameTabBarBase, PE_PanelButtonCommand,
  PE_PanelButtonBevel, PE_PanelButtonTool, PE_PanelMenuBar, PE_PanelToolBar,
  PE_PanelLineEdit, PE_IndicatorArrowDown, PE_IndicatorArrowLeft, PE_IndicatorArrowRight,
  PE_IndicatorArrowUp, PE_IndicatorBranch, PE_IndicatorButtonDropDown, PE_IndicatorViewItemCheck,
  PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck, PE_IndicatorCheckBox, PE_IndicatorDockWidgetResizeHandle, PE_IndicatorHeaderArrow,
  PE_IndicatorMenuCheckMark, PE_IndicatorProgressChunk, PE_IndicatorRadioButton, PE_IndicatorSpinDown,
  PE_IndicatorSpinMinus, PE_IndicatorSpinPlus, PE_IndicatorSpinUp, PE_IndicatorToolBarHandle,
  PE_IndicatorToolBarSeparator, PE_PanelTipLabel, PE_IndicatorTabTear, PE_PanelScrollAreaCorner,
  PE_Widget, PE_IndicatorColumnViewArrow, PE_IndicatorItemViewItemDrop, PE_PanelItemViewItem,
  PE_PanelItemViewRow, PE_PanelStatusBar, PE_IndicatorTabClose, PE_PanelMenu,
  PE_CustomBase = 0xf000000
}
 This enum describes the various primitive elements. More...
 
enum  RequestSoftwareInputPanel { RSIP_OnMouseClickAndAlreadyFocused, RSIP_OnMouseClick }
 This enum describes under what circumstances a software input panel will be requested by input capable widgets. More...
 
enum  StandardPixmap {
  SP_TitleBarMenuButton, SP_TitleBarMinButton, SP_TitleBarMaxButton, SP_TitleBarCloseButton,
  SP_TitleBarNormalButton, SP_TitleBarShadeButton, SP_TitleBarUnshadeButton, SP_TitleBarContextHelpButton,
  SP_DockWidgetCloseButton, SP_MessageBoxInformation, SP_MessageBoxWarning, SP_MessageBoxCritical,
  SP_MessageBoxQuestion, SP_DesktopIcon, SP_TrashIcon, SP_ComputerIcon,
  SP_DriveFDIcon, SP_DriveHDIcon, SP_DriveCDIcon, SP_DriveDVDIcon,
  SP_DriveNetIcon, SP_DirOpenIcon, SP_DirClosedIcon, SP_DirLinkIcon,
  SP_FileIcon, SP_FileLinkIcon, SP_ToolBarHorizontalExtensionButton, SP_ToolBarVerticalExtensionButton,
  SP_FileDialogStart, SP_FileDialogEnd, SP_FileDialogToParent, SP_FileDialogNewFolder,
  SP_FileDialogDetailedView, SP_FileDialogInfoView, SP_FileDialogContentsView, SP_FileDialogListView,
  SP_FileDialogBack, SP_DirIcon, SP_DialogOkButton, SP_DialogCancelButton,
  SP_DialogHelpButton, SP_DialogOpenButton, SP_DialogSaveButton, SP_DialogCloseButton,
  SP_DialogApplyButton, SP_DialogResetButton, SP_DialogDiscardButton, SP_DialogYesButton,
  SP_DialogNoButton, SP_ArrowUp, SP_ArrowDown, SP_ArrowLeft,
  SP_ArrowRight, SP_ArrowBack, SP_ArrowForward, SP_DirHomeIcon,
  SP_CommandLink, SP_VistaShield, SP_BrowserReload, SP_BrowserStop,
  SP_MediaPlay, SP_MediaStop, SP_MediaPause, SP_MediaSkipForward,
  SP_MediaSkipBackward, SP_MediaSeekForward, SP_MediaSeekBackward, SP_MediaVolume,
  SP_MediaVolumeMuted, SP_CustomBase = 0xf0000000
}
 This enum describes the available standard pixmaps. More...
 
enum  StateFlag {
  State_None = 0x00000000, State_Enabled = 0x00000001, State_Raised = 0x00000002, State_Sunken = 0x00000004,
  State_Off = 0x00000008, State_NoChange = 0x00000010, State_On = 0x00000020, State_DownArrow = 0x00000040,
  State_Horizontal = 0x00000080, State_HasFocus = 0x00000100, State_Top = 0x00000200, State_Bottom = 0x00000400,
  State_FocusAtBorder = 0x00000800, State_AutoRaise = 0x00001000, State_MouseOver = 0x00002000, State_UpArrow = 0x00004000,
  State_Selected = 0x00008000, State_Active = 0x00010000, State_Window = 0x00020000, State_Open = 0x00040000,
  State_Children = 0x00080000, State_Item = 0x00100000, State_Sibling = 0x00200000, State_Editing = 0x00400000,
  State_KeyboardFocusChange = 0x00800000, State_ReadOnly = 0x02000000, State_Small = 0x04000000, State_Mini = 0x08000000
}
 This enum describes flags that are used when drawing primitive elements. More...
 
enum  StyleHint {
  SH_EtchDisabledText, SH_DitherDisabledText, SH_ScrollBar_MiddleClickAbsolutePosition, SH_ScrollBar_ScrollWhenPointerLeavesControl,
  SH_TabBar_SelectMouseType, SH_TabBar_Alignment, SH_Header_ArrowAlignment, SH_Slider_SnapToValue,
  SH_Slider_SloppyKeyEvents, SH_ProgressDialog_CenterCancelButton, SH_ProgressDialog_TextLabelAlignment, SH_PrintDialog_RightAlignButtons,
  SH_MainWindow_SpaceBelowMenuBar, SH_FontDialog_SelectAssociatedText, SH_Menu_AllowActiveAndDisabled, SH_Menu_SpaceActivatesItem,
  SH_Menu_SubMenuPopupDelay, SH_ScrollView_FrameOnlyAroundContents, SH_MenuBar_AltKeyNavigation, SH_ComboBox_ListMouseTracking,
  SH_Menu_MouseTracking, SH_MenuBar_MouseTracking, SH_ItemView_ChangeHighlightOnFocus, SH_Widget_ShareActivation,
  SH_Workspace_FillSpaceOnMaximize, SH_ComboBox_Popup, SH_TitleBar_NoBorder, SH_Slider_StopMouseOverSlider,
  SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, SH_BlinkCursorWhenTextSelected, SH_RichText_FullWidthSelection, SH_Menu_Scrollable,
  SH_GroupBox_TextLabelVerticalAlignment, SH_GroupBox_TextLabelColor, SH_Menu_SloppySubMenus, SH_Table_GridLineColor,
  SH_LineEdit_PasswordCharacter, SH_DialogButtons_DefaultButton, SH_ToolBox_SelectedPageTitleBold, SH_TabBar_PreferNoArrows,
  SH_ScrollBar_LeftClickAbsolutePosition, SH_Q3ListViewExpand_SelectMouseType, SH_UnderlineShortcut, SH_SpinBox_AnimateButton,
  SH_SpinBox_KeyPressAutoRepeatRate, SH_SpinBox_ClickAutoRepeatRate, SH_Menu_FillScreenWithScroll, SH_ToolTipLabel_Opacity,
  SH_DrawMenuBarSeparator, SH_TitleBar_ModifyNotification, SH_Button_FocusPolicy, SH_MenuBar_DismissOnSecondClick,
  SH_MessageBox_UseBorderForButtonSpacing, SH_TitleBar_AutoRaise, SH_ToolButton_PopupDelay, SH_FocusFrame_Mask,
  SH_RubberBand_Mask, SH_WindowFrame_Mask, SH_SpinControls_DisableOnBounds, SH_Dial_BackgroundRole,
  SH_ComboBox_LayoutDirection, SH_ItemView_EllipsisLocation, SH_ItemView_ShowDecorationSelected, SH_ItemView_ActivateItemOnSingleClick,
  SH_ScrollBar_ContextMenu, SH_ScrollBar_RollBetweenButtons, SH_Slider_AbsoluteSetButtons, SH_Slider_PageSetButtons,
  SH_Menu_KeyboardSearch, SH_TabBar_ElideMode, SH_DialogButtonLayout, SH_ComboBox_PopupFrameStyle,
  SH_MessageBox_TextInteractionFlags, SH_DialogButtonBox_ButtonsHaveIcons, SH_SpellCheckUnderlineStyle, SH_MessageBox_CenterButtons,
  SH_Menu_SelectionWrap, SH_ItemView_MovementWithoutUpdatingSelection, SH_ToolTip_Mask, SH_FocusFrame_AboveWidget,
  SH_TextControl_FocusIndicatorTextCharFormat, SH_WizardStyle, SH_ItemView_ArrowKeysNavigateIntoChildren, SH_Menu_Mask,
  SH_Menu_FlashTriggeredItem, SH_Menu_FadeOutOnHide, SH_SpinBox_ClickAutoRepeatThreshold, SH_ItemView_PaintAlternatingRowColorsForEmptyArea,
  SH_FormLayoutWrapPolicy, SH_TabWidget_DefaultTabPosition, SH_ToolBar_Movable, SH_FormLayoutFieldGrowthPolicy,
  SH_FormLayoutFormAlignment, SH_FormLayoutLabelAlignment, SH_ItemView_DrawDelegateFrame, SH_TabBar_CloseButtonPosition,
  SH_DockWidget_ButtonsHaveFrame, SH_ToolButtonStyle, SH_RequestSoftwareInputPanel, SH_CustomBase = 0xf0000000
}
 This enum describes the available style hints. More...
 
enum  SubControl {
  SC_None = 0x00000000, SC_ScrollBarAddLine = 0x00000001, SC_ScrollBarSubLine = 0x00000002, SC_ScrollBarAddPage = 0x00000004,
  SC_ScrollBarSubPage = 0x00000008, SC_ScrollBarFirst = 0x00000010, SC_ScrollBarLast = 0x00000020, SC_ScrollBarSlider = 0x00000040,
  SC_ScrollBarGroove = 0x00000080, SC_SpinBoxUp = 0x00000001, SC_SpinBoxDown = 0x00000002, SC_SpinBoxFrame = 0x00000004,
  SC_SpinBoxEditField = 0x00000008, SC_ComboBoxFrame = 0x00000001, SC_ComboBoxEditField = 0x00000002, SC_ComboBoxArrow = 0x00000004,
  SC_ComboBoxListBoxPopup = 0x00000008, SC_SliderGroove = 0x00000001, SC_SliderHandle = 0x00000002, SC_SliderTickmarks = 0x00000004,
  SC_ToolButton = 0x00000001, SC_ToolButtonMenu = 0x00000002, SC_TitleBarSysMenu = 0x00000001, SC_TitleBarMinButton = 0x00000002,
  SC_TitleBarMaxButton = 0x00000004, SC_TitleBarCloseButton = 0x00000008, SC_TitleBarNormalButton = 0x00000010, SC_TitleBarShadeButton = 0x00000020,
  SC_TitleBarUnshadeButton = 0x00000040, SC_TitleBarContextHelpButton = 0x00000080, SC_TitleBarLabel = 0x00000100, SC_Q3ListView = 0x00000001,
  SC_Q3ListViewBranch = 0x00000002, SC_Q3ListViewExpand = 0x00000004, SC_DialGroove = 0x00000001, SC_DialHandle = 0x00000002,
  SC_DialTickmarks = 0x00000004, SC_GroupBoxCheckBox = 0x00000001, SC_GroupBoxLabel = 0x00000002, SC_GroupBoxContents = 0x00000004,
  SC_GroupBoxFrame = 0x00000008, SC_MdiMinButton = 0x00000001, SC_MdiNormalButton = 0x00000002, SC_MdiCloseButton = 0x00000004,
  SC_CustomBase = 0xf0000000, SC_All = 0xffffffff
}
 This enum describes the available sub controls. More...
 
enum  SubElement {
  SE_PushButtonContents, SE_PushButtonFocusRect, SE_CheckBoxIndicator, SE_CheckBoxContents,
  SE_CheckBoxFocusRect, SE_CheckBoxClickRect, SE_RadioButtonIndicator, SE_RadioButtonContents,
  SE_RadioButtonFocusRect, SE_RadioButtonClickRect, SE_ComboBoxFocusRect, SE_SliderFocusRect,
  SE_Q3DockWindowHandleRect, SE_ProgressBarGroove, SE_ProgressBarContents, SE_ProgressBarLabel,
  SE_DialogButtonAccept, SE_DialogButtonReject, SE_DialogButtonApply, SE_DialogButtonHelp,
  SE_DialogButtonAll, SE_DialogButtonAbort, SE_DialogButtonIgnore, SE_DialogButtonRetry,
  SE_DialogButtonCustom, SE_ToolBoxTabContents, SE_HeaderLabel, SE_HeaderArrow,
  SE_TabWidgetTabBar, SE_TabWidgetTabPane, SE_TabWidgetTabContents, SE_TabWidgetLeftCorner,
  SE_TabWidgetRightCorner, SE_ViewItemCheckIndicator, SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator, SE_TabBarTearIndicator,
  SE_TreeViewDisclosureItem, SE_LineEditContents, SE_FrameContents, SE_DockWidgetCloseButton,
  SE_DockWidgetFloatButton, SE_DockWidgetTitleBarText, SE_DockWidgetIcon, SE_CheckBoxLayoutItem,
  SE_ComboBoxLayoutItem, SE_DateTimeEditLayoutItem, SE_DialogButtonBoxLayoutItem, SE_LabelLayoutItem,
  SE_ProgressBarLayoutItem, SE_PushButtonLayoutItem, SE_RadioButtonLayoutItem, SE_SliderLayoutItem,
  SE_SpinBoxLayoutItem, SE_ToolButtonLayoutItem, SE_FrameLayoutItem, SE_GroupBoxLayoutItem,
  SE_TabWidgetLayoutItem, SE_ItemViewItemDecoration, SE_ItemViewItemText, SE_ItemViewItemFocusRect,
  SE_TabBarTabLeftButton, SE_TabBarTabRightButton, SE_TabBarTabText, SE_ShapedFrameContents,
  SE_ToolBarHandle, SE_CustomBase = 0xf0000000
}
 This enum represents a sub-area of a widget. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QStyle
static QRect alignedRect (Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
 Returns a new rectangle of the specified size that is aligned to the given rectangle according to the specified alignment and direction. More...
 
static int sliderPositionFromValue (int min, int max, int val, int space, bool upsideDown=false)
 Converts the given logicalValue to a pixel position. More...
 
static int sliderValueFromPosition (int min, int max, int pos, int space, bool upsideDown=false)
 Converts the given pixel position to a logical value. More...
 
static Qt::Alignment visualAlignment (Qt::LayoutDirection direction, Qt::Alignment alignment)
 Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with Qt::AlignAbsolute according to the layout direction. More...
 
static QPoint visualPos (Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
 Returns the given logicalPosition converted to screen coordinates based on the specified direction. More...
 
static QRect visualRect (Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
 Returns the given logicalRectangle converted to screen coordinates based on the specified direction. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QWindowsStyle
bool eventFilter (QObject *o, QEvent *e)
 Reimplemented Function More...
 
 QWindowsStyle (QWindowsStylePrivate &dd)
 Constructs a QWindowsStyle object. More...
 
void timerEvent (QTimerEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QCommonStyle
 QCommonStyle (QCommonStylePrivate &dd)
 
- Protected Functions inherited from QStyle
 QStyle (QStylePrivate &dd)
 Constructs a style object. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows Vista.

Since
4.3
Warning
This style is only available on the Windows Vista platform because it makes use of Windows Vista's style engine.
See also
QMacStyle, QWindowsXPStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle

Definition at line 56 of file qwindowsvistastyle.h.

Constructors and Destructors

◆ QWindowsVistaStyle()

QWindowsVistaStyle::QWindowsVistaStyle ( )

Constructs a QWindowsVistaStyle object.

Definition at line 164 of file qwindowsvistastyle.cpp.

166 {
167 }
QWindowsXPStyle()
Constructs a QWindowsStyle.

Functions

◆ drawComplexControl()

void QWindowsVistaStyle::drawComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
QPainter painter,
const QWidget widget 
) const
virtual
Warning
This function is not part of the public interface.

see drawPrimitive for comments on the animation support

Reimplemented from QWindowsStyle.

Definition at line 1548 of file qwindowsvistastyle.cpp.

1550 {
1551  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
1553  QWindowsStyle::drawComplexControl(control, option, painter, widget);
1554  return;
1555  }
1556 
1557  State state = option->state;
1558  SubControls sub = option->subControls;
1559  QRect r = option->rect;
1560 
1561  int partId = 0;
1562  int stateId = 0;
1563 
1564  State flags = option->state;
1565  if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
1566  flags |= State_MouseOver;
1567 
1568  if (d->transitionsEnabled() && widget) {
1569  if ((qobject_cast<const QScrollBar *>(widget) && control == CC_ScrollBar)
1570 #ifndef QT_NO_SPINBOX
1571  || (qobject_cast<const QAbstractSpinBox*>(widget) && control == CC_SpinBox)
1572 #endif // QT_NO_SPINBOX
1573 #ifndef QT_NO_COMBOBOX
1574  || (qobject_cast<const QComboBox*>(widget) && control == CC_ComboBox)
1575 #endif // QT_NO_COMBOBOX
1576  )
1577  {
1578  QWidget *w = const_cast<QWidget *> (widget);
1579 
1580  int oldState = w->property("_q_stylestate").toInt();
1581  int oldActiveControls = w->property("_q_stylecontrols").toInt();
1582  QRect oldRect = w->property("_q_stylerect").toRect();
1583  w->setProperty("_q_stylestate", (int)option->state);
1584  w->setProperty("_q_stylecontrols", (int)option->activeSubControls);
1585  w->setProperty("_q_stylerect", w->rect());
1586 
1587  bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
1588  (state & State_On) != (oldState & State_On) ||
1589  (state & State_MouseOver) != (oldState & State_MouseOver) ||
1590  oldActiveControls != option->activeSubControls);
1591 
1592 
1593  if (qstyleoption_cast<const QStyleOptionSlider *>(option)) {
1594  QRect oldSliderPos = w->property("_q_stylesliderpos").toRect();
1595  QRect currentPos = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1596  w->setProperty("_q_stylesliderpos", currentPos);
1597  if (oldSliderPos != currentPos) {
1598  doTransition = false;
1599  d->stopAnimation(widget);
1600  }
1601  } else if (control == CC_SpinBox) {
1602  //spinboxes have a transition when focus changes
1603  if (!doTransition)
1604  doTransition = (state & State_HasFocus) != (oldState & State_HasFocus);
1605  }
1606 
1607  if (oldRect != option->rect) {
1608  doTransition = false;
1609  d->stopAnimation(widget);
1610  }
1611 
1612  if (doTransition) {
1613  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1614  QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1615  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
1617  t->setWidget(w);
1618  if (!anim) {
1619  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option)) {
1620  //Combo boxes are special cased to avoid cleartype issues
1621  startImage.fill(0);
1622  QPainter startPainter(&startImage);
1623  QStyleOptionComboBox startCombo = *combo;
1624  startCombo.state = (QStyle::State)oldState;
1625  startCombo.activeSubControls = (QStyle::SubControl)oldActiveControls;
1626  proxy()->drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */);
1627  t->setStartImage(startImage);
1628  } else if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) {
1629  //This is a workaround for the direct3d engine as it currently has some issues with grabWindow
1630  startImage.fill(0);
1631  QPainter startPainter(&startImage);
1632  QStyleOptionSlider startSlider = *slider;
1633  startSlider.state = (QStyle::State)oldState;
1634  startSlider.activeSubControls = (QStyle::SubControl)oldActiveControls;
1635  proxy()->drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */);
1636  t->setStartImage(startImage);
1637  } else {
1638  QPoint offset(0, 0);
1639  if (!widget->internalWinId())
1640  offset = widget->mapTo(widget->nativeParentWidget(), offset);
1641  t->setStartImage(QPixmap::grabWindow(widget->effectiveWinId(), offset.x(), offset.y(),
1642  option->rect.width(), option->rect.height()).toImage());
1643  }
1644  } else {
1645  startImage.fill(0);
1646  QPainter startPainter(&startImage);
1647  anim->paint(&startPainter, option);
1648  t->setStartImage(startImage);
1649  }
1650  d->startAnimation(t);
1651  endImage.fill(0);
1652  QPainter endPainter(&endImage);
1653  proxy()->drawComplexControl(control, option, &endPainter, 0 /* Intentional */);
1654  t->setEndImage(endImage);
1656 
1657  if (option->state & State_MouseOver || option->state & State_Sunken)
1658  t->setDuration(150);
1659  else
1660  t->setDuration(500);
1661  }
1662 
1663  if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
1664  anim->paint(painter, option);
1665  return;
1666  }
1667 
1668  }
1669  }
1670 
1671  switch (control) {
1672  case CC_ComboBox:
1673  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
1674  {
1675  if (cmb->editable) {
1676  if (sub & SC_ComboBoxEditField) {
1677  partId = EP_EDITBORDER_NOSCROLL;
1678  if (!(flags & State_Enabled))
1679  stateId = ETS_DISABLED;
1680  else if (flags & State_MouseOver)
1681  stateId = ETS_HOT;
1682  else if (flags & State_HasFocus)
1683  stateId = ETS_FOCUSED;
1684  else
1685  stateId = ETS_NORMAL;
1686 
1687  XPThemeData theme(widget, painter, QLatin1String("EDIT"), partId, stateId, r);
1688 
1689  d->drawBackground(theme);
1690  }
1691  if (sub & SC_ComboBoxArrow) {
1692  QRect subRect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
1693  XPThemeData theme(widget, painter, QLatin1String("COMBOBOX"));
1694  theme.rect = subRect;
1696 
1697  if (!(cmb->state & State_Enabled))
1698  stateId = CBXS_DISABLED;
1699  else if (cmb->state & State_Sunken || cmb->state & State_On)
1700  stateId = CBXS_PRESSED;
1701  else if (cmb->state & State_MouseOver && option->activeSubControls & SC_ComboBoxArrow)
1702  stateId = CBXS_HOT;
1703  else
1704  stateId = CBXS_NORMAL;
1705 
1706  theme.partId = partId;
1707  theme.stateId = stateId;
1708  d->drawBackground(theme);
1709  }
1710 
1711  } else {
1712  if (sub & SC_ComboBoxFrame) {
1713  QStyleOptionButton btn;
1714  btn.QStyleOption::operator=(*option);
1715  btn.rect = option->rect.adjusted(-1, -1, 1, 1);
1716  if (sub & SC_ComboBoxArrow)
1718  proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget);
1719  }
1720  }
1721  }
1722  break;
1723  case CC_ScrollBar:
1724  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option))
1725  {
1726  XPThemeData theme(widget, painter, QLatin1String("SCROLLBAR"));
1727 
1728  bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
1729  if (maxedOut)
1730  flags &= ~State_Enabled;
1731 
1732  bool isHorz = flags & State_Horizontal;
1733  bool isRTL = option->direction == Qt::RightToLeft;
1734  if (sub & SC_ScrollBarAddLine) {
1735  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
1736  partId = SBP_ARROWBTN;
1737  if (!(flags & State_Enabled))
1738  stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
1739  else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
1740  stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
1741  else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
1742  stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
1743  else if (scrollbar->state & State_MouseOver)
1744  stateId = (isHorz ? (isRTL ? ABS_LEFTHOVER : ABS_RIGHTHOVER) : ABS_DOWNHOVER);
1745  else
1746  stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
1747  theme.partId = partId;
1748  theme.stateId = stateId;
1749  d->drawBackground(theme);
1750  }
1751  if (sub & SC_ScrollBarSubLine) {
1752  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
1753  partId = SBP_ARROWBTN;
1754  if (!(flags & State_Enabled))
1755  stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
1756  else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
1757  stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
1758  else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
1759  stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
1760  else if (scrollbar->state & State_MouseOver)
1761  stateId = (isHorz ? (isRTL ? ABS_RIGHTHOVER : ABS_LEFTHOVER) : ABS_UPHOVER);
1762  else
1763  stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
1764  theme.partId = partId;
1765  theme.stateId = stateId;
1766  d->drawBackground(theme);
1767  }
1768  if (maxedOut) {
1769  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1770  theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
1771  theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
1772  partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1773  stateId = SCRBS_DISABLED;
1774  theme.partId = partId;
1775  theme.stateId = stateId;
1776  d->drawBackground(theme);
1777  } else {
1778  if (sub & SC_ScrollBarSubPage) {
1779  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
1780  partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
1781  if (!(flags & State_Enabled))
1782  stateId = SCRBS_DISABLED;
1783  else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
1784  stateId = SCRBS_PRESSED;
1785  else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
1786  stateId = SCRBS_HOT;
1787  else
1788  stateId = SCRBS_NORMAL;
1789  theme.partId = partId;
1790  theme.stateId = stateId;
1791  d->drawBackground(theme);
1792  }
1793  if (sub & SC_ScrollBarAddPage) {
1794  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
1795  partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1796  if (!(flags & State_Enabled))
1797  stateId = SCRBS_DISABLED;
1798  else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
1799  stateId = SCRBS_PRESSED;
1800  else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
1801  stateId = SCRBS_HOT;
1802  else
1803  stateId = SCRBS_NORMAL;
1804  theme.partId = partId;
1805  theme.stateId = stateId;
1806  d->drawBackground(theme);
1807  }
1808  if (sub & SC_ScrollBarSlider) {
1809  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1810  if (!(flags & State_Enabled))
1811  stateId = SCRBS_DISABLED;
1812  else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
1813  stateId = SCRBS_PRESSED;
1814  else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
1815  stateId = SCRBS_HOT;
1816  else if (option->state & State_MouseOver)
1817  stateId = SCRBS_HOVER;
1818  else
1819  stateId = SCRBS_NORMAL;
1820 
1821  // Draw handle
1822  theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
1823  theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
1824  theme.stateId = stateId;
1825  d->drawBackground(theme);
1826 
1827  // Calculate rect of gripper
1828  const int swidth = theme.rect.width();
1829  const int sheight = theme.rect.height();
1830 
1831  MARGINS contentsMargin;
1832  RECT rect = theme.toRECT(theme.rect);
1833  pGetThemeMargins(theme.handle(), 0, theme.partId, theme.stateId, TMT_SIZINGMARGINS, &rect, &contentsMargin);
1834 
1835  SIZE size;
1836  theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
1837  pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
1838  int gw = size.cx, gh = size.cy;
1839 
1841  QRect gripperBounds;
1842  if (flags & State_Horizontal && ((swidth - contentsMargin.cxLeftWidth - contentsMargin.cxRightWidth) > gw)) {
1843  gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
1844  gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
1845  gripperBounds.setWidth(gw);
1846  gripperBounds.setHeight(gh);
1847  } else if ((sheight - contentsMargin.cyTopHeight - contentsMargin.cyBottomHeight) > gh) {
1848  gripperBounds.setLeft(theme.rect.left() + swidth/2 - gw/2);
1849  gripperBounds.setTop(theme.rect.top() + sheight/2 - gh/2);
1850  gripperBounds.setWidth(gw);
1851  gripperBounds.setHeight(gh);
1852  }
1853 
1854  // Draw gripper if there is enough space
1855  if (!gripperBounds.isEmpty() && flags & State_Enabled) {
1856  painter->save();
1857  XPThemeData grippBackground = theme;
1858  grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
1859  theme.rect = gripperBounds;
1860  painter->setClipRegion(d->region(theme));// Only change inside the region of the gripper
1861  d->drawBackground(grippBackground);// The gutter is the grippers background
1862  d->drawBackground(theme); // Transparent gripper ontop of background
1863  painter->restore();
1864  }
1865  }
1866  }
1867  }
1868  }
1869  break;
1870 #ifndef QT_NO_SPINBOX
1871  case CC_SpinBox:
1872  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
1873  {
1874  XPThemeData theme(widget, painter, QLatin1String("SPIN"));
1875  if (sb->frame && (sub & SC_SpinBoxFrame)) {
1876  partId = EP_EDITBORDER_NOSCROLL;
1877  if (!(flags & State_Enabled))
1878  stateId = ETS_DISABLED;
1879  else if (flags & State_MouseOver)
1880  stateId = ETS_HOT;
1881  else if (flags & State_HasFocus)
1882  stateId = ETS_SELECTED;
1883  else
1884  stateId = ETS_NORMAL;
1885 
1886  XPThemeData ftheme(widget, painter, QLatin1String("EDIT"), partId, stateId, r);
1887  ftheme.noContent = true;
1888  d->drawBackground(ftheme);
1889  }
1890  if (sub & SC_SpinBoxUp) {
1891  theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
1892  partId = SPNP_UP;
1893  if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
1894  stateId = UPS_DISABLED;
1895  else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
1896  stateId = UPS_PRESSED;
1897  else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
1898  stateId = UPS_HOT;
1899  else
1900  stateId = UPS_NORMAL;
1901  theme.partId = partId;
1902  theme.stateId = stateId;
1903  d->drawBackground(theme);
1904  }
1905  if (sub & SC_SpinBoxDown) {
1906  theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
1907  partId = SPNP_DOWN;
1908  if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
1909  stateId = DNS_DISABLED;
1910  else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
1911  stateId = DNS_PRESSED;
1912  else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
1913  stateId = DNS_HOT;
1914  else
1915  stateId = DNS_NORMAL;
1916  theme.partId = partId;
1917  theme.stateId = stateId;
1918  d->drawBackground(theme);
1919  }
1920  }
1921  break;
1922 #endif // QT_NO_SPINBOX
1923  default:
1924  QWindowsXPStyle::drawComplexControl(control, option, painter, widget);
1925  break;
1926  }
1927 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
void setWidget(QWidget *widget)
QPointer< QWidget > widget
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
#define CP_DROPDOWNBUTTONLEFT
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void drawBackground(XPThemeData &themeData)
Main theme drawing function.
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void stopAnimation(const QWidget *)
#define SIZE(large, small, mini)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
#define SCRBS_HOVER
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
#define ABS_UPHOVER
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void setEndImage(const QImage &image)
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
ButtonFeatures features
a bitwise OR of the features that describe this button
Definition: qstyleoption.h:289
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
The State element defines configurations of objects and properties.
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
#define CP_DROPDOWNBUTTONRIGHT
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *p, const QWidget *widget=0) const
Reimplemented Function
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
QRegion region(XPThemeData &themeData)
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
State
Definition: qaudio.h:59
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
void startAnimation(QWindowsVistaAnimation *)
static const QStyle::SubControl SubControls[]
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
static PtrGetThemeMargins pGetThemeMargins
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by Q...
static PtrGetThemePartSize pGetThemePartSize
#define TMT_SIZINGMARGINS
#define EP_EDITBORDER_NOSCROLL
void setStartImage(const QImage &image)
#define ABS_RIGHTHOVER
void setDuration(int duration)
#define ABS_DOWNHOVER
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
#define ABS_LEFTHOVER
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
void setStartTime(const QTime &startTime)
QWindowsVistaAnimation * widgetAnimation(const QWidget *) const

◆ drawControl()

void QWindowsVistaStyle::drawControl ( ControlElement  element,
const QStyleOption option,
QPainter painter,
const QWidget widget 
) const
virtual
Warning
This function is not part of the public interface.

see drawPrimitive for comments on the animation support

Reimplemented from QWindowsStyle.

Definition at line 881 of file qwindowsvistastyle.cpp.

883 {
884  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
885 
887  QWindowsStyle::drawControl(element, option, painter, widget);
888  return;
889  }
890 
891  bool selected = option->state & State_Selected;
892  bool pressed = option->state & State_Sunken;
893  bool disabled = !(option->state & State_Enabled);
894 
895  int state = option->state;
896  QString name;
897 
898  QRect rect(option->rect);
899  State flags = option->state;
900  int partId = 0;
901  int stateId = 0;
902 
903  QRect oldRect;
904  QRect newRect;
905 
906  if (d->transitionsEnabled() && widget) {
907  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
908  if ((qobject_cast<const QPushButton*>(widget) && element == CE_PushButtonBevel))
909  {
910  QWidget *w = const_cast<QWidget *> (widget);
911  int oldState = w->property("_q_stylestate").toInt();
912  oldRect = w->property("_q_stylerect").toRect();
913  newRect = w->rect();
914  w->setProperty("_q_stylestate", (int)option->state);
915  w->setProperty("_q_stylerect", w->rect());
916 
917  bool wasDefault = w->property("_q_isdefault").toBool();
918  bool isDefault = button->features & QStyleOptionButton::DefaultButton;
919  w->setProperty("_q_isdefault", isDefault);
920 
921  bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
922  (state & State_On) != (oldState & State_On) ||
923  (state & State_MouseOver) != (oldState & State_MouseOver));
924 
925  if (oldRect != newRect || (wasDefault && !isDefault))
926  {
927  doTransition = false;
928  d->stopAnimation(widget);
929  }
930 
931  if (doTransition) {
932  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
934  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
935 
936  QStyleOptionButton opt = *button;
937  opt.state = (QStyle::State)oldState;
938 
939  startImage.fill(0);
941  t->setWidget(w);
942  QPainter startPainter(&startImage);
943 
944  if (!anim) {
945  proxy()->drawControl(element, &opt, &startPainter, 0 /* Intentional */);
946  } else {
947  anim->paint(&startPainter, &opt);
948  d->stopAnimation(widget);
949  }
950 
951  t->setStartImage(startImage);
952  d->startAnimation(t);
953 
954  endImage.fill(0);
955  QPainter endPainter(&endImage);
956  proxy()->drawControl(element, option, &endPainter, 0 /* Intentional */);
957  t->setEndImage(endImage);
958  int duration = 0;
959  HTHEME theme = pOpenThemeData(0, L"Button");
960 
961  int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
962  int toState = buttonStateId(option->state, BP_PUSHBUTTON);
963  if (pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
964  t->setDuration(duration);
965  else
966  t->setDuration(0);
968  }
969  }
970  }
971  }
972  switch (element) {
973  case CE_PushButtonBevel:
974  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
975  {
976 
977  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
978  if (anim && (btn->state & State_Enabled)) {
979  anim->paint(painter, option);
980  } else {
981  name = QLatin1String("BUTTON");
982  partId = BP_PUSHBUTTON;
983  if (btn->features & QStyleOptionButton::CommandLinkButton)
984  partId = BP_COMMANDLINK;
985  bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken));
986  if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))
987  stateId = PBS_DISABLED;
988  else if (justFlat)
989  ;
990  else if (flags & (State_Sunken | State_On))
991  stateId = PBS_PRESSED;
992  else if (flags & State_MouseOver)
993  stateId = PBS_HOT;
994  else if (btn->features & QStyleOptionButton::DefaultButton && (state & State_Active))
995  stateId = PBS_DEFAULTED;
996  else
997  stateId = PBS_NORMAL;
998 
999  if (!justFlat) {
1000 
1001  if (widget && d->transitionsEnabled() && (btn->features & QStyleOptionButton::DefaultButton) &&
1002  !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) &&
1003  (state & State_Enabled) && (state & State_Active))
1004  {
1005  if (!anim && widget) {
1006  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1007  startImage.fill(0);
1008  QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
1009  alternateImage.fill(0);
1010 
1012  pulse->setWidget(const_cast<QWidget*>(widget));
1013 
1014  QPainter startPainter(&startImage);
1015  stateId = PBS_DEFAULTED;
1016  XPThemeData theme(widget, &startPainter, name, partId, stateId, rect);
1017  d->drawBackground(theme);
1018 
1019  QPainter alternatePainter(&alternateImage);
1020  theme.stateId = PBS_DEFAULTED_ANIMATING;
1021  theme.painter = &alternatePainter;
1022  d->drawBackground(theme);
1023  pulse->setPrimaryImage(startImage);
1024  pulse->setAlternateImage(alternateImage);
1025  pulse->setStartTime(QTime::currentTime());
1026  pulse->setDuration(2000);
1027  d->startAnimation(pulse);
1028  anim = pulse;
1029  }
1030 
1031  if (anim)
1032  anim->paint(painter, option);
1033  else {
1034  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1035  d->drawBackground(theme);
1036  }
1037  }
1038  else {
1039  d->stopAnimation(widget);
1040  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1041  d->drawBackground(theme);
1042  }
1043  }
1044  }
1045  if (btn->features & QStyleOptionButton::HasMenu) {
1046  int mbiw = 0, mbih = 0;
1047  XPThemeData theme(widget, 0, QLatin1String("TOOLBAR"), TP_DROPDOWNBUTTON);
1048  if (theme.isValid()) {
1049  SIZE size;
1050  if (pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size) == S_OK) {
1051  mbiw = size.cx;
1052  mbih = size.cy;
1053  }
1054  }
1055  QRect ir = subElementRect(SE_PushButtonContents, option, 0);
1056  QStyleOptionButton newBtn = *btn;
1057  newBtn.rect = QStyle::visualRect(option->direction, option->rect,
1058  QRect(ir.right() - mbiw - 2,
1059  option->rect.top() + (option->rect.height()/2) - (mbih/2),
1060  mbiw + 1, mbih + 1));
1061  proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
1062  }
1063  return;
1064  }
1065  break;
1066 #ifndef QT_NO_PROGRESSBAR
1067  case CE_ProgressBarGroove:
1068  {
1070  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
1071  orient = pb2->orientation;
1072  partId = (orient == Qt::Horizontal) ? PP_TRANSPARENTBAR : PP_TRANSPARENTBARVERT;
1073  name = QLatin1String("PROGRESS");
1074  stateId = 1;
1075 
1076  XPThemeData theme(widget, painter, name, partId, stateId, rect);
1077  d->drawBackground(theme);
1078  }
1079  break;
1081  if (const QStyleOptionProgressBar *bar
1082  = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
1083  bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
1084  bool vertical = false;
1085  bool inverted = false;
1086  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
1087  vertical = (pb2->orientation == Qt::Vertical);
1088  inverted = pb2->invertedAppearance;
1089  }
1090 
1091  if (const QProgressBar *progressbar = qobject_cast<const QProgressBar *>(widget)) {
1092  if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled())) {
1093  if (!d->widgetAnimation(progressbar)) {
1095  a->setWidget(const_cast<QWidget*>(widget));
1097  d->startAnimation(a);
1098  }
1099  } else {
1100  d->stopAnimation(progressbar);
1101  }
1102  }
1103 
1104  XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL);
1105  theme.rect = option->rect;
1106  bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
1107  QTime current = QTime::currentTime();
1108 
1109  if (isIndeterminate) {
1110  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
1111  int glowSize = 120;
1112  int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
1113  int animOffset = a->startTime().msecsTo(current) / 4;
1114  if (animOffset > animationWidth)
1116  painter->save();
1117  painter->setClipRect(theme.rect);
1118  QRect animRect;
1119  QSize pixmapSize(14, 14);
1120  if (vertical) {
1121  animRect = QRect(theme.rect.left(),
1122  inverted ? rect.top() - glowSize + animOffset :
1123  rect.bottom() + glowSize - animOffset,
1124  rect.width(), glowSize);
1125  pixmapSize.setHeight(animRect.height());
1126  } else {
1127  animRect = QRect(rect.left() - glowSize + animOffset,
1128  rect.top(), glowSize, rect.height());
1129  animRect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight,
1130  option->rect, animRect);
1131  pixmapSize.setWidth(animRect.width());
1132  }
1133  QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height());
1134  QPixmap pixmap;
1135  if (!QPixmapCache::find(name, pixmap)) {
1136  QImage image(pixmapSize, QImage::Format_ARGB32);
1137  image.fill(Qt::transparent);
1138  QPainter imagePainter(&image);
1139  theme.painter = &imagePainter;
1140  theme.partId = vertical ? PP_FILLVERT : PP_FILL;
1141  theme.rect = QRect(QPoint(0,0), theme.rect.size());
1142  QLinearGradient alphaGradient(0, 0, vertical ? 0 : image.width(),
1143  vertical ? image.height() : 0);
1144  alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
1145  alphaGradient.setColorAt(0.5, QColor(0, 0, 0, 220));
1146  alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
1147  imagePainter.fillRect(image.rect(), alphaGradient);
1148  imagePainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
1149  d->drawBackground(theme);
1150  imagePainter.end();
1151  pixmap = QPixmap::fromImage(image);
1152  QPixmapCache::insert(name, pixmap);
1153  }
1154  painter->drawPixmap(animRect, pixmap);
1155  painter->restore();
1156  }
1157  }
1158  else {
1159  qint64 progress = qMax<qint64>(bar->progress, bar->minimum); // workaround for bug in QProgressBar
1160 
1161  if (vertical) {
1162  int maxHeight = option->rect.height();
1163  int minHeight = 0;
1164  double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxHeight);
1165  int height = isIndeterminate ? maxHeight: qMax(int(vc6_workaround), minHeight);
1166  theme.rect.setHeight(height);
1167  if (!inverted)
1168  theme.rect.moveTop(rect.height() - theme.rect.height());
1169  } else {
1170  int maxWidth = option->rect.width();
1171  int minWidth = 0;
1172  double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth);
1173  int width = isIndeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth);
1174  theme.rect.setWidth(width);
1175  theme.rect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight,
1176  option->rect, theme.rect);
1177  }
1178  d->drawBackground(theme);
1179 
1180  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
1181  int glowSize = 140;
1182  int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
1183  int animOffset = a->startTime().msecsTo(current) / 4;
1184  theme.partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
1185  if (animOffset > animationWidth) {
1186  if (bar->progress < bar->maximum)
1188  else
1189  d->stopAnimation(widget); //we stop the glow motion only after it has
1190  //moved out of view
1191  }
1192  painter->save();
1193  painter->setClipRect(theme.rect);
1194  if (vertical) {
1195  theme.rect = QRect(theme.rect.left(),
1196  inverted ? rect.top() - glowSize + animOffset :
1197  rect.bottom() + glowSize - animOffset,
1198  rect.width(), glowSize);
1199  } else {
1200  theme.rect = QRect(rect.left() - glowSize + animOffset,rect.top(), glowSize, rect.height());
1201  theme.rect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight, option->rect, theme.rect);
1202  }
1203  d->drawBackground(theme);
1204  painter->restore();
1205  }
1206  }
1207  }
1208  break;
1209 #endif // QT_NO_PROGRESSBAR
1210  case CE_MenuBarItem:
1211  {
1212 
1213  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
1214  {
1215  if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem)
1216  break;
1217 
1219  QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
1220 
1222  if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
1223  alignment |= Qt::TextHideMnemonic;
1224 
1225  //The rect adjustment is a workaround for the menu not really filling its background.
1226  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1));
1227  d->drawBackground(theme);
1228 
1229  int stateId = MBI_NORMAL;
1230  if (disabled)
1231  stateId = MBI_DISABLED;
1232  else if (pressed)
1233  stateId = MBI_PUSHED;
1234  else if (selected)
1235  stateId = MBI_HOT;
1236 
1237  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_BARITEM, stateId, option->rect);
1238  d->drawBackground(theme2);
1239 
1240  if (!pix.isNull())
1241  drawItemPixmap(painter, mbi->rect, alignment, pix);
1242  else
1243  drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
1244  }
1245  }
1246  break;
1247 #ifndef QT_NO_MENU
1248  case CE_MenuItem:
1249  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1250  // windows always has a check column, regardless whether we have an icon or not
1251  int checkcol = 25;
1252  {
1253  SIZE size;
1254  MARGINS margins;
1255  XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
1256  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1257  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
1258  checkcol = qMax(menuitem->maxIconWidth, int(3 + size.cx + margins.cxLeftWidth + margins.cxRightWidth));
1259  }
1260  QRect rect = option->rect;
1261 
1262  //draw vertical menu line
1263  if (option->direction == Qt::LeftToRight)
1264  checkcol += rect.x();
1265  QPoint p1 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.top()));
1266  QPoint p2 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.bottom()));
1267  QRect gutterRect(p1.x(), p1.y(), 3, p2.y() - p1.y() + 1);
1268  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPGUTTER, stateId, gutterRect);
1269  d->drawBackground(theme2);
1270 
1271  int x, y, w, h;
1272  menuitem->rect.getRect(&x, &y, &w, &h);
1273  int tab = menuitem->tabWidth;
1274  bool dis = !(menuitem->state & State_Enabled);
1275  bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1276  ? menuitem->checked : false;
1277  bool act = menuitem->state & State_Selected;
1278 
1279  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
1280  int yoff = y-2 + h / 2;
1281  QPoint p1 = QPoint(x + checkcol, yoff);
1282  QPoint p2 = QPoint(x + w + 6 , yoff);
1283  stateId = MBI_HOT;
1284  QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6);
1285  subRect = QStyle::visualRect(option->direction, option->rect, subRect );
1286  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPSEPARATOR, stateId, subRect);
1287  d->drawBackground(theme2);
1288  return;
1289  }
1290 
1291  QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(),
1292  menuitem->rect.y(), checkcol - 6, menuitem->rect.height()));
1293 
1294  if (act) {
1295  stateId = dis ? MBI_DISABLED : MBI_HOT;
1296  XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect);
1297  d->drawBackground(theme2);
1298  }
1299 
1300  if (checked) {
1301  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND,
1302  menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
1303  SIZE size;
1304  MARGINS margins;
1305  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1306  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0,
1307  TMT_CONTENTMARGINS, NULL, &margins);
1308  QRect checkRect(0, 0, size.cx + margins.cxLeftWidth + margins.cxRightWidth ,
1309  size.cy + margins.cyBottomHeight + margins.cyTopHeight);
1310  checkRect.moveCenter(vCheckRect.center());
1311  theme.rect = checkRect;
1312 
1313  d->drawBackground(theme);
1314 
1315  if (menuitem->icon.isNull()) {
1316  checkRect = QRect(0, 0, size.cx, size.cy);
1317  checkRect.moveCenter(theme.rect.center());
1318  theme.rect = checkRect;
1319 
1320  theme.partId = MENU_POPUPCHECK;
1321  bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive;
1322  if (dis)
1323  theme.stateId = bullet ? MC_BULLETDISABLED: MC_CHECKMARKDISABLED;
1324  else
1325  theme.stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL;
1326  d->drawBackground(theme);
1327  }
1328  }
1329 
1330  if (!menuitem->icon.isNull()) {
1331  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1332  if (act && !dis)
1333  mode = QIcon::Active;
1334  QPixmap pixmap;
1335  if (checked)
1336  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
1337  else
1338  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
1339  int pixw = pixmap.width();
1340  int pixh = pixmap.height();
1341  QRect pmr(0, 0, pixw, pixh);
1342  pmr.moveCenter(vCheckRect.center());
1343  painter->setPen(menuitem->palette.text().color());
1344  painter->drawPixmap(pmr.topLeft(), pixmap);
1345  }
1346 
1347  painter->setPen(menuitem->palette.buttonText().color());
1348 
1349  const QColor textColor = menuitem->palette.text().color();
1350  if (dis)
1351  painter->setPen(textColor);
1352 
1353  int xm = windowsItemFrame + checkcol + windowsItemHMargin;
1354  int xpos = menuitem->rect.x() + xm;
1355  QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
1356  QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect);
1357  QString s = menuitem->text;
1358  if (!s.isEmpty()) { // draw text
1359  painter->save();
1360  int t = s.indexOf(QLatin1Char('\t'));
1362  if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1363  text_flags |= Qt::TextHideMnemonic;
1364  text_flags |= Qt::AlignLeft;
1365  if (t >= 0) {
1366  QRect vShortcutRect = visualRect(option->direction, menuitem->rect,
1367  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1368  painter->drawText(vShortcutRect, text_flags, s.mid(t + 1));
1369  s = s.left(t);
1370  }
1371  QFont font = menuitem->font;
1372  if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1373  font.setBold(true);
1374  painter->setFont(font);
1375  painter->setPen(textColor);
1376  painter->drawText(vTextRect, text_flags, s.left(t));
1377  painter->restore();
1378  }
1379  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1380  int dim = (h - 2 * windowsItemFrame) / 2;
1381  PrimitiveElement arrow;
1383  xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
1384  QRect vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1385  QStyleOptionMenuItem newMI = *menuitem;
1386  newMI.rect = vSubMenuRect;
1387  newMI.state = dis ? State_None : State_Enabled;
1388  proxy()->drawPrimitive(arrow, &newMI, painter, widget);
1389  }
1390  }
1391  break;
1392 #endif // QT_NO_MENU
1393  case CE_HeaderSection:
1394  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
1395  name = QLatin1String("HEADER");
1396  partId = HP_HEADERITEM;
1397  if (flags & State_Sunken)
1398  stateId = HIS_PRESSED;
1399  else if (flags & State_MouseOver)
1400  stateId = HIS_HOT;
1401  else
1402  stateId = HIS_NORMAL;
1403 
1404  if (header->sortIndicator != QStyleOptionHeader::None)
1405  stateId += 3;
1406 
1407  XPThemeData theme(widget, painter, name, partId, stateId, option->rect);
1408  d->drawBackground(theme);
1409  }
1410  break;
1411  case CE_MenuBarEmptyArea:
1412  {
1413  stateId = MBI_NORMAL;
1414  if (!(state & State_Enabled))
1415  stateId = MBI_DISABLED;
1416  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, stateId, option->rect);
1417  d->drawBackground(theme);
1418  }
1419  break;
1420  case CE_ToolBar:
1421  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
1422  QPalette pal = option->palette;
1423  pal.setColor(QPalette::Dark, option->palette.background().color().darker(130));
1424  QStyleOptionToolBar copyOpt = *toolbar;
1425  copyOpt.palette = pal;
1426  QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
1427  }
1428  break;
1429  case CE_DockWidgetTitle:
1430  if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget)) {
1431  QRect rect = option->rect;
1432  if (dockWidget->isFloating()) {
1433  QWindowsXPStyle::drawControl(element, option, painter, widget);
1434  break; //otherwise fall through
1435  }
1436 
1437  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
1438 
1439  const QStyleOptionDockWidgetV2 *v2
1441  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
1442 
1443  if (verticalTitleBar) {
1444  QSize s = rect.size();
1445  s.transpose();
1446  rect.setSize(s);
1447 
1448  painter->translate(rect.left() - 1, rect.top() + rect.width());
1449  painter->rotate(-90);
1450  painter->translate(-rect.left() + 1, -rect.top());
1451  }
1452 
1453  painter->setBrush(option->palette.background().color().darker(110));
1454  painter->setPen(option->palette.background().color().darker(130));
1455  painter->drawRect(rect.adjusted(0, 1, -1, -3));
1456 
1457  int buttonMargin = 4;
1458  int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
1459  int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
1460  const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
1461  bool isFloating = dw != 0 && dw->isFloating();
1462 
1463  QRect r = option->rect.adjusted(0, 2, -1, -3);
1464  QRect titleRect = r;
1465 
1466  if (dwOpt->closable) {
1467  QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
1468  titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
1469  }
1470 
1471  if (dwOpt->floatable) {
1472  QSize sz = standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
1473  titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
1474  }
1475 
1476  if (isFloating) {
1477  titleRect.adjust(0, -fw, 0, 0);
1478  if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
1479  titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
1480  } else {
1481  titleRect.adjust(mw, 0, 0, 0);
1482  if (!dwOpt->floatable && !dwOpt->closable)
1483  titleRect.adjust(0, 0, -mw, 0);
1484  }
1485  if (!verticalTitleBar)
1486  titleRect = visualRect(dwOpt->direction, r, titleRect);
1487 
1488  if (!dwOpt->title.isEmpty()) {
1489  QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
1490  verticalTitleBar ? titleRect.height() : titleRect.width());
1491  const int indent = painter->fontMetrics().descent();
1492  drawItemText(painter, rect.adjusted(indent + 1, 1, -indent - 1, -1),
1493  Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
1494  dwOpt->state & State_Enabled, titleText,
1496  }
1497  }
1498  break;
1499  }
1500 #ifndef QT_NO_ITEMVIEWS
1501  case CE_ItemViewItem:
1502  {
1503  const QStyleOptionViewItemV4 *vopt;
1504  const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
1505  bool newStyle = true;
1506 
1507  if (qobject_cast<const QTableView*>(widget))
1508  newStyle = false;
1509 
1510  if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
1511  /*
1512  // We cannot currently get the correct selection color for "explorer style" views
1513  COLORREF cref = 0;
1514  XPThemeData theme(d->treeViewHelper(), 0, QLatin1String("LISTVIEW"), 0, 0);
1515  unsigned int res = pGetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
1516  QColor textColor(GetRValue(cref), GetGValue(cref), GetBValue(cref));
1517  */
1518  QPalette palette = vopt->palette;
1520  // Note that setting a saturated color here results in ugly XOR colors in the focus rect
1521  palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
1522  QStyleOptionViewItemV4 adjustedOption = *vopt;
1523  adjustedOption.palette = palette;
1524  // We hide the focusrect in singleselection as it is not required
1526  && !(vopt->state & State_KeyboardFocusChange))
1527  adjustedOption.state &= ~State_HasFocus;
1528  QWindowsXPStyle::drawControl(element, &adjustedOption, painter, widget);
1529  } else {
1530  QWindowsXPStyle::drawControl(element, option, painter, widget);
1531  }
1532  break;
1533  }
1534 #endif // QT_NO_ITEMVIEWS
1535 
1536  default:
1537  QWindowsXPStyle::drawControl(element, option, painter, widget);
1538  break;
1539  }
1540 }
void setDuration(int duration)
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
virtual void paint(QPainter *painter, const QStyleOption *option)
#define MBI_PUSHED
#define MC_CHECKMARKDISABLED
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
#define disabled
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
void setWidget(QWidget *widget)
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPointer< QWidget > widget
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static PtrGetThemeTransitionDuration pGetThemeTransitionDuration
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2109
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
int descent() const
Returns the descent of the font.
static const int windowsItemVMargin
#define PP_TRANSPARENTBAR
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int msecsTo(const QTime &) const
Returns the number of milliseconds from this time to t.
Definition: qdatetime.cpp:1832
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
const QTime & startTime() const
static PtrOpenThemeData pOpenThemeData
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
long ASN1_INTEGER_get ASN1_INTEGER * a
void drawBackground(XPThemeData &themeData)
Main theme drawing function.
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define MENU_POPUPSEPARATOR
#define PP_MOVEOVERLAY
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
void stopAnimation(const QWidget *)
#define SIZE(large, small, mini)
#define MENU_BARBACKGROUND
QIcon windowIcon
the widget&#39;s icon
Definition: qwidget.h:199
NSToolbar * toolbar
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
SelectionMode selectionMode
which selection mode the view operates in
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
static QPixmap * find(const QString &key)
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
#define PBS_DEFAULTED_ANIMATING
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
static QIcon windowIcon()
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
The QTime class provides clock time functions.
Definition: qdatetime.h:148
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
void drawControl(ControlElement element, const QStyleOption *option, QPainter *p, const QWidget *wwidget=0) const
Reimplemented Function
#define MC_BULLETNORMAL
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define TMT_TRANSITIONDURATIONS
#define PP_TRANSPARENTBARVERT
#define PP_FILL
const char * name
#define MENU_POPUPITEM
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
void setEndImage(const QImage &image)
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static int buttonStateId(int flags, int partId)
static const int windowsItemHMargin
#define MENU_POPUPCHECKBACKGROUND
__int64 qint64
Definition: qglobal.h:942
The State element defines configurations of objects and properties.
#define BP_COMMANDLINK
#define MENU_POPUPCHECK
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
State
Definition: qaudio.h:59
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition: qicon.cpp:679
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
#define MBI_HOT
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
void setPrimaryImage(const QImage &image)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
void setAlternateImage(const QImage &image)
void startAnimation(QWindowsVistaAnimation *)
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
#define MBI_DISABLED
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
#define MENU_BARITEM
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
static const int windowsArrowHMargin
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isFloating() const
Definition: qdockwidget.h:96
#define MC_CHECKMARKNORMAL
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define MBI_NORMAL
static const int windowsRightBorder
static const int windowsItemFrame
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
static PtrGetThemeMargins pGetThemeMargins
#define PP_FILLVERT
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static PtrGetThemePartSize pGetThemePartSize
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
#define MC_BULLETDISABLED
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
void setStartImage(const QImage &image)
void setDuration(int duration)
Orientation
Definition: qnamespace.h:174
#define PP_MOVEOVERLAYVERT
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define MENU_POPUPGUTTER
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void setStartTime(const QTime &startTime)
QWindowsVistaAnimation * widgetAnimation(const QWidget *) const
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
#define TMT_CONTENTMARGINS

◆ drawPrimitive()

void QWindowsVistaStyle::drawPrimitive ( PrimitiveElement  element,
const QStyleOption option,
QPainter painter,
const QWidget widget = 0 
) const
virtual
Warning
This function is not part of the public interface.

Animations are used for some state transitions on specific widgets.

Only one running animation can exist for a widget at any specific time. Animations can be added through QWindowsVistaStylePrivate::startAnimation(Animation *) and any existing animation on a widget can be retrieved with QWindowsVistaStylePrivate::widgetAnimation(Widget *).

Once an animation has been started, QWindowsVistaStylePrivate::timerEvent(QTimerEvent *) will continuously call update() on the widget until it is stopped, meaning that drawPrimitive will be called many times until the transition has completed. During this time, the result will be retrieved by the Animation::paint(...) function and not by the style itself.

To determine if a transition should occur, the style needs to know the previous state of the widget as well as the current one. This is solved by updating dynamic properties on the widget every time the function is called.

Transitions interrupting existing transitions should always be smooth, so whenever a hover-transition is started on a pulsating button, it uses the current frame of the pulse-animation as the starting image for the hover transition.

Reimplemented from QWindowsStyle.

Definition at line 345 of file qwindowsvistastyle.cpp.

347 {
348  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
349 
350  int state = option->state;
352  QWindowsStyle::drawPrimitive(element, option, painter, widget);
353  return;
354  }
355 
356  QRect oldRect;
357  QRect newRect;
358 
359  if (widget && d->transitionsEnabled())
360  {
361  /* all widgets that supports state transitions : */
362  if (
363 #ifndef QT_NO_LINEEDIT
364  (qobject_cast<const QLineEdit*>(widget) && element == PE_FrameLineEdit) ||
365 #endif // QT_NO_LINEEDIT
366  (qobject_cast<const QRadioButton*>(widget)&& element == PE_IndicatorRadioButton) ||
367  (qobject_cast<const QCheckBox*>(widget) && element == PE_IndicatorCheckBox) ||
368  (qobject_cast<const QGroupBox *>(widget)&& element == PE_IndicatorCheckBox) ||
369  (qobject_cast<const QToolButton*>(widget) && element == PE_PanelButtonBevel)
370  )
371  {
372  // Retrieve and update the dynamic properties tracking
373  // the previous state of the widget:
374  QWidget *w = const_cast<QWidget *> (widget);
375  int oldState = w->property("_q_stylestate").toInt();
376  oldRect = w->property("_q_stylerect").toRect();
377  newRect = w->rect();
378  w->setProperty("_q_stylestate", (int)option->state);
379  w->setProperty("_q_stylerect", w->rect());
380 
381  bool doTransition = oldState &&
382  ((state & State_Sunken) != (oldState & State_Sunken) ||
383  (state & State_On) != (oldState & State_On) ||
384  (state & State_MouseOver) != (oldState & State_MouseOver));
385 
386  if (oldRect != newRect ||
387  (state & State_Enabled) != (oldState & State_Enabled) ||
388  (state & State_Active) != (oldState & State_Active))
389  d->stopAnimation(widget);
390 
391 #ifndef QT_NO_LINEEDIT
392  if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(widget))
393  if (edit->isReadOnly() && element == PE_FrameLineEdit) // Do not animate read only line edits
394  doTransition = false;
395 #endif // QT_NO_LINEEDIT
396 
397  if (doTransition) {
398 
399  // We create separate images for the initial and final transition states and store them in the
400  // Transition object.
401  QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
403  QStyleOption opt = *option;
404 
405  opt.rect.setRect(0, 0, option->rect.width(), option->rect.height());
406  opt.state = (QStyle::State)oldState;
407  startImage.fill(0);
408  QPainter startPainter(&startImage);
409 
410  QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
412  t->setWidget(w);
413 
414  // If we have a running animation on the widget already, we will use that to paint the initial
415  // state of the new transition, this ensures a smooth transition from a current animation such as a
416  // pulsating default button into the intended target state.
417 
418  if (!anim)
419  proxy()->drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0
420  else // this ensures that we do not recurse in the animation logic above
421  anim->paint(&startPainter, &opt);
422 
423  d->startAnimation(t);
424  t->setStartImage(startImage);
425 
426  // The end state of the transition is simply the result we would have painted
427  // if the style was not animated.
428 
429  QPainter endPainter(&endImage);
430  endImage.fill(0);
431  QStyleOption opt2 = opt;
432  opt2.state = option->state;
433  proxy()->drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0
434  // this ensures that we do not recurse in the animation logic above
435  t->setEndImage(endImage);
436 
437  HTHEME theme;
438  int partId;
439  int duration;
440  int fromState = 0;
441  int toState = 0;
442 
443  //translate state flags to UXTHEME states :
444  if (element == PE_FrameLineEdit) {
445  theme = pOpenThemeData(0, L"Edit");
446  partId = EP_EDITBORDER_NOSCROLL;
447 
448  if (oldState & State_MouseOver)
449  fromState = ETS_HOT;
450  else if (oldState & State_HasFocus)
451  fromState = ETS_FOCUSED;
452  else
453  fromState = ETS_NORMAL;
454 
455  if (state & State_MouseOver)
456  toState = ETS_HOT;
457  else if (state & State_HasFocus)
458  toState = ETS_FOCUSED;
459  else
460  toState = ETS_NORMAL;
461 
462  } else {
463  theme = pOpenThemeData(0, L"Button");
464  if (element == PE_IndicatorRadioButton)
465  partId = BP_RADIOBUTTON;
466  else if (element == PE_IndicatorCheckBox)
467  partId = BP_CHECKBOX;
468  else
469  partId = BP_PUSHBUTTON;
470 
471  fromState = buttonStateId(oldState, partId);
472  toState = buttonStateId(option->state, partId);
473  }
474 
475  // Retrieve the transition time between the states from the system.
476  if (theme && pGetThemeTransitionDuration(theme, partId, fromState, toState,
477  TMT_TRANSITIONDURATIONS, &duration) == S_OK)
478  {
479  t->setDuration(duration);
480  }
482  }
483  }
484  } // End of animation part
485 
486 
487  QRect rect = option->rect;
488 
489  switch (element) {
491  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
492  int stateId = HSAS_SORTEDDOWN;
493  if (header->sortIndicator & QStyleOptionHeader::SortDown)
494  stateId = HSAS_SORTEDUP; //note that the uxtheme sort down indicator is the inverse of ours
495  XPThemeData theme(widget, painter, QLatin1String("HEADER"), HP_HEADERSORTARROW, stateId, option->rect);
496  d->drawBackground(theme);
497  }
498  break;
499 
500  case PE_IndicatorBranch:
501  {
502  XPThemeData theme(d->treeViewHelper(), painter, QLatin1String("TREEVIEW"));
503  static int decoration_size = 0;
504  if (theme.isValid() && !decoration_size) {
505  SIZE size;
506  pGetThemePartSize(theme.handle(), 0, TVP_HOTGLYPH, GLPS_OPENED, 0, TS_TRUE, &size);
507  decoration_size = qMax(size.cx, size.cy);
508  }
509  int mid_h = option->rect.x() + option->rect.width() / 2;
510  int mid_v = option->rect.y() + option->rect.height() / 2;
511  int bef_h = mid_h;
512  int bef_v = mid_v;
513  int aft_h = mid_h;
514  int aft_v = mid_v;
515  if (option->state & State_Children) {
516  int delta = decoration_size / 2;
517  theme.rect = QRect(bef_h - delta, bef_v - delta, decoration_size, decoration_size);
518  theme.partId = option->state & State_MouseOver ? TVP_HOTGLYPH : TVP_GLYPH;
519  theme.stateId = option->state & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
520  if (option->direction == Qt::RightToLeft)
521  theme.mirrorHorizontally = true;
522  d->drawBackground(theme);
523  bef_h -= delta + 2;
524  bef_v -= delta + 2;
525  aft_h += delta - 2;
526  aft_v += delta - 2;
527  }
528 #if 0
529  QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
530  if (option->state & State_Item) {
531  if (option->direction == Qt::RightToLeft)
532  painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
533  else
534  painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
535  }
536  if (option->state & State_Sibling && option->rect.bottom() > aft_v)
537  painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
538  if (option->state & (State_Open | State_Children | State_Item | State_Sibling) && (bef_v > option->rect.y()))
539  painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
540 #endif
541  }
542  break;
543 
544  case PE_PanelButtonBevel:
547  {
548  if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
549  a->paint(painter, option);
550  } else {
551  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
552  }
553  }
554  break;
555 
556  case PE_FrameMenu:
557  {
558  int stateId = option->state & State_Active ? MB_ACTIVE : MB_INACTIVE;
559  XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPBORDERS, stateId, option->rect);
560  d->drawBackground(theme);
561  }
562  break;
563  case PE_Frame:
564 #ifndef QT_NO_TEXTEDIT
565  if (const QTextEdit *edit = qobject_cast<const QTextEdit*>(widget)) {
566  painter->save();
567  int stateId = ETS_NORMAL;
568  if (!(state & State_Enabled))
569  stateId = ETS_DISABLED;
570  else if (edit->isReadOnly())
571  stateId = ETS_READONLY;
572  else if (state & State_HasFocus)
573  stateId = ETS_SELECTED;
574  XPThemeData theme(widget, painter, QLatin1String("EDIT"), EP_EDITBORDER_HVSCROLL, stateId, option->rect);
575  // Since EP_EDITBORDER_HVSCROLL does not us borderfill, theme.noContent cannot be used for clipping
576  int borderSize = 1;
577  pGetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
578  QRegion clipRegion = option->rect;
579  QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
580  clipRegion ^= content;
581  painter->setClipRegion(clipRegion);
582  d->drawBackground(theme);
583  painter->restore();
584  } else
585 #endif // QT_NO_TEXTEDIT
586  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
587  break;
588 
589  case PE_PanelLineEdit:
590  if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
591  QBrush bg;
592  bool usePalette = false;
593  bool isEnabled = option->state & State_Enabled;
594  uint resolve_mask = panel->palette.resolve();
595  if (widget) {
596  //Since spin box and combo box includes a line edit we need to resolve the palette on the parent instead
597 #ifndef QT_NO_SPINBOX
598  if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget()))
599  resolve_mask = spinbox->palette().resolve();
600 #endif // QT_NO_SPINBOX
601  }
602  if (resolve_mask & (1 << QPalette::Base)) {
603  // Base color is set for this widget, so use it
604  bg = panel->palette.brush(QPalette::Base);
605  usePalette = true;
606  }
607  if (usePalette) {
608  painter->fillRect(panel->rect, bg);
609  } else {
610  int partId = EP_BACKGROUND;
611  int stateId = EBS_NORMAL;
612  if (!isEnabled)
613  stateId = EBS_DISABLED;
614  else if (state & State_ReadOnly)
615  stateId = EBS_READONLY;
616  else if (state & State_MouseOver)
617  stateId = EBS_HOT;
618 
619  XPThemeData theme(0, painter, QLatin1String("EDIT"), partId, stateId, rect);
620  if (!theme.isValid()) {
621  QWindowsStyle::drawPrimitive(element, option, painter, widget);
622  return;
623  }
624  int bgType;
625  pGetThemeEnumValue( theme.handle(),
626  partId,
627  stateId,
628  TMT_BGTYPE,
629  &bgType);
630  if( bgType == BT_IMAGEFILE ) {
631  d->drawBackground(theme);
632  } else {
633  QBrush fillColor = option->palette.brush(QPalette::Base);
634  if (!isEnabled) {
635  PROPERTYORIGIN origin = PO_NOTFOUND;
636  pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
637  // Use only if the fill property comes from our part
638  if ((origin == PO_PART || origin == PO_STATE)) {
639  COLORREF bgRef;
640  pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
641  fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
642  }
643  }
644  painter->fillRect(option->rect, fillColor);
645  }
646  }
647  if (panel->lineWidth > 0)
648  proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
649  return;
650  }
651  break;
652 
653  case PE_FrameLineEdit:
654  if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
655  anim->paint(painter, option);
656  } else {
657  QPainter *p = painter;
659  // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
660  QPen oldPen = p->pen();
661  // Inner white border
662  p->setPen(QPen(option->palette.base().color(), 1));
663  p->drawRect(option->rect.adjusted(1, 1, -2, -2));
664  // Outer dark border
665  p->setPen(QPen(option->palette.shadow().color(), 1));
666  p->drawRect(option->rect.adjusted(0, 0, -1, -1));
667  p->setPen(oldPen);
668  return;
669  } else {
670  int stateId = ETS_NORMAL;
671  if (!(state & State_Enabled))
672  stateId = ETS_DISABLED;
673  else if (state & State_ReadOnly)
674  stateId = ETS_READONLY;
675  else if (state & State_MouseOver)
676  stateId = ETS_HOT;
677  else if (state & State_HasFocus)
678  stateId = ETS_SELECTED;
679  XPThemeData theme(widget, painter, QLatin1String("EDIT"), EP_EDITBORDER_NOSCROLL, stateId, option->rect);
680  painter->save();
681  QRegion clipRegion = option->rect;
682  clipRegion -= option->rect.adjusted(2, 2, -2, -2);
683  painter->setClipRegion(clipRegion);
684  d->drawBackground(theme);
685  painter->restore();
686  }
687  }
688  break;
689 
691  {
692  XPThemeData theme;
693  QRect rect;
694  if (option->state & State_Horizontal) {
695  theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
696  rect = option->rect.adjusted(0, 1, 0, -2);
697  rect.setWidth(4);
698  } else {
699  theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
700  rect = option->rect.adjusted(1, 0, -1, 0);
701  rect.setHeight(4);
702  }
703  theme.rect = rect;
704  d->drawBackground(theme);
705  }
706  break;
707 
709  {
710  QPen pen = painter->pen();
711  int margin = 3;
712  painter->setPen(option->palette.background().color().darker(114));
713  if (option->state & State_Horizontal) {
714  int x1 = option->rect.center().x();
715  painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));
716  } else {
717  int y1 = option->rect.center().y();
718  painter->drawLine(QPoint(option->rect.left() + margin, y1), QPoint(option->rect.right() - margin, y1));
719  }
720  painter->setPen(pen);
721  }
722  break;
723 
724  case PE_PanelTipLabel: {
725  XPThemeData theme(widget, painter, QLatin1String("TOOLTIP"), TTP_STANDARD, TTSS_NORMAL, option->rect);
726  d->drawBackground(theme);
727  break;
728  }
729 
731  {
732  const QStyleOptionViewItemV4 *vopt;
733  const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
734  bool newStyle = true;
735 
736  if (qobject_cast<const QTableView*>(widget))
737  newStyle = false;
738 
739  if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) {
740  bool selected = vopt->state & QStyle::State_Selected;
741  bool hover = vopt->state & QStyle::State_MouseOver;
742  bool active = vopt->state & QStyle::State_Active;
743 
745  painter->fillRect(vopt->rect, vopt->palette.alternateBase());
746 
749  if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
750  cg = QPalette::Inactive;
751 
752  QRect itemRect = subElementRect(QStyle::SE_ItemViewItemFocusRect, option, widget).adjusted(-1, 0, 1, 0);
753  itemRect.setTop(vopt->rect.top());
754  itemRect.setBottom(vopt->rect.bottom());
755 
756  QSize sectionSize = itemRect.size();
757  if (vopt->showDecorationSelected)
758  sectionSize = vopt->rect.size();
759 
761  sectionSize.setWidth(vopt->rect.width());
763  hover = false;
764  QPixmap pixmap;
765 
766  if (vopt->backgroundBrush.style() != Qt::NoBrush) {
767  const QPointF oldBrushOrigin = painter->brushOrigin();
768  painter->setBrushOrigin(vopt->rect.topLeft());
769  painter->fillRect(vopt->rect, vopt->backgroundBrush);
770  painter->setBrushOrigin(oldBrushOrigin);
771  }
772 
773  if (hover || selected) {
774  if (sectionSize.width() > 0 && sectionSize.height() > 0) {
775  QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width())
776  .arg(sectionSize.height()).arg(selected).arg(active).arg(hover);
777  if (!QPixmapCache::find(key, pixmap)) {
778  pixmap = QPixmap(sectionSize);
779  pixmap.fill(Qt::transparent);
780 
781  int state;
782  if (selected && hover)
783  state = LISS_HOTSELECTED;
784  else if (selected && !active)
785  state = LISS_SELECTEDNOTFOCUS;
786  else if (selected)
787  state = LISS_SELECTED;
788  else
789  state = LISS_HOT;
790 
791  QPainter pixmapPainter(&pixmap);
792  XPThemeData theme(d->treeViewHelper(), &pixmapPainter, QLatin1String("TREEVIEW"),
793  LVP_LISTITEM, state, QRect(0, 0, sectionSize.width(), sectionSize.height()));
794  if (theme.isValid()) {
795  d->drawBackground(theme);
796  } else {
797  QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
798  break;;
799  }
800  QPixmapCache::insert(key, pixmap);
801  }
802  }
803 
804  if (vopt->showDecorationSelected) {
805  const int frame = 2; //Assumes a 2 pixel pixmap border
806  QRect srcRect = QRect(0, 0, sectionSize.width(), sectionSize.height());
807  QRect pixmapRect = vopt->rect;
808  bool reverse = vopt->direction == Qt::RightToLeft;
809  bool leftSection = vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning;
810  bool rightSection = vopt->viewItemPosition == QStyleOptionViewItemV4::End;
813  painter->drawPixmap(pixmapRect.topLeft(), pixmap);
814  else if (reverse ? rightSection : leftSection){
815  painter->drawPixmap(QRect(pixmapRect.topLeft(),
816  QSize(frame, pixmapRect.height())), pixmap,
817  QRect(QPoint(0, 0), QSize(frame, pixmapRect.height())));
818  painter->drawPixmap(pixmapRect.adjusted(frame, 0, 0, 0),
819  pixmap, srcRect.adjusted(frame, 0, -frame, 0));
820  } else if (reverse ? leftSection : rightSection) {
821  painter->drawPixmap(QRect(pixmapRect.topRight() - QPoint(frame - 1, 0),
822  QSize(frame, pixmapRect.height())), pixmap,
823  QRect(QPoint(pixmapRect.width() - frame, 0),
824  QSize(frame, pixmapRect.height())));
825  painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
826  pixmap, srcRect.adjusted(frame, 0, -frame, 0));
828  painter->drawPixmap(pixmapRect, pixmap,
829  srcRect.adjusted(frame, 0, -frame, 0));
830  } else {
831  if (vopt->text.isEmpty() && vopt->icon.isNull())
832  break;
833  painter->drawPixmap(itemRect.topLeft(), pixmap);
834  }
835  }
836  } else {
837  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
838  }
839  break;
840  }
841  case PE_Widget:
842  {
843  const QDialogButtonBox *buttonBox = 0;
844 
845  if (qobject_cast<const QMessageBox *> (widget))
846  buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
847 #ifndef QT_NO_INPUTDIALOG
848  else if (qobject_cast<const QInputDialog *> (widget))
849  buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
850 #endif // QT_NO_INPUTDIALOG
851 
852  if (buttonBox) {
853  //draw white panel part
854  XPThemeData theme(widget, painter, QLatin1String("TASKDIALOG"), TDLG_PRIMARYPANEL, 0, option->rect);
855  QRect toprect = option->rect;
856  toprect.setBottom(buttonBox->geometry().top());
857  theme.rect = toprect;
858  d->drawBackground(theme);
859 
860  //draw bottom panel part
861  QRect buttonRect = option->rect;
862  buttonRect.setTop(buttonBox->geometry().top());
863  theme.rect = buttonRect;
864  theme.partId = TDLG_SECONDARYPANEL;
865  d->drawBackground(theme);
866  }
867  }
868  break;
869  default:
870  QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
871  break;
872  }
873 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
virtual void paint(QPainter *painter, const QStyleOption *option)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
#define LISS_HOTSELECTED
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
void setWidget(QWidget *widget)
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
static PtrGetThemeTransitionDuration pGetThemeTransitionDuration
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
QIcon icon
The icon (if any) to be drawn in the view item.
Definition: qstyleoption.h:617
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
static PtrGetThemeInt pGetThemeInt
static C reverse(const C &l)
QBrush backgroundBrush
The QBrush that should be used to paint the view items background.
Definition: qstyleoption.h:620
#define TVP_HOTGLYPH
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define LISS_SELECTEDNOTFOCUS
static PtrOpenThemeData pOpenThemeData
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define MB_INACTIVE
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
void drawBackground(XPThemeData &themeData)
Main theme drawing function.
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define BT_IMAGEFILE
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
void stopAnimation(const QWidget *)
#define SIZE(large, small, mini)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
SelectionMode selectionMode
which selection mode the view operates in
#define EP_EDITBORDER_HVSCROLL
static QPixmap * find(const QString &key)
ColorGroup
Definition: qpalette.h:92
#define LISS_HOT
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
int width() const
Returns the width.
Definition: qsize.h:126
The QRadioButton widget provides a radio button with a text label.
Definition: qradiobutton.h:56
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define TMT_BGTYPE
ViewItemFeatures features
a bitwise OR of the features that describe this view item
Definition: qstyleoption.h:577
#define TDLG_SECONDARYPANEL
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define TMT_TRANSITIONDURATIONS
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p, const QWidget *widget=0) const
Reimplemented Function
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
#define EBS_DISABLED
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
bool showDecorationSelected
whether the decoration should be highlighted on selected items
Definition: qstyleoption.h:553
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void setEndImage(const QImage &image)
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
unsigned int uint
Definition: qglobal.h:996
static int buttonStateId(int flags, int partId)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static bool isItemViewDelegateLineEdit(const QWidget *widget)
#define LISS_SELECTED
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
static PtrGetThemeEnumValue pGetThemeEnumValue
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
static PtrGetThemeColor pGetThemeColor
#define EBS_READONLY
ViewItemPosition viewItemPosition
Gives the position of this view item relative to other items.
Definition: qstyleoption.h:619
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static PtrGetThemePropertyOrigin pGetThemePropertyOrigin
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
State
Definition: qaudio.h:59
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void startAnimation(QWindowsVistaAnimation *)
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
#define EBS_HOT
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
#define MB_ACTIVE
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
const QBrush & alternateBase() const
Returns the alternate base brush of the current color group.
Definition: qpalette.h:131
#define EP_BACKGROUND
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define TMT_BORDERSIZE
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static PtrGetThemePartSize pGetThemePartSize
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition: qtoolbutton.h:59
const QRect & geometry() const
#define EP_EDITBORDER_NOSCROLL
void setStartImage(const QImage &image)
#define MENU_POPUPBORDERS
void setDuration(int duration)
The QCheckBox widget provides a checkbox with a text label.
Definition: qcheckbox.h:56
SelectionBehavior selectionBehavior
which selection behavior the view uses
#define TDLG_PRIMARYPANEL
#define TMT_FILLCOLOR
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void setStartTime(const QTime &startTime)
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
QWindowsVistaAnimation * widgetAnimation(const QWidget *) const
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
QString text
The text (if any) to be drawn in the view item.
Definition: qstyleoption.h:618
#define EBS_NORMAL
#define QT_NO_LINEEDIT
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ event()

bool QWindowsVistaStyle::event ( QEvent e)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QObject.

Definition at line 2301 of file qwindowsvistastyle.cpp.

2302 {
2304  switch (e->type()) {
2305  case QEvent::Timer:
2306  {
2308  if (d->animationTimer.timerId() == timerEvent->timerId()) {
2309  d->timerEvent();
2310  e->accept();
2311  return true;
2312  }
2313  }
2314  break;
2315  default:
2316  break;
2317  }
2318  return QWindowsXPStyle::event(e);
2319 }
double d
Definition: qnumeric_p.h:62
The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows ...
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
void timerEvent(QTimerEvent *event)
Reimplemented Function
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ hitTestComplexControl()

QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
const QPoint pos,
const QWidget widget = 0 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 2324 of file qwindowsvistastyle.cpp.

2326 {
2328  return QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
2329  }
2330  return QWindowsXPStyle::hitTestComplexControl(control, option, pos, widget);
2331 }
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function

◆ pixelMetric()

int QWindowsVistaStyle::pixelMetric ( PixelMetric  metric,
const QStyleOption option = 0,
const QWidget widget = 0 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2336 of file qwindowsvistastyle.cpp.

Referenced by drawControl().

2337 {
2339  return QWindowsStyle::pixelMetric(metric, option, widget);
2340  }
2341  switch (metric) {
2342 
2344  return int(QStyleHelper::dpiScaled(5.));
2345  case PM_ScrollBarSliderMin:
2346  return int(QStyleHelper::dpiScaled(18.));
2347  case PM_MenuHMargin:
2348  case PM_MenuVMargin:
2349  return 0;
2350  case PM_MenuPanelWidth:
2351  return 3;
2352  default:
2353  break;
2354  }
2355  return QWindowsXPStyle::pixelMetric(metric, option, widget);
2356 }
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
qreal dpiScaled(qreal value)
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function

◆ polish() [1/3]

void QWindowsVistaStyle::polish ( QWidget widget)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2377 of file qwindowsvistastyle.cpp.

2378 {
2379  QWindowsXPStyle::polish(widget);
2380 #ifndef QT_NO_LINEEDIT
2381  if (qobject_cast<QLineEdit*>(widget))
2382  widget->setAttribute(Qt::WA_Hover);
2383  else
2384 #endif // QT_NO_LINEEDIT
2385  if (qobject_cast<QGroupBox*>(widget))
2386  widget->setAttribute(Qt::WA_Hover);
2387  else if (qobject_cast<QCommandLinkButton*>(widget)) {
2388  QFont buttonFont = widget->font();
2389  buttonFont.setFamily(QLatin1String("Segoe UI"));
2390  widget->setFont(buttonFont);
2391  }
2392  else if (widget->inherits("QTipLabel")){
2393  //note that since tooltips are not reused
2394  //we do not have to care about unpolishing
2395  widget->setContentsMargins(3, 0, 4, 0);
2396  COLORREF bgRef;
2397  HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
2398  if (theme) {
2399  if (pGetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef) == S_OK) {
2400  QColor textColor = QColor::fromRgb(bgRef);
2401  QPalette pal;
2402  pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
2403  widget->setPalette(pal);
2404  }
2405  }
2406  } else if (qobject_cast<QMessageBox *> (widget)) {
2408  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
2409  if (buttonBox)
2410  buttonBox->setContentsMargins(0, 9, 0, 0);
2411  }
2412 #ifndef QT_NO_INPUTDIALOG
2413  else if (qobject_cast<QInputDialog *> (widget)) {
2415  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
2416  if (buttonBox)
2417  buttonBox->setContentsMargins(0, 9, 0, 0);
2418  }
2419 #endif // QT_NO_INPUTDIALOG
2420  else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
2421  tree->viewport()->setAttribute(Qt::WA_Hover);
2422  }
2423  else if (QListView *list = qobject_cast<QListView *> (widget)) {
2424  list->viewport()->setAttribute(Qt::WA_Hover);
2425  }
2426 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
#define TMT_TEXTCOLOR
QFont font
the font currently set for the widget
Definition: qwidget.h:181
static PtrOpenThemeData pOpenThemeData
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static PtrGetThemeColor pGetThemeColor
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
static HWND winId(const QWidget *widget)
This function will always return a valid window handle, and might create a limbo widget to do so...
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
static QColor fromRgb(QRgb rgb)
Static convenience function that returns a QColor constructed from the given QRgb value rgb...
Definition: qcolor.cpp:1958
void polish(QApplication *)
Reimplemented Function
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ polish() [2/3]

void QWindowsVistaStyle::polish ( QPalette pal)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2481 of file qwindowsvistastyle.cpp.

2482 {
2483  QWindowsStyle::polish(pal);
2484  pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(104));
2485 }
void polish(QApplication *)
Reimplemented Function
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206

◆ polish() [3/3]

void QWindowsVistaStyle::polish ( QApplication app)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2369 of file qwindowsvistastyle.cpp.

2370 {
2372 }
void polish(QApplication *)
Reimplemented Function

◆ sizeFromContents()

QSize QWindowsVistaStyle::sizeFromContents ( ContentsType  type,
const QStyleOption option,
const QSize size,
const QWidget widget 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 1932 of file qwindowsvistastyle.cpp.

1934 {
1936  return QWindowsStyle::sizeFromContents(type, option, size, widget);
1937 
1938  QSize sz(size);
1939  switch (type) {
1940  case CT_MenuItem:
1941  sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1942  int minimumHeight;
1943  {
1944  SIZE size;
1945  MARGINS margins;
1946  XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT);
1947  pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size);
1948  pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins);
1949  minimumHeight = qMax<qint32>(size.cy + margins.cyBottomHeight+ margins.cyTopHeight, sz.height());
1950  sz.rwidth() += size.cx + margins.cxLeftWidth + margins.cxRightWidth;
1951  }
1952 
1953  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1954  if (menuitem->menuItemType != QStyleOptionMenuItem::Separator)
1955  sz.setHeight(minimumHeight);
1956  }
1957  return sz;
1958 #ifndef QT_NO_MENUBAR
1959  case CT_MenuBarItem:
1960  if (!sz.isEmpty())
1961  sz += QSize(windowsItemHMargin * 5 + 1, 5);
1962  return sz;
1963  break;
1964 #endif
1965  case CT_ItemViewItem:
1966  sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1967  sz.rheight() += 2;
1968  return sz;
1969  case CT_SpinBox:
1970  {
1971  //Spinbox adds frame twice
1972  sz = QWindowsStyle::sizeFromContents(type, option, size, widget);
1973  int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
1974  sz -= QSize(2*border, 2*border);
1975  }
1976  return sz;
1977  default:
1978  break;
1979  }
1980  return QWindowsXPStyle::sizeFromContents(type, option, size, widget);
1981 }
int type
Definition: qmetatype.cpp:239
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define SIZE(large, small, mini)
static const int windowsItemHMargin
QSize sizeFromContents(ContentsType ct, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
#define MENU_POPUPCHECKBACKGROUND
#define MENU_POPUPCHECK
#define MBI_HOT
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
const QStyle * proxy() const
Definition: qstyle.cpp:2546
static PtrGetThemeMargins pGetThemeMargins
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static PtrGetThemePartSize pGetThemePartSize
#define TMT_CONTENTMARGINS

◆ standardIconImplementation

QIcon QWindowsVistaStyle::standardIconImplementation ( StandardPixmap  standardIcon,
const QStyleOption option,
const QWidget widget = 0 
) const
protectedslot
Warning
This function is not part of the public interface.

Definition at line 2635 of file qwindowsvistastyle.cpp.

2638 {
2641  }
2642 
2643  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate *>(d_func());
2644  switch(standardIcon) {
2645  case SP_CommandLink:
2646  {
2648  if (theme.isValid()) {
2649  SIZE size;
2650  pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size);
2651  QIcon linkGlyph;
2652  QPixmap pm = QPixmap(size.cx, size.cy);
2653  pm.fill(Qt::transparent);
2654  QPainter p(&pm);
2655  theme.painter = &p;
2656  theme.rect = QRect(0, 0, size.cx, size.cy);
2657  d->drawBackground(theme);
2658  linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
2659  pm.fill(Qt::transparent);
2660 
2661  theme.stateId = CMDLGS_PRESSED;
2662  d->drawBackground(theme);
2663  linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
2664  pm.fill(Qt::transparent);
2665 
2666  theme.stateId = CMDLGS_HOT;
2667  d->drawBackground(theme);
2668  linkGlyph.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
2669  pm.fill(Qt::transparent);
2670 
2671  theme.stateId = CMDLGS_DISABLED;
2672  d->drawBackground(theme);
2673  linkGlyph.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
2674  return linkGlyph;
2675  }
2676  }
2677  break;
2678  default:
2679  break;
2680  }
2682 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
#define CMDLGS_HOT
#define BP_COMMANDLINKGLYPH
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void drawBackground(XPThemeData &themeData)
Main theme drawing function.
#define CMDLGS_PRESSED
#define SIZE(large, small, mini)
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
#define CMDLGS_NORMAL
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
#define CMDLGS_DISABLED
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static PtrGetThemePartSize pGetThemePartSize
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ standardPalette()

QPalette QWindowsVistaStyle::standardPalette ( ) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QStyle.

Definition at line 2361 of file qwindowsvistastyle.cpp.

2362 {
2364 }
QPalette standardPalette() const
Reimplemented Function

◆ standardPixmap()

QPixmap QWindowsVistaStyle::standardPixmap ( StandardPixmap  standardPixmap,
const QStyleOption option,
const QWidget widget = 0 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2490 of file qwindowsvistastyle.cpp.

2492 {
2494  return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
2495  }
2496  return QWindowsXPStyle::standardPixmap(standardPixmap, option, widget);
2497 }
QPixmap standardPixmap(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
Reimplemented Function
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function

◆ styleHint()

int QWindowsVistaStyle::styleHint ( StyleHint  hint,
const QStyleOption option = 0,
const QWidget widget = 0,
QStyleHintReturn returnData = 0 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2154 of file qwindowsvistastyle.cpp.

Referenced by drawControl().

2156 {
2157  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
2158  int ret = 0;
2159  switch (hint) {
2161  ret = false;
2162  break;
2163  case SH_ToolTip_Mask:
2164  if (option) {
2165  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
2166  ret = true;
2167  XPThemeData themeData(widget, 0, QLatin1String("TOOLTIP"), TTP_STANDARD, TTSS_NORMAL, option->rect);
2168  mask->region = d->region(themeData);
2169  }
2170  }
2171  break;
2173  if (option)
2174  ret = option->palette.color(QPalette::Base).darker(118).rgb();
2175  else
2176  ret = -1;
2177  break;
2178  default:
2179  ret = QWindowsXPStyle::styleHint(hint, option, widget, returnData);
2180  break;
2181  }
2182  return ret;
2183 }
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
QRegion region(XPThemeData &themeData)
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051

◆ subControlRect()

QRect QWindowsVistaStyle::subControlRect ( ComplexControl  control,
const QStyleOptionComplex option,
SubControl  subControl,
const QWidget widget 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 2189 of file qwindowsvistastyle.cpp.

Referenced by drawComplexControl().

2191 {
2193  return QWindowsStyle::subControlRect(control, option, subControl, widget);
2194 
2195  QRect rect = QWindowsXPStyle::subControlRect(control, option, subControl, widget);
2196  switch (control) {
2197 #ifndef QT_NO_COMBOBOX
2198  case CC_ComboBox:
2199  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
2200  int x = cb->rect.x(),
2201  y = cb->rect.y(),
2202  wi = cb->rect.width(),
2203  he = cb->rect.height();
2204  int xpos = x;
2205  int margin = cb->frame ? 3 : 0;
2206  int bmarg = cb->frame ? 2 : 0;
2207  int arrowButtonWidth = bmarg + 16;
2208  xpos += wi - arrowButtonWidth;
2209 
2210  switch (subControl) {
2211  case SC_ComboBoxFrame:
2212  rect = cb->rect;
2213  break;
2214  case SC_ComboBoxArrow:
2215  rect.setRect(xpos, y , arrowButtonWidth, he);
2216  break;
2217  case SC_ComboBoxEditField:
2218  rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
2219  break;
2221  rect = cb->rect;
2222  break;
2223  default:
2224  break;
2225  }
2226  rect = visualRect(cb->direction, cb->rect, rect);
2227  return rect;
2228  }
2229 #endif // QT_NO_COMBOBOX
2230  case CC_TitleBar:
2231  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
2232  if (!buttonVisible(subControl, tb))
2233  return rect;
2234  const bool isToolTitle = false;
2235  const int height = tb->rect.height();
2236  const int width = tb->rect.width();
2237  int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4;
2238 
2239  const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
2240  const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
2241  const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
2242  const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0;
2243  const bool contextHint = (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) != 0;
2244  const bool shadeHint = (tb->titleBarFlags & Qt::WindowShadeButtonHint) != 0;
2245 
2246  switch (subControl) {
2247  case SC_TitleBarLabel:
2248  rect = QRect(frameWidth, 0, width - (buttonWidth + frameWidth + 10), height);
2249  if (isToolTitle) {
2250  if (sysmenuHint) {
2251  rect.adjust(0, 0, -buttonWidth - 3, 0);
2252  }
2253  if (minimizeHint || maximizeHint)
2254  rect.adjust(0, 0, -buttonWidth - 2, 0);
2255  } else {
2256  if (sysmenuHint) {
2257  const int leftOffset = height - 8;
2258  rect.adjust(leftOffset, 0, 0, 4);
2259  }
2260  if (minimizeHint)
2261  rect.adjust(0, 0, -buttonWidth - 2, 0);
2262  if (maximizeHint)
2263  rect.adjust(0, 0, -buttonWidth - 2, 0);
2264  if (contextHint)
2265  rect.adjust(0, 0, -buttonWidth - 2, 0);
2266  if (shadeHint)
2267  rect.adjust(0, 0, -buttonWidth - 2, 0);
2268  }
2269  rect.translate(0, 2);
2270  rect = visualRect(option->direction, option->rect, rect);
2271  break;
2272  case SC_TitleBarSysMenu:
2273  {
2274  const int controlTop = 6;
2275  const int controlHeight = height - controlTop - 3;
2276  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
2277  QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
2278  if (tb->icon.isNull())
2279  iconSize = QSize(controlHeight, controlHeight);
2280  int hPad = (controlHeight - iconSize.height())/2;
2281  int vPad = (controlHeight - iconSize.width())/2;
2282  rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height());
2283  rect.translate(0, 3);
2284  rect = visualRect(option->direction, option->rect, rect);
2285  }
2286  break;
2287  default:
2288  break;
2289  }
2290  }
2291  break;
2292  default:
2293  break;
2294  }
2295  return rect;
2296 }
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget=0) const
Reimplemented Function
int width() const
Returns the width.
Definition: qsize.h:126
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb)
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function

◆ subElementRect()

QRect QWindowsVistaStyle::subElementRect ( SubElement  element,
const QStyleOption option,
const QWidget widget 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 1986 of file qwindowsvistastyle.cpp.

Referenced by drawControl(), and drawPrimitive().

1987 {
1989  return QWindowsStyle::subElementRect(element, option, widget);
1990 
1991  QRect rect = QWindowsXPStyle::subElementRect(element, option, widget);
1992  switch (element) {
1993 
1994  case SE_PushButtonContents:
1995  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1996  MARGINS borderSize;
1997  HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
1998  if (theme) {
1999  int stateId = PBS_NORMAL;
2000  if (!(option->state & State_Enabled))
2001  stateId = PBS_DISABLED;
2002  else if (option->state & State_Sunken)
2003  stateId = PBS_PRESSED;
2004  else if (option->state & State_MouseOver)
2005  stateId = PBS_HOT;
2006  else if (btn->features & QStyleOptionButton::DefaultButton)
2007  stateId = PBS_DEFAULTED;
2008 
2009  int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
2010  rect = option->rect.adjusted(border, border, -border, -border);
2011 
2012  int result = pGetThemeMargins(theme,
2013  NULL,
2014  BP_PUSHBUTTON,
2015  stateId,
2017  NULL,
2018  &borderSize);
2019 
2020  if (result == S_OK) {
2021  rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
2022  -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
2023  rect = visualRect(option->direction, option->rect, rect);
2024  }
2025  }
2026  }
2027  break;
2028 
2029  case SE_HeaderArrow:
2030  {
2031  QRect r = rect;
2032  int h = option->rect.height();
2033  int w = option->rect.width();
2034  int x = option->rect.x();
2035  int y = option->rect.y();
2036  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
2037 
2038  XPThemeData theme(widget, 0, QLatin1String("HEADER"), HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
2039 
2040  int arrowWidth = 13;
2041  int arrowHeight = 5;
2042  if (theme.isValid()) {
2043  SIZE size;
2044  if (pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size) == S_OK) {
2045  arrowWidth = size.cx;
2046  arrowHeight = size.cy;
2047  }
2048  }
2049  if (option->state & State_Horizontal) {
2050  r.setRect(x + w/2 - arrowWidth/2, y , arrowWidth, arrowHeight);
2051  } else {
2052  int vert_size = w / 2;
2053  r.setRect(x + 5, y + h - margin * 2 - vert_size,
2054  w - margin * 2 - 5, vert_size);
2055  }
2056  rect = visualRect(option->direction, option->rect, r);
2057  }
2058  break;
2059 
2060  case SE_HeaderLabel:
2061  {
2062  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
2063  QRect r = option->rect;
2064  r.setRect(option->rect.x() + margin, option->rect.y() + margin,
2065  option->rect.width() - margin * 2, option->rect.height() - margin * 2);
2066  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2067  // Subtract width needed for arrow, if there is one
2068  if (header->sortIndicator != QStyleOptionHeader::None) {
2069  if (!(option->state & State_Horizontal)) //horizontal arrows are positioned on top
2070  r.setHeight(r.height() - (option->rect.width() / 2) - (margin * 2));
2071  }
2072  }
2073  rect = visualRect(option->direction, option->rect, r);
2074  }
2075  break;
2077  rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget);
2078  break;
2080  if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))
2081  rect.adjust(-2, 0, 2, 0);
2082  break;
2084  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
2085  QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, option, widget);
2086  QRect displayRect = subElementRect(QStyle::SE_ItemViewItemDecoration, option, widget);
2087  if (!vopt->icon.isNull())
2088  rect = textRect.united(displayRect);
2089  else
2090  rect = textRect;
2091  rect = rect.adjusted(1, 0, -1, 0);
2092  }
2093  break;
2094  default:
2095  break;
2096  }
2097  return rect;
2098 }
QRect subElementRect(SubElement r, const QStyleOption *option, const QWidget *widget=0) const
Reimplemented Function
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
static PtrOpenThemeData pOpenThemeData
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define SIZE(large, small, mini)
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static HWND winId(const QWidget *widget)
This function will always return a valid window handle, and might create a limbo widget to do so...
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
static PtrGetThemeMargins pGetThemeMargins
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
static PtrGetThemePartSize pGetThemePartSize
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define TMT_CONTENTMARGINS

◆ unpolish() [1/2]

void QWindowsVistaStyle::unpolish ( QWidget widget)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2431 of file qwindowsvistastyle.cpp.

2432 {
2433  QWindowsXPStyle::unpolish(widget);
2434 
2435  QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
2436  d->stopAnimation(widget);
2437 
2438 #ifndef QT_NO_LINEEDIT
2439  if (qobject_cast<QLineEdit*>(widget))
2440  widget->setAttribute(Qt::WA_Hover, false);
2441  else
2442 #endif // QT_NO_LINEEDIT
2443  if (qobject_cast<QGroupBox*>(widget))
2444  widget->setAttribute(Qt::WA_Hover, false);
2445  else if (qobject_cast<QMessageBox *> (widget)) {
2446  widget->setAttribute(Qt::WA_StyledBackground, false);
2447  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
2448  if (buttonBox)
2449  buttonBox->setContentsMargins(0, 0, 0, 0);
2450  }
2451 #ifndef QT_NO_INPUTDIALOG
2452  else if (qobject_cast<QInputDialog *> (widget)) {
2453  widget->setAttribute(Qt::WA_StyledBackground, false);
2454  QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
2455  if (buttonBox)
2456  buttonBox->setContentsMargins(0, 0, 0, 0);
2457  }
2458 #endif // QT_NO_INPUTDIALOG
2459  else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
2460  tree->viewport()->setAttribute(Qt::WA_Hover, false);
2461  } else if (qobject_cast<QCommandLinkButton*>(widget)) {
2462  QFont font = QApplication::font("QCommandLinkButton");
2463  QFont widgetFont = widget->font();
2464  widgetFont.setFamily(font.family()); //Only family set by polish
2465  widget->setFont(widgetFont);
2466  }
2467 }
double d
Definition: qnumeric_p.h:62
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
QFont font
the font currently set for the widget
Definition: qwidget.h:181
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void stopAnimation(const QWidget *)
static QFont font()
Returns the default application font.
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
void unpolish(QApplication *)
Reimplemented Function
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ unpolish() [2/2]

void QWindowsVistaStyle::unpolish ( QApplication app)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QWindowsStyle.

Definition at line 2473 of file qwindowsvistastyle.cpp.

2474 {
2476 }
void unpolish(QApplication *)
Reimplemented Function

Friends and Related Functions

◆ QStyleFactory

friend class QStyleFactory
friend

Definition at line 100 of file qwindowsvistastyle.h.


The documentation for this class was generated from the following files: