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

The QCommonStyle class encapsulates the common Look and Feel of a GUI. More...

#include <qcommonstyle.h>

Inheritance diagram for QCommonStyle:
QStyle QObject QMotifStyle QProxyStyle QWindowsStyle QCDEStyle QCleanlooksStyle QMacStyle QPlastiqueStyle QStyleSheetStyle QWindowsCEStyle QWindowsMobileStyle QWindowsXPStyle

Public Functions

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

Protected Slots

QIcon standardIconImplementation (StandardPixmap standardIcon, const QStyleOption *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

 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
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Additional Inherited Members

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

Detailed Description

The QCommonStyle class encapsulates the common Look and Feel of a GUI.

This abstract class implements some of the widget's look and feel that is common to all GUI styles provided and shipped as part of Qt.

Since QCommonStyle inherits QStyle, all of its functions are fully documented in the QStyle documentation.

Warning
This function is not part of the public interface. , although the extra functions that QCommonStyle provides, e.g. drawComplexControl(), drawControl(), drawPrimitive(), hitTestComplexControl(), subControlRect(), sizeFromContents(), and subElementRect() are documented here.
See also
QStyle, QMotifStyle, QWindowsStyle

Definition at line 54 of file qcommonstyle.h.

Constructors and Destructors

◆ QCommonStyle() [1/2]

QCommonStyle::QCommonStyle ( )

Constructs a QCommonStyle.

Definition at line 123 of file qcommonstyle.cpp.

125 { }
QStyle()
Constructs a style object.
Definition: qstyle.cpp:337

◆ ~QCommonStyle()

QCommonStyle::~QCommonStyle ( )

Destroys the style.

Definition at line 136 of file qcommonstyle.cpp.

137 { }

◆ QCommonStyle() [2/2]

QCommonStyle::QCommonStyle ( QCommonStylePrivate dd)
protected
Warning
This function is not part of the public interface.

Definition at line 129 of file qcommonstyle.cpp.

130  : QStyle(dd)
131 { }
QStyle()
Constructs a style object.
Definition: qstyle.cpp:337

Functions

◆ drawComplexControl()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QMacStyle, QStyleSheetStyle, QMotifStyle, QGtkStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QWindowsMobileStyle, QPlastiqueStyle, QWindowsCEStyle, and QWindowsVistaStyle.

Definition at line 3107 of file qcommonstyle.cpp.

Referenced by QWindowsCEStyle::drawComplexControl(), QWindowsMobileStyle::drawComplexControl(), QWindowsStyle::drawComplexControl(), and QMotifStyle::drawComplexControl().

3109 {
3110  switch (cc) {
3111 #ifndef QT_NO_SLIDER
3112  case CC_Slider:
3113  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3114  if (slider->subControls == SC_SliderTickmarks) {
3115  int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
3116  int ticks = slider->tickPosition;
3117  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
3118  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3119  int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
3120  int interval = slider->tickInterval;
3121  if (interval <= 0) {
3122  interval = slider->singleStep;
3123  if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
3124  available)
3125  - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3126  0, available) < 3)
3127  interval = slider->pageStep;
3128  }
3129  if (!interval)
3130  interval = 1;
3131  int fudge = len / 2;
3132  int pos;
3133  // Since there is no subrect for tickmarks do a translation here.
3134  p->save();
3135  p->translate(slider->rect.x(), slider->rect.y());
3136  p->setPen(slider->palette.foreground().color());
3137  int v = slider->minimum;
3138  while (v <= slider->maximum + 1) {
3139  if (v == slider->maximum + 1 && interval == 1)
3140  break;
3141  const int v_ = qMin(v, slider->maximum);
3142  pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3143  v_, available) + fudge;
3144  if (slider->orientation == Qt::Horizontal) {
3145  if (ticks & QSlider::TicksAbove)
3146  p->drawLine(pos, 0, pos, tickOffset - 2);
3147  if (ticks & QSlider::TicksBelow)
3148  p->drawLine(pos, tickOffset + thickness + 1, pos,
3149  slider->rect.height()-1);
3150  } else {
3151  if (ticks & QSlider::TicksAbove)
3152  p->drawLine(0, pos, tickOffset - 2, pos);
3153  if (ticks & QSlider::TicksBelow)
3154  p->drawLine(tickOffset + thickness + 1, pos,
3155  slider->rect.width()-1, pos);
3156  }
3157  // in the case where maximum is max int
3158  int nextInterval = v + interval;
3159  if (nextInterval < v)
3160  break;
3161  v = nextInterval;
3162  }
3163  p->restore();
3164  }
3165  }
3166  break;
3167 #endif // QT_NO_SLIDER
3168 #ifndef QT_NO_SCROLLBAR
3169  case CC_ScrollBar:
3170  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3171  // Make a copy here and reset it for each primitive.
3172  QStyleOptionSlider newScrollbar = *scrollbar;
3173  State saveFlags = scrollbar->state;
3174 
3175  if (scrollbar->subControls & SC_ScrollBarSubLine) {
3176  newScrollbar.state = saveFlags;
3177  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget);
3178  if (newScrollbar.rect.isValid()) {
3179  if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
3180  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3181  proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget);
3182  }
3183  }
3184  if (scrollbar->subControls & SC_ScrollBarAddLine) {
3185  newScrollbar.rect = scrollbar->rect;
3186  newScrollbar.state = saveFlags;
3187  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget);
3188  if (newScrollbar.rect.isValid()) {
3189  if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
3190  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3191  proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget);
3192  }
3193  }
3194  if (scrollbar->subControls & SC_ScrollBarSubPage) {
3195  newScrollbar.rect = scrollbar->rect;
3196  newScrollbar.state = saveFlags;
3197  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget);
3198  if (newScrollbar.rect.isValid()) {
3199  if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage))
3200  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3201  proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget);
3202  }
3203  }
3204  if (scrollbar->subControls & SC_ScrollBarAddPage) {
3205  newScrollbar.rect = scrollbar->rect;
3206  newScrollbar.state = saveFlags;
3207  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget);
3208  if (newScrollbar.rect.isValid()) {
3209  if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage))
3210  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3211  proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget);
3212  }
3213  }
3214  if (scrollbar->subControls & SC_ScrollBarFirst) {
3215  newScrollbar.rect = scrollbar->rect;
3216  newScrollbar.state = saveFlags;
3217  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget);
3218  if (newScrollbar.rect.isValid()) {
3219  if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
3220  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3221  proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget);
3222  }
3223  }
3224  if (scrollbar->subControls & SC_ScrollBarLast) {
3225  newScrollbar.rect = scrollbar->rect;
3226  newScrollbar.state = saveFlags;
3227  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget);
3228  if (newScrollbar.rect.isValid()) {
3229  if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
3230  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3231  proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget);
3232  }
3233  }
3234  if (scrollbar->subControls & SC_ScrollBarSlider) {
3235  newScrollbar.rect = scrollbar->rect;
3236  newScrollbar.state = saveFlags;
3237  newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget);
3238  if (newScrollbar.rect.isValid()) {
3239  if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
3240  newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3241  proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget);
3242 
3243  if (scrollbar->state & State_HasFocus) {
3244  QStyleOptionFocusRect fropt;
3245  fropt.QStyleOption::operator=(newScrollbar);
3246  fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2,
3247  newScrollbar.rect.width() - 5,
3248  newScrollbar.rect.height() - 5);
3249  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
3250  }
3251  }
3252  }
3253  }
3254  break;
3255 #endif // QT_NO_SCROLLBAR
3256 #ifdef QT3_SUPPORT
3257  case CC_Q3ListView:
3258  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
3259  if (lv->subControls & SC_Q3ListView)
3260  p->fillRect(lv->rect, lv->viewportPalette.brush(lv->viewportBGRole));
3261  }
3262  break;
3263 #endif // QT3_SUPPORT
3264 #ifndef QT_NO_SPINBOX
3265  case CC_SpinBox:
3266  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3267  QStyleOptionSpinBox copy = *sb;
3268  PrimitiveElement pe;
3269 
3270  if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3272  qDrawWinPanel(p, r, sb->palette, true);
3273  }
3274 
3275  if (sb->subControls & SC_SpinBoxUp) {
3276  copy.subControls = SC_SpinBoxUp;
3277  QPalette pal2 = sb->palette;
3278  if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
3280  copy.state &= ~State_Enabled;
3281  }
3282 
3283  copy.palette = pal2;
3284 
3285  if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3286  copy.state |= State_On;
3287  copy.state |= State_Sunken;
3288  } else {
3289  copy.state |= State_Raised;
3290  copy.state &= ~State_Sunken;
3291  }
3292  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3293  : PE_IndicatorSpinUp);
3294 
3297  copy.rect.adjust(3, 0, -4, 0);
3298  proxy()->drawPrimitive(pe, &copy, p, widget);
3299  }
3300 
3301  if (sb->subControls & SC_SpinBoxDown) {
3302  copy.subControls = SC_SpinBoxDown;
3303  copy.state = sb->state;
3304  QPalette pal2 = sb->palette;
3305  if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
3307  copy.state &= ~State_Enabled;
3308  }
3309  copy.palette = pal2;
3310 
3311  if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3312  copy.state |= State_On;
3313  copy.state |= State_Sunken;
3314  } else {
3315  copy.state |= State_Raised;
3316  copy.state &= ~State_Sunken;
3317  }
3318  pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3320 
3323  copy.rect.adjust(3, 0, -4, 0);
3324  proxy()->drawPrimitive(pe, &copy, p, widget);
3325  }
3326  }
3327  break;
3328 #endif // QT_NO_SPINBOX
3329 #ifndef QT_NO_TOOLBUTTON
3330  case CC_ToolButton:
3331  if (const QStyleOptionToolButton *toolbutton
3332  = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3333  QRect button, menuarea;
3334  button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
3335  menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
3336 
3337  State bflags = toolbutton->state & ~State_Sunken;
3338 
3339  if (bflags & State_AutoRaise) {
3340  if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
3341  bflags &= ~State_Raised;
3342  }
3343  }
3344  State mflags = bflags;
3345  if (toolbutton->state & State_Sunken) {
3346  if (toolbutton->activeSubControls & SC_ToolButton)
3347  bflags |= State_Sunken;
3348  mflags |= State_Sunken;
3349  }
3350 
3351  QStyleOption tool(0);
3352  tool.palette = toolbutton->palette;
3353  if (toolbutton->subControls & SC_ToolButton) {
3354  if (bflags & (State_Sunken | State_On | State_Raised)) {
3355  tool.rect = button;
3356  tool.state = bflags;
3358  }
3359  }
3360 
3361  if (toolbutton->state & State_HasFocus) {
3363  fr.QStyleOption::operator=(*toolbutton);
3364  fr.rect.adjust(3, 3, -3, -3);
3365  if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
3367  toolbutton, widget), 0);
3369  }
3370  QStyleOptionToolButton label = *toolbutton;
3371  label.state = bflags;
3372  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
3373  label.rect = button.adjusted(fw, fw, -fw, -fw);
3374  proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
3375 
3376  if (toolbutton->subControls & SC_ToolButtonMenu) {
3377  tool.rect = menuarea;
3378  tool.state = mflags;
3379  if (mflags & (State_Sunken | State_On | State_Raised))
3382  } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
3383  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
3384  QRect ir = toolbutton->rect;
3385  QStyleOptionToolButton newBtn = *toolbutton;
3386  newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6);
3388  }
3389  }
3390  break;
3391 #endif // QT_NO_TOOLBUTTON
3392  case CC_TitleBar:
3393  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
3394  QRect ir;
3395  if (opt->subControls & SC_TitleBarLabel) {
3396  QColor left = tb->palette.highlight().color();
3397  QColor right = tb->palette.base().color();
3398 
3399  QBrush fillBrush(left);
3400  if (left != right) {
3401  QPoint p1(tb->rect.x(), tb->rect.top() + tb->rect.height()/2);
3402  QPoint p2(tb->rect.right(), tb->rect.top() + tb->rect.height()/2);
3403  QLinearGradient lg(p1, p2);
3404  lg.setColorAt(0, left);
3405  lg.setColorAt(1, right);
3406  fillBrush = lg;
3407  }
3408 
3409  p->fillRect(opt->rect, fillBrush);
3410 
3412 
3413  p->setPen(tb->palette.highlightedText().color());
3414  p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(),
3416  }
3417 
3418  bool down = false;
3419  QPixmap pm;
3420 
3421  QStyleOption tool(0);
3422  tool.palette = tb->palette;
3423  if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3425  down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken);
3426  if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool
3427 #ifndef QT_NO_DOCKWIDGET
3428  || qobject_cast<const QDockWidget *>(widget)
3429 #endif
3430  )
3431  pm = standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(10, 10);
3432  else
3433  pm = standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10);
3434  tool.rect = ir;
3435  tool.state = down ? State_Sunken : State_Raised;
3437 
3438  p->save();
3439  if (down)
3442  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3443  p->restore();
3444  }
3445 
3446  if (tb->subControls & SC_TitleBarMaxButton
3447  && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
3448  && !(tb->titleBarState & Qt::WindowMaximized)) {
3450 
3451  down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
3452  pm = standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10);
3453  tool.rect = ir;
3454  tool.state = down ? State_Sunken : State_Raised;
3456 
3457  p->save();
3458  if (down)
3461  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3462  p->restore();
3463  }
3464 
3465  if (tb->subControls & SC_TitleBarMinButton
3466  && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
3467  && !(tb->titleBarState & Qt::WindowMinimized)) {
3469  down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
3470  pm = standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10);
3471  tool.rect = ir;
3472  tool.state = down ? State_Sunken : State_Raised;
3474 
3475  p->save();
3476  if (down)
3479  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3480  p->restore();
3481  }
3482 
3483  bool drawNormalButton = (tb->subControls & SC_TitleBarNormalButton)
3484  && (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3485  && (tb->titleBarState & Qt::WindowMinimized))
3486  || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3487  && (tb->titleBarState & Qt::WindowMaximized)));
3488 
3489  if (drawNormalButton) {
3491  down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
3492  pm = standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10);
3493  tool.rect = ir;
3494  tool.state = down ? State_Sunken : State_Raised;
3496 
3497  p->save();
3498  if (down)
3501  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3502  p->restore();
3503  }
3504 
3505  if (tb->subControls & SC_TitleBarShadeButton
3506  && tb->titleBarFlags & Qt::WindowShadeButtonHint
3507  && !(tb->titleBarState & Qt::WindowMinimized)) {
3509  down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
3510  pm = standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10);
3511  tool.rect = ir;
3512  tool.state = down ? State_Sunken : State_Raised;
3514  p->save();
3515  if (down)
3518  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3519  p->restore();
3520  }
3521 
3522  if (tb->subControls & SC_TitleBarUnshadeButton
3523  && tb->titleBarFlags & Qt::WindowShadeButtonHint
3524  && tb->titleBarState & Qt::WindowMinimized) {
3526 
3527  down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
3528  pm = standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10);
3529  tool.rect = ir;
3530  tool.state = down ? State_Sunken : State_Raised;
3532  p->save();
3533  if (down)
3536  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3537  p->restore();
3538  }
3539  if (tb->subControls & SC_TitleBarContextHelpButton
3540  && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) {
3542 
3543  down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken);
3545  tool.rect = ir;
3546  tool.state = down ? State_Sunken : State_Raised;
3548  p->save();
3549  if (down)
3552  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3553  p->restore();
3554  }
3555  if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3557  if (!tb->icon.isNull()) {
3558  tb->icon.paint(p, ir);
3559  } else {
3560  int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
3561  pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize);
3562  tool.rect = ir;
3563  p->save();
3564  proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3565  p->restore();
3566  }
3567  }
3568  }
3569  break;
3570 #ifndef QT_NO_DIAL
3571  case CC_Dial:
3572  if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3573  // OK, this is more a port of things over
3574  p->save();
3575 
3576  // avoid dithering
3579 
3580  int width = dial->rect.width();
3581  int height = dial->rect.height();
3582  qreal r = qMin(width, height) / 2;
3583  qreal d_ = r / 6;
3584  qreal dx = dial->rect.x() + d_ + (width - 2 * r) / 2 + 1;
3585  qreal dy = dial->rect.y() + d_ + (height - 2 * r) / 2 + 1;
3586  QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2), int(r * 2 - 2 * d_ - 2));
3587 
3588  QPalette pal = opt->palette;
3589  // draw notches
3590  if (dial->subControls & QStyle::SC_DialTickmarks) {
3591  p->setPen(pal.foreground().color());
3593  }
3594 
3595  if (dial->state & State_Enabled) {
3597  dial, widget))));
3598  p->setPen(Qt::NoPen);
3599  p->drawEllipse(br);
3600  p->setBrush(Qt::NoBrush);
3601  }
3602  p->setPen(QPen(pal.dark().color()));
3603  p->drawArc(br, 60 * 16, 180 * 16);
3604  p->setPen(QPen(pal.light().color()));
3605  p->drawArc(br, 240 * 16, 180 * 16);
3606 
3607  qreal a;
3608  QPolygonF arrow(calcArrow(dial, a));
3609 
3610  p->setPen(Qt::NoPen);
3611  p->setBrush(pal.button());
3612  p->drawPolygon(arrow);
3613 
3614  a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]);
3615  p->setBrush(Qt::NoBrush);
3616 
3617  if (a <= 0 || a > 200) {
3618  p->setPen(pal.light().color());
3619  p->drawLine(arrow[2], arrow[0]);
3620  p->drawLine(arrow[1], arrow[2]);
3621  p->setPen(pal.dark().color());
3622  p->drawLine(arrow[0], arrow[1]);
3623  } else if (a > 0 && a < 45) {
3624  p->setPen(pal.light().color());
3625  p->drawLine(arrow[2], arrow[0]);
3626  p->setPen(pal.dark().color());
3627  p->drawLine(arrow[1], arrow[2]);
3628  p->drawLine(arrow[0], arrow[1]);
3629  } else if (a >= 45 && a < 135) {
3630  p->setPen(pal.dark().color());
3631  p->drawLine(arrow[2], arrow[0]);
3632  p->drawLine(arrow[1], arrow[2]);
3633  p->setPen(pal.light().color());
3634  p->drawLine(arrow[0], arrow[1]);
3635  } else if (a >= 135 && a < 200) {
3636  p->setPen(pal.dark().color());
3637  p->drawLine(arrow[2], arrow[0]);
3638  p->setPen(pal.light().color());
3639  p->drawLine(arrow[0], arrow[1]);
3640  p->drawLine(arrow[1], arrow[2]);
3641  }
3642 
3643  // draw focus rect around the dial
3644  QStyleOptionFocusRect fropt;
3645  fropt.rect = dial->rect;
3646  fropt.state = dial->state;
3647  fropt.palette = dial->palette;
3648  if (fropt.state & QStyle::State_HasFocus) {
3649  br.adjust(0, 0, 2, 2);
3650  if (dial->subControls & SC_DialTickmarks) {
3651  int r = qMin(width, height) / 2;
3652  br.translate(-r / 6, - r / 6);
3653  br.setWidth(br.width() + r / 3);
3654  br.setHeight(br.height() + r / 3);
3655  }
3656  fropt.rect = br.adjusted(-2, -2, 2, 2);
3658  }
3659  p->restore();
3660  }
3661  break;
3662 #endif // QT_NO_DIAL
3663 #ifndef QT_NO_GROUPBOX
3664  case CC_GroupBox:
3665  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
3666  // Draw frame
3668  QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget);
3669  if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
3670  QStyleOptionFrameV2 frame;
3671  frame.QStyleOption::operator=(*groupBox);
3672  frame.features = groupBox->features;
3673  frame.lineWidth = groupBox->lineWidth;
3674  frame.midLineWidth = groupBox->midLineWidth;
3676  p->save();
3677  QRegion region(groupBox->rect);
3678  if (!groupBox->text.isEmpty()) {
3679  bool ltr = groupBox->direction == Qt::LeftToRight;
3680  QRect finalRect;
3681  if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
3682  finalRect = checkBoxRect.united(textRect);
3683  finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
3684  } else {
3685  finalRect = textRect;
3686  }
3687  region -= finalRect;
3688  }
3689  p->setClipRegion(region);
3690  proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p, widget);
3691  p->restore();
3692  }
3693 
3694  // Draw title
3695  if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
3696  QColor textColor = groupBox->textColor;
3697  if (textColor.isValid())
3698  p->setPen(textColor);
3699  int alignment = int(groupBox->textAlignment);
3701  alignment |= Qt::TextHideMnemonic;
3702 
3703  proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
3704  groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
3706 
3707  if (groupBox->state & State_HasFocus) {
3708  QStyleOptionFocusRect fropt;
3709  fropt.QStyleOption::operator=(*groupBox);
3710  fropt.rect = textRect;
3711  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
3712  }
3713  }
3714 
3715  // Draw checkbox
3716  if (groupBox->subControls & SC_GroupBoxCheckBox) {
3717  QStyleOptionButton box;
3718  box.QStyleOption::operator=(*groupBox);
3719  box.rect = checkBoxRect;
3721  }
3722  }
3723  break;
3724 #endif // QT_NO_GROUPBOX
3725 #ifndef QT_NO_WORKSPACE
3726  case CC_MdiControls:
3727  {
3728  QStyleOptionButton btnOpt;
3729  btnOpt.QStyleOption::operator=(*opt);
3730  btnOpt.state &= ~State_MouseOver;
3731  int bsx = 0;
3732  int bsy = 0;
3735  btnOpt.state |= State_Sunken;
3736  btnOpt.state &= ~State_Raised;
3739  } else {
3740  btnOpt.state |= State_Raised;
3741  btnOpt.state &= ~State_Sunken;
3742  bsx = 0;
3743  bsy = 0;
3744  }
3748  proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3749  }
3752  btnOpt.state |= State_Sunken;
3753  btnOpt.state &= ~State_Raised;
3756  } else {
3757  btnOpt.state |= State_Raised;
3758  btnOpt.state &= ~State_Sunken;
3759  bsx = 0;
3760  bsy = 0;
3761  }
3765  proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3766  }
3767  if (opt->subControls & QStyle::SC_MdiMinButton) {
3769  btnOpt.state |= State_Sunken;
3770  btnOpt.state &= ~State_Raised;
3773  } else {
3774  btnOpt.state |= State_Raised;
3775  btnOpt.state &= ~State_Sunken;
3776  bsx = 0;
3777  bsy = 0;
3778  }
3782  proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3783  }
3784  }
3785  break;
3786 #endif // QT_NO_WORKSPACE
3787 
3788  default:
3789  qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc);
3790  }
3791 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
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
double qreal
Definition: qglobal.h:1193
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
Definition: qpainter.cpp:4602
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
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...
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
QRect united(const QRect &other) const
Returns the bounding rectangle of this rectangle and the given rectangle.
Definition: qrect.h:491
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
long ASN1_INTEGER_get ASN1_INTEGER * a
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
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
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
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
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
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
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
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 drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
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
Q_CORE_EXPORT void qWarning(const char *,...)
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
The State element defines configurations of objects and properties.
FrameFeatures features
a bitwise OR of the features that describe this frame.
Definition: qstyleoption.h:143
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
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
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
qreal angle(const QPointF &p1, const QPointF &p2)
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPolygonF calcLines(const QStyleOptionSlider *dial)
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
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
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
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 QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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
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
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
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

◆ drawControl()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QMacStyle, QMotifStyle, QGtkStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QPlastiqueStyle, QWindowsMobileStyle, QWindowsCEStyle, and QWindowsVistaStyle.

Definition at line 1203 of file qcommonstyle.cpp.

Referenced by QWindowsCEStyle::drawControl(), QCDEStyle::drawControl(), QWindowsMobileStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), and QStyleSheetStyle::drawControl().

