Qt 4.8
Public Functions | Public Variables | Static Public Variables | Protected Slots | Protected Functions | Private Types | Private Functions | Static Private Functions | Properties | Friends | List of all members
QStyleSheetStyle Class Reference

#include <qstylesheetstyle_p.h>

Inheritance diagram for QStyleSheetStyle:
QWindowsStyle QCommonStyle QStyle QObject

Public Functions

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

Public Variables

QStylebase
 

Static Public Variables

static int numinstances = 0
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 

Protected Slots

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

Protected Functions

bool event (QEvent *e)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
- Protected Functions inherited from QWindowsStyle
bool eventFilter (QObject *o, QEvent *e)
 Reimplemented Function More...
 
 QWindowsStyle (QWindowsStylePrivate &dd)
 Constructs a QWindowsStyle object. More...
 
void timerEvent (QTimerEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QCommonStyle
 QCommonStyle (QCommonStylePrivate &dd)
 
- Protected Functions inherited from QStyle
 QStyle (QStylePrivate &dd)
 Constructs a style object. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 

Private Types

typedef QWindowsStyle ParentStyle
 

Private Functions

QSize defaultSize (const QWidget *, QSize, const QRect &, int) const
 
QCss::StyleSheet getDefaultStyleSheet () const
 
bool hasStyleRule (const QWidget *w, int part) const
 
bool initWidget (const QWidget *w) const
 Make sure that the cache will be clean by connecting destroyed if needed. More...
 
int nativeFrameWidth (const QWidget *)
 
QRect positionRect (const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
 
QRect positionRect (const QWidget *w, const QRenderRule &rule2, int pe, const QRect &originRect, Qt::LayoutDirection dir) const
 
QRenderRule renderRule (const QWidget *, int, quint64=0) const
 
QRenderRule renderRule (const QWidget *, const QStyleOption *, int=0) const
 
void setGeometry (QWidget *)
 
void setPalette (QWidget *)
 
void setProperties (QWidget *)
 
QVector< QCss::StyleRulestyleRules (const QWidget *w) const
 
QHash< QStyle::SubControl, QRecttitleBarLayout (const QWidget *w, const QStyleOptionTitleBar *tb) const
 
void unsetPalette (QWidget *)
 

Static Private Functions

static bool isNaturalChild (const QWidget *w)
 
static Qt::Alignment resolveAlignment (Qt::LayoutDirection, Qt::Alignment)
 

Properties

QCss::Parser parser
 
int refcount
 

Friends

class QRenderRule
 

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

Detailed Description

Definition at line 75 of file qstylesheetstyle_p.h.

Typedefs

◆ ParentStyle

Definition at line 77 of file qstylesheetstyle_p.h.

Constructors and Destructors

◆ QStyleSheetStyle()

QStyleSheetStyle::QStyleSheetStyle ( QStyle baseStyle)

Definition at line 2613 of file qstylesheetstyle.cpp.

2615 {
2616  ++numinstances;
2617  if (numinstances == 1) {
2619  }
2620 }
static QStyleSheetStyleCaches * styleSheetCaches
QWindowsStyle()
Constructs a QWindowsStyle object.

◆ ~QStyleSheetStyle()

QStyleSheetStyle::~QStyleSheetStyle ( )

Definition at line 2622 of file qstylesheetstyle.cpp.

2623 {
2624  --numinstances;
2625  if (numinstances == 0) {
2626  delete styleSheetCaches;
2627  }
2628 }
static QStyleSheetStyleCaches * styleSheetCaches

Functions

◆ baseStyle()

QStyle * QStyleSheetStyle::baseStyle ( ) const

◆ clearWidgetFont()

void QStyleSheetStyle::clearWidgetFont ( QWidget w) const

Definition at line 5846 of file qstylesheetstyle.cpp.

5847 {
5848  w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid));
5849 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755

◆ defaultSize()

QSize QStyleSheetStyle::defaultSize ( const QWidget w,
QSize  sz,
const QRect rect,
int  pe 
) const
private

Definition at line 2160 of file qstylesheetstyle.cpp.

2161 {
2162  QStyle *base = baseStyle();
2163 
2164  switch (pe) {
2167  if (sz.width() == -1)
2168  sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w));
2169  if (sz.height() == -1)
2170  sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w));
2171  break;
2172 
2175  if (sz.width() == -1)
2177  if (sz.height() == -1)
2179  break;
2180 
2182  int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w);
2183  if (sz.width() == -1)
2184  sz.setWidth(pm);
2185  if (sz.height() == -1)
2186  sz.setHeight(pm);
2187  }
2188  break;
2189 
2191  if (sz.width() == -1)
2192  sz.setWidth(16);
2193  break;
2194 
2200  if (sz.width() == -1)
2201  sz.setWidth(13);
2202  if (sz.height() == -1)
2203  sz.setHeight(13);
2204  break;
2205 
2208  if (sz.width() == -1)
2209  sz.setWidth(16);
2210  if (sz.height() == -1)
2211  sz.setHeight(rect.height()/2);
2212  break;
2213 
2215  if (sz.width() == -1)
2216  sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w));
2217  break;
2218 
2221  int pm = base->pixelMetric(PM_HeaderMargin, 0, w);
2222  if (sz.width() == -1)
2223  sz.setWidth(pm);
2224  if (sz.height() == 1)
2225  sz.setHeight(pm);
2226  break;
2227  }
2228 
2234  int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w);
2235  if (sz.width() == -1)
2236  sz.setWidth(pm);
2237  if (sz.height() == -1)
2238  sz.setHeight(pm);
2239  break;
2240  }
2241 
2244  int iconSize = pixelMetric(PM_SmallIconSize, 0, w);
2245  return QSize(iconSize, iconSize);
2246  }
2247 
2248  default:
2249  break;
2250  }
2251 
2252  // expand to rectangle
2253  if (sz.height() == -1)
2254  sz.setHeight(rect.height());
2255  if (sz.width() == -1)
2256  sz.setWidth(rect.width());
2257 
2258  return sz;
2259 }
QStyle * baseStyle() const
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
int width() const
Returns the width.
Definition: qsize.h:126
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ deref()

void QStyleSheetStyle::deref ( )
inline

Definition at line 128 of file qstylesheetstyle_p.h.

128 { Q_ASSERT(refcount > 0); if (!--refcount) delete this; }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ drawComplexControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2845 of file qstylesheetstyle.cpp.

2847 {
2848  RECURSION_GUARD(baseStyle()->drawComplexControl(cc, opt, p, w); return)
2849 
2850  QRenderRule rule = renderRule(w, opt);
2851 
2852  switch (cc) {
2853  case CC_ComboBox:
2854  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2855  QStyleOptionComboBox cmbOpt(*cmb);
2856  cmbOpt.rect = rule.borderRect(opt->rect);
2857  if (rule.hasNativeBorder()) {
2858  rule.drawBackgroundImage(p, cmbOpt.rect);
2859  rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button);
2860  bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow)
2862  if (customDropDown)
2863  cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow;
2864  if (rule.baseStyleCanDraw()) {
2865  baseStyle()->drawComplexControl(cc, &cmbOpt, p, w);
2866  } else {
2867  QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
2868  }
2869  if (!customDropDown)
2870  return;
2871  } else {
2872  rule.drawRule(p, opt->rect);
2873  }
2874 
2877  if (subRule.hasDrawable()) {
2879  subRule.drawRule(p, r);
2881  r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction);
2882  subRule2.drawRule(p, r);
2883  } else {
2884  cmbOpt.subControls = QStyle::SC_ComboBoxArrow;
2885  QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
2886  }
2887  }
2888 
2889  return;
2890  }
2891  break;
2892 
2893 #ifndef QT_NO_SPINBOX
2894  case CC_SpinBox:
2895  if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
2896  QStyleOptionSpinBox spinOpt(*spin);
2897  rule.configurePalette(&spinOpt.palette, QPalette::ButtonText, QPalette::Button);
2898  rule.configurePalette(&spinOpt.palette, QPalette::Text, QPalette::Base);
2899  spinOpt.rect = rule.borderRect(opt->rect);
2900  bool customUp = true, customDown = true;
2903  bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
2904  bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
2905  if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
2906  rule.drawBackgroundImage(p, spinOpt.rect);
2907  customUp = (opt->subControls & QStyle::SC_SpinBoxUp)
2909  if (customUp)
2910  spinOpt.subControls &= ~QStyle::SC_SpinBoxUp;
2911  customDown = (opt->subControls & QStyle::SC_SpinBoxDown)
2913  if (customDown)
2914  spinOpt.subControls &= ~QStyle::SC_SpinBoxDown;
2915  if (rule.baseStyleCanDraw()) {
2916  baseStyle()->drawComplexControl(cc, &spinOpt, p, w);
2917  } else {
2918  QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
2919  }
2920  if (!customUp && !customDown)
2921  return;
2922  } else {
2923  rule.drawRule(p, opt->rect);
2924  }
2925 
2926  if ((opt->subControls & QStyle::SC_SpinBoxUp) && customUp) {
2928  if (subRule.hasDrawable()) {
2930  subRule.drawRule(p, r);
2932  r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxUpArrow, r, opt->direction);
2933  subRule2.drawRule(p, r);
2934  } else {
2935  spinOpt.subControls = QStyle::SC_SpinBoxUp;
2936  QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
2937  }
2938  }
2939 
2940  if ((opt->subControls & QStyle::SC_SpinBoxDown) && customDown) {
2942  if (subRule.hasDrawable()) {
2944  subRule.drawRule(p, r);
2946  r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxDownArrow, r, opt->direction);
2947  subRule2.drawRule(p, r);
2948  } else {
2949  spinOpt.subControls = QStyle::SC_SpinBoxDown;
2950  QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
2951  }
2952  }
2953  return;
2954  }
2955  break;
2956 #endif // QT_NO_SPINBOX
2957 
2958  case CC_GroupBox:
2959  if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
2960 
2961  QRect labelRect, checkBoxRect, titleRect, frameRect;
2962  bool hasTitle = (gb->subControls & QStyle::SC_GroupBoxCheckBox) || !gb->text.isEmpty();
2963 
2964  if (!rule.hasDrawable() && (!hasTitle || !hasStyleRule(w, PseudoElement_GroupBoxTitle))
2965  && !hasStyleRule(w, PseudoElement_Indicator) && !rule.hasBox() && !rule.hasFont && !rule.hasPalette()) {
2966  // let the native style draw the combobox if there is no style for it.
2967  break;
2968  }
2969  rule.drawBackground(p, opt->rect);
2970 
2971  QRenderRule titleRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
2972  bool clipSet = false;
2973 
2974  if (hasTitle) {
2975  labelRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w);
2976  //Some native style (such as mac) may return a too small rectangle (because they use smaller fonts), so we may need to expand it a little bit.
2977  labelRect.setSize(labelRect.size().expandedTo(ParentStyle::subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w).size()));
2978  if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
2979  checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, w);
2980  titleRect = titleRule.boxRect(checkBoxRect.united(labelRect));
2981  } else {
2982  titleRect = titleRule.boxRect(labelRect);
2983  }
2984  if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) {
2985  clipSet = true;
2986  p->save();
2987  p->setClipRegion(QRegion(opt->rect) - titleRect);
2988  }
2989  }
2990 
2991  frameRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, w);
2992  QStyleOptionFrameV2 frame;
2993  frame.QStyleOption::operator=(*gb);
2994  frame.features = gb->features;
2995  frame.lineWidth = gb->lineWidth;
2996  frame.midLineWidth = gb->midLineWidth;
2997  frame.rect = frameRect;
2998  drawPrimitive(PE_FrameGroupBox, &frame, p, w);
2999 
3000  if (clipSet)
3001  p->restore();
3002 
3003  // draw background and frame of the title
3004  if (hasTitle)
3005  titleRule.drawRule(p, titleRect);
3006 
3007  // draw the indicator
3008  if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
3009  QStyleOptionButton box;
3010  box.QStyleOption::operator=(*gb);
3011  box.rect = checkBoxRect;
3012  drawPrimitive(PE_IndicatorCheckBox, &box, p, w);
3013  }
3014 
3015  // draw the text
3016  if (!gb->text.isEmpty()) {
3017  int alignment = int(Qt::AlignCenter | Qt::TextShowMnemonic);
3018  if (!styleHint(QStyle::SH_UnderlineShortcut, opt, w)) {
3019  alignment |= Qt::TextHideMnemonic;
3020  }
3021 
3022  QPalette pal = gb->palette;
3023  if (gb->textColor.isValid())
3024  pal.setColor(QPalette::WindowText, gb->textColor);
3026  drawItemText(p, labelRect, alignment, pal, gb->state & State_Enabled,
3027  gb->text, QPalette::WindowText);
3028 
3029  if (gb->state & State_HasFocus) {
3030  QStyleOptionFocusRect fropt;
3031  fropt.QStyleOption::operator=(*gb);
3032  fropt.rect = labelRect;
3033  drawPrimitive(PE_FrameFocusRect, &fropt, p, w);
3034  }
3035  }
3036 
3037  return;
3038  }
3039  break;
3040 
3041  case CC_ToolButton:
3042  if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3043  QStyleOptionToolButton toolOpt(*tool);
3044  rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button);
3045  toolOpt.font = rule.font.resolve(toolOpt.font);
3046  toolOpt.rect = rule.borderRect(opt->rect);
3047  bool customArrow = (tool->features & (QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup));
3048  bool customDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup;
3049  if (rule.hasNativeBorder()) {
3050  if (tool->subControls & SC_ToolButton) {
3051  //in some case (eg. the button is "auto raised") the style doesn't draw the background
3052  //so we need to draw the background.
3053  // use the same condition as in QCommonStyle
3054  State bflags = tool->state & ~State_Sunken;
3055  if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled)))
3056  bflags &= ~State_Raised;
3057  if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton)
3058  bflags |= State_Sunken;
3059  if (!(bflags & (State_Sunken | State_On | State_Raised)))
3060  rule.drawBackground(p, toolOpt.rect);
3061  }
3062  customArrow = customArrow && hasStyleRule(w, PseudoElement_ToolButtonDownArrow);
3063  if (customArrow)
3064  toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
3065  customDropDown = customDropDown && hasStyleRule(w, PseudoElement_ToolButtonMenu);
3066  if (customDropDown)
3067  toolOpt.subControls &= ~QStyle::SC_ToolButtonMenu;
3068 
3069  if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) {
3070  baseStyle()->drawComplexControl(cc, &toolOpt, p, w);
3071  } else {
3072  QWindowsStyle::drawComplexControl(cc, &toolOpt, p, w);
3073  }
3074 
3075  if (!customArrow && !customDropDown)
3076  return;
3077  } else {
3078  rule.drawRule(p, opt->rect);
3079  toolOpt.rect = rule.contentsRect(opt->rect);
3080  if (rule.hasFont)
3081  toolOpt.font = rule.font;
3082  drawControl(CE_ToolButtonLabel, &toolOpt, p, w);
3083  }
3084 
3087  if (customDropDown) {
3089  if (subRule.hasDrawable()) {
3090  subRule.drawRule(p, r);
3091  } else {
3092  toolOpt.rect = r;
3094  }
3095  }
3096  }
3097 
3098  if (customArrow) {
3099  QRenderRule subRule2 = customDropDown ? renderRule(w, opt, PseudoElement_ToolButtonMenuArrow)
3100  : renderRule(w, opt, PseudoElement_ToolButtonDownArrow);
3101  QRect r2 = customDropDown
3102  ? positionRect(w, subRule, subRule2, PseudoElement_ToolButtonMenuArrow, r, opt->direction)
3103  : positionRect(w, rule, subRule2, PseudoElement_ToolButtonDownArrow, opt->rect, opt->direction);
3104  if (subRule2.hasDrawable()) {
3105  subRule2.drawRule(p, r2);
3106  } else {
3107  toolOpt.rect = r2;
3109  }
3110  }
3111 
3112  return;
3113  }
3114  break;
3115 
3116 #ifndef QT_NO_SCROLLBAR
3117  case CC_ScrollBar:
3118  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3119  QStyleOptionSlider sbOpt(*sb);
3120  if (!rule.hasDrawable()) {
3121  sbOpt.rect = rule.borderRect(opt->rect);
3122  rule.drawBackgroundImage(p, opt->rect);
3123  baseStyle()->drawComplexControl(cc, &sbOpt, p, w);
3124  } else {
3125  rule.drawRule(p, opt->rect);
3126  QWindowsStyle::drawComplexControl(cc, opt, p, w);
3127  }
3128  return;
3129  }
3130  break;
3131 #endif // QT_NO_SCROLLBAR
3132 
3133 #ifndef QT_NO_SLIDER
3134  case CC_Slider:
3135  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3136  rule.drawRule(p, opt->rect);
3137 
3138  QRenderRule grooveSubRule = renderRule(w, opt, PseudoElement_SliderGroove);
3139  QRenderRule handleSubRule = renderRule(w, opt, PseudoElement_SliderHandle);
3140  if (!grooveSubRule.hasDrawable()) {
3141  QStyleOptionSlider slOpt(*slider);
3142  bool handleHasRule = handleSubRule.hasDrawable();
3143  // If the style specifies a different handler rule, draw the groove without the handler.
3144  if (handleHasRule)
3145  slOpt.subControls &= ~SC_SliderHandle;
3146  baseStyle()->drawComplexControl(cc, &slOpt, p, w);
3147  if (!handleHasRule)
3148  return;
3149  }
3150 
3151  QRect gr = subControlRect(cc, opt, SC_SliderGroove, w);
3152  if (slider->subControls & SC_SliderGroove) {
3153  grooveSubRule.drawRule(p, gr);
3154  }
3155 
3156  if (slider->subControls & SC_SliderHandle) {
3157  QRect hr = subControlRect(cc, opt, SC_SliderHandle, w);
3158 
3160  if (subRule1.hasDrawable()) {
3161  QRect r(gr.topLeft(),
3162  slider->orientation == Qt::Horizontal
3163  ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1)
3164  : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2));
3165  subRule1.drawRule(p, r);
3166  }
3167 
3169  if (subRule2.hasDrawable()) {
3170  QRect r(slider->orientation == Qt::Horizontal
3171  ? QPoint(hr.x()+hr.width()/2+1, gr.y())
3172  : QPoint(gr.x(), hr.y()+hr.height()/2+1),
3173  gr.bottomRight());
3174  subRule2.drawRule(p, r);
3175  }
3176 
3177  handleSubRule.drawRule(p, handleSubRule.boxRect(hr, Margin));
3178  }
3179 
3180  if (slider->subControls & SC_SliderTickmarks) {
3181  // TODO...
3182  }
3183 
3184  return;
3185  }
3186  break;
3187 #endif // QT_NO_SLIDER
3188 
3189  case CC_MdiControls:
3193  QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
3194  if (layout.isEmpty())
3195  layout = subControlLayout(QLatin1String("mNX"));
3196 
3197  QStyleOptionComplex optCopy(*opt);
3198  optCopy.subControls = 0;
3199  for (int i = 0; i < layout.count(); i++) {
3200  int layoutButton = layout[i].toInt();
3201  if (layoutButton < PseudoElement_MdiCloseButton
3202  || layoutButton > PseudoElement_MdiNormalButton)
3203  continue;
3204  QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
3205  if (!(opt->subControls & control))
3206  continue;
3207  QRenderRule subRule = renderRule(w, opt, layoutButton);
3208  if (subRule.hasDrawable()) {
3209  QRect rect = subRule.boxRect(subControlRect(CC_MdiControls, opt, control, w), Margin);
3210  subRule.drawRule(p, rect);
3211  QIcon icon = standardIcon(subControlIcon(layoutButton), opt);
3212  icon.paint(p, subRule.contentsRect(rect), Qt::AlignCenter);
3213  } else {
3214  optCopy.subControls |= control;
3215  }
3216  }
3217 
3218  if (optCopy.subControls)
3219  baseStyle()->drawComplexControl(CC_MdiControls, &optCopy, p, w);
3220  return;
3221  }
3222  break;
3223 
3224  case CC_TitleBar:
3225  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
3226  QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
3227  if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
3228  break;
3229  subRule.drawRule(p, opt->rect);
3231 
3232  QRect ir;
3233  ir = layout[SC_TitleBarLabel];
3234  if (ir.isValid()) {
3235  if (subRule.hasPalette())
3236  p->setPen(subRule.palette()->foreground.color());
3237  p->fillRect(ir, Qt::white);
3238  p->drawText(ir.x(), ir.y(), ir.width(), ir.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
3239  }
3240 
3241  QPixmap pm;
3242 
3243  ir = layout[SC_TitleBarSysMenu];
3244  if (ir.isValid()) {
3246  subSubRule.drawRule(p, ir);
3247  ir = subSubRule.contentsRect(ir);
3248  if (!tb->icon.isNull()) {
3249  tb->icon.paint(p, ir);
3250  } else {
3251  int iconSize = pixelMetric(PM_SmallIconSize, tb, w);
3252  pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize);
3253  drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3254  }
3255  }
3256 
3257  ir = layout[SC_TitleBarCloseButton];
3258  if (ir.isValid()) {
3260  subSubRule.drawRule(p, ir);
3261 
3262  QSize sz = subSubRule.contentsRect(ir).size();
3263  if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool)
3265  else
3266  pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz);
3267  drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3268  }
3269 
3270  int pes[] = {
3277  };
3278 
3279  for (unsigned int i = 0; i < sizeof(pes)/sizeof(int); i++) {
3280  int pe = pes[i];
3282  ir = layout[sc];
3283  if (!ir.isValid())
3284  continue;
3285  QRenderRule subSubRule = renderRule(w, opt, pe);
3286  subSubRule.drawRule(p, ir);
3287  pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size());
3288  drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3289  }
3290 
3291  return;
3292  }
3293  break;
3294 
3295 
3296  default:
3297  break;
3298  }
3299 
3300  baseStyle()->drawComplexControl(cc, opt, p, w);
3301 }
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
static QList< QVariant > subControlLayout(const QString &layout)
bool hasGeometry() const
bool hasStyleRule(const QWidget *w, int part) const
QStyle * baseStyle() const
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
const QStyleSheetBackgroundData * background() const
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
bool hasBackground() const
void drawItemText(QPainter *painter, const QRect &rect, int alignment, 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.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool hasPosition() const
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect boxRect(const QRect &r, int flags=All) const
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool)
QStyle::SubControl subControl
static QStyle::StandardPixmap subControlIcon(int pe)
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QRect contentsRect(const QRect &r) const
virtual ~QStyle()
Destroys the style object.
Definition: qstyle.cpp:362
const QStyleSheetPaletteData * palette() const
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
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.
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const char * layout
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
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...
The State element defines configurations of objects and properties.
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
FrameFeatures features
a bitwise OR of the features that describe this frame.
Definition: qstyleoption.h:143
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QHash< QStyle::SubControl, QRect > titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
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 y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
bool hasBorder() const
bool hasBox() const
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
bool hasDrawable() const
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
#define RECURSION_GUARD(RETURN)
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
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
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
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
bool hasPalette() const
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
void drawRule(QPainter *, const QRect &)
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
Definition: qicon.cpp:744
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
Qt::LayoutDirection direction
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ drawControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 3303 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl().

