Qt 4.8
Public Functions | Protected Slots | Protected Functions | Properties | List of all members
QWindowsStyle Class Reference

The QWindowsStyle class provides a Microsoft Windows-like look and feel. More...

#include <qwindowsstyle.h>

Inheritance diagram for QWindowsStyle:
QCommonStyle QStyle QObject QCleanlooksStyle QMacStyle QPlastiqueStyle QStyleSheetStyle QWindowsCEStyle QWindowsMobileStyle QWindowsXPStyle QGtkStyle QWindowsVistaStyle

Public Functions

void drawComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
 Reimplemented Function More...
 
void drawControl (ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
 Reimplemented Function More...
 
void drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=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...
 
 QWindowsStyle ()
 Constructs a QWindowsStyle object. More...
 
QSize sizeFromContents (ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
 Reimplemented Function More...
 
QPixmap standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
 Reimplemented Function More...
 
int styleHint (StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
 Reimplemented Function More...
 
QRect subElementRect (SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
 Reimplemented Function More...
 
void unpolish (QApplication *)
 Reimplemented Function More...
 
void unpolish (QWidget *)
 Reimplemented Function 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...
 
SubControl hitTestComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
 Reimplemented Function More...
 
 QCommonStyle ()
 Constructs a QCommonStyle. More...
 
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
 Reimplemented Function 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 QPalette standardPalette () const
 Returns the style's standard palette. 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...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. 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 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...
 

Protected Functions

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
 

Properties

void * reserved
 

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 Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QWindowsStyle class provides a Microsoft Windows-like look and feel.

This style is Qt's default GUI style on Windows.

qwindowsstyle.png
See also
QWindowsXPStyle, QMacStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle

Definition at line 57 of file qwindowsstyle.h.

Constructors and Destructors

◆ QWindowsStyle() [1/2]

QWindowsStyle::QWindowsStyle ( )

Constructs a QWindowsStyle object.

Definition at line 279 of file qwindowsstyle.cpp.

280 {
281 }
QCommonStyle()
Constructs a QCommonStyle.

◆ ~QWindowsStyle()

QWindowsStyle::~QWindowsStyle ( )

Destroys the QWindowsStyle object.

Definition at line 297 of file qwindowsstyle.cpp.

298 {
299 }

◆ QWindowsStyle() [2/2]

QWindowsStyle::QWindowsStyle ( QWindowsStylePrivate dd)
protected

Constructs a QWindowsStyle object.

Warning
This function is not part of the public interface.

Definition at line 291 of file qwindowsstyle.cpp.

291  : QCommonStyle(dd)
292 {
293 }
QCommonStyle()
Constructs a QCommonStyle.

Functions

◆ drawComplexControl()

void QWindowsStyle::drawComplexControl ( ComplexControl  cc,
const QStyleOptionComplex opt,
QPainter p,
const QWidget w = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 2628 of file qwindowsstyle.cpp.

Referenced by QWindowsVistaStyle::drawComplexControl(), QWindowsCEStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QWindowsMobileStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QStyleSheetStyle::drawComplexControl(), and QMacStyle::drawComplexControl().

2630 {
2631  switch (cc) {
2632 #ifndef QT_NO_SLIDER
2633  case CC_Slider:
2634  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2635  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2636  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
2637  int ticks = slider->tickPosition;
2638  QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
2639  QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
2640 
2641  if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
2642  int mid = thickness / 2;
2643 
2644  if (ticks & QSlider::TicksAbove)
2645  mid += len / 8;
2646  if (ticks & QSlider::TicksBelow)
2647  mid -= len / 8;
2648 
2649  p->setPen(slider->palette.shadow().color());
2650  if (slider->orientation == Qt::Horizontal) {
2651  qDrawWinPanel(p, groove.x(), groove.y() + mid - 2,
2652  groove.width(), 4, slider->palette, true);
2653  p->drawLine(groove.x() + 1, groove.y() + mid - 1,
2654  groove.x() + groove.width() - 3, groove.y() + mid - 1);
2655  } else {
2656  qDrawWinPanel(p, groove.x() + mid - 2, groove.y(),
2657  4, groove.height(), slider->palette, true);
2658  p->drawLine(groove.x() + mid - 1, groove.y() + 1,
2659  groove.x() + mid - 1, groove.y() + groove.height() - 3);
2660  }
2661  }
2662 
2663  if (slider->subControls & SC_SliderTickmarks) {
2664  QStyleOptionSlider tmpSlider = *slider;
2665  tmpSlider.subControls = SC_SliderTickmarks;
2666  QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
2667  }
2668 
2669  if (slider->subControls & SC_SliderHandle) {
2670  // 4444440
2671  // 4333310
2672  // 4322210
2673  // 4322210
2674  // 4322210
2675  // 4322210
2676  // *43210*
2677  // **410**
2678  // ***0***
2679  const QColor c0 = slider->palette.shadow().color();
2680  const QColor c1 = slider->palette.dark().color();
2681  // const QColor c2 = g.button();
2682  const QColor c3 = slider->palette.midlight().color();
2683  const QColor c4 = slider->palette.light().color();
2684  QBrush handleBrush;
2685 
2686  if (slider->state & State_Enabled) {
2687  handleBrush = slider->palette.color(QPalette::Button);
2688  } else {
2689  handleBrush = QBrush(slider->palette.color(QPalette::Button),
2691  }
2692 
2693 
2694  int x = handle.x(), y = handle.y(),
2695  wi = handle.width(), he = handle.height();
2696 
2697  int x1 = x;
2698  int x2 = x+wi-1;
2699  int y1 = y;
2700  int y2 = y+he-1;
2701 
2702  Qt::Orientation orient = slider->orientation;
2703  bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
2704  bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
2705 
2706  if (slider->state & State_HasFocus) {
2707  QStyleOptionFocusRect fropt;
2708  fropt.QStyleOption::operator=(*slider);
2709  fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
2710  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
2711  }
2712 
2713  if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
2714  Qt::BGMode oldMode = p->backgroundMode();
2716  qDrawWinButton(p, QRect(x, y, wi, he), slider->palette, false,
2717  &handleBrush);
2718  p->setBackgroundMode(oldMode);
2719  return;
2720  }
2721 
2722  QSliderDirection dir;
2723 
2724  if (orient == Qt::Horizontal)
2725  if (tickAbove)
2726  dir = SlUp;
2727  else
2728  dir = SlDown;
2729  else
2730  if (tickAbove)
2731  dir = SlLeft;
2732  else
2733  dir = SlRight;
2734 
2735  QPolygon a;
2736 
2737  int d = 0;
2738  switch (dir) {
2739  case SlUp:
2740  y1 = y1 + wi/2;
2741  d = (wi + 1) / 2 - 1;
2742  a.setPoints(5, x1,y1, x1,y2, x2,y2, x2,y1, x1+d,y1-d);
2743  break;
2744  case SlDown:
2745  y2 = y2 - wi/2;
2746  d = (wi + 1) / 2 - 1;
2747  a.setPoints(5, x1,y1, x1,y2, x1+d,y2+d, x2,y2, x2,y1);
2748  break;
2749  case SlLeft:
2750  d = (he + 1) / 2 - 1;
2751  x1 = x1 + he/2;
2752  a.setPoints(5, x1,y1, x1-d,y1+d, x1,y2, x2,y2, x2,y1);
2753  break;
2754  case SlRight:
2755  d = (he + 1) / 2 - 1;
2756  x2 = x2 - he/2;
2757  a.setPoints(5, x1,y1, x1,y2, x2,y2, x2+d,y1+d, x2,y1);
2758  break;
2759  }
2760 
2761  QBrush oldBrush = p->brush();
2762  p->setPen(Qt::NoPen);
2763  p->setBrush(handleBrush);
2764  Qt::BGMode oldMode = p->backgroundMode();
2766  p->drawRect(x1, y1, x2-x1+1, y2-y1+1);
2767  p->drawPolygon(a);
2768  p->setBrush(oldBrush);
2769  p->setBackgroundMode(oldMode);
2770 
2771  if (dir != SlUp) {
2772  p->setPen(c4);
2773  p->drawLine(x1, y1, x2, y1);
2774  p->setPen(c3);
2775  p->drawLine(x1, y1+1, x2, y1+1);
2776  }
2777  if (dir != SlLeft) {
2778  p->setPen(c3);
2779  p->drawLine(x1+1, y1+1, x1+1, y2);
2780  p->setPen(c4);
2781  p->drawLine(x1, y1, x1, y2);
2782  }
2783  if (dir != SlRight) {
2784  p->setPen(c0);
2785  p->drawLine(x2, y1, x2, y2);
2786  p->setPen(c1);
2787  p->drawLine(x2-1, y1+1, x2-1, y2-1);
2788  }
2789  if (dir != SlDown) {
2790  p->setPen(c0);
2791  p->drawLine(x1, y2, x2, y2);
2792  p->setPen(c1);
2793  p->drawLine(x1+1, y2-1, x2-1, y2-1);
2794  }
2795 
2796  switch (dir) {
2797  case SlUp:
2798  p->setPen(c4);
2799  p->drawLine(x1, y1, x1+d, y1-d);
2800  p->setPen(c0);
2801  d = wi - d - 1;
2802  p->drawLine(x2, y1, x2-d, y1-d);
2803  d--;
2804  p->setPen(c3);
2805  p->drawLine(x1+1, y1, x1+1+d, y1-d);
2806  p->setPen(c1);
2807  p->drawLine(x2-1, y1, x2-1-d, y1-d);
2808  break;
2809  case SlDown:
2810  p->setPen(c4);
2811  p->drawLine(x1, y2, x1+d, y2+d);
2812  p->setPen(c0);
2813  d = wi - d - 1;
2814  p->drawLine(x2, y2, x2-d, y2+d);
2815  d--;
2816  p->setPen(c3);
2817  p->drawLine(x1+1, y2, x1+1+d, y2+d);
2818  p->setPen(c1);
2819  p->drawLine(x2-1, y2, x2-1-d, y2+d);
2820  break;
2821  case SlLeft:
2822  p->setPen(c4);
2823  p->drawLine(x1, y1, x1-d, y1+d);
2824  p->setPen(c0);
2825  d = he - d - 1;
2826  p->drawLine(x1, y2, x1-d, y2-d);
2827  d--;
2828  p->setPen(c3);
2829  p->drawLine(x1, y1+1, x1-d, y1+1+d);
2830  p->setPen(c1);
2831  p->drawLine(x1, y2-1, x1-d, y2-1-d);
2832  break;
2833  case SlRight:
2834  p->setPen(c4);
2835  p->drawLine(x2, y1, x2+d, y1+d);
2836  p->setPen(c0);
2837  d = he - d - 1;
2838  p->drawLine(x2, y2, x2+d, y2-d);
2839  d--;
2840  p->setPen(c3);
2841  p->drawLine(x2, y1+1, x2+d, y1+1+d);
2842  p->setPen(c1);
2843  p->drawLine(x2, y2-1, x2+d, y2-1-d);
2844  break;
2845  }
2846  }
2847  }
2848  break;
2849 #endif // QT_NO_SLIDER
2850 #ifndef QT_NO_SCROLLBAR
2851  case CC_ScrollBar:
2852  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2853  QStyleOptionSlider newScrollbar = *scrollbar;
2854  if (scrollbar->minimum == scrollbar->maximum)
2855  newScrollbar.state &= ~State_Enabled; //do not draw the slider.
2856  QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
2857  }
2858  break;
2859 #endif // QT_NO_SCROLLBAR
2860 #ifdef QT3_SUPPORT
2861  case CC_Q3ListView:
2862  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
2863  int i;
2864  if (lv->subControls & SC_Q3ListView)
2866  if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
2867  if (lv->items.isEmpty())
2868  break;
2869  QStyleOptionQ3ListViewItem item = lv->items.at(0);
2870  int y = lv->rect.y();
2871  int c;
2872  int dotoffset = 0;
2873  QPolygon dotlines;
2874  if ((lv->activeSubControls & SC_All) && (lv->subControls & SC_Q3ListViewExpand)) {
2875  c = 2;
2876  dotlines.resize(2);
2877  dotlines[0] = QPoint(lv->rect.right(), lv->rect.top());
2878  dotlines[1] = QPoint(lv->rect.right(), lv->rect.bottom());
2879  } else {
2880  int linetop = 0, linebot = 0;
2881  // each branch needs at most two lines, ie. four end points
2882  dotoffset = (item.itemY + item.height - y) % 2;
2883  dotlines.resize(item.childCount * 4);
2884  c = 0;
2885 
2886  // skip the stuff above the exposed rectangle
2887  for (i = 1; i < lv->items.size(); ++i) {
2888  QStyleOptionQ3ListViewItem child = lv->items.at(i);
2889  if (child.height + y > 0)
2890  break;
2891  y += child.totalHeight;
2892  }
2893  int bx = lv->rect.width() / 2;
2894 
2895  // paint stuff in the magical area
2896  while (i < lv->items.size() && y < lv->rect.height()) {
2897  QStyleOptionQ3ListViewItem child = lv->items.at(i);
2899  int lh;
2901  lh = child.height;
2902  else
2903  lh = p->fontMetrics().height() + 2 * lv->itemMargin;
2904  lh = qMax(lh, QApplication::globalStrut().height());
2905  if (lh % 2 > 0)
2906  ++lh;
2907  linebot = y + lh / 2;
2909  || (child.childCount > 0 && child.height > 0)) {
2910  // needs a box
2911  p->setPen(lv->palette.mid().color());
2912  p->drawRect(bx - 4, linebot - 4, 8, 8);
2913  // plus or minus
2914  p->setPen(lv->palette.text().color());
2915  p->drawLine(bx - 2, linebot, bx + 2, linebot);
2916  if (!(child.state & State_Open))
2917  p->drawLine(bx, linebot - 2, bx, linebot + 2);
2918  // dotlinery
2919  p->setPen(lv->palette.mid().color());
2920  dotlines[c++] = QPoint(bx, linetop);
2921  dotlines[c++] = QPoint(bx, linebot - 4);
2922  dotlines[c++] = QPoint(bx + 5, linebot);
2923  dotlines[c++] = QPoint(lv->rect.width(), linebot);
2924  linetop = linebot + 5;
2925  } else {
2926  // just dotlinery
2927  dotlines[c++] = QPoint(bx+1, linebot -1);
2928  dotlines[c++] = QPoint(lv->rect.width(), linebot -1);
2929  }
2930  y += child.totalHeight;
2931  }
2932  ++i;
2933  }
2934 
2935  // Expand line height to edge of rectangle if there's any
2936  // visible child below
2937  while (i < lv->items.size() && lv->items.at(i).height <= 0)
2938  ++i;
2939  if (i < lv->items.size())
2940  linebot = lv->rect.height();
2941 
2942  if (linetop < linebot) {
2943  dotlines[c++] = QPoint(bx, linetop);
2944  dotlines[c++] = QPoint(bx, linebot);
2945  }
2946  }
2947  p->setPen(lv->palette.text().color());
2948  QBitmap *verticalLine = globalVerticalLine();
2949  QBitmap *horizontalLine = globalHorizontalLine();
2950  static bool isInit = false;
2951  if (!isInit) {
2952  isInit = true;
2953  // make 128*1 and 1*128 bitmaps that can be used for
2954  // drawing the right sort of lines.
2955  verticalLine->clear();
2956  horizontalLine->clear();
2957  QPolygon a(64);
2958  QPainter p;
2959  p.begin(verticalLine);
2960  for(i = 0; i < 64; ++i)
2961  a.setPoint(i, 0, i * 2 + 1);
2962  p.setPen(Qt::color1);
2963  p.drawPoints(a);
2964  p.end();
2966  verticalLine->setMask(*verticalLine);
2967  p.begin(horizontalLine);
2968  for(i = 0; i < 64; ++i)
2969  a.setPoint(i, i * 2 + 1, 0);
2970  p.setPen(Qt::color1);
2971  p.drawPoints(a);
2972  p.end();
2974  horizontalLine->setMask(*horizontalLine);
2975  }
2976 
2977  int line; // index into dotlines
2978  if (lv->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
2979  // assumptions here: lines are horizontal or vertical.
2980  // lines always start with the numerically lowest
2981  // coordinate.
2982 
2983  // point ... relevant coordinate of current point
2984  // end ..... same coordinate of the end of the current line
2985  // other ... the other coordinate of the current point/line
2986  if (dotlines[line].y() == dotlines[line+1].y()) {
2987  int end = dotlines[line + 1].x();
2988  int point = dotlines[line].x();
2989  int other = dotlines[line].y();
2990  while (point < end) {
2991  int i = 128;
2992  if (i + point > end)
2993  i = end-point;
2994  p->drawPixmap(point, other, *horizontalLine, 0, 0, i, 1);
2995  point += i;
2996  }
2997  } else {
2998  int end = dotlines[line + 1].y();
2999  int point = dotlines[line].y();
3000  int other = dotlines[line].x();
3001  int pixmapoffset = ((point & 1) != dotoffset) ? 1 : 0;
3002  while(point < end) {
3003  int i = 128;
3004  if (i + point > end)
3005  i = end-point;
3006  p->drawPixmap(other, point, *verticalLine, 0, pixmapoffset, 1, i);
3007  point += i;
3008  }
3009  }
3010  }
3011  }
3012  }
3013  break;
3014 #endif // QT3_SUPPORT
3015 #ifndef QT_NO_COMBOBOX
3016  case CC_ComboBox:
3017  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
3018  QBrush editBrush = cmb->palette.brush(QPalette::Base);
3019  if ((cmb->subControls & SC_ComboBoxFrame)) {
3020  if (cmb->frame) {
3021  QPalette shadePal = opt->palette;
3022  shadePal.setColor(QPalette::Midlight, shadePal.button().color());
3023  qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush);
3024  }
3025  else {
3026  p->fillRect(opt->rect, editBrush);
3027  }
3028  }
3029  if (cmb->subControls & SC_ComboBoxArrow) {
3030  State flags = State_None;
3031 
3033  bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow
3034  && cmb->state & State_Sunken;
3035  if (sunkenArrow) {
3036  p->setPen(cmb->palette.dark().color());
3037  p->setBrush(cmb->palette.brush(QPalette::Button));
3038  p->drawRect(ar.adjusted(0,0,-1,-1));
3039  } else {
3040  // Make qDrawWinButton use the right colors for drawing the shade of the button
3041  QPalette pal(cmb->palette);
3042  pal.setColor(QPalette::Button, cmb->palette.light().color());
3043  pal.setColor(QPalette::Light, cmb->palette.button().color());
3044  qDrawWinButton(p, ar, pal, false,
3045  &cmb->palette.brush(QPalette::Button));
3046  }
3047 
3048  ar.adjust(2, 2, -2, -2);
3049  if (opt->state & State_Enabled)
3050  flags |= State_Enabled;
3051  if (opt->state & State_HasFocus)
3052  flags |= State_HasFocus;
3053 
3054  if (sunkenArrow)
3055  flags |= State_Sunken;
3056  QStyleOption arrowOpt(0);
3057  arrowOpt.rect = ar.adjusted(1, 1, -1, -1);
3058  arrowOpt.palette = cmb->palette;
3059  arrowOpt.state = flags;
3060  proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
3061  }
3062 
3063  if (cmb->subControls & SC_ComboBoxEditField) {
3065  if (cmb->state & State_HasFocus && !cmb->editable)
3066  p->fillRect(re.x(), re.y(), re.width(), re.height(),
3067  cmb->palette.brush(QPalette::Highlight));
3068 
3069  if (cmb->state & State_HasFocus) {
3070  p->setPen(cmb->palette.highlightedText().color());
3071  p->setBackground(cmb->palette.highlight());
3072 
3073  } else {
3074  p->setPen(cmb->palette.text().color());
3075  p->setBackground(cmb->palette.background());
3076  }
3077 
3078  if (cmb->state & State_HasFocus && !cmb->editable) {
3079  QStyleOptionFocusRect focus;
3080  focus.QStyleOption::operator=(*cmb);
3082  focus.state |= State_FocusAtBorder;
3083  focus.backgroundColor = cmb->palette.highlight().color();
3084  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
3085  }
3086  }
3087  }
3088  break;
3089 #endif // QT_NO_COMBOBOX
3090 #ifndef QT_NO_SPINBOX
3091  case CC_SpinBox:
3092  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3093  QStyleOptionSpinBox copy = *sb;
3094  PrimitiveElement pe;
3095  bool enabled = opt->state & State_Enabled;
3096  if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3097  QBrush editBrush = sb->palette.brush(QPalette::Base);
3099  QPalette shadePal = sb->palette;
3100  shadePal.setColor(QPalette::Midlight, shadePal.button().color());
3101  qDrawWinPanel(p, r, shadePal, true, &editBrush);
3102  }
3103 
3104  QPalette shadePal(opt->palette);
3105  shadePal.setColor(QPalette::Button, opt->palette.light().color());
3106  shadePal.setColor(QPalette::Light, opt->palette.button().color());
3107 
3108  if (sb->subControls & SC_SpinBoxUp) {
3109  copy.subControls = SC_SpinBoxUp;
3110  QPalette pal2 = sb->palette;
3111  if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
3113  copy.state &= ~State_Enabled;
3114  }
3115 
3116  copy.palette = pal2;
3117 
3118  if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3119  copy.state |= State_On;
3120  copy.state |= State_Sunken;
3121  } else {
3122  copy.state |= State_Raised;
3123  copy.state &= ~State_Sunken;
3124  }
3125  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3126  : PE_IndicatorSpinUp);
3127 
3129  qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
3130  &copy.palette.brush(QPalette::Button));
3131  copy.rect.adjust(4, 1, -5, -1);
3132  if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled))
3133  && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
3134  {
3135  QStyleOptionSpinBox lightCopy = copy;
3136  lightCopy.rect.adjust(1, 1, 1, 1);
3137  lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
3138  proxy()->drawPrimitive(pe, &lightCopy, p, widget);
3139  }
3140  proxy()->drawPrimitive(pe, &copy, p, widget);
3141  }
3142 
3143  if (sb->subControls & SC_SpinBoxDown) {
3144  copy.subControls = SC_SpinBoxDown;
3145  copy.state = sb->state;
3146  QPalette pal2 = sb->palette;
3147  if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
3149  copy.state &= ~State_Enabled;
3150  }
3151  copy.palette = pal2;
3152 
3153  if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3154  copy.state |= State_On;
3155  copy.state |= State_Sunken;
3156  } else {
3157  copy.state |= State_Raised;
3158  copy.state &= ~State_Sunken;
3159  }
3160  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3162 
3164  qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
3165  &copy.palette.brush(QPalette::Button));
3166  copy.rect.adjust(4, 0, -5, -1);
3167  if ((!enabled || !(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled))
3168  && proxy()->styleHint(SH_EtchDisabledText, opt, widget) )
3169  {
3170  QStyleOptionSpinBox lightCopy = copy;
3171  lightCopy.rect.adjust(1, 1, 1, 1);
3172  lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light());
3173  proxy()->drawPrimitive(pe, &lightCopy, p, widget);
3174  }
3175  proxy()->drawPrimitive(pe, &copy, p, widget);
3176  }
3177  }
3178  break;
3179 #endif // QT_NO_SPINBOX
3180 
3181  default:
3183  }
3184 }
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
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
int height
the height of the item
Definition: qstyleoption.h:474
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
unsigned char c[8]
Definition: qnumeric_p.h:62
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen&#39;s color.
Definition: qpainter.cpp:3816
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
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...
void setMask(const QBitmap &)
Sets a mask bitmap.
Definition: qpixmap.cpp:822
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int childCount
the number of children the item has
Definition: qstyleoption.h:477
QSliderDirection
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
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
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false...
Definition: qpainter.cpp:1723
QColor backgroundColor
the background color on which the focus rectangle is being drawn
Definition: qstyleoption.h:109
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
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
int totalHeight
the total height of the item, including its children
Definition: qstyleoption.h:475
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
QColor dark(int f=200) const
Use darker(factor) instead.
Definition: qcolor.cpp:2447
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...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:435
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
The State element defines configurations of objects and properties.
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
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
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
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
Qt::BGMode backgroundMode() const
Returns the current background mode.
Definition: qpainter.cpp:4026
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Definition: qpolygon.h:120
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
void clear()
Clears the bitmap, setting all its bits to Qt::color0.
Definition: qbitmap.h:69
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 itemY
the Y-coordinate for the item
Definition: qstyleoption.h:476
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
int height() const
Returns the height of the font.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
static const KeyPair *const end
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
Orientation
Definition: qnamespace.h:174
BGMode
Definition: qnamespace.h:588
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
#define enabled
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
bool end()
Ends painting.
Definition: qpainter.cpp:1929
static void flush()
Flushes the platform specific event queues.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
QColor light(int f=150) const
Use lighter(factor) instead.
Definition: qcolor.cpp:2391
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawControl()