1205 {
1206  Q_D(const QCommonStyle);
1207  switch (element) {
1208 
1209  case CE_PushButton:
1210  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1212  QStyleOptionButton subopt = *btn;
1214  proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
1215  if (btn->state & State_HasFocus) {
1216  QStyleOptionFocusRect fropt;
1217  fropt.QStyleOption::operator=(*btn);
1219  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
1220  }
1221  }
1222  break;
1223  case CE_PushButtonBevel:
1224  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1225  QRect br = btn->rect;
1226  int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
1227  if (btn->features & QStyleOptionButton::DefaultButton)
1229  if (btn->features & QStyleOptionButton::AutoDefaultButton)
1230  br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
1232  || btn->state & (State_Sunken | State_On)
1233  || (btn->features & QStyleOptionButton::CommandLinkButton && btn->state & State_MouseOver)) {
1234  QStyleOptionButton tmpBtn = *btn;
1235  tmpBtn.rect = br;
1237  }
1238  if (btn->features & QStyleOptionButton::HasMenu) {
1239  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
1240  QRect ir = btn->rect;
1241  QStyleOptionButton newBtn = *btn;
1242  newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6);
1244  }
1245  }
1246  break;
1247  case CE_PushButtonLabel:
1248  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1249  QRect textRect = button->rect;
1251  if (!proxy()->styleHint(SH_UnderlineShortcut, button, widget))
1252  tf |= Qt::TextHideMnemonic;
1253 
1254  if (!button->icon.isNull()) {
1255  //Center both icon and text
1256  QRect iconRect;
1257  QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
1258  if (mode == QIcon::Normal && button->state & State_HasFocus)
1259  mode = QIcon::Active;
1260  QIcon::State state = QIcon::Off;
1261  if (button->state & State_On)
1262  state = QIcon::On;
1263 
1264  QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
1265  int labelWidth = pixmap.width();
1266  int labelHeight = pixmap.height();
1267  int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
1268  int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
1269  if (!button->text.isEmpty())
1270  labelWidth += (textWidth + iconSpacing);
1271 
1272  iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
1273  textRect.y() + (textRect.height() - labelHeight) / 2,
1274  pixmap.width(), pixmap.height());
1275 
1276  iconRect = visualRect(button->direction, textRect, iconRect);
1277 
1278  tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
1279 
1280  if (button->direction == Qt::RightToLeft)
1281  textRect.setRight(iconRect.left() - iconSpacing);
1282  else
1283  textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
1284 
1285  if (button->state & (State_On | State_Sunken))
1288  p->drawPixmap(iconRect, pixmap);
1289  } else {
1290  tf |= Qt::AlignHCenter;
1291  }
1292  if (button->state & (State_On | State_Sunken))
1295 
1296  if (button->features & QStyleOptionButton::HasMenu) {
1297  int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget);
1298  if (button->direction == Qt::LeftToRight)
1299  textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
1300  else
1301  textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
1302  }
1303  proxy()->drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled),
1304  button->text, QPalette::ButtonText);
1305  }
1306  break;
1307  case CE_RadioButton:
1308  case CE_CheckBox:
1309  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1310  bool isRadio = (element == CE_RadioButton);
1311  QStyleOptionButton subopt = *btn;
1312  subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
1313  : SE_CheckBoxIndicator, btn, widget);
1315  &subopt, p, widget);
1316  subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
1317  : SE_CheckBoxContents, btn, widget);
1318  proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
1319  if (btn->state & State_HasFocus) {
1320  QStyleOptionFocusRect fropt;
1321  fropt.QStyleOption::operator=(*btn);
1322  fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
1323  : SE_CheckBoxFocusRect, btn, widget);
1324  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
1325  }
1326  }
1327  break;
1328  case CE_RadioButtonLabel:
1329  case CE_CheckBoxLabel:
1330  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1331  uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter);
1332 
1333  if (!proxy()->styleHint(SH_UnderlineShortcut, btn, widget))
1334  alignment |= Qt::TextHideMnemonic;
1335  QPixmap pix;
1336  QRect textRect = btn->rect;
1337  if (!btn->icon.isNull()) {
1338  pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
1339  proxy()->drawItemPixmap(p, btn->rect, alignment, pix);
1340  if (btn->direction == Qt::RightToLeft)
1341  textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
1342  else
1343  textRect.setLeft(textRect.left() + btn->iconSize.width() + 4);
1344  }
1345  if (!btn->text.isEmpty()){
1346  proxy()->drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,
1347  btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
1348  }
1349  }
1350  break;
1351 #ifndef QT_NO_MENU
1352  case CE_MenuScroller: {
1353  p->fillRect(opt->rect, opt->palette.background());
1354  QStyleOption arrowOpt = *opt;
1355  arrowOpt.state |= State_Enabled;
1357  &arrowOpt, p, widget);
1358  break; }
1359  case CE_MenuTearoff:
1360  if (opt->state & State_Selected)
1361  p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight));
1362  else
1363  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1364  p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1365  p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1,
1366  opt->rect.x() + opt->rect.width() - 4,
1367  opt->rect.y() + opt->rect.height() / 2 - 1);
1368  p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1369  p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2,
1370  opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
1371  break;
1372 #endif // QT_NO_MENU
1373 #ifndef QT_NO_MENUBAR
1374  case CE_MenuBarItem:
1375  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1378  if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
1379  alignment |= Qt::TextHideMnemonic;
1380  QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1381  if (!pix.isNull())
1382  proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
1383  else
1384  proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
1385  mbi->text, QPalette::ButtonText);
1386  }
1387  break;
1388  case CE_MenuBarEmptyArea:
1390  p->eraseRect(opt->rect);
1391  break;
1392 #endif // QT_NO_MENUBAR
1393 #ifndef QT_NO_PROGRESSBAR
1394  case CE_ProgressBar:
1395  if (const QStyleOptionProgressBar *pb
1396  = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1397  QStyleOptionProgressBarV2 subopt = *pb;
1399  proxy()->drawControl(CE_ProgressBarGroove, &subopt, p, widget);
1402  if (pb->textVisible) {
1404  proxy()->drawControl(CE_ProgressBarLabel, &subopt, p, widget);
1405  }
1406  }
1407  break;
1408  case CE_ProgressBarGroove:
1409  if (opt->rect.isValid())
1410  qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
1411  &opt->palette.brush(QPalette::Window));
1412  break;
1413  case CE_ProgressBarLabel:
1414  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1415  bool vertical = false;
1416  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1417  vertical = (pb2->orientation == Qt::Vertical);
1418  }
1419  if (!vertical) {
1421  if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
1422  && ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) {
1423  textRole = QPalette::HighlightedText;
1424  //Draw text shadow, This will increase readability when the background of same color
1425  QRect shadowRect(pb->rect);
1426  shadowRect.translate(1,1);
1427  QColor shadowColor = (pb->palette.color(textRole).value() <= 128)
1428  ? QColor(255,255,255,160) : QColor(0,0,0,160);
1429  QPalette shadowPalette = pb->palette;
1430  shadowPalette.setColor(textRole, shadowColor);
1431  proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette,
1432  pb->state & State_Enabled, pb->text, textRole);
1433  }
1434  proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette,
1435  pb->state & State_Enabled, pb->text, textRole);
1436  }
1437  }
1438  break;
1440  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1441 
1442  QRect rect = pb->rect;
1443  bool vertical = false;
1444  bool inverted = false;
1445  qint64 minimum = qint64(pb->minimum);
1446  qint64 maximum = qint64(pb->maximum);
1447  qint64 progress = qint64(pb->progress);
1448 
1449  // Get extra style options if version 2
1451  if (pb2) {
1452  vertical = (pb2->orientation == Qt::Vertical);
1453  inverted = pb2->invertedAppearance;
1454  }
1455  QMatrix m;
1456 
1457  if (vertical) {
1458  rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
1459  m.rotate(90);
1460  m.translate(0, -(rect.height() + rect.y()*2));
1461  }
1462 
1463  QPalette pal2 = pb->palette;
1464  // Correct the highlight color if it is the same as the background
1465  if (pal2.highlight() == pal2.background())
1466  pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1468  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1469  if (inverted)
1470  reverse = !reverse;
1471  int w = rect.width();
1472  if (pb->minimum == 0 && pb->maximum == 0) {
1473  // draw busy indicator
1474  int x = (progress - minimum) % (w * 2);
1475  if (x > w)
1476  x = 2 * w - x;
1477  x = reverse ? rect.right() - x : x + rect.x();
1478  p->setPen(QPen(pal2.highlight().color(), 4));
1479  p->drawLine(x, rect.y(), x, rect.height());
1480  } else {
1481  const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
1482  if (!unit_width)
1483  return;
1484 
1485  int u;
1486  if (unit_width > 1)
1487  u = ((rect.width() + unit_width) / unit_width);
1488  else
1489  u = w / unit_width;
1490  qint64 p_v = progress - minimum;
1491  qint64 t_s = (maximum - minimum) ? (maximum - minimum) : qint64(1);
1492 
1493  if (u > 0 && p_v >= INT_MAX / u && t_s >= u) {
1494  // scale down to something usable.
1495  p_v /= u;
1496  t_s /= u;
1497  }
1498 
1499  // nu < tnu, if last chunk is only a partial chunk
1500  int tnu, nu;
1501  tnu = nu = p_v * u / t_s;
1502 
1503  if (nu * unit_width > w)
1504  --nu;
1505 
1506  // Draw nu units out of a possible u of unit_width
1507  // width, each a rectangle bordered by background
1508  // color, all in a sunken panel with a percentage text
1509  // display at the end.
1510  int x = 0;
1511  int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0)
1512  : rect.x();
1513 
1514  QStyleOptionProgressBarV2 pbBits = *pb;
1515  pbBits.rect = rect;
1516  pbBits.palette = pal2;
1517  int myY = pbBits.rect.y();
1518  int myHeight = pbBits.rect.height();
1519  pbBits.state = State_None;
1520  for (int i = 0; i < nu; ++i) {
1521  pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1522  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1524  x += reverse ? -unit_width : unit_width;
1525  }
1526 
1527  // Draw the last partial chunk to fill up the
1528  // progress bar entirely
1529  if (nu < tnu) {
1530  int pixels_left = w - (nu * unit_width);
1531  int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x;
1532  pbBits.rect.setRect(offset, myY, pixels_left, myHeight);
1533  pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1535  }
1536  }
1537  }
1538  break;
1539 #endif // QT_NO_PROGRESSBAR
1540  case CE_HeaderLabel:
1541  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
1542  QRect rect = header->rect;
1543  if (!header->icon.isNull()) {
1544  QPixmap pixmap
1545  = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1546  int pixw = pixmap.width();
1547 
1548  QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect);
1549  QRect inter = aligned.intersected(rect);
1550  p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
1551 
1552  if (header->direction == Qt::LeftToRight)
1553  rect.setLeft(rect.left() + pixw + 2);
1554  else
1555  rect.setRight(rect.right() - pixw - 2);
1556  }
1557  if (header->state & QStyle::State_On) {
1558  QFont fnt = p->font();
1559  fnt.setBold(true);
1560  p->setFont(fnt);
1561  }
1562  proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
1563  (header->state & State_Enabled), header->text, QPalette::ButtonText);
1564  }
1565  break;
1566 #ifndef QT_NO_TOOLBUTTON
1567  case CE_ToolButtonLabel:
1568  if (const QStyleOptionToolButton *toolbutton
1569  = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1570  QRect rect = toolbutton->rect;
1571  int shiftX = 0;
1572  int shiftY = 0;
1573  if (toolbutton->state & (State_Sunken | State_On)) {
1574  shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget);
1575  shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget);
1576  }
1577  // Arrow type always overrules and is always shown
1578  bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow;
1579  if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty())
1580  || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) {
1581  int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
1582  if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget))
1583  alignment |= Qt::TextHideMnemonic;
1584  rect.translate(shiftX, shiftY);
1585  p->setFont(toolbutton->font);
1586  proxy()->drawItemText(p, rect, alignment, toolbutton->palette,
1587  opt->state & State_Enabled, toolbutton->text,
1589  } else {
1590  QPixmap pm;
1591  QSize pmSize = toolbutton->iconSize;
1592  if (!toolbutton->icon.isNull()) {
1593  QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off;
1594  QIcon::Mode mode;
1595  if (!(toolbutton->state & State_Enabled))
1596  mode = QIcon::Disabled;
1597  else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise))
1598  mode = QIcon::Active;
1599  else
1600  mode = QIcon::Normal;
1601  pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize),
1602  mode, state);
1603  pmSize = pm.size();
1604  }
1605 
1606  if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) {
1607  p->setFont(toolbutton->font);
1608  QRect pr = rect,
1609  tr = rect;
1610  int alignment = Qt::TextShowMnemonic;
1611  if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget))
1612  alignment |= Qt::TextHideMnemonic;
1613 
1614  if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
1615  pr.setHeight(pmSize.height() + 6);
1616  tr.adjust(0, pr.height() - 1, 0, -2);
1617  pr.translate(shiftX, shiftY);
1618  if (!hasArrow) {
1619  proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm);
1620  } else {
1621  drawArrow(this, toolbutton, pr, p, widget);
1622  }
1623  alignment |= Qt::AlignCenter;
1624  } else {
1625  pr.setWidth(pmSize.width() + 8);
1626  tr.adjust(pr.width(), 0, 0, 0);
1627  pr.translate(shiftX, shiftY);
1628  if (!hasArrow) {
1629  proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm);
1630  } else {
1631  drawArrow(this, toolbutton, pr, p, widget);
1632  }
1633  alignment |= Qt::AlignLeft | Qt::AlignVCenter;
1634  }
1635  tr.translate(shiftX, shiftY);
1636  proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette,
1637  toolbutton->state & State_Enabled, toolbutton->text,
1639  } else {
1640  rect.translate(shiftX, shiftY);
1641  if (hasArrow) {
1642  drawArrow(this, toolbutton, rect, p, widget);
1643  } else {
1644  proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm);
1645  }
1646  }
1647  }
1648  }
1649  break;
1650 #endif // QT_NO_TOOLBUTTON
1651 #ifndef QT_NO_TOOLBOX
1652  case CE_ToolBoxTab:
1653  if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1656  }
1657  break;
1658  case CE_ToolBoxTabShape:
1659  if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1660  int d = 20 + tb->rect.height() - 3;
1661  QPolygon a(7);
1662  if (tb->direction != Qt::RightToLeft) {
1663  a.setPoint(0, -1, tb->rect.height() + 1);
1664  a.setPoint(1, -1, 1);
1665  a.setPoint(2, tb->rect.width() - d, 1);
1666  a.setPoint(3, tb->rect.width() - 20, tb->rect.height() - 2);
1667  a.setPoint(4, tb->rect.width() - 1, tb->rect.height() - 2);
1668  a.setPoint(5, tb->rect.width() - 1, tb->rect.height() + 1);
1669  a.setPoint(6, -1, tb->rect.height() + 1);
1670  } else {
1671  a.setPoint(0, tb->rect.width(), tb->rect.height() + 1);
1672  a.setPoint(1, tb->rect.width(), 1);
1673  a.setPoint(2, d - 1, 1);
1674  a.setPoint(3, 20 - 1, tb->rect.height() - 2);
1675  a.setPoint(4, 0, tb->rect.height() - 2);
1676  a.setPoint(5, 0, tb->rect.height() + 1);
1677  a.setPoint(6, tb->rect.width(), tb->rect.height() + 1);
1678  }
1679 
1680  p->setPen(tb->palette.mid().color().darker(150));
1681  p->drawPolygon(a);
1682  p->setPen(tb->palette.light().color());
1683  if (tb->direction != Qt::RightToLeft) {
1684  p->drawLine(0, 2, tb->rect.width() - d, 2);
1685  p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1);
1686  p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1,
1687  tb->rect.width(), tb->rect.height() - 1);
1688  } else {
1689  p->drawLine(tb->rect.width() - 1, 2, d - 1, 2);
1690  p->drawLine(d, 2, 20, tb->rect.height() - 1);
1691  p->drawLine(19, tb->rect.height() - 1,
1692  -1, tb->rect.height() - 1);
1693  }
1694  p->setBrush(Qt::NoBrush);
1695  }
1696  break;
1697 #endif // QT_NO_TOOLBOX
1698 #ifndef QT_NO_TABBAR
1699  case CE_TabBarTab:
1700  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1703  }
1704  break;
1705  case CE_TabBarTabShape:
1706  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1707  p->save();
1708 
1709  QRect rect(tab->rect);
1710  bool selected = tab->state & State_Selected;
1711  bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1712  int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget);
1713 
1714  if (!selected) {
1715  switch (tab->shape) {
1717  rect.adjust(0, 0, 0, -tabOverlap);
1718  if(!selected)
1719  rect.adjust(1, 1, -1, 0);
1720  break;
1722  rect.adjust(0, tabOverlap, 0, 0);
1723  if(!selected)
1724  rect.adjust(1, 0, -1, -1);
1725  break;
1727  rect.adjust(tabOverlap, 0, 0, 0);
1728  if(!selected)
1729  rect.adjust(0, 1, -1, -1);
1730  break;
1732  rect.adjust(0, 0, -tabOverlap, 0);
1733  if(!selected)
1734  rect.adjust(1, 1, 0, -1);
1735  break;
1736  default:
1737  break;
1738  }
1739  }
1740 
1741  p->setPen(QPen(tab->palette.foreground(), 0));
1742  if (selected) {
1743  p->setBrush(tab->palette.base());
1744  } else {
1745  if (widget && widget->parentWidget())
1747  else
1748  p->setBrush(tab->palette.background());
1749  }
1750 
1751  int y;
1752  int x;
1753  QPolygon a(10);
1754  switch (tab->shape) {
1756  case QTabBar::TriangularSouth: {
1757  a.setPoint(0, 0, -1);
1758  a.setPoint(1, 0, 0);
1759  y = rect.height() - 2;
1760  x = y / 3;
1761  a.setPoint(2, x++, y - 1);
1762  ++x;
1763  a.setPoint(3, x++, y++);
1764  a.setPoint(4, x, y);
1765 
1766  int i;
1767  int right = rect.width() - 1;
1768  for (i = 0; i < 5; ++i)
1769  a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y());
1770  if (tab->shape == QTabBar::TriangularNorth)
1771  for (i = 0; i < 10; ++i)
1772  a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y());
1773 
1774  a.translate(rect.left(), rect.top());
1776  p->translate(0, 0.5);
1777 
1778  QPainterPath path;
1779  path.addPolygon(a);
1780  p->drawPath(path);
1781  break; }
1783  case QTabBar::TriangularWest: {
1784  a.setPoint(0, -1, 0);
1785  a.setPoint(1, 0, 0);
1786  x = rect.width() - 2;
1787  y = x / 3;
1788  a.setPoint(2, x - 1, y++);
1789  ++y;
1790  a.setPoint(3, x++, y++);
1791  a.setPoint(4, x, y);
1792  int i;
1793  int bottom = rect.height() - 1;
1794  for (i = 0; i < 5; ++i)
1795  a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y());
1796  if (tab->shape == QTabBar::TriangularWest)
1797  for (i = 0; i < 10; ++i)
1798  a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y());
1799  a.translate(rect.left(), rect.top());
1801  p->translate(0.5, 0);
1802  QPainterPath path;
1803  path.addPolygon(a);
1804  p->drawPath(path);
1805  break; }
1806  default:
1807  break;
1808  }
1809  p->restore();
1810  }
1811  break;
1812  case CE_ToolBoxTabLabel:
1813  if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1814  bool enabled = tb->state & State_Enabled;
1815  bool selected = tb->state & State_Selected;
1816  QPixmap pm = tb->icon.pixmap(proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget),
1817  enabled ? QIcon::Normal : QIcon::Disabled);
1818 
1820  QRect tr, ir;
1821  int ih = 0;
1822  if (pm.isNull()) {
1823  tr = cr;
1824  tr.adjust(4, 0, -8, 0);
1825  } else {
1826  int iw = pm.width() + 4;
1827  ih = pm.height();
1828  ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih);
1829  tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height());
1830  }
1831 
1833  QFont f(p->font());
1834  f.setBold(true);
1835  p->setFont(f);
1836  }
1837 
1838  QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width());
1839 
1840  if (ih)
1841  p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm);
1842 
1845  alignment |= Qt::TextHideMnemonic;
1846  proxy()->drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText);
1847 
1848  if (!txt.isEmpty() && opt->state & State_HasFocus) {
1850  opt.rect = tr;
1851  opt.palette = tb->palette;
1852  opt.state = QStyle::State_None;
1854  }
1855  }
1856  break;
1857  case CE_TabBarTabLabel:
1858  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1859  QStyleOptionTabV3 tabV2(*tab);
1860  QRect tr = tabV2.rect;
1861  bool verticalTabs = tabV2.shape == QTabBar::RoundedEast
1862  || tabV2.shape == QTabBar::RoundedWest
1863  || tabV2.shape == QTabBar::TriangularEast
1864  || tabV2.shape == QTabBar::TriangularWest;
1865 
1866  int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
1867  if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget))
1868  alignment |= Qt::TextHideMnemonic;
1869 
1870  if (verticalTabs) {
1871  p->save();
1872  int newX, newY, newRot;
1873  if (tabV2.shape == QTabBar::RoundedEast || tabV2.shape == QTabBar::TriangularEast) {
1874  newX = tr.width() + tr.x();
1875  newY = tr.y();
1876  newRot = 90;
1877  } else {
1878  newX = tr.x();
1879  newY = tr.y() + tr.height();
1880  newRot = -90;
1881  }
1882  QTransform m = QTransform::fromTranslate(newX, newY);
1883  m.rotate(newRot);
1884  p->setTransform(m, true);
1885  }
1886  QRect iconRect;
1887  d->tabLayout(&tabV2, widget, &tr, &iconRect);
1888  tr = proxy()->subElementRect(SE_TabBarTabText, opt, widget); //we compute tr twice because the style may override subElementRect
1889 
1890  if (!tabV2.icon.isNull()) {
1891  QPixmap tabIcon = tabV2.icon.pixmap(tabV2.iconSize,
1892  (tabV2.state & State_Enabled) ? QIcon::Normal
1893  : QIcon::Disabled,
1894  (tabV2.state & State_Selected) ? QIcon::On
1895  : QIcon::Off);
1896  p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
1897  }
1898 
1899  proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText);
1900  if (verticalTabs)
1901  p->restore();
1902 
1903  if (tabV2.state & State_HasFocus) {
1904  const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
1905 
1906  int x1, x2;
1907  x1 = tabV2.rect.left();
1908  x2 = tabV2.rect.right() - 1;
1909 
1910  QStyleOptionFocusRect fropt;
1911  fropt.QStyleOption::operator=(*tab);
1912  fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET,
1913  x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET);
1914  drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
1915  }
1916  }
1917  break;
1918 #endif // QT_NO_TABBAR
1919 #ifndef QT_NO_SIZEGRIP
1920  case CE_SizeGrip: {
1921  p->save();
1922  int x, y, w, h;
1923  opt->rect.getRect(&x, &y, &w, &h);
1924 
1925  int sw = qMin(h, w);
1926  if (h > w)
1927  p->translate(0, h - w);
1928  else
1929  p->translate(w - h, 0);
1930 
1931  int sx = x;
1932  int sy = y;
1933  int s = sw / 3;
1934 
1935  Qt::Corner corner;
1936  if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt))
1937  corner = sgOpt->corner;
1938  else if (opt->direction == Qt::RightToLeft)
1939  corner = Qt::BottomLeftCorner;
1940  else
1941  corner = Qt::BottomRightCorner;
1942 
1943  if (corner == Qt::BottomLeftCorner) {
1944  sx = x + sw;
1945  for (int i = 0; i < 4; ++i) {
1946  p->setPen(QPen(opt->palette.light().color(), 1));
1947  p->drawLine(x, sy - 1 , sx + 1, sw);
1948  p->setPen(QPen(opt->palette.dark().color(), 1));
1949  p->drawLine(x, sy, sx, sw);
1950  p->setPen(QPen(opt->palette.dark().color(), 1));
1951  p->drawLine(x, sy + 1, sx - 1, sw);
1952  sx -= s;
1953  sy += s;
1954  }
1955  } else if (corner == Qt::BottomRightCorner) {
1956  for (int i = 0; i < 4; ++i) {
1957  p->setPen(QPen(opt->palette.light().color(), 1));
1958  p->drawLine(sx - 1, sw, sw, sy - 1);
1959  p->setPen(QPen(opt->palette.dark().color(), 1));
1960  p->drawLine(sx, sw, sw, sy);
1961  p->setPen(QPen(opt->palette.dark().color(), 1));
1962  p->drawLine(sx + 1, sw, sw, sy + 1);
1963  sx += s;
1964  sy += s;
1965  }
1966  } else if (corner == Qt::TopRightCorner) {
1967  sy = y + sw;
1968  for (int i = 0; i < 4; ++i) {
1969  p->setPen(QPen(opt->palette.light().color(), 1));
1970  p->drawLine(sx - 1, y, sw, sy + 1);
1971  p->setPen(QPen(opt->palette.dark().color(), 1));
1972  p->drawLine(sx, y, sw, sy);
1973  p->setPen(QPen(opt->palette.dark().color(), 1));
1974  p->drawLine(sx + 1, y, sw, sy - 1);
1975  sx += s;
1976  sy -= s;
1977  }
1978  } else if (corner == Qt::TopLeftCorner) {
1979  for (int i = 0; i < 4; ++i) {
1980  p->setPen(QPen(opt->palette.light().color(), 1));
1981  p->drawLine(x, sy - 1, sx - 1, y);
1982  p->setPen(QPen(opt->palette.dark().color(), 1));
1983  p->drawLine(x, sy, sx, y);
1984  p->setPen(QPen(opt->palette.dark().color(), 1));
1985  p->drawLine(x, sy + 1, sx + 1, y);
1986  sx += s;
1987  sy += s;
1988  }
1989  }
1990  p->restore();
1991  break; }
1992 #endif // QT_NO_SIZEGRIP
1993 #ifndef QT_NO_RUBBERBAND
1994  case CE_RubberBand: {
1995  if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
1996  QPixmap tiledPixmap(16, 16);
1997  QPainter pixmapPainter(&tiledPixmap);
1998  pixmapPainter.setPen(Qt::NoPen);
1999  pixmapPainter.setBrush(Qt::Dense4Pattern);
2000  pixmapPainter.setBackground(QBrush(opt->palette.base()));
2001  pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
2002  pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
2003  pixmapPainter.end();
2004  // ### workaround for borked XRENDER
2005  tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
2006 
2007  p->save();
2008  QRect r = opt->rect;
2009  QStyleHintReturnMask mask;
2010  if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
2011  p->setClipRegion(mask.region);
2012  p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
2014  p->setBrush(Qt::NoBrush);
2015  p->drawRect(r.adjusted(0, 0, -1, -1));
2016  if (rbOpt->shape == QRubberBand::Rectangle)
2017  p->drawRect(r.adjusted(3, 3, -4, -4));
2018  p->restore();
2019  }
2020  break; }
2021 #endif // QT_NO_RUBBERBAND
2022 #ifndef QT_NO_DOCKWIDGET
2023  case CE_DockWidgetTitle:
2024  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2025  QRect r = dwOpt->rect.adjusted(0, 0, -1, -1);
2026  if (dwOpt->movable) {
2027  p->setPen(dwOpt->palette.color(QPalette::Dark));
2028  p->drawRect(r);
2029  }
2030 
2031  if (!dwOpt->title.isEmpty()) {
2032  const QStyleOptionDockWidgetV2 *v2
2034  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2035 
2036  if (verticalTitleBar) {
2037  QSize s = r.size();
2038  s.transpose();
2039  r.setSize(s);
2040 
2041  p->save();
2042  p->translate(r.left(), r.top() + r.width());
2043  p->rotate(-90);
2044  p->translate(-r.left(), -r.top());
2045  }
2046 
2047  const int indent = p->fontMetrics().descent();
2048  proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),
2050  dwOpt->state & State_Enabled, dwOpt->title,
2052 
2053  if (verticalTitleBar)
2054  p->restore();
2055  }
2056  }
2057  break;
2058 #endif // QT_NO_DOCKWIDGET
2059  case CE_Header:
2060  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2061  QRegion clipRegion = p->clipRegion();
2062  p->setClipRect(opt->rect);
2063  proxy()->drawControl(CE_HeaderSection, header, p, widget);
2064  QStyleOptionHeader subopt = *header;
2065  subopt.rect = subElementRect(SE_HeaderLabel, header, widget);
2066  if (subopt.rect.isValid())
2067  proxy()->drawControl(CE_HeaderLabel, &subopt, p, widget);
2068  if (header->sortIndicator != QStyleOptionHeader::None) {
2069  subopt.rect = subElementRect(SE_HeaderArrow, opt, widget);
2071  }
2072  p->setClipRegion(clipRegion);
2073  }
2074  break;
2075  case CE_FocusFrame:
2076  p->fillRect(opt->rect, opt->palette.foreground());
2077  break;
2078  case CE_HeaderSection:
2079  qDrawShadePanel(p, opt->rect, opt->palette,
2080  opt->state & State_Sunken, 1,
2081  &opt->palette.brush(QPalette::Button));
2082  break;
2083  case CE_HeaderEmptyArea:
2084  p->fillRect(opt->rect, opt->palette.background());
2085  break;
2086 #ifndef QT_NO_COMBOBOX
2087  case CE_ComboBoxLabel:
2088  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2090  p->save();
2091  p->setClipRect(editRect);
2092  if (!cb->currentIcon.isNull()) {
2093  QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
2094  : QIcon::Disabled;
2095  QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
2096  QRect iconRect(editRect);
2097  iconRect.setWidth(cb->iconSize.width() + 4);
2098  iconRect = alignedRect(cb->direction,
2100  iconRect.size(), editRect);
2101  if (cb->editable)
2102  p->fillRect(iconRect, opt->palette.brush(QPalette::Base));
2103  proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
2104 
2105  if (cb->direction == Qt::RightToLeft)
2106  editRect.translate(-4 - cb->iconSize.width(), 0);
2107  else
2108  editRect.translate(cb->iconSize.width() + 4, 0);
2109  }
2110  if (!cb->currentText.isEmpty() && !cb->editable) {
2111  proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0),
2113  cb->palette, cb->state & State_Enabled, cb->currentText);
2114  }
2115  p->restore();
2116  }
2117  break;
2118 #endif // QT_NO_COMBOBOX
2119 #ifndef QT_NO_TOOLBAR
2120  case CE_ToolBar:
2121  if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2122  // Compatibility with styles that use PE_PanelToolBar
2123  QStyleOptionFrame frame;
2124  frame.QStyleOption::operator=(*toolBar);
2125  frame.lineWidth = toolBar->lineWidth;
2126  frame.midLineWidth = toolBar->midLineWidth;
2128 
2129  if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
2130  break;
2131  qDrawShadePanel(p, toolBar->rect, toolBar->palette, false, toolBar->lineWidth,
2132  &toolBar->palette.brush(QPalette::Button));
2133  }
2134  break;
2135 #endif // QT_NO_TOOLBAR
2136  case CE_ColumnViewGrip: {
2137  // draw background gradients
2138  QLinearGradient g(0, 0, opt->rect.width(), 0);
2140  g.setColorAt(0.5, Qt::white);
2141  p->fillRect(QRect(0, 0, opt->rect.width(), opt->rect.height()), g);
2142 
2143  // draw the two lines
2144  QPen pen(p->pen());
2145  pen.setWidth(opt->rect.width()/20);
2146  pen.setColor(opt->palette.color(QPalette::Active, QPalette::Dark));
2147  p->setPen(pen);
2148 
2149  int line1starting = opt->rect.width()*8 / 20;
2150  int line2starting = opt->rect.width()*13 / 20;
2151  int top = opt->rect.height()*20/75;
2152  int bottom = opt->rect.height() - 1 - top;
2153  p->drawLine(line1starting, top, line1starting, bottom);
2154  p->drawLine(line2starting, top, line2starting, bottom);
2155  }
2156  break;
2157 
2158 #ifndef QT_NO_ITEMVIEWS
2159  case CE_ItemViewItem:
2160  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
2161  p->save();
2162  p->setClipRect(opt->rect);
2163 
2166  QRect textRect = subElementRect(SE_ItemViewItemText, vopt, widget);
2167 
2168  // draw the background
2170 
2171  // draw the check mark
2172  if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) {
2173  QStyleOptionViewItemV4 option(*vopt);
2174  option.rect = checkRect;
2175  option.state = option.state & ~QStyle::State_HasFocus;
2176 
2177  switch (vopt->checkState) {
2178  case Qt::Unchecked:
2179  option.state |= QStyle::State_Off;
2180  break;
2181  case Qt::PartiallyChecked:
2182  option.state |= QStyle::State_NoChange;
2183  break;
2184  case Qt::Checked:
2185  option.state |= QStyle::State_On;
2186  break;
2187  }
2189  }
2190 
2191  // draw the icon
2192  QIcon::Mode mode = QIcon::Normal;
2193  if (!(vopt->state & QStyle::State_Enabled))
2194  mode = QIcon::Disabled;
2195  else if (vopt->state & QStyle::State_Selected)
2196  mode = QIcon::Selected;
2197  QIcon::State state = vopt->state & QStyle::State_Open ? QIcon::On : QIcon::Off;
2198  vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state);
2199 
2200  // draw the text
2201  if (!vopt->text.isEmpty()) {
2202  QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
2204  if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
2205  cg = QPalette::Inactive;
2206 
2207  if (vopt->state & QStyle::State_Selected) {
2208  p->setPen(vopt->palette.color(cg, QPalette::HighlightedText));
2209  } else {
2210  p->setPen(vopt->palette.color(cg, QPalette::Text));
2211  }
2212  if (vopt->state & QStyle::State_Editing) {
2213  p->setPen(vopt->palette.color(cg, QPalette::Text));
2214  p->drawRect(textRect.adjusted(0, 0, -1, -1));
2215  }
2216 
2217  d->viewItemDrawText(p, vopt, textRect);
2218  }
2219 
2220  // draw the focus rect
2221  if (vopt->state & QStyle::State_HasFocus) {
2223  o.QStyleOption::operator=(*vopt);
2227  QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled)
2229  o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected)
2232  }
2233 
2234  p->restore();
2235  }
2236  break;
2237 
2238 #endif // QT_NO_ITEMVIEWS
2239 #ifndef QT_NO_FRAME
2240  case CE_ShapedFrame:
2241  if (const QStyleOptionFrameV3 *f = qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) {
2242  int frameShape = f->frameShape;
2243  int frameShadow = QFrame::Plain;
2244  if (f->state & QStyle::State_Sunken) {
2245  frameShadow = QFrame::Sunken;
2246  } else if (f->state & QStyle::State_Raised) {
2247  frameShadow = QFrame::Raised;
2248  }
2249 
2250  int lw = f->lineWidth;
2251  int mlw = f->midLineWidth;
2252  QPalette::ColorRole foregroundRole = QPalette::WindowText;
2253  if (widget)
2254  foregroundRole = widget->foregroundRole();
2255 
2256  switch (frameShape) {
2257  case QFrame::Box:
2258  if (frameShadow == QFrame::Plain) {
2259  qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2260  } else {
2261  qDrawShadeRect(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2262  }
2263  break;
2264  case QFrame::StyledPanel:
2265  //keep the compatibility with Qt 4.4 if there is a proxy style.
2266  //be sure to call drawPrimitive(QStyle::PE_Frame) on the proxy style
2267  if (widget) {
2269  } else {
2271  }
2272  break;
2273  case QFrame::Panel:
2274  if (frameShadow == QFrame::Plain) {
2275  qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2276  } else {
2277  qDrawShadePanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw);
2278  }
2279  break;
2280  case QFrame::WinPanel:
2281  if (frameShadow == QFrame::Plain) {
2282  qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2283  } else {
2284  qDrawWinPanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken);
2285  }
2286  break;
2287  case QFrame::HLine:
2288  case QFrame::VLine: {
2289  QPoint p1, p2;
2290  if (frameShape == QFrame::HLine) {
2291  p1 = QPoint(opt->rect.x(), opt->rect.height() / 2);
2292  p2 = QPoint(opt->rect.x() + opt->rect.width(), p1.y());
2293  } else {
2294  p1 = QPoint(opt->rect.x()+opt->rect.width() / 2, 0);
2295  p2 = QPoint(p1.x(), opt->rect.height());
2296  }
2297  if (frameShadow == QFrame::Plain) {
2298  QPen oldPen = p->pen();
2299  p->setPen(QPen(opt->palette.brush(foregroundRole), lw));
2300  p->drawLine(p1, p2);
2301  p->setPen(oldPen);
2302  } else {
2303  qDrawShadeLine(p, p1, p2, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2304  }
2305  break;
2306  }
2307  }
2308  }
2309  break;
2310 #endif
2311  default:
2312  break;
2313  }
2314 }
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
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
QPalette palette
the widget&#39;s palette
Definition: qwidget.h:180
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPointer< QWidget > widget
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
int descent() const
Returns the descent of the font.
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
static bool verticalTabs(QTabBar::Shape shape)
Qt::Orientation orientation
the progress bar&#39;s orientation (horizontal or vertical); the default orentation is Qt::Horizontal ...
Definition: qstyleoption.h:422
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
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
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
quint16 u
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
long ASN1_INTEGER_get ASN1_INTEGER * a
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QStyleOptionToolBox class is used to describe the parameters needed for drawing a tool box...
Definition: qstyleoption.h:633
#define Q_D(Class)
Definition: qglobal.h:2482
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QStyleOptionSizeGrip class is used to describe the parameter for drawing a size grip...
Definition: qstyleoption.h:853
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
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
QStyle * style() const
Definition: qwidget.cpp:2742
ColorGroup
Definition: qpalette.h:92
QColor backgroundColor
the background color on which the focus rectangle is being drawn
Definition: qstyleoption.h:109
virtual ~QStyle()
Destroys the style object.
Definition: qstyle.cpp:362
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
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
QRegion clipRegion() const
Returns the currently set clip region.
Definition: qpainter.cpp:2562
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QMatrix & rotate(qreal a)
Rotates the coordinate system the given degrees counterclockwise.
Definition: qmatrix.cpp:990
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
QPalette::ColorRole foregroundRole() const
Returns the foreground role.
Definition: qwidget.cpp:4728
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
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 adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
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...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
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
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
__int64 qint64
Definition: qglobal.h:942
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
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
Corner
Definition: qnamespace.h:1456
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition: qstyle.cpp:2149
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.
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
void eraseRect(const QRectF &)
Erases the area inside the given rectangle.
Definition: qpainter.cpp:7332
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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 QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93
bool invertedAppearance
whether the progress bar&#39;s appearance is inverted
Definition: qstyleoption.h:423
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
Definition: qmatrix.cpp:389
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton, const QRect &rect, QPainter *painter, const QWidget *widget=0)
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define INT_MAX
#define enabled
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition: qpen.cpp:667
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawPrimitive()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QMacStyle, QMotifStyle, QGtkStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QPlastiqueStyle, QWindowsMobileStyle, QWindowsVistaStyle, and QWindowsCEStyle.