3305 {
3306  RECURSION_GUARD(baseStyle()->drawControl(ce, opt, p, w); return)
3307 
3308  QRenderRule rule = renderRule(w, opt);
3309  int pe1 = PseudoElement_None, pe2 = PseudoElement_None;
3310  bool fallback = false;
3311 
3312  switch (ce) {
3313  case CE_ToolButtonLabel:
3314  if (const QStyleOptionToolButton *btn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3315  if (rule.hasBox() || btn->features & QStyleOptionToolButton::Arrow) {
3316  QCommonStyle::drawControl(ce, opt, p, w);
3317  } else {
3318  QStyleOptionToolButton butOpt(*btn);
3319  rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
3320  baseStyle()->drawControl(ce, &butOpt, p, w);
3321  }
3322  return;
3323  }
3324  break;
3325 
3326  case CE_FocusFrame:
3327  if (!rule.hasNativeBorder()) {
3328  rule.drawBorder(p, opt->rect);
3329  return;
3330  }
3331  break;
3332 
3333  case CE_PushButton:
3334  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3335  if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() ||
3337  ParentStyle::drawControl(ce, opt, p, w);
3338  return;
3339  }
3340  }
3341  break;
3342  case CE_PushButtonBevel:
3343  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3344  QStyleOptionButton btnOpt(*btn);
3345  btnOpt.rect = rule.borderRect(opt->rect);
3346  if (rule.hasNativeBorder()) {
3347  rule.drawBackgroundImage(p, btnOpt.rect);
3348  rule.configurePalette(&btnOpt.palette, QPalette::ButtonText, QPalette::Button);
3349  bool customMenu = (btn->features & QStyleOptionButton::HasMenu
3351  if (customMenu)
3352  btnOpt.features &= ~QStyleOptionButton::HasMenu;
3353  if (rule.baseStyleCanDraw()) {
3354  baseStyle()->drawControl(ce, &btnOpt, p, w);
3355  } else {
3356  QWindowsStyle::drawControl(ce, &btnOpt, p, w);
3357  }
3358  if (!customMenu)
3359  return;
3360  } else {
3361  rule.drawRule(p, opt->rect);
3362  }
3363 
3364  if (btn->features & QStyleOptionButton::HasMenu) {
3366  QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction);
3367  if (subRule.hasDrawable()) {
3368  subRule.drawRule(p, ir);
3369  } else {
3370  btnOpt.rect = ir;
3371  baseStyle()->drawPrimitive(PE_IndicatorArrowDown, &btnOpt, p, w);
3372  }
3373  }
3374  }
3375  return;
3376 
3377  case CE_PushButtonLabel:
3378  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3379  QStyleOptionButton butOpt(*button);
3380  rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
3381 
3382  const QFont oldFont = p->font();
3383  if (rule.hasFont)
3384  p->setFont(rule.font);
3385 
3386  if (rule.hasPosition() && rule.position()->textAlignment != 0) {
3387  Qt::Alignment textAlignment = rule.position()->textAlignment;
3388  QRect textRect = button->rect;
3390  const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
3391  tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
3392  if (!styleHint(SH_UnderlineShortcut, button, w))
3393  tf |= Qt::TextHideMnemonic;
3394  if (!button->icon.isNull()) {
3395  //Group both icon and text
3396  QRect iconRect;
3397  QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
3398  if (mode == QIcon::Normal && button->state & State_HasFocus)
3399  mode = QIcon::Active;
3400  QIcon::State state = QIcon::Off;
3401  if (button->state & State_On)
3402  state = QIcon::On;
3403 
3404  QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
3405  int labelWidth = pixmap.width();
3406  int labelHeight = pixmap.height();
3407  int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
3408  int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
3409  if (!button->text.isEmpty())
3410  labelWidth += (textWidth + iconSpacing);
3411 
3412  //Determine label alignment:
3413  if (textAlignment & Qt::AlignLeft) { /*left*/
3414  iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
3415  pixmap.width(), pixmap.height());
3416  } else if (textAlignment & Qt::AlignHCenter) { /* center */
3417  iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
3418  textRect.y() + (textRect.height() - labelHeight) / 2,
3419  pixmap.width(), pixmap.height());
3420  } else { /*right*/
3421  iconRect = QRect(textRect.x() + textRect.width() - labelWidth,
3422  textRect.y() + (textRect.height() - labelHeight) / 2,
3423  pixmap.width(), pixmap.height());
3424  }
3425 
3426  iconRect = visualRect(button->direction, textRect, iconRect);
3427 
3428  tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
3429 
3430  if (button->direction == Qt::RightToLeft)
3431  textRect.setRight(iconRect.left() - iconSpacing);
3432  else
3433  textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
3434 
3435  if (button->state & (State_On | State_Sunken))
3438  p->drawPixmap(iconRect, pixmap);
3439  } else {
3440  tf |= textAlignment;
3441  }
3442  if (button->state & (State_On | State_Sunken))
3445 
3446  if (button->features & QStyleOptionButton::HasMenu) {
3447  int indicatorSize = pixelMetric(PM_MenuButtonIndicator, button, w);
3448  if (button->direction == Qt::LeftToRight)
3449  textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
3450  else
3451  textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
3452  }
3453  drawItemText(p, textRect, tf, butOpt.palette, (button->state & State_Enabled),
3454  button->text, QPalette::ButtonText);
3455  } else {
3456  ParentStyle::drawControl(ce, &butOpt, p, w);
3457  }
3458 
3459  if (rule.hasFont)
3460  p->setFont(oldFont);
3461  }
3462  return;
3463 
3464  case CE_RadioButton:
3465  case CE_CheckBox:
3466  if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
3467  rule.drawRule(p, opt->rect);
3468  ParentStyle::drawControl(ce, opt, p, w);
3469  return;
3470  } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3471  QStyleOptionButton butOpt(*btn);
3472  rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
3473  baseStyle()->drawControl(ce, &butOpt, p, w);
3474  return;
3475  }
3476  break;
3477  case CE_RadioButtonLabel:
3478  case CE_CheckBoxLabel:
3479  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3480  QStyleOptionButton butOpt(*btn);
3481  rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
3482  ParentStyle::drawControl(ce, &butOpt, p, w);
3483  }
3484  return;
3485 
3486  case CE_Splitter:
3488  break;
3489 
3490  case CE_ToolBar:
3491  if (rule.hasBackground()) {
3492  rule.drawBackground(p, opt->rect);
3493  }
3494  if (rule.hasBorder()) {
3495  rule.drawBorder(p, rule.borderRect(opt->rect));
3496  } else {
3497 #ifndef QT_NO_TOOLBAR
3498  if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
3499  QStyleOptionToolBar newTb(*tb);
3500  newTb.rect = rule.borderRect(opt->rect);
3501  baseStyle()->drawControl(ce, &newTb, p, w);
3502  }
3503 #endif // QT_NO_TOOLBAR
3504  }
3505  return;
3506 
3507  case CE_MenuEmptyArea:
3508  case CE_MenuBarEmptyArea:
3509  if (rule.hasDrawable()) {
3510  // Drawn by PE_Widget
3511  return;
3512  }
3513  break;
3514 
3515  case CE_MenuTearoff:
3516  case CE_MenuScroller:
3517  if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3518  QStyleOptionMenuItem mi(*m);
3520  QRenderRule subRule = renderRule(w, opt, pe);
3521  mi.rect = subRule.contentsRect(opt->rect);
3522  rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
3524 
3525  if (subRule.hasDrawable()) {
3526  subRule.drawRule(p, opt->rect);
3527  } else {
3528  baseStyle()->drawControl(ce, &mi, p, w);
3529  }
3530  }
3531  return;
3532 
3533  case CE_MenuItem:
3534  if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3535  QStyleOptionMenuItem mi(*m);
3536 
3538  QRenderRule subRule = renderRule(w, opt, pseudo);
3539  mi.rect = subRule.contentsRect(opt->rect);
3540  rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
3541  rule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
3544  QFont oldFont = p->font();
3545  if (subRule.hasFont)
3546  p->setFont(subRule.font.resolve(p->font()));
3547 
3548  // We fall back to drawing with the style sheet code whenever at least one of the
3549  // items are styled in an incompatible way, such as having a background image.
3551 
3552  if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
3553  subRule.drawRule(p, opt->rect);
3554  } else if ((pseudo == PseudoElement_Item)
3555  && (allRules.hasBox() || allRules.hasBorder()
3556  || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
3557  subRule.drawRule(p, opt->rect);
3558  if (subRule.hasBackground()) {
3559  mi.palette.setBrush(QPalette::Highlight, Qt::NoBrush);
3560  mi.palette.setBrush(QPalette::Button, Qt::NoBrush);
3561  } else {
3562  mi.palette.setBrush(QPalette::Highlight, mi.palette.brush(QPalette::Button));
3563  }
3564  mi.palette.setBrush(QPalette::HighlightedText, mi.palette.brush(QPalette::ButtonText));
3565 
3566  bool checkable = mi.checkType != QStyleOptionMenuItem::NotCheckable;
3567  bool checked = checkable ? mi.checked : false;
3568 
3569  bool dis = !(opt->state & QStyle::State_Enabled),
3570  act = opt->state & QStyle::State_Selected;
3571 
3572  if (!mi.icon.isNull()) {
3573  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
3574  if (act && !dis)
3575  mode = QIcon::Active;
3576  QPixmap pixmap;
3577  if (checked)
3578  pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
3579  else
3580  pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
3581  int pixw = pixmap.width();
3582  int pixh = pixmap.height();
3583  QRenderRule iconRule = renderRule(w, opt, PseudoElement_MenuIcon);
3584  if (!iconRule.hasGeometry()) {
3585  iconRule.geo = new QStyleSheetGeometryData(pixw, pixh, pixw, pixh, -1, -1);
3586  } else {
3587  iconRule.geo->width = pixw;
3588  iconRule.geo->height = pixh;
3589  }
3590  QRect iconRect = positionRect(w, subRule, iconRule, PseudoElement_MenuIcon, opt->rect, opt->direction);
3591  iconRule.drawRule(p, iconRect);
3592  QRect pmr(0, 0, pixw, pixh);
3593  pmr.moveCenter(iconRect.center());
3594  p->drawPixmap(pmr.topLeft(), pixmap);
3595  } else if (checkable) {
3596  QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
3597  if (subSubRule.hasDrawable() || checked) {
3598  QStyleOptionMenuItem newMi = mi;
3599  newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
3601  }
3602  }
3603 
3604  QRect textRect = subRule.contentsRect(opt->rect);
3605  textRect.setWidth(textRect.width() - mi.tabWidth);
3606  QString s = mi.text;
3607  p->setPen(mi.palette.buttonText().color());
3608  if (!s.isEmpty()) {
3609  int text_flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
3610  if (!styleHint(SH_UnderlineShortcut, &mi, w))
3611  text_flags |= Qt::TextHideMnemonic;
3612  int t = s.indexOf(QLatin1Char('\t'));
3613  if (t >= 0) {
3614  QRect vShortcutRect = visualRect(opt->direction, mi.rect,
3615  QRect(textRect.topRight(), QPoint(mi.rect.right(), textRect.bottom())));
3616  p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
3617  s = s.left(t);
3618  }
3619  p->drawText(textRect, text_flags, s.left(t));
3620  }
3621 
3622  if (mi.menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
3625  mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction);
3626  drawPrimitive(arrow, &mi, p, w);
3627  }
3629  QWindowsStyle::drawControl(ce, &mi, p, w);
3630  if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) {
3631  // We have a style defined, but QWindowsStyle won't draw anything if not checked.
3632  // So we mimick what QWindowsStyle would do.
3633  int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
3634  QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height()));
3635  if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
3636  qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button));
3637  } else {
3638  QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern);
3639  qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill);
3640  }
3641  QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
3642  if (subSubRule.hasDrawable()) {
3643  QStyleOptionMenuItem newMi(mi);
3644  newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame,
3647  mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
3649  }
3650  }
3651  } else {
3652  if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
3653  mi.palette.setColor(QPalette::Window, Qt::transparent);
3654  mi.palette.setColor(QPalette::Button, Qt::transparent);
3655  }
3656  if (rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
3657  baseStyle()->drawControl(ce, &mi, p, w);
3658  } else {
3659  ParentStyle::drawControl(ce, &mi, p, w);
3660  }
3661  }
3662 
3663  if (subRule.hasFont)
3664  p->setFont(oldFont);
3665 
3666  return;
3667  }
3668  return;
3669 
3670  case CE_MenuBarItem:
3671  if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3672  QStyleOptionMenuItem mi(*m);
3673  QRenderRule subRule = renderRule(w, opt, PseudoElement_Item);
3674  mi.rect = subRule.contentsRect(opt->rect);
3675  rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
3677 
3678  if (subRule.hasDrawable()) {
3679  subRule.drawRule(p, opt->rect);
3680  QCommonStyle::drawControl(ce, &mi, p, w);
3681  } else {
3682  if (rule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
3683  // So that the menu bar background is not hidden by the items
3684  mi.palette.setColor(QPalette::Window, Qt::transparent);
3685  mi.palette.setColor(QPalette::Button, Qt::transparent);
3686  }
3687  baseStyle()->drawControl(ce, &mi, p, w);
3688  }
3689  }
3690  return;
3691 
3692 #ifndef QT_NO_COMBOBOX
3693  case CE_ComboBoxLabel:
3694  if (!rule.hasBox())
3695  break;
3696  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
3698  p->save();
3699  p->setClipRect(editRect);
3700  if (!cb->currentIcon.isNull()) {
3701  int spacing = rule.hasBox() ? rule.box()->spacing : -1;
3702  if (spacing == -1)
3703  spacing = 6;
3704  QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
3705  QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
3706  QRect iconRect(editRect);
3707  iconRect.setWidth(cb->iconSize.width());
3708  iconRect = alignedRect(cb->direction,
3709  Qt::AlignLeft | Qt::AlignVCenter,
3710  iconRect.size(), editRect);
3711  drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
3712 
3713  if (cb->direction == Qt::RightToLeft)
3714  editRect.translate(-spacing - cb->iconSize.width(), 0);
3715  else
3716  editRect.translate(cb->iconSize.width() + spacing, 0);
3717  }
3718  if (!cb->currentText.isEmpty() && !cb->editable) {
3719  QPalette styledPalette(cb->palette);
3720  rule.configurePalette(&styledPalette, QPalette::Text, QPalette::Base);
3721  drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, styledPalette,
3722  cb->state & State_Enabled, cb->currentText, QPalette::Text);
3723  }
3724  p->restore();
3725  return;
3726  }
3727  break;
3728 #endif // QT_NO_COMBOBOX
3729 
3730  case CE_Header:
3733  ParentStyle::drawControl(ce, opt, p, w);
3734  return;
3735  }
3738  if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
3739  || subRule.hasBackground() || subRule.hasPalette()) {
3740  ParentStyle::drawControl(ce, opt, p, w);
3741  return;
3742  }
3743  }
3744  break;
3745  case CE_HeaderSection:
3746  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
3748  if (subRule.hasNativeBorder()) {
3749  QStyleOptionHeader hdr(*header);
3750  subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
3751 
3752  if (subRule.baseStyleCanDraw()) {
3753  baseStyle()->drawControl(CE_HeaderSection, &hdr, p, w);
3754  } else {
3756  }
3757  } else {
3758  subRule.drawRule(p, opt->rect);
3759  }
3760  return;
3761  }
3762  break;
3763 
3764  case CE_HeaderLabel:
3765  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
3766  QStyleOptionHeader hdr(*header);
3768  subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
3769  QFont oldFont = p->font();
3770  if (subRule.hasFont)
3771  p->setFont(subRule.font.resolve(p->font()));
3772  baseStyle()->drawControl(ce, &hdr, p, w);
3773  if (subRule.hasFont)
3774  p->setFont(oldFont);
3775  return;
3776  }
3777  break;
3778 
3779  case CE_HeaderEmptyArea:
3780  if (rule.hasDrawable()) {
3781  return;
3782  }
3783  break;
3784 
3785  case CE_ProgressBar:
3786  QWindowsStyle::drawControl(ce, opt, p, w);
3787  return;
3788 
3789  case CE_ProgressBarGroove:
3790  if (!rule.hasNativeBorder()) {
3791  rule.drawRule(p, rule.boxRect(opt->rect, Margin));
3792  return;
3793  }
3794  break;
3795 
3796  case CE_ProgressBarContents: {
3798  if (subRule.hasDrawable()) {
3799  if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
3800  p->save();
3801  p->setClipRect(pb->rect);
3802 
3803  qint64 minimum = qint64(pb->minimum);
3804  qint64 maximum = qint64(pb->maximum);
3805  qint64 progress = qint64(pb->progress);
3806  bool vertical = (pb->orientation == Qt::Vertical);
3807  bool inverted = pb->invertedAppearance;
3808 
3809  QTransform m;
3810  QRect rect = pb->rect;
3811  if (vertical) {
3812  rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
3813  m.rotate(90);
3814  m.translate(0, -(rect.height() + rect.y()*2));
3815  }
3816 
3817  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
3818  if (inverted)
3819  reverse = !reverse;
3820  const bool indeterminate = pb->minimum == pb->maximum;
3821  qreal fillRatio = indeterminate ? qreal(0.50) : qreal(progress - minimum)/(maximum - minimum);
3822  int fillWidth = int(rect.width() * fillRatio);
3823  int chunkWidth = fillWidth;
3824  if (subRule.hasContentsSize()) {
3825  QSize sz = subRule.size();
3826  chunkWidth = (opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
3827  }
3828 
3829  QRect r = rect;
3830  if (pb->minimum == 0 && pb->maximum == 0) {
3831  Q_D(const QWindowsStyle);
3832  int chunkCount = fillWidth/chunkWidth;
3833  int offset = (d->animateStep*8%rect.width());
3834  int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
3835  while (chunkCount > 0) {
3836  r.setRect(x, rect.y(), chunkWidth, rect.height());
3837  r = m.mapRect(QRectF(r)).toRect();
3838  subRule.drawRule(p, r);
3839  x += reverse ? -chunkWidth : chunkWidth;
3840  if (reverse ? x < rect.left() : x > rect.right())
3841  break;
3842  --chunkCount;
3843  }
3844 
3845  r = rect;
3846  x = reverse ? r.right() - (r.left() - x - chunkWidth)
3847  : r.left() + (x - r.right() - chunkWidth);
3848  while (chunkCount > 0) {
3849  r.setRect(x, rect.y(), chunkWidth, rect.height());
3850  r = m.mapRect(QRectF(r)).toRect();
3851  subRule.drawRule(p, r);
3852  x += reverse ? -chunkWidth : chunkWidth;
3853  --chunkCount;
3854  };
3855  } else {
3856  int x = reverse ? r.left() + r.width() - chunkWidth : r.x();
3857 
3858  for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) {
3859  r.setRect(x, rect.y(), chunkWidth, rect.height());
3860  r = m.mapRect(QRectF(r)).toRect();
3861  subRule.drawRule(p, r);
3862  x += reverse ? -chunkWidth : chunkWidth;
3863  }
3864  }
3865 
3866  p->restore();
3867  return;
3868  }
3869  }
3870  }
3871  break;
3872 
3873  case CE_ProgressBarLabel:
3874  if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
3875  if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
3876  drawItemText(p, pb->rect, pb->textAlignment | Qt::TextSingleLine, pb->palette,
3877  pb->state & State_Enabled, pb->text, QPalette::Text);
3878  } else {
3879  QStyleOptionProgressBarV2 pbCopy(*pb);
3880  rule.configurePalette(&pbCopy.palette, QPalette::HighlightedText, QPalette::Highlight);
3881  baseStyle()->drawControl(ce, &pbCopy, p, w);
3882  }
3883  return;
3884  }
3885  break;
3886 
3887  case CE_SizeGrip:
3888  if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) {
3889  if (rule.hasDrawable()) {
3890  rule.drawFrame(p, opt->rect);
3891  p->save();
3892  switch (sgOpt->corner) {
3893  case Qt::BottomRightCorner: break;
3894  case Qt::BottomLeftCorner: p->rotate(90); break;
3895  case Qt::TopLeftCorner: p->rotate(180); break;
3896  case Qt::TopRightCorner: p->rotate(270); break;
3897  default: break;
3898  }
3899  rule.drawImage(p, opt->rect);
3900  p->restore();
3901  } else {
3902  QStyleOptionSizeGrip sg(*sgOpt);
3903  sg.rect = rule.contentsRect(opt->rect);
3904  baseStyle()->drawControl(CE_SizeGrip, &sg, p, w);
3905  }
3906  return;
3907  }
3908  break;
3909 
3910  case CE_ToolBoxTab:
3911  QWindowsStyle::drawControl(ce, opt, p, w);
3912  return;
3913 
3914  case CE_ToolBoxTabShape: {
3915  QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
3916  if (subRule.hasDrawable()) {
3917  subRule.drawRule(p, opt->rect);
3918  return;
3919  }
3920  }
3921  break;
3922 
3923  case CE_ToolBoxTabLabel:
3924  if (const QStyleOptionToolBox *box = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
3925  QStyleOptionToolBox boxCopy(*box);
3926  QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
3927  subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button);
3928  QFont oldFont = p->font();
3929  if (subRule.hasFont)
3930  p->setFont(subRule.font);
3931  boxCopy.rect = subRule.contentsRect(opt->rect);
3932  QWindowsStyle::drawControl(ce, &boxCopy, p , w);
3933  if (subRule.hasFont)
3934  p->setFont(oldFont);
3935  return;
3936  }
3937  break;
3938 
3939  case CE_ScrollBarAddPage:
3941  break;
3942 
3943  case CE_ScrollBarSubPage:
3945  break;
3946 
3947  case CE_ScrollBarAddLine:
3950  fallback = true;
3951  break;
3952 
3953  case CE_ScrollBarSubLine:
3956  fallback = true;
3957  break;
3958 
3959  case CE_ScrollBarFirst:
3961  break;
3962 
3963  case CE_ScrollBarLast:
3965  break;
3966 
3967  case CE_ScrollBarSlider:
3969  fallback = true;
3970  break;
3971 
3972 #ifndef QT_NO_ITEMVIEWS
3973  case CE_ItemViewItem:
3974  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
3975  QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
3976  if (subRule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
3977  QStyleOptionViewItemV4 optCopy(*vopt);
3978  subRule.configurePalette(&optCopy.palette, vopt->state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text,
3980  QWindowsStyle::drawControl(ce, &optCopy, p, w);
3981  } else {
3982  QStyleOptionViewItemV4 voptCopy(*vopt);
3983  subRule.configurePalette(&voptCopy.palette, QPalette::Text, QPalette::NoRole);
3984  baseStyle()->drawControl(ce, &voptCopy, p, w);
3985  }
3986  return;
3987  }
3988  break;
3989 #endif // QT_NO_ITEMVIEWS
3990 
3991 #ifndef QT_NO_TABBAR
3992  case CE_TabBarTab:
3994  QWindowsStyle::drawControl(ce, opt, p, w);
3995  return;
3996  }
3997  break;
3998 
3999  case CE_TabBarTabLabel:
4000  case CE_TabBarTabShape:
4001  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
4002  QStyleOptionTabV3 tabCopy(*tab);
4003  QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
4004  QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction);
4005  if (ce == CE_TabBarTabShape && subRule.hasDrawable()) {
4006  subRule.drawRule(p, r);
4007  return;
4008  }
4009  subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window);
4010  QFont oldFont = p->font();
4011  if (subRule.hasFont)
4012  p->setFont(subRule.font);
4013  if (subRule.hasBox() || !subRule.hasNativeBorder()) {
4014  tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
4015  : subRule.contentsRect(r);
4016  QWindowsStyle::drawControl(ce, &tabCopy, p, w);
4017  } else {
4018  baseStyle()->drawControl(ce, &tabCopy, p, w);
4019  }
4020  if (subRule.hasFont)
4021  p->setFont(oldFont);
4022 
4023  return;
4024  }
4025  break;
4026 #endif // QT_NO_TABBAR
4027 
4028  case CE_ColumnViewGrip:
4029  if (rule.hasDrawable()) {
4030  rule.drawRule(p, opt->rect);
4031  return;
4032  }
4033  break;
4034 
4035  case CE_DockWidgetTitle:
4036  if (const QStyleOptionDockWidgetV2 *dwOpt = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
4038  if (!subRule.hasDrawable() && !subRule.hasPosition())
4039  break;
4040  if (subRule.hasDrawable()) {
4041  subRule.drawRule(p, opt->rect);
4042  } else {
4043  QStyleOptionDockWidgetV2 dwCopy(*dwOpt);
4044  dwCopy.title = QString();
4045  baseStyle()->drawControl(ce, &dwCopy, p, w);
4046  }
4047 
4048  if (!dwOpt->title.isEmpty()) {
4049  QRect r = opt->rect;
4050  if (dwOpt->verticalTitleBar) {
4051  QSize s = r.size();
4052  s.transpose();
4053  r.setSize(s);
4054 
4055  p->save();
4056  p->translate(r.left(), r.top() + r.width());
4057  p->rotate(-90);
4058  p->translate(-r.left(), -r.top());
4059  }
4060 
4061  Qt::Alignment alignment = 0;
4062  if (subRule.hasPosition())
4063  alignment = subRule.position()->textAlignment;
4064  if (alignment == 0)
4065  alignment = Qt::AlignLeft;
4066  drawItemText(p, subRule.contentsRect(opt->rect),
4067  alignment | Qt::TextShowMnemonic, dwOpt->palette,
4068  dwOpt->state & State_Enabled, dwOpt->title,
4070 
4071  if (dwOpt->verticalTitleBar)
4072  p->restore();
4073  }
4074 
4075  return;
4076  }
4077  break;
4078  case CE_ShapedFrame:
4079  if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
4080  if (rule.hasNativeBorder()) {
4081  QStyleOptionFrameV3 frmOpt(*frm);
4082  rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
4083  frmOpt.rect = rule.borderRect(frmOpt.rect);
4084  baseStyle()->drawControl(ce, &frmOpt, p, w);
4085  }
4086  // else, borders are already drawn in PE_Widget
4087  }
4088  return;
4089 
4090 
4091  default:
4092  break;
4093  }
4094 
4095  if (pe1 != PseudoElement_None) {
4096  QRenderRule subRule = renderRule(w, opt, pe1);
4097  if (subRule.bg != 0 || subRule.hasDrawable()) {
4098  //We test subRule.bg directly because hasBackground() would return false for background:none.
4099  //But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926)
4100  subRule.drawRule(p, opt->rect);
4101  } else if (fallback) {
4102  QWindowsStyle::drawControl(ce, opt, p, w);
4103  pe2 = PseudoElement_None;
4104  } else {
4105  baseStyle()->drawControl(ce, opt, p, w);
4106  }
4107  if (pe2 != PseudoElement_None) {
4108  QRenderRule subSubRule = renderRule(w, opt, pe2);
4109  QRect r = positionRect(w, subRule, subSubRule, pe2, opt->rect, opt->direction);
4110  subSubRule.drawRule(p, r);
4111  }
4112  return;
4113  }
4114 
4115  baseStyle()->drawControl(ce, opt, p, w);
4116 }
QRect borderRect(const QRect &r) const
double d
Definition: qnumeric_p.h:62
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...
Definition: qstyle.cpp:2120
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
double qreal
Definition: qglobal.h:1193
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
const quint64 PseudoClass_Any
Definition: qcssparser_p.h:508
bool hasGeometry() const
bool hasStyleRule(const QWidget *w, int part) const
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
QStyle * baseStyle() const
QSharedDataPointer< QStyleSheetGeometryData > geo
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
const QStyleSheetBackgroundData * background() const
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
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
bool hasBackground() const
void drawItemText(QPainter *painter, const QRect &rect, int alignment, 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.
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
bool hasPosition() const
QTransform & 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: qtransform.cpp:417
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 QStyleOptionToolBox class is used to describe the parameters needed for drawing a tool box...
Definition: qstyleoption.h:633
void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool)
#define Q_D(Class)
Definition: qglobal.h:2482
The QStyleOptionSizeGrip class is used to describe the parameter for drawing a size grip...
Definition: qstyleoption.h:853
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
QRect contentsRect(const QRect &r) const
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
QSharedDataPointer< QStyleSheetBackgroundData > bg
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
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
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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.
const QStyleSheetPositionData * position() const
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
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...
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
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
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
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
__int64 qint64
Definition: qglobal.h:942
#define ceil(x)
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
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
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
bool hasNativeBorder() const
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
bool hasContentsSize() const
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
bool baseStyleCanDraw() const
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
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
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
bool hasBorder() const
bool hasBox() const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QStyleOptionFrameV3 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:157
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
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
bool hasDrawable() const
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
#define RECURSION_GUARD(RETURN)
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 QStyleOptionTabV3 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
Definition: qstyleoption.h:347
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
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
bool hasPalette() const
QRenderRule renderRule(const QWidget *, int, quint64=0) const
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
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
void drawRule(QPainter *, const QRect &)
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
QSize size() const
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
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
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static QMenuBar * fallback
Definition: qmenu_mac.mm:1617
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
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