void QWindowsStyle::drawControl ( ControlElement  element,
const QStyleOption opt,
QPainter p,
const QWidget w = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 1816 of file qwindowsstyle.cpp.

Referenced by QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QWindowsMobileStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QMacStyle::drawControl(), and QStyleSheetStyle::drawControl().

1818 {
1819  switch (ce) {
1820 #ifndef QT_NO_RUBBERBAND
1821  case CE_RubberBand:
1822  if (qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1823  // ### workaround for slow general painter path
1824  QPixmap tiledPixmap(16, 16);
1825  QPainter pixmapPainter(&tiledPixmap);
1826  pixmapPainter.setPen(Qt::NoPen);
1827  pixmapPainter.setBrush(Qt::Dense4Pattern);
1828  pixmapPainter.setBackground(Qt::white);
1829  pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1830  pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1831  pixmapPainter.end();
1832  tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1833  p->save();
1834  QRect r = opt->rect;
1835  QStyleHintReturnMask mask;
1836  if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1837  p->setClipRegion(mask.region);
1838  p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1839  p->restore();
1840  return;
1841  }
1842  break;
1843 #endif // QT_NO_RUBBERBAND
1844 
1845 #if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
1846  case CE_MenuBarEmptyArea:
1847  if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
1848  p->fillRect(opt->rect, opt->palette.button());
1849  QPen oldPen = p->pen();
1850  p->setPen(QPen(opt->palette.dark().color()));
1851  p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
1852  p->setPen(oldPen);
1853  }
1854  break;
1855 #endif
1856 #ifndef QT_NO_MENU
1857  case CE_MenuItem:
1858  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1859  int x, y, w, h;
1860  menuitem->rect.getRect(&x, &y, &w, &h);
1861  int tab = menuitem->tabWidth;
1862  bool dis = !(menuitem->state & State_Enabled);
1863  bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
1864  ? menuitem->checked : false;
1865  bool act = menuitem->state & State_Selected;
1866 
1867  // windows always has a check column, regardless whether we have an icon or not
1868  int checkcol = qMax<int>(menuitem->maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
1869 
1870  QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
1871  p->fillRect(menuitem->rect.adjusted(0, 0, -1, 0), fill);
1872 
1873  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
1874  int yoff = y-1 + h / 2;
1875  p->setPen(menuitem->palette.dark().color());
1876  p->drawLine(x + 2, yoff, x + w - 4, yoff);
1877  p->setPen(menuitem->palette.light().color());
1878  p->drawLine(x + 2, yoff + 1, x + w - 4, yoff + 1);
1879  return;
1880  }
1881 
1882  QRect vCheckRect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x(), menuitem->rect.y(), checkcol, menuitem->rect.height()));
1883  if (!menuitem->icon.isNull() && checked) {
1884  if (act) {
1885  qDrawShadePanel(p, vCheckRect,
1886  menuitem->palette, true, 1,
1887  &menuitem->palette.brush(QPalette::Button));
1888  } else {
1889  QBrush fill(menuitem->palette.light().color(), Qt::Dense4Pattern);
1890  qDrawShadePanel(p, vCheckRect, menuitem->palette, true, 1, &fill);
1891  }
1892  } else if (!act) {
1893  p->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
1894  }
1895 
1896  // On Windows Style, if we have a checkable item and an icon we
1897  // draw the icon recessed to indicate an item is checked. If we
1898  // have no icon, we draw a checkmark instead.
1899  if (!menuitem->icon.isNull()) {
1900  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
1901  if (act && !dis)
1902  mode = QIcon::Active;
1903  QPixmap pixmap;
1904  if (checked)
1905  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1906  else
1907  pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode);
1908  int pixw = pixmap.width();
1909  int pixh = pixmap.height();
1910  if (act && !dis && !checked)
1911  qDrawShadePanel(p, vCheckRect, menuitem->palette, false, 1,
1912  &menuitem->palette.brush(QPalette::Button));
1913  QRect pmr(0, 0, pixw, pixh);
1914  pmr.moveCenter(vCheckRect.center());
1915  p->setPen(menuitem->palette.text().color());
1916  p->drawPixmap(pmr.topLeft(), pixmap);
1917  } else if (checked) {
1918  QStyleOptionMenuItem newMi = *menuitem;
1919  newMi.state = State_None;
1920  if (!dis)
1921  newMi.state |= State_Enabled;
1922  if (act)
1923  newMi.state |= State_On;
1924  newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + QWindowsStylePrivate::windowsItemFrame,
1925  menuitem->rect.y() + QWindowsStylePrivate::windowsItemFrame,
1927  menuitem->rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
1929  }
1930  p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
1931 
1932  QColor discol;
1933  if (dis) {
1934  discol = menuitem->palette.text().color();
1935  p->setPen(discol);
1936  }
1937 
1938  int xm = int(QWindowsStylePrivate::windowsItemFrame) + checkcol + int(QWindowsStylePrivate::windowsItemHMargin);
1939  int xpos = menuitem->rect.x() + xm;
1942  QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1943  QString s = menuitem->text;
1944  if (!s.isEmpty()) { // draw text
1945  p->save();
1946  int t = s.indexOf(QLatin1Char('\t'));
1948  if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1949  text_flags |= Qt::TextHideMnemonic;
1950  text_flags |= Qt::AlignLeft;
1951  if (t >= 0) {
1952  QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1953  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
1954  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1955  p->setPen(menuitem->palette.light().color());
1956  p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
1957  p->setPen(discol);
1958  }
1959  p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
1960  s = s.left(t);
1961  }
1962  QFont font = menuitem->font;
1963  if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
1964  font.setBold(true);
1965  p->setFont(font);
1966  if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) {
1967  p->setPen(menuitem->palette.light().color());
1968  p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
1969  p->setPen(discol);
1970  }
1971  p->drawText(vTextRect, text_flags, s.left(t));
1972  p->restore();
1973  }
1974  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1975  int dim = (h - 2 * QWindowsStylePrivate::windowsItemFrame) / 2;
1976  PrimitiveElement arrow;
1978  xpos = x + w - QWindowsStylePrivate::windowsArrowHMargin - QWindowsStylePrivate::windowsItemFrame - dim;
1979  QRect vSubMenuRect = visualRect(opt->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
1980  QStyleOptionMenuItem newMI = *menuitem;
1981  newMI.rect = vSubMenuRect;
1982  newMI.state = dis ? State_None : State_Enabled;
1983  if (act)
1985  newMI.palette.highlightedText().color());
1986  proxy()->drawPrimitive(arrow, &newMI, p, widget);
1987  }
1988 
1989  }
1990  break;
1991 #endif // QT_NO_MENU
1992 #ifndef QT_NO_MENUBAR
1993  case CE_MenuBarItem:
1994  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1995  bool active = mbi->state & State_Selected;
1996  bool hasFocus = mbi->state & State_HasFocus;
1997  bool down = mbi->state & State_Sunken;
1998  QStyleOptionMenuItem newMbi = *mbi;
1999  p->fillRect(mbi->rect, mbi->palette.brush(QPalette::Button));
2000  if (active || hasFocus) {
2001  QBrush b = mbi->palette.brush(QPalette::Button);
2002  if (active && down)
2003  p->setBrushOrigin(p->brushOrigin() + QPoint(1, 1));
2004  if (active && hasFocus)
2005  qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(),
2006  mbi->rect.height(), mbi->palette, active && down, 1, 0, &b);
2007  if (active && down) {
2010  p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1));
2011  }
2012  }
2013  QCommonStyle::drawControl(ce, &newMbi, p, widget);
2014  }
2015  break;
2016 #endif // QT_NO_MENUBAR
2017 #ifndef QT_NO_TABBAR
2018  case CE_TabBarTabShape:
2019  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2020  bool rtlHorTabs = (tab->direction == Qt::RightToLeft
2021  && (tab->shape == QTabBar::RoundedNorth
2022  || tab->shape == QTabBar::RoundedSouth));
2023  bool selected = tab->state & State_Selected;
2024  bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
2025  || (rtlHorTabs
2026  && tab->position == QStyleOptionTab::Beginning));
2027  bool firstTab = ((!rtlHorTabs
2028  && tab->position == QStyleOptionTab::Beginning)
2029  || (rtlHorTabs
2030  && tab->position == QStyleOptionTab::End));
2031  bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
2032  bool previousSelected =
2033  ((!rtlHorTabs
2034  && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
2035  || (rtlHorTabs
2036  && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
2037  bool nextSelected =
2038  ((!rtlHorTabs
2039  && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
2040  || (rtlHorTabs
2041  && tab->selectedPosition
2043  int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
2044  bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
2045  || (rtlHorTabs
2046  && tabBarAlignment == Qt::AlignRight);
2047 
2048  bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
2049  || (rtlHorTabs
2050  && tabBarAlignment == Qt::AlignLeft);
2051 
2052  QColor light = tab->palette.light().color();
2053  QColor dark = tab->palette.dark().color();
2054  QColor shadow = tab->palette.shadow().color();
2055  int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
2056  if (selected)
2057  borderThinkness /= 2;
2058  QRect r2(opt->rect);
2059  int x1 = r2.left();
2060  int x2 = r2.right();
2061  int y1 = r2.top();
2062  int y2 = r2.bottom();
2063  switch (tab->shape) {
2064  default:
2065  QCommonStyle::drawControl(ce, tab, p, widget);
2066  break;
2067  case QTabBar::RoundedNorth: {
2068  if (!selected) {
2069  y1 += 2;
2070  x1 += onlyOne || firstTab ? borderThinkness : 0;
2071  x2 -= onlyOne || lastTab ? borderThinkness : 0;
2072  }
2073 
2074  p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
2075 
2076  // Delete border
2077  if (selected) {
2078  p->fillRect(QRect(x1,y2-1,x2-x1,1), tab->palette.background());
2079  p->fillRect(QRect(x1,y2,x2-x1,1), tab->palette.background());
2080  }
2081  // Left
2082  if (firstTab || selected || onlyOne || !previousSelected) {
2083  p->setPen(light);
2084  p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
2085  p->drawPoint(x1 + 1, y1 + 1);
2086  }
2087  // Top
2088  {
2089  int beg = x1 + (previousSelected ? 0 : 2);
2090  int end = x2 - (nextSelected ? 0 : 2);
2091  p->setPen(light);
2092  p->drawLine(beg, y1, end, y1);
2093  }
2094  // Right
2095  if (lastTab || selected || onlyOne || !nextSelected) {
2096  p->setPen(shadow);
2097  p->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2098  p->drawPoint(x2 - 1, y1 + 1);
2099  p->setPen(dark);
2100  p->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2101  }
2102  break; }
2103  case QTabBar::RoundedSouth: {
2104  if (!selected) {
2105  y2 -= 2;
2106  x1 += firstTab ? borderThinkness : 0;
2107  x2 -= lastTab ? borderThinkness : 0;
2108  }
2109 
2110  p->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
2111 
2112  // Delete border
2113  if (selected) {
2114  p->fillRect(QRect(x1, y1 + 1, (x2 - 1)-x1, 1), tab->palette.background());
2115  p->fillRect(QRect(x1, y1, (x2 - 1)-x1, 1), tab->palette.background());
2116  }
2117  // Left
2118  if (firstTab || selected || onlyOne || !previousSelected) {
2119  p->setPen(light);
2120  p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
2121  p->drawPoint(x1 + 1, y2 - 1);
2122  }
2123  // Bottom
2124  {
2125  int beg = x1 + (previousSelected ? 0 : 2);
2126  int end = x2 - (nextSelected ? 0 : 2);
2127  p->setPen(shadow);
2128  p->drawLine(beg, y2, end, y2);
2129  p->setPen(dark);
2130  p->drawLine(beg, y2 - 1, end, y2 - 1);
2131  }
2132  // Right
2133  if (lastTab || selected || onlyOne || !nextSelected) {
2134  p->setPen(shadow);
2135  p->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2136  p->drawPoint(x2 - 1, y2 - 1);
2137  p->setPen(dark);
2138  p->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
2139  }
2140  break; }
2141  case QTabBar::RoundedWest: {
2142  if (!selected) {
2143  x1 += 2;
2144  y1 += firstTab ? borderThinkness : 0;
2145  y2 -= lastTab ? borderThinkness : 0;
2146  }
2147 
2148  p->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
2149 
2150  // Delete border
2151  if (selected) {
2152  p->fillRect(QRect(x2 - 1, y1, 1, y2-y1), tab->palette.background());
2153  p->fillRect(QRect(x2, y1, 1, y2-y1), tab->palette.background());
2154  }
2155  // Top
2156  if (firstTab || selected || onlyOne || !previousSelected) {
2157  p->setPen(light);
2158  p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
2159  p->drawPoint(x1 + 1, y1 + 1);
2160  }
2161  // Left
2162  {
2163  int beg = y1 + (previousSelected ? 0 : 2);
2164  int end = y2 - (nextSelected ? 0 : 2);
2165  p->setPen(light);
2166  p->drawLine(x1, beg, x1, end);
2167  }
2168  // Bottom
2169  if (lastTab || selected || onlyOne || !nextSelected) {
2170  p->setPen(shadow);
2171  p->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
2172  p->drawPoint(x1 + 2, y2 - 1);
2173  p->setPen(dark);
2174  p->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
2175  p->drawPoint(x1 + 1, y2 - 1);
2176  p->drawPoint(x1 + 2, y2);
2177  }
2178  break; }
2179  case QTabBar::RoundedEast: {
2180  if (!selected) {
2181  x2 -= 2;
2182  y1 += firstTab ? borderThinkness : 0;
2183  y2 -= lastTab ? borderThinkness : 0;
2184  }
2185 
2186  p->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
2187 
2188  // Delete border
2189  if (selected) {
2190  p->fillRect(QRect(x1 + 1, y1, 1, (y2 - 1)-y1),tab->palette.background());
2191  p->fillRect(QRect(x1, y1, 1, (y2-1)-y1), tab->palette.background());
2192  }
2193  // Top
2194  if (firstTab || selected || onlyOne || !previousSelected) {
2195  p->setPen(light);
2196  p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1);
2197  p->drawPoint(x2 - 1, y1 + 1);
2198  }
2199  // Right
2200  {
2201  int beg = y1 + (previousSelected ? 0 : 2);
2202  int end = y2 - (nextSelected ? 0 : 2);
2203  p->setPen(shadow);
2204  p->drawLine(x2, beg, x2, end);
2205  p->setPen(dark);
2206  p->drawLine(x2 - 1, beg, x2 - 1, end);
2207  }
2208  // Bottom
2209  if (lastTab || selected || onlyOne || !nextSelected) {
2210  p->setPen(shadow);
2211  p->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2);
2212  p->drawPoint(x2 - 1, y2 - 1);
2213  p->setPen(dark);
2214  p->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness), y2 - 1);
2215  }
2216  break; }
2217  }
2218  }
2219  break;
2220 #endif // QT_NO_TABBAR
2221  case CE_ToolBoxTabShape:
2222  qDrawShadePanel(p, opt->rect, opt->palette,
2223  opt->state & (State_Sunken | State_On), 1,
2224  &opt->palette.brush(QPalette::Button));
2225  break;
2226 #ifndef QT_NO_SPLITTER
2227  case CE_Splitter:
2228  p->eraseRect(opt->rect);
2229  break;
2230 #endif // QT_NO_SPLITTER
2231 #ifndef QT_NO_SCROLLBAR
2232  case CE_ScrollBarSubLine:
2233  case CE_ScrollBarAddLine: {
2234  if ((opt->state & State_Sunken)) {
2235  p->setPen(opt->palette.dark().color());
2236  p->setBrush(opt->palette.brush(QPalette::Button));
2237  p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
2238  } else {
2239  QStyleOption buttonOpt = *opt;
2240  if (!(buttonOpt.state & State_Sunken))
2241  buttonOpt.state |= State_Raised;
2242  QPalette pal(opt->palette);
2243  pal.setColor(QPalette::Button, opt->palette.light().color());
2244  pal.setColor(QPalette::Light, opt->palette.button().color());
2245  qDrawWinButton(p, opt->rect, pal, opt->state & (State_Sunken | State_On),
2246  &opt->palette.brush(QPalette::Button));
2247  }
2248  PrimitiveElement arrow;
2249  if (opt->state & State_Horizontal) {
2250  if (ce == CE_ScrollBarAddLine)
2252  else
2254  } else {
2255  if (ce == CE_ScrollBarAddLine)
2256  arrow = PE_IndicatorArrowDown;
2257  else
2258  arrow = PE_IndicatorArrowUp;
2259  }
2260  QStyleOption arrowOpt = *opt;
2261  arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4);
2262  proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
2263  break; }
2264  case CE_ScrollBarAddPage:
2265  case CE_ScrollBarSubPage: {
2266  QBrush br;
2267  QBrush bg = p->background();
2268  Qt::BGMode bg_mode = p->backgroundMode();
2269  p->setPen(Qt::NoPen);
2271 
2272  if (opt->state & State_Sunken) {
2273  br = QBrush(opt->palette.shadow().color(), Qt::Dense4Pattern);
2274  p->setBackground(opt->palette.dark().color());
2275  p->setBrush(br);
2276  } else {
2278  br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2279  p->setBackground(opt->palette.background().color());
2280  p->setBrush(br);
2281  }
2282  p->drawRect(opt->rect);
2283  p->setBackground(bg);
2284  p->setBackgroundMode(bg_mode);
2285  break; }
2286  case CE_ScrollBarSlider:
2287  if (!(opt->state & State_Enabled)) {
2289  QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2290  p->setPen(Qt::NoPen);
2291  p->setBrush(br);
2293  p->drawRect(opt->rect);
2294  } else {
2295  QStyleOptionButton buttonOpt;
2296  buttonOpt.QStyleOption::operator=(*opt);
2297  buttonOpt.state = State_Enabled | State_Raised;
2298 
2299  QPalette pal(opt->palette);
2300  pal.setColor(QPalette::Button, opt->palette.light().color());
2301  pal.setColor(QPalette::Light, opt->palette.button().color());
2302  qDrawWinButton(p, opt->rect, pal, false, &opt->palette.brush(QPalette::Button));
2303  }
2304  break;
2305 #endif // QT_NO_SCROLLBAR
2306  case CE_HeaderSection: {
2307  QBrush fill;
2308  if (opt->state & State_On)
2309  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
2310  else
2311  fill = opt->palette.brush(QPalette::Button);
2312 
2313  if (opt->state & (State_Raised | State_Sunken)) {
2314  qDrawWinButton(p, opt->rect, opt->palette, opt->state & State_Sunken, &fill);
2315  } else {
2316  p->fillRect(opt->rect, fill);
2317  }
2318  break; }
2319 #ifndef QT_NO_TOOLBAR
2320  case CE_ToolBar:
2321  if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2322  QRect rect = opt->rect;
2323 
2324  bool paintLeftBorder = true;
2325  bool paintRightBorder = true;
2326  bool paintBottomBorder = true;
2327 
2328  switch (toolbar->toolBarArea){
2329  case Qt::BottomToolBarArea :
2330  switch(toolbar->positionOfLine){
2333  paintBottomBorder = false;
2334  default:
2335  break;
2336  }
2337  case Qt::TopToolBarArea :
2338  switch(toolbar->positionWithinLine){
2340  paintLeftBorder = false;
2341  break;
2343  paintRightBorder = false;
2344  break;
2346  paintRightBorder = false;
2347  paintLeftBorder = false;
2348  default:
2349  break;
2350  }
2351  if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end
2352  bool tmp = paintLeftBorder;
2353  paintRightBorder=paintLeftBorder;
2354  paintLeftBorder=tmp;
2355  }
2356  break;
2357  case Qt::RightToolBarArea :
2358  switch (toolbar->positionOfLine){
2361  paintRightBorder = false;
2362  break;
2363  default:
2364  break;
2365  }
2366  break;
2367  case Qt::LeftToolBarArea :
2368  switch (toolbar->positionOfLine){
2371  paintLeftBorder = false;
2372  break;
2373  default:
2374  break;
2375  }
2376  break;
2377  default:
2378  break;
2379  }
2380 
2381 
2382  //draw top border
2383  p->setPen(QPen(opt->palette.light().color()));
2384  p->drawLine(rect.topLeft().x(),
2385  rect.topLeft().y(),
2386  rect.topRight().x(),
2387  rect.topRight().y());
2388 
2389  if (paintLeftBorder){
2390  p->setPen(QPen(opt->palette.light().color()));
2391  p->drawLine(rect.topLeft().x(),
2392  rect.topLeft().y(),
2393  rect.bottomLeft().x(),
2394  rect.bottomLeft().y());
2395  }
2396 
2397  if (paintRightBorder){
2398  p->setPen(QPen(opt->palette.dark().color()));
2399  p->drawLine(rect.topRight().x(),
2400  rect.topRight().y(),
2401  rect.bottomRight().x(),
2402  rect.bottomRight().y());
2403  }
2404 
2405  if (paintBottomBorder){
2406  p->setPen(QPen(opt->palette.dark().color()));
2407  p->drawLine(rect.bottomLeft().x(),
2408  rect.bottomLeft().y(),
2409  rect.bottomRight().x(),
2410  rect.bottomRight().y());
2411  }
2412  }
2413  break;
2414 
2415 
2416 #endif // QT_NO_TOOLBAR
2417 #ifndef QT_NO_PROGRESSBAR
2419  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2420  QRect rect = pb->rect;
2421  if (!rect.isValid())
2422  return;
2423 
2424  bool vertical = false;
2425  bool inverted = false;
2426 
2427  // Get extra style options if version 2
2429  if (pb2) {
2430  vertical = (pb2->orientation == Qt::Vertical);
2431  inverted = pb2->invertedAppearance;
2432  }
2433  QMatrix m;
2434  if (vertical) {
2435  rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
2436  m.rotate(90);
2437  m.translate(0, -(rect.height() + rect.y()*2));
2438  }
2439  QPalette pal2 = pb->palette;
2440  // Correct the highlight color if it is the same as the background
2441  if (pal2.highlight() == pal2.background())
2442  pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
2444  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
2445  if (inverted)
2446  reverse = !reverse;
2447  int w = rect.width();
2448  if (pb->minimum == 0 && pb->maximum == 0) {
2449  Q_D(const QWindowsStyle);
2450  const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
2451  QStyleOptionProgressBarV2 pbBits = *pb;
2452  Q_ASSERT(unit_width >0);
2453 
2454  pbBits.rect = rect;
2455  pbBits.palette = pal2;
2456 
2457  int chunkCount = w / unit_width + 1;
2458  int step = d->animateStep%chunkCount;
2459  int chunksInRow = 5;
2460  int myY = pbBits.rect.y();
2461  int myHeight = pbBits.rect.height();
2462  int chunksToDraw = chunksInRow;
2463 
2464  if(step > chunkCount - 5)chunksToDraw = (chunkCount - step);
2465  p->save();
2466  p->setClipRect(m.mapRect(QRectF(rect)).toRect());
2467 
2468  int x0 = reverse ? rect.left() + rect.width() - unit_width*(step) - unit_width : rect.left() + unit_width * step;
2469  int x = 0;
2470 
2471  for (int i = 0; i < chunksToDraw ; ++i) {
2472  pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2473  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2475  x += reverse ? -unit_width : unit_width;
2476  }
2477  //Draw wrap-around chunks
2478  if( step > chunkCount-5){
2479  x0 = reverse ? rect.left() + rect.width() - unit_width : rect.left() ;
2480  x = 0;
2481  int chunksToDraw = step - (chunkCount - chunksInRow);
2482  for (int i = 0; i < chunksToDraw ; ++i) {
2483  pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
2484  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
2486  x += reverse ? -unit_width : unit_width;
2487  }
2488  }
2489  p->restore(); //restore state
2490  }
2491  else {
2492  QCommonStyle::drawControl(ce, opt, p, widget);
2493  }
2494  }
2495  break;
2496 #endif // QT_NO_PROGRESSBAR
2497 
2498 #ifndef QT_NO_DOCKWIDGET
2499  case CE_DockWidgetTitle:
2500 
2501  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2502  Q_D(const QWindowsStyle);
2503 
2504  const QStyleOptionDockWidgetV2 *v2
2506  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2507 
2508  QRect rect = dwOpt->rect;
2509  QRect r = rect;
2510 
2511  if (verticalTitleBar) {
2512  QSize s = r.size();
2513  s.transpose();
2514  r.setSize(s);
2515 
2516  p->save();
2517  p->translate(r.left(), r.top() + r.width());
2518  p->rotate(-90);
2519  p->translate(-r.left(), -r.top());
2520  }
2521 
2522  bool floating = false;
2523  bool active = dwOpt->state & State_Active;
2524  QColor inactiveCaptionTextColor = d->inactiveCaptionText;
2525  if (dwOpt->movable) {
2526  QColor left, right;
2527 
2528  //Titlebar gradient
2529  if (widget && widget->isWindow()) {
2530  floating = true;
2531  if (active) {
2532  left = d->activeCaptionColor;
2533  right = d->activeGradientCaptionColor;
2534  } else {
2535  left = d->inactiveCaptionColor;
2536  right = d->inactiveGradientCaptionColor;
2537  }
2538  QBrush fillBrush(left);
2539  if (left != right) {
2540  QPoint p1(r.x(), r.top() + r.height()/2);
2541  QPoint p2(rect.right(), r.top() + r.height()/2);
2542  QLinearGradient lg(p1, p2);
2543  lg.setColorAt(0, left);
2544  lg.setColorAt(1, right);
2545  fillBrush = lg;
2546  }
2547  p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
2548  }
2549  p->setPen(dwOpt->palette.color(QPalette::Light));
2550  if (!widget || !widget->isWindow()) {
2551  p->drawLine(r.topLeft(), r.topRight());
2552  p->setPen(dwOpt->palette.color(QPalette::Dark));
2553  p->drawLine(r.bottomLeft(), r.bottomRight()); }
2554  }
2555  if (!dwOpt->title.isEmpty()) {
2556  QFont oldFont = p->font();
2557  if (floating) {
2558  QFont font = oldFont;
2559  font.setBold(true);
2560  p->setFont(font);
2561  }
2562  QPalette palette = dwOpt->palette;
2563  palette.setColor(QPalette::Window, inactiveCaptionTextColor);
2565  if (verticalTitleBar) {
2566  titleRect = QRect(r.left() + rect.bottom()
2567  - titleRect.bottom(),
2568  r.top() + titleRect.left() - rect.left(),
2569  titleRect.height(), titleRect.width());
2570  }
2571  proxy()->drawItemText(p, titleRect,
2573  dwOpt->state & State_Enabled, dwOpt->title,
2574  floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
2575  p->setFont(oldFont);
2576  }
2577  if (verticalTitleBar)
2578  p->restore();
2579  }
2580  return;
2581 #endif // QT_NO_DOCKWIDGET
2582  default:
2583  QCommonStyle::drawControl(ce, opt, p, widget);
2584  }
2585 }
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
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
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
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
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
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
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
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
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
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.
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
Qt::Orientation orientation
the progress bar&#39;s orientation (horizontal or vertical); the default orentation is Qt::Horizontal ...
Definition: qstyleoption.h:422
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
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
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
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 Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
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 drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
NSToolbar * toolbar
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
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
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
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
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
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
QColor dark(int f=200) const
Use darker(factor) instead.
Definition: qcolor.cpp:2447
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
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:435
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
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
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
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
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
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
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 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
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
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
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
Qt::BGMode backgroundMode() const
Returns the current background mode.
Definition: qpainter.cpp:4026
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
Definition: qpainter.cpp:7332
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
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
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
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
Definition: qnamespace.h:54
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
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
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
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
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57
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
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
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
static const KeyPair *const end
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
bool invertedAppearance
whether the progress bar&#39;s appearance is inverted
Definition: qstyleoption.h:423
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
Definition: qmatrix.cpp:389
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
BGMode
Definition: qnamespace.h:588
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
QColor light(int f=150) const
Use lighter(factor) instead.
Definition: qcolor.cpp:2391
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
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