Definition at line 143 of file qcommonstyle.cpp.

Referenced by drawControl(), QWindowsStyle::drawPrimitive(), QGtkStyle::drawPrimitive(), and QMotifStyle::drawPrimitive().

145 {
146  Q_D(const QCommonStyle);
147  switch (pe) {
148  case PE_FrameButtonBevel:
149  case PE_FrameButtonTool:
150  qDrawShadeRect(p, opt->rect, opt->palette,
151  opt->state & (State_Sunken | State_On), 1, 0);
152  break;
154  case PE_PanelButtonBevel:
155  case PE_PanelButtonTool:
157  qDrawShadePanel(p, opt->rect, opt->palette,
158  opt->state & (State_Sunken | State_On), 1,
160  break;
163  break;
165  if (opt->state & State_NoChange) {
166  p->setPen(opt->palette.foreground().color());
167  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
168  p->drawRect(opt->rect);
169  p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight());
170  } else {
171  qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
172  opt->palette, opt->state & (State_Sunken | State_On), 1,
174  }
175  break;
177  QRect ir = opt->rect;
178  p->setPen(opt->palette.dark().color());
179  p->drawArc(opt->rect, 0, 5760);
180  if (opt->state & (State_Sunken | State_On)) {
181  ir.adjust(2, 2, -2, -2);
182  p->setBrush(opt->palette.foreground());
183  p->drawEllipse(ir);
184  }
185  break; }
186  case PE_FrameFocusRect:
187  if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
188  QColor bg = fropt->backgroundColor;
189  QPen oldPen = p->pen();
190  if (bg.isValid()) {
191  int h, s, v;
192  bg.getHsv(&h, &s, &v);
193  if (v >= 128)
194  p->setPen(Qt::black);
195  else
196  p->setPen(Qt::white);
197  } else {
198  p->setPen(opt->palette.foreground().color());
199  }
200  QRect focusRect = opt->rect.adjusted(1, 1, -1, -1);
201  p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive
202  p->setPen(oldPen);
203  }
204  break;
206  const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width();
207  const int markH = markW;
208  int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1;
209  int posY = opt->rect.y() + (opt->rect.height() - markH)/2;
210 
212  a.reserve(markH);
213 
214  int i, xx, yy;
215  xx = posX;
216  yy = 3 + posY;
217  for (i = 0; i < markW/2; ++i) {
218  a << QLineF(xx, yy, xx, yy + 2);
219  ++xx;
220  ++yy;
221  }
222  yy -= 2;
223  for (; i < markH; ++i) {
224  a << QLineF(xx, yy, xx, yy + 2);
225  ++xx;
226  --yy;
227  }
228  if (!(opt->state & State_Enabled) && !(opt->state & State_On)) {
229  p->save();
230  p->translate(1, 1);
231  p->setPen(opt->palette.light().color());
232  p->drawLines(a);
233  p->restore();
234  }
235  p->setPen((opt->state & State_On) ? opt->palette.highlightedText().color() : opt->palette.text().color());
236  p->drawLines(a);
237  break; }
238  case PE_Frame:
239  case PE_FrameMenu:
240  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
241  if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) {
242  qDrawShadePanel(p, frame->rect, frame->palette, frame->state & State_Sunken,
243  frame->lineWidth);
244  } else {
245  qDrawPlainRect(p, frame->rect, frame->palette.foreground().color(), frame->lineWidth);
246  }
247  }
248  break;
249 #ifndef QT_NO_TOOLBAR
250  case PE_PanelMenuBar:
251  if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
252  break;
253  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)){
254  qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth,
255  &frame->palette.brush(QPalette::Button));
256 
257  }
258  else if (const QStyleOptionToolBar *frame = qstyleoption_cast<const QStyleOptionToolBar *>(opt)){
259  qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth,
260  &frame->palette.brush(QPalette::Button));
261  }
262 
263  break;
264  case PE_PanelMenu:
265  break;
266  case PE_PanelToolBar:
267  break;
268 #endif // QT_NO_TOOLBAR
269 #ifndef QT_NO_PROGRESSBAR
271  {
272  bool vertical = false;
273  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
274  vertical = (pb2->orientation == Qt::Vertical);
275  if (!vertical) {
276  p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
278  } else {
279  p->fillRect(opt->rect.x() + 2, opt->rect.y(), opt->rect.width() -6, opt->rect.height() - 2,
281  }
282  }
283  break;
284 #endif // QT_NO_PROGRESSBAR
285 #ifdef QT3_SUPPORT
287 #ifndef QT_NO_IMAGEFORMAT_XPM
289 #endif
290  break;
292  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
293  if (lv->items.isEmpty())
294  return;
295  int x = lv->rect.x(),
296  y = lv->rect.y();
297 #define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
298  static const int pts1[] = { // dark lines
299  1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
300  static const int pts2[] = { // black lines
301  2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
302  static const int pts3[] = { // background lines
303  2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
304  static const int pts4[] = { // white lines
305  2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
306  11,4, 10,3, 10,2 };
307  // static const int pts5[] = { // inner fill
308  // 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
309  //QPolygon a;
310 
311  if (lv->state & State_Enabled)
312  p->setPen(lv->palette.text().color());
313  else
314  p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text)));
315  QPolygon a(INTARRLEN(pts1), pts1);
316  a.translate(x, y);
317  //p->setPen(pal.dark());
318  p->drawPolyline(a);
319  a.setPoints(INTARRLEN(pts2), pts2);
320  a.translate(x, y);
321  p->drawPolyline(a);
322  a.setPoints(INTARRLEN(pts3), pts3);
323  a.translate(x, y);
324  // p->setPen(black);
325  p->drawPolyline(a);
326  a.setPoints(INTARRLEN(pts4), pts4);
327  a.translate(x, y);
328  // p->setPen(blue);
329  p->drawPolyline(a);
330  // a.setPoints(INTARRLEN(pts5), pts5);
331  // a.translate(x, y);
332  // QColor fillColor = isDown() ? g.background() : g.base();
333  // p->setPen(fillColor);
334  // p->setBrush(fillColor);
335  // p->drawPolygon(a);
336  if (opt->state & State_On) {
337  p->setPen(Qt::NoPen);
338  p->setBrush(opt->palette.text());
339  p->drawRect(x + 5, y + 4, 2, 4);
340  p->drawRect(x + 4, y + 5, 4, 2);
341  }
342 #undef INTARRLEN
343  }
344  break;
346  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
347  if(lv->items.isEmpty())
348  break;
349  QStyleOptionQ3ListViewItem item = lv->items.at(0);
350  int x = lv->rect.x(),
351  y = lv->rect.y(),
352  w = lv->rect.width(),
353  h = lv->rect.width(),
354  marg = lv->itemMargin;
355 
356  if (lv->state & State_Enabled)
357  p->setPen(QPen(lv->palette.text().color(), 2));
358  else
359  p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text), 2));
360  if (opt->state & State_Selected && !lv->rootIsDecorated
362  p->fillRect(0, 0, x + marg + w + 4, item.height,
363  lv->palette.brush(QPalette::Highlight));
364  if (item.state & State_Enabled)
365  p->setPen(QPen(lv->palette.highlightedText().color(), 2));
366  }
367 
368  if (lv->state & State_NoChange)
369  p->setBrush(lv->palette.brush(QPalette::Button));
370  p->drawRect(x + marg, y + 2, w - 4, h - 4);
372  ++x;
373  ++y;
374  if (lv->state & State_On || lv->state & State_NoChange) {
375  QLineF lines[7];
376  int i,
377  xx = x + 1 + marg,
378  yy = y + 5;
379  for (i = 0; i < 3; ++i) {
380  lines[i] = QLineF(xx, yy, xx, yy + 2);
381  ++xx;
382  ++yy;
383  }
384  yy -= 2;
385  for (i = 3; i < 7; ++i) {
386  lines[i] = QLineF(xx, yy, xx, yy + 2);
387  ++xx;
388  --yy;
389  }
390  p->drawLines(lines, 7);
391  }
392  }
393  break;
394 #endif // QT3_SUPPORT
395  case PE_IndicatorBranch: {
396  int mid_h = opt->rect.x() + opt->rect.width() / 2;
397  int mid_v = opt->rect.y() + opt->rect.height() / 2;
398  int bef_h = mid_h;
399  int bef_v = mid_v;
400  int aft_h = mid_h;
401  int aft_v = mid_v;
402 #ifndef QT_NO_IMAGEFORMAT_XPM
403  static const int decoration_size = 9;
405  static QPixmap closed(tree_branch_closed_xpm);
406  if (opt->state & State_Children) {
407  int delta = decoration_size / 2;
408  bef_h -= delta;
409  bef_v -= delta;
410  aft_h += delta;
411  aft_v += delta;
412  p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed);
413  }
414 #endif // QT_NO_IMAGEFORMAT_XPM
415  if (opt->state & State_Item) {
416  if (opt->direction == Qt::RightToLeft)
417  p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v);
418  else
419  p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v);
420  }
421  if (opt->state & State_Sibling)
422  p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom());
424  p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v);
425  break; }
426 #ifdef QT3_SUPPORT
427  case PE_Q3Separator:
428  qDrawShadeLine(p, opt->rect.left(), opt->rect.top(), opt->rect.right(), opt->rect.bottom(),
429  opt->palette, opt->state & State_Sunken, 1, 0);
430  break;
431 #endif // QT3_SUPPORT
433  qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0);
434  break;
436  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
437  QPen oldPen = p->pen();
438  if (header->sortIndicator & QStyleOptionHeader::SortUp) {
439  QPolygon pa(3);
440  p->setPen(QPen(opt->palette.light(), 0));
441  p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),
442  opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
443  p->setPen(QPen(opt->palette.dark(), 0));
444  pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
445  pa.setPoint(1, opt->rect.x(), opt->rect.y());
446  pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y());
447  p->drawPolyline(pa);
448  } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
449  QPolygon pa(3);
450  p->setPen(QPen(opt->palette.light(), 0));
451  pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height());
452  pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height());
453  pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
454  p->drawPolyline(pa);
455  p->setPen(QPen(opt->palette.dark(), 0));
456  p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),
457  opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
458  }
459  p->setPen(oldPen);
460  }
461  break;
462 #ifndef QT_NO_TABBAR
463  case PE_FrameTabBarBase:
464  if (const QStyleOptionTabBarBase *tbb
465  = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
466  p->save();
467  switch (tbb->shape) {
470  p->setPen(QPen(tbb->palette.light(), 0));
471  p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
472  break;
475  p->setPen(QPen(tbb->palette.light(), 0));
476  p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
477  break;
480  p->setPen(QPen(tbb->palette.shadow(), 0));
481  p->drawLine(tbb->rect.left(), tbb->rect.bottom(),
482  tbb->rect.right(), tbb->rect.bottom());
483  p->setPen(QPen(tbb->palette.dark(), 0));
484  p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1,
485  tbb->rect.right() - 1, tbb->rect.bottom() - 1);
486  break;
489  p->setPen(QPen(tbb->palette.dark(), 0));
490  p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
491  break;
492  }
493  p->restore();
494  }
495  break;
496  case PE_IndicatorTabClose: {
497  if (d->tabBarcloseButtonIcon.isNull()) {
498  d->tabBarcloseButtonIcon.addPixmap(QPixmap(
499  QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-16.png")),
501  d->tabBarcloseButtonIcon.addPixmap(QPixmap(
502  QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-down-16.png")),
504  d->tabBarcloseButtonIcon.addPixmap(QPixmap(
505  QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-hover-16.png")),
507  }
508 
510  QIcon::Mode mode = opt->state & State_Enabled ?
512  : QIcon::Disabled;
513  if (!(opt->state & State_Raised)
514  && !(opt->state & State_Sunken)
515  && !(opt->state & QStyle::State_Selected))
516  mode = QIcon::Disabled;
517 
519  QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(size, mode, state);
520  proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap);
521  break;
522  }
523 #endif // QT_NO_TABBAR
524  case PE_FrameTabWidget:
525  case PE_FrameWindow:
526  qDrawWinPanel(p, opt->rect, opt->palette, false, 0);
527  break;
528  case PE_FrameLineEdit:
529  proxy()->drawPrimitive(PE_Frame, opt, p, widget);
530  break;
531 #ifndef QT_NO_GROUPBOX
532  case PE_FrameGroupBox:
533  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
534  const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt);
535  if (frame2 && (frame2->features & QStyleOptionFrameV2::Flat)) {
536  QRect fr = frame->rect;
537  QPoint p1(fr.x(), fr.y() + 1);
538  QPoint p2(fr.x() + fr.width(), p1.y());
539  qDrawShadeLine(p, p1, p2, frame->palette, true,
540  frame->lineWidth, frame->midLineWidth);
541  } else {
542  qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(),
543  frame->rect.height(), frame->palette, true,
544  frame->lineWidth, frame->midLineWidth);
545  }
546  }
547  break;
548 #endif // QT_NO_GROUPBOX
549 #ifndef QT_NO_DOCKWIDGET
550  case PE_FrameDockWidget:
551  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
552  int lw = frame->lineWidth;
553  if (lw <= 0)
555 
556  qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
557  }
558  break;
559 #endif // QT_NO_DOCKWIDGET
560 #ifndef QT_NO_TOOLBAR
562  p->save();
563  p->translate(opt->rect.x(), opt->rect.y());
564  if (opt->state & State_Horizontal) {
565  int x = opt->rect.width() / 3;
566  if (opt->direction == Qt::RightToLeft)
567  x -= 2;
568  if (opt->rect.height() > 4) {
569  qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
570  opt->palette, false, 1, 0);
571  qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,
572  opt->palette, false, 1, 0);
573  }
574  } else {
575  if (opt->rect.width() > 4) {
576  int y = opt->rect.height() / 3;
577  qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
578  opt->palette, false, 1, 0);
579  qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,
580  opt->palette, false, 1, 0);
581  }
582  }
583  p->restore();
584  break;
587  break;
589  {
590  QPoint p1, p2;
591  if (opt->state & State_Horizontal) {
592  p1 = QPoint(opt->rect.width()/2, 0);
593  p2 = QPoint(p1.x(), opt->rect.height());
594  } else {
595  p1 = QPoint(0, opt->rect.height()/2);
596  p2 = QPoint(opt->rect.width(), p1.y());
597  }
598  qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
599  break;
600  }
601 #endif // QT_NO_TOOLBAR
602 #ifndef QT_NO_SPINBOX
604  case PE_IndicatorSpinMinus: {
605  QRect r = opt->rect;
606  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
607  QRect br = r.adjusted(fw, fw, -fw, -fw);
608 
609  int offset = (opt->state & State_Sunken) ? 1 : 0;
610  int step = (br.width() + 4) / 5;
611  p->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
612  br.width(), step,
613  opt->palette.buttonText());
614  if (pe == PE_IndicatorSpinPlus)
615  p->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset,
616  step, br.height(),
617  opt->palette.buttonText());
618 
619  break; }
620  case PE_IndicatorSpinUp:
621  case PE_IndicatorSpinDown: {
622  QRect r = opt->rect;
623  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
624  // QRect br = r.adjusted(fw, fw, -fw, -fw);
625  int x = r.x(), y = r.y(), w = r.width(), h = r.height();
626  int sw = w-4;
627  if (sw < 3)
628  break;
629  else if (!(sw & 1))
630  sw--;
631  sw -= (sw / 7) * 2; // Empty border
632  int sh = sw/2 + 2; // Must have empty row at foot of arrow
633 
634  int sx = x + w / 2 - sw / 2;
635  int sy = y + h / 2 - sh / 2;
636 
637  if (pe == PE_IndicatorSpinUp && fw)
638  --sy;
639 
640  QPolygon a;
641  if (pe == PE_IndicatorSpinDown)
642  a.setPoints(3, 0, 1, sw-1, 1, sh-2, sh-1);
643  else
644  a.setPoints(3, 0, sh-1, sw-1, sh-1, sh-2, 1);
645  int bsx = 0;
646  int bsy = 0;
647  if (opt->state & State_Sunken) {
650  }
651  p->save();
652  p->translate(sx + bsx, sy + bsy);
653  p->setPen(opt->palette.buttonText().color());
654  p->setBrush(opt->palette.buttonText());
655  p->drawPolygon(a);
656  p->restore();
657  break; }
658 #endif // QT_NO_SPINBOX
659  case PE_PanelTipLabel: {
660  QBrush oldBrush = p->brush();
661  QPen oldPen = p->pen();
662  p->setPen(QPen(opt->palette.toolTipText(), 0));
663  p->setBrush(opt->palette.toolTipBase());
664  p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
665  p->setPen(oldPen);
666  p->setBrush(oldBrush);
667  break;
668  }
669 #ifndef QT_NO_TABBAR
670  case PE_IndicatorTabTear:
671  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
672  bool rtl = tab->direction == Qt::RightToLeft;
673  QRect rect = tab->rect;
674  QPainterPath path;
675 
676  rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
677  rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
678 
679  path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
680  int count = 4;
681  for(int jags = 1; jags <= count; ++jags, rtl = !rtl)
682  path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
683 
684  p->setPen(QPen(tab->palette.light(), qreal(.8)));
685  p->setBrush(tab->palette.background());
687  p->drawPath(path);
688  }
689  break;
690 #endif // QT_NO_TABBAR
691 #ifndef QT_NO_LINEEDIT
692  case PE_PanelLineEdit:
693  if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
694  p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth),
695  panel->palette.brush(QPalette::Base));
696 
697  if (panel->lineWidth > 0)
699  }
700  break;
701 #endif // QT_NO_LINEEDIT
702 #ifndef QT_NO_COLUMNVIEW
704  if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
705  bool reverse = (viewOpt->direction == Qt::RightToLeft);
706  p->save();
707  QPainterPath path;
708  int x = viewOpt->rect.x() + 1;
709  int offset = (viewOpt->rect.height() / 3);
710  int height = (viewOpt->rect.height()) - offset * 2;
711  if (height % 2 == 1)
712  --height;
713  int x2 = x + height - 1;
714  if (reverse) {
715  x = viewOpt->rect.x() + viewOpt->rect.width() - 1;
716  x2 = x - height + 1;
717  }
718  path.moveTo(x, viewOpt->rect.y() + offset);
719  path.lineTo(x, viewOpt->rect.y() + offset + height);
720  path.lineTo(x2, viewOpt->rect.y() + offset+height/2);
721  path.closeSubpath();
722  if (viewOpt->state & QStyle::State_Selected ) {
723  if (viewOpt->showDecorationSelected) {
724  QColor color = viewOpt->palette.color(QPalette::Active, QPalette::HighlightedText);
725  p->setPen(color);
726  p->setBrush(color);
727  } else {
728  QColor color = viewOpt->palette.color(QPalette::Active, QPalette::WindowText);
729  p->setPen(color);
730  p->setBrush(color);
731  }
732 
733  } else {
734  QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Mid);
735  p->setPen(color);
736  p->setBrush(color);
737  }
738  p->drawPath(path);
739 
740  // draw the vertical and top triangle line
741  if (!(viewOpt->state & QStyle::State_Selected)) {
742  QPainterPath lines;
743  lines.moveTo(x, viewOpt->rect.y() + offset);
744  lines.lineTo(x, viewOpt->rect.y() + offset + height);
745  lines.moveTo(x, viewOpt->rect.y() + offset);
746  lines.lineTo(x2, viewOpt->rect.y() + offset+height/2);
747  QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Dark);
748  p->setPen(color);
749  p->drawPath(lines);
750  }
751  p->restore();
752  }
753  break; }
754 #endif //QT_NO_COLUMNVIEW
756  QRect rect = opt->rect;
757  if (opt->rect.height() == 0)
758  p->drawLine(rect.topLeft(), rect.topRight());
759  else
760  p->drawRect(rect);
761  break; }
762 #ifndef QT_NO_ITEMVIEWS
763  case PE_PanelItemViewRow:
764  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
767  if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
768  cg = QPalette::Inactive;
769 
771  p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
772  else if (vopt->features & QStyleOptionViewItemV2::Alternate)
773  p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
774  }
775  break;
777  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
780  if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
781  cg = QPalette::Inactive;
782 
783  if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) {
784  p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
785  } else {
786  if (vopt->backgroundBrush.style() != Qt::NoBrush) {
787  QPointF oldBO = p->brushOrigin();
788  p->setBrushOrigin(vopt->rect.topLeft());
789  p->fillRect(vopt->rect, vopt->backgroundBrush);
790  p->setBrushOrigin(oldBO);
791  }
792 
793  if (vopt->state & QStyle::State_Selected) {
795  p->fillRect(textRect, vopt->palette.brush(cg, QPalette::Highlight));
796  }
797  }
798  }
799  break;
800 #endif //QT_NO_ITEMVIEWS
802  const QBrush brush(opt->palette.brush(QPalette::Window));
803  p->fillRect(opt->rect, brush);
804  } break;
805  default:
806  break;
807  }
808 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
int height
the height of the item
Definition: qstyleoption.h:474
#define INTARRLEN(x)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
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
double qreal
Definition: qglobal.h:1193
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
Definition: qpainter.cpp:4602
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:204
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
static C reverse(const C &l)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
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
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
void getHsv(int *h, int *s, int *v, int *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
Definition: qcolor.cpp:679
ColorGroup
Definition: qpalette.h:92
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
Definition: qdrawutil.cpp:475
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The QStyleOptionTabBarBase class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:218
static const char *const tree_branch_open_xpm[]
FrameFeatures features
a bitwise OR of the features that describe this frame.
Definition: qstyleoption.h:143
bool isEnabled() const
Definition: qwidget.h:948
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
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
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
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
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
static const char *const tree_branch_closed_xpm[]
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
const QBrush & toolTipBase() const
Returns the tool tip base brush of the current color group.
Definition: qpalette.h:132
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static const char *const check_list_controller_xpm[]
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
const QBrush & toolTipText() const
Returns the tool tip text brush of the current color group.
Definition: qpalette.h:133
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
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
int open(const char *, int,...)
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ generatedIconPixmap()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QMacStyle, QGtkStyle, QStyleSheetStyle, QProxyStyle, and QWindowsMobileStyle.

Definition at line 5981 of file qcommonstyle.cpp.

Referenced by QWindowsMobileStyle::generatedIconPixmap(), QCleanlooksStyle::generatedIconPixmap(), and QMacStyle::generatedIconPixmap().

5983 {
5984  switch (iconMode) {
5985  case QIcon::Disabled: {
5987 
5988  // Create a colortable based on the background (black -> bg -> white)
5990  int red = bg.red();
5991  int green = bg.green();
5992  int blue = bg.blue();
5993  uchar reds[256], greens[256], blues[256];
5994  for (int i=0; i<128; ++i) {
5995  reds[i] = uchar((red * (i<<1)) >> 8);
5996  greens[i] = uchar((green * (i<<1)) >> 8);
5997  blues[i] = uchar((blue * (i<<1)) >> 8);
5998  }
5999  for (int i=0; i<128; ++i) {
6000  reds[i+128] = uchar(qMin(red + (i << 1), 255));
6001  greens[i+128] = uchar(qMin(green + (i << 1), 255));
6002  blues[i+128] = uchar(qMin(blue + (i << 1), 255));
6003  }
6004 
6005  int intensity = qt_intensity(red, green, blue);
6006  const int factor = 191;
6007 
6008  // High intensity colors needs dark shifting in the color table, while
6009  // low intensity colors needs light shifting. This is to increase the
6010  // percieved contrast.
6011  if ((red - factor > green && red - factor > blue)
6012  || (green - factor > red && green - factor > blue)
6013  || (blue - factor > red && blue - factor > green))
6014  intensity = qMin(255, intensity + 91);
6015  else if (intensity <= 128)
6016  intensity -= 51;
6017 
6018  for (int y=0; y<im.height(); ++y) {
6019  QRgb *scanLine = (QRgb*)im.scanLine(y);
6020  for (int x=0; x<im.width(); ++x) {
6021  QRgb pixel = *scanLine;
6022  // Calculate color table index, taking intensity adjustment
6023  // and a magic offset into account.
6024  uint ci = uint(qGray(pixel)/3 + (130 - intensity / 3));
6025  *scanLine = qRgba(reds[ci], greens[ci], blues[ci], qAlpha(pixel));
6026  ++scanLine;
6027  }
6028  }
6029 
6030  return QPixmap::fromImage(im);
6031  }
6032  case QIcon::Selected: {
6035  color.setAlphaF(qreal(0.3));
6036  QPainter painter(&img);
6037  painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
6038  painter.fillRect(0, 0, img.width(), img.height(), color);
6039  painter.end();
6040  return QPixmap::fromImage(img); }
6041  case QIcon::Active:
6042  return pixmap;
6043  default:
6044  break;
6045  }
6046  return pixmap;
6047 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
unsigned int QRgb
Definition: qrgb.h:53
double qreal
Definition: qglobal.h:1193
static uint qt_intensity(uint r, uint g, uint b)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
unsigned char uchar
Definition: qglobal.h:994
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
Definition: qrgb.h:72
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1117
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ hitTestComplexControl()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QMacStyle, QProxyStyle, QWindowsCEStyle, QPlastiqueStyle, and QWindowsVistaStyle.

Definition at line 3796 of file qcommonstyle.cpp.

Referenced by QWindowsVistaStyle::hitTestComplexControl(), QCleanlooksStyle::hitTestComplexControl(), QPlastiqueStyle::hitTestComplexControl(), QWindowsCEStyle::hitTestComplexControl(), QMacStyle::hitTestComplexControl(), and QStyleSheetStyle::hitTestComplexControl().

3798 {
3799  SubControl sc = SC_None;
3800  switch (cc) {
3801 #ifndef QT_NO_SLIDER
3802  case CC_Slider:
3803  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3804  QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget);
3805  if (r.isValid() && r.contains(pt)) {
3806  sc = SC_SliderHandle;
3807  } else {
3808  r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget);
3809  if (r.isValid() && r.contains(pt))
3810  sc = SC_SliderGroove;
3811  }
3812  }
3813  break;
3814 #endif // QT_NO_SLIDER
3815 #ifndef QT_NO_SCROLLBAR
3816  case CC_ScrollBar:
3817  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3818  QRect r;
3819  uint ctrl = SC_ScrollBarAddLine;
3820  while (ctrl <= SC_ScrollBarGroove) {
3821  r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget);
3822  if (r.isValid() && r.contains(pt)) {
3823  sc = QStyle::SubControl(ctrl);
3824  break;
3825  }
3826  ctrl <<= 1;
3827  }
3828  }
3829  break;
3830 #endif // QT_NO_SCROLLBAR
3831 #ifndef QT_NO_TOOLBUTTON
3832  case CC_ToolButton:
3833  if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3834  QRect r;
3835  uint ctrl = SC_ToolButton;
3836  while (ctrl <= SC_ToolButtonMenu) {
3837  r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget);
3838  if (r.isValid() && r.contains(pt)) {
3839  sc = QStyle::SubControl(ctrl);
3840  break;
3841  }
3842  ctrl <<= 1;
3843  }
3844  }
3845  break;
3846 #endif // QT_NO_TOOLBUTTON
3847 #ifdef QT3_SUPPORT
3848  case CC_Q3ListView:
3849  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
3850  if (pt.x() >= 0 && pt.x() < lv->treeStepSize)
3851  sc = SC_Q3ListViewExpand;
3852  }
3853  break;
3854 #endif // QT3_SUPPORT
3855 #ifndef QT_NO_SPINBOX
3856  case CC_SpinBox:
3857  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3858  QRect r;
3859  uint ctrl = SC_SpinBoxUp;
3860  while (ctrl <= SC_SpinBoxEditField) {
3861  r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget);
3862  if (r.isValid() && r.contains(pt)) {
3863  sc = QStyle::SubControl(ctrl);
3864  break;
3865  }
3866  ctrl <<= 1;
3867  }
3868  }
3869  break;
3870 #endif // QT_NO_SPINBOX
3871  case CC_TitleBar:
3872  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
3873  QRect r;
3874  uint ctrl = SC_TitleBarSysMenu;
3875 
3876  while (ctrl <= SC_TitleBarLabel) {
3877  r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget);
3878  if (r.isValid() && r.contains(pt)) {
3879  sc = QStyle::SubControl(ctrl);
3880  break;
3881  }
3882  ctrl <<= 1;
3883  }
3884  }
3885  break;
3886 #ifndef QT_NO_COMBOBOX
3887  case CC_ComboBox:
3888  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
3889  QRect r;
3890  uint ctrl = SC_ComboBoxArrow; // Start here and go down.
3891  while (ctrl > 0) {
3892  r = proxy()->subControlRect(cc, cb, QStyle::SubControl(ctrl), widget);
3893  if (r.isValid() && r.contains(pt)) {
3894  sc = QStyle::SubControl(ctrl);
3895  break;
3896  }
3897  ctrl >>= 1;
3898  }
3899  }
3900  break;
3901 #endif // QT_NO_COMBOBOX
3902 #ifndef QT_NO_GROUPBOX
3903  case CC_GroupBox:
3904  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
3905  QRect r;
3906  uint ctrl = SC_GroupBoxCheckBox;
3907  while (ctrl <= SC_GroupBoxFrame) {
3908  r = proxy()->subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget);
3909  if (r.isValid() && r.contains(pt)) {
3910  sc = QStyle::SubControl(ctrl);
3911  break;
3912  }
3913  ctrl <<= 1;
3914  }
3915  }
3916  break;
3917 #endif // QT_NO_GROUPBOX
3918  case CC_MdiControls:
3919  {
3920  QRect r;
3921  uint ctrl = SC_MdiMinButton;
3922  while (ctrl <= SC_MdiCloseButton) {
3924  if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) {
3925  sc = QStyle::SubControl(ctrl);
3926  return sc;
3927  }
3928  ctrl <<= 1;
3929  }
3930  }
3931  break;
3932  default:
3933  qWarning("QCommonStyle::hitTestComplexControl: Case %d not handled", cc);
3934  }
3935  return sc;
3936 }
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QPointer< QWidget > widget
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...
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
Q_CORE_EXPORT void qWarning(const char *,...)
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
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693