◆ drawItemPixmap()

void QStyleSheetStyle::drawItemPixmap ( QPainter painter,
const QRect rectangle,
int  alignment,
const QPixmap pixmap 
) const
virtual

Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.

See also
drawItemText()

Reimplemented from QStyle.

Definition at line 4118 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), and drawControl().

4120 {
4121  baseStyle()->drawItemPixmap(p, rect, alignment, pixmap);
4122 }
QStyle * baseStyle() const
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570

◆ drawItemText()

void QStyleSheetStyle::drawItemText ( QPainter painter,
const QRect rectangle,
int  alignment,
const QPalette palette,
bool  enabled,
const QString text,
QPalette::ColorRole  textRole = QPalette::NoRole 
) const
virtual

Draws the given text in the specified rectangle using the provided painter and palette.

The text is drawn using the painter's pen, and aligned and wrapped according to the specified alignment. If an explicit textRole is specified, the text is drawn using the palette's color for the given role. The enabled parameter indicates whether or not the item is enabled; when reimplementing this function, the enabled parameter should influence how the item is drawn.

See also
Qt::Alignment, drawItemPixmap()

Reimplemented from QStyle.

Definition at line 4124 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), and drawControl().

4126 {
4127  baseStyle()->drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
4128 }
QStyle * baseStyle() const
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
#define enabled

◆ drawPrimitive()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4130 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), and drawControl().

4132 {
4133  RECURSION_GUARD(baseStyle()->drawPrimitive(pe, opt, p, w); return)
4134 
4135  int pseudoElement = PseudoElement_None;
4136  QRenderRule rule = renderRule(w, opt);
4137  QRect rect = opt->rect;
4138 
4139  switch (pe) {
4140 
4141  case PE_FrameStatusBar: {
4142  QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_Item);
4143  if (subRule.hasDrawable()) {
4144  subRule.drawRule(p, opt->rect);
4145  return;
4146  }
4147  break;
4148  }
4149 
4150  case PE_IndicatorArrowDown:
4151  pseudoElement = PseudoElement_DownArrow;
4152  break;
4153 
4154  case PE_IndicatorArrowUp:
4155  pseudoElement = PseudoElement_UpArrow;
4156  break;
4157 
4159  pseudoElement = PseudoElement_ExclusiveIndicator;
4160  break;
4161 
4163  pseudoElement = PseudoElement_ViewItemIndicator;
4164  break;
4165 
4166  case PE_IndicatorCheckBox:
4167  pseudoElement = PseudoElement_Indicator;
4168  break;
4169 
4171  if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
4172  pseudoElement = hdr->sortIndicator == QStyleOptionHeader::SortUp
4175  }
4176  break;
4177 
4178  case PE_PanelButtonTool:
4179  case PE_PanelButtonCommand:
4180  if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) {
4181  //the window style will draw the borders
4182  ParentStyle::drawPrimitive(pe, opt, p, w);
4183  if (!rule.background()->pixmap.isNull() || rule.hasImage()) {
4184  rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin).adjusted(1,1,-1,-1));
4185  }
4186  return;
4187  }
4188  if (!rule.hasNativeBorder()) {
4189  rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin));
4190  return;
4191  }
4192  break;
4193 
4196  if (!subRule.hasNativeBorder()) {
4197  rule.drawBorder(p, opt->rect);
4198  return;
4199  }
4200  break;
4201  }
4202 
4203  case PE_FrameDefaultButton:
4204  if (rule.hasNativeBorder()) {
4205  if (rule.baseStyleCanDraw())
4206  break;
4207  QWindowsStyle::drawPrimitive(pe, opt, p, w);
4208  }
4209  return;
4210 
4211  case PE_FrameWindow:
4212  case PE_FrameDockWidget:
4213  case PE_Frame:
4214  if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
4215  if (rule.hasNativeBorder()) {
4216  QStyleOptionFrameV2 frmOpt(*frm);
4217  rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
4218  if (!qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) //if it comes from CE_ShapedFrame, the margins are already sustracted
4219  frmOpt.rect = rule.borderRect(frmOpt.rect);
4220  baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
4221  } else {
4222  rule.drawBorder(p, rule.borderRect(opt->rect));
4223  }
4224  }
4225  return;
4226 
4227  case PE_PanelLineEdit:
4228  if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
4229 #ifndef QT_NO_SPINBOX
4230  if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
4231  QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
4232  if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
4233  return;
4234  rule = spinboxRule;
4235  }
4236 #endif
4237  if (rule.hasNativeBorder()) {
4238  QStyleOptionFrame frmOpt(*frm);
4239  rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
4240  frmOpt.rect = rule.borderRect(frmOpt.rect);
4241  if (rule.baseStyleCanDraw()) {
4242  rule.drawBackgroundImage(p, opt->rect);
4243  baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
4244  } else {
4245  rule.drawBackground(p, opt->rect);
4246  if (frmOpt.lineWidth > 0)
4247  baseStyle()->drawPrimitive(PE_FrameLineEdit, &frmOpt, p, w);
4248  }
4249  } else {
4250  rule.drawRule(p, opt->rect);
4251  }
4252  }
4253  return;
4254 
4255  case PE_Widget:
4256  if (w && !rule.hasDrawable()) {
4257  QWidget *container = containerWidget(w);
4259  && (container == w || !renderRule(container, opt).hasBackground())) {
4260  //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
4261  // (this may happen if we have rules like :focus)
4262  p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
4263  }
4264  break;
4265  }
4266 #ifndef QT_NO_SCROLLAREA
4267  if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
4268  const QAbstractScrollAreaPrivate *sap = sa->d_func();
4269  rule.drawBackground(p, opt->rect, sap->contentsOffset());
4270  if (rule.hasBorder()) {
4271  QRect brect = rule.borderRect(opt->rect);
4273  QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
4274  sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0);
4275  brect = QStyle::visualRect(opt->direction, brect, r);
4276  }
4277  rule.drawBorder(p, brect);
4278  }
4279  break;
4280  }
4281 #endif
4282  //fall tghought
4283  case PE_PanelMenu:
4284  case PE_PanelStatusBar:
4285  if(rule.hasDrawable()) {
4286  rule.drawRule(p, opt->rect);
4287  return;
4288  }
4289  break;
4290 
4291  case PE_FrameMenu:
4292  if (rule.hasDrawable()) {
4293  // Drawn by PE_PanelMenu
4294  return;
4295  }
4296  break;
4297 
4298  case PE_PanelMenuBar:
4299  if (rule.hasDrawable()) {
4300  // Drawn by PE_Widget
4301  return;
4302  }
4303  break;
4304 
4308  QRenderRule subRule = renderRule(w, opt, ps);
4309  if (subRule.hasDrawable()) {
4310  subRule.drawRule(p, opt->rect);
4311  return;
4312  }
4313  }
4314  break;
4315 
4317  pseudoElement = PseudoElement_MenuCheckMark;
4318  break;
4319 
4320  case PE_IndicatorArrowLeft:
4321  pseudoElement = PseudoElement_LeftArrow;
4322  break;
4323 
4325  pseudoElement = PseudoElement_RightArrow;
4326  break;
4327 
4329  if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
4330  bool reverse = (viewOpt->direction == Qt::RightToLeft);
4331  pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow;
4332  } else {
4333  pseudoElement = PseudoElement_RightArrow;
4334  }
4335  break;
4336 
4337  case PE_IndicatorBranch:
4338  if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
4340  if (subRule.hasDrawable()) {
4341  if ((v2->state & QStyle::State_Selected) && v2->showDecorationSelected)
4342  p->fillRect(v2->rect, v2->palette.highlight());
4343  else if (v2->features & QStyleOptionViewItemV2::Alternate)
4344  p->fillRect(v2->rect, v2->palette.alternateBase());
4345  subRule.drawRule(p, opt->rect);
4346  } else {
4347  baseStyle()->drawPrimitive(pe, v2, p, w);
4348  }
4349  }
4350  return;
4351 
4352  case PE_PanelTipLabel:
4353  if (!rule.hasDrawable())
4354  break;
4355 
4356  if (const QStyleOptionFrame *frmOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
4357  if (rule.hasNativeBorder()) {
4358  rule.drawBackground(p, opt->rect);
4359  QStyleOptionFrame optCopy(*frmOpt);
4360  optCopy.rect = rule.borderRect(opt->rect);
4361  optCopy.palette.setBrush(QPalette::Window, Qt::NoBrush); // oh dear
4362  baseStyle()->drawPrimitive(pe, &optCopy, p, w);
4363  } else {
4364  rule.drawRule(p, opt->rect);
4365  }
4366  }
4367  return;
4368 
4369  case PE_FrameGroupBox:
4370  if (rule.hasNativeBorder())
4371  break;
4372  rule.drawBorder(p, opt->rect);
4373  return;
4374 
4375 #ifndef QT_NO_TABWIDGET
4376  case PE_FrameTabWidget:
4377  if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
4379  if (subRule.hasNativeBorder()) {
4380  subRule.drawBackground(p, opt->rect);
4381  QStyleOptionTabWidgetFrameV2 frmCopy(*frm);
4382  subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window);
4383  baseStyle()->drawPrimitive(pe, &frmCopy, p, w);
4384  } else {
4385  subRule.drawRule(p, opt->rect);
4386  }
4387  return;
4388  }
4389  break;
4390 #endif // QT_NO_TABWIDGET
4391 
4393  pseudoElement = PseudoElement_ProgressBarChunk;
4394  break;
4395 
4396  case PE_IndicatorTabTear:
4397  pseudoElement = PseudoElement_TabBarTear;
4398  break;
4399 
4400  case PE_FrameFocusRect:
4401  if (!rule.hasNativeOutline()) {
4402  rule.drawOutline(p, opt->rect);
4403  return;
4404  }
4405  break;
4406 
4408  pseudoElement = PseudoElement_DockWidgetSeparator;
4409  break;
4410 
4411  case PE_PanelItemViewItem:
4412  pseudoElement = PseudoElement_ViewItem;
4413  break;
4414 
4416  pseudoElement = PseudoElement_ScrollAreaCorner;
4417  break;
4418 
4419  case PE_IndicatorSpinDown:
4420  case PE_IndicatorSpinMinus:
4421  pseudoElement = PseudoElement_SpinBoxDownArrow;
4422  break;
4423 
4424  case PE_IndicatorSpinUp:
4425  case PE_IndicatorSpinPlus:
4426  pseudoElement = PseudoElement_SpinBoxUpArrow;
4427  break;
4428 #ifndef QT_NO_TABBAR
4429  case PE_IndicatorTabClose:
4430  if (w)
4431  w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
4432  pseudoElement = PseudoElement_TabBarTabCloseButton;
4433 #endif
4434 
4435  default:
4436  break;
4437  }
4438 
4439  if (pseudoElement != PseudoElement_None) {
4440  QRenderRule subRule = renderRule(w, opt, pseudoElement);
4441  if (subRule.hasDrawable()) {
4442  subRule.drawRule(p, rect);
4443  } else {
4444  baseStyle()->drawPrimitive(pe, opt, p, w);
4445  }
4446  } else {
4447  baseStyle()->drawPrimitive(pe, opt, p, w);
4448  }
4449 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
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 drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
QStyle * baseStyle() const
static C reverse(const C &l)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool hasBackground() const
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
PseudoElement
void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool)
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QStyleOptionViewItemV2 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:562
static QStyleSheetStyleCaches * styleSheetCaches
void drawBackground(QPainter *, const QRect &, const QPoint &=QPoint(0, 0))
bool contains(const T &value) const
Definition: qset.h:91
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 QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
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
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
bool hasNativeBorder() const
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
bool baseStyleCanDraw() const
QSet< const QWidget * > autoFillDisabledWidgets
bool hasDrawable() const
#define RECURSION_GUARD(RETURN)
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
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
void drawRule(QPainter *, const QRect &)
static QWidget * containerWidget(const QWidget *w)
The QStyleOptionTabWidgetFrameV2 class is used to describe the parameters for drawing the frame aroun...
Definition: qstyleoption.h:196
virtual QPoint contentsOffset() const
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420

◆ event()

bool QStyleSheetStyle::event ( QEvent e)
protectedvirtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QObject.

Definition at line 5804 of file qstylesheetstyle.cpp.

5805 {
5806  return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e);
5807 }
QStyle * baseStyle() const
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
bool isAccepted() const
Definition: qcoreevent.h:307
bool event(QEvent *e)
This virtual function receives events to an object and should return true if the event e was recogniz...

◆ generatedIconPixmap()