◆ drawPrimitive()

void QWindowsStyle::drawPrimitive ( PrimitiveElement  pe,
const QStyleOption opt,
QPainter p,
const QWidget w = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 1253 of file qwindowsstyle.cpp.

Referenced by QWindowsCEStyle::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), QWindowsMobileStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QWindowsXPStyle::drawPrimitive(), QGtkStyle::drawPrimitive(), QMacStyle::drawPrimitive(), and QStyleSheetStyle::drawPrimitive().

1255 {
1256  // Used to restore across fallthrough cases. Currently only used in PE_IndicatorCheckBox
1257  bool doRestore = false;
1258 
1259  switch (pe) {
1260 #ifndef QT_NO_TOOLBAR
1262  {
1263  QRect rect = opt->rect;
1264  const int margin = 2;
1265  QPen oldPen = p->pen();
1266  if(opt->state & State_Horizontal){
1267  const int offset = rect.width()/2;
1268  p->setPen(QPen(opt->palette.dark().color()));
1269  p->drawLine(rect.bottomLeft().x() + offset,
1270  rect.bottomLeft().y() - margin,
1271  rect.topLeft().x() + offset,
1272  rect.topLeft().y() + margin);
1273  p->setPen(QPen(opt->palette.light().color()));
1274  p->drawLine(rect.bottomLeft().x() + offset + 1,
1275  rect.bottomLeft().y() - margin,
1276  rect.topLeft().x() + offset + 1,
1277  rect.topLeft().y() + margin);
1278  }
1279  else{ //Draw vertical separator
1280  const int offset = rect.height()/2;
1281  p->setPen(QPen(opt->palette.dark().color()));
1282  p->drawLine(rect.topLeft().x() + margin ,
1283  rect.topLeft().y() + offset,
1284  rect.topRight().x() - margin,
1285  rect.topRight().y() + offset);
1286  p->setPen(QPen(opt->palette.light().color()));
1287  p->drawLine(rect.topLeft().x() + margin ,
1288  rect.topLeft().y() + offset + 1,
1289  rect.topRight().x() - margin,
1290  rect.topRight().y() + offset + 1);
1291  }
1292  p->setPen(oldPen);
1293  }
1294  break;
1296  p->save();
1297  p->translate(opt->rect.x(), opt->rect.y());
1298  if (opt->state & State_Horizontal) {
1299  int x = opt->rect.width() / 2 - 4;
1300  if (opt->direction == Qt::RightToLeft)
1301  x -= 2;
1302  if (opt->rect.height() > 4) {
1303  qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
1304  opt->palette, false, 1, 0);
1305  qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
1306  opt->palette, false, 1, 0);
1307  }
1308  } else {
1309  if (opt->rect.width() > 4) {
1310  int y = opt->rect.height() / 2 - 4;
1311  qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
1312  opt->palette, false, 1, 0);
1313  qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
1314  opt->palette, false, 1, 0);
1315  }
1316  }
1317  p->restore();
1318  break;
1319 
1320 #endif // QT_NO_TOOLBAR
1321  case PE_FrameButtonTool:
1322  case PE_PanelButtonTool: {
1323  QPen oldPen = p->pen();
1324 #ifndef QT_NO_DOCKWIDGET
1325  if (w && w->inherits("QDockWidgetTitleButton")) {
1326  if (const QWidget *dw = w->parentWidget())
1327  if (dw->isWindow()){
1328  qDrawWinButton(p, opt->rect.adjusted(1, 1, 0, 0), opt->palette, opt->state & (State_Sunken | State_On),
1329  &opt->palette.button());
1330 
1331  return;
1332  }
1333  }
1334 #endif // QT_NO_DOCKWIDGET
1335  QBrush fill;
1336  bool stippled;
1337  bool panel = (pe == PE_PanelButtonTool);
1338  if ((!(opt->state & State_Sunken ))
1339  && (!(opt->state & State_Enabled)
1340  || !(opt->state & State_MouseOver && opt->state & State_AutoRaise))
1341  && (opt->state & State_On)) {
1342  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1343  stippled = true;
1344  } else {
1345  fill = opt->palette.brush(QPalette::Button);
1346  stippled = false;
1347  }
1348 
1349  if (opt->state & (State_Raised | State_Sunken | State_On)) {
1350  if (opt->state & State_AutoRaise) {
1351  if(opt->state & (State_Enabled | State_Sunken | State_On)){
1352  if (panel)
1353  qDrawShadePanel(p, opt->rect, opt->palette,
1354  opt->state & (State_Sunken | State_On), 1, &fill);
1355  else
1356  qDrawShadeRect(p, opt->rect, opt->palette,
1357  opt->state & (State_Sunken | State_On), 1);
1358  }
1359  if (stippled) {
1360  p->setPen(opt->palette.button().color());
1361  p->drawRect(opt->rect.adjusted(1,1,-2,-2));
1362  }
1363  } else {
1364  qDrawWinButton(p, opt->rect, opt->palette,
1365  opt->state & (State_Sunken | State_On), panel ? &fill : 0);
1366  }
1367  } else {
1368  p->fillRect(opt->rect, fill);
1369  }
1370  p->setPen(oldPen);
1371  break; }
1372  case PE_PanelButtonCommand:
1373  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1374  QBrush fill;
1375  State flags = opt->state;
1376  QPalette pal = opt->palette;
1377  QRect r = opt->rect;
1378  if (! (flags & State_Sunken) && (flags & State_On))
1379  fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
1380  else
1381  fill = pal.brush(QPalette::Button);
1382 
1383  if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
1384  p->setPen(pal.dark().color());
1385  p->setBrush(fill);
1386  p->drawRect(r.adjusted(0, 0, -1, -1));
1387  } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
1388  qDrawWinButton(p, r, pal, flags & (State_Sunken | State_On),
1389  &fill);
1390  } else {
1391  p->fillRect(r, fill);
1392  }
1393  }
1394  break;
1395  case PE_FrameDefaultButton: {
1396  QPen oldPen = p->pen();
1397  p->setPen(opt->palette.shadow().color());
1398  QRect rect = opt->rect;
1399  rect.adjust(0, 0, -1, -1);
1400  p->drawRect(rect);
1401  p->setPen(oldPen);
1402  break;
1403  }
1404  case PE_IndicatorArrowUp:
1405  case PE_IndicatorArrowDown:
1407  case PE_IndicatorArrowLeft:
1408  {
1409  if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
1410  break;
1411  QRect r = opt->rect;
1412  int size = qMin(r.height(), r.width());
1413  QPixmap pixmap;
1414  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-")
1415  % QLatin1String(metaObject()->className()), opt, QSize(size, size))
1416  % HexString<uint>(pe);
1417  if (!QPixmapCache::find(pixmapName, pixmap)) {
1418  int border = size/5;
1419  int sqsize = 2*(size/2);
1420  QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
1421  image.fill(0);
1422  QPainter imagePainter(&image);
1423 
1424  QPolygon a;
1425  switch (pe) {
1426  case PE_IndicatorArrowUp:
1427  a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
1428  break;
1429  case PE_IndicatorArrowDown:
1430  a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
1431  break;
1433  a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1434  break;
1435  case PE_IndicatorArrowLeft:
1436  a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
1437  break;
1438  default:
1439  break;
1440  }
1441 
1442  int bsx = 0;
1443  int bsy = 0;
1444 
1445  if (opt->state & State_Sunken) {
1446  bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w);
1447  bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w);
1448  }
1449 
1450  QRect bounds = a.boundingRect();
1451  int sx = sqsize / 2 - bounds.center().x() - 1;
1452  int sy = sqsize / 2 - bounds.center().y() - 1;
1453  imagePainter.translate(sx + bsx, sy + bsy);
1454  imagePainter.setPen(opt->palette.buttonText().color());
1455  imagePainter.setBrush(opt->palette.buttonText());
1456 
1457  if (!(opt->state & State_Enabled)) {
1458  imagePainter.translate(1, 1);
1459  imagePainter.setBrush(opt->palette.light().color());
1460  imagePainter.setPen(opt->palette.light().color());
1461  imagePainter.drawPolygon(a);
1462  imagePainter.translate(-1, -1);
1463  imagePainter.setBrush(opt->palette.mid().color());
1464  imagePainter.setPen(opt->palette.mid().color());
1465  }
1466 
1467  imagePainter.drawPolygon(a);
1468  imagePainter.end();
1469  pixmap = QPixmap::fromImage(image);
1470  QPixmapCache::insert(pixmapName, pixmap);
1471  }
1472  int xOffset = r.x() + (r.width() - size)/2;
1473  int yOffset = r.y() + (r.height() - size)/2;
1474  p->drawPixmap(xOffset, yOffset, pixmap);
1475  }
1476  break;
1477  case PE_IndicatorCheckBox: {
1478  QBrush fill;
1479  if (opt->state & State_NoChange)
1480  fill = QBrush(opt->palette.base().color(), Qt::Dense4Pattern);
1481  else if (opt->state & State_Sunken)
1482  fill = opt->palette.button();
1483  else if (opt->state & State_Enabled)
1484  fill = opt->palette.base();
1485  else
1486  fill = opt->palette.background();
1487  p->save();
1488  doRestore = true;
1489  qDrawWinPanel(p, opt->rect, opt->palette, true, &fill);
1490  if (opt->state & State_NoChange)
1491  p->setPen(opt->palette.dark().color());
1492  else
1493  p->setPen(opt->palette.text().color());
1494  } // Fall through!
1497  if (!doRestore) {
1498  p->save();
1499  doRestore = true;
1500  }
1502  const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
1503  p->setPen(itemViewOpt
1504  && itemViewOpt->showDecorationSelected
1505  && opt->state & State_Selected
1506  ? opt->palette.highlightedText().color()
1507  : opt->palette.text().color());
1508  if (opt->state & State_NoChange)
1510  p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
1511  }
1512  if (!(opt->state & State_Off)) {
1513  QLineF lines[7];
1514  int i, xx, yy;
1515  xx = opt->rect.x() + 3;
1516  yy = opt->rect.y() + 5;
1517  for (i = 0; i < 3; ++i) {
1518  lines[i] = QLineF(xx, yy, xx, yy + 2);
1519  ++xx;
1520  ++yy;
1521  }
1522  yy -= 2;
1523  for (i = 3; i < 7; ++i) {
1524  lines[i] = QLineF(xx, yy, xx, yy + 2);
1525  ++xx;
1526  --yy;
1527  }
1528  p->drawLines(lines, 7);
1529  }
1530  if (doRestore)
1531  p->restore();
1532  break;
1533  case PE_FrameFocusRect:
1534  if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
1535  //### check for d->alt_down
1536  if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt))
1537  return;
1538  QRect r = opt->rect;
1539  p->save();
1541  QColor bg_col = fropt->backgroundColor;
1542  if (!bg_col.isValid())
1543  bg_col = p->background().color();
1544  // Create an "XOR" color.
1545  QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
1546  (bg_col.green() ^ 0xff) & 0xff,
1547  (bg_col.blue() ^ 0xff) & 0xff);
1548  p->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
1549  p->setBrushOrigin(r.topLeft());
1550  p->setPen(Qt::NoPen);
1551  p->drawRect(r.left(), r.top(), r.width(), 1); // Top
1552  p->drawRect(r.left(), r.bottom(), r.width(), 1); // Bottom
1553  p->drawRect(r.left(), r.top(), 1, r.height()); // Left
1554  p->drawRect(r.right(), r.top(), 1, r.height()); // Right
1555  p->restore();
1556  }
1557  break;
1559  {
1560 #define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
1561  static const QPoint pts1[] = { // dark lines
1562  QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
1563  QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
1564  };
1565  static const QPoint pts2[] = { // black lines
1566  QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
1567  QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
1568  };
1569  static const QPoint pts3[] = { // background lines
1570  QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
1571  QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
1572  };
1573  static const QPoint pts4[] = { // white lines
1574  QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
1575  QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
1576  QPoint(10, 3), QPoint(10, 2)
1577  };
1578  static const QPoint pts5[] = { // inner fill
1579  QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
1580  QPoint(2, 7), QPoint(2, 4)
1581  };
1582 
1583  // make sure the indicator is square
1584  QRect ir = opt->rect;
1585 
1586  if (opt->rect.width() < opt->rect.height()) {
1587  ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
1588  ir.setHeight(opt->rect.width());
1589  } else if (opt->rect.height() < opt->rect.width()) {
1590  ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
1591  ir.setWidth(opt->rect.height());
1592  }
1593 
1594  p->save();
1595  bool down = opt->state & State_Sunken;
1596  bool enabled = opt->state & State_Enabled;
1597  bool on = opt->state & State_On;
1598  QPolygon a;
1599 
1600  //center when rect is larger than indicator size
1601  int xOffset = 0;
1602  int yOffset = 0;
1603  int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1604  int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
1605  if (ir.width() > indicatorWidth)
1606  xOffset += (ir.width() - indicatorWidth)/2;
1607  if (ir.height() > indicatorHeight)
1608  yOffset += (ir.height() - indicatorHeight)/2;
1609  p->translate(xOffset, yOffset);
1610 
1611  p->translate(ir.x(), ir.y());
1612 
1613  p->setPen(opt->palette.dark().color());
1614  p->drawPolyline(pts1, PTSARRLEN(pts1));
1615 
1616  p->setPen(opt->palette.shadow().color());
1617  p->drawPolyline(pts2, PTSARRLEN(pts2));
1618 
1619  p->setPen(opt->palette.midlight().color());
1620  p->drawPolyline(pts3, PTSARRLEN(pts3));
1621 
1622  p->setPen(opt->palette.light().color());
1623  p->drawPolyline(pts4, PTSARRLEN(pts4));
1624 
1625  QColor fillColor = (down || !enabled)
1626  ? opt->palette.button().color()
1627  : opt->palette.base().color();
1628  p->setPen(fillColor);
1629  p->setBrush(fillColor) ;
1630  p->drawPolygon(pts5, PTSARRLEN(pts5));
1631 
1632  p->translate(-ir.x(), -ir.y()); // restore translate
1633 
1634  if (on) {
1635  p->setPen(Qt::NoPen);
1636  p->setBrush(opt->palette.text());
1637  p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
1638  p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
1639  }
1640  p->restore();
1641  break;
1642  }
1643 #ifndef QT_NO_FRAME
1644  case PE_Frame:
1645  case PE_FrameMenu:
1646  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1647  if (frame->lineWidth == 2 || pe == PE_Frame) {
1648  QPalette popupPal = frame->palette;
1649  if (pe == PE_FrameMenu) {
1650  popupPal.setColor(QPalette::Light, frame->palette.background().color());
1651  popupPal.setColor(QPalette::Midlight, frame->palette.light().color());
1652  }
1653  if (pe == PE_Frame && (frame->state & State_Raised))
1654  qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken);
1655  else if (pe == PE_Frame && (frame->state & State_Sunken))
1656  {
1657  popupPal.setColor(QPalette::Midlight, frame->palette.background().color());
1658  qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1659  }
1660  else
1661  qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken);
1662  } else {
1663  QCommonStyle::drawPrimitive(pe, opt, p, w);
1664  }
1665  } else {
1666  QPalette popupPal = opt->palette;
1667  popupPal.setColor(QPalette::Light, opt->palette.background().color());
1668  popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1669  qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1670  }
1671  break;
1672 #endif // QT_NO_FRAME
1673  case PE_IndicatorBranch: {
1674  // This is _way_ too similar to the common style.
1675  static const int decoration_size = 9;
1676  int mid_h = opt->rect.x() + opt->rect.width() / 2;
1677  int mid_v = opt->rect.y() + opt->rect.height() / 2;
1678  int bef_h = mid_h;
1679  int bef_v = mid_v;
1680  int aft_h = mid_h;
1681  int aft_v = mid_v;
1682  if (opt->state & State_Children) {
1683  int delta = decoration_size / 2;
1684  bef_h -= delta;
1685  bef_v -= delta;
1686  aft_h += delta;
1687  aft_v += delta;
1688  p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
1689  if (!(opt->state & State_Open))
1690  p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
1691  QPen oldPen = p->pen();
1692  p->setPen(opt->palette.dark().color());
1693  p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
1694  p->setPen(oldPen);
1695  }
1696  QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
1697  if (opt->state & State_Item) {
1698  if (opt->direction == Qt::RightToLeft)
1699  p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
1700  else
1701  p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
1702  }
1703  if (opt->state & State_Sibling)
1704  p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
1706  p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
1707  break; }
1708  case PE_FrameButtonBevel:
1709  case PE_PanelButtonBevel: {
1710  QBrush fill;
1711  bool panel = pe != PE_FrameButtonBevel;
1712  p->setBrushOrigin(opt->rect.topLeft());
1713  if (!(opt->state & State_Sunken) && (opt->state & State_On))
1714  fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern);
1715  else
1716  fill = opt->palette.brush(QPalette::Button);
1717 
1718  if (opt->state & (State_Raised | State_On | State_Sunken)) {
1719  qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
1720  panel ? &fill : 0);
1721  } else {
1722  if (panel)
1723  p->fillRect(opt->rect, fill);
1724  else
1725  p->drawRect(opt->rect);
1726  }
1727  break; }
1728  case PE_FrameWindow: {
1729  QPalette popupPal = opt->palette;
1730  popupPal.setColor(QPalette::Light, opt->palette.background().color());
1731  popupPal.setColor(QPalette::Midlight, opt->palette.light().color());
1732  qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
1733  break; }
1734 #ifndef QT_NO_DOCKWIDGET
1736  QPen oldPen = p->pen();
1737  p->setPen(opt->palette.light().color());
1738  if (opt->state & State_Horizontal) {
1739  p->drawLine(opt->rect.left(), opt->rect.top(),
1740  opt->rect.right(), opt->rect.top());
1741  p->setPen(opt->palette.dark().color());
1742  p->drawLine(opt->rect.left(), opt->rect.bottom() - 1,
1743  opt->rect.right(), opt->rect.bottom() - 1);
1744  p->setPen(opt->palette.shadow().color());
1745  p->drawLine(opt->rect.left(), opt->rect.bottom(),
1746  opt->rect.right(), opt->rect.bottom());
1747  } else {
1748  p->drawLine(opt->rect.left(), opt->rect.top(),
1749  opt->rect.left(), opt->rect.bottom());
1750  p->setPen(opt->palette.dark().color());
1751  p->drawLine(opt->rect.right() - 1, opt->rect.top(),
1752  opt->rect.right() - 1, opt->rect.bottom());
1753  p->setPen(opt->palette.shadow().color());
1754  p->drawLine(opt->rect.right(), opt->rect.top(),
1755  opt->rect.right(), opt->rect.bottom());
1756  }
1757  p->setPen(oldPen);
1758  break; }
1759 case PE_FrameDockWidget:
1760  if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1762  }
1763  break;
1764 #endif // QT_NO_DOCKWIDGET
1765 
1766  case PE_FrameStatusBarItem:
1767  qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
1768  break;
1769 
1770 #ifndef QT_NO_PROGRESSBAR
1772  {
1773  bool vertical = false, inverted = false;
1774  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1775  vertical = (pb2->orientation == Qt::Vertical);
1776  inverted = pb2->invertedAppearance;
1777  }
1778 
1779  int space = 2;
1780  int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space;
1781  if (!vertical) {
1782  if (opt->rect.width() <= chunksize)
1783  space = 0;
1784 
1785  if (inverted)
1786  p->fillRect(opt->rect.x() + space, opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1788  else
1789  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width() - space, opt->rect.height(),
1791  } else {
1792  if (opt->rect.height() <= chunksize)
1793  space = 0;
1794 
1795  if (inverted)
1796  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height() - space,
1798  else
1799  p->fillRect(opt->rect.x(), opt->rect.y() + space, opt->rect.width(), opt->rect.height() - space,
1801  }
1802  }
1803  break;
1804 #endif // QT_NO_PROGRESSBAR
1805 
1806  case PE_FrameTabWidget: {
1807  qDrawWinButton(p, opt->rect, opt->palette, false, 0);
1808  break;
1809  }
1810  default:
1811  QCommonStyle::drawPrimitive(pe, opt, p, w);
1812  }
1813 }
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
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
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
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
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
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
#define PTSARRLEN(x)
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.
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
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
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
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
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
const char * className
Definition: qwizard.cpp:137
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static QPixmap * find(const QString &key)
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
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
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition: qpalette.h:136
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
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...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
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
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void qDrawWinButton(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:435
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The State element defines configurations of objects and properties.
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
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
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
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
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
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
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
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
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
QRect boundingRect() const
Returns the bounding rectangle of the polygon, or QRect(0, 0, 0, 0) if the polygon is empty...
Definition: qpolygon.cpp:492
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
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define enabled
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
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

◆ eventFilter()

bool QWindowsStyle::eventFilter ( QObject o,
QEvent e 
)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 183 of file qwindowsstyle.cpp.

Referenced by QPlastiqueStyle::eventFilter().

184 {
185  // Records Alt- and Focus events
186  if (!o->isWidgetType())
187  return QObject::eventFilter(o, e);
188 
191  switch(e->type()) {
192  case QEvent::KeyPress:
193  if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Alt) {
194  widget = widget->window();
195 
196  // Alt has been pressed - find all widgets that care
197  QList<QWidget *> l = widget->findChildren<QWidget *>();
198  for (int pos=0 ; pos < l.size() ;) {
199  QWidget *w = l.at(pos);
200  if (w->isWindow() || !w->isVisible() ||
201  w->style()->styleHint(SH_UnderlineShortcut, 0, w)) {
202  l.removeAt(pos);
203  continue;
204  }
205  pos++;
206  }
207  // Update states before repainting
208  d->seenAlt.append(widget);
209  d->alt_down = true;
210 
211  // Repaint all relevant widgets
212  for (int pos = 0; pos < l.size(); ++pos)
213  l.at(pos)->update();
214  }
215  break;
216  case QEvent::KeyRelease:
217  if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Alt) {
218  widget = widget->window();
219 
220  // Update state and repaint the menu bars.
221  d->alt_down = false;
222 #ifndef QT_NO_MENUBAR
223  QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
224  for (int i = 0; i < l.size(); ++i)
225  l.at(i)->update();
226 #endif
227  }
228  break;
229  case QEvent::Close:
230  // Reset widget when closing
231  d->seenAlt.removeAll(widget);
232  d->seenAlt.removeAll(widget->window());
233  break;
234 #ifndef QT_NO_PROGRESSBAR
235  case QEvent::StyleChange:
236  case QEvent::Paint:
237  case QEvent::Show:
238  if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
239  // Animation by timer for progress bars that have their min and
240  // max values the same
241  if (bar->minimum() == bar->maximum())
242  d->startAnimation(this, bar);
243  else
244  d->stopAnimation(this, bar);
245  }
246  break;
247  case QEvent::Destroy:
248  case QEvent::Hide:
249  // Do static_cast because there is no type info when getting
250  // the destroy event. We know that it is a QProgressBar, since
251  // we only install a widget event filter for QScrollBars.
252  d->stopAnimation(this, static_cast<QProgressBar *>(o));
253  break;
254 #endif // QT_NO_PROGRESSBAR
255  default:
256  break;
257  }
258  return QCommonStyle::eventFilter(o, e);
259 }
double d
Definition: qnumeric_p.h:62
QPointer< QWidget > widget
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
int key
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
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.
Definition: qobject.h:162
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ pixelMetric()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 380 of file qwindowsstyle.cpp.