◆ pixelMetric()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QMacStyle, QMotifStyle, QWindowsCEStyle, QWindowsMobileStyle, QGtkStyle, QProxyStyle, QPlastiqueStyle, QWindowsStyle, QWindowsXPStyle, and QWindowsVistaStyle.

Definition at line 4373 of file qcommonstyle.cpp.

Referenced by drawComplexControl(), drawControl(), QWindowsStyle::pixelMetric(), QMotifStyle::pixelMetric(), sizeFromContents(), and subElementRect().

4374 {
4375  int ret;
4376 
4377  switch (m) {
4378  case PM_FocusFrameVMargin:
4379  case PM_FocusFrameHMargin:
4380  ret = 2;
4381  break;
4382  case PM_MenuBarVMargin:
4383  case PM_MenuBarHMargin:
4384  ret = 0;
4385  break;
4387  ret = int(QStyleHelper::dpiScaled(5.));
4388  break;
4390  ret = int(QStyleHelper::dpiScaled(70.));
4391  break;
4393  ret = int(QStyleHelper::dpiScaled(30.));
4394  break;
4397  ret = int(QStyleHelper::dpiScaled(16.));
4398  break;
4399  case PM_TitleBarHeight: {
4400  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4401  if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) {
4402  ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 16);
4403 #ifndef QT_NO_DOCKWIDGET
4404  } else if (qobject_cast<const QDockWidget*>(widget)) {
4405  ret = qMax(widget->fontMetrics().height(), int(QStyleHelper::dpiScaled(13)));
4406 #endif
4407  } else {
4408  ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 18);
4409  }
4410  } else {
4411  ret = int(QStyleHelper::dpiScaled(18.));
4412  }
4413 
4414  break; }
4415  case PM_ScrollBarSliderMin:
4416  ret = int(QStyleHelper::dpiScaled(9.));
4417  break;
4418 
4419  case PM_ButtonMargin:
4420  ret = int(QStyleHelper::dpiScaled(6.));
4421  break;
4422 
4424  ret = int(QStyleHelper::dpiScaled(2.));
4425  break;
4426 
4428  ret = 0;
4429  break;
4430 
4432  ret = int(QStyleHelper::dpiScaled(12.));
4433  break;
4434 
4437 
4438  case PM_DefaultFrameWidth:
4439  ret = 2;
4440  break;
4441 
4442  case PM_ComboBoxFrameWidth:
4443  case PM_SpinBoxFrameWidth:
4444  case PM_MenuPanelWidth:
4445  case PM_TabBarBaseOverlap:
4446  case PM_TabBarBaseHeight:
4447  ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
4448  break;
4449 
4451  ret = int(QStyleHelper::dpiScaled(4.));
4452  break;
4453 
4455  ret = int(QStyleHelper::dpiScaled(196.));
4456  break;
4457 
4458 #ifndef QT_NO_SCROLLBAR
4459  case PM_ScrollBarExtent:
4460  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4461  int s = sb->orientation == Qt::Horizontal ?
4464  ret = qMax(16, s);
4465  } else {
4466  ret = int(QStyleHelper::dpiScaled(16.));
4467  }
4468  break;
4469 #endif
4471  ret = -1;
4472  break;
4473 
4474 #ifndef QT_NO_SLIDER
4475  case PM_SliderThickness:
4476  ret = int(QStyleHelper::dpiScaled(16.));
4477  break;
4478 
4480  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4481  int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height()
4482  : sl->rect.width();
4483  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget);
4484  int ticks = sl->tickPosition;
4485 
4486  if (ticks == QSlider::TicksBothSides)
4487  ret = (space - thickness) / 2;
4488  else if (ticks == QSlider::TicksAbove)
4489  ret = space - thickness;
4490  else
4491  ret = 0;
4492  } else {
4493  ret = 0;
4494  }
4495  break;
4496 
4498  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4499  if (sl->orientation == Qt::Horizontal)
4500  ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4501  else
4502  ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4503  } else {
4504  ret = 0;
4505  }
4506  break;
4507 #endif // QT_NO_SLIDER
4508 #ifndef QT_NO_DOCKWIDGET
4510  ret = int(QStyleHelper::dpiScaled(6.));
4511  break;
4512 
4514  ret = int(QStyleHelper::dpiScaled(8.));
4515  break;
4517  ret = 0;
4518  break;
4520  ret = 1;
4521  break;
4522 #endif // QT_NO_DOCKWIDGET
4523 
4525  case PM_MenuBarPanelWidth:
4526  ret = 2;
4527  break;
4528 
4529  case PM_MenuBarItemSpacing:
4530  ret = 0;
4531  break;
4532 
4533 #ifndef QT_NO_TOOLBAR
4534  case PM_ToolBarFrameWidth:
4535  ret = 1;
4536  break;
4537 
4538  case PM_ToolBarItemMargin:
4539  ret = 0;
4540  break;
4541 
4542  case PM_ToolBarItemSpacing:
4543  ret = int(QStyleHelper::dpiScaled(4.));
4544  break;
4545 
4547  ret = int(QStyleHelper::dpiScaled(8.));
4548  break;
4549 
4551  ret = int(QStyleHelper::dpiScaled(6.));
4552  break;
4553 
4555  ret = int(QStyleHelper::dpiScaled(12.));
4556  break;
4557 #endif // QT_NO_TOOLBAR
4558 
4559 #ifndef QT_NO_TABBAR
4560  case PM_TabBarTabOverlap:
4561  ret = 3;
4562  break;
4563 
4564  case PM_TabBarTabHSpace:
4565  ret = int(QStyleHelper::dpiScaled(24.));
4566  break;
4567 
4569  ret = 0;
4570  break;
4571 
4573  ret = 2;
4574  break;
4575 
4576  case PM_TabBarTabVSpace: {
4577  const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt);
4578  if (tb && (tb->shape == QTabBar::RoundedNorth || tb->shape == QTabBar::RoundedSouth
4580  ret = 8;
4581  else
4582  if(tb && (tb->shape == QTabBar::TriangularWest || tb->shape == QTabBar::TriangularEast))
4583  ret = 3;
4584  else
4585  ret = 2;
4586  break; }
4587 #endif
4588 
4590  ret = 9;
4591  break;
4592 
4593  case PM_IndicatorWidth:
4594  ret = int(QStyleHelper::dpiScaled(13.));
4595  break;
4596 
4597  case PM_IndicatorHeight:
4598  ret = int(QStyleHelper::dpiScaled(13.));
4599  break;
4600 
4602  ret = int(QStyleHelper::dpiScaled(12.));
4603  break;
4604 
4606  ret = int(QStyleHelper::dpiScaled(12.));
4607  break;
4608 
4609  case PM_MenuTearoffHeight:
4610  ret = int(QStyleHelper::dpiScaled(10.));
4611  break;
4612 
4613  case PM_MenuScrollerHeight:
4614  ret = int(QStyleHelper::dpiScaled(10.));
4615  break;
4616 
4618  case PM_MenuHMargin:
4619  case PM_MenuVMargin:
4620  ret = 0;
4621  break;
4622 
4623  case PM_HeaderMargin:
4624  ret = int(QStyleHelper::dpiScaled(4.));
4625  break;
4626  case PM_HeaderMarkSize:
4627  ret = int(QStyleHelper::dpiScaled(32.));
4628  break;
4629  case PM_HeaderGripMargin:
4630  ret = int(QStyleHelper::dpiScaled(4.));
4631  break;
4633  ret = int(QStyleHelper::dpiScaled(16.));
4634  break;
4635  case PM_LayoutLeftMargin:
4636  case PM_LayoutTopMargin:
4637  case PM_LayoutRightMargin:
4638  case PM_LayoutBottomMargin:
4639  {
4640  bool isWindow = false;
4641  if (opt) {
4642  isWindow = (opt->state & State_Window);
4643  } else if (widget) {
4644  isWindow = widget->isWindow();
4645  }
4647  }
4648  break;
4652  break;
4653 
4655  ret = int(QStyleHelper::dpiScaled(11.));
4656  break;
4657  case PM_DefaultChildMargin:
4658  ret = int(QStyleHelper::dpiScaled(9.));
4659  break;
4661  ret = int(QStyleHelper::dpiScaled(6.));
4662  break;
4663 
4664  case PM_ToolBarIconSize:
4666  if (!ret)
4667  ret = int(QStyleHelper::dpiScaled(24.));
4668  break;
4669 
4670  case PM_TabBarIconSize:
4671  case PM_ListViewIconSize:
4672  ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
4673  break;
4674 
4675  case PM_ButtonIconSize:
4676  case PM_SmallIconSize:
4677  ret = int(QStyleHelper::dpiScaled(16.));
4678  break;
4679  case PM_IconViewIconSize:
4680  ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
4681  break;
4682 
4683  case PM_LargeIconSize:
4684  ret = int(QStyleHelper::dpiScaled(32.));
4685  break;
4686 
4688  ret = 1;
4689  break;
4692  ret = int(QStyleHelper::dpiScaled(6.));
4693  break;
4694  case PM_SizeGripSize:
4695  ret = int(QStyleHelper::dpiScaled(13.));
4696  break;
4697  case PM_MessageBoxIconSize:
4698 #ifdef Q_WS_MAC
4700  ret = 64; // No DPI scaling, it's handled elsewhere.
4701  } else
4702 #endif
4703  {
4704  ret = int(QStyleHelper::dpiScaled(32.));
4705  }
4706  break;
4707  case PM_TextCursorWidth:
4708  ret = 1;
4709  break;
4711  ret = 1;
4712  break;
4715  ret = int(QStyleHelper::dpiScaled(16.));
4716  break;
4718  ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
4719  break;
4720  case PM_SubMenuOverlap:
4721  ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget);
4722  break;
4723  default:
4724  ret = 0;
4725  break;
4726  }
4727 
4728  return ret;
4729 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
QGuiPlatformPlugin * qt_guiPlatformPlugin()
Return (an construct if necesseray) the Gui Platform plugin.
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
Definition: qstyleoption.h:316
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
virtual int platformHint(PlatformHint hint)
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
qreal dpiScaled(qreal value)
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
int height() const
Returns the height.
Definition: qsize.h:129
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
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.