QPixmap QStyleSheetStyle::generatedIconPixmap ( QIcon::Mode  iconMode,
const QPixmap pixmap,
const QStyleOption opt 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4451 of file qstylesheetstyle.cpp.

4453 {
4454  return baseStyle()->generatedIconPixmap(iconMode, pixmap, option);
4455 }
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
Returns a copy of the given pixmap, styled to conform to the specified iconMode and taking into accou...
QStyle * baseStyle() const

◆ getDefaultStyleSheet()

StyleSheet QStyleSheetStyle::getDefaultStyleSheet ( ) const
private

Definition at line 147 of file qstylesheetstyle_default.cpp.

148 {
149  StyleSheet sheet;
150  StyleRule styleRule;
151  BasicSelector bSelector;
152  Selector selector;
153  Declaration decl;
154  QCss::Value value;
155  Pseudo pseudo;
156  AttributeSelector attr;
157 
158  // pixmap based style doesn't support any features
159  bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")
160  || baseStyle()->inherits("QWindowsXPStyle")
161  || baseStyle()->inherits("QGtkStyle")
162  || baseStyle()->inherits("QS60Style");
163 
164 
165  /*QLineEdit {
166  -qt-background-role: base;
167  border: native;
168  -qt-style-features: background-color;
169  }*/
170  {
171  SET_ELEMENT_NAME(QLatin1String("QLineEdit"));
173  ADD_SELECTOR;
174 
175  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
176  ADD_VALUE(Value::KnownIdentifier, Value_Base);
178 
179  SET_PROPERTY(QLatin1String("border"), Border);
180  ADD_VALUE(Value::KnownIdentifier, Value_Native);
182 
183  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
184  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
186 
188  }
189 
190  /*QLineEdit:no-frame {
191  border: none;
192  }*/
193  {
194  SET_ELEMENT_NAME(QLatin1String("QLineEdit"));
197  ADD_SELECTOR;
198 
199  SET_PROPERTY(QLatin1String("border"), Border);
200  ADD_VALUE(Value::KnownIdentifier, Value_None);
202 
204  }
205 
206  /*QFrame {
207  border: native;
208  }*/
209  {
210  SET_ELEMENT_NAME(QLatin1String("QFrame"));
212  ADD_SELECTOR;
213 
214  SET_PROPERTY(QLatin1String("border"), Border);
215  ADD_VALUE(Value::KnownIdentifier, Value_Native);
217 
219  }
220 
221  /*QLabel, QToolBox {
222  background: none;
223  border-image: none;
224  }*/
225  {
226  SET_ELEMENT_NAME(QLatin1String("QLabel"));
228  ADD_SELECTOR;
229 
230  SET_ELEMENT_NAME(QLatin1String("QToolBox"));
232  ADD_SELECTOR;
233 
234  SET_PROPERTY(QLatin1String("background"), Background);
235  ADD_VALUE(Value::KnownIdentifier, Value_None);
237 
238  SET_PROPERTY(QLatin1String("border-image"), BorderImage);
239  ADD_VALUE(Value::KnownIdentifier, Value_None);
241 
243  }
244 
245  /*QGroupBox {
246  border: native;
247  }*/
248  {
249  SET_ELEMENT_NAME(QLatin1String("QGroupBox"));
251  ADD_SELECTOR;
252 
253  SET_PROPERTY(QLatin1String("border"), Border);
254  ADD_VALUE(Value::KnownIdentifier, Value_Native);
256 
258  }
259 
260 
261  /*QToolTip {
262  -qt-background-role: window;
263  border: native;
264  }*/
265  {
266  SET_ELEMENT_NAME(QLatin1String("QToolTip"));
268  ADD_SELECTOR;
269 
270  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
271  ADD_VALUE(Value::KnownIdentifier, Value_Window);
273 
274  SET_PROPERTY(QLatin1String("border"), Border);
275  ADD_VALUE(Value::KnownIdentifier, Value_Native);
277 
279  }
280 
281  /*QPushButton, QToolButton {
282  border-style: native;
283  -qt-style-features: background-color; //only for not pixmap based styles
284  }*/
285  {
286  SET_ELEMENT_NAME(QLatin1String("QPushButton"));
288  ADD_SELECTOR;
289 
290  SET_ELEMENT_NAME(QLatin1String("QToolButton"));
292  ADD_SELECTOR;
293 
294  SET_PROPERTY(QLatin1String("border-style"), BorderStyles);
295  ADD_VALUE(Value::KnownIdentifier, Value_Native);
297 
298  if (!styleIsPixmapBased) {
299  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
300  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
302  }
303 
304 
306  }
307 
308 
309  /*QComboBox {
310  border: native;
311  -qt-style-features: background-color background-gradient; //only for not pixmap based styles
312  -qt-background-role: base;
313  }*/
314 
315  {
316  SET_ELEMENT_NAME(QLatin1String("QComboBox"));
318  ADD_SELECTOR;
319 
320  SET_PROPERTY(QLatin1String("border"), Border);
321  ADD_VALUE(Value::KnownIdentifier, Value_Native);
323 
324  if (!styleIsPixmapBased) {
325  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
326  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
327  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-gradient"));
329  }
330 
331  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
332  ADD_VALUE(Value::KnownIdentifier, Value_Base);
334 
336  }
337 
338  /*QComboBox[style="QPlastiqueStyle"][readOnly="true"],
339  QComboBox[style="QCleanlooksStyle"][readOnly="true"]
340  {
341  -qt-background-role: button;
342  }*/
343  if (baseStyle()->inherits("QPlastiqueStyle") || baseStyle()->inherits("QCleanlooksStyle"))
344  {
345  SET_ELEMENT_NAME(QLatin1String("QComboBox"));
346  ADD_ATTRIBUTE_SELECTOR(QLatin1String("readOnly"), QLatin1String("true"), AttributeSelector::MatchEqual);
348  ADD_SELECTOR;
349 
350  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
351  ADD_VALUE(Value::KnownIdentifier, Value_Button);
353 
355  }
356 
357  /*QAbstractSpinBox {
358  border: native;
359  -qt-style-features: background-color;
360  -qt-background-role: base;
361  }*/
362  {
363  SET_ELEMENT_NAME(QLatin1String("QAbstractSpinBox"));
365  ADD_SELECTOR;
366 
367  SET_PROPERTY(QLatin1String("border"), Border);
368  ADD_VALUE(Value::KnownIdentifier, Value_Native);
370 
371  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
372  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
374 
375  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
376  ADD_VALUE(Value::KnownIdentifier, Value_Base);
378 
380  }
381 
382  /*QMenu {
383  -qt-background-role: window;
384  }*/
385  {
388  ADD_SELECTOR;
389 
390  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
391  ADD_VALUE(Value::KnownIdentifier, Value_Window);
393 
395  }
396  /*QMenu::item {
397  -qt-style-features: background-color;
398  }*/
399  if (!styleIsPixmapBased) {
403  ADD_SELECTOR;
404 
405  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
406  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
408 
410  }
411 
412  /*QHeaderView {
413  -qt-background-role: window;
414  }*/
415  {
416  SET_ELEMENT_NAME(QLatin1String("QHeaderView"));
418  ADD_SELECTOR;
419 
420  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
421  ADD_VALUE(Value::KnownIdentifier, Value_Window);
423 
425  }
426 
427  /*QTableCornerButton::section, QHeaderView::section {
428  -qt-background-role: button;
429  -qt-style-features: background-color; //if style is not pixmap based
430  border: native;
431  }*/
432  {
433  SET_ELEMENT_NAME(QLatin1String("QTableCornerButton"));
436  ADD_SELECTOR;
437 
438  SET_ELEMENT_NAME(QLatin1String("QHeaderView"));
441  ADD_SELECTOR;
442 
443  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
444  ADD_VALUE(Value::KnownIdentifier, Value_Button);
446 
447  if (!styleIsPixmapBased) {
448  SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);
449  ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));
451  }
452 
453  SET_PROPERTY(QLatin1String("border"), Border);
454  ADD_VALUE(Value::KnownIdentifier, Value_Native);
456 
458  }
459 
460  /*QProgressBar {
461  -qt-background-role: base;
462  }*/
463  {
464  SET_ELEMENT_NAME(QLatin1String("QProgressBar"));
466  ADD_SELECTOR;
467 
468  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
469  ADD_VALUE(Value::KnownIdentifier, Value_Base);
471 
473  }
474 
475  /*QScrollBar {
476  -qt-background-role: window;
477  }*/
478  {
479  SET_ELEMENT_NAME(QLatin1String("QScrollBar"));
481  ADD_SELECTOR;
482 
483  SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);
484  ADD_VALUE(Value::KnownIdentifier, Value_Window);
486 
488  }
489 
490  /*QDockWidget {
491  border: native;
492  }*/
493  {
494  SET_ELEMENT_NAME(QLatin1String("QDockWidget"));
496  ADD_SELECTOR;
497 
498  SET_PROPERTY(QLatin1String("border"), Border);
499  ADD_VALUE(Value::KnownIdentifier, Value_Native);
501 
503  }
504 
506  sheet.buildIndexes();
507  return sheet;
508 }
void buildIndexes(Qt::CaseSensitivity nameCaseSensitivity=Qt::CaseSensitive)
QStyle * baseStyle() const
#define ADD_BASIC_SELECTOR
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
StyleSheetOrigin origin
Definition: qcssparser_p.h:643
#define SET_PROPERTY(x, y)
const quint64 PseudoClass_Unknown
Definition: qcssparser_p.h:461
#define ADD_STYLE_RULE
#define SET_ELEMENT_NAME(x)
#define ADD_DECLARATION
The BorderImage element provides an image that can be used as a border.
const quint64 PseudoClass_Frameless
Definition: qcssparser_p.h:491
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
#define ADD_SELECTOR
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define ADD_VALUE(x, y)
#define ADD_PSEUDO(x, y)
#define ADD_ATTRIBUTE_SELECTOR(x, y, z)

◆ hasStyleRule()

bool QStyleSheetStyle::hasStyleRule ( const QWidget w,
int  part 
) const
private

Definition at line 2029 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), drawControl(), hitTestComplexControl(), pixelMetric(), sizeFromContents(), subControlRect(), and subElementRect().

2030 {
2032  QHash<int, bool>::const_iterator cacheIt = cache.constFind(part);
2033  if (cacheIt != cache.constEnd())
2034  return cacheIt.value();
2035 
2036  if (!initWidget(w))
2037  return false;
2038 
2039 
2040  const QVector<StyleRule> &rules = styleRules(w);
2041  if (part == PseudoElement_None) {
2042  bool result = w && !rules.isEmpty();
2043  cache[part] = result;
2044  return result;
2045  }
2046 
2047  QString pseudoElement = QLatin1String(knownPseudoElements[part].name);
2049  for (int i = 0; i < rules.count(); i++) {
2050  const Selector& selector = rules.at(i).selectors.at(0);
2051  if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) {
2052  cache[part] = true;
2053  return true;
2054  }
2055  }
2056 
2057  cache[part] = false;
2058  return false;
2059 }
QString pseudoElement() const
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QHash< const QWidget *, QHash< int, bool > > hasStyleRuleCache
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QStyleSheetStyleCaches * styleSheetCaches
QVector< Selector > selectors
Definition: qcssparser_p.h:605
const char * name
static QVector< Declaration > declarations(const QVector< StyleRule > &styleRules, const QString &part, quint64 pseudoClass=PseudoClass_Unspecified)
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QCss::StyleRule > styleRules(const QWidget *w) const
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int compare(const QString &s) const
Definition: qstring.cpp:5037
bool initWidget(const QWidget *w) const
Make sure that the cache will be clean by connecting destroyed if needed.
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ hitTestComplexControl()

QStyle::SubControl QStyleSheetStyle::hitTestComplexControl ( ComplexControl  cc,
const QStyleOptionComplex opt,
const QPoint pt,
const QWidget w = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4457 of file qstylesheetstyle.cpp.

4459 {
4460  RECURSION_GUARD(return baseStyle()->hitTestComplexControl(cc, opt, pt, w))
4461  switch (cc) {
4462  case CC_TitleBar:
4463  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4465  if (rule.hasDrawable() || rule.hasBox() || rule.hasBorder()) {
4467  QRect r;
4469  uint ctrl = SC_TitleBarSysMenu;
4470  while (ctrl <= SC_TitleBarLabel) {
4471  r = layout[QStyle::SubControl(ctrl)];
4472  if (r.isValid() && r.contains(pt)) {
4473  sc = QStyle::SubControl(ctrl);
4474  break;
4475  }
4476  ctrl <<= 1;
4477  }
4478  return sc;
4479  }
4480  }
4481  break;
4482 
4483  case CC_MdiControls:
4487  return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
4488  break;
4489 
4490  case CC_ScrollBar: {
4491  QRenderRule rule = renderRule(w, opt);
4492  if (!rule.hasDrawable() && !rule.hasBox())
4493  break;
4494  }
4495  // intentionally falls through
4496  case CC_SpinBox:
4497  case CC_GroupBox:
4498  case CC_ComboBox:
4499  case CC_Slider:
4500  case CC_ToolButton:
4501  return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
4502  default:
4503  break;
4504  }
4505 
4506  return baseStyle()->hitTestComplexControl(cc, opt, pt, w);
4507 }
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
bool hasStyleRule(const QWidget *w, int part) const
QStyle * baseStyle() const
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
const char * layout
unsigned int uint
Definition: qglobal.h:996
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
QHash< QStyle::SubControl, QRect > titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
bool hasBorder() const
bool hasBox() const
bool hasDrawable() const
#define RECURSION_GUARD(RETURN)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=0) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
QRenderRule renderRule(const QWidget *, int, quint64=0) const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237

◆ initWidget()

bool QStyleSheetStyle::initWidget ( const QWidget w) const
private

Make sure that the cache will be clean by connecting destroyed if needed.

return false if the widget is not stylable;

Definition at line 2657 of file qstylesheetstyle.cpp.

Referenced by polish().

2658 {
2659  if (!w)
2660  return false;
2662  return true;
2663 
2664  if(unstylable(w))
2665  return false;
2666 
2667  const_cast<QWidget *>(w)->setAttribute(Qt::WA_StyleSheet, true);
2669  return true;
2670 }
static bool unstylable(const QWidget *w)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QStyleSheetStyleCaches * styleSheetCaches
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
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 rece...
Definition: qobject.cpp:2580
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ isNaturalChild()

bool QStyleSheetStyle::isNaturalChild ( const QWidget w)
staticprivate

Definition at line 5894 of file qstylesheetstyle.cpp.

Referenced by updateStyleSheetFont().

5895 {
5896  if (w->objectName().startsWith(QLatin1String("qt_")))
5897  return true;
5898 
5899  return false;
5900 }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString objectName() const

◆ itemPixmapRect()

QRect QStyleSheetStyle::itemPixmapRect ( const QRect r,
int  flags,
const QPixmap pixmap 
) const
virtual

Returns the area within the given rectangle in which to draw the specified pixmap according to the defined alignment.

Reimplemented from QStyle.

Definition at line 4509 of file qstylesheetstyle.cpp.

4510 {
4511  return baseStyle()->itemPixmapRect(rect, alignment, pixmap);
4512 }
QStyle * baseStyle() const
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 de...
Definition: qstyle.cpp:497

◆ itemTextRect()

QRect QStyleSheetStyle::itemTextRect ( const QFontMetrics metrics,
const QRect rectangle,
int  alignment,
bool  enabled,
const QString text 
) const
virtual

Returns the area within the given rectangle in which to draw the provided text according to the specified font metrics and alignment.

The enabled parameter indicates whether or not the associated item is enabled.

If the given rectangle is larger than the area needed to render the text, the rectangle that is returned will be offset within rectangle according to the specified alignment. For example, if alignment is Qt::AlignCenter, the returned rectangle will be centered within rectangle. If the given rectangle is smaller than the area needed, the returned rectangle will be the smallest rectangle large enough to render the text.

See also
Qt::Alignment

Reimplemented from QStyle.

Definition at line 4514 of file qstylesheetstyle.cpp.

4516 {
4517  return baseStyle()->itemTextRect(metrics, rect, alignment, enabled, text);
4518 }
QStyle * baseStyle() const
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 speci...
Definition: qstyle.cpp:470
#define enabled

◆ layoutSpacing()

int QStyleSheetStyle::layoutSpacing ( QSizePolicy::ControlType  control1,
QSizePolicy::ControlType  control2,
Qt::Orientation  orientation,
const QStyleOption option = 0,
const QWidget widget = 0 
) const

Definition at line 5107 of file qstylesheetstyle.cpp.

5110 {
5111  return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
5112 }
QStyle * baseStyle() const
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.
Definition: qstyle.cpp:2395

◆ layoutSpacingImplementation

int QStyleSheetStyle::layoutSpacingImplementation ( QSizePolicy::ControlType  control1,
QSizePolicy::ControlType  control2,
Qt::Orientation  orientation,
const QStyleOption option = 0,
const QWidget widget = 0 
) const
protectedslot

Definition at line 5114 of file qstylesheetstyle.cpp.

5119 {
5120  return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
5121 }
QStyle * baseStyle() const
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.
Definition: qstyle.cpp:2395

◆ nativeFrameWidth()

int QStyleSheetStyle::nativeFrameWidth ( const QWidget w)
private

Definition at line 1615 of file qstylesheetstyle.cpp.

Referenced by QRenderRule::QRenderRule().

1616 {
1617  QStyle *base = baseStyle();
1618 
1619 #ifndef QT_NO_SPINBOX
1620  if (qobject_cast<const QAbstractSpinBox *>(w))
1621  return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
1622 #endif
1623 
1624 #ifndef QT_NO_COMBOBOX
1625  if (qobject_cast<const QComboBox *>(w))
1626  return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
1627 #endif
1628 
1629 #ifndef QT_NO_MENU
1630  if (qobject_cast<const QMenu *>(w))
1631  return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
1632 #endif
1633 
1634 #ifndef QT_NO_MENUBAR
1635  if (qobject_cast<const QMenuBar *>(w))
1636  return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
1637 #endif
1638 #ifndef QT_NO_FRAME
1639  if (const QFrame *frame = qobject_cast<const QFrame *>(w)) {
1640  if (frame->frameShape() == QFrame::NoFrame)
1641  return 0;
1642  }
1643 #endif
1644 
1645  if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0)
1646  return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w);
1647 
1648  return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w);
1649 }
QStyle * baseStyle() const
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ pixelMetric()

int QStyleSheetStyle::pixelMetric ( PixelMetric  m,
const QStyleOption opt = 0,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4520 of file qstylesheetstyle.cpp.

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

4521 {
4522  RECURSION_GUARD(return baseStyle()->pixelMetric(m, opt, w))
4523 
4524  QRenderRule rule = renderRule(w, opt);
4525  QRenderRule subRule;
4526 
4527  switch (m) {
4529 #ifndef QT_NO_TOOLBUTTON
4530  // QToolButton adds this directly to the width
4531  if (qobject_cast<const QToolButton *>(w) && (rule.hasBox() || !rule.hasNativeBorder()))
4532  return 0;
4533 #endif
4535  if (subRule.hasContentsSize())
4536  return subRule.size().width();
4537  break;
4538 
4541  case PM_ButtonMargin:
4543  if (rule.hasBox())
4544  return 0;
4545  break;
4546 
4547  case PM_DefaultFrameWidth:
4548  if (!rule.hasNativeBorder())
4549  return rule.border()->borders[LeftEdge];
4550  break;
4551 
4553  case PM_IndicatorWidth:
4555  case PM_IndicatorHeight:
4556  subRule = renderRule(w, opt, PseudoElement_Indicator);
4557  if (subRule.hasContentsSize()) {
4558  return (m == PM_ExclusiveIndicatorWidth) || (m == PM_IndicatorWidth)
4559  ? subRule.size().width() : subRule.size().height();
4560  }
4561  break;
4562 
4564  case PM_ToolTipLabelFrameWidth: // border + margin + padding (support only one width)
4565  if (!rule.hasDrawable())
4566  break;
4567 
4568  return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
4569  + (rule.hasBox() ? rule.box()->margins[LeftEdge] + rule.box()->paddings[LeftEdge]: 0);
4570 
4571  case PM_ToolBarFrameWidth:
4572  if (rule.hasBorder() || rule.hasBox())
4573  return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
4574  + (rule.hasBox() ? rule.box()->paddings[LeftEdge]: 0);
4575  break;
4576 
4577  case PM_MenuPanelWidth:
4578  case PM_MenuBarPanelWidth:
4579  if (rule.hasBorder() || rule.hasBox())
4580  return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
4581  + (rule.hasBox() ? rule.box()->margins[LeftEdge]: 0);
4582  break;
4583 
4584 
4585  case PM_MenuHMargin:
4586  case PM_MenuBarHMargin:
4587  if (rule.hasBox())
4588  return rule.box()->paddings[LeftEdge];
4589  break;
4590 
4591  case PM_MenuVMargin:
4592  case PM_MenuBarVMargin:
4593  if (rule.hasBox())
4594  return rule.box()->paddings[TopEdge];
4595  break;
4596 
4598  case PM_ToolBarItemMargin:
4599  if (rule.hasBox())
4600  return rule.box()->margins[TopEdge];
4601  break;
4602 
4603  case PM_ToolBarItemSpacing:
4604  case PM_MenuBarItemSpacing:
4605  if (rule.hasBox() && rule.box()->spacing != -1)
4606  return rule.box()->spacing;
4607  break;
4608 
4609  case PM_MenuTearoffHeight:
4610  case PM_MenuScrollerHeight: {
4612  subRule = renderRule(w, opt, ps);
4613  if (subRule.hasContentsSize())
4614  return subRule.size().height();
4615  break;
4616  }
4617 
4619  break;
4620 
4621  case PM_SplitterWidth:
4623  case PM_ToolBarHandleExtent: {
4624  PseudoElement ps;
4626  else if (m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle;
4628  subRule = renderRule(w, opt, ps);
4629  if (subRule.hasContentsSize()) {
4630  QSize sz = subRule.size();
4631  return (opt && opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
4632  }
4633  break;
4634  }
4635 
4637  if (rule.hasBox() && rule.box()->spacing != -1)
4638  return rule.box()->spacing;
4639  break;
4641  if (qobject_cast<const QCheckBox *>(w)) {
4642  if (rule.hasBox() && rule.box()->spacing != -1)
4643  return rule.box()->spacing;
4644  }
4645  // assume group box
4646  subRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
4647  if (subRule.hasBox() && subRule.box()->spacing != -1)
4648  return subRule.box()->spacing;
4649  break;
4650 
4651 #ifndef QT_NO_SCROLLBAR
4652  case PM_ScrollBarExtent:
4653  if (rule.hasContentsSize()) {
4654  QSize sz = rule.size();
4655  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
4656  return sb->orientation == Qt::Horizontal ? sz.height() : sz.width();
4657  return sz.width() == -1 ? sz.height() : sz.width();
4658  }
4659  break;
4660 
4661  case PM_ScrollBarSliderMin:
4663  subRule = renderRule(w, opt, PseudoElement_ScrollBarSlider);
4664  QSize msz = subRule.minimumSize();
4665  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
4666  return sb->orientation == Qt::Horizontal ? msz.width() : msz.height();
4667  return msz.width() == -1 ? msz.height() : msz.width();
4668  }
4669  break;
4670 
4672  if(!rule.hasNativeBorder() || rule.hasBox())
4673  return 0;
4674  break;
4675 #endif // QT_NO_SCROLLBAR
4676 
4678  subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
4679  if (subRule.hasContentsSize()) {
4680  QSize sz = subRule.size();
4681  return (opt->state & QStyle::State_Horizontal)
4682  ? sz.width() : sz.height();
4683  }
4684  break;
4685 
4686 #ifndef QT_NO_TABWIDGET
4687  case PM_TabBarTabHSpace:
4688  case PM_TabBarTabVSpace:
4689  subRule = renderRule(w, opt, PseudoElement_TabBarTab);
4690  if (subRule.hasBox() || subRule.hasBorder())
4691  return 0;
4692  break;
4693 
4695  subRule = renderRule(w, opt, PseudoElement_TabBarScroller);
4696  if (subRule.hasContentsSize()) {
4697  QSize sz = subRule.size();
4698  return sz.width() != -1 ? sz.width() : sz.height();
4699  }
4700  }
4701  break;
4702 
4705  subRule = renderRule(w, opt, PseudoElement_TabBarTab);
4706  if (subRule.hasBox())
4707  return 0;
4708  break;
4709 
4710  case PM_TabBarBaseOverlap: {
4711  const QWidget *tabWidget = qobject_cast<const QTabWidget *>(w) ? w : w->parentWidget();
4712  if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) {
4713  return 0;
4714  }
4715  break;
4716  }
4717 #endif // QT_NO_TABWIDGET
4718 
4719  case PM_SliderThickness: // horizontal slider's height (sizeHint)
4720  case PM_SliderLength: // minimum length of slider
4721  if (rule.hasContentsSize()) {
4722  bool horizontal = opt->state & QStyle::State_Horizontal;
4723  if (m == PM_SliderThickness) {
4724  QSize sz = rule.size();
4725  return horizontal ? sz.height() : sz.width();
4726  } else {
4727  QSize msz = rule.minimumContentsSize();
4728  return horizontal ? msz.width() : msz.height();
4729  }
4730  }
4731  break;
4732 
4735  if (!subRule.hasContentsSize())
4736  break;
4737  QSize size = subRule.size();
4738  return (opt->state & QStyle::State_Horizontal) ? size.height() : size.width();
4739  }
4740 
4741  case PM_ToolBarIconSize:
4742  case PM_ListViewIconSize:
4743  case PM_IconViewIconSize:
4744  case PM_TabBarIconSize:
4745  case PM_MessageBoxIconSize:
4746  case PM_ButtonIconSize:
4747  case PM_SmallIconSize:
4748  if (rule.hasStyleHint(QLatin1String("icon-size"))) {
4749  return rule.styleHint(QLatin1String("icon-size")).toSize().width();
4750  }
4751  break;
4752 
4753  case PM_DockWidgetTitleMargin: {
4755  if (!subRule.hasBox())
4756  break;
4757  return (subRule.border() ? subRule.border()->borders[TopEdge] : 0)
4758  + (subRule.hasBox() ? subRule.box()->margins[TopEdge] + subRule.box()->paddings[TopEdge]: 0);
4759  }
4760 
4763  if (!subRule.hasContentsSize())
4764  break;
4765  QSize sz = subRule.size();
4766  return qMax(sz.width(), sz.height());
4767  }
4768 
4769  case PM_TitleBarHeight: {
4770  QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
4771  if (subRule.hasContentsSize())
4772  return subRule.size().height();
4773  else if (subRule.hasBox() || subRule.hasBorder()) {
4774  QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics();
4775  return subRule.size(QSize(0, fm.height())).height();
4776  }
4777  break;
4778  }
4779 
4781  if (rule.hasBox() || rule.hasBorder()) {
4782  return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
4783  + (rule.hasBox() ? rule.box()->paddings[LeftEdge]+rule.box()->margins[LeftEdge]: 0);
4784  }
4785  break;
4786 
4789  int width = subRule.size().width();
4790  if (width != -1)
4791  return width;
4792  break;
4793  }
4794  default:
4795  break;
4796  }
4797 
4798  return baseStyle()->pixelMetric(m, opt, w);
4799 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QVariant styleHint(const QString &sh) const
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
bool hasStyleRule(const QWidget *w, int part) const
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
QStyle * baseStyle() const
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const quint64 PseudoClass_Minimized
Definition: qcssparser_p.h:497
QSize minimumSize() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
const QStyleSheetBoxData * box() const
PseudoElement
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QSize minimumContentsSize() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
Returns the width.
Definition: qsize.h:126
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QSize toSize() const
Returns the variant as a QSize if the variant has type() Size ; otherwise returns an invalid QSize...
Definition: qvariant.cpp:2432
bool hasNativeBorder() const
bool hasContentsSize() const
bool hasBorder() const
bool hasBox() const
const QStyleSheetBorderData * border() const
bool hasDrawable() const
#define RECURSION_GUARD(RETURN)
int height() const
Returns the height.
Definition: qsize.h:129
bool hasStyleHint(const QString &sh) const
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
int height() const
Returns the height of the font.
QSize size() const