Referenced by drawControl(), QCleanlooksStyle::pixelMetric(), QWindowsVistaStyle::pixelMetric(), QWindowsXPStyle::pixelMetric(), QPlastiqueStyle::pixelMetric(), QWindowsCEStyle::pixelMetric(), QWindowsMobileStyle::pixelMetric(), and QMacStyle::pixelMetric().

381 {
382  int ret;
383 
384  switch (pm) {
388  case PM_MenuHMargin:
389  case PM_MenuVMargin:
390  ret = 1;
391  break;
392 #ifndef QT_NO_TABBAR
394  ret = 0;
395  break;
397  ret = 2;
398  break;
399 #endif
401 #if defined(Q_WS_WIN)
402  {
403  HDC hdcScreen = GetDC(0);
404  int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX);
405  ReleaseDC(0, hdcScreen);
406  ret = (int)(dpi * 1.375);
407  }
408 #else
409  ret = 60;
410 #endif
411  break;
412 
413 #ifndef QT_NO_SLIDER
414  case PM_SliderLength:
415  ret = int(QStyleHelper::dpiScaled(11.));
416  break;
417 
418  // Returns the number of pixels to use for the business part of the
419  // slider (i.e., the non-tickmark portion). The remaining space is shared
420  // equally between the tickmark regions.
422  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
423  int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
424  int ticks = sl->tickPosition;
425  int n = 0;
426  if (ticks & QSlider::TicksAbove)
427  ++n;
428  if (ticks & QSlider::TicksBelow)
429  ++n;
430  if (!n) {
431  ret = space;
432  break;
433  }
434 
435  int thick = 6; // Magic constant to get 5 + 16 + 5
436  if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
437  thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
438 
439  space -= thick;
440  if (space > 0)
441  thick += (space * 2) / (n + 2);
442  ret = thick;
443  } else {
444  ret = 0;
445  }
446  break;
447 #endif // QT_NO_SLIDER
448 
449 #ifndef QT_NO_MENU
450  case PM_MenuBarHMargin:
451  ret = 0;
452  break;
453 
454  case PM_MenuBarVMargin:
455  ret = 0;
456  break;
457 
459  ret = 0;
460  break;
461 
462  case PM_SmallIconSize:
463  ret = int(QStyleHelper::dpiScaled(16.));
464  break;
465 
466  case PM_LargeIconSize:
467  ret = int(QStyleHelper::dpiScaled(32.));
468  break;
469 
470  case PM_IconViewIconSize:
471  ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
472  break;
473 
475  ret = int(QStyleHelper::dpiScaled(2.));
476  break;
478  ret = int(QStyleHelper::dpiScaled(4.));
479  break;
480 #if defined(Q_WS_WIN)
482 #if defined(Q_OS_WINCE)
483  ret = GetSystemMetrics(SM_CXDLGFRAME);
484 #else
485  ret = GetSystemMetrics(SM_CXFRAME);
486 #endif
487  break;
488 #else
490  ret = 4;
491  break;
492 #endif // Q_WS_WIN
493  break;
494 
495 #endif // QT_NO_MENU
496 
497 
498 #if defined(Q_WS_WIN)
499  case PM_TitleBarHeight:
500 #ifdef QT3_SUPPORT
501  // qt3 dockwindow height should be equal to tool windows
502  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
503  ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
504  } else
505 #endif
506  if (widget && (widget->windowType() == Qt::Tool)) {
507  // MS always use one less than they say
508 #if defined(Q_OS_WINCE)
509  ret = GetSystemMetrics(SM_CYCAPTION) - 1;
510 #else
511  ret = GetSystemMetrics(SM_CYSMCAPTION) - 1;
512 #endif
513  } else {
514  ret = GetSystemMetrics(SM_CYCAPTION) - 1;
515  }
516 
517  break;
518 
519  case PM_ScrollBarExtent:
520  {
521 #ifndef Q_OS_WINCE
522  NONCLIENTMETRICS ncm;
523  ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
524  if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
525  ret = qMax(ncm.iScrollHeight, ncm.iScrollWidth);
526  else
527 #endif
528  ret = QCommonStyle::pixelMetric(pm, opt, widget);
529  }
530  break;
531 #endif // Q_WS_WIN
532 
533  case PM_SplitterWidth:
534  ret = qMax(4, QApplication::globalStrut().width());
535  break;
536 
537 #if defined(Q_WS_WIN)
539 #if defined(Q_OS_WINCE)
540  ret = GetSystemMetrics(SM_CYDLGFRAME);
541 #else
542  ret = GetSystemMetrics(SM_CYFRAME);
543 #endif
544  break;
545  case PM_TextCursorWidth: {
546  DWORD caretWidth = 1;
547 #if defined(SPI_GETCARETWIDTH)
548  SystemParametersInfo(SPI_GETCARETWIDTH, 0, &caretWidth, 0);
549 #endif
550  ret = (int)caretWidth;
551  break; }
552 #endif
554  ret = 1;
555  break;
557  ret = 0;
558  break;
560  ret = int(QStyleHelper::dpiScaled(10.));
561  break;
562  default:
563  ret = QCommonStyle::pixelMetric(pm, opt, widget);
564  break;
565  }
566 
567  return ret;
568 }
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
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
qreal dpiScaled(qreal value)
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ polish() [1/3]