◆ polish() [1/3]

void QCommonStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QStyle.

Reimplemented in QGtkStyle, QStyleSheetStyle, QWindowsMobileStyle, QWindowsCEStyle, QProxyStyle, QPlastiqueStyle, QWindowsVistaStyle, QMacStyle, QMotifStyle, QWindowsStyle, and QWindowsXPStyle.

Definition at line 6052 of file qcommonstyle.cpp.

Referenced by QWindowsStyle::polish(), and QMotifStyle::polish().

6053 {
6054  QStyle::polish(pal);
6055 }
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ polish() [2/3]

void QCommonStyle::polish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QStyle.

Reimplemented in QGtkStyle, QStyleSheetStyle, QWindowsCEStyle, QProxyStyle, QWindowsMobileStyle, QPlastiqueStyle, QWindowsVistaStyle, QMacStyle, QMotifStyle, QWindowsXPStyle, and QWindowsStyle.

Definition at line 6076 of file qcommonstyle.cpp.

6077 {
6078  QStyle::polish(app);
6079 }
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ polish() [3/3]

void QCommonStyle::polish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QStyle.

Reimplemented in QGtkStyle, QStyleSheetStyle, QWindowsMobileStyle, QWindowsCEStyle, QProxyStyle, QPlastiqueStyle, QWindowsVistaStyle, QMacStyle, QMotifStyle, QWindowsStyle, and QWindowsXPStyle.

Definition at line 6060 of file qcommonstyle.cpp.

6061 {
6062  QStyle::polish(widget);
6063 }
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ sizeFromContents()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QMacStyle, QMotifStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QWindowsCEStyle, QWindowsMobileStyle, QPlastiqueStyle, and QWindowsVistaStyle.

Definition at line 4734 of file qcommonstyle.cpp.

Referenced by QWindowsMobileStyle::sizeFromContents(), QWindowsStyle::sizeFromContents(), QMotifStyle::sizeFromContents(), and QMacStyle::sizeFromContents().

4736 {
4737  Q_D(const QCommonStyle);
4738  QSize sz(csz);
4739  switch (ct) {
4740  case CT_PushButton:
4741  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4742  int w = csz.width(),
4743  h = csz.height(),
4744  bm = proxy()->pixelMetric(PM_ButtonMargin, btn, widget),
4745  fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) * 2;
4746  w += bm + fw;
4747  h += bm + fw;
4748  if (btn->features & QStyleOptionButton::AutoDefaultButton){
4749  int dbw = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2;
4750  w += dbw;
4751  h += dbw;
4752  }
4753  sz = QSize(w, h);
4754  }
4755  break;
4756  case CT_RadioButton:
4757  case CT_CheckBox:
4758  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4759  bool isRadio = (ct == CT_RadioButton);
4760 
4761  int w = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
4762  : PM_IndicatorWidth, btn, widget);
4763  int h = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
4764  : PM_IndicatorHeight, btn, widget);
4765 
4766  int margins = 0;
4767  // we add 4 pixels for label margins
4768  if (!btn->icon.isNull() || !btn->text.isEmpty())
4769  margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
4770  : PM_CheckBoxLabelSpacing, opt, widget);
4771  sz += QSize(w + margins, 4);
4772  sz.setHeight(qMax(sz.height(), h));
4773  }
4774  break;
4775 #ifndef QT_NO_MENU
4776  case CT_MenuItem:
4777  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4778  bool checkable = mi->menuHasCheckableItems;
4779  int maxpmw = mi->maxIconWidth;
4780  int w = sz.width(), h = sz.height();
4781  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
4782  w = 10;
4783  h = 2;
4784  } else {
4785  h = mi->fontMetrics.height() + 8;
4786  if (!mi->icon.isNull()) {
4787  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
4788  h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
4789  }
4790  }
4791  if (mi->text.contains(QLatin1Char('\t')))
4792  w += 12;
4793  if (maxpmw > 0)
4794  w += maxpmw + 6;
4795  if (checkable && maxpmw < 20)
4796  w += 20 - maxpmw;
4797  if (checkable || maxpmw > 0)
4798  w += 2;
4799  w += 12;
4800  sz = QSize(w, h);
4801  }
4802  break;
4803 #endif // QT_NO_MENU
4804 #ifndef QT_NO_TOOLBUTTON
4805  case CT_ToolButton:
4806  sz = QSize(sz.width() + 6, sz.height() + 5);
4807  break;
4808 #endif // QT_NO_TOOLBUTTON
4809 #ifndef QT_NO_COMBOBOX
4810  case CT_ComboBox:
4811  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4812  int fw = cmb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0;
4813  const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
4814  // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
4815  int other = qMax(23, 2*textMargins + proxy()->pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget));
4816  sz = QSize(sz.width() + fw + other, sz.height() + fw);
4817  }
4818  break;
4819 #endif // QT_NO_COMBOBOX
4820  case CT_HeaderSection:
4821  if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
4822  bool nullIcon = hdr->icon.isNull();
4823  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget);
4824  int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize, hdr, widget);
4825  QSize txt = hdr->fontMetrics.size(0, hdr->text);
4826  sz.setHeight(margin + qMax(iconSize, txt.height()) + margin);
4827  sz.setWidth((nullIcon ? 0 : margin) + iconSize
4828  + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
4829  }
4830  break;
4831  case CT_TabWidget:
4832  sz += QSize(4, 4);
4833  break;
4834  case CT_LineEdit:
4835  if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt))
4836  sz += QSize(2*f->lineWidth, 2*f->lineWidth);
4837  break;
4838 #ifndef QT_NO_GROUPBOX
4839  case CT_GroupBox:
4840  if (const QGroupBox *grb = static_cast<const QGroupBox *>(widget))
4841  sz += QSize(!grb->isFlat() ? 16 : 0, 0);
4842  break;
4843 #endif // QT_NO_GROUPBOX
4844  case CT_MdiControls:
4845  if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
4846  int width = 1;
4847  if (styleOpt->subControls & SC_MdiMinButton)
4848  width += 16 + 1;
4849  if (styleOpt->subControls & SC_MdiNormalButton)
4850  width += 16 + 1;
4851  if (styleOpt->subControls & SC_MdiCloseButton)
4852  width += 16 + 1;
4853  sz = QSize(width, 16);
4854  } else {
4855  sz = QSize(52, 16);
4856  }
4857  break;
4858 #ifndef QT_NO_ITEMVIEWS
4859  case CT_ItemViewItem:
4860  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
4861  QRect decorationRect, displayRect, checkRect;
4862  d->viewItemLayout(vopt, &checkRect, &decorationRect, &displayRect, true);
4863  sz = (decorationRect|displayRect|checkRect).size();
4864  }
4865  break;
4866 #endif // QT_NO_ITEMVIEWS
4867  case CT_ScrollBar:
4868  case CT_MenuBar:
4869  case CT_Menu:
4870  case CT_MenuBarItem:
4871  case CT_Q3Header:
4872  case CT_Slider:
4873  case CT_ProgressBar:
4874  case CT_TabBarTab:
4875  // just return the contentsSize for now
4876  // fall through intended
4877  default:
4878  break;
4879  }
4880  return sz;
4881 }
double d
Definition: qnumeric_p.h:62
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
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
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 QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionComplex class is used to hold parameters that are common to all complex controls...
Definition: qstyleoption.h:687
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

◆ standardIconImplementation

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

Definition at line 5485 of file qcommonstyle.cpp.

Referenced by QWindowsStyle::standardIconImplementation(), and QMotifStyle::standardIconImplementation().