◆ polish() [1/3]

void QStyleSheetStyle::polish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2672 of file qstylesheetstyle.cpp.

2673 {
2674  baseStyle()->polish(w);
2675  RECURSION_GUARD(return)
2676 
2677  if (!initWidget(w))
2678  return;
2679 
2681  // the widget accessed its style pointer before polish (or repolish)
2682  // (exemple: the QAbstractSpinBox constructor ask for the stylehint)
2686  }
2687  setGeometry(w);
2688  setProperties(w);
2689  unsetPalette(w);
2690  setPalette(w);
2691 
2692  //set the WA_Hover attribute if one of the selector depends of the hover state
2693  QVector<StyleRule> rules = styleRules(w);
2694  for (int i = 0; i < rules.count(); i++) {
2695  const Selector& selector = rules.at(i).selectors.at(0);
2696  quint64 negated = 0;
2697  quint64 cssClass = selector.pseudoClass(&negated);
2698  if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) {
2699  w->setAttribute(Qt::WA_Hover);
2701  }
2702  }
2703 
2704 
2705 #ifndef QT_NO_SCROLLAREA
2706  if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
2708  if ((rule.hasBorder() && rule.border()->hasBorderImage())
2709  || (rule.hasBackground() && !rule.background()->pixmap.isNull())) {
2710  QObject::connect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
2711  sa, SLOT(update()), Qt::UniqueConnection);
2712  QObject::connect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
2713  sa, SLOT(update()), Qt::UniqueConnection);
2714  }
2715  }
2716 #endif
2717 
2718 #ifndef QT_NO_PROGRESSBAR
2719  if (QProgressBar *pb = qobject_cast<QProgressBar *>(w)) {
2721  }
2722 #endif
2723 
2725  if (rule.hasDrawable() || rule.hasBox()) {
2726  if (w->metaObject() == &QWidget::staticMetaObject
2727 #ifndef QT_NO_ITEMVIEWS
2728  || qobject_cast<QHeaderView *>(w)
2729 #endif
2730 #ifndef QT_NO_TABBAR
2731  || qobject_cast<QTabBar *>(w)
2732 #endif
2733 #ifndef QT_NO_FRAME
2734  || qobject_cast<QFrame *>(w)
2735 #endif
2736 #ifndef QT_NO_MAINWINDOW
2737  || qobject_cast<QMainWindow *>(w)
2738 #endif
2739 #ifndef QT_NO_MDIAREA
2740  || qobject_cast<QMdiSubWindow *>(w)
2741 #endif
2742 #ifndef QT_NO_MENUBAR
2743  || qobject_cast<QMenuBar *>(w)
2744 #endif
2745  || qobject_cast<QDialog *>(w)) {
2746  w->setAttribute(Qt::WA_StyledBackground, true);
2747  }
2748  QWidget *ew = embeddedWidget(w);
2749  if (ew->autoFillBackground()) {
2750  ew->setAutoFillBackground(false);
2752  if (ew != w) { //eg. viewport of a scrollarea
2753  //(in order to draw the background anyway in case we don't.)
2755  }
2756  }
2757  if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
2758  || (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
2759  w->setAttribute(Qt::WA_OpaquePaintEvent, false);
2760  }
2761 }
void polish(QApplication *)
Reimplemented Function
const quint64 PseudoClass_Enabled
Definition: qcssparser_p.h:462
const quint64 PseudoClass_Any
Definition: qcssparser_p.h:508
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
QStyle * baseStyle() const
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
const quint64 PseudoClass_Hover
Definition: qcssparser_p.h:466
void setPalette(QWidget *)
#define SLOT(a)
Definition: qobjectdefs.h:226
const QStyleSheetBackgroundData * background() const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
QHash< const QWidget *, QHash< int, bool > > hasStyleRuleCache
bool hasBackground() const
quint64 pseudoClass(quint64 *negated=0) const
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
#define QT_NO_MAINWINDOW
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
#define QT_NO_MENUBAR
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QHash< const QWidget *, QRenderRules > renderRulesCache
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
bool autoFillBackground
whether the widget background is filled automatically
Definition: qwidget.h:218
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QStyleSheetStyleCaches * styleSheetCaches
unsigned __int64 quint64
Definition: qglobal.h:943
static QWidget * embeddedWidget(QWidget *w)
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 rece...
Definition: qobject.cpp:2580
QVector< Selector > selectors
Definition: qcssparser_p.h:605
void unsetPalette(QWidget *)
const_iterator insert(const T &value)
Definition: qset.h:179
void setGeometry(QWidget *)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:631
QVector< QCss::StyleRule > styleRules(const QWidget *w) const
bool hasNativeBorder() const
QSet< const QWidget * > autoFillDisabledWidgets
bool hasBorder() const
void setProperties(QWidget *)
bool hasBox() const
const QStyleSheetBorderData * border() const
bool hasDrawable() const
bool initWidget(const QWidget *w) const
Make sure that the cache will be clean by connecting destroyed if needed.
#define RECURSION_GUARD(RETURN)
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390
QRenderRule renderRule(const QWidget *, int, quint64=0) const
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QHash< const QWidget *, QVector< QCss::StyleRule > > styleRulesCache
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
#define QT_NO_TABBAR
The QHeaderView class provides a header row or header column for item views.
Definition: qheaderview.h:58

◆ polish() [2/3]

void QStyleSheetStyle::polish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2763 of file qstylesheetstyle.cpp.

2764 {
2765  baseStyle()->polish(app);
2766 }
QStyle * baseStyle() const
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ polish() [3/3]

void QStyleSheetStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2768 of file qstylesheetstyle.cpp.

2769 {
2770  baseStyle()->polish(pal);
2771 }
QStyle * baseStyle() const
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ positionRect() [1/2]

QRect QStyleSheetStyle::positionRect ( const QWidget w,
const QRenderRule rule1,
const QRenderRule rule2,
int  pe,
const QRect rect,
Qt::LayoutDirection  dir 
) const
private

Definition at line 2311 of file qstylesheetstyle.cpp.

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

2313 {
2314  const QStyleSheetPositionData *p = rule2.position();
2315  Origin origin = (p && p->origin != Origin_Unknown) ? p->origin : defaultOrigin(pe);
2316  QRect originRect = rule1.originRect(rect, origin);
2317  return positionRect(w, rule2, pe, originRect, dir);
2318 }
QRect originRect(const QRect &rect, Origin origin) const
const QStyleSheetPositionData * position() const
static Origin defaultOrigin(int pe)
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ positionRect() [2/2]

QRect QStyleSheetStyle::positionRect ( const QWidget w,
const QRenderRule rule2,
int  pe,
const QRect originRect,
Qt::LayoutDirection  dir 
) const
private

Definition at line 2280 of file qstylesheetstyle.cpp.

2282 {
2283  const QStyleSheetPositionData *p = rule2.position();
2284  PositionMode mode = (p && p->mode != PositionMode_Unknown) ? p->mode : defaultPositionMode(pe);
2285  Qt::Alignment position = (p && p->position != 0) ? p->position : defaultPosition(pe);
2286  QRect r;
2287 
2288  if (mode != PositionMode_Absolute) {
2289  QSize sz = defaultSize(w, rule2.size(), originRect, pe);
2290  sz = sz.expandedTo(rule2.minimumContentsSize());
2291  r = QStyle::alignedRect(dir, position, sz, originRect);
2292  if (p) {
2293  int left = p->left ? p->left : -p->right;
2294  int top = p->top ? p->top : -p->bottom;
2295  r.translate(dir == Qt::LeftToRight ? left : -left, top);
2296  }
2297  } else {
2298  r = p ? originRect.adjusted(dir == Qt::LeftToRight ? p->left : p->right, p->top,
2299  dir == Qt::LeftToRight ? -p->right : -p->left, -p->bottom)
2300  : originRect;
2301  if (rule2.hasContentsSize()) {
2302  QSize sz = rule2.size().expandedTo(rule2.minimumContentsSize());
2303  if (sz.width() == -1) sz.setWidth(r.width());
2304  if (sz.height() == -1) sz.setHeight(r.height());
2305  r = QStyle::alignedRect(dir, position, sz, r);
2306  }
2307  }
2308  return r;
2309 }
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...
Definition: qstyle.cpp:2120
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
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
PositionMode
Definition: qcssparser_p.h:331
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
QSize minimumContentsSize() const
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
int width() const
Returns the width.
Definition: qsize.h:126
const QStyleSheetPositionData * position() const
QSize defaultSize(const QWidget *, QSize, const QRect &, int) const
static PositionMode defaultPositionMode(int pe)
bool hasContentsSize() const
static Qt::Alignment defaultPosition(int pe)
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
QSize size() const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ ref()

void QStyleSheetStyle::ref ( )
inline

Definition at line 127 of file qstylesheetstyle_p.h.

◆ renderRule() [1/2]

QRenderRule QStyleSheetStyle::renderRule ( const QWidget w,
int  element,
quint64  state = 0 
) const
private

Definition at line 1717 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), drawControl(), drawPrimitive(), hitTestComplexControl(), pixelMetric(), polish(), sizeFromContents(), standardIconImplementation(), standardPixmap(), styleHint(), styleSheetPalette(), subControlRect(), subElementRect(), and updateStyleSheetFont().

1718 {
1719  qt_check_if_internal_widget(&w, &element);
1722  if (cacheIt != cache.constEnd())
1723  return cacheIt.value();
1724 
1725  if (!initWidget(w))
1726  return QRenderRule();
1727 
1728  quint64 stateMask = 0;
1729  const QVector<StyleRule> rules = styleRules(w);
1730  for (int i = 0; i < rules.count(); i++) {
1731  const Selector& selector = rules.at(i).selectors.at(0);
1732  quint64 negated = 0;
1733  stateMask |= selector.pseudoClass(&negated);
1734  stateMask |= negated;
1735  }
1736 
1737  cacheIt = cache.constFind(state & stateMask);
1738  if (cacheIt != cache.constEnd()) {
1739  const QRenderRule &newRule = cacheIt.value();
1740  cache[state] = newRule;
1741  return newRule;
1742  }
1743 
1744 
1745  const QString part = QLatin1String(knownPseudoElements[element].name);
1746  QVector<Declaration> decls = declarations(rules, part, state);
1747  QRenderRule newRule(decls, w);
1748  cache[state] = newRule;
1749  if ((state & stateMask) != state)
1750  cache[state&stateMask] = newRule;
1751  return newRule;
1752 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
friend class QRenderRule
quint64 pseudoClass(quint64 *negated=0) const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QHash< const QWidget *, QRenderRules > renderRulesCache
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
static QStyleSheetStyleCaches * styleSheetCaches
unsigned __int64 quint64
Definition: qglobal.h:943
QVector< Selector > selectors
Definition: qcssparser_p.h:605
const char * name
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
static QVector< Declaration > declarations(const QVector< StyleRule > &styleRules, const QString &part, quint64 pseudoClass=PseudoClass_Unspecified)
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QCss::StyleRule > styleRules(const QWidget *w) const
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
bool initWidget(const QWidget *w) const
Make sure that the cache will be clean by connecting destroyed if needed.
static void qt_check_if_internal_widget(const QWidget **w, int *element)
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]

◆ renderRule() [2/2]

QRenderRule QStyleSheetStyle::renderRule ( const QWidget w,
const QStyleOption opt,
int  pseudoElement = 0 
) const
private

Definition at line 1754 of file qstylesheetstyle.cpp.

1755 {
1756  quint64 extraClass = 0;
1757  QStyle::State state = opt ? opt->state : QStyle::State(QStyle::State_None);
1758 
1759  if (const QStyleOptionComplex *complex = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
1760  if (pseudoElement != PseudoElement_None) {
1761  // if not an active subcontrol, just pass enabled/disabled
1762  QStyle::SubControl subControl = knownPseudoElements[pseudoElement].subControl;
1763 
1764  if (!(complex->activeSubControls & subControl))
1766  }
1767 
1768  switch (pseudoElement) {
1771  state |= (complex->state & (QStyle::State_On|QStyle::State_ReadOnly));
1772  break;
1777 #ifndef QT_NO_SPINBOX
1778  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1779  bool on = false;
1780  bool up = pseudoElement == PseudoElement_SpinBoxUpButton
1781  || pseudoElement == PseudoElement_SpinBoxUpArrow;
1782  if ((sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) && up)
1783  on = true;
1784  else if ((sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) && !up)
1785  on = true;
1786  state |= (on ? QStyle::State_On : QStyle::State_Off);
1787  }
1788 #endif // QT_NO_SPINBOX
1789  break;
1791  state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken));
1792  break;
1796  state |= complex->state & QStyle::State_MouseOver;
1797  if (complex->state & QStyle::State_Sunken ||
1798  complex->activeSubControls & QStyle::SC_ToolButtonMenu)
1799  state |= QStyle::State_Sunken;
1800  break;
1802  state |= complex->state & QStyle::State_MouseOver;
1803  break;
1804  default:
1805  break;
1806  }
1807 
1808  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
1809  // QStyle::State_On is set when the popup is being shown
1810  // Propagate EditField Pressed state
1811  if (pseudoElement == PseudoElement_None
1812  && (complex->activeSubControls & QStyle::SC_ComboBoxEditField)
1813  && (!(state & QStyle::State_MouseOver))) {
1814  state |= QStyle::State_Sunken;
1815  }
1816 
1817  if (!combo->frame)
1818  extraClass |= PseudoClass_Frameless;
1819  if (!combo->editable)
1820  extraClass |= PseudoClass_ReadOnly;
1821  else
1822  extraClass |= PseudoClass_Editable;
1823 #ifndef QT_NO_SPINBOX
1824  } else if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1825  if (!spin->frame)
1826  extraClass |= PseudoClass_Frameless;
1827 #endif // QT_NO_SPINBOX
1828  } else if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
1829  if (gb->features & QStyleOptionFrameV2::Flat)
1830  extraClass |= PseudoClass_Flat;
1831  if (gb->lineWidth == 0)
1832  extraClass |= PseudoClass_Frameless;
1833  } else if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
1834  if (tb->titleBarState & Qt::WindowMinimized) {
1835  extraClass |= PseudoClass_Minimized;
1836  }
1837  else if (tb->titleBarState & Qt::WindowMaximized)
1838  extraClass |= PseudoClass_Maximized;
1839  }
1840  } else {
1841  // handle simple style options
1842  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1843  if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem)
1844  extraClass |= PseudoClass_Default;
1845  if (mi->checkType == QStyleOptionMenuItem::Exclusive)
1846  extraClass |= PseudoClass_Exclusive;
1847  else if (mi->checkType == QStyleOptionMenuItem::NonExclusive)
1848  extraClass |= PseudoClass_NonExclusive;
1849  if (mi->checkType != QStyleOptionMenuItem::NotCheckable)
1850  extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked)
1852  } else if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
1853  if (hdr->position == QStyleOptionHeader::OnlyOneSection)
1854  extraClass |= PseudoClass_OnlyOne;
1855  else if (hdr->position == QStyleOptionHeader::Beginning)
1856  extraClass |= PseudoClass_First;
1857  else if (hdr->position == QStyleOptionHeader::End)
1858  extraClass |= PseudoClass_Last;
1859  else if (hdr->position == QStyleOptionHeader::Middle)
1860  extraClass |= PseudoClass_Middle;
1861 
1862  if (hdr->selectedPosition == QStyleOptionHeader::NextAndPreviousAreSelected)
1864  else if (hdr->selectedPosition == QStyleOptionHeader::NextIsSelected)
1865  extraClass |= PseudoClass_NextSelected;
1866  else if (hdr->selectedPosition == QStyleOptionHeader::PreviousIsSelected)
1867  extraClass |= PseudoClass_PreviousSelected;
1868 #ifndef QT_NO_TABWIDGET
1869  } else if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
1870  switch (tab->shape) {
1871  case QTabBar::RoundedNorth:
1873  extraClass |= PseudoClass_Top;
1874  break;
1875  case QTabBar::RoundedSouth:
1877  extraClass |= PseudoClass_Bottom;
1878  break;
1879  case QTabBar::RoundedEast:
1881  extraClass |= PseudoClass_Left;
1882  break;
1883  case QTabBar::RoundedWest:
1885  extraClass |= PseudoClass_Right;
1886  break;
1887  default:
1888  break;
1889  }
1890 #endif
1891 #ifndef QT_NO_TABBAR
1892  } else if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1893  if (tab->position == QStyleOptionTab::OnlyOneTab)
1894  extraClass |= PseudoClass_OnlyOne;
1895  else if (tab->position == QStyleOptionTab::Beginning)
1896  extraClass |= PseudoClass_First;
1897  else if (tab->position == QStyleOptionTab::End)
1898  extraClass |= PseudoClass_Last;
1899  else if (tab->position == QStyleOptionTab::Middle)
1900  extraClass |= PseudoClass_Middle;
1901 
1902  if (tab->selectedPosition == QStyleOptionTab::NextIsSelected)
1903  extraClass |= PseudoClass_NextSelected;
1904  else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
1905  extraClass |= PseudoClass_PreviousSelected;
1906 
1907  switch (tab->shape) {
1908  case QTabBar::RoundedNorth:
1910  extraClass |= PseudoClass_Top;
1911  break;
1912  case QTabBar::RoundedSouth:
1914  extraClass |= PseudoClass_Bottom;
1915  break;
1916  case QTabBar::RoundedEast:
1918  extraClass |= PseudoClass_Left;
1919  break;
1920  case QTabBar::RoundedWest:
1922  extraClass |= PseudoClass_Right;
1923  break;
1924  default:
1925  break;
1926  }
1927 #endif // QT_NO_TABBAR
1928  } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1929  if (btn->features & QStyleOptionButton::Flat)
1930  extraClass |= PseudoClass_Flat;
1931  if (btn->features & QStyleOptionButton::DefaultButton)
1932  extraClass |= PseudoClass_Default;
1933  } else if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
1934  if (frm->lineWidth == 0)
1935  extraClass |= PseudoClass_Frameless;
1936  if (const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
1937  if (frame2->features & QStyleOptionFrameV2::Flat)
1938  extraClass |= PseudoClass_Flat;
1939  }
1940  }
1941 #ifndef QT_NO_TOOLBAR
1942  else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
1943  if (tb->toolBarArea == Qt::LeftToolBarArea)
1944  extraClass |= PseudoClass_Left;
1945  else if (tb->toolBarArea == Qt::RightToolBarArea)
1946  extraClass |= PseudoClass_Right;
1947  else if (tb->toolBarArea == Qt::TopToolBarArea)
1948  extraClass |= PseudoClass_Top;
1949  else if (tb->toolBarArea == Qt::BottomToolBarArea)
1950  extraClass |= PseudoClass_Bottom;
1951 
1952  if (tb->positionWithinLine == QStyleOptionToolBar::Beginning)
1953  extraClass |= PseudoClass_First;
1954  else if (tb->positionWithinLine == QStyleOptionToolBar::Middle)
1955  extraClass |= PseudoClass_Middle;
1956  else if (tb->positionWithinLine == QStyleOptionToolBar::End)
1957  extraClass |= PseudoClass_Last;
1958  else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
1959  extraClass |= PseudoClass_OnlyOne;
1960  }
1961 #endif // QT_NO_TOOLBAR
1962 #ifndef QT_NO_TOOLBOX
1963  else if (const QStyleOptionToolBoxV2 *tab = qstyleoption_cast<const QStyleOptionToolBoxV2 *>(opt)) {
1964  if (tab->position == QStyleOptionToolBoxV2::OnlyOneTab)
1965  extraClass |= PseudoClass_OnlyOne;
1966  else if (tab->position == QStyleOptionToolBoxV2::Beginning)
1967  extraClass |= PseudoClass_First;
1968  else if (tab->position == QStyleOptionToolBoxV2::End)
1969  extraClass |= PseudoClass_Last;
1970  else if (tab->position == QStyleOptionToolBoxV2::Middle)
1971  extraClass |= PseudoClass_Middle;
1972 
1973  if (tab->selectedPosition == QStyleOptionToolBoxV2::NextIsSelected)
1974  extraClass |= PseudoClass_NextSelected;
1975  else if (tab->selectedPosition == QStyleOptionToolBoxV2::PreviousIsSelected)
1976  extraClass |= PseudoClass_PreviousSelected;
1977  }
1978 #endif // QT_NO_TOOLBOX
1979 #ifndef QT_NO_DOCKWIDGET
1980  else if (const QStyleOptionDockWidgetV2 *dw = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
1981  if (dw->verticalTitleBar)
1982  extraClass |= PseudoClass_Vertical;
1983  else
1984  extraClass |= PseudoClass_Horizontal;
1985  if (dw->closable)
1986  extraClass |= PseudoClass_Closable;
1987  if (dw->floatable)
1988  extraClass |= PseudoClass_Floatable;
1989  if (dw->movable)
1990  extraClass |= PseudoClass_Movable;
1991  }
1992 #endif // QT_NO_DOCKWIDGET
1993 #ifndef QT_NO_ITEMVIEWS
1994  else if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
1995  if (v2->features & QStyleOptionViewItemV2::Alternate)
1996  extraClass |= PseudoClass_Alternate;
1997  if (const QStyleOptionViewItemV4 *v4 = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
1998  if (v4->viewItemPosition == QStyleOptionViewItemV4::OnlyOne)
1999  extraClass |= PseudoClass_OnlyOne;
2000  else if (v4->viewItemPosition == QStyleOptionViewItemV4::Beginning)
2001  extraClass |= PseudoClass_First;
2002  else if (v4->viewItemPosition == QStyleOptionViewItemV4::End)
2003  extraClass |= PseudoClass_Last;
2004  else if (v4->viewItemPosition == QStyleOptionViewItemV4::Middle)
2005  extraClass |= PseudoClass_Middle;
2006  }
2007  }
2008 #endif
2009 #ifndef QT_NO_LINEEDIT
2010  // LineEdit sets Sunken flag to indicate Sunken frame (argh)
2011  if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(w)) {
2012  state &= ~QStyle::State_Sunken;
2013  if (lineEdit->hasFrame()) {
2014  extraClass &= ~PseudoClass_Frameless;
2015  } else {
2016  extraClass |= PseudoClass_Frameless;
2017  }
2018  } else
2019 #endif
2020  if (const QFrame *frm = qobject_cast<const QFrame *>(w)) {
2021  if (frm->lineWidth() == 0)
2022  extraClass |= PseudoClass_Frameless;
2023  }
2024  }
2025 
2026  return renderRule(w, pseudoElement, pseudoClass(state) | extraClass);
2027 }
const quint64 PseudoClass_Off
Definition: qcssparser_p.h:500
const quint64 PseudoClass_Last
Definition: qcssparser_p.h:479
The QStyleOptionToolBoxV2 class is used to describe the parameters necessary for drawing a frame in Q...
Definition: qstyleoption.h:649
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
const quint64 PseudoClass_Exclusive
Definition: qcssparser_p.h:489
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
const quint64 PseudoClass_Vertical
Definition: qcssparser_p.h:473
const quint64 PseudoClass_Middle
Definition: qcssparser_p.h:480
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
const quint64 PseudoClass_Minimized
Definition: qcssparser_p.h:497
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QStyle::SubControl subControl
const quint64 PseudoClass_ReadOnly
Definition: qcssparser_p.h:492
const quint64 PseudoClass_Checked
Definition: qcssparser_p.h:467
The QStyleOptionViewItemV2 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:562
const quint64 PseudoClass_Unchecked
Definition: qcssparser_p.h:468
virtual ~QStyle()
Destroys the style object.
Definition: qstyle.cpp:362
const quint64 PseudoClass_Horizontal
Definition: qcssparser_p.h:472
unsigned __int64 quint64
Definition: qglobal.h:943
const quint64 PseudoClass_Left
Definition: qcssparser_p.h:485
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
const quint64 PseudoClass_Movable
Definition: qcssparser_p.h:495
const quint64 PseudoClass_NonExclusive
Definition: qcssparser_p.h:490
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
const quint64 PseudoClass_Right
Definition: qcssparser_p.h:486
const quint64 PseudoClass_Bottom
Definition: qcssparser_p.h:488
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
const quint64 PseudoClass_Flat
Definition: qcssparser_p.h:484
const quint64 PseudoClass_Alternate
Definition: qcssparser_p.h:506
const quint64 PseudoClass_Frameless
Definition: qcssparser_p.h:491
const quint64 PseudoClass_Editable
Definition: qcssparser_p.h:501
const quint64 PseudoClass_OnlyOne
Definition: qcssparser_p.h:481
const quint64 PseudoClass_PreviousSelected
Definition: qcssparser_p.h:482
State
Definition: qaudio.h:59
const quint64 PseudoClass_Maximized
Definition: qcssparser_p.h:498
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
static quint64 pseudoClass(QStyle::State state)
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
const quint64 PseudoClass_First
Definition: qcssparser_p.h:478
QRenderRule renderRule(const QWidget *, int, quint64=0) const
const quint64 PseudoClass_Top
Definition: qcssparser_p.h:487
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
const quint64 PseudoClass_Default
Definition: qcssparser_p.h:477
const quint64 PseudoClass_Closable
Definition: qcssparser_p.h:494
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
const quint64 PseudoClass_Floatable
Definition: qcssparser_p.h:496
const quint64 PseudoClass_On
Definition: qcssparser_p.h:499
const quint64 PseudoClass_NextSelected
Definition: qcssparser_p.h:483