void QWindowsStyle::polish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsVistaStyle, and QWindowsXPStyle.

Definition at line 309 of file qwindowsstyle.cpp.

Referenced by QWindowsXPStyle::polish(), QMacStyle::polish(), QWindowsVistaStyle::polish(), QPlastiqueStyle::polish(), QWindowsMobileStyle::polish(), QWindowsCEStyle::polish(), QCleanlooksStyle::polish(), and QStyleSheetStyle::polish().

310 {
312  QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
313  // We only need the overhead when shortcuts are sometimes hidden
314  if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
315  app->installEventFilter(this);
316 
317  d->activeCaptionColor = app->palette().highlight().color();
319  d->inactiveCaptionColor = app->palette().dark().color();
322 
323 #if defined(Q_WS_WIN) //fetch native title bar colors
324  if(app->desktopSettingsAware()){
325  DWORD activeCaption = GetSysColor(COLOR_ACTIVECAPTION);
326  DWORD gradientActiveCaption = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
327  DWORD inactiveCaption = GetSysColor(COLOR_INACTIVECAPTION);
328  DWORD gradientInactiveCaption = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
329  DWORD inactiveCaptionText = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
330  d->activeCaptionColor = colorref2qrgb(activeCaption);
331  d->activeGradientCaptionColor = colorref2qrgb(gradientActiveCaption);
332  d->inactiveCaptionColor = colorref2qrgb(inactiveCaption);
333  d->inactiveGradientCaptionColor = colorref2qrgb(gradientInactiveCaption);
334  d->inactiveCaptionText = colorref2qrgb(inactiveCaptionText);
335  }
336 #endif
337 }
double d
Definition: qnumeric_p.h:62
QColor inactiveGradientCaptionColor
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static QPalette palette()
Returns the application palette.
#define COLOR_GRADIENTINACTIVECAPTION
static QRgb colorref2qrgb(COLORREF col)
void polish(QPalette &)
Reimplemented Function
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
#define COLOR_GRADIENTACTIVECAPTION
const QStyle * proxy() const
Definition: qstyle.cpp:2546