5487 {
5488  QIcon icon;
5489  const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
5491  switch (standardIcon) {
5492  case SP_DirHomeIcon:
5493  icon = QIcon::fromTheme(QLatin1String("user-home"));
5494  break;
5496  icon = QIcon::fromTheme(QLatin1String("dialog-information"));
5497  break;
5498  case SP_MessageBoxWarning:
5499  icon = QIcon::fromTheme(QLatin1String("dialog-warning"));
5500  break;
5501  case SP_MessageBoxCritical:
5502  icon = QIcon::fromTheme(QLatin1String("dialog-error"));
5503  break;
5504  case SP_MessageBoxQuestion:
5505  icon = QIcon::fromTheme(QLatin1String("dialog-question"));
5506  break;
5507  case SP_DialogOpenButton:
5508  case SP_DirOpenIcon:
5509  icon = QIcon::fromTheme(QLatin1String("folder-open"));
5510  break;
5511  case SP_DialogSaveButton:
5512  icon = QIcon::fromTheme(QLatin1String("document-save"));
5513  break;
5514  case SP_DialogApplyButton:
5515  icon = QIcon::fromTheme(QLatin1String("dialog-ok-apply"));
5516  break;
5517  case SP_DialogYesButton:
5518  case SP_DialogOkButton:
5519  icon = QIcon::fromTheme(QLatin1String("dialog-ok"));
5520  break;
5522  icon = QIcon::fromTheme(QLatin1String("edit-delete"));
5523  break;
5524  case SP_DialogResetButton:
5525  icon = QIcon::fromTheme(QLatin1String("edit-clear"));
5526  break;
5527  case SP_DialogHelpButton:
5528  icon = QIcon::fromTheme(QLatin1String("help-contents"));
5529  break;
5530  case SP_FileIcon:
5531  icon = QIcon::fromTheme(QLatin1String("text-x-generic"));
5532  break;
5533  case SP_DirClosedIcon:
5534  case SP_DirIcon:
5535  icon = QIcon::fromTheme(QLatin1String("folder"));
5536  break;
5537  case SP_DriveFDIcon:
5538  icon = QIcon::fromTheme(QLatin1String("floppy_unmount"));
5539  break;
5540  case SP_ComputerIcon:
5541  icon = QIcon::fromTheme(QLatin1String("computer"),
5542  QIcon::fromTheme(QLatin1String("system")));
5543  break;
5544  case SP_DesktopIcon:
5545  icon = QIcon::fromTheme(QLatin1String("user-desktop"));
5546  break;
5547  case SP_TrashIcon:
5548  icon = QIcon::fromTheme(QLatin1String("user-trash"));
5549  break;
5550  case SP_DriveCDIcon:
5551  case SP_DriveDVDIcon:
5552  icon = QIcon::fromTheme(QLatin1String("media-optical"));
5553  break;
5554  case SP_DriveHDIcon:
5555  icon = QIcon::fromTheme(QLatin1String("drive-harddisk"));
5556  break;
5557  case SP_FileDialogToParent:
5558  icon = QIcon::fromTheme(QLatin1String("go-up"));
5559  break;
5561  icon = QIcon::fromTheme(QLatin1String("folder-new"));
5562  break;
5563  case SP_ArrowUp:
5564  icon = QIcon::fromTheme(QLatin1String("go-up"));
5565  break;
5566  case SP_ArrowDown:
5567  icon = QIcon::fromTheme(QLatin1String("go-down"));
5568  break;
5569  case SP_ArrowRight:
5570  icon = QIcon::fromTheme(QLatin1String("go-next"));
5571  break;
5572  case SP_ArrowLeft:
5573  icon = QIcon::fromTheme(QLatin1String("go-previous"));
5574  break;
5575  case SP_DialogCancelButton:
5576  icon = QIcon::fromTheme(QLatin1String("dialog-cancel"),
5577  QIcon::fromTheme(QLatin1String("process-stop")));
5578  break;
5579  case SP_DialogCloseButton:
5580  icon = QIcon::fromTheme(QLatin1String("window-close"));
5581  break;
5583  icon = QIcon::fromTheme(QLatin1String("view-list-details"));
5584  break;
5585  case SP_FileDialogListView:
5586  icon = QIcon::fromTheme(QLatin1String("view-list-icons"));
5587  break;
5588  case SP_BrowserReload:
5589  icon = QIcon::fromTheme(QLatin1String("view-refresh"));
5590  break;
5591  case SP_BrowserStop:
5592  icon = QIcon::fromTheme(QLatin1String("process-stop"));
5593  break;
5594  case SP_MediaPlay:
5595  icon = QIcon::fromTheme(QLatin1String("media-playback-start"));
5596  break;
5597  case SP_MediaPause:
5598  icon = QIcon::fromTheme(QLatin1String("media-playback-pause"));
5599  break;
5600  case SP_MediaStop:
5601  icon = QIcon::fromTheme(QLatin1String("media-playback-stop"));
5602  break;
5603  case SP_MediaSeekForward:
5604  icon = QIcon::fromTheme(QLatin1String("media-seek-forward"));
5605  break;
5606  case SP_MediaSeekBackward:
5607  icon = QIcon::fromTheme(QLatin1String("media-seek-backward"));
5608  break;
5609  case SP_MediaSkipForward:
5610  icon = QIcon::fromTheme(QLatin1String("media-skip-forward"));
5611  break;
5612  case SP_MediaSkipBackward:
5613  icon = QIcon::fromTheme(QLatin1String("media-skip-backward"));
5614  break;
5615  case SP_MediaVolume:
5616  icon = QIcon::fromTheme(QLatin1String("audio-volume-medium"));
5617  break;
5618  case SP_MediaVolumeMuted:
5619  icon = QIcon::fromTheme(QLatin1String("audio-volume-muted"));
5620  break;
5621  case SP_ArrowForward:
5622  if (rtl)
5623  return standardIconImplementation(SP_ArrowLeft, option, widget);
5624  return standardIconImplementation(SP_ArrowRight, option, widget);
5625  case SP_ArrowBack:
5626  if (rtl)
5627  return standardIconImplementation(SP_ArrowRight, option, widget);
5628  return standardIconImplementation(SP_ArrowLeft, option, widget);
5629  case SP_FileLinkIcon:
5630  {
5631  QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link"));
5632  if (!linkIcon.isNull()) {
5633  QIcon baseIcon = standardIconImplementation(SP_FileIcon, option, widget);
5634  const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
5635  for (int i = 0 ; i < sizes.size() ; ++i) {
5636  int size = sizes[i].width();
5637  QPixmap basePixmap = baseIcon.pixmap(size);
5638  QPixmap linkPixmap = linkIcon.pixmap(size/2);
5639  QPainter painter(&basePixmap);
5640  painter.drawPixmap(size/2, size/2, linkPixmap);
5641  icon.addPixmap(basePixmap);
5642  }
5643  }
5644  }
5645  break;
5646  case SP_DirLinkIcon:
5647  {
5648  QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link"));
5649  if (!linkIcon.isNull()) {
5650  QIcon baseIcon = standardIconImplementation(SP_DirIcon, option, widget);
5651  const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
5652  for (int i = 0 ; i < sizes.size() ; ++i) {
5653  int size = sizes[i].width();
5654  QPixmap basePixmap = baseIcon.pixmap(size);
5655  QPixmap linkPixmap = linkIcon.pixmap(size/2);
5656  QPainter painter(&basePixmap);
5657  painter.drawPixmap(size/2, size/2, linkPixmap);
5658  icon.addPixmap(basePixmap);
5659  }
5660  }
5661  }
5662  break;
5663  default:
5664  break;
5665  }
5666  } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty())
5667  if (!icon.isNull())
5668  return icon;
5669 #if defined(Q_WS_MAC)
5671  OSType iconType = 0;
5672  switch (standardIcon) {
5674  iconType = kQuestionMarkIcon;
5675  break;
5677  iconType = kAlertNoteIcon;
5678  break;
5680  iconType = kAlertCautionIcon;
5681  break;
5683  iconType = kAlertStopIcon;
5684  break;
5685  case SP_DesktopIcon:
5686  iconType = kDesktopIcon;
5687  break;
5688  case SP_TrashIcon:
5689  iconType = kTrashIcon;
5690  break;
5691  case SP_ComputerIcon:
5692  iconType = kComputerIcon;
5693  break;
5694  case SP_DriveFDIcon:
5695  iconType = kGenericFloppyIcon;
5696  break;
5697  case SP_DriveHDIcon:
5698  iconType = kGenericHardDiskIcon;
5699  break;
5700  case SP_DriveCDIcon:
5701  case SP_DriveDVDIcon:
5702  iconType = kGenericCDROMIcon;
5703  break;
5704  case SP_DriveNetIcon:
5705  iconType = kGenericNetworkIcon;
5706  break;
5707  case SP_DirOpenIcon:
5708  iconType = kOpenFolderIcon;
5709  break;
5710  case SP_DirClosedIcon:
5711  case SP_DirLinkIcon:
5712  iconType = kGenericFolderIcon;
5713  break;
5714  case SP_FileLinkIcon:
5715  case SP_FileIcon:
5716  iconType = kGenericDocumentIcon;
5717  break;
5718  case SP_DirIcon: {
5719  // A rather special case
5720  QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget);
5721  QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget);
5722  closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On);
5723  closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On);
5724  closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On);
5725  closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On);
5726  return closeIcon;
5727  }
5729  case SP_TitleBarCloseButton: {
5730  QIcon titleBarIcon;
5732  titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png"));
5733  titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
5734  } else {
5735  titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png"));
5736  titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
5737  }
5738  return titleBarIcon;
5739  }
5740  default:
5741  break;
5742  }
5743  if (iconType != 0) {
5744  QIcon retIcon;
5745  IconRef icon;
5746  IconRef overlayIcon = 0;
5747  if (iconType != kGenericApplicationIcon) {
5748  GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon);
5749  } else {
5750  FSRef fsRef;
5751  ProcessSerialNumber psn = { 0, kCurrentProcess };
5752  GetProcessBundleLocation(&psn, &fsRef);
5753  GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0);
5755  overlayIcon = icon;
5756  GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon);
5757  }
5758  }
5759  if (icon) {
5760  qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon);
5761  ReleaseIconRef(icon);
5762  }
5763  if (overlayIcon)
5764  ReleaseIconRef(overlayIcon);
5765  return retIcon;
5766  }
5767  } // if (QApplication::desktopSettingsAware())
5768 #endif // Q_WS_MAC
5769 
5770  switch (standardIcon) {
5771 #ifndef QT_NO_IMAGEFORMAT_PNG
5773  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png"), QSize(16, 16));
5774  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-32.png"), QSize(32, 32));
5775  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-128.png"), QSize(128, 128));
5776  break;
5777  case SP_FileDialogBack:
5778  return standardIconImplementation(SP_ArrowBack, option, widget);
5779  case SP_FileDialogToParent:
5780  return standardIconImplementation(SP_ArrowUp, option, widget);
5782  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-16.png"), QSize(16, 16));
5783  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-32.png"), QSize(32, 32));
5784  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-128.png"), QSize(128, 128));
5785  break;
5786  case SP_FileDialogInfoView:
5787  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-16.png"), QSize(16, 16));
5788  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-32.png"), QSize(32, 32));
5789  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-128.png"), QSize(128, 128));
5790  break;
5792  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-16.png"), QSize(16, 16));
5793  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-32.png"), QSize(32, 32));
5794  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-128.png"), QSize(128, 128));
5795  break;
5796  case SP_FileDialogListView:
5797  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png"), QSize(16, 16));
5798  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-32.png"), QSize(32, 32));
5799  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-128.png"), QSize(128, 128));
5800  break;
5801  case SP_DialogOkButton:
5802  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png"), QSize(16, 16));
5803  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-32.png"), QSize(32, 32));
5804  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-128.png"), QSize(128, 128));
5805  break;
5806  case SP_DialogCancelButton:
5807  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png"), QSize(16, 16));
5808  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-32.png"), QSize(32, 32));
5809  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-128.png"), QSize(128, 128));
5810  break;
5811  case SP_DialogHelpButton:
5812  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png"), QSize(16, 16));
5813  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-32.png"), QSize(32, 32));
5814  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-128.png"), QSize(128, 128));
5815  break;
5816  case SP_DialogOpenButton:
5817  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png"), QSize(16, 16));
5818  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png"), QSize(32, 32));
5819  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png"), QSize(128, 128));
5820  break;
5821  case SP_DialogSaveButton:
5822  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(16, 16));
5823  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(32, 32));
5824  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(128, 128));
5825  break;
5826  case SP_DialogCloseButton:
5827  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png"), QSize(16, 16));
5828  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-32.png"), QSize(32, 32));
5829  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-128.png"), QSize(128, 128));
5830  break;
5831  case SP_DialogApplyButton:
5832  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png"), QSize(16, 16));
5833  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-32.png"), QSize(32, 32));
5834  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-128.png"), QSize(128, 128));
5835  break;
5836  case SP_DialogResetButton:
5837  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-16.png"), QSize(16, 16));
5838  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-32.png"), QSize(32, 32));
5839  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-128.png"), QSize(128, 128));
5840  break;
5842  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-16.png"), QSize(16, 16));
5843  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-32.png"), QSize(32, 32));
5844  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-128.png"), QSize(128, 128));
5845  break;
5846  case SP_DialogYesButton:
5847  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png"), QSize(16, 16));
5848  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-32.png"), QSize(32, 32));
5849  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-128.png"), QSize(128, 128));
5850  break;
5851  case SP_DialogNoButton:
5852  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png"), QSize(16, 16));
5853  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-32.png"), QSize(32, 32));
5854  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-128.png"), QSize(128, 128));
5855  break;
5856  case SP_ArrowForward:
5857  if (rtl)
5858  return standardIconImplementation(SP_ArrowLeft, option, widget);
5859  return standardIconImplementation(SP_ArrowRight, option, widget);
5860  case SP_ArrowBack:
5861  if (rtl)
5862  return standardIconImplementation(SP_ArrowRight, option, widget);
5863  return standardIconImplementation(SP_ArrowLeft, option, widget);
5864  case SP_ArrowLeft:
5865  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png"), QSize(16, 16));
5866  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-32.png"), QSize(32, 32));
5867  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-128.png"), QSize(128, 128));
5868  break;
5869  case SP_ArrowRight:
5870  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png"), QSize(16, 16));
5871  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-32.png"), QSize(32, 32));
5872  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-128.png"), QSize(128, 128));
5873  break;
5874  case SP_ArrowUp:
5875  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png"), QSize(16, 16));
5876  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-32.png"), QSize(32, 32));
5877  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-128.png"), QSize(128, 128));
5878  break;
5879  case SP_ArrowDown:
5880  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png"), QSize(16, 16));
5881  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-32.png"), QSize(32, 32));
5882  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-128.png"), QSize(128, 128));
5883  break;
5884  case SP_DirHomeIcon:
5885  case SP_DirIcon:
5886  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png"),
5888  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png"),
5890  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-32.png"),
5891  QSize(32, 32), QIcon::Normal, QIcon::Off);
5892  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-32.png"),
5893  QSize(32, 32), QIcon::Normal, QIcon::On);
5894  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-128.png"),
5895  QSize(128, 128), QIcon::Normal, QIcon::Off);
5896  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-128.png"),
5897  QSize(128, 128), QIcon::Normal, QIcon::On);
5898  break;
5899  case SP_DriveCDIcon:
5900  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-16.png"), QSize(16, 16));
5901  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-32.png"), QSize(32, 32));
5902  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-128.png"), QSize(128, 128));
5903  break;
5904  case SP_DriveDVDIcon:
5905  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-16.png"), QSize(16, 16));
5906  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-32.png"), QSize(32, 32));
5907  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-128.png"), QSize(128, 128));
5908  break;
5909  case SP_FileIcon:
5910  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png"), QSize(16, 16));
5911  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-32.png"), QSize(32, 32));
5912  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-128.png"), QSize(128, 128));
5913  break;
5914  case SP_FileLinkIcon:
5915  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-16.png"), QSize(16, 16));
5916  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-32.png"), QSize(32, 32));
5917  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-128.png"), QSize(128, 128));
5918  break;
5919  case SP_TrashIcon:
5920  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-16.png"), QSize(16, 16));
5921  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-32.png"), QSize(32, 32));
5922  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-128.png"), QSize(128, 128));
5923  break;
5924  case SP_BrowserReload:
5925  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-24.png"), QSize(24, 24));
5926  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-32.png"), QSize(32, 32));
5927  break;
5928  case SP_BrowserStop:
5929  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/stop-24.png"), QSize(24, 24));
5930  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/stop-32.png"), QSize(32, 32));
5931  break;
5932  case SP_MediaPlay:
5933  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-16.png"), QSize(16, 16));
5934  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-32.png"), QSize(32, 32));
5935  break;
5936  case SP_MediaPause:
5937  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-16.png"), QSize(16, 16));
5938  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-32.png"), QSize(32, 32));
5939  break;
5940  case SP_MediaStop:
5941  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-16.png"), QSize(16, 16));
5942  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-32.png"), QSize(32, 32));
5943  break;
5944  case SP_MediaSeekForward:
5945  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-16.png"), QSize(16, 16));
5946  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-32.png"), QSize(32, 32));
5947  break;
5948  case SP_MediaSeekBackward:
5949  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-16.png"), QSize(16, 16));
5950  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-32.png"), QSize(32, 32));
5951  break;
5952  case SP_MediaSkipForward:
5953  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-16.png"), QSize(16, 16));
5954  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-32.png"), QSize(32, 32));
5955  break;
5956  case SP_MediaSkipBackward:
5957  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-16.png"), QSize(16, 16));
5958  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-32.png"), QSize(32, 32));
5959  break;
5960  case SP_MediaVolume:
5961  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-16.png"), QSize(16, 16));
5962  break;
5963  case SP_MediaVolumeMuted:
5964  icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-muted-16.png"), QSize(16, 16));
5965  break;
5966 #endif // QT_NO_IMAGEFORMAT_PNG
5967  default:
5968  icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget));
5969  break;
5970  }
5971  return icon;
5972 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
Returns a list of available icon sizes for the specified mode and state.
Definition: qicon.cpp:900
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition: qicon.cpp:814
static QIcon fromTheme(const QString &name, const QIcon &fallback=QIcon())
Returns the QIcon corresponding to name in the current icon theme.
Definition: qicon.cpp:1039
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
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
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
static QString themeName()
Returns the name of the current icon theme.
Definition: qicon.cpp:1001
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon)
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
void addFile(const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
Adds an image from the file with the given fileName to the icon, as a specialization for size...
Definition: qicon.cpp:851
struct OpaqueIconRef * IconRef
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ standardPixmap()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QMacStyle, QStyleSheetStyle, QGtkStyle, QMotifStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QPlastiqueStyle, QWindowsCEStyle, QWindowsMobileStyle, and QWindowsVistaStyle.

Definition at line 5176 of file qcommonstyle.cpp.

Referenced by standardIconImplementation(), QWindowsMobileStyle::standardPixmap(), QWindowsStyle::standardPixmap(), and QMotifStyle::standardPixmap().

5178 {
5179  const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
5180 #ifdef QT_NO_IMAGEFORMAT_PNG
5181  Q_UNUSED(widget);
5182  Q_UNUSED(sp);
5183 #else
5184  QPixmap pixmap;
5185 
5187  switch (sp) {
5188  case SP_DialogYesButton:
5189  case SP_DialogOkButton:
5190  pixmap = QIcon::fromTheme(QLatin1String("dialog-ok")).pixmap(16);
5191  break;
5192  case SP_DialogApplyButton:
5193  pixmap = QIcon::fromTheme(QLatin1String("dialog-ok-apply")).pixmap(16);
5194  break;
5196  pixmap = QIcon::fromTheme(QLatin1String("edit-delete")).pixmap(16);
5197  break;
5198  case SP_DialogCloseButton:
5199  pixmap = QIcon::fromTheme(QLatin1String("dialog-close")).pixmap(16);
5200  break;
5201  case SP_DirHomeIcon:
5202  pixmap = QIcon::fromTheme(QLatin1String("user-home")).pixmap(16);
5203  break;
5205  pixmap = QIcon::fromTheme(QLatin1String("messagebox_info")).pixmap(16);
5206  break;
5207  case SP_MessageBoxWarning:
5208  pixmap = QIcon::fromTheme(QLatin1String("messagebox_warning")).pixmap(16);
5209  break;
5210  case SP_MessageBoxCritical:
5211  pixmap = QIcon::fromTheme(QLatin1String("messagebox_critical")).pixmap(16);
5212  break;
5213  case SP_MessageBoxQuestion:
5214  pixmap = QIcon::fromTheme(QLatin1String("help")).pixmap(16);
5215  break;
5216  case SP_DialogOpenButton:
5217  case SP_DirOpenIcon:
5218  pixmap = QIcon::fromTheme(QLatin1String("folder-open")).pixmap(16);
5219  break;
5220  case SP_FileIcon:
5221  pixmap = QIcon::fromTheme(QLatin1String("text-x-generic"),
5222  QIcon::fromTheme(QLatin1String("empty"))).pixmap(16);
5223  break;
5224  case SP_DirClosedIcon:
5225  case SP_DirIcon:
5226  pixmap = QIcon::fromTheme(QLatin1String("folder")).pixmap(16);
5227  break;
5228  case SP_DriveFDIcon:
5229  pixmap = QIcon::fromTheme(QLatin1String("media-floppy"),
5230  QIcon::fromTheme(QLatin1String("3floppy_unmount"))).pixmap(16);
5231  break;
5232  case SP_ComputerIcon:
5233  pixmap = QIcon::fromTheme(QLatin1String("computer"),
5234  QIcon::fromTheme(QLatin1String("system"))).pixmap(16);
5235  break;
5236  case SP_DesktopIcon:
5237  pixmap = QIcon::fromTheme(QLatin1String("user-desktop"),
5238  QIcon::fromTheme(QLatin1String("desktop"))).pixmap(16);
5239  break;
5240  case SP_TrashIcon:
5241  pixmap = QIcon::fromTheme(QLatin1String("user-trash"),
5242  QIcon::fromTheme(QLatin1String("trashcan_empty"))).pixmap(16);
5243  break;
5244  case SP_DriveCDIcon:
5245  case SP_DriveDVDIcon:
5246  pixmap = QIcon::fromTheme(QLatin1String("media-optical"),
5247  QIcon::fromTheme(QLatin1String("cdrom_unmount"))).pixmap(16);
5248  break;
5249  case SP_DriveHDIcon:
5250  pixmap = QIcon::fromTheme(QLatin1String("drive-harddisk"),
5251  QIcon::fromTheme(QLatin1String("hdd_unmount"))).pixmap(16);
5252  break;
5253  case SP_FileDialogToParent:
5254  pixmap = QIcon::fromTheme(QLatin1String("go-up"),
5256  break;
5258  pixmap = QIcon::fromTheme(QLatin1String("folder_new")).pixmap(16);
5259  break;
5260  case SP_ArrowUp:
5261  pixmap = QIcon::fromTheme(QLatin1String("go-up"),
5263  break;
5264  case SP_ArrowDown:
5265  pixmap = QIcon::fromTheme(QLatin1String("go-down"),
5266  QIcon::fromTheme(QLatin1String("down"))).pixmap(16);
5267  break;
5268  case SP_ArrowRight:
5269  pixmap = QIcon::fromTheme(QLatin1String("go-next"),
5270  QIcon::fromTheme(QLatin1String("forward"))).pixmap(16);
5271  break;
5272  case SP_ArrowLeft:
5273  pixmap = QIcon::fromTheme(QLatin1String("go-previous"),
5274  QIcon::fromTheme(QLatin1String("back"))).pixmap(16);
5275  break;
5277  pixmap = QIcon::fromTheme(QLatin1String("view_detailed")).pixmap(16);
5278  break;
5279  case SP_FileDialogListView:
5280  pixmap = QIcon::fromTheme(QLatin1String("view_icon")).pixmap(16);
5281  break;
5282  case SP_BrowserReload:
5283  pixmap = QIcon::fromTheme(QLatin1String("reload")).pixmap(16);
5284  break;
5285  case SP_BrowserStop:
5286  pixmap = QIcon::fromTheme(QLatin1String("process-stop")).pixmap(16);
5287  break;
5288  case SP_MediaPlay:
5289  pixmap = QIcon::fromTheme(QLatin1String("media-playback-start")).pixmap(16);
5290  break;
5291  case SP_MediaPause:
5292  pixmap = QIcon::fromTheme(QLatin1String("media-playback-pause")).pixmap(16);
5293  break;
5294  case SP_MediaStop:
5295  pixmap = QIcon::fromTheme(QLatin1String("media-playback-stop")).pixmap(16);
5296  break;
5297  case SP_MediaSeekForward:
5298  pixmap = QIcon::fromTheme(QLatin1String("media-seek-forward")).pixmap(16);
5299  break;
5300  case SP_MediaSeekBackward:
5301  pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16);
5302  break;
5303  case SP_MediaSkipForward:
5304  pixmap = QIcon::fromTheme(QLatin1String("media-skip-forward")).pixmap(16);
5305  break;
5306  case SP_MediaSkipBackward:
5307  pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16);
5308  break;
5309  case SP_DialogResetButton:
5310  pixmap = QIcon::fromTheme(QLatin1String("edit-clear")).pixmap(24);
5311  break;
5312  case SP_DialogHelpButton:
5313  pixmap = QIcon::fromTheme(QLatin1String("help-contents")).pixmap(24);
5314  break;
5315  case SP_DialogNoButton:
5316  case SP_DialogCancelButton:
5317  pixmap = QIcon::fromTheme(QLatin1String("dialog-cancel"),
5318  QIcon::fromTheme(QLatin1String("process-stop"))).pixmap(24);
5319  break;
5320  case SP_DialogSaveButton:
5321  pixmap = QIcon::fromTheme(QLatin1String("document-save")).pixmap(24);
5322  break;
5323  case SP_FileLinkIcon:
5324  pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16);
5325  if (!pixmap.isNull()) {
5326  QPixmap fileIcon = QIcon::fromTheme(QLatin1String("text-x-generic")).pixmap(16);
5327  if (fileIcon.isNull())
5328  fileIcon = QIcon::fromTheme(QLatin1String("empty")).pixmap(16);
5329  if (!fileIcon.isNull()) {
5330  QPainter painter(&fileIcon);
5331  painter.drawPixmap(0, 0, 16, 16, pixmap);
5332  return fileIcon;
5333  }
5334  }
5335  break;
5336  case SP_DirLinkIcon:
5337  pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16);
5338  if (!pixmap.isNull()) {
5339  QPixmap dirIcon = QIcon::fromTheme(QLatin1String("folder")).pixmap(16);
5340  if (!dirIcon.isNull()) {
5341  QPainter painter(&dirIcon);
5342  painter.drawPixmap(0, 0, 16, 16, pixmap);
5343  return dirIcon;
5344  }
5345  }
5346  break;
5347  default:
5348  break;
5349  }
5350  }
5351 
5352  if (!pixmap.isNull())
5353  return pixmap;
5354 #endif //QT_NO_IMAGEFORMAT_PNG
5355  switch (sp) {
5356 #ifndef QT_NO_IMAGEFORMAT_XPM
5358  if (rtl) {
5360  im = im.convertToFormat(QImage::Format_ARGB32).mirrored(true, false);
5361  return QPixmap::fromImage(im);
5362  }
5366  case SP_FileDialogStart:
5367  return QPixmap(filedialog_start_xpm);
5368  case SP_FileDialogEnd:
5369  return QPixmap(filedialog_end_xpm);
5370 #endif
5371 #ifndef QT_NO_IMAGEFORMAT_PNG
5372  case SP_CommandLink:
5373  case SP_ArrowForward:
5374  if (rtl)
5375  return proxy()->standardPixmap(SP_ArrowLeft, option, widget);
5376  return proxy()->standardPixmap(SP_ArrowRight, option, widget);
5377  case SP_ArrowBack:
5378  if (rtl)
5379  return proxy()->standardPixmap(SP_ArrowRight, option, widget);
5380  return proxy()->standardPixmap(SP_ArrowLeft, option, widget);
5381  case SP_ArrowLeft:
5382  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png"));
5383  case SP_ArrowRight:
5384  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png"));
5385  case SP_ArrowUp:
5386  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png"));
5387  case SP_ArrowDown:
5388  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png"));
5389  case SP_FileDialogToParent:
5390  return proxy()->standardPixmap(SP_ArrowUp, option, widget);
5392  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png"));
5394  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-16.png"));
5395  case SP_FileDialogInfoView:
5396  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-16.png"));
5398  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-16.png"));
5399  case SP_FileDialogListView:
5400  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png"));
5401  case SP_FileDialogBack:
5402  return proxy()->standardPixmap(SP_ArrowBack, option, widget);
5403  case SP_DriveHDIcon:
5404  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/harddrive-16.png"));
5405  case SP_TrashIcon:
5406  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/trash-16.png"));
5407  case SP_DriveFDIcon:
5408  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/floppy-16.png"));
5409  case SP_DriveNetIcon:
5410  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/networkdrive-16.png"));
5411  case SP_DesktopIcon:
5412  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/desktop-16.png"));
5413  case SP_ComputerIcon:
5414  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/computer-16.png"));
5415  case SP_DriveCDIcon:
5416  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-16.png"));
5417  case SP_DriveDVDIcon:
5418  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-16.png"));
5419  case SP_DirHomeIcon:
5420  case SP_DirOpenIcon:
5421  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png"));
5422  case SP_DirIcon:
5423  case SP_DirClosedIcon:
5424  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png"));
5425  case SP_DirLinkIcon:
5426  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dirlink-16.png"));
5427  case SP_FileIcon:
5428  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png"));
5429  case SP_FileLinkIcon:
5430  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-16.png"));
5431  case SP_DialogOkButton:
5432  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png"));
5433  case SP_DialogCancelButton:
5434  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png"));
5435  case SP_DialogHelpButton:
5436  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png"));
5437  case SP_DialogOpenButton:
5438  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png"));
5439  case SP_DialogSaveButton:
5440  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"));
5441  case SP_DialogCloseButton:
5442  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png"));
5443  case SP_DialogApplyButton:
5444  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png"));
5445  case SP_DialogResetButton:
5446  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-16.png"));
5448  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-16.png"));
5449  case SP_DialogYesButton:
5450  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png"));
5451  case SP_DialogNoButton:
5452  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png"));
5453  case SP_BrowserReload:
5454  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-24.png"));
5455  case SP_BrowserStop:
5456  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/stop-24.png"));
5457  case SP_MediaPlay:
5458  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-32.png"));
5459  case SP_MediaPause:
5460  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-32.png"));
5461  case SP_MediaStop:
5462  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-32.png"));
5463  case SP_MediaSeekForward:
5464  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-32.png"));
5465  case SP_MediaSeekBackward:
5466  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-32.png"));
5467  case SP_MediaSkipForward:
5468  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-32.png"));
5469  case SP_MediaSkipBackward:
5470  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-32.png"));
5471  case SP_MediaVolume:
5472  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-16.png"));
5473  case SP_MediaVolumeMuted:
5474  return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-muted-16.png"));
5475 #endif // QT_NO_IMAGEFORMAT_PNG
5476  default:
5477  break;
5478  }
5479  return QPixmap();
5480 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
static QIcon fromTheme(const QString &name, const QIcon &fallback=QIcon())
Returns the QIcon corresponding to name in the current icon theme.
Definition: qicon.cpp:1039
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char *const tb_extension_arrow_v_xpm[]
static bool isEmpty(const char *str)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static QString themeName()
Returns the name of the current icon theme.
Definition: qicon.cpp:1001
static const char *const filedialog_start_xpm[]
static const char *const filedialog_end_xpm[]
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
#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
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=0, const QWidget *widget=0) const =0
static const char *const tb_extension_arrow_h_xpm[]