◆ repolish() [1/2]

void QStyleSheetStyle::repolish ( QWidget widget)

Definition at line 2773 of file qstylesheetstyle.cpp.

Referenced by QWidgetPrivate::inheritStyle(), QApplication::setStyleSheet(), and QWidget::setStyleSheet().

2774 {
2775  QList<const QWidget *> children = w->findChildren<const QWidget *>(QString());
2776  children.append(w);
2777  styleSheetCaches->styleSheetCache.remove(w);
2778  updateWidgets(children);
2779 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QHash< const void *, QCss::StyleSheet > styleSheetCache
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QStyleSheetStyleCaches * styleSheetCaches
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
static void updateWidgets(const QList< const QWidget *> &widgets)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ repolish() [2/2]

void QStyleSheetStyle::repolish ( QApplication app)

Definition at line 2781 of file qstylesheetstyle.cpp.

2782 {
2783  Q_UNUSED(app);
2789  updateWidgets(allWidgets);
2790 }
void clear()
Removes all items from the hash.
Definition: qhash.h:574
QHash< const QWidget *, QHash< int, bool > > hasStyleRuleCache
QHash< const void *, QCss::StyleSheet > styleSheetCache
QHash< const QWidget *, QRenderRules > renderRulesCache
static QStyleSheetStyleCaches * styleSheetCaches
#define qApp
QHash< const QWidget *, QVector< QCss::StyleRule > > styleRulesCache
static void updateWidgets(const QList< const QWidget *> &widgets)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Definition: qhash.h:648
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ resolveAlignment()

Qt::Alignment QStyleSheetStyle::resolveAlignment ( Qt::LayoutDirection  layDir,
Qt::Alignment  src 
)
staticprivate

Definition at line 5872 of file qstylesheetstyle.cpp.

Referenced by subControlRect().

5873 {
5874  if (layDir == Qt::LeftToRight || src & Qt::AlignAbsolute)
5875  return src;
5876 
5877  if (src & Qt::AlignLeft) {
5878  src &= ~Qt::AlignLeft;
5879  src |= Qt::AlignRight;
5880  } else if (src & Qt::AlignRight) {
5881  src &= ~Qt::AlignRight;
5882  src |= Qt::AlignLeft;
5883  }
5884  src |= Qt::AlignAbsolute;
5885  return src;
5886 }
Definition: qnamespace.h:54

◆ saveWidgetFont()

void QStyleSheetStyle::saveWidgetFont ( QWidget w,
const QFont font 
) const

Definition at line 5841 of file qstylesheetstyle.cpp.

Referenced by QWidget::setFont().

5842 {
5843  w->setProperty("_q_styleSheetWidgetFont", font);
5844 }
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755

◆ setGeometry()

void QStyleSheetStyle::setGeometry ( QWidget w)
private

Definition at line 2437 of file qstylesheetstyle.cpp.

Referenced by polish().

2438 {
2440  const QStyleSheetGeometryData *geo = rule.geometry();
2441  if (w->property("_q_stylesheet_minw").toBool()
2442  && ((!rule.hasGeometry() || geo->minWidth == -1))) {
2443  w->setMinimumWidth(0);
2444  w->setProperty("_q_stylesheet_minw", QVariant());
2445  }
2446  if (w->property("_q_stylesheet_minh").toBool()
2447  && ((!rule.hasGeometry() || geo->minHeight == -1))) {
2448  w->setMinimumHeight(0);
2449  w->setProperty("_q_stylesheet_minh", QVariant());
2450  }
2451  if (w->property("_q_stylesheet_maxw").toBool()
2452  && ((!rule.hasGeometry() || geo->maxWidth == -1))) {
2454  w->setProperty("_q_stylesheet_maxw", QVariant());
2455  }
2456  if (w->property("_q_stylesheet_maxh").toBool()
2457  && ((!rule.hasGeometry() || geo->maxHeight == -1))) {
2459  w->setProperty("_q_stylesheet_maxh", QVariant());
2460  }
2461 
2462 
2463  if (rule.hasGeometry()) {
2464  if (geo->minWidth != -1) {
2465  w->setProperty("_q_stylesheet_minw", true);
2466  w->setMinimumWidth(rule.boxSize(QSize(qMax(geo->width, geo->minWidth), 0)).width());
2467  }
2468  if (geo->minHeight != -1) {
2469  w->setProperty("_q_stylesheet_minh", true);
2470  w->setMinimumHeight(rule.boxSize(QSize(0, qMax(geo->height, geo->minHeight))).height());
2471  }
2472  if (geo->maxWidth != -1) {
2473  w->setProperty("_q_stylesheet_maxw", true);
2474  w->setMaximumWidth(rule.boxSize(QSize(qMin(geo->width == -1 ? QWIDGETSIZE_MAX : geo->width,
2475  geo->maxWidth == -1 ? QWIDGETSIZE_MAX : geo->maxWidth), 0)).width());
2476  }
2477  if (geo->maxHeight != -1) {
2478  w->setProperty("_q_stylesheet_maxh", true);
2479  w->setMaximumHeight(rule.boxSize(QSize(0, qMin(geo->height == -1 ? QWIDGETSIZE_MAX : geo->height,
2480  geo->maxHeight == -1 ? QWIDGETSIZE_MAX : geo->maxHeight))).height());
2481  }
2482  }
2483 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const quint64 PseudoClass_Enabled
Definition: qcssparser_p.h:462
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool hasGeometry() const
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
void setMinimumHeight(int minh)
Definition: qwidget.cpp:4334
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
Returns the width.
Definition: qsize.h:126
void setMaximumWidth(int maxw)
Definition: qwidget.cpp:4343
const QStyleSheetGeometryData * geometry() const
void setMaximumHeight(int maxh)
Definition: qwidget.cpp:4352
int height() const
Returns the height.
Definition: qsize.h:129
void setMinimumWidth(int minw)
Definition: qwidget.cpp:4325
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QSize boxSize(const QSize &s, int flags=All) const
static quint64 extendedPseudoClass(const QWidget *w)

◆ setPalette()

void QStyleSheetStyle::setPalette ( QWidget w)
private

Definition at line 2533 of file qstylesheetstyle.cpp.

Referenced by polish().

2534 {
2535  struct RuleRoleMap {
2536  int state;
2537  QPalette::ColorGroup group;
2538  } map[3] = {
2542  };
2543 
2544  QPalette p = w->palette();
2545  QWidget *ew = embeddedWidget(w);
2546 
2547  for (int i = 0; i < 3; i++) {
2549  if (i == 0) {
2550  if (!w->property("_q_styleSheetWidgetFont").isValid()) {
2551  saveWidgetFont(w, w->font());
2552  }
2554  if (ew != w)
2556  }
2557 
2558  rule.configurePalette(&p, map[i].group, ew, ew != w);
2559  }
2560 
2562  w->setPalette(p);
2563  if (ew != w)
2564  ew->setPalette(p);
2565 }
QPalette palette
the widget&#39;s palette
Definition: qwidget.h:180
const quint64 PseudoClass_Enabled
Definition: qcssparser_p.h:462
QHash< const QWidget *, QPalette > customPaletteWidgets
const quint64 PseudoClass_Active
Definition: qcssparser_p.h:493
QFont font
the font currently set for the widget
Definition: qwidget.h:181
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
ColorGroup
Definition: qpalette.h:92
static QStyleSheetStyleCaches * styleSheetCaches
static QWidget * embeddedWidget(QWidget *w)
void saveWidgetFont(QWidget *w, const QFont &font) const
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QRenderRule renderRule(const QWidget *, int, quint64=0) const
static quint64 extendedPseudoClass(const QWidget *w)
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
const quint64 PseudoClass_Disabled
Definition: qcssparser_p.h:463
void updateStyleSheetFont(QWidget *w) const
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ setProperties()

void QStyleSheetStyle::setProperties ( QWidget w)
private

Definition at line 2485 of file qstylesheetstyle.cpp.

Referenced by polish().

2486 {
2487  QHash<QString, QVariant> propertyHash;
2489 
2490  // run through the declarations in order
2491  for (int i = 0; i < decls.count(); i++) {
2492  const Declaration &decl = decls.at(i);
2493  QString property = decl.d->property;
2494  if (!property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive))
2495  continue;
2496  property.remove(0, 10); // strip "qproperty-"
2497  const QVariant value = w->property(property.toLatin1());
2498  const QMetaObject *metaObject = w->metaObject();
2499  int index = metaObject->indexOfProperty(property.toLatin1());
2500  if (index == -1) {
2501  qWarning() << w << " does not have a property named " << property;
2502  continue;
2503  }
2504  QMetaProperty metaProperty = metaObject->property(index);
2505  if (!metaProperty.isWritable() || !metaProperty.isDesignable()) {
2506  qWarning() << w << " cannot design property named " << property;
2507  continue;
2508  }
2509  QVariant v;
2510  switch (value.type()) {
2511  case QVariant::Icon: v = decl.iconValue(); break;
2512  case QVariant::Image: v = QImage(decl.uriValue()); break;
2513  case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
2514  case QVariant::Rect: v = decl.rectValue(); break;
2515  case QVariant::Size: v = decl.sizeValue(); break;
2516  case QVariant::Color: v = decl.colorValue(); break;
2517  case QVariant::Brush: v = decl.brushValue(); break;
2518 #ifndef QT_NO_SHORTCUT
2519  case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
2520 #endif
2521  default: v = decl.d->values.at(0).variant; break;
2522  }
2523  propertyHash[property] = v;
2524  }
2525  // apply the values
2526  const QList<QString> properties = propertyHash.keys();
2527  for (int i = 0; i < properties.count(); i++) {
2528  const QString &property = properties.at(i);
2529  w->setProperty(property.toLatin1(), propertyHash[property]);
2530  }
2531 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QColor colorValue(const QPalette &=QPalette()) const
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
QRect rectValue() const
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
QSize sizeValue() const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
QIcon iconValue() const
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
static QVector< Declaration > declarations(const QVector< StyleRule > &styleRules, const QString &part, quint64 pseudoClass=PseudoClass_Unspecified)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QCss::StyleRule > styleRules(const QWidget *w) const
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
QBrush brushValue(const QPalette &=QPalette()) const
QString uriValue() const
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
bool isDesignable(const QObject *obj=0) const
Returns true if this property is designable for the given object; otherwise returns false...
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
quint16 index
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Definition: qhash.h:648
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ sizeFromContents()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4801 of file qstylesheetstyle.cpp.

4803 {
4804  RECURSION_GUARD(return baseStyle()->sizeFromContents(ct, opt, csz, w))
4805 
4806  QRenderRule rule = renderRule(w, opt);
4807  QSize sz = rule.adjustSize(csz);
4808 
4809  switch (ct) {
4810  case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1)
4811  if (rule.hasBox() || !rule.hasNativeBorder())
4812  return csz;
4813  return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
4814  : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
4815  case CT_ToolButton:
4816  if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw())
4817  sz += QSize(3, 3); // ### broken QToolButton
4818  //fall thought
4819  case CT_ComboBox:
4820  case CT_PushButton:
4821  if (rule.hasBox() || !rule.hasNativeBorder()) {
4822  if(ct == CT_ComboBox) {
4823  //add some space for the drop down.
4825  QRect comboRect = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
4826  //+2 because there is hardcoded margins in QCommonStyle::drawControl(CE_ComboBoxLabel)
4827  sz += QSize(comboRect.width() + 2, 0);
4828  }
4829  return rule.boxSize(sz);
4830  }
4831  sz = rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
4832  : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
4833  return rule.boxSize(sz, Margin);
4834 
4835  case CT_HeaderSection: {
4836  if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
4838  if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) {
4839  sz = subRule.adjustSize(csz);
4840  if (!subRule.hasGeometry()) {
4841  QSize nativeContentsSize;
4842  bool nullIcon = hdr->icon.isNull();
4843  int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
4844  QSize txt = hdr->fontMetrics.size(0, hdr->text);
4845  nativeContentsSize.setHeight(qMax(iconSize, txt.height()));
4846  nativeContentsSize.setWidth(iconSize + txt.width());
4847  sz = sz.expandedTo(nativeContentsSize);
4848  }
4849  return subRule.size(sz);
4850  }
4851  return subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
4852  : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
4853  }
4854  }
4855  break;
4856  case CT_GroupBox:
4857  case CT_LineEdit:
4858 #ifndef QT_NO_SPINBOX
4859  // ### hopelessly broken QAbstractSpinBox (part 2)
4860  if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) {
4861  QRenderRule rule = renderRule(spinBox, opt);
4862  if (rule.hasBox() || !rule.hasNativeBorder())
4863  return csz;
4864  return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
4865  : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
4866  }
4867 #endif
4868  if (rule.hasBox() || !rule.hasNativeBorder()) {
4869  return rule.boxSize(sz);
4870  }
4871  break;
4872 
4873  case CT_CheckBox:
4874  case CT_RadioButton:
4875  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4876  if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
4877  bool isRadio = (ct == CT_RadioButton);
4878  int iw = pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
4879  : PM_IndicatorWidth, btn, w);
4880  int ih = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
4881  : PM_IndicatorHeight, btn, w);
4882 
4883  int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
4884  : PM_CheckBoxLabelSpacing, btn, w);
4885  sz.setWidth(sz.width() + iw + spacing);
4886  sz.setHeight(qMax(sz.height(), ih));
4887  return rule.boxSize(sz);
4888  }
4889  }
4890  break;
4891 
4892  case CT_Menu:
4893  case CT_MenuBar: // already has everything!
4894  case CT_ScrollBar:
4895  if (rule.hasBox() || rule.hasBorder())
4896  return sz;
4897  break;
4898 
4899  case CT_MenuItem:
4900  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4901  PseudoElement pe = (mi->menuItemType == QStyleOptionMenuItem::Separator)
4903  QRenderRule subRule = renderRule(w, opt, pe);
4904  if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
4905  return QSize(sz.width(), subRule.size().height());
4906  } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) {
4907  int width = csz.width();
4908  if (mi->text.contains(QLatin1Char('\t')))
4909  width += 12; //as in QCommonStyle
4910  return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height())));
4911  }
4912  }
4913  break;
4914 
4915  case CT_Splitter:
4916  case CT_MenuBarItem: {
4918  QRenderRule subRule = renderRule(w, opt, pe);
4919  if (subRule.hasBox() || subRule.hasBorder())
4920  return subRule.boxSize(sz);
4921  break;
4922  }
4923 
4924  case CT_ProgressBar:
4925  case CT_SizeGrip:
4926  return (rule.hasContentsSize())
4927  ? rule.size(sz)
4928  : rule.boxSize(baseStyle()->sizeFromContents(ct, opt, sz, w));
4929  break;
4930 
4931  case CT_Slider:
4932  if (rule.hasBorder() || rule.hasBox() || rule.hasGeometry())
4933  return rule.boxSize(sz);
4934  break;
4935 
4936 #ifndef QT_NO_TABBAR
4937  case CT_TabBarTab: {
4938  QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
4939  if (subRule.hasBox() || !subRule.hasNativeBorder()) {
4940  int spaceForIcon = 0;
4941  bool vertical = false;
4942  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
4943  if (!tab->icon.isNull())
4944  spaceForIcon = 6 /* icon offset */ + 4 /* spacing */ + 2 /* magic */; // ###: hardcoded to match with common style
4945  vertical = verticalTabs(tab->shape);
4946  }
4947  sz = csz + QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0);
4948  return subRule.boxSize(subRule.adjustSize(sz));
4949  }
4950 #ifdef Q_WS_MAC
4951  if (baseStyle()->inherits("QMacStyle")) {
4952  //adjust the size after the call to the style because the mac style ignore the size arguments anyway.
4953  //this might cause the (max-){width,height} property to include the native style border while they should not.
4954  return subRule.adjustSize(baseStyle()->sizeFromContents(ct, opt, csz, w));
4955  }
4956 #endif
4957  sz = subRule.adjustSize(csz);
4958  break;
4959  }
4960 #endif // QT_NO_TABBAR
4961 
4962  case CT_MdiControls:
4963  if (const QStyleOptionComplex *ccOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
4967  break;
4968 
4969  QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
4970  if (layout.isEmpty())
4971  layout = subControlLayout(QLatin1String("mNX"));
4972 
4973  int width = 0, height = 0;
4974  for (int i = 0; i < layout.count(); i++) {
4975  int layoutButton = layout[i].toInt();
4976  if (layoutButton < PseudoElement_MdiCloseButton
4977  || layoutButton > PseudoElement_MdiNormalButton)
4978  continue;
4980  if (!(ccOpt->subControls & sc))
4981  continue;
4982  QRenderRule subRule = renderRule(w, opt, layoutButton);
4983  QSize sz = subRule.size();
4984  width += sz.width();
4985  height = qMax(height, sz.height());
4986  }
4987 
4988  return QSize(width, height);
4989  }
4990  break;
4991 
4992 #ifndef QT_NO_ITEMVIEWS
4993  case CT_ItemViewItem: {
4994  QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
4995  sz = baseStyle()->sizeFromContents(ct, opt, csz, w);
4996  sz = subRule.adjustSize(sz);
4997  if (subRule.hasBox() || subRule.hasBorder())
4998  sz = subRule.boxSize(sz);
4999  return sz;
5000  }
5001 #endif // QT_NO_ITEMVIEWS
5002 
5003  default:
5004  break;
5005  }
5006 
5007  return baseStyle()->sizeFromContents(ct, opt, sz, w);
5008 }
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QVariant styleHint(const QString &sh) const
static QList< QVariant > subControlLayout(const QString &layout)
bool hasGeometry() const
bool hasStyleRule(const QWidget *w, int part) const
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
QStyle * baseStyle() const
static bool verticalTabs(QTabBar::Shape shape)
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
PseudoElement
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
QStyle::SubControl subControl
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
int width() const
Returns the width.
Definition: qsize.h:126
const char * layout
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
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
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
bool hasNativeBorder() const
bool hasContentsSize() const
bool baseStyleCanDraw() const
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
bool hasBorder() const
bool hasBox() const
#define RECURSION_GUARD(RETURN)
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QSize adjustSize(const QSize &sz)
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
QSize boxSize(const QSize &s, int flags=All) const
QSize size() const
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
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function