◆ polish() [2/3]

void QWindowsStyle::polish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsVistaStyle, and QWindowsXPStyle.

Definition at line 347 of file qwindowsstyle.cpp.

348 {
349  QCommonStyle::polish(widget);
350 #ifndef QT_NO_PROGRESSBAR
351  if (qobject_cast<QProgressBar *>(widget))
352  widget->installEventFilter(this);
353 #endif
354 }
void polish(QPalette &)
Reimplemented Function
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070

◆ polish() [3/3]

void QWindowsStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsVistaStyle, and QWindowsXPStyle.

Definition at line 372 of file qwindowsstyle.cpp.

373 {
375 }
void polish(QPalette &)
Reimplemented Function

◆ sizeFromContents()

QSize QWindowsStyle::sizeFromContents ( ContentsType  ct,
const QStyleOption opt,
const QSize contentsSize,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 3187 of file qwindowsstyle.cpp.

Referenced by QWindowsVistaStyle::sizeFromContents(), QPlastiqueStyle::sizeFromContents(), QWindowsMobileStyle::sizeFromContents(), QWindowsCEStyle::sizeFromContents(), QCleanlooksStyle::sizeFromContents(), QWindowsXPStyle::sizeFromContents(), QMacStyle::sizeFromContents(), and QStyleSheetStyle::sizeFromContents().

3189 {
3190  QSize sz(csz);
3191  switch (ct) {
3192  case CT_PushButton:
3193  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3194  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3195  int w = sz.width(),
3196  h = sz.height();
3197  int defwidth = 0;
3198  if (btn->features & QStyleOptionButton::AutoDefaultButton)
3199  defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
3200  int minwidth = int(QStyleHelper::dpiScaled(75.));
3201  int minheight = int(QStyleHelper::dpiScaled(23.));
3202 
3203 #ifndef QT_QWS_SMALL_PUSHBUTTON
3204  if (w < minwidth + defwidth && !btn->text.isEmpty())
3205  w = minwidth + defwidth;
3206  if (h < minheight + defwidth)
3207  h = minheight + defwidth;
3208 #endif
3209  sz = QSize(w, h);
3210  }
3211  break;
3212 #ifndef QT_NO_MENU
3213  case CT_MenuItem:
3214  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3215  int w = sz.width();
3216  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3217 
3218  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
3220  }
3221  else if (mi->icon.isNull()) {
3222  sz.setHeight(sz.height() - 2);
3223  w -= 6;
3224  }
3225 
3226  if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) {
3227  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
3228  sz.setHeight(qMax(sz.height(),
3229  mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()
3231  }
3232  int maxpmw = mi->maxIconWidth;
3233  int tabSpacing = 20;
3234  if (mi->text.contains(QLatin1Char('\t')))
3235  w += tabSpacing;
3236  else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
3238  else if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) {
3239  // adjust the font and add the difference in size.
3240  // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
3241  QFontMetrics fm(mi->font);
3242  QFont fontBold = mi->font;
3243  fontBold.setBold(true);
3244  QFontMetrics fmBold(fontBold);
3245  w += fmBold.width(mi->text) - fm.width(mi->text);
3246  }
3247 
3248  int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
3249  w += checkcol;
3251  sz.setWidth(w);
3252  }
3253  break;
3254 #endif // QT_NO_MENU
3255 #ifndef QT_NO_MENUBAR
3256  case CT_MenuBarItem:
3257  if (!sz.isEmpty())
3259  break;
3260 #endif
3261  // Otherwise, fall through
3262  case CT_ToolButton:
3263  if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
3264  return sz += QSize(7, 6);
3265  // Otherwise, fall through
3266 
3267  default:
3268  sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
3269  }
3270  return sz;
3271 }
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
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.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
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
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
qreal dpiScaled(qreal value)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
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
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 text
Definition: qobjectdefs.h:80