◆ styleHint()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QMacStyle, QMotifStyle, QWindowsCEStyle, QWindowsMobileStyle, QGtkStyle, QWindowsStyle, QWindowsXPStyle, QProxyStyle, QWindowsVistaStyle, and QPlastiqueStyle.

Definition at line 4885 of file qcommonstyle.cpp.

Referenced by drawComplexControl(), drawControl(), QPlastiqueStyle::styleHint(), QWindowsStyle::styleHint(), and QMotifStyle::styleHint().

4887 {
4888  int ret = 0;
4889 
4890  switch (sh) {
4892  ret = false;
4893  break;
4895  ret = Qt::MidButton;
4896  break;
4898  ret = Qt::LeftButton;
4899  break;
4901  ret = true;
4902  break;
4903  case SH_DialogButtons_DefaultButton: // This value not used anywhere.
4905  break;
4906 #ifndef QT_NO_GROUPBOX
4908  ret = Qt::AlignVCenter;
4909  break;
4910 
4912  ret = opt ? int(opt->palette.color(QPalette::Text).rgba()) : 0;
4913  break;
4914 #endif // QT_NO_GROUPBOX
4915 
4919  break;
4920 
4921 #ifdef QT3_SUPPORT
4922  case SH_GUIStyle:
4923  ret = Qt::WindowsStyle;
4924  break;
4925 #endif
4926 
4927  case SH_TabBar_Alignment:
4929  ret = Qt::AlignLeft;
4930  break;
4931 
4932  case SH_TitleBar_AutoRaise:
4933  ret = false;
4934  break;
4935 
4937  ret = 256;
4938  break;
4939 
4941  ret = true;
4942  break;
4943 
4945  ret = Qt::AlignCenter;
4946  break;
4947 
4949  ret = 1;
4950  break;
4951 
4953  if (opt)
4954  ret = opt->palette.color(QPalette::Mid).rgb();
4955  else
4956  ret = -1;
4957  break;
4959  const QFontMetrics &fm = opt ? opt->fontMetrics
4960  : (widget ? widget->fontMetrics() : QFontMetrics(QFont()));
4961  ret = 0;
4962  if (fm.inFont(QChar(0x25CF))) {
4963  ret = 0x25CF;
4964  } else if (fm.inFont(QChar(0x2022))) {
4965  ret = 0x2022;
4966  } else {
4967  ret = '*';
4968  }
4969  break;
4970  }
4971 
4972 
4974  ret = 1;
4975  break;
4976 
4977  case SH_UnderlineShortcut:
4978  ret = 1;
4979  break;
4980 
4982  ret = 150;
4983  break;
4984 
4986  ret = 500;
4987  break;
4988 
4990  ret = 75;
4991  break;
4992 
4993  case SH_Menu_SelectionWrap:
4994  ret = true;
4995  break;
4996 
4998  ret = true;
4999  break;
5000 
5002  ret = 255;
5003  break;
5004 
5005  case SH_Button_FocusPolicy:
5006  ret = Qt::StrongFocus;
5007  break;
5008 
5010  ret = 1;
5011  break;
5012 
5014  ret = 0;
5015  break;
5016 
5018  ret = 600;
5019  break;
5020 
5021  case SH_FocusFrame_Mask:
5022  ret = 1;
5023  if (widget) {
5024  if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5025  mask->region = widget->rect();
5028  mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
5029  }
5030  }
5031  break;
5032 #ifndef QT_NO_RUBBERBAND
5033  case SH_RubberBand_Mask:
5034  if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
5035  ret = 0;
5036  if (rbOpt->shape == QRubberBand::Rectangle) {
5037  ret = true;
5038  if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5039  mask->region = opt->rect;
5040  int margin = proxy()->pixelMetric(PM_DefaultFrameWidth) * 2;
5041  mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
5042  }
5043  }
5044  }
5045  break;
5046 #endif // QT_NO_RUBBERBAND
5048  ret = 1;
5049  break;
5050 
5052  ret = QPalette::Window;
5053  break;
5054 
5056  ret = opt ? opt->direction : Qt::LeftToRight;
5057  break;
5058 
5060  ret = Qt::AlignTrailing;
5061  break;
5062 
5064  ret = false;
5065  break;
5066 
5069  break;
5070 
5072  ret = true;
5073  break;
5075  ret = false;
5076  break;
5077  case SH_TabBar_ElideMode:
5078  ret = Qt::ElideNone;
5079  break;
5080  case SH_DialogButtonLayout:
5082 #ifdef Q_WS_X11
5083  if (X11->desktopEnvironment == DE_KDE)
5085  else if (X11->desktopEnvironment == DE_GNOME)
5087 #endif
5088  break;
5091  break;
5094  break;
5096 #ifdef Q_WS_X11
5097  return true;
5098 #endif
5099  ret = 0;
5100  break;
5103  break;
5105  ret = true;
5106  break;
5108  ret = true;
5109  break;
5111  ret = false;
5112  break;
5113 #ifndef QT_NO_TABWIDGET
5115  ret = QTabWidget::North;
5116  break;
5117 #endif
5118  case SH_ToolBar_Movable:
5119  ret = true;
5120  break;
5122  ret = true;
5123  if (QStyleHintReturnVariant *vret = qstyleoption_cast<QStyleHintReturnVariant*>(hret)) {
5124  QPen outline(opt->palette.color(QPalette::Text), 1, Qt::DotLine);
5125  QTextCharFormat fmt;
5126  fmt.setProperty(QTextFormat::OutlinePen, outline);
5127  vret->variant = fmt;
5128  }
5129  break;
5130 #ifndef QT_NO_WIZARD
5131  case SH_WizardStyle:
5132  ret = QWizard::ClassicStyle;
5133  break;
5134 #endif
5137  break;
5140  break;
5142  ret = Qt::AlignLeft | Qt::AlignTop;
5143  break;
5145  ret = Qt::AlignLeft;
5146  break;
5148  ret = false;
5149  break;
5151  ret = 0;
5152  break;
5153 #ifndef QT_NO_TABBAR
5155  ret = QTabBar::RightSide;
5156  break;
5157 #endif
5159  ret = true;
5160  break;
5161  case SH_ToolButtonStyle:
5163  break;
5166  break;
5167  default:
5168  ret = 0;
5169  break;
5170  }
5171 
5172  return ret;
5173 }
The QStyleHintReturnVariant class provides style hints that return a QVariant.
Definition: qstyleoption.h:933
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QGuiPlatformPlugin * qt_guiPlatformPlugin()
Return (an construct if necesseray) the Gui Platform plugin.
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
#define X11
Definition: qt_x11_p.h:724
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
virtual int platformHint(PlatformHint hint)
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
bool inFont(QChar) const
Returns true if character ch is a valid character in the font; otherwise returns false.
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051

◆ subControlRect()

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

Reimplemented Function

Implements QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QMacStyle, QMotifStyle, QWindowsCEStyle, QProxyStyle, QWindowsMobileStyle, QWindowsXPStyle, QPlastiqueStyle, and QWindowsVistaStyle.

Definition at line 3941 of file qcommonstyle.cpp.

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

3943 {
3944  QRect ret;
3945  switch (cc) {
3946 #ifndef QT_NO_SLIDER
3947  case CC_Slider:
3948  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3949  int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
3950  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
3951 
3952  switch (sc) {
3953  case SC_SliderHandle: {
3954  int sliderPos = 0;
3955  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3956  bool horizontal = slider->orientation == Qt::Horizontal;
3957  sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
3958  slider->sliderPosition,
3959  (horizontal ? slider->rect.width()
3960  : slider->rect.height()) - len,
3961  slider->upsideDown);
3962  if (horizontal)
3963  ret.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
3964  else
3965  ret.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
3966  break; }
3967  case SC_SliderGroove:
3968  if (slider->orientation == Qt::Horizontal)
3969  ret.setRect(slider->rect.x(), slider->rect.y() + tickOffset,
3970  slider->rect.width(), thickness);
3971  else
3972  ret.setRect(slider->rect.x() + tickOffset, slider->rect.y(),
3973  thickness, slider->rect.height());
3974  break;
3975  default:
3976  break;
3977  }
3978  ret = visualRect(slider->direction, slider->rect, ret);
3979  }
3980  break;
3981 #endif // QT_NO_SLIDER
3982 #ifndef QT_NO_SCROLLBAR
3983  case CC_ScrollBar:
3984  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3985  const QRect scrollBarRect = scrollbar->rect;
3986  int sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget);
3987  int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
3988  scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2);
3989  int sliderlen;
3990 
3991  // calculate slider length
3992  if (scrollbar->maximum != scrollbar->minimum) {
3993  uint range = scrollbar->maximum - scrollbar->minimum;
3994  sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep);
3995 
3996  int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);
3997  if (sliderlen < slidermin || range > INT_MAX / 2)
3998  sliderlen = slidermin;
3999  if (sliderlen > maxlen)
4000  sliderlen = maxlen;
4001  } else {
4002  sliderlen = maxlen;
4003  }
4004 
4005  int sliderstart = sbextent + sliderPositionFromValue(scrollbar->minimum,
4006  scrollbar->maximum,
4007  scrollbar->sliderPosition,
4008  maxlen - sliderlen,
4009  scrollbar->upsideDown);
4010 
4011  switch (sc) {
4012  case SC_ScrollBarSubLine: // top/left button
4013  if (scrollbar->orientation == Qt::Horizontal) {
4014  int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent);
4015  ret.setRect(0, 0, buttonWidth, scrollBarRect.height());
4016  } else {
4017  int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent);
4018  ret.setRect(0, 0, scrollBarRect.width(), buttonHeight);
4019  }
4020  break;
4021  case SC_ScrollBarAddLine: // bottom/right button
4022  if (scrollbar->orientation == Qt::Horizontal) {
4023  int buttonWidth = qMin(scrollBarRect.width()/2, sbextent);
4024  ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height());
4025  } else {
4026  int buttonHeight = qMin(scrollBarRect.height()/2, sbextent);
4027  ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight);
4028  }
4029  break;
4030  case SC_ScrollBarSubPage: // between top/left button and slider
4031  if (scrollbar->orientation == Qt::Horizontal)
4032  ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height());
4033  else
4034  ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent);
4035  break;
4036  case SC_ScrollBarAddPage: // between bottom/right button and slider
4037  if (scrollbar->orientation == Qt::Horizontal)
4038  ret.setRect(sliderstart + sliderlen, 0,
4039  maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height());
4040  else
4041  ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(),
4042  maxlen - sliderstart - sliderlen + sbextent);
4043  break;
4044  case SC_ScrollBarGroove:
4045  if (scrollbar->orientation == Qt::Horizontal)
4046  ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2,
4047  scrollBarRect.height());
4048  else
4049  ret.setRect(0, sbextent, scrollBarRect.width(),
4050  scrollBarRect.height() - sbextent * 2);
4051  break;
4052  case SC_ScrollBarSlider:
4053  if (scrollbar->orientation == Qt::Horizontal)
4054  ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
4055  else
4056  ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
4057  break;
4058  default:
4059  break;
4060  }
4061  ret = visualRect(scrollbar->direction, scrollBarRect, ret);
4062  }
4063  break;
4064 #endif // QT_NO_SCROLLBAR
4065 #ifndef QT_NO_SPINBOX
4066  case CC_SpinBox:
4067  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
4068  QSize bs;
4069  int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
4070  bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw));
4071  // 1.6 -approximate golden mean
4072  bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4)));
4074  int y = fw + spinbox->rect.y();
4075  int x, lx, rx;
4076  x = spinbox->rect.x() + spinbox->rect.width() - fw - bs.width();
4077  lx = fw;
4078  rx = x - fw;
4079  switch (sc) {
4080  case SC_SpinBoxUp:
4081  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4082  return QRect();
4083  ret = QRect(x, y, bs.width(), bs.height());
4084  break;
4085  case SC_SpinBoxDown:
4086  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4087  return QRect();
4088 
4089  ret = QRect(x, y + bs.height(), bs.width(), bs.height());
4090  break;
4091  case SC_SpinBoxEditField:
4092  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4093  ret = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
4094  } else {
4095  ret = QRect(lx, fw, rx, spinbox->rect.height() - 2*fw);
4096  }
4097  break;
4098  case SC_SpinBoxFrame:
4099  ret = spinbox->rect;
4100  default:
4101  break;
4102  }
4103  ret = visualRect(spinbox->direction, spinbox->rect, ret);
4104  }
4105  break;
4106 #endif // Qt_NO_SPINBOX
4107 #ifndef QT_NO_TOOLBUTTON
4108  case CC_ToolButton:
4109  if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
4110  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget);
4111  ret = tb->rect;
4112  switch (sc) {
4113  case SC_ToolButton:
4114  if ((tb->features
4117  ret.adjust(0, 0, -mbi, 0);
4118  break;
4119  case SC_ToolButtonMenu:
4120  if ((tb->features
4123  ret.adjust(ret.width() - mbi, 0, 0, 0);
4124  break;
4125  default:
4126  break;
4127  }
4128  ret = visualRect(tb->direction, tb->rect, ret);
4129  }
4130  break;
4131 #endif // QT_NO_TOOLBUTTON
4132 #ifndef QT_NO_COMBOBOX
4133  case CC_ComboBox:
4134  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4135  int x = cb->rect.x(),
4136  y = cb->rect.y(),
4137  wi = cb->rect.width(),
4138  he = cb->rect.height();
4139  int xpos = x;
4140  int margin = cb->frame ? 3 : 0;
4141  int bmarg = cb->frame ? 2 : 0;
4142  xpos += wi - bmarg - 16;
4143 
4144 
4145  switch (sc) {
4146  case SC_ComboBoxFrame:
4147  ret = cb->rect;
4148  break;
4149  case SC_ComboBoxArrow:
4150  ret.setRect(xpos, y + bmarg, 16, he - 2*bmarg);
4151  break;
4152  case SC_ComboBoxEditField:
4153  ret.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
4154  break;
4156  ret = cb->rect;
4157  break;
4158  default:
4159  break;
4160  }
4161  ret = visualRect(cb->direction, cb->rect, ret);
4162  }
4163  break;
4164 #endif // QT_NO_COMBOBOX
4165  case CC_TitleBar:
4166  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4167  const int controlMargin = 2;
4168  const int controlHeight = tb->rect.height() - controlMargin *2;
4169  const int delta = controlHeight + controlMargin;
4170  int offset = 0;
4171 
4172  bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
4173  bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
4174 
4175  switch (sc) {
4176  case SC_TitleBarLabel:
4177  if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
4178  ret = tb->rect;
4179  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4180  ret.adjust(delta, 0, -delta, 0);
4181  if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
4182  ret.adjust(0, 0, -delta, 0);
4183  if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
4184  ret.adjust(0, 0, -delta, 0);
4185  if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
4186  ret.adjust(0, 0, -delta, 0);
4187  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4188  ret.adjust(0, 0, -delta, 0);
4189  }
4190  break;
4192  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4193  offset += delta;
4194  case SC_TitleBarMinButton:
4195  if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4196  offset += delta;
4197  else if (sc == SC_TitleBarMinButton)
4198  break;
4200  if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4201  offset += delta;
4202  else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4203  offset += delta;
4204  else if (sc == SC_TitleBarNormalButton)
4205  break;
4206  case SC_TitleBarMaxButton:
4207  if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4208  offset += delta;
4209  else if (sc == SC_TitleBarMaxButton)
4210  break;
4212  if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4213  offset += delta;
4214  else if (sc == SC_TitleBarShadeButton)
4215  break;
4217  if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4218  offset += delta;
4219  else if (sc == SC_TitleBarUnshadeButton)
4220  break;
4222  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4223  offset += delta;
4224  else if (sc == SC_TitleBarCloseButton)
4225  break;
4226  ret.setRect(tb->rect.right() - offset, tb->rect.top() + controlMargin,
4227  controlHeight, controlHeight);
4228  break;
4229  case SC_TitleBarSysMenu:
4230  if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
4231  ret.setRect(tb->rect.left() + controlMargin, tb->rect.top() + controlMargin,
4232  controlHeight, controlHeight);
4233  }
4234  break;
4235  default:
4236  break;
4237  }
4238  ret = visualRect(tb->direction, tb->rect, ret);
4239  }
4240  break;
4241 #ifndef QT_NO_GROUPBOX
4242  case CC_GroupBox: {
4243  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4244  switch (sc) {
4245  case SC_GroupBoxFrame:
4246  // FALL THROUGH
4247  case SC_GroupBoxContents: {
4248  int topMargin = 0;
4249  int topHeight = 0;
4250  int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
4251  if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) {
4252  topHeight = groupBox->fontMetrics.height();
4253  if (verticalAlignment & Qt::AlignVCenter)
4254  topMargin = topHeight / 2;
4255  else if (verticalAlignment & Qt::AlignTop)
4256  topMargin = topHeight;
4257  }
4258 
4259  QRect frameRect = groupBox->rect;
4260  frameRect.setTop(topMargin);
4261 
4262  if (sc == SC_GroupBoxFrame) {
4263  ret = frameRect;
4264  break;
4265  }
4266 
4267  int frameWidth = 0;
4268  if (!(widget && widget->inherits("Q3GroupBox"))
4269  && ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)) {
4270  frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
4271  }
4272  ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin,
4273  -frameWidth, -frameWidth);
4274  break;
4275  }
4276  case SC_GroupBoxCheckBox:
4277  // FALL THROUGH
4278  case SC_GroupBoxLabel: {
4279  QFontMetrics fontMetrics = groupBox->fontMetrics;
4280  int h = fontMetrics.height();
4281  int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
4282  int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8;
4283  ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
4284  ret.setHeight(h);
4285 
4286  int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget);
4287  int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;
4288  bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4289  int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
4290 
4291  // Adjusted rect for label + indicatorWidth + indicatorSpace
4292  QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
4293  QSize(tw + checkBoxSize, h), ret);
4294 
4295  // Adjust totalRect if checkbox is set
4296  if (hasCheckBox) {
4297  bool ltr = groupBox->direction == Qt::LeftToRight;
4298  int left = 0;
4299  // Adjust for check box
4300  if (sc == SC_GroupBoxCheckBox) {
4301  int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
4302  left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
4303  int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
4304  totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
4305  // Adjust for label
4306  } else {
4307  left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
4308  totalRect.setRect(left, totalRect.top(),
4309  totalRect.width() - checkBoxSize, totalRect.height());
4310  }
4311  }
4312  ret = totalRect;
4313  break;
4314  }
4315  default:
4316  break;
4317  }
4318  }
4319  break;
4320  }
4321 #endif // QT_NO_GROUPBOX
4322 #ifndef QT_NO_WORKSPACE
4323  case CC_MdiControls:
4324  {
4325  int numSubControls = 0;
4326  if (opt->subControls & SC_MdiCloseButton)
4327  ++numSubControls;
4328  if (opt->subControls & SC_MdiMinButton)
4329  ++numSubControls;
4330  if (opt->subControls & SC_MdiNormalButton)
4331  ++numSubControls;
4332  if (numSubControls == 0)
4333  break;
4334 
4335  int buttonWidth = opt->rect.width()/ numSubControls - 1;
4336  int offset = 0;
4337  switch (sc) {
4338  case SC_MdiCloseButton:
4339  // Only one sub control, no offset needed.
4340  if (numSubControls == 1)
4341  break;
4342  offset += buttonWidth + 2;
4343  //FALL THROUGH
4344  case SC_MdiNormalButton:
4345  // No offset needed if
4346  // 1) There's only one sub control
4347  // 2) We have a close button and a normal button (offset already added in SC_MdiClose)
4348  if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton)))
4349  break;
4350  if (opt->subControls & SC_MdiNormalButton)
4351  offset += buttonWidth;
4352  break;
4353  default:
4354  break;
4355  }
4356 
4357  // Subtract one pixel if we only have one sub control. At this point
4358  // buttonWidth is the actual width + 1 pixel margin, but we don't want the
4359  // margin when there are no other controllers.
4360  if (numSubControls == 1)
4361  --buttonWidth;
4362  ret = QRect(offset, 0, buttonWidth, opt->rect.height());
4363  break;
4364  }
4365 #endif // QT_NO_WORKSPACE
4366  default:
4367  qWarning("QCommonStyle::subControlRect: Case %d not handled", cc);
4368  }
4369  return ret;
4370 }
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
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
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...
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
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
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
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
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
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
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
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
__int64 qint64
Definition: qglobal.h:942
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The 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
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
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int height() const
Returns the height of the font.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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
#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

◆ subElementRect()

QRect QCommonStyle::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

Implements QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QMotifStyle, QMacStyle, QWindowsCEStyle, QProxyStyle, QWindowsStyle, QWindowsMobileStyle, QWindowsXPStyle, QPlastiqueStyle, and QWindowsVistaStyle.

Definition at line 2319 of file qcommonstyle.cpp.

Referenced by drawControl(), drawPrimitive(), QWindowsVistaStyle::subElementRect(), QWindowsXPStyle::subElementRect(), QWindowsStyle::subElementRect(), QMacStyle::subElementRect(), and QMotifStyle::subElementRect().