◆ standardIconImplementation

QIcon QStyleSheetStyle::standardIconImplementation ( StandardPixmap  standardIcon,
const QStyleOption opt = 0,
const QWidget widget = 0 
) const
protectedslot

Definition at line 5074 of file qstylesheetstyle.cpp.

5076 {
5079  if (!s.isEmpty()) {
5080  QRenderRule rule = renderRule(w, opt);
5081  if (rule.hasStyleHint(s))
5082  return qvariant_cast<QIcon>(rule.styleHint(s));
5083  }
5084  return baseStyle()->standardIcon(standardIcon, opt, w);
5085 }
QVariant styleHint(const QString &sh) const
QStyle * baseStyle() const
static QLatin1String propertyNameForStandardPixmap(QStyle::StandardPixmap sp)
The QString class provides a Unicode character string.
Definition: qstring.h:83
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 isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define RECURSION_GUARD(RETURN)
bool hasStyleHint(const QString &sh) const
QRenderRule renderRule(const QWidget *, int, quint64=0) const

◆ standardPalette()

QPalette QStyleSheetStyle::standardPalette ( ) const
virtual

Returns the style's standard palette.

Note that on systems that support system colors, the style's standard palette is not used. In particular, the Windows XP, Vista, and Mac styles do not use the standard palette, but make use of native theme engines. With these styles, you should not set the palette with QApplication::setStandardPalette().

Reimplemented from QStyle.

Definition at line 5087 of file qstylesheetstyle.cpp.

5088 {
5089  return baseStyle()->standardPalette();
5090 }
QStyle * baseStyle() const
virtual QPalette standardPalette() const
Returns the style&#39;s standard palette.
Definition: qstyle.cpp:2283

◆ standardPixmap()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5092 of file qstylesheetstyle.cpp.

5094 {
5097  if (!s.isEmpty()) {
5098  QRenderRule rule = renderRule(w, opt);
5099  if (rule.hasStyleHint(s)) {
5100  QIcon icon = qvariant_cast<QIcon>(rule.styleHint(s));
5101  return icon.pixmap(16, 16); // ###: unhard-code this if someone complains
5102  }
5103  }
5104  return baseStyle()->standardPixmap(standardPixmap, opt, w);
5105 }
QVariant styleHint(const QString &sh) const
QStyle * baseStyle() const
static QLatin1String propertyNameForStandardPixmap(QStyle::StandardPixmap sp)
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define RECURSION_GUARD(RETURN)
bool hasStyleHint(const QString &sh) const
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
QRenderRule renderRule(const QWidget *, int, quint64=0) const
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=0, const QWidget *widget=0) const =0
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option=0, const QWidget *w=0) const
Reimplemented Function
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ styleHint()

int QStyleSheetStyle::styleHint ( StyleHint  sh,
const QStyleOption opt = 0,
const QWidget w = 0,
QStyleHintReturn shret = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5123 of file qstylesheetstyle.cpp.

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

5125 {
5126  RECURSION_GUARD(return baseStyle()->styleHint(sh, opt, w, shret))
5127  // Prevent endless loop if somebody use isActiveWindow property as selector.
5128  // QWidget::isActiveWindow uses this styleHint to determine if the window is active or not
5129  if (sh == SH_Widget_ShareActivation)
5130  return baseStyle()->styleHint(sh, opt, w, shret);
5131 
5132  QRenderRule rule = renderRule(w, opt);
5133  QString s;
5134  switch (sh) {
5135  case SH_LineEdit_PasswordCharacter: s = QLatin1String("lineedit-password-character"); break;
5136  case SH_DitherDisabledText: s = QLatin1String("dither-disabled-text"); break;
5137  case SH_EtchDisabledText: s = QLatin1String("etch-disabled-text"); break;
5138  case SH_ItemView_ActivateItemOnSingleClick: s = QLatin1String("activate-on-singleclick"); break;
5139  case SH_ItemView_ShowDecorationSelected: s = QLatin1String("show-decoration-selected"); break;
5140  case SH_Table_GridLineColor: s = QLatin1String("gridline-color"); break;
5141  case SH_DialogButtonLayout: s = QLatin1String("button-layout"); break;
5142  case SH_ToolTipLabel_Opacity: s = QLatin1String("opacity"); break;
5143  case SH_ComboBox_Popup: s = QLatin1String("combobox-popup"); break;
5144  case SH_ComboBox_ListMouseTracking: s = QLatin1String("combobox-list-mousetracking"); break;
5145  case SH_MenuBar_AltKeyNavigation: s = QLatin1String("menubar-altkey-navigation"); break;
5146  case SH_Menu_Scrollable: s = QLatin1String("menu-scrollable"); break;
5147  case SH_DrawMenuBarSeparator: s = QLatin1String("menubar-separator"); break;
5148  case SH_MenuBar_MouseTracking: s = QLatin1String("mouse-tracking"); break;
5149  case SH_SpinBox_ClickAutoRepeatRate: s = QLatin1String("spinbox-click-autorepeat-rate"); break;
5150  case SH_SpinControls_DisableOnBounds: s = QLatin1String("spincontrol-disable-on-bounds"); break;
5151  case SH_MessageBox_TextInteractionFlags: s = QLatin1String("messagebox-text-interaction-flags"); break;
5152  case SH_ToolButton_PopupDelay: s = QLatin1String("toolbutton-popup-delay"); break;
5154  if (renderRule(w, opt, PseudoElement_ToolBoxTab).hasFont)
5155  return 0;
5156  break;
5158  if (rule.hasPalette() && rule.palette()->foreground.style() != Qt::NoBrush)
5159  return rule.palette()->foreground.color().rgba();
5160  break;
5161  case SH_ScrollView_FrameOnlyAroundContents: s = QLatin1String("scrollview-frame-around-contents"); break;
5162  case SH_ScrollBar_ContextMenu: s = QLatin1String("scrollbar-contextmenu"); break;
5163  case SH_ScrollBar_LeftClickAbsolutePosition: s = QLatin1String("scrollbar-leftclick-absolute-position"); break;
5164  case SH_ScrollBar_MiddleClickAbsolutePosition: s = QLatin1String("scrollbar-middleclick-absolute-position"); break;
5165  case SH_ScrollBar_RollBetweenButtons: s = QLatin1String("scrollbar-roll-between-buttons"); break;
5166  case SH_ScrollBar_ScrollWhenPointerLeavesControl: s = QLatin1String("scrollbar-scroll-when-pointer-leaves-control"); break;
5167  case SH_TabBar_Alignment:
5168 #ifndef QT_NO_TABWIDGET
5169  if (qobject_cast<const QTabWidget *>(w)) {
5170  rule = renderRule(w, opt, PseudoElement_TabWidgetTabBar);
5171  if (rule.hasPosition())
5172  return rule.position()->position;
5173  }
5174 #endif // QT_NO_TABWIDGET
5175  s = QLatin1String("alignment");
5176  break;
5177 #ifndef QT_NO_TABBAR
5180  if (rule.hasPosition()) {
5181  Qt::Alignment align = rule.position()->position;
5182  if (align & Qt::AlignLeft || align & Qt::AlignTop)
5183  return QTabBar::LeftSide;
5184  if (align & Qt::AlignRight || align & Qt::AlignBottom)
5185  return QTabBar::RightSide;
5186  }
5187  break;
5188 #endif
5189  case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break;
5190  case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break;
5192 #ifndef QT_NO_COMBOBOX
5193  if (qobject_cast<const QComboBox *>(w)) {
5195  if (view) {
5196  view->ensurePolished();
5197  QRenderRule subRule = renderRule(view, PseudoElement_None);
5198  if (subRule.hasBox() || !subRule.hasNativeBorder())
5199  return QFrame::NoFrame;
5200  }
5201  }
5202 #endif // QT_NO_COMBOBOX
5203  break;
5204  case SH_DialogButtonBox_ButtonsHaveIcons: s = QLatin1String("dialogbuttonbox-buttons-have-icons"); break;
5205  case SH_Workspace_FillSpaceOnMaximize: s = QLatin1String("mdi-fill-space-on-maximize"); break;
5206  case SH_TitleBar_NoBorder:
5207  if (rule.hasBorder())
5208  return !rule.border()->borders[LeftEdge];
5209  break;
5210  case SH_TitleBar_AutoRaise: { // plain absurd
5211  QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
5212  if (subRule.hasDrawable())
5213  return 1;
5214  break;
5215  }
5216  case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break;
5217  case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break;
5218  default: break;
5219  }
5220  if (!s.isEmpty() && rule.hasStyleHint(s)) {
5221  return rule.styleHint(s).toInt();
5222  }
5223 
5224  return baseStyle()->styleHint(sh, opt, w, shret);
5225 }
QVariant styleHint(const QString &sh) const
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
QStyle * baseStyle() const
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...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool hasPosition() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
const QStyleSheetPaletteData * palette() const
const QStyleSheetPositionData * position() const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
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
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QAbstractItemView class provides the basic functionality for item view classes.
bool hasNativeBorder() const
bool hasBorder() const
bool hasBox() const
const QStyleSheetBorderData * border() const
bool hasDrawable() const
#define RECURSION_GUARD(RETURN)
bool hasStyleHint(const QString &sh) const
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
bool hasPalette() const
QRenderRule renderRule(const QWidget *, int, quint64=0) const
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019

◆ styleRules()

QVector< QCss::StyleRule > QStyleSheetStyle::styleRules ( const QWidget w) const
private

Definition at line 1519 of file qstylesheetstyle.cpp.

Referenced by polish().

1520 {
1522  if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
1523  return cacheIt.value();
1524 
1525  if (!initWidget(w)) {
1526  return QVector<StyleRule>();
1527  }
1528 
1529  QStyleSheetStyleSelector styleSelector;
1530 
1531  StyleSheet defaultSs;
1533  if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1534  defaultSs = getDefaultStyleSheet();
1535  QStyle *bs = baseStyle();
1536  styleSheetCaches->styleSheetCache.insert(bs, defaultSs);
1538  } else {
1539  defaultSs = defaultCacheIt.value();
1540  }
1541  styleSelector.styleSheets += defaultSs;
1542 
1543  if (!qApp->styleSheet().isEmpty()) {
1544  StyleSheet appSs;
1546  if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1547  QString ss = qApp->styleSheet();
1548  if (ss.startsWith(QLatin1String("file:///")))
1549  ss.remove(0, 8);
1550  parser.init(ss, qApp->styleSheet() != ss);
1551  if (!parser.parse(&appSs))
1552  qWarning("Could not parse application stylesheet");
1554  appSs.depth = 1;
1555  styleSheetCaches->styleSheetCache.insert(qApp, appSs);
1556  } else {
1557  appSs = appCacheIt.value();
1558  }
1559  styleSelector.styleSheets += appSs;
1560  }
1561 
1562  QVector<QCss::StyleSheet> widgetSs;
1563  for (const QWidget *wid = w; wid; wid = parentWidget(wid)) {
1564  if (wid->styleSheet().isEmpty())
1565  continue;
1566  StyleSheet ss;
1568  if (widCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1569  parser.init(wid->styleSheet());
1570  if (!parser.parse(&ss)) {
1571  parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}'));
1572  if (!parser.parse(&ss))
1573  qWarning("Could not parse stylesheet of widget %p", wid);
1574  }
1576  styleSheetCaches->styleSheetCache.insert(wid, ss);
1577  } else {
1578  ss = widCacheIt.value();
1579  }
1580  widgetSs.append(ss);
1581  }
1582 
1583  for (int i = 0; i < widgetSs.count(); i++)
1584  widgetSs[i].depth = widgetSs.count() - i + 2;
1585 
1586  styleSelector.styleSheets += widgetSs;
1587 
1589  n.ptr = (void *)w;
1590  QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
1592  return rules;
1593 }
QCss::StyleSheet getDefaultStyleSheet() const
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QStyle * baseStyle() const
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QHash< const void *, QCss::StyleSheet > styleSheetCache
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
StyleSheetOrigin origin
Definition: qcssparser_p.h:643
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QStyleSheetStyleCaches * styleSheetCaches
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
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 rece...
Definition: qobject.cpp:2580
#define qApp
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
static QWidget * parentWidget(const QWidget *w)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
bool initWidget(const QWidget *w) const
Make sure that the cache will be clean by connecting destroyed if needed.
bool parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity=Qt::CaseSensitive)
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
QHash< const QWidget *, QVector< QCss::StyleRule > > styleRulesCache
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void init(const QString &css, bool file=false)

◆ styleSheetPalette()

bool QStyleSheetStyle::styleSheetPalette ( const QWidget w,
const QStyleOption opt,
QPalette pal 
)

Definition at line 5855 of file qstylesheetstyle.cpp.

5856 {
5857  if (!w || !opt || !pal)
5858  return false;
5859 
5860  RECURSION_GUARD(return false)
5861 
5862  w = containerWidget(w);
5863 
5865  if (!rule.hasPalette())
5866  return false;
5867 
5869  return true;
5870 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool)
#define RECURSION_GUARD(RETURN)
static quint64 pseudoClass(QStyle::State state)
bool hasPalette() const
QRenderRule renderRule(const QWidget *, int, quint64=0) const
static quint64 extendedPseudoClass(const QWidget *w)
static QWidget * containerWidget(const QWidget *w)

◆ subControlRect()

QRect QStyleSheetStyle::subControlRect ( ComplexControl  cc,
const QStyleOptionComplex opt,
SubControl  sc,
const QWidget w = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5227 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), and drawControl().

5229 {
5230  RECURSION_GUARD(return baseStyle()->subControlRect(cc, opt, sc, w))
5231 
5232  QRenderRule rule = renderRule(w, opt);
5233  switch (cc) {
5234  case CC_ComboBox:
5235  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
5236  if (rule.hasBox() || !rule.hasNativeBorder()) {
5237  switch (sc) {
5238  case SC_ComboBoxFrame: return rule.borderRect(opt->rect);
5239  case SC_ComboBoxEditField:
5240  {
5242  QRect r = rule.contentsRect(opt->rect);
5243  QRect r2 = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown,
5244  opt->rect, opt->direction);
5245  if (subRule.hasPosition() && subRule.position()->position & Qt::AlignLeft) {
5246  return visualRect(opt->direction, r, r.adjusted(r2.width(),0,0,0));
5247  } else {
5248  return visualRect(opt->direction, r, r.adjusted(0,0,-r2.width(),0));
5249  }
5250  }
5251  case SC_ComboBoxArrow: {
5253  return positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
5254  }
5256  default:
5257  return baseStyle()->subControlRect(cc, opt, sc, w);
5258  }
5259  }
5260 
5261  QStyleOptionComboBox comboBox(*cb);
5262  comboBox.rect = rule.borderRect(opt->rect);
5263  return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w)
5264  : QWindowsStyle::subControlRect(cc, &comboBox, sc, w);
5265  }
5266  break;
5267 
5268 #ifndef QT_NO_SPINBOX
5269  case CC_SpinBox:
5270  if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
5273  bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
5274  bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
5275  bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition();
5276  if (ruleMatch || upRuleMatch || downRuleMatch) {
5277  switch (sc) {
5278  case SC_SpinBoxFrame:
5279  return rule.borderRect(opt->rect);
5280  case SC_SpinBoxEditField:
5281  {
5282  QRect r = rule.contentsRect(opt->rect);
5283  // Use the widest button on each side to determine edit field size.
5284  Qt::Alignment upAlign, downAlign;
5285 
5286  upAlign = upRule.hasPosition() ? upRule.position()->position
5287  : Qt::Alignment(Qt::AlignRight);
5288  upAlign = resolveAlignment(opt->direction, upAlign);
5289 
5290  downAlign = downRule.hasPosition() ? downRule.position()->position
5291  : Qt::Alignment(Qt::AlignRight);
5292  downAlign = resolveAlignment(opt->direction, downAlign);
5293 
5294  int upSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w).width();
5295  int downSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w).width();
5296  int widestL = qMax((upAlign & Qt::AlignLeft) ? upSize : 0,
5297  (downAlign & Qt::AlignLeft) ? downSize : 0);
5298  int widestR = qMax((upAlign & Qt::AlignRight) ? upSize : 0,
5299  (downAlign & Qt::AlignRight) ? downSize : 0);
5300  r.setRight(r.right() - widestR);
5301  r.setLeft(r.left() + widestL);
5302  return r;
5303  }
5304  case SC_SpinBoxDown:
5305  if (downRuleMatch)
5306  return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton,
5307  opt->rect, opt->direction);
5308  break;
5309  case SC_SpinBoxUp:
5310  if (upRuleMatch)
5311  return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton,
5312  opt->rect, opt->direction);
5313  break;
5314  default:
5315  break;
5316  }
5317 
5318  return baseStyle()->subControlRect(cc, opt, sc, w);
5319  }
5320 
5321  QStyleOptionSpinBox spinBox(*spin);
5322  spinBox.rect = rule.borderRect(opt->rect);
5323  return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w)
5324  : QWindowsStyle::subControlRect(cc, &spinBox, sc, w);
5325  }
5326  break;
5327 #endif // QT_NO_SPINBOX
5328 
5329  case CC_GroupBox:
5330  if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
5331  switch (sc) {
5332  case SC_GroupBoxFrame:
5333  case SC_GroupBoxContents: {
5334  if (rule.hasBox() || !rule.hasNativeBorder()) {
5335  return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect)
5336  : rule.contentsRect(opt->rect);
5337  }
5338  QStyleOptionGroupBox groupBox(*gb);
5339  groupBox.rect = rule.borderRect(opt->rect);
5340  return baseStyle()->subControlRect(cc, &groupBox, sc, w);
5341  }
5342  default:
5343  case SC_GroupBoxLabel:
5344  case SC_GroupBoxCheckBox: {
5346  QRenderRule labelRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
5347  if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
5348  && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
5349  QStyleOptionGroupBox groupBox(*gb);
5350  groupBox.rect = rule.borderRect(opt->rect);
5351  return baseStyle()->subControlRect(cc, &groupBox, sc, w);
5352  }
5353  int tw = opt->fontMetrics.width(gb->text);
5354  int th = opt->fontMetrics.height();
5355  int spacing = pixelMetric(QStyle::PM_CheckBoxLabelSpacing, opt, w);
5356  int iw = pixelMetric(QStyle::PM_IndicatorWidth, opt, w);
5357  int ih = pixelMetric(QStyle::PM_IndicatorHeight, opt, w);
5358 
5359  if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
5360  tw = tw + iw + spacing;
5361  th = qMax(th, ih);
5362  }
5363  if (!labelRule.hasGeometry()) {
5364  labelRule.geo = new QStyleSheetGeometryData(tw, th, tw, th, -1, -1);
5365  } else {
5366  labelRule.geo->width = tw;
5367  labelRule.geo->height = th;
5368  }
5369  if (!labelRule.hasPosition()) {
5371  gb->textAlignment, PositionMode_Static);
5372  }
5373  QRect r = positionRect(w, rule, labelRule, PseudoElement_GroupBoxTitle,
5374  opt->rect, opt->direction);
5375  if (gb->subControls & SC_GroupBoxCheckBox) {
5376  r = labelRule.contentsRect(r);
5377  if (sc == SC_GroupBoxLabel) {
5378  r.setLeft(r.left() + iw + spacing);
5379  r.setTop(r.center().y() - th/2);
5380  } else {
5381  r = QRect(r.left(), r.center().y() - ih/2, iw, ih);
5382  }
5383  return r;
5384  } else {
5385  return labelRule.contentsRect(r);
5386  }
5387  }
5388  } // switch
5389  }
5390  break;
5391 
5392  case CC_ToolButton:
5393  if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
5394  if (rule.hasBox() || !rule.hasNativeBorder()) {
5395  switch (sc) {
5396  case SC_ToolButton: return rule.borderRect(opt->rect);
5397  case SC_ToolButtonMenu: {
5399  return positionRect(w, rule, subRule, PseudoElement_ToolButtonMenu, opt->rect, opt->direction);
5400  }
5401  default:
5402  break;
5403  }
5404  }
5405 
5406  QStyleOptionToolButton tool(*tb);
5407  tool.rect = rule.borderRect(opt->rect);
5408  return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w)
5409  : QWindowsStyle::subControlRect(cc, &tool, sc, w);
5410  }
5411  break;
5412 
5413 #ifndef QT_NO_SCROLLBAR
5414  case CC_ScrollBar:
5415  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5416  QStyleOptionSlider styleOptionSlider(*sb);
5417  styleOptionSlider.rect = rule.borderRect(opt->rect);
5418  if (rule.hasDrawable() || rule.hasBox()) {
5419  QRect grooveRect;
5420  if (!rule.hasBox()) {
5421  grooveRect = rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, sb, SC_ScrollBarGroove, w)
5423  } else {
5424  grooveRect = rule.contentsRect(opt->rect);
5425  }
5426 
5428 
5429  switch (sc) {
5430  case SC_ScrollBarGroove:
5431  return grooveRect;
5432  case SC_ScrollBarAddPage:
5433  case SC_ScrollBarSubPage:
5434  case SC_ScrollBarSlider: {
5435  QRect contentRect = grooveRect;
5438  Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
5439  contentRect = rule.originRect(opt->rect, origin);
5440  }
5441  int maxlen = (styleOptionSlider.orientation == Qt::Horizontal) ? contentRect.width() : contentRect.height();
5442  int sliderlen;
5443  if (sb->maximum != sb->minimum) {
5444  uint range = sb->maximum - sb->minimum;
5445  sliderlen = (qint64(sb->pageStep) * maxlen) / (range + sb->pageStep);
5446 
5447  int slidermin = pixelMetric(PM_ScrollBarSliderMin, sb, w);
5448  if (sliderlen < slidermin || range > INT_MAX / 2)
5449  sliderlen = slidermin;
5450  if (sliderlen > maxlen)
5451  sliderlen = maxlen;
5452  } else {
5453  sliderlen = maxlen;
5454  }
5455 
5456  int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top())
5457  + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition,
5458  maxlen - sliderlen, sb->upsideDown);
5459 
5460  QRect sr = (sb->orientation == Qt::Horizontal)
5461  ? QRect(sliderstart, contentRect.top(), sliderlen, contentRect.height())
5462  : QRect(contentRect.left(), sliderstart, contentRect.width(), sliderlen);
5463  if (sc == SC_ScrollBarSlider) {
5464  return sr;
5465  } else if (sc == SC_ScrollBarSubPage) {
5466  return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight());
5467  } else { // SC_ScrollBarAddPage
5468  return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight());
5469  }
5470  break;
5471  }
5476  default: break;
5477  }
5478  if (hasStyleRule(w,pe)) {
5479  QRenderRule subRule = renderRule(w, opt, pe);
5480  if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
5481  const QStyleSheetPositionData *pos = subRule.position();
5482  QRect originRect = grooveRect;
5483  if (rule.hasBox()) {
5484  Origin origin = (pos && pos->origin != Origin_Unknown) ? pos->origin : defaultOrigin(pe);
5485  originRect = rule.originRect(opt->rect, origin);
5486  }
5487  return positionRect(w, subRule, pe, originRect, styleOptionSlider.direction);
5488  }
5489  }
5490  }
5491  return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w)
5492  : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w);
5493  }
5494  break;
5495 #endif // QT_NO_SCROLLBAR
5496 
5497 #ifndef QT_NO_SLIDER
5498  case CC_Slider:
5499  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5501  if (!subRule.hasDrawable())
5502  break;
5503  subRule.img = 0;
5504  QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction);
5505  switch (sc) {
5506  case SC_SliderGroove:
5507  return gr;
5508  case SC_SliderHandle: {
5509  bool horizontal = slider->orientation & Qt::Horizontal;
5510  QRect cr = subRule.contentsRect(gr);
5512  int len = horizontal ? subRule2.size().width() : subRule2.size().height();
5513  subRule2.img = 0;
5514  subRule2.geo = 0;
5515  cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction);
5516  int thickness = horizontal ? cr.height() : cr.width();
5517  int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
5518  (horizontal ? cr.width() : cr.height()) - len, slider->upsideDown);
5519  cr = horizontal ? QRect(cr.x() + sliderPos, cr.y(), len, thickness)
5520  : QRect(cr.x(), cr.y() + sliderPos, thickness, len);
5521  return subRule2.borderRect(cr);
5522  break; }
5523  case SC_SliderTickmarks:
5524  // TODO...
5525  default:
5526  break;
5527  }
5528  }
5529  break;
5530 #endif // QT_NO_SLIDER
5531 
5532  case CC_MdiControls:
5536  QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
5537  if (layout.isEmpty())
5538  layout = subControlLayout(QLatin1String("mNX"));
5539 
5540  int x = 0, width = 0;
5541  QRenderRule subRule;
5542  for (int i = 0; i < layout.count(); i++) {
5543  int layoutButton = layout[i].toInt();
5544  if (layoutButton < PseudoElement_MdiCloseButton
5545  || layoutButton > PseudoElement_MdiNormalButton)
5546  continue;
5547  QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
5548  if (!(opt->subControls & control))
5549  continue;
5550  subRule = renderRule(w, opt, layoutButton);
5551  width = subRule.size().width();
5552  if (sc == control)
5553  break;
5554  x += width;
5555  }
5556 
5557  return subRule.borderRect(QRect(x, opt->rect.top(), width, opt->rect.height()));
5558  }
5559  break;
5560 
5561  case CC_TitleBar:
5562  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
5563  QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
5564  if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
5565  break;
5566  QHash<QStyle::SubControl, QRect> layoutRects = titleBarLayout(w, tb);
5567  return layoutRects.value(sc);
5568  }
5569  break;
5570 
5571  default:
5572  break;
5573  }
5574 
5575  return baseStyle()->subControlRect(cc, opt, sc, w);
5576 }
QRect borderRect(const QRect &r) const
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
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
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QVariant styleHint(const QString &sh) const
static QList< QVariant > subControlLayout(const QString &layout)
bool hasGeometry() const
bool hasStyleRule(const QWidget *w, int part) const
QStyle * baseStyle() const
QSharedDataPointer< QStyleSheetGeometryData > geo
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...
static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment)
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
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
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
QSharedDataPointer< QStyleSheetPositionData > p
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool hasPosition() const
PseudoElement
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QStyle::SubControl subControl
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QRect contentsRect(const QRect &r) const
QRect originRect(const QRect &rect, Origin origin) const
int width() const
Returns the width.
Definition: qsize.h:126
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
const QStyleSheetPositionData * position() const
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
static Origin defaultOrigin(int pe)
const char * layout
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
QSharedDataPointer< QStyleSheetImageData > img
unsigned int uint
Definition: qglobal.h:996
__int64 qint64
Definition: qglobal.h:942
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
bool hasNativeBorder() const
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
bool hasContentsSize() const
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
QHash< QStyle::SubControl, QRect > titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
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
bool baseStyleCanDraw() const
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
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
bool hasBorder() const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
bool hasBox() const
bool hasDrawable() const
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
#define RECURSION_GUARD(RETURN)
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
int height() const
Returns the height of the font.
QSize size() const
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define INT_MAX
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ subElementRect()

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