◆ standardIconImplementation

QIcon QWindowsStyle::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 3276 of file qwindowsstyle.cpp.

Referenced by QStyleSheetStyle::deref(), QWindowsXPStyle::standardIconImplementation(), QWindowsVistaStyle::standardIconImplementation(), QPlastiqueStyle::standardIconImplementation(), QCleanlooksStyle::standardIconImplementation(), and QMacStyle::standardIconImplementation().

3278 {
3279  QIcon icon;
3280  QPixmap pixmap;
3281 #ifdef Q_OS_WIN
3282  switch (standardIcon) {
3284  {
3285  for (int size = 16 ; size <= 32 ; size += 16) {
3286  pixmap = loadIconFromShell32(319, size);
3287  icon.addPixmap(pixmap, QIcon::Normal);
3288  }
3289  break;
3290  }
3291  case SP_DirHomeIcon:
3292  {
3293  for (int size = 16 ; size <= 32 ; size += 16) {
3294  pixmap = loadIconFromShell32(235, size);
3295  icon.addPixmap(pixmap, QIcon::Normal);
3296  }
3297  break;
3298  }
3299  case SP_DirIcon:
3300  for (int size = 16 ; size <= 32 ; size += 16) {
3301  pixmap = loadIconFromShell32(4, size);
3302  icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
3303  pixmap = loadIconFromShell32(5, size);
3304  icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
3305  }
3306  break;
3307  case SP_DirLinkIcon:
3308  for (int size = 16 ; size <= 32 ; size += 16) {
3309  QPixmap link = loadIconFromShell32(30, size);
3310  pixmap = loadIconFromShell32(4, size);
3311  if (!pixmap.isNull() && !link.isNull()) {
3312  QPainter painter(&pixmap);
3313  painter.drawPixmap(0, 0, size, size, link);
3314  icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
3315  }
3316  link = loadIconFromShell32(30, size);
3317  pixmap = loadIconFromShell32(5, size);
3318  if (!pixmap.isNull() && !link.isNull()) {
3319  QPainter painter(&pixmap);
3320  painter.drawPixmap(0, 0, size, size, link);
3321  icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
3322  }
3323  }
3324  break;
3325  case SP_FileIcon:
3326  for (int size = 16 ; size <= 32 ; size += 16) {
3327  pixmap = loadIconFromShell32(1, size);
3328  icon.addPixmap(pixmap, QIcon::Normal);
3329  }
3330  break;
3331  case SP_ComputerIcon:
3332  for (int size = 16 ; size <= 32 ; size += 16) {
3333  pixmap = loadIconFromShell32(16, size);
3334  icon.addPixmap(pixmap, QIcon::Normal);
3335  }
3336  break;
3337 
3338  case SP_DesktopIcon:
3339  for (int size = 16 ; size <= 32 ; size += 16) {
3340  pixmap = loadIconFromShell32(35, size);
3341  icon.addPixmap(pixmap, QIcon::Normal);
3342  }
3343  break;
3344  case SP_DriveCDIcon:
3345  case SP_DriveDVDIcon:
3346  for (int size = 16 ; size <= 32 ; size += 16) {
3347  pixmap = loadIconFromShell32(12, size);
3348  icon.addPixmap(pixmap, QIcon::Normal);
3349  }
3350  break;
3351  case SP_DriveNetIcon:
3352  for (int size = 16 ; size <= 32 ; size += 16) {
3353  pixmap = loadIconFromShell32(10, size);
3354  icon.addPixmap(pixmap, QIcon::Normal);
3355  }
3356  break;
3357  case SP_DriveHDIcon:
3358  for (int size = 16 ; size <= 32 ; size += 16) {
3359  pixmap = loadIconFromShell32(9, size);
3360  icon.addPixmap(pixmap, QIcon::Normal);
3361  }
3362  break;
3363  case SP_DriveFDIcon:
3364  for (int size = 16 ; size <= 32 ; size += 16) {
3365  pixmap = loadIconFromShell32(7, size);
3366  icon.addPixmap(pixmap, QIcon::Normal);
3367  }
3368  break;
3369  case SP_FileLinkIcon:
3370  for (int size = 16 ; size <= 32 ; size += 16) {
3371  QPixmap link;
3372  link = loadIconFromShell32(30, size);
3373  pixmap = loadIconFromShell32(1, size);
3374  if (!pixmap.isNull() && !link.isNull()) {
3375  QPainter painter(&pixmap);
3376  painter.drawPixmap(0, 0, size, size, link);
3377  icon.addPixmap(pixmap, QIcon::Normal);
3378  }
3379  }
3380  break;
3381  case SP_VistaShield:
3382  {
3386  {
3387  icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon
3388  QSHSTOCKICONINFO iconInfo; //append large icon
3389  memset(&iconInfo, 0, sizeof(iconInfo));
3390  iconInfo.cbSize = sizeof(iconInfo);
3391  if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_LARGEICON, &iconInfo) == S_OK) {
3392  icon.addPixmap(QPixmap::fromWinHICON(iconInfo.hIcon));
3393  DestroyIcon(iconInfo.hIcon);
3394  }
3395  }
3396  }
3397  break;
3398  default:
3399  break;
3400  }
3401 #endif
3402 
3403  if (icon.isNull())
3405  return icon;
3406 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
static QPixmap fromWinHICON(HICON hicon)
#define _SIID_SHIELD
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
#define _SHGFI_LARGEICON
#define _SHGFI_ICON
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static QPixmap loadIconFromShell32(int resourceId, int size)
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
static PtrSHGetStockIconInfo pSHGetStockIconInfo
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ standardPixmap()