2321 {
2322  Q_D(const QCommonStyle);
2323  QRect r;
2324  switch (sr) {
2325  case SE_PushButtonContents:
2326  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2327  int dx1, dx2;
2328  dx1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
2329  if (btn->features & QStyleOptionButton::AutoDefaultButton)
2330  dx1 += proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
2331  dx2 = dx1 * 2;
2332  r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2,
2333  opt->rect.height() - dx2);
2334  r = visualRect(opt->direction, opt->rect, r);
2335  }
2336  break;
2338  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2339  int dbw1 = 0, dbw2 = 0;
2340  if (btn->features & QStyleOptionButton::AutoDefaultButton){
2341  dbw1 = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
2342  dbw2 = dbw1 * 2;
2343  }
2344 
2345  int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1,
2346  dfw2 = dfw1 * 2;
2347 
2348  r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1,
2349  btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2);
2350  r = visualRect(opt->direction, opt->rect, r);
2351  }
2352  break;
2353  case SE_CheckBoxIndicator:
2354  {
2355  int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
2356  r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2357  proxy()->pixelMetric(PM_IndicatorWidth, opt, widget), h);
2358  r = visualRect(opt->direction, opt->rect, r);
2359  }
2360  break;
2361 
2362  case SE_CheckBoxContents:
2363  {
2364  // Deal with the logical first, then convert it back to screen coords.
2365  QRect ir = visualRect(opt->direction, opt->rect,
2366  subElementRect(SE_CheckBoxIndicator, opt, widget));
2367  int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget);
2368  r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2369  opt->rect.height());
2370  r = visualRect(opt->direction, opt->rect, r);
2371  }
2372  break;
2373 
2374  case SE_CheckBoxFocusRect:
2375  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2376  if (btn->icon.isNull() && btn->text.isEmpty()) {
2377  r = subElementRect(SE_CheckBoxIndicator, opt, widget);
2378  r.adjust(1, 1, -1, -1);
2379  break;
2380  }
2381  // As above, deal with the logical first, then convert it back to screen coords.
2382  QRect cr = visualRect(btn->direction, btn->rect,
2383  subElementRect(SE_CheckBoxContents, btn, widget));
2384 
2385  QRect iconRect, textRect;
2386  if (!btn->text.isEmpty()) {
2389  btn->state & State_Enabled, btn->text);
2390  }
2391  if (!btn->icon.isNull()) {
2394  btn->icon.pixmap(btn->iconSize, QIcon::Normal));
2395  if (!textRect.isEmpty())
2396  textRect.translate(iconRect.right() + 4, 0);
2397  }
2398  r = iconRect | textRect;
2399  r.adjust(-3, -2, 3, 2);
2400  r = r.intersected(btn->rect);
2401  r = visualRect(btn->direction, btn->rect, r);
2402  }
2403  break;
2404 
2406  {
2407  int h = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget);
2408  r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2409  proxy()->pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h);
2410  r = visualRect(opt->direction, opt->rect, r);
2411  }
2412  break;
2413 
2415  {
2416  QRect ir = visualRect(opt->direction, opt->rect,
2417  subElementRect(SE_RadioButtonIndicator, opt, widget));
2418  int spacing = proxy()->pixelMetric(PM_RadioButtonLabelSpacing, opt, widget);
2419  r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2420  opt->rect.height());
2421  r = visualRect(opt->direction, opt->rect, r);
2422  break;
2423  }
2424 
2426  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2427  if (btn->icon.isNull() && btn->text.isEmpty()) {
2428  r = subElementRect(SE_RadioButtonIndicator, opt, widget);
2429  r.adjust(1, 1, -1, -1);
2430  break;
2431  }
2432  QRect cr = visualRect(btn->direction, btn->rect,
2433  subElementRect(SE_RadioButtonContents, opt, widget));
2434 
2435  QRect iconRect, textRect;
2436  if (!btn->text.isEmpty()){
2438  | Qt::TextShowMnemonic, btn->state & State_Enabled, btn->text);
2439  }
2440  if (!btn->icon.isNull()) {
2442  btn->icon.pixmap(btn->iconSize, QIcon::Normal));
2443  if (!textRect.isEmpty())
2444  textRect.translate(iconRect.right() + 4, 0);
2445  }
2446  r = iconRect | textRect;
2447  r.adjust(-3, -2, 3, 2);
2448  r = r.intersected(btn->rect);
2449  r = visualRect(btn->direction, btn->rect, r);
2450  }
2451  break;
2452 #ifndef QT_NO_SLIDER
2453  case SE_SliderFocusRect:
2454  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2455  int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
2456  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2457  if (slider->orientation == Qt::Horizontal)
2458  r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2);
2459  else
2460  r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height());
2461  r = r.intersected(slider->rect);
2462  r = visualRect(opt->direction, opt->rect, r);
2463  }
2464  break;
2465 #endif // QT_NO_SLIDER
2466 #ifndef QT_NO_PROGRESSBAR
2467  case SE_ProgressBarGroove:
2469  case SE_ProgressBarLabel:
2470  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2471  int textw = 0;
2472  bool vertical = false;
2473  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
2474  vertical = (pb2->orientation == Qt::Vertical);
2475  }
2476  if (!vertical) {
2477  if (pb->textVisible)
2478  textw = qMax(pb->fontMetrics.width(pb->text), pb->fontMetrics.width(QLatin1String("100%"))) + 6;
2479  }
2480 
2481  if ((pb->textAlignment & Qt::AlignCenter) == 0) {
2482  if (sr != SE_ProgressBarLabel)
2483  r.setCoords(pb->rect.left(), pb->rect.top(),
2484  pb->rect.right() - textw, pb->rect.bottom());
2485  else
2486  r.setCoords(pb->rect.right() - textw, pb->rect.top(),
2487  pb->rect.right(), pb->rect.bottom());
2488  } else {
2489  r = pb->rect;
2490  }
2491  r = visualRect(pb->direction, pb->rect, r);
2492  }
2493  break;
2494 #endif // QT_NO_PROGRESSBAR
2495 #ifdef QT3_SUPPORT
2497  if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
2498  if (!dw->docked || !dw->closeEnabled)
2499  r.setRect(0, 0, dw->rect.width(), dw->rect.height());
2500  else {
2501  if (dw->state & State_Horizontal)
2502  r.setRect(0, 15, dw->rect.width(), dw->rect.height() - 15);
2503  else
2504  r.setRect(0, 1, dw->rect.width() - 15, dw->rect.height() - 1);
2505  }
2506  r = visualRect(opt->direction, opt->rect, r);
2507  }
2508  break;
2509 #endif // QT3_SUPPORT
2510 #ifndef QT_NO_COMBOBOX
2511  case SE_ComboBoxFocusRect:
2512  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2513  int margin = cb->frame ? 3 : 0;
2514  r.setRect(opt->rect.left() + margin, opt->rect.top() + margin,
2515  opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin);
2516  r = visualRect(opt->direction, opt->rect, r);
2517  }
2518  break;
2519 #endif // QT_NO_COMBOBOX
2520 #ifndef QT_NO_TOOLBOX
2521  case SE_ToolBoxTabContents:
2522  r = opt->rect;
2523  r.adjust(0, 0, -30, 0);
2524  break;
2525 #endif // QT_NO_TOOLBOX
2526  case SE_HeaderLabel: {
2527  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
2528  r.setRect(opt->rect.x() + margin, opt->rect.y() + margin,
2529  opt->rect.width() - margin * 2, opt->rect.height() - margin * 2);
2530 
2531  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2532  // Subtract width needed for arrow, if there is one
2533  if (header->sortIndicator != QStyleOptionHeader::None) {
2534  if (opt->state & State_Horizontal)
2535  r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
2536  else
2537  r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2));
2538  }
2539  }
2540  r = visualRect(opt->direction, opt->rect, r);
2541  break; }
2542  case SE_HeaderArrow: {
2543  int h = opt->rect.height();
2544  int w = opt->rect.width();
2545  int x = opt->rect.x();
2546  int y = opt->rect.y();
2547  int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
2548 
2549  if (opt->state & State_Horizontal) {
2550  int horiz_size = h / 2;
2551  r.setRect(x + w - margin * 2 - horiz_size, y + 5,
2552  horiz_size, h - margin * 2 - 5);
2553  } else {
2554  int vert_size = w / 2;
2555  r.setRect(x + 5, y + h - margin * 2 - vert_size,
2556  w - margin * 2 - 5, vert_size);
2557  }
2558  r = visualRect(opt->direction, opt->rect, r);
2559  break; }
2560 
2562  r = subElementRect(SE_RadioButtonFocusRect, opt, widget);
2563  r |= subElementRect(SE_RadioButtonIndicator, opt, widget);
2564  break;
2565  case SE_CheckBoxClickRect:
2566  r = subElementRect(SE_CheckBoxFocusRect, opt, widget);
2567  r |= subElementRect(SE_CheckBoxIndicator, opt, widget);
2568  break;
2569 #ifndef QT_NO_TABWIDGET
2570  case SE_TabWidgetTabBar:
2571  if (const QStyleOptionTabWidgetFrame *twf
2572  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2573  r.setSize(twf->tabBarSize);
2574  const uint alingMask = Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter;
2575  switch (twf->shape) {
2576  case QTabBar::RoundedNorth:
2578  // Constrain the size now, otherwise, center could get off the page
2579  // This of course repeated for all the other directions
2580  r.setWidth(qMin(r.width(), twf->rect.width()
2581  - twf->leftCornerWidgetSize.width()
2582  - twf->rightCornerWidgetSize.width()));
2583  switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2584  default:
2585  case Qt::AlignLeft:
2586  r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0));
2587  break;
2588  case Qt::AlignHCenter:
2589  r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2590  + (twf->leftCornerWidgetSize.width() / 2)
2591  - (twf->rightCornerWidgetSize.width() / 2), 0));
2592  break;
2593  case Qt::AlignRight:
2594  r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2595  - twf->rightCornerWidgetSize.width(), 0));
2596  break;
2597  }
2598  r = visualRect(twf->direction, twf->rect, r);
2599  break;
2600  case QTabBar::RoundedSouth:
2602  r.setWidth(qMin(r.width(), twf->rect.width()
2603  - twf->leftCornerWidgetSize.width()
2604  - twf->rightCornerWidgetSize.width()));
2605  switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2606  default:
2607  case Qt::AlignLeft:
2608  r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(),
2609  twf->rect.height() - twf->tabBarSize.height()));
2610  break;
2611  case Qt::AlignHCenter:
2612  r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2613  + (twf->leftCornerWidgetSize.width() / 2)
2614  - (twf->rightCornerWidgetSize.width() / 2),
2615  twf->rect.height() - twf->tabBarSize.height()));
2616  break;
2617  case Qt::AlignRight:
2618  r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2619  - twf->rightCornerWidgetSize.width(),
2620  twf->rect.height() - twf->tabBarSize.height()));
2621  break;
2622  }
2623  r = visualRect(twf->direction, twf->rect, r);
2624  break;
2625  case QTabBar::RoundedEast:
2627  r.setHeight(qMin(r.height(), twf->rect.height()
2628  - twf->leftCornerWidgetSize.height()
2629  - twf->rightCornerWidgetSize.height()));
2630  switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2631  default:
2632  case Qt::AlignLeft:
2633  r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2634  twf->leftCornerWidgetSize.height()));
2635  break;
2636  case Qt::AlignHCenter:
2637  r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2638  twf->rect.center().y() - r.height() / 2));
2639  break;
2640  case Qt::AlignRight:
2641  r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2642  twf->rect.height() - twf->tabBarSize.height()
2643  - twf->rightCornerWidgetSize.height()));
2644  break;
2645  }
2646  break;
2647  case QTabBar::RoundedWest:
2649  r.setHeight(qMin(r.height(), twf->rect.height()
2650  - twf->leftCornerWidgetSize.height()
2651  - twf->rightCornerWidgetSize.height()));
2652  switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2653  default:
2654  case Qt::AlignLeft:
2655  r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height()));
2656  break;
2657  case Qt::AlignHCenter:
2658  r.moveTopLeft(QPoint(0, twf->rect.center().y() - r.height() / 2));
2659  break;
2660  case Qt::AlignRight:
2661  r.moveTopLeft(QPoint(0, twf->rect.height() - twf->tabBarSize.height()
2662  - twf->rightCornerWidgetSize.height()));
2663  break;
2664  }
2665  break;
2666  }
2667  }
2668  break;
2669  case SE_TabWidgetTabPane:
2671  if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2672  QStyleOptionTab tabopt;
2673  tabopt.shape = twf->shape;
2674  int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget);
2675  if (twf->lineWidth == 0)
2676  overlap = 0;
2677  switch (twf->shape) {
2678  case QTabBar::RoundedNorth:
2680  r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)),
2681  QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2682  break;
2683  case QTabBar::RoundedSouth:
2685  r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2686  break;
2687  case QTabBar::RoundedEast:
2689  r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2690  break;
2691  case QTabBar::RoundedWest:
2693  r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0),
2694  QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2695  break;
2696  }
2697  if (sr == SE_TabWidgetTabContents && twf->lineWidth > 0)
2698  r.adjust(2, 2, -2, -2);
2699  }
2700  break;
2702  if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2703  QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget);
2704  switch (twf->shape) {
2705  case QTabBar::RoundedNorth:
2707  r = QRect(QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()),
2708  twf->leftCornerWidgetSize);
2709  break;
2710  case QTabBar::RoundedSouth:
2712  r = QRect(QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize);
2713  break;
2714  default:
2715  break;
2716  }
2717  r = visualRect(twf->direction, twf->rect, r);
2718  }
2719  break;
2721  if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2722  QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget);
2723  switch (twf->shape) {
2724  case QTabBar::RoundedNorth:
2726  r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2727  paneRect.y() - twf->rightCornerWidgetSize.height()),
2728  twf->rightCornerWidgetSize);
2729  break;
2730  case QTabBar::RoundedSouth:
2732  r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2733  paneRect.height()), twf->rightCornerWidgetSize);
2734  break;
2735  default:
2736  break;
2737  }
2738  r = visualRect(twf->direction, twf->rect, r);
2739  }
2740  break;
2741  case SE_TabBarTabText:
2742  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2743  QStyleOptionTabV3 tabV3(*tab);
2744  QRect dummyIconRect;
2745  d->tabLayout(&tabV3, widget, &r, &dummyIconRect);
2746  }
2747  break;
2750  if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
2751  bool selected = tab->state & State_Selected;
2752  int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
2753  int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
2754  int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
2755  hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt
2756 
2757  bool verticalTabs = tab->shape == QTabBar::RoundedEast
2758  || tab->shape == QTabBar::RoundedWest
2759  || tab->shape == QTabBar::TriangularEast
2760  || tab->shape == QTabBar::TriangularWest;
2761 
2762  QRect tr = tab->rect;
2763  if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth)
2764  verticalShift = -verticalShift;
2765  if (verticalTabs) {
2766  qSwap(horizontalShift, verticalShift);
2767  horizontalShift *= -1;
2768  verticalShift *= -1;
2769  }
2770  if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest)
2771  horizontalShift = -horizontalShift;
2772 
2773  tr.adjust(0, 0, horizontalShift, verticalShift);
2774  if (selected)
2775  {
2776  tr.setBottom(tr.bottom() - verticalShift);
2777  tr.setRight(tr.right() - horizontalShift);
2778  }
2779 
2780  QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize;
2781  int w = size.width();
2782  int h = size.height();
2783  int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2));
2784  int midWidth = ((tr.width() - w) / 2);
2785 
2786  bool atTheTop = true;
2787  switch (tab->shape) {
2788  case QTabBar::RoundedWest:
2790  atTheTop = (sr == SE_TabBarTabLeftButton);
2791  break;
2792  case QTabBar::RoundedEast:
2794  atTheTop = (sr == SE_TabBarTabRightButton);
2795  break;
2796  default:
2797  if (sr == SE_TabBarTabLeftButton)
2798  r = QRect(tab->rect.x() + hpadding, midHeight, w, h);
2799  else
2800  r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h);
2801  r = visualRect(tab->direction, tab->rect, r);
2802  }
2803  if (verticalTabs) {
2804  if (atTheTop)
2805  r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h);
2806  else
2807  r = QRect(midWidth, tr.y() + hpadding, w, h);
2808  }
2809  }
2810 
2811  break;
2812 #endif // QT_NO_TABWIDGET
2813 #ifndef QT_NO_TABBAR
2815  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2816  switch (tab->shape) {
2817  case QTabBar::RoundedNorth:
2819  case QTabBar::RoundedSouth:
2821  r.setRect(tab->rect.left(), tab->rect.top(), 4, opt->rect.height());
2822  break;
2823  case QTabBar::RoundedWest:
2825  case QTabBar::RoundedEast:
2827  r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 4);
2828  break;
2829  default:
2830  break;
2831  }
2832  r = visualRect(opt->direction, opt->rect, r);
2833  }
2834  break;
2835 #endif
2837  r = opt->rect;
2838  break;
2839  case SE_LineEditContents:
2840  if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2841  r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth);
2842  r = visualRect(opt->direction, opt->rect, r);
2843  }
2844  break;
2845  case SE_FrameContents:
2846  if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
2847  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, f, widget);
2848  r = opt->rect.adjusted(fw, fw, -fw, -fw);
2849  r = visualRect(opt->direction, opt->rect, r);
2850  }
2851  break;
2853  if (const QStyleOptionFrameV3 *f = qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) {
2854  int frameShape = f->frameShape;
2855  int frameShadow = QFrame::Plain;
2856  if (f->state & QStyle::State_Sunken) {
2857  frameShadow = QFrame::Sunken;
2858  } else if (f->state & QStyle::State_Raised) {
2859  frameShadow = QFrame::Raised;
2860  }
2861 
2862  int frameWidth = 0;
2863 
2864  switch (frameShape) {
2865  case QFrame::NoFrame:
2866  frameWidth = 0;
2867  break;
2868 
2869  case QFrame::Box:
2870  case QFrame::HLine:
2871  case QFrame::VLine:
2872  switch (frameShadow) {
2873  case QFrame::Plain:
2874  frameWidth = f->lineWidth;
2875  break;
2876  case QFrame::Raised:
2877  case QFrame::Sunken:
2878  frameWidth = (short)(f->lineWidth*2 + f->midLineWidth);
2879  break;
2880  }
2881  break;
2882 
2883  case QFrame::StyledPanel:
2884  //keep the compatibility with Qt 4.4 if there is a proxy style.
2885  //be sure to call drawPrimitive(QStyle::SE_FrameContents) on the proxy style
2886  if (widget)
2887  return widget->style()->subElementRect(QStyle::SE_FrameContents, opt, widget);
2888  else
2889  return subElementRect(QStyle::SE_FrameContents, opt, widget);
2890  break;
2891 
2892  case QFrame::WinPanel:
2893  frameWidth = 2;
2894  break;
2895 
2896  case QFrame::Panel:
2897  switch (frameShadow) {
2898  case QFrame::Plain:
2899  case QFrame::Raised:
2900  case QFrame::Sunken:
2901  frameWidth = f->lineWidth;
2902  break;
2903  }
2904  break;
2905  }
2906  r = f->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
2907  }
2908  break;
2909 #ifndef QT_NO_DOCKWIDGET
2913  case SE_DockWidgetIcon: {
2914  int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
2915  int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget);
2916  int margin = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget);
2917  QRect rect = opt->rect;
2918 
2919  const QStyleOptionDockWidget *dwOpt
2921  bool canClose = dwOpt == 0 ? true : dwOpt->closable;
2922  bool canFloat = dwOpt == 0 ? false : dwOpt->floatable;
2923  const QStyleOptionDockWidgetV2 *v2
2925  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
2926 
2927  // If this is a vertical titlebar, we transpose and work as if it was
2928  // horizontal, then transpose again.
2929 
2930  if (verticalTitleBar) {
2931  QSize size = rect.size();
2932  size.transpose();
2933  rect.setSize(size);
2934  }
2935 
2936  do {
2937 
2938  int right = rect.right();
2939  int left = rect.left();
2940 
2941  QRect closeRect;
2942  if (canClose) {
2944  opt, widget).actualSize(QSize(iconSize, iconSize));
2945  sz += QSize(buttonMargin, buttonMargin);
2946  if (verticalTitleBar)
2947  sz.transpose();
2948  closeRect = QRect(right - sz.width(),
2949  rect.center().y() - sz.height()/2,
2950  sz.width(), sz.height());
2951  right = closeRect.left() - 1;
2952  }
2953  if (sr == SE_DockWidgetCloseButton) {
2954  r = closeRect;
2955  break;
2956  }
2957 
2958  QRect floatRect;
2959  if (canFloat) {
2961  opt, widget).actualSize(QSize(iconSize, iconSize));
2962  sz += QSize(buttonMargin, buttonMargin);
2963  if (verticalTitleBar)
2964  sz.transpose();
2965  floatRect = QRect(right - sz.width(),
2966  rect.center().y() - sz.height()/2,
2967  sz.width(), sz.height());
2968  right = floatRect.left() - 1;
2969  }
2970  if (sr == SE_DockWidgetFloatButton) {
2971  r = floatRect;
2972  break;
2973  }
2974 
2975  QRect iconRect;
2976  if (const QDockWidget *dw = qobject_cast<const QDockWidget*>(widget)) {
2977  QIcon icon;
2978  if (dw->isFloating())
2979  icon = dw->windowIcon();
2980  if (!icon.isNull()
2981  && icon.cacheKey() != QApplication::windowIcon().cacheKey()) {
2982  QSize sz = icon.actualSize(QSize(r.height(), r.height()));
2983  if (verticalTitleBar)
2984  sz.transpose();
2985  iconRect = QRect(left, rect.center().y() - sz.height()/2,
2986  sz.width(), sz.height());
2987  left = iconRect.right() + margin;
2988  }
2989  }
2990  if (sr == SE_DockWidgetIcon) {
2991  r = iconRect;
2992  break;
2993  }
2994 
2995  QRect textRect = QRect(left, rect.top(),
2996  right - left, rect.height());
2997  if (sr == SE_DockWidgetTitleBarText) {
2998  r = textRect;
2999  break;
3000  }
3001 
3002  } while (false);
3003 
3004  if (verticalTitleBar) {
3005  r = QRect(rect.left() + r.top() - rect.top(),
3006  rect.top() + rect.right() - r.right(),
3007  r.height(), r.width());
3008  } else {
3009  r = visualRect(opt->direction, rect, r);
3010  }
3011  break;
3012  }
3013 #endif
3014 #ifndef QT_NO_ITEMVIEWS
3016  if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
3017  r = subElementRect(SE_CheckBoxIndicator, opt, widget);
3018  break;
3019  }
3021  case SE_ItemViewItemText:
3023  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
3024  if (!d->isViewItemCached(*vopt)) {
3025  d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false);
3026  if (d->cachedOption) {
3027  delete d->cachedOption;
3028  d->cachedOption = 0;
3029  }
3030  d->cachedOption = new QStyleOptionViewItemV4(*vopt);
3031  }
3032  if (sr == SE_ViewItemCheckIndicator)
3033  r = d->checkRect;
3034  else if (sr == SE_ItemViewItemDecoration)
3035  r = d->decorationRect;
3036  else if (sr == SE_ItemViewItemText || sr == SE_ItemViewItemFocusRect)
3037  r = d->displayRect;
3038  }
3039  break;
3040 #endif //QT_NO_ITEMVIEWS
3041 #ifndef QT_NO_TOOLBAR
3042  case SE_ToolBarHandle:
3043  if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
3044  if (tbopt->features & QStyleOptionToolBar::Movable) {
3046  //have all the information we need (ie. the layout's margin)
3047  const QToolBar *tb = qobject_cast<const QToolBar*>(widget);
3048  const int margin = tb && tb->layout() ? tb->layout()->margin() : 2;
3049  const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb);
3050  if (tbopt->state & QStyle::State_Horizontal) {
3051  r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin);
3052  r = QStyle::visualRect(tbopt->direction, tbopt->rect, r);
3053  } else {
3054  r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent);
3055  }
3056  }
3057  }
3058  break;
3059 #endif //QT_NO_TOOLBAR
3060  default:
3061  break;
3062  }
3063  return r;
3064 }
double d
Definition: qnumeric_p.h:62
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
QPointer< QWidget > widget
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
int qCeil(qreal v)
Definition: qmath.h:63
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
virtual 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
int margin
the width of the outside border of the layout
Definition: qlayout.h:96
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
bool closable
whether the dock window is closable
Definition: qstyleoption.h:511
static bool verticalTabs(QTabBar::Shape shape)
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
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
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
#define Q_D(Class)
Definition: qglobal.h:2482
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
Definition: qstyleoption.h:316
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QStyle * style() const
Definition: qwidget.cpp:2742
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
static QIcon windowIcon()
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
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
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QStyleOptionQ3DockWindow class is used to describe the parameters for drawing various parts of a ...
Definition: qstyleoption.h:488
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
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
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
bool floatable
whether the dock window is floatable
Definition: qstyleoption.h:513
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
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.
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition: qicon.cpp:679
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
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 QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
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
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
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
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ unpolish() [1/2]

void QCommonStyle::unpolish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QWindowsMobileStyle, QProxyStyle, QPlastiqueStyle, QWindowsVistaStyle, QMacStyle, QMotifStyle, QWindowsStyle, and QWindowsXPStyle.

Definition at line 6068 of file qcommonstyle.cpp.

Referenced by QWindowsStyle::unpolish(), and QMotifStyle::unpolish().

6069 {
6070  QStyle::unpolish(widget);
6071 }
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409

◆ unpolish() [2/2]

void QCommonStyle::unpolish ( QApplication application)
virtual

Reimplemented Function

Reimplemented from QStyle.

Reimplemented in QStyleSheetStyle, QGtkStyle, QProxyStyle, QWindowsMobileStyle, QPlastiqueStyle, QWindowsVistaStyle, QMacStyle, QMotifStyle, QWindowsStyle, and QWindowsXPStyle.

Definition at line 6084 of file qcommonstyle.cpp.

6085 {
6086  Q_D(const QCommonStyle);
6087  d->tabBarcloseButtonIcon = QIcon();
6088  QStyle::unpolish(application);
6089 }
double d
Definition: qnumeric_p.h:62
virtual void unpolish(QWidget *)
Uninitialize the given {widget}&#39;s appearance.
Definition: qstyle.cpp:409
#define Q_D(Class)
Definition: qglobal.h:2482
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
Definition: qcommonstyle.h:54
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

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