Reimplemented Function

we need to access the widget here because the style option doesn't

Reimplemented from QCommonStyle.

Definition at line 5578 of file qstylesheetstyle.cpp.

5579 {
5580  RECURSION_GUARD(return baseStyle()->subElementRect(se, opt, w))
5581 
5582  QRenderRule rule = renderRule(w, opt);
5583 #ifndef QT_NO_TABBAR
5584  int pe = PseudoElement_None;
5585 #endif
5586 
5587  switch (se) {
5588  case SE_PushButtonContents:
5590  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
5591  QStyleOptionButton btnOpt(*btn);
5592  if (rule.hasBox() || !rule.hasNativeBorder())
5593  return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
5594  return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
5595  : QWindowsStyle::subElementRect(se, &btnOpt, w);
5596  }
5597  break;
5598 
5599  case SE_LineEditContents:
5600  case SE_FrameContents:
5602  if (rule.hasBox() || !rule.hasNativeBorder()) {
5603  return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
5604  }
5605  break;
5606 
5607  case SE_CheckBoxIndicator:
5609  if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
5611  QRenderRule subRule = renderRule(w, opt, pe);
5612  return positionRect(w, rule, subRule, pe, opt->rect, opt->direction);
5613  }
5614  break;
5615 
5616  case SE_CheckBoxContents:
5618  if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
5619  bool isRadio = se == SE_RadioButtonContents;
5621  opt, w);
5622  ir = visualRect(opt->direction, opt->rect, ir);
5623  int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w);
5624  QRect cr = rule.contentsRect(opt->rect);
5625  ir.setRect(ir.left() + ir.width() + spacing, cr.y(),
5626  cr.width() - ir.width() - spacing, cr.height());
5627  return visualRect(opt->direction, opt->rect, ir);
5628  }
5629  break;
5630 
5631  case SE_ToolBoxTabContents:
5632  if (w && hasStyleRule(w->parentWidget(), PseudoElement_ToolBoxTab)) {
5633  QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_ToolBoxTab);
5634  return visualRect(opt->direction, opt->rect, subRule.contentsRect(opt->rect));
5635  }
5636  break;
5637 
5639  case SE_RadioButtonClickRect: // focusrect | indicator
5640  if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
5641  return opt->rect;
5642  }
5643  break;
5644 
5645  case SE_CheckBoxFocusRect:
5646  case SE_CheckBoxClickRect: // relies on indicator and contents
5647  return ParentStyle::subElementRect(se, opt, w);
5648 
5649 #ifndef QT_NO_ITEMVIEWS
5651  if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
5652  return subElementRect(SE_CheckBoxIndicator, opt, w);
5653  }
5654  // intentionally falls through
5655  case SE_ItemViewItemText:
5658  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
5659  QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
5661  if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
5663  else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration)
5667  else
5668  break;
5669  if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) {
5670  QRenderRule subRule2 = renderRule(w, opt, pe);
5671  QStyleOptionViewItemV4 optCopy(*vopt);
5672  optCopy.rect = subRule.contentsRect(vopt->rect);
5673  QRect rect = ParentStyle::subElementRect(se, &optCopy, w);
5674  return positionRect(w, subRule2, pe, rect, opt->direction);
5675  }
5676  }
5677  break;
5678 #endif // QT_NO_ITEMVIEWS
5679 
5680  case SE_HeaderArrow: {
5682  if (subRule.hasPosition() || subRule.hasGeometry())
5683  return positionRect(w, rule, subRule, PseudoElement_HeaderViewUpArrow, opt->rect, opt->direction);
5684  }
5685  break;
5686 
5687  case SE_HeaderLabel: {
5689  if (subRule.hasBox() || !subRule.hasNativeBorder())
5690  return subRule.contentsRect(opt->rect);
5691  }
5692  break;
5693 
5694  case SE_ProgressBarGroove:
5696  case SE_ProgressBarLabel:
5697  if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
5698  if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasPosition() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
5699  if (se == SE_ProgressBarGroove)
5700  return rule.borderRect(pb->rect);
5701  else if (se == SE_ProgressBarContents)
5702  return rule.contentsRect(pb->rect);
5703 
5704  QSize sz = pb->fontMetrics.size(0, pb->text);
5705  return QStyle::alignedRect(Qt::LeftToRight, rule.hasPosition() ? rule.position()->textAlignment : pb->textAlignment,
5706  sz, pb->rect);
5707  }
5708  }
5709  break;
5710 
5711 #ifndef QT_NO_TABBAR
5714  // intentionally falls through
5716  if (pe == PseudoElement_None)
5718  // intentionally falls through
5719  case SE_TabWidgetTabBar:
5720  if (pe == PseudoElement_None)
5722  // intentionally falls through
5723  case SE_TabWidgetTabPane:
5725  if (pe == PseudoElement_None)
5727 
5728  if (hasStyleRule(w, pe)) {
5730  QRenderRule subRule = renderRule(w, opt, pe);
5731  r = positionRect(w, subRule, pe, r, opt->direction);
5732  if (pe == PseudoElement_TabWidgetTabBar) {
5733  Q_ASSERT(opt);
5734  r = opt->rect.intersected(r);
5735  }
5736  if (se == SE_TabWidgetTabContents)
5737  r = subRule.contentsRect(r);
5738  return r;
5739  }
5740  break;
5741 
5742  case SE_TabBarTearIndicator: {
5743  QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTear);
5744  if (subRule.hasContentsSize()) {
5745  QRect r;
5746  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
5747  switch (tab->shape) {
5748  case QTabBar::RoundedNorth:
5750  case QTabBar::RoundedSouth:
5752  r.setRect(tab->rect.left(), tab->rect.top(), subRule.size().width(), opt->rect.height());
5753  break;
5754  case QTabBar::RoundedWest:
5756  case QTabBar::RoundedEast:
5758  r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), subRule.size().height());
5759  break;
5760  default:
5761  break;
5762  }
5763  r = visualRect(opt->direction, opt->rect, r);
5764  }
5765  return r;
5766  }
5767  break;
5768  }
5769  case SE_TabBarTabText:
5771  case SE_TabBarTabRightButton: {
5772  QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
5773  if (subRule.hasBox() || !subRule.hasNativeBorder()) {
5774  return ParentStyle::subElementRect(se, opt, w);
5775  }
5776  break;
5777  }
5778 #endif // QT_NO_TABBAR
5779 
5781  case SE_DockWidgetFloatButton: {
5783  QRenderRule subRule2 = renderRule(w, opt, pe);
5784  if (!subRule2.hasPosition())
5785  break;
5787  return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
5788  }
5789 
5790 #ifndef QT_NO_TOOLBAR
5791  case SE_ToolBarHandle:
5793  return ParentStyle::subElementRect(se, opt, w);
5794  break;
5795 #endif //QT_NO_TOOLBAR
5796 
5797  default:
5798  break;
5799  }
5800 
5801  return baseStyle()->subElementRect(se, opt, w);
5802 }
QRect borderRect(const QRect &r) const
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
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...
Definition: qstyle.cpp:2120
bool hasGeometry() const
bool hasStyleRule(const QWidget *w, int part) const
QStyle * baseStyle() const
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
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
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
bool hasPosition() const
PseudoElement
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QRect contentsRect(const QRect &r) const
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
const QStyleSheetPositionData * position() const
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
bool hasNativeBorder() const
bool hasContentsSize() const
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
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=0) const =0
Returns the sub-area for the given element as described in the provided style option.
bool baseStyleCanDraw() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
bool hasBorder() const
bool hasBox() const
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
#define RECURSION_GUARD(RETURN)
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
QRenderRule renderRule(const QWidget *, int, quint64=0) const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QSize size() const
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ titleBarLayout()

QHash< QStyle::SubControl, QRect > QStyleSheetStyle::titleBarLayout ( const QWidget w,
const QStyleOptionTitleBar tb 
) const
private

Definition at line 741 of file qstylesheetstyle.cpp.

Referenced by drawComplexControl(), hitTestComplexControl(), and subControlRect().

742 {
744  const bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
745  const bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
746  QRenderRule subRule = renderRule(w, tb);
747  QRect cr = subRule.contentsRect(tb->rect);
748  QList<QVariant> layout = subRule.styleHint(QLatin1String("button-layout")).toList();
749  if (layout.isEmpty())
750  layout = subControlLayout(QLatin1String("I(T)HSmMX"));
751 
752  int offsets[3] = { 0, 0, 0 };
753  enum Where { Left, Right, Center, NoWhere } where = Left;
754  QList<ButtonInfo> infos;
755  for (int i = 0; i < layout.count(); i++) {
756  ButtonInfo info;
757  info.element = layout[i].toInt();
758  if (info.element == '(') {
759  where = Center;
760  } else if (info.element == ')') {
761  where = Right;
762  } else {
763  switch (info.element) {
766  continue;
767  break;
770  continue;
771  break;
774  continue;
775  if (isMinimized)
776  info.element = PseudoElement_TitleBarNormalButton;
777  break;
780  continue;
781  if (isMaximized)
782  info.element = PseudoElement_TitleBarNormalButton;
783  break;
786  continue;
787  if (isMinimized)
789  break;
793  continue;
794  break;
795  default:
796  continue;
797  }
798  if (info.element == PseudoElement_TitleBar) {
799  info.width = tb->fontMetrics.width(tb->text) + 6;
800  subRule.geo = new QStyleSheetGeometryData(info.width, tb->fontMetrics.height(), -1, -1, -1, -1);
801  } else {
802  subRule = renderRule(w, tb, info.element);
803  info.width = subRule.size().width();
804  }
805  info.rule = subRule;
806  info.offset = offsets[where];
807  info.where = where;
808  infos.append(info);
809 
810  offsets[where] += info.width;
811  }
812  }
813 
814  for (int i = 0; i < infos.count(); i++) {
815  ButtonInfo info = infos[i];
816  QRect lr = cr;
817  switch (info.where) {
818  case Center: {
819  lr.setLeft(cr.left() + offsets[Left]);
820  lr.setRight(cr.right() - offsets[Right]);
821  QRect r(0, 0, offsets[Center], lr.height());
822  r.moveCenter(lr.center());
823  r.setLeft(r.left()+info.offset);
824  r.setWidth(info.width);
825  lr = r;
826  break; }
827  case Left:
828  lr.translate(info.offset, 0);
829  lr.setWidth(info.width);
830  break;
831  case Right:
832  lr.moveLeft(cr.right() + 1 - offsets[Right] + info.offset);
833  lr.setWidth(info.width);
834  break;
835  default:
836  break;
837  }
838  QStyle::SubControl control = knownPseudoElements[info.element].subControl;
839  layoutRects[control] = positionRect(w, info.rule, info.element, lr, tb->direction);
840  }
841 
842  return layoutRects;
843 }
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QVariant styleHint(const QString &sh) const
static mach_timebase_info_data_t info
static QList< QVariant > subControlLayout(const QString &layout)
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
QSharedDataPointer< QStyleSheetGeometryData > geo
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
Definition: qvariant.cpp:2751
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString text
the text of the title bar
Definition: qstyleoption.h:822
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QStyle::SubControl subControl
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QRect contentsRect(const QRect &r) const
int width() const
Returns the width.
Definition: qsize.h:126
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const char * layout
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
QRect positionRect(const QWidget *, const QRenderRule &, const QRenderRule &, int, const QRect &, Qt::LayoutDirection) const
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
static const PseudoElementInfo knownPseudoElements[NumPseudoElements]
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
QRenderRule renderRule(const QWidget *, int, quint64=0) const
Qt::WindowFlags titleBarFlags
the widget flags for the title bar
Definition: qstyleoption.h:825
int height() const
Returns the height of the font.
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
int titleBarState
the state of the title bar
Definition: qstyleoption.h:824
QSize size() const
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ unpolish() [1/2]

void QStyleSheetStyle::unpolish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2792 of file qstylesheetstyle.cpp.

2793 {
2794  if (!w || !w->testAttribute(Qt::WA_StyleSheet)) {
2795  baseStyle()->unpolish(w);
2796  return;
2797  }
2798 
2802  styleSheetCaches->styleSheetCache.remove(w);
2803  unsetPalette(w);
2804  w->setProperty("_q_stylesheet_minw", QVariant());
2805  w->setProperty("_q_stylesheet_minh", QVariant());
2806  w->setProperty("_q_stylesheet_maxw", QVariant());
2807  w->setProperty("_q_stylesheet_maxh", QVariant());
2808  w->setAttribute(Qt::WA_StyleSheet, false);
2809  QObject::disconnect(w, 0, this, 0);
2810 #ifndef QT_NO_SCROLLAREA
2811  if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
2812  QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
2813  sa, SLOT(update()));
2814  QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
2815  sa, SLOT(update()));
2816  }
2817 #endif
2818 #ifndef QT_NO_PROGRESSBAR
2819  if (QProgressBar *pb = qobject_cast<QProgressBar *>(w))
2821 #endif
2822  baseStyle()->unpolish(w);
2823 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
void unpolish(QApplication *)
Reimplemented Function
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
QStyle * baseStyle() const
#define SLOT(a)
Definition: qobjectdefs.h:226
QHash< const QWidget *, QHash< int, bool > > hasStyleRuleCache
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
QHash< const void *, QCss::StyleSheet > styleSheetCache
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
QHash< const QWidget *, QRenderRules > renderRulesCache
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QStyleSheetStyleCaches * styleSheetCaches
void unsetPalette(QWidget *)
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.
Definition: qobject.cpp:2895
QHash< const QWidget *, QVector< QCss::StyleRule > > styleRulesCache

◆ unpolish() [2/2]

void QStyleSheetStyle::unpolish ( QApplication application)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2825 of file qstylesheetstyle.cpp.

2826 {
2827  baseStyle()->unpolish(app);
2828  RECURSION_GUARD(return)
2833 }
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
void clear()
Removes all items from the hash.
Definition: qhash.h:574
QStyle * baseStyle() const
QHash< const QWidget *, QHash< int, bool > > hasStyleRuleCache
QHash< const void *, QCss::StyleSheet > styleSheetCache
QHash< const QWidget *, QRenderRules > renderRulesCache
static QStyleSheetStyleCaches * styleSheetCaches
#define qApp
#define RECURSION_GUARD(RETURN)
QHash< const QWidget *, QVector< QCss::StyleRule > > styleRulesCache

◆ unsetPalette()

void QStyleSheetStyle::unsetPalette ( QWidget w)
private

Definition at line 2567 of file qstylesheetstyle.cpp.

Referenced by polish(), and unpolish().

2568 {
2571  w->setPalette(p);
2572  QWidget *ew = embeddedWidget(w);
2573  if (ew != w)
2574  ew->setPalette(p);
2576  }
2577  QVariant oldFont = w->property("_q_styleSheetWidgetFont");
2578  if (oldFont.isValid()) {
2579  w->setFont(qvariant_cast<QFont>(oldFont));
2580  }
2584  }
2585 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
QHash< const QWidget *, QPalette > customPaletteWidgets
bool remove(const T &value)
Definition: qset.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static QStyleSheetStyleCaches * styleSheetCaches
static QWidget * embeddedWidget(QWidget *w)
bool contains(const T &value) const
Definition: qset.h:91
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:631
QSet< const QWidget * > autoFillDisabledWidgets
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
void setPalette(const QPalette &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4858
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ updateStyleSheetFont()

void QStyleSheetStyle::updateStyleSheetFont ( QWidget w) const

Definition at line 5809 of file qstylesheetstyle.cpp.

Referenced by QWidgetPrivate::updateFont().

5810 {
5811  QWidget *container = containerWidget(w);
5812  QRenderRule rule = renderRule(container, PseudoElement_None,
5814  QFont font = rule.font.resolve(w->font());
5815 
5817  && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
5818 
5819  font = font.resolve(static_cast<QWidget *>(w->parent())->font());
5820  }
5821 
5822  if (w->data->fnt == font)
5823  return;
5824 
5825 #ifdef QT3_SUPPORT
5826  QFont old = w->data->fnt;
5827 #endif
5828  w->data->fnt = font;
5829 #if defined(Q_WS_X11)
5830  // make sure the font set on this widget is associated with the correct screen
5831  //w->data->fnt.x11SetScreen(w->d_func()->xinfo.screen());
5832 #endif
5833 
5835  QApplication::sendEvent(w, &e);
5836 #ifdef QT3_SUPPORT
5837  w->fontChange(old);
5838 #endif
5839 }
const quint64 PseudoClass_Enabled
Definition: qcssparser_p.h:462
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
QFont fnt
Definition: qwidget.h:133
const quint64 PseudoClass_Active
Definition: qcssparser_p.h:493
QFont font
the font currently set for the widget
Definition: qwidget.h:181
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidgetData * data
Definition: qwidget.h:815
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool isNaturalChild(const QWidget *w)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QRenderRule renderRule(const QWidget *, int, quint64=0) const
static quint64 extendedPseudoClass(const QWidget *w)
static QWidget * containerWidget(const QWidget *w)
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual void fontChange(const QFont &)
Definition: qwidget.cpp:12003

Friends and Related Functions

◆ QRenderRule

friend class QRenderRule
friend

Definition at line 151 of file qstylesheetstyle_p.h.

Properties

◆ base

QStyle* QStyleSheetStyle::base

◆ numinstances

int QStyleSheetStyle::numinstances = 0
static

Definition at line 178 of file qstylesheetstyle_p.h.

Referenced by QStyleSheetStyle(), updateWidgets(), and ~QStyleSheetStyle().

◆ parser

QCss::Parser QStyleSheetStyle::parser
mutableprivate

Definition at line 161 of file qstylesheetstyle_p.h.

◆ refcount

int QStyleSheetStyle::refcount
private

Definition at line 149 of file qstylesheetstyle_p.h.


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