QPixmap QWindowsStyle::standardPixmap ( StandardPixmap  standardPixmap,
const QStyleOption opt,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 966 of file qwindowsstyle.cpp.

Referenced by standardIconImplementation(), QWindowsVistaStyle::standardPixmap(), QWindowsMobileStyle::standardPixmap(), QPlastiqueStyle::standardPixmap(), QWindowsCEStyle::standardPixmap(), QCleanlooksStyle::standardPixmap(), QWindowsXPStyle::standardPixmap(), and QMacStyle::standardPixmap().

968 {
969 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
970  QPixmap desktopIcon;
971  switch(standardPixmap) {
972  case SP_DriveCDIcon:
973  case SP_DriveDVDIcon:
974  {
975  desktopIcon = loadIconFromShell32(12, 16);
976  break;
977  }
978  case SP_DriveNetIcon:
979  {
980  desktopIcon = loadIconFromShell32(10, 16);
981  break;
982  }
983  case SP_DriveHDIcon:
984  {
985  desktopIcon = loadIconFromShell32(9, 16);
986  break;
987  }
988  case SP_DriveFDIcon:
989  {
990  desktopIcon = loadIconFromShell32(7, 16);
991  break;
992  }
993  case SP_FileIcon:
994  {
995  desktopIcon = loadIconFromShell32(1, 16);
996  break;
997  }
998  case SP_FileLinkIcon:
999  {
1000  desktopIcon = loadIconFromShell32(1, 16);
1001  QPainter painter(&desktopIcon);
1002  QPixmap link = loadIconFromShell32(30, 16);
1003  painter.drawPixmap(0, 0, 16, 16, link);
1004  break;
1005  }
1006  case SP_DirLinkIcon:
1007  {
1008  desktopIcon = loadIconFromShell32(4, 16);
1009  QPainter painter(&desktopIcon);
1010  QPixmap link = loadIconFromShell32(30, 16);
1011  painter.drawPixmap(0, 0, 16, 16, link);
1012  break;
1013  }
1014  case SP_DirClosedIcon:
1015  {
1016  desktopIcon = loadIconFromShell32(4, 16);
1017  break;
1018  }
1019  case SP_DesktopIcon:
1020  {
1021  desktopIcon = loadIconFromShell32(35, 16);
1022  break;
1023  }
1024  case SP_ComputerIcon:
1025  {
1026  desktopIcon = loadIconFromShell32(16, 16);
1027  break;
1028  }
1029  case SP_DirOpenIcon:
1030  {
1031  desktopIcon = loadIconFromShell32(5, 16);
1032  break;
1033  }
1035  {
1036  desktopIcon = loadIconFromShell32(319, 16);
1037  break;
1038  }
1039  case SP_DirHomeIcon:
1040  {
1041  desktopIcon = loadIconFromShell32(235, 16);
1042  break;
1043  }
1044  case SP_TrashIcon:
1045  {
1046  desktopIcon = loadIconFromShell32(191, 16);
1047  break;
1048  }
1050  {
1051  HICON iconHandle = LoadIcon(NULL, IDI_INFORMATION);
1052  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1053  DestroyIcon(iconHandle);
1054  break;
1055  }
1056  case SP_MessageBoxWarning:
1057  {
1058  HICON iconHandle = LoadIcon(NULL, IDI_WARNING);
1059  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1060  DestroyIcon(iconHandle);
1061  break;
1062  }
1063  case SP_MessageBoxCritical:
1064  {
1065  HICON iconHandle = LoadIcon(NULL, IDI_ERROR);
1066  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1067  DestroyIcon(iconHandle);
1068  break;
1069  }
1070  case SP_MessageBoxQuestion:
1071  {
1072  HICON iconHandle = LoadIcon(NULL, IDI_QUESTION);
1073  desktopIcon = QPixmap::fromWinHICON( iconHandle );
1074  DestroyIcon(iconHandle);
1075  break;
1076  }
1077  case SP_VistaShield:
1078  {
1082  {
1083  QPixmap pixmap;
1084  QSHSTOCKICONINFO iconInfo;
1085  memset(&iconInfo, 0, sizeof(iconInfo));
1086  iconInfo.cbSize = sizeof(iconInfo);
1087  if (pSHGetStockIconInfo(_SIID_SHIELD, _SHGFI_ICON | _SHGFI_SMALLICON, &iconInfo) == S_OK) {
1088  pixmap = QPixmap::fromWinHICON(iconInfo.hIcon);
1089  DestroyIcon(iconInfo.hIcon);
1090  return pixmap;
1091  }
1092  }
1093  }
1094  break;
1095  default:
1096  break;
1097  }
1098  if (!desktopIcon.isNull()) {
1099  return desktopIcon;
1100  }
1101 #endif
1102 #ifndef QT_NO_IMAGEFORMAT_XPM
1103  switch (standardPixmap) {
1104  case SP_TitleBarMenuButton:
1105  return QPixmap(qt_menu_xpm);
1107  return QPixmap(qt_shade_xpm);
1109  return QPixmap(qt_unshade_xpm);
1111  return QPixmap(qt_normalizeup_xpm);
1112  case SP_TitleBarMinButton:
1113  return QPixmap(qt_minimize_xpm);
1114  case SP_TitleBarMaxButton:
1115  return QPixmap(qt_maximize_xpm);
1117  return QPixmap(qt_close_xpm);
1119  return QPixmap(qt_help_xpm);
1123  return QPixmap(information_xpm);
1124  case SP_MessageBoxWarning:
1125  return QPixmap(warning_xpm);
1126  case SP_MessageBoxCritical:
1127  return QPixmap(critical_xpm);
1128  case SP_MessageBoxQuestion:
1129  return QPixmap(question_xpm);
1130  default:
1131  break;
1132  }
1133 #endif //QT_NO_IMAGEFORMAT_XPM
1134  return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
1135 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
static const char *const qt_close_xpm[]
static QPixmap fromWinHICON(HICON hicon)
static const char *const information_xpm[]
static const char *const qt_menu_xpm[]
static const char *const question_xpm[]
#define _SIID_SHIELD
static const char *const qt_shade_xpm[]
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
static const char *const qt_maximize_xpm[]
static const char *const qt_help_xpm[]
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
static const char * dock_widget_close_xpm[]
static const char *const qt_normalizeup_xpm[]
static const char *const warning_xpm[]
#define _SHGFI_ICON
static const char *const critical_xpm[]
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
static const char *const qt_minimize_xpm[]
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static QPixmap loadIconFromShell32(int resourceId, int size)
static const char *const qt_unshade_xpm[]
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
#define _SHGFI_SMALLICON
static PtrSHGetStockIconInfo pSHGetStockIconInfo

◆ styleHint()

int QWindowsStyle::styleHint ( StyleHint  hint,
const QStyleOption opt = 0,
const QWidget widget = 0,
QStyleHintReturn returnData = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 1138 of file qwindowsstyle.cpp.

Referenced by drawComplexControl(), drawControl(), drawPrimitive(), QPlastiqueStyle::styleHint(), QWindowsXPStyle::styleHint(), QCleanlooksStyle::styleHint(), QWindowsCEStyle::styleHint(), QWindowsMobileStyle::styleHint(), and QMacStyle::styleHint().

1140 {
1141  int ret = 0;
1142 
1143  switch (hint) {
1144  case SH_EtchDisabledText:
1145  case SH_Slider_SnapToValue:
1151  case SH_Menu_MouseTracking:
1155  ret = 1;
1156 
1157  break;
1159 #ifndef QT_NO_LISTVIEW
1160  if (qobject_cast<const QListView*>(widget))
1161  ret = 1;
1162 #endif
1163  break;
1165  ret = 1;
1166  break;
1168  ret = 0;
1169  break;
1170 
1171 #if defined(Q_WS_WIN)
1172  case SH_UnderlineShortcut:
1173  {
1174  ret = 1;
1175  BOOL cues = false;
1176  SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0);
1177  ret = int(cues);
1178  // Do nothing if we always paint underlines
1179  Q_D(const QWindowsStyle);
1180  if (!ret && widget && d) {
1181 #ifndef QT_NO_MENUBAR
1182  const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
1183  if (!menuBar && qobject_cast<const QMenu *>(widget)) {
1185  if (w && w != widget)
1186  menuBar = w->findChild<QMenuBar *>();
1187  }
1188  // If we paint a menu bar draw underlines if is in the keyboardState
1189  if (menuBar) {
1190  if (menuBar->d_func()->keyboardState || d->altDown())
1191  ret = 1;
1192  // Otherwise draw underlines if the toplevel widget has seen an alt-press
1193  } else
1194 #endif // QT_NO_MENUBAR
1195  if (d->hasSeenAlt(widget)) {
1196  ret = 1;
1197  }
1198  }
1199  break;
1200  }
1201 #endif
1202 #ifndef QT_NO_RUBBERBAND
1203  case SH_RubberBand_Mask:
1204  if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1205  ret = 0;
1206  if (rbOpt->shape == QRubberBand::Rectangle) {
1207  ret = true;
1208  if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
1209  mask->region = opt->rect;
1210  int size = 1;
1211  if (widget && widget->isWindow())
1212  size = 4;
1213  mask->region -= opt->rect.adjusted(size, size, -size, -size);
1214  }
1215  }
1216  }
1217  break;
1218 #endif // QT_NO_RUBBERBAND
1220  {
1221 #ifdef Q_WS_WIN
1223  const QFontMetrics &fm = widget->fontMetrics();
1224  if (fm.inFont(QChar(0x25CF)))
1225  ret = 0x25CF;
1226  else if (fm.inFont(QChar(0x2022)))
1227  ret = 0x2022;
1228  }
1229 #endif
1230  if (!ret)
1231  ret = '*';
1232  }
1233  break;
1234 #ifndef QT_NO_WIZARD
1235  case SH_WizardStyle:
1236  ret = QWizard::ModernStyle;
1237  break;
1238 #endif
1240  ret = true;
1241  break;
1243  ret = 0;
1244  break;
1245  default:
1246  ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
1247  break;
1248  }
1249  return ret;
1250 }
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
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
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
#define Q_D(Class)
Definition: qglobal.h:2482
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
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 inFont(QChar) const
Returns true if character ch is a valid character in the font; otherwise returns false.
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
#define SPI_GETKEYBOARDCUES
Definition: qt_windows.h:107
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function

◆ subElementRect()

QRect QWindowsStyle::subElementRect ( SubElement  r,
const QStyleOption opt,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 2588 of file qwindowsstyle.cpp.

Referenced by drawComplexControl(), drawControl(), QWindowsVistaStyle::subElementRect(), QPlastiqueStyle::subElementRect(), QWindowsXPStyle::subElementRect(), QCleanlooksStyle::subElementRect(), QWindowsMobileStyle::subElementRect(), QWindowsCEStyle::subElementRect(), QMacStyle::subElementRect(), and QStyleSheetStyle::subElementRect().

2589 {
2590  QRect r;
2591  switch (sr) {
2592  case SE_SliderFocusRect:
2593  case SE_ToolBoxTabContents:
2594  r = visualRect(opt->direction, opt->rect, opt->rect);
2595  break;
2597  r = QCommonStyle::subElementRect(sr, opt, w);
2598  const QStyleOptionDockWidgetV2 *v2
2600  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2601  int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
2602  if (verticalTitleBar) {
2603  r.adjust(0, 0, 0, -m);
2604  } else {
2605  if (opt->direction == Qt::LeftToRight)
2606  r.adjust(m, 0, 0, 0);
2607  else
2608  r.adjust(0, 0, -m, 0);
2609  }
2610  break;
2611  }
2614  r.adjust(3, 3, -3, -3);
2615  break;
2616  default:
2617  r = QCommonStyle::subElementRect(sr, opt, w);
2618  }
2619  return r;
2620 }
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
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
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
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
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ timerEvent()

void QWindowsStyle::timerEvent ( QTimerEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 166 of file qwindowsstyle.cpp.

Referenced by QWindowsVistaStyle::event().

167 {
168 #ifndef QT_NO_PROGRESSBAR
170  if (event->timerId() == d->animateTimer) {
171  Q_ASSERT(d->animationFps> 0);
172  d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
173  foreach (QProgressBar *bar, d->animatedProgressBars)
174  bar->update();
175  }
176 #endif // QT_NO_PROGRESSBAR
177  event->ignore();
178 }
double d
Definition: qnumeric_p.h:62
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57

◆ unpolish() [1/2]

void QWindowsStyle::unpolish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsVistaStyle, and QWindowsXPStyle.

Definition at line 340 of file qwindowsstyle.cpp.

Referenced by QWindowsXPStyle::unpolish(), QMacStyle::unpolish(), QPlastiqueStyle::unpolish(), QWindowsMobileStyle::unpolish(), QCleanlooksStyle::unpolish(), and QStyleSheetStyle::unpolish().

341 {
343  app->removeEventFilter(this);
344 }
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
void unpolish(QWidget *widget)
Reimplemented Function

◆ unpolish() [2/2]

void QWindowsStyle::unpolish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Reimplemented in QWindowsVistaStyle, and QWindowsXPStyle.

Definition at line 357 of file qwindowsstyle.cpp.

358 {
359  QCommonStyle::unpolish(widget);
360 #ifndef QT_NO_PROGRESSBAR
361  if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
363  widget->removeEventFilter(this);
364  d->stopAnimation(this, bar);
365  }
366 #endif
367 }
double d
Definition: qnumeric_p.h:62
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
#define Q_D(Class)
Definition: qglobal.h:2482
void unpolish(QWidget *widget)
Reimplemented Function
The QWindowsStyle class provides a Microsoft Windows-like look and feel.
Definition: qwindowsstyle.h:57

Properties

◆ reserved

void* QWindowsStyle::reserved
private

Definition at line 102 of file qwindowsstyle.h.


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