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

#include <qmacstyle_mac.h>

Inheritance diagram for QMacStyle:
QWindowsStyle QCommonStyle QStyle QObject

Public Types

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

Static Public Functions

static FocusRectPolicy focusRectPolicy (const QWidget *w)
 
static void setFocusRectPolicy (QWidget *w, FocusRectPolicy policy)
 
static void setWidgetSizePolicy (const QWidget *w, WidgetSizePolicy policy)
 
static WidgetSizePolicy widgetSizePolicy (const QWidget *w)
 
- Static Public Functions inherited from QStyle
static QRect alignedRect (Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
 Returns a new rectangle of the specified size that is aligned to the given rectangle according to the specified alignment and direction. More...
 
static int sliderPositionFromValue (int min, int max, int val, int space, bool upsideDown=false)
 Converts the given logicalValue to a pixel position. More...
 
static int sliderValueFromPosition (int min, int max, int pos, int space, bool upsideDown=false)
 Converts the given pixel position to a logical value. More...
 
static Qt::Alignment visualAlignment (Qt::LayoutDirection direction, Qt::Alignment alignment)
 Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with Qt::AlignAbsolute according to the layout direction. More...
 
static QPoint visualPos (Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
 Returns the given logicalPosition converted to screen coordinates based on the specified direction. More...
 
static QRect visualRect (Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
 Returns the given logicalRectangle converted to screen coordinates based on the specified direction. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Protected Slots

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

Properties

QMacStylePrivated
 

Friends

bool qt_mac_buttonIsRenderedFlat (const QPushButton *pushButton, const QStyleOptionButton *option)
 

Additional Inherited Members

- 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 Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QWindowsStyle
bool eventFilter (QObject *o, QEvent *e)
 Reimplemented Function More...
 
 QWindowsStyle (QWindowsStylePrivate &dd)
 Constructs a QWindowsStyle object. More...
 
void timerEvent (QTimerEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QCommonStyle
 QCommonStyle (QCommonStylePrivate &dd)
 
- Protected Functions inherited from QStyle
 QStyle (QStylePrivate &dd)
 Constructs a style object. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 66 of file qmacstyle_mac.h.

Enumerations

◆ FocusRectPolicy

Enumerator
FocusEnabled 
FocusDisabled 
FocusDefault 

Definition at line 102 of file qmacstyle_mac.h.

◆ WidgetSizePolicy

Enumerator
SizeSmall 
SizeLarge 
SizeMini 
SizeDefault 

Definition at line 106 of file qmacstyle_mac.h.

107 #ifdef QT3_SUPPORT
108  , SizeNone = SizeDefault
109 #endif
110  };

Constructors and Destructors

◆ QMacStyle()

QMacStyle::QMacStyle ( )

Definition at line 1781 of file qmacstyle_mac.mm.

1782  : QWindowsStyle()
1783 {
1784  d = new QMacStylePrivate(this);
1785 }
QMacStylePrivate * d
QWindowsStyle()
Constructs a QWindowsStyle object.

◆ ~QMacStyle()

QMacStyle::~QMacStyle ( )
virtual

Definition at line 1787 of file qmacstyle_mac.mm.

1788 {
1789  delete qt_mac_backgroundPattern;
1791  delete d;
1792 }
QMacStylePrivate * d
QPixmap * qt_mac_backgroundPattern

Functions

◆ drawComplexControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4662 of file qmacstyle_mac.mm.

4664 {
4665  ThemeDrawState tds = d->getDrawState(opt->state);
4666  QMacCGContext cg(p);
4667  switch (cc) {
4668  case CC_Slider:
4669  case CC_ScrollBar:
4670  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4671  HIThemeTrackDrawInfo tdi;
4672  d->getSliderInfo(cc, slider, &tdi, widget);
4673  if (slider->state & State_Sunken) {
4674  if (cc == CC_Slider) {
4675  if (slider->activeSubControls == SC_SliderHandle)
4676  tdi.trackInfo.slider.pressState = kThemeThumbPressed;
4677  else if (slider->activeSubControls == SC_SliderGroove)
4678  tdi.trackInfo.slider.pressState = kThemeLeftTrackPressed;
4679  } else {
4680  if (slider->activeSubControls == SC_ScrollBarSubLine
4681  || slider->activeSubControls == SC_ScrollBarAddLine) {
4682  // This test looks complex but it basically boils down
4683  // to the following: The "RTL look" on the mac also
4684  // changed the directions of the controls, that's not
4685  // what people expect (an arrow is an arrow), so we
4686  // kind of fake and say the opposite button is hit.
4687  // This works great, up until 10.4 which broke the
4688  // scroll bars, so I also have actually do something
4689  // similar when I have an upside down scroll bar
4690  // because on Tiger I only "fake" the reverse stuff.
4691  bool reverseHorizontal = (slider->direction == Qt::RightToLeft
4692  && slider->orientation == Qt::Horizontal);
4693  if ((reverseHorizontal
4694  && slider->activeSubControls == SC_ScrollBarAddLine)
4695  || (!reverseHorizontal
4696  && slider->activeSubControls == SC_ScrollBarSubLine)) {
4697  tdi.trackInfo.scrollbar.pressState = kThemeRightInsideArrowPressed
4698  | kThemeLeftOutsideArrowPressed;
4699  } else {
4700  tdi.trackInfo.scrollbar.pressState = kThemeLeftInsideArrowPressed
4701  | kThemeRightOutsideArrowPressed;
4702  }
4703  } else if (slider->activeSubControls == SC_ScrollBarAddPage) {
4704  tdi.trackInfo.scrollbar.pressState = kThemeRightTrackPressed;
4705  } else if (slider->activeSubControls == SC_ScrollBarSubPage) {
4706  tdi.trackInfo.scrollbar.pressState = kThemeLeftTrackPressed;
4707  } else if (slider->activeSubControls == SC_ScrollBarSlider) {
4708  tdi.trackInfo.scrollbar.pressState = kThemeThumbPressed;
4709  }
4710  }
4711  }
4712  HIRect macRect;
4713  bool tracking = slider->sliderPosition == slider->sliderValue;
4714  if (!tracking) {
4715  // Small optimization, the same as q->subControlRect
4716  QCFType<HIShapeRef> shape;
4717  HIThemeGetTrackThumbShape(&tdi, &shape);
4718  ptrHIShapeGetBounds(shape, &macRect);
4719  tdi.value = slider->sliderValue;
4720  }
4721 
4722  // Remove controls from the scroll bar if it is to short to draw them correctly.
4723  // This is done in two stages: first the thumb indicator is removed when it is
4724  // no longer possible to move it, second the up/down buttons are removed when
4725  // there is not enough space for them.
4726  if (cc == CC_ScrollBar) {
4727  const int scrollBarLength = (slider->orientation == Qt::Horizontal)
4728  ? slider->rect.width() : slider->rect.height();
4730  if (scrollBarLength < scrollButtonsCutoffSize(thumbIndicatorCutoff, sizePolicy))
4731  tdi.attributes &= ~kThemeTrackShowThumb;
4732  if (scrollBarLength < scrollButtonsCutoffSize(scrollButtonsCutoff, sizePolicy))
4733  tdi.enableState = kThemeTrackNothingToScroll;
4734  } else {
4735  if (!(slider->subControls & SC_SliderHandle))
4736  tdi.attributes &= ~kThemeTrackShowThumb;
4737 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
4738  if (!(slider->subControls & SC_SliderGroove))
4739  tdi.attributes |= kThemeTrackHideTrack;
4740 #endif
4741  }
4742 
4743  HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg,
4744  kHIThemeOrientationNormal);
4745  if (cc == CC_Slider && slider->subControls & SC_SliderTickmarks) {
4746  if (qt_mac_is_metal(widget)) {
4747  if (tdi.enableState == kThemeTrackInactive)
4748  tdi.enableState = kThemeTrackActive; // Looks more Cocoa-like
4749  }
4750  int interval = slider->tickInterval;
4751  if (interval == 0) {
4752  interval = slider->pageStep;
4753  if (interval == 0)
4754  interval = slider->singleStep;
4755  if (interval == 0)
4756  interval = 1;
4757  }
4758  int numMarks = 1 + ((slider->maximum - slider->minimum) / interval);
4759 
4760  if (tdi.trackInfo.slider.thumbDir == kThemeThumbPlain) {
4761  // They asked for both, so we'll give it to them.
4762  tdi.trackInfo.slider.thumbDir = kThemeThumbDownward;
4763  HIThemeDrawTrackTickMarks(&tdi, numMarks,
4764  cg,
4765  kHIThemeOrientationNormal);
4766  tdi.trackInfo.slider.thumbDir = kThemeThumbUpward;
4767  HIThemeDrawTrackTickMarks(&tdi, numMarks,
4768  cg,
4769  kHIThemeOrientationNormal);
4770  } else {
4771  HIThemeDrawTrackTickMarks(&tdi, numMarks,
4772  cg,
4773  kHIThemeOrientationNormal);
4774 
4775  }
4776  }
4777  }
4778  break;
4779  case CC_Q3ListView:
4780  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
4781  if (lv->subControls & SC_Q3ListView)
4783  if (lv->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
4784  int y = lv->rect.y();
4785  int h = lv->rect.height();
4786  int x = lv->rect.right() - 10;
4787  for (int i = 1; i < lv->items.size() && y < h; ++i) {
4788  QStyleOptionQ3ListViewItem item = lv->items.at(i);
4789  if (y + item.height > 0 && (item.childCount > 0
4794  QStyleOption treeOpt(0);
4795  treeOpt.rect.setRect(x, y + item.height / 2 - 4, 9, 9);
4796  treeOpt.palette = lv->palette;
4797  treeOpt.state = lv->state;
4798  treeOpt.state |= State_Children;
4799  if (item.state & State_Open)
4800  treeOpt.state |= State_Open;
4801  proxy()->drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget);
4802  }
4803  y += item.totalHeight;
4804  }
4805  }
4806  }
4807  break;
4808  case CC_SpinBox:
4809  if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
4810  QStyleOptionSpinBox newSB = *sb;
4811  if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
4812  SInt32 frame_size;
4813  GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
4814 
4816  lineeditRect.adjust(-frame_size, -frame_size, +frame_size, +frame_size);
4817 
4818  HIThemeFrameDrawInfo fdi;
4819  fdi.version = qt_mac_hitheme_version;
4820  fdi.state = ((sb->state & State_ReadOnly) || !(sb->state & State_Enabled)) ? kThemeStateInactive : kThemeStateActive;
4821  fdi.kind = kHIThemeFrameTextFieldSquare;
4822  fdi.isFocused = false;
4823  HIRect hirect = qt_hirectForQRect(lineeditRect);
4824  HIThemeDrawFrame(&hirect, &fdi, cg, kHIThemeOrientationNormal);
4825  }
4826  if (sb->subControls & (SC_SpinBoxUp | SC_SpinBoxDown)) {
4827  HIThemeButtonDrawInfo bdi;
4828  bdi.version = qt_mac_hitheme_version;
4829  QAquaWidgetSize aquaSize = d->aquaSizeConstrain(opt, widget);
4830  switch (aquaSize) {
4831  case QAquaSizeUnknown:
4832  case QAquaSizeLarge:
4833  bdi.kind = kThemeIncDecButton;
4834  break;
4835  case QAquaSizeMini:
4836  bdi.kind = kThemeIncDecButtonMini;
4837  break;
4838  case QAquaSizeSmall:
4839  bdi.kind = kThemeIncDecButtonSmall;
4840  break;
4841  }
4842  if (!(sb->stepEnabled & (QAbstractSpinBox::StepUpEnabled
4844  tds = kThemeStateUnavailable;
4845  if (sb->activeSubControls == SC_SpinBoxDown
4846  && (sb->state & State_Sunken))
4847  tds = kThemeStatePressedDown;
4848  else if (sb->activeSubControls == SC_SpinBoxUp
4849  && (sb->state & State_Sunken))
4850  tds = kThemeStatePressedUp;
4851  bdi.state = tds;
4852  if (!(sb->state & State_Active)
4853  && sb->palette.currentColorGroup() == QPalette::Active
4854  && tds == kThemeStateInactive)
4855  bdi.state = kThemeStateActive;
4856  bdi.value = kThemeButtonOff;
4857  bdi.adornment = kThemeAdornmentNone;
4858 
4860 
4861  updown |= proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
4862  HIRect newRect = qt_hirectForQRect(updown);
4863  QRect off_rct;
4864  HIRect outRect;
4865  HIThemeGetButtonBackgroundBounds(&newRect, &bdi, &outRect);
4866  off_rct.setRect(int(newRect.origin.x - outRect.origin.x),
4867  int(newRect.origin.y - outRect.origin.y),
4868  int(outRect.size.width - newRect.size.width),
4869  int(outRect.size.height - newRect.size.height));
4870 
4871  newRect = qt_hirectForQRect(updown, off_rct);
4872  HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
4873  }
4874  }
4875  break;
4876  case CC_ComboBox:
4877  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
4878  HIThemeButtonDrawInfo bdi;
4879  d->initComboboxBdi(combo, &bdi, widget, d->getDrawState(opt->state));
4880  bool drawColorless = combo->palette.currentColorGroup() == QPalette::Active && tds == kThemeStateInactive;
4881  if (!drawColorless)
4882  QMacStylePrivate::drawCombobox(qt_hirectForQRect(combo->rect), bdi, p);
4883  else
4884  d->drawColorlessButton(qt_hirectForQRect(combo->rect), &bdi, p, opt);
4885  }
4886  break;
4887  case CC_TitleBar:
4888  if (const QStyleOptionTitleBar *titlebar
4889  = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4890  if (titlebar->state & State_Active) {
4891  if (titlebar->titleBarState & State_Active)
4892  tds = kThemeStateActive;
4893  else
4894  tds = kThemeStateInactive;
4895  } else {
4896  tds = kThemeStateInactive;
4897  }
4898 
4899  HIThemeWindowDrawInfo wdi;
4900  wdi.version = qt_mac_hitheme_version;
4901  wdi.state = tds;
4902  wdi.windowType = QtWinType;
4903  wdi.titleHeight = titlebar->rect.height();
4904  wdi.titleWidth = titlebar->rect.width();
4905  wdi.attributes = kThemeWindowHasTitleText;
4906  // It seems HIThemeDrawTitleBarWidget is not able to draw a dirty
4907  // close button, so use HIThemeDrawWindowFrame instead.
4908  if (widget && widget->isWindowModified() && titlebar->subControls & SC_TitleBarCloseButton)
4909  wdi.attributes |= kThemeWindowHasCloseBox | kThemeWindowHasDirty;
4910 
4911  HIRect titleBarRect;
4912  HIRect tmpRect = qt_hirectForQRect(titlebar->rect);
4913  {
4914  QCFType<HIShapeRef> titleRegion;
4915  QRect newr = titlebar->rect.adjusted(0, 0, 2, 0);
4916  HIThemeGetWindowShape(&tmpRect, &wdi, kWindowTitleBarRgn, &titleRegion);
4917  ptrHIShapeGetBounds(titleRegion, &tmpRect);
4918  newr.translate(newr.x() - int(tmpRect.origin.x), newr.y() - int(tmpRect.origin.y));
4919  titleBarRect = qt_hirectForQRect(newr);
4920  }
4921  HIThemeDrawWindowFrame(&titleBarRect, &wdi, cg, kHIThemeOrientationNormal, 0);
4922  if (titlebar->subControls & (SC_TitleBarCloseButton
4926  HIThemeWindowWidgetDrawInfo wwdi;
4927  wwdi.version = qt_mac_hitheme_version;
4928  wwdi.widgetState = tds;
4929  if (titlebar->state & State_MouseOver)
4930  wwdi.widgetState = kThemeStateRollover;
4931  wwdi.windowType = QtWinType;
4932  wwdi.attributes = wdi.attributes | kThemeWindowHasFullZoom | kThemeWindowHasCloseBox | kThemeWindowHasCollapseBox;
4933  wwdi.windowState = wdi.state;
4934  wwdi.titleHeight = wdi.titleHeight;
4935  wwdi.titleWidth = wdi.titleWidth;
4936  ThemeDrawState savedControlState = wwdi.widgetState;
4938  ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox;
4939  bool active = titlebar->state & State_Active;
4940  if (qMacVersion() < QSysInfo::MV_10_6) {
4941  int border = 2;
4942  titleBarRect.origin.x += border;
4943  titleBarRect.origin.y -= border;
4944  }
4945 
4946  while (sc <= SC_TitleBarCloseButton) {
4947  if (sc & titlebar->subControls) {
4948  uint tmp = sc;
4949  wwdi.widgetState = savedControlState;
4950  wwdi.widgetType = tbw;
4951  if (sc == SC_TitleBarMinButton)
4952  tmp |= SC_TitleBarNormalButton;
4953  if (active && (titlebar->activeSubControls & tmp)
4954  && (titlebar->state & State_Sunken))
4955  wwdi.widgetState = kThemeStatePressed;
4956  // Draw all sub controllers except the dirty close button
4957  // (it is already handled by HIThemeDrawWindowFrame).
4958  if (!(widget && widget->isWindowModified() && tbw == kThemeWidgetCloseBox)) {
4959  HIThemeDrawTitleBarWidget(&titleBarRect, &wwdi, cg, kHIThemeOrientationNormal);
4960  p->paintEngine()->syncState();
4961  }
4962  }
4963  sc = sc << 1;
4964  tbw = tbw >> 1;
4965  }
4966  }
4967  p->paintEngine()->syncState();
4968  if (titlebar->subControls & SC_TitleBarLabel) {
4969  int iw = 0;
4970  if (!titlebar->icon.isNull()) {
4971  QCFType<HIShapeRef> titleRegion2;
4972  HIThemeGetWindowShape(&titleBarRect, &wdi, kWindowTitleProxyIconRgn,
4973  &titleRegion2);
4974  ptrHIShapeGetBounds(titleRegion2, &tmpRect);
4975  if (tmpRect.size.width != 1) {
4976  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
4977  iw = titlebar->icon.actualSize(QSize(iconExtent, iconExtent)).width();
4978  }
4979  }
4980  if (!titlebar->text.isEmpty()) {
4981  p->save();
4982  QCFType<HIShapeRef> titleRegion3;
4983  HIThemeGetWindowShape(&titleBarRect, &wdi, kWindowTitleTextRgn, &titleRegion3);
4984  ptrHIShapeGetBounds(titleRegion3, &tmpRect);
4985  p->setClipRect(qt_qrectForHIRect(tmpRect));
4986  QRect br = p->clipRegion().boundingRect();
4987  int x = br.x(),
4988  y = br.y() + (titlebar->rect.height() / 2 - p->fontMetrics().height() / 2);
4989  if (br.width() <= (p->fontMetrics().width(titlebar->text) + iw * 2))
4990  x += iw;
4991  else
4992  x += br.width() / 2 - p->fontMetrics().width(titlebar->text) / 2;
4993  if (iw)
4994  p->drawPixmap(x - iw, y,
4995  titlebar->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), QIcon::Normal));
4996  drawItemText(p, br, Qt::AlignCenter, opt->palette, tds == kThemeStateActive,
4997  titlebar->text, QPalette::Text);
4998  p->restore();
4999  }
5000  }
5001  }
5002  break;
5003  case CC_GroupBox:
5004  if (const QStyleOptionGroupBox *groupBox
5005  = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
5006 
5007  QStyleOptionGroupBox groupBoxCopy(*groupBox);
5010  groupBoxCopy.subControls = groupBoxCopy.subControls & ~SC_GroupBoxLabel;
5011  QWindowsStyle::drawComplexControl(cc, &groupBoxCopy, p, widget);
5012  if (groupBoxCopy.subControls != groupBox->subControls) {
5013  bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
5014  p->save();
5015  CGContextSetShouldAntialias(cg, true);
5016  CGContextSetShouldSmoothFonts(cg, true);
5017  HIThemeTextInfo tti;
5018  tti.version = qt_mac_hitheme_version;
5019  tti.state = tds;
5020  QColor textColor = groupBox->palette.windowText().color();
5021  CGFloat colorComp[] = { textColor.redF(), textColor.greenF(),
5022  textColor.blueF(), textColor.alphaF() };
5023  CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace());
5024  CGContextSetFillColor(cg, colorComp);
5025  tti.fontID = checkable ? kThemeSystemFont : kThemeSmallSystemFont;
5026  tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter;
5027  tti.verticalFlushness = kHIThemeTextVerticalFlushCenter;
5028  tti.options = kHIThemeTextBoxOptionNone;
5029  tti.truncationPosition = kHIThemeTextTruncationNone;
5030  tti.truncationMaxLines = 1 + groupBox->text.count(QLatin1Char('\n'));
5031  QCFString groupText = qt_mac_removeMnemonics(groupBox->text);
5033  HIRect bounds = qt_hirectForQRect(r);
5034  HIThemeDrawTextBox(groupText, &bounds, &tti, cg, kHIThemeOrientationNormal);
5035  p->restore();
5036  }
5037  }
5038  break;
5039  case CC_ToolButton:
5040  if (const QStyleOptionToolButton *tb
5041  = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
5042  if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
5043  if (tb->subControls & SC_ToolButtonMenu) {
5044  QStyleOption arrowOpt(0);
5045  arrowOpt.rect = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget);
5046  arrowOpt.rect.setY(arrowOpt.rect.y() + arrowOpt.rect.height() / 2);
5047  arrowOpt.rect.setHeight(arrowOpt.rect.height() / 2);
5048  arrowOpt.state = tb->state;
5049  arrowOpt.palette = tb->palette;
5050  proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
5051  } else if ((tb->features & QStyleOptionToolButton::HasMenu)
5052  && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) {
5053  drawToolbarButtonArrow(tb->rect, tds, cg);
5054  }
5055  if (tb->state & State_On) {
5057  static QPixmap pm(QLatin1String(":/trolltech/mac/style/images/leopard-unified-toolbar-on.png"));
5059  QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);
5060  } else {
5061  QPen oldPen = p->pen();
5062  p->setPen(QColor(0, 0, 0, 0x3a));
5063  p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12));
5064  p->drawLine(tb->rect.left() + 1, tb->rect.top(),
5065  tb->rect.right() - 1, tb->rect.top());
5066  p->drawLine(tb->rect.left() + 1, tb->rect.bottom(),
5067  tb->rect.right() - 1, tb->rect.bottom());
5068  p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft());
5069  p->drawLine(tb->rect.topRight(), tb->rect.bottomRight());
5070  p->setPen(oldPen);
5071  }
5072  }
5074  } else {
5075  ThemeButtonKind bkind = kThemeBevelButton;
5076  switch (d->aquaSizeConstrain(opt, widget)) {
5077  case QAquaSizeUnknown:
5078  case QAquaSizeLarge:
5079  bkind = kThemeBevelButton;
5080  break;
5081  case QAquaSizeMini:
5082  case QAquaSizeSmall:
5083  bkind = kThemeSmallBevelButton;
5084  break;
5085  }
5086 
5087  QRect button, menuarea;
5088  button = proxy()->subControlRect(cc, tb, SC_ToolButton, widget);
5089  menuarea = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget);
5090  State bflags = tb->state,
5091  mflags = tb->state;
5092  if (tb->subControls & SC_ToolButton)
5093  bflags |= State_Sunken;
5094  if (tb->subControls & SC_ToolButtonMenu)
5095  mflags |= State_Sunken;
5096 
5097  if (tb->subControls & SC_ToolButton) {
5098  if (bflags & (State_Sunken | State_On | State_Raised)) {
5099  HIThemeButtonDrawInfo bdi;
5100  bdi.version = qt_mac_hitheme_version;
5101  bdi.state = tds;
5102  bdi.adornment = kThemeAdornmentNone;
5103  bdi.kind = bkind;
5104  bdi.value = kThemeButtonOff;
5105  if (tb->state & State_HasFocus)
5106  bdi.adornment = kThemeAdornmentFocus;
5107  if (tb->state & State_Sunken)
5108  bdi.state = kThemeStatePressed;
5109  if (tb->state & State_On)
5110  bdi.value = kThemeButtonOn;
5111 
5112  QRect off_rct(0, 0, 0, 0);
5113  HIRect myRect, macRect;
5114  myRect = CGRectMake(tb->rect.x(), tb->rect.y(),
5115  tb->rect.width(), tb->rect.height());
5116  HIThemeGetButtonBackgroundBounds(&myRect, &bdi, &macRect);
5117  off_rct.setRect(int(myRect.origin.x - macRect.origin.x),
5118  int(myRect.origin.y - macRect.origin.y),
5119  int(macRect.size.width - myRect.size.width),
5120  int(macRect.size.height - myRect.size.height));
5121 
5122  myRect = qt_hirectForQRect(button, off_rct);
5123  HIThemeDrawButton(&myRect, &bdi, cg, kHIThemeOrientationNormal, 0);
5124  }
5125  }
5126 
5127  if (tb->subControls & SC_ToolButtonMenu) {
5128  HIThemeButtonDrawInfo bdi;
5129  bdi.version = qt_mac_hitheme_version;
5130  bdi.state = tds;
5131  bdi.value = kThemeButtonOff;
5132  bdi.adornment = kThemeAdornmentNone;
5133  bdi.kind = bkind;
5134  if (tb->state & State_HasFocus)
5135  bdi.adornment = kThemeAdornmentFocus;
5136  if (tb->state & (State_On | State_Sunken)
5137  || (tb->activeSubControls & SC_ToolButtonMenu))
5138  bdi.state = kThemeStatePressed;
5139  HIRect hirect = qt_hirectForQRect(menuarea);
5140  HIThemeDrawButton(&hirect, &bdi, cg, kHIThemeOrientationNormal, 0);
5141  QRect r(menuarea.x() + ((menuarea.width() / 2) - 3), menuarea.height() - 8, 8, 8);
5142  HIThemePopupArrowDrawInfo padi;
5143  padi.version = qt_mac_hitheme_version;
5144  padi.state = tds;
5145  padi.orientation = kThemeArrowDown;
5146  padi.size = kThemeArrow7pt;
5147  hirect = qt_hirectForQRect(r);
5148  HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal);
5149  } else if (tb->features & QStyleOptionToolButton::HasMenu) {
5150  drawToolbarButtonArrow(tb->rect, tds, cg);
5151  }
5153  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
5154  QStyleOptionToolButton label = *tb;
5155  label.rect = buttonRect.adjusted(fw, fw, -fw, -fw);
5156  proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
5157  }
5158  }
5159  break;
5160  case CC_Dial:
5161  if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt))
5162  QStyleHelper::drawDial(dial, p);
5163  break;
5164  default:
5166  break;
5167  }
5168 }
const int qt_mac_hitheme_version
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
int height
the height of the item
Definition: qstyleoption.h:474
QString qt_mac_removeMnemonics(const QString &original)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static CGColorSpaceRef macGenericColorSpace()
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
bool qt_mac_is_metal(const QWidget *w)
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
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
QPointer< QWidget > widget
void syncState()
Updates all dirty states in this engine.
virtual void drawItemText(QPainter *p, const QRect &r, 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.
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
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.
int pixelMetric(PixelMetric pm, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
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
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
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int childCount
the number of children the item has
Definition: qstyleoption.h:477
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
static const QRect qt_qrectForHIRect(const HIRect &hirect)
QMacStylePrivate * d
const ThemeWindowType QtWinType
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
static PtrHIShapeGetBounds ptrHIShapeGetBounds
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
bool isWindowModified() const
Definition: qwidget.cpp:11554
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
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
int totalHeight
the total height of the item, including its children
Definition: qstyleoption.h:475
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
QAquaWidgetSize
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...
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
unsigned int uint
Definition: qglobal.h:996
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
The State element defines configurations of objects and properties.
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p)
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe)
int qMacVersion()
Definition: qglobal.h:1685
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static WidgetSizePolicy widgetSizePolicy(const QWidget *w)
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
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
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
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static ThemeDrawState getDrawState(QStyle::State flags)
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, const QWidget *widget, const ThemeDrawState &tds)
int height() const
Returns the height of the font.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
static void drawToolbarButtonArrow(const QRect &toolButtonRect, ThemeDrawState tds, CGContextRef cg)
void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const
static int scrollButtonsCutoffSize(ScrollBarCutoffType cutoffType, QMacStyle::WidgetSizePolicy widgetSize)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
void 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
float CGFloat

◆ drawControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 3167 of file qmacstyle_mac.mm.

Referenced by drawPrimitive().

3169 {
3170  ThemeDrawState tds = d->getDrawState(opt->state);
3171  QMacCGContext cg(p);
3172  switch (ce) {
3173  case CE_HeaderSection:
3174  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
3175  HIThemeButtonDrawInfo bdi;
3176  bdi.version = qt_mac_hitheme_version;
3177  State flags = header->state;
3178  QRect ir = header->rect;
3179  bdi.kind = kThemeListHeaderButton;
3180  bdi.adornment = kThemeAdornmentNone;
3181  bdi.state = kThemeStateActive;
3182 
3183  if (flags & State_On)
3184  bdi.value = kThemeButtonOn;
3185  else
3186  bdi.value = kThemeButtonOff;
3187 
3188  if (header->orientation == Qt::Horizontal){
3189  switch (header->position) {
3191  ir.adjust(-1, -1, 0, 0);
3192  break;
3194  ir.adjust(-1, -1, 0, 0);
3195  break;
3198  ir.adjust(-1, -1, 1, 0);
3199  break;
3200  default:
3201  break;
3202  }
3203 
3204  if (header->position != QStyleOptionHeader::Beginning
3205  && header->position != QStyleOptionHeader::OnlyOneSection) {
3206  bdi.adornment = header->direction == Qt::LeftToRight
3207  ? kThemeAdornmentHeaderButtonLeftNeighborSelected
3208  : kThemeAdornmentHeaderButtonRightNeighborSelected;
3209  }
3210  }
3211 
3212  if (flags & State_Active) {
3213  if (!(flags & State_Enabled))
3214  bdi.state = kThemeStateUnavailable;
3215  else if (flags & State_Sunken)
3216  bdi.state = kThemeStatePressed;
3217  } else {
3218  if (flags & State_Enabled)
3219  bdi.state = kThemeStateInactive;
3220  else
3221  bdi.state = kThemeStateUnavailableInactive;
3222  }
3223 
3224  if (header->sortIndicator != QStyleOptionHeader::None) {
3225  bdi.value = kThemeButtonOn;
3226  if (header->sortIndicator == QStyleOptionHeader::SortDown)
3227  bdi.adornment = kThemeAdornmentHeaderButtonSortUp;
3228  }
3229  if (flags & State_HasFocus)
3230  bdi.adornment = kThemeAdornmentFocus;
3231 
3232  ir = visualRect(header->direction, header->rect, ir);
3233  HIRect bounds = qt_hirectForQRect(ir);
3234 
3235  bool noVerticalHeader = true;
3236  if (w)
3237  if (const QTableView *table = qobject_cast<const QTableView *>(w->parentWidget()))
3238  noVerticalHeader = !table->verticalHeader()->isVisible();
3239 
3240  bool drawTopBorder = header->orientation == Qt::Horizontal;
3241  bool drawLeftBorder = header->orientation == Qt::Vertical
3242  || header->position == QStyleOptionHeader::OnlyOneSection
3243  || (header->position == QStyleOptionHeader::Beginning && noVerticalHeader);
3244  d->drawTableHeader(bounds, drawTopBorder, drawLeftBorder, bdi, p);
3245  }
3246  break;
3247  case CE_HeaderLabel:
3248  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
3249  QRect textr = header->rect;
3250  if (!header->icon.isNull()) {
3252  if (opt->state & State_Enabled)
3253  mode = QIcon::Normal;
3254  QPixmap pixmap = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), mode);
3255 
3256  QRect pixr = header->rect;
3257  pixr.setY(header->rect.center().y() - (pixmap.height() - 1) / 2);
3258  proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap);
3259  textr.translate(pixmap.width() + 2, 0);
3260  }
3261 
3262  proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
3263  header->state & State_Enabled, header->text, QPalette::ButtonText);
3264  }
3265  break;
3266  case CE_ToolButtonLabel:
3267  if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3268  QStyleOptionToolButton myTb = *tb;
3269  myTb.state &= ~State_AutoRaise;
3270  if (w && qobject_cast<QToolBar *>(w->parentWidget())) {
3271  QRect cr = tb->rect;
3272  int shiftX = 0;
3273  int shiftY = 0;
3274  bool needText = false;
3275  int alignment = 0;
3276  bool down = tb->state & (State_Sunken | State_On);
3277  if (down) {
3278  shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, w);
3279  shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, tb, w);
3280  }
3281  // The down state is special for QToolButtons in a toolbar on the Mac
3282  // The text is a bit bolder and gets a drop shadow and the icons are also darkened.
3283  // This doesn't really fit into any particular case in QIcon, so we
3284  // do the majority of the work ourselves.
3285  if (!(tb->features & QStyleOptionToolButton::Arrow)) {
3286  Qt::ToolButtonStyle tbstyle = tb->toolButtonStyle;
3287  if (tb->icon.isNull() && !tb->text.isEmpty())
3288  tbstyle = Qt::ToolButtonTextOnly;
3289 
3290  switch (tbstyle) {
3291  case Qt::ToolButtonTextOnly: {
3292  needText = true;
3293  alignment = Qt::AlignCenter;
3294  break; }
3298  QRect pr = cr;
3299  QIcon::Mode iconMode = (tb->state & State_Enabled) ? QIcon::Normal
3300  : QIcon::Disabled;
3301  QIcon::State iconState = (tb->state & State_On) ? QIcon::On
3302  : QIcon::Off;
3303  QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState);
3304 
3305  // Draw the text if it's needed.
3306  if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
3307  needText = true;
3308  if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
3309  QMainWindow *mw = qobject_cast<QMainWindow *>(w->window());
3310  if (mw && mw->unifiedTitleAndToolBarOnMac()) {
3311  pr.setHeight(pixmap.size().height());
3312  cr.adjust(0, pr.bottom() + 1, 0, 1);
3313  } else {
3314  pr.setHeight(pixmap.size().height() + 6);
3315  cr.adjust(0, pr.bottom(), 0, -3);
3316  }
3317  alignment |= Qt::AlignCenter;
3318  } else {
3319  pr.setWidth(pixmap.width() + 8);
3320  cr.adjust(pr.right(), 0, 0, 0);
3321  alignment |= Qt::AlignLeft | Qt::AlignVCenter;
3322  }
3323  }
3324  if (opt->state & State_Sunken) {
3325  pr.translate(shiftX, shiftY);
3326  pixmap = darkenPixmap(pixmap);
3327  }
3328  proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pixmap);
3329  break; }
3330  default:
3331  Q_ASSERT(false);
3332  break;
3333  }
3334 
3335  if (needText) {
3336  QPalette pal = tb->palette;
3338  if (!proxy()->styleHint(SH_UnderlineShortcut, tb, w))
3339  alignment |= Qt::TextHideMnemonic;
3340  if (down)
3341  cr.translate(shiftX, shiftY);
3343  && (tbstyle == Qt::ToolButtonTextOnly
3344  || (tbstyle != Qt::ToolButtonTextOnly && !down))) {
3345  QPen pen = p->pen();
3346  QColor light = down ? Qt::black : Qt::white;
3347  light.setAlphaF(0.375f);
3348  p->setPen(light);
3349  p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text);
3350  p->setPen(pen);
3351  if (down && tbstyle == Qt::ToolButtonTextOnly) {
3352  pal = QApplication::palette("QMenu");
3353  pal.setCurrentColorGroup(tb->palette.currentColorGroup());
3355  }
3356  }
3357  proxy()->drawItemText(p, cr, alignment, pal,
3358  tb->state & State_Enabled, tb->text, role);
3360  (tb->state & State_Sunken)) {
3361  // Draw a "drop shadow" in earlier versions.
3362  proxy()->drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment,
3363  tb->palette, tb->state & State_Enabled, tb->text);
3364  }
3365  }
3366  } else {
3367  QWindowsStyle::drawControl(ce, &myTb, p, w);
3368  }
3369  } else {
3370  QWindowsStyle::drawControl(ce, &myTb, p, w);
3371  }
3372  }
3373  break;
3374  case CE_ToolBoxTabShape:
3375  QCommonStyle::drawControl(ce, opt, p, w);
3376  break;
3377  case CE_PushButtonBevel:
3378  if (const QStyleOptionButton *btn = ::qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3379  if (!(btn->state & (State_Raised | State_Sunken | State_On)))
3380  break;
3381 
3382  if (btn->features & QStyleOptionButton::CommandLinkButton) {
3383  QWindowsStyle::drawControl(ce, opt, p, w);
3384  break;
3385  }
3386 
3387  HIThemeButtonDrawInfo bdi;
3388  d->initHIThemePushButton(btn, w, tds, &bdi);
3389  if (btn->features & QStyleOptionButton::DefaultButton
3391  bdi.adornment |= kThemeAdornmentDefault;
3392  bdi.animation.time.start = d->defaultButtonStart;
3393  bdi.animation.time.current = CFAbsoluteTimeGetCurrent();
3394  if (d->timerID <= -1)
3395  QMetaObject::invokeMethod(d, "startAnimationTimer", Qt::QueuedConnection);
3396  }
3397  // Unlike Carbon, we want the button to always be drawn inside its bounds.
3398  // Therefore, make the button a bit smaller, so that even if it got focus,
3399  // the focus 'shadow' will be inside.
3400  HIRect newRect = qt_hirectForQRect(btn->rect);
3401  if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) {
3402  newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset;
3403  newRect.origin.y += QMacStylePrivate::PushButtonTopOffset;
3404  newRect.size.width -= QMacStylePrivate::PushButtonRightOffset;
3405  newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset;
3406  } else if (bdi.kind == kThemePushButtonMini) {
3407  newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset - 2;
3408  newRect.origin.y += QMacStylePrivate::PushButtonTopOffset;
3409  newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4;
3410  }
3411  HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
3412 
3413  if (btn->features & QStyleOptionButton::HasMenu) {
3414  int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
3415  QRect ir = btn->rect;
3416  HIRect arrowRect = CGRectMake(ir.right() - mbi - QMacStylePrivate::PushButtonRightOffset,
3417  ir.height() / 2 - 4, mbi, ir.height() / 2);
3418  bool drawColorless = btn->palette.currentColorGroup() == QPalette::Active;
3419  if (drawColorless && tds == kThemeStateInactive)
3420  tds = kThemeStateActive;
3421 
3422  HIThemePopupArrowDrawInfo pdi;
3423  pdi.version = qt_mac_hitheme_version;
3424  pdi.state = tds;
3425  pdi.orientation = kThemeArrowDown;
3426  if (arrowRect.size.width < 8.)
3427  pdi.size = kThemeArrow5pt;
3428  else
3429  pdi.size = kThemeArrow9pt;
3430  HIThemeDrawPopupArrow(&arrowRect, &pdi, cg, kHIThemeOrientationNormal);
3431  }
3432  }
3433  break;
3434  case CE_PushButtonLabel:
3435  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
3436  // We really don't want the label to be drawn the same as on
3437  // windows style if it has an icon and text, then it should be more like a
3438  // tab. So, cheat a little here. However, if it *is* only an icon
3439  // the windows style works great, so just use that implementation.
3440  bool hasMenu = btn->features & QStyleOptionButton::HasMenu;
3441  bool hasIcon = !btn->icon.isNull();
3442  bool hasText = !btn->text.isEmpty();
3443  if (!hasIcon && !hasMenu) {
3444  // ### this is really overly difficult, simplify.
3445  // It basically tries to get the right font for "small" and "mini" icons.
3446  QFont oldFont = p->font();
3447  QFont newFont = qt_app_fonts_hash()->value("QPushButton", QFont());
3448  ThemeFontID themeId = kThemePushButtonFont;
3449  if (oldFont == newFont) { // Yes, use HITheme to draw the text for small sizes.
3450  switch (d->aquaSizeConstrain(opt, w)) {
3451  default:
3452  break;
3453  case QAquaSizeSmall:
3454  themeId = kThemeSmallSystemFont;
3455  break;
3456  case QAquaSizeMini:
3457  themeId = kThemeMiniSystemFont;
3458  break;
3459  }
3460  }
3461  if (themeId == kThemePushButtonFont) {
3462  QWindowsStyle::drawControl(ce, btn, p, w);
3463  } else {
3464  p->save();
3465  CGContextSetShouldAntialias(cg, true);
3466  CGContextSetShouldSmoothFonts(cg, true);
3467  HIThemeTextInfo tti;
3468  tti.version = qt_mac_hitheme_version;
3469  tti.state = tds;
3470  QColor textColor = btn->palette.buttonText().color();
3471  CGFloat colorComp[] = { textColor.redF(), textColor.greenF(),
3472  textColor.blueF(), textColor.alphaF() };
3473  CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace());
3474  CGContextSetFillColor(cg, colorComp);
3475  tti.fontID = themeId;
3476  tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter;
3477  tti.verticalFlushness = kHIThemeTextVerticalFlushCenter;
3478  tti.options = kHIThemeTextBoxOptionNone;
3479  tti.truncationPosition = kHIThemeTextTruncationNone;
3480  tti.truncationMaxLines = 1 + btn->text.count(QLatin1Char('\n'));
3481  QCFString buttonText = qt_mac_removeMnemonics(btn->text);
3482  QRect r = btn->rect;
3483  HIRect bounds = qt_hirectForQRect(r);
3484  HIThemeDrawTextBox(buttonText, &bounds, &tti,
3485  cg, kHIThemeOrientationNormal);
3486  p->restore();
3487  }
3488  } else {
3489  if (hasIcon && !hasText) {
3490  QWindowsStyle::drawControl(ce, btn, p, w);
3491  } else {
3492  QRect freeContentRect = btn->rect;
3493  QRect textRect = itemTextRect(
3494  btn->fontMetrics, freeContentRect, Qt::AlignCenter, btn->state & State_Enabled, btn->text);
3495  if (hasMenu)
3496  textRect.adjust(-1, 0, -1, 0);
3497  // Draw the icon:
3498  if (hasIcon) {
3499  int contentW = textRect.width();
3500  if (hasMenu)
3501  contentW += proxy()->pixelMetric(PM_MenuButtonIndicator) + 4;
3502  QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
3503  if (mode == QIcon::Normal && btn->state & State_HasFocus)
3504  mode = QIcon::Active;
3505  // Decide if the icon is should be on or off:
3506  QIcon::State state = QIcon::Off;
3507  if (btn->state & State_On)
3508  state = QIcon::On;
3509  QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state);
3510  contentW += pixmap.width() + QMacStylePrivate::PushButtonContentPadding;
3511  int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2;
3512  int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2;
3513  QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height());
3514  QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect);
3515  proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap);
3516  int newOffset = iconDestRect.x() + iconDestRect.width()
3518  textRect.adjust(newOffset, 0, newOffset, 0);
3519  }
3520  // Draw the text:
3521  if (hasText) {
3522  textRect = visualRect(btn->direction, freeContentRect, textRect);
3523  proxy()->drawItemText(p, textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, btn->palette,
3524  (btn->state & State_Enabled), btn->text, QPalette::ButtonText);
3525  }
3526  }
3527  }
3528  }
3529  break;
3530  case CE_ComboBoxLabel:
3531  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
3532  QStyleOptionComboBox comboCopy = *cb;
3533  comboCopy.direction = Qt::LeftToRight;
3534  QWindowsStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w);
3535  }
3536  break;
3537  case CE_TabBarTabShape:
3538  if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
3539 
3540  if (const QStyleOptionTabV3 *tabOptV3 = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
3541  if (tabOptV3->documentMode) {
3542  p->save();
3543  QRect tabRect = tabOptV3->rect;
3544  drawTabShape(p, tabOptV3);
3545  p->restore();
3546  return;
3547  }
3548  }
3549  HIThemeTabDrawInfo tdi;
3550  tdi.version = 1;
3551  tdi.style = kThemeTabNonFront;
3552  tdi.direction = getTabDirection(tabOpt->shape);
3553  switch (d->aquaSizeConstrain(opt, w)) {
3554  default:
3555  case QAquaSizeUnknown:
3556  case QAquaSizeLarge:
3557  tdi.size = kHIThemeTabSizeNormal;
3558  break;
3559  case QAquaSizeSmall:
3560  tdi.size = kHIThemeTabSizeSmall;
3561  break;
3562  case QAquaSizeMini:
3563  tdi.size = kHIThemeTabSizeMini;
3564  break;
3565  }
3566  bool verticalTabs = tdi.direction == kThemeTabWest || tdi.direction == kThemeTabEast;
3567  QRect tabRect = tabOpt->rect;
3568 
3569  bool selected = tabOpt->state & State_Selected;
3570  if (selected) {
3571  if (!(tabOpt->state & State_Active))
3572  tdi.style = kThemeTabFrontUnavailable;
3573  else if (!(tabOpt->state & State_Enabled))
3574  tdi.style = kThemeTabFrontInactive;
3575  else
3576  tdi.style = kThemeTabFront;
3577  } else if (!(tabOpt->state & State_Active)) {
3578  tdi.style = kThemeTabNonFrontUnavailable;
3579  } else if (!(tabOpt->state & State_Enabled)) {
3580  tdi.style = kThemeTabNonFrontInactive;
3581  } else if (tabOpt->state & State_Sunken) {
3582  tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed)
3583  }
3584  if (tabOpt->state & State_HasFocus)
3585  tdi.adornment = kHIThemeTabAdornmentFocus;
3586  else
3587  tdi.adornment = kHIThemeTabAdornmentNone;
3588  tdi.kind = kHIThemeTabKindNormal;
3589  if (!verticalTabs)
3590  tabRect.setY(tabRect.y() - 1);
3591  else
3592  tabRect.setX(tabRect.x() - 1);
3593  QStyleOptionTab::TabPosition tp = tabOpt->position;
3594  QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition;
3595  if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) {
3598  else if (sp == QStyleOptionTab::PreviousIsSelected)
3600  switch (tp) {
3602  tp = QStyleOptionTab::End;
3603  break;
3604  case QStyleOptionTab::End:
3606  break;
3607  default:
3608  break;
3609  }
3610  }
3611  bool stretchTabs = (!verticalTabs && tabRect.height() > 22) || (verticalTabs && tabRect.width() > 22);
3612 
3613  switch (tp) {
3615  tdi.position = kHIThemeTabPositionFirst;
3616  if (sp != QStyleOptionTab::NextIsSelected || stretchTabs)
3617  tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
3618  break;
3620  tdi.position = kHIThemeTabPositionMiddle;
3621  if (selected)
3622  tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
3623  if (sp != QStyleOptionTab::NextIsSelected || stretchTabs) // Also when we're selected.
3624  tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
3625  break;
3626  case QStyleOptionTab::End:
3627  tdi.position = kHIThemeTabPositionLast;
3628  if (selected)
3629  tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator;
3630  break;
3632  tdi.position = kHIThemeTabPositionOnly;
3633  break;
3634  }
3635  // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves.
3636  if (stretchTabs) {
3637  HIRect hirect = CGRectMake(0, 0, 23, 23);
3638  QPixmap pm(23, 23);
3639  pm.fill(Qt::transparent);
3640  {
3641  QMacCGContext pmcg(&pm);
3642  HIThemeDrawTab(&hirect, &tdi, pmcg, kHIThemeOrientationNormal, 0);
3643  }
3644  QStyleHelper::drawBorderPixmap(pm, p, tabRect, 7, 7, 7, 7);
3645  } else {
3646  HIRect hirect = qt_hirectForQRect(tabRect);
3647  HIThemeDrawTab(&hirect, &tdi, cg, kHIThemeOrientationNormal, 0);
3648  }
3649  }
3650  break;
3651  case CE_TabBarTabLabel:
3652  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
3653  QStyleOptionTabV3 myTab = *tab;
3654  ThemeTabDirection ttd = getTabDirection(myTab.shape);
3655  bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
3656  bool selected = (myTab.state & QStyle::State_Selected);
3657  bool usingModernOSX = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6;
3658 
3659  if (usingModernOSX && selected && !myTab.documentMode)
3661 
3662  // Check to see if we use have the same as the system font
3663  // (QComboMenuItem is internal and should never be seen by the
3664  // outside world, unless they read the source, in which case, it's
3665  // their own fault).
3666  bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem");
3667  if ((usingModernOSX && selected) || verticalTabs || nonDefaultFont || !tab->icon.isNull()
3668  || !myTab.leftButtonSize.isNull() || !myTab.rightButtonSize.isNull()) {
3669  int heightOffset = 0;
3670  if (verticalTabs) {
3671  heightOffset = -1;
3672  } else if (nonDefaultFont) {
3673  if (p->fontMetrics().height() == myTab.rect.height())
3674  heightOffset = 2;
3675  }
3676  myTab.rect.setHeight(myTab.rect.height() + heightOffset);
3677 
3678  if (myTab.documentMode || (usingModernOSX && selected)) {
3679  p->save();
3680  rotateTabPainter(p, myTab.shape, myTab.rect);
3681 
3682  QColor shadowColor = QColor(myTab.documentMode ? Qt::white : Qt::black);
3683  shadowColor.setAlpha(75);
3684  QPalette np = tab->palette;
3685  np.setColor(QPalette::WindowText, shadowColor);
3686 
3687  QRect nr = subElementRect(SE_TabBarTabText, opt, w);
3688  nr.moveTop(-1);
3690  proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled,
3691  tab->text, QPalette::WindowText);
3692  p->restore();
3693  }
3694 
3695  QCommonStyle::drawControl(ce, &myTab, p, w);
3696  } else {
3697  p->save();
3698  CGContextSetShouldAntialias(cg, true);
3699  CGContextSetShouldSmoothFonts(cg, true);
3700  HIThemeTextInfo tti;
3701  tti.version = qt_mac_hitheme_version;
3702  tti.state = tds;
3703  QColor textColor = myTab.palette.windowText().color();
3704  CGFloat colorComp[] = { textColor.redF(), textColor.greenF(),
3705  textColor.blueF(), textColor.alphaF() };
3706  CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace());
3707  CGContextSetFillColor(cg, colorComp);
3708  switch (d->aquaSizeConstrain(opt, w)) {
3709  default:
3710  case QAquaSizeUnknown:
3711  case QAquaSizeLarge:
3712  tti.fontID = kThemeSystemFont;
3713  break;
3714  case QAquaSizeSmall:
3715  tti.fontID = kThemeSmallSystemFont;
3716  break;
3717  case QAquaSizeMini:
3718  tti.fontID = kThemeMiniSystemFont;
3719  break;
3720  }
3721  tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter;
3722  tti.verticalFlushness = kHIThemeTextVerticalFlushCenter;
3723  tti.options = verticalTabs ? kHIThemeTextBoxOptionStronglyVertical : kHIThemeTextBoxOptionNone;
3724  tti.truncationPosition = kHIThemeTextTruncationNone;
3725  tti.truncationMaxLines = 1 + myTab.text.count(QLatin1Char('\n'));
3726  QCFString tabText = qt_mac_removeMnemonics(myTab.text);
3727  QRect r = myTab.rect.adjusted(0, 0, 0, -1);
3728  HIRect bounds = qt_hirectForQRect(r);
3729  HIThemeDrawTextBox(tabText, &bounds, &tti, cg, kHIThemeOrientationNormal);
3730  p->restore();
3731  }
3732  }
3733  break;
3734  case CE_DockWidgetTitle:
3735  if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(w)) {
3736  bool floating = dockWidget->isFloating();
3737  if (floating) {
3738  ThemeDrawState tds = d->getDrawState(opt->state);
3739  HIThemeWindowDrawInfo wdi;
3740  wdi.version = qt_mac_hitheme_version;
3741  wdi.state = tds;
3742  wdi.windowType = kThemeMovableDialogWindow;
3743  wdi.titleHeight = opt->rect.height();
3744  wdi.titleWidth = opt->rect.width();
3745  wdi.attributes = 0;
3746 
3747  HIRect titleBarRect;
3748  HIRect tmpRect = qt_hirectForQRect(opt->rect);
3749  {
3750  QCFType<HIShapeRef> titleRegion;
3751  QRect newr = opt->rect.adjusted(0, 0, 2, 0);
3752  HIThemeGetWindowShape(&tmpRect, &wdi, kWindowTitleBarRgn, &titleRegion);
3753  ptrHIShapeGetBounds(titleRegion, &tmpRect);
3754  newr.translate(newr.x() - int(tmpRect.origin.x), newr.y() - int(tmpRect.origin.y));
3755  titleBarRect = qt_hirectForQRect(newr);
3756  }
3757  QMacCGContext cg(p);
3758  HIThemeDrawWindowFrame(&titleBarRect, &wdi, cg, kHIThemeOrientationNormal, 0);
3759  } else {
3760  // fill title bar background
3761  QLinearGradient linearGrad(0, opt->rect.top(), 0, opt->rect.bottom());
3762  linearGrad.setColorAt(0, mainWindowGradientBegin);
3763  linearGrad.setColorAt(1, mainWindowGradientEnd);
3764  p->fillRect(opt->rect, linearGrad);
3765 
3766  // draw horizontal lines at top and bottom
3767  p->save();
3769  p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
3771  p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
3772  p->restore();
3773  }
3774  }
3775 
3776  // Draw the text...
3777  if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
3778  if (!dwOpt->title.isEmpty()) {
3779  const QStyleOptionDockWidgetV2 *v2
3781  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
3782 
3783  QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, w);
3784  if (verticalTitleBar) {
3785  QRect rect = dwOpt->rect;
3786  QRect r = rect;
3787  QSize s = r.size();
3788  s.transpose();
3789  r.setSize(s);
3790 
3791  titleRect = QRect(r.left() + rect.bottom()
3792  - titleRect.bottom(),
3793  r.top() + titleRect.left() - rect.left(),
3794  titleRect.height(), titleRect.width());
3795 
3796  p->translate(r.left(), r.top() + r.width());
3797  p->rotate(-90);
3798  p->translate(-r.left(), -r.top());
3799  }
3800 
3801  QFont oldFont = p->font();
3802  p->setFont(qt_app_fonts_hash()->value("QToolButton", p->font()));
3803  QString text = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
3804  titleRect.width());
3805  drawItemText(p, titleRect,
3806  Qt::AlignCenter | Qt::TextShowMnemonic, dwOpt->palette,
3807  dwOpt->state & State_Enabled, text,
3809  p->setFont(oldFont);
3810  }
3811  }
3812  break;
3813  case CE_FocusFrame: {
3814  int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1;
3815  int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1;
3816  HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
3817  opt->rect.height() - 2 * yOff);
3818  HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal);
3819  break; }
3820  case CE_MenuItem:
3821  case CE_MenuEmptyArea:
3822  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3823  p->fillRect(mi->rect, opt->palette.background());
3824  QAquaWidgetSize widgetSize = d->aquaSizeConstrain(opt, w);
3825  int tabwidth = mi->tabWidth;
3826  int maxpmw = mi->maxIconWidth;
3827  bool active = mi->state & State_Selected;
3828  bool enabled = mi->state & State_Enabled;
3829  HIRect menuRect = qt_hirectForQRect(mi->menuRect);
3830  HIRect itemRect = qt_hirectForQRect(mi->rect);
3831  HIThemeMenuItemDrawInfo mdi;
3832  mdi.version = qt_mac_hitheme_version;
3833  mdi.itemType = kThemeMenuItemPlain;
3834  if (!mi->icon.isNull())
3835  mdi.itemType |= kThemeMenuItemHasIcon;
3836  if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
3837  mdi.itemType |= kThemeMenuItemHierarchical | kThemeMenuItemHierBackground;
3838  else
3839  mdi.itemType |= kThemeMenuItemPopUpBackground;
3840  if (enabled)
3841  mdi.state = kThemeMenuActive;
3842  else
3843  mdi.state = kThemeMenuDisabled;
3844  if (active)
3845  mdi.state |= kThemeMenuSelected;
3846  QRect contentRect;
3847  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
3848  // First arg should be &menurect, but wacky stuff happens then.
3849  HIThemeDrawMenuSeparator(&itemRect, &itemRect, &mdi,
3850  cg, kHIThemeOrientationNormal);
3851  break;
3852  } else {
3853  HIRect cr;
3854  bool needAlpha = mi->palette.color(QPalette::Button) == Qt::transparent;
3855  if (needAlpha) {
3856  needAlpha = true;
3857  CGContextSaveGState(cg);
3858  CGContextSetAlpha(cg, 0.0);
3859  }
3860  HIThemeDrawMenuItem(&menuRect, &itemRect, &mdi,
3861  cg, kHIThemeOrientationNormal, &cr);
3862  if (needAlpha)
3863  CGContextRestoreGState(cg);
3864  if (ce == CE_MenuEmptyArea)
3865  break;
3866  contentRect = qt_qrectForHIRect(cr);
3867  }
3868  int xpos = contentRect.x() + 18;
3869  int checkcol = maxpmw;
3870  if (!enabled)
3871  p->setPen(mi->palette.text().color());
3872  else if (active)
3873  p->setPen(mi->palette.highlightedText().color());
3874  else
3875  p->setPen(mi->palette.buttonText().color());
3876 
3877  if (mi->checked) {
3878  // Use the HIThemeTextInfo foo to draw the check mark correctly, if we do it,
3879  // we somehow need to use a special encoding as it doesn't look right with our
3880  // drawText().
3881  p->save();
3882  CGContextSetShouldAntialias(cg, true);
3883  CGContextSetShouldSmoothFonts(cg, true);
3884  QColor textColor = p->pen().color();
3885  CGFloat colorComp[] = { textColor.redF(), textColor.greenF(),
3886  textColor.blueF(), textColor.alphaF() };
3887  CGContextSetFillColorSpace(cg, QCoreGraphicsPaintEngine::macGenericColorSpace());
3888  CGContextSetFillColor(cg, colorComp);
3889  HIThemeTextInfo tti;
3890  tti.version = qt_mac_hitheme_version;
3891  tti.state = tds;
3892  if (active && enabled)
3893  tti.state = kThemeStatePressed;
3894  switch (widgetSize) {
3895  case QAquaSizeUnknown:
3896  case QAquaSizeLarge:
3897  tti.fontID = kThemeMenuItemMarkFont;
3898  break;
3899  case QAquaSizeSmall:
3900  tti.fontID = kThemeSmallSystemFont;
3901  break;
3902  case QAquaSizeMini:
3903  tti.fontID = kThemeMiniSystemFont;
3904  break;
3905  }
3906  tti.horizontalFlushness = kHIThemeTextHorizontalFlushLeft;
3907  tti.verticalFlushness = kHIThemeTextVerticalFlushCenter;
3908  tti.options = kHIThemeTextBoxOptionNone;
3909  tti.truncationPosition = kHIThemeTextTruncationNone;
3910  tti.truncationMaxLines = 1;
3911  QCFString checkmark;
3912 #if 0
3913  if (mi->checkType == QStyleOptionMenuItem::Exclusive)
3914  checkmark = QString(QChar(kDiamondUnicode));
3915  else
3916 #endif
3917  checkmark = QString(QChar(kCheckUnicode));
3918  int mw = checkcol + macItemFrame;
3919  int mh = contentRect.height() - 2 * macItemFrame;
3920  int xp = contentRect.x();
3921  xp += macItemFrame;
3922  CGFloat outWidth, outHeight, outBaseline;
3923  HIThemeGetTextDimensions(checkmark, 0, &tti, &outWidth, &outHeight,
3924  &outBaseline);
3925  if (widgetSize == QAquaSizeMini)
3926  outBaseline += 1;
3927  QRect r(xp, contentRect.y(), mw, mh);
3928  r.translate(0, p->fontMetrics().ascent() - int(outBaseline) + 1);
3929  HIRect bounds = qt_hirectForQRect(r);
3930  HIThemeDrawTextBox(checkmark, &bounds, &tti,
3931  cg, kHIThemeOrientationNormal);
3932  p->restore();
3933  }
3934  if (!mi->icon.isNull()) {
3935  QIcon::Mode mode = (mi->state & State_Enabled) ? QIcon::Normal
3936  : QIcon::Disabled;
3937  // Always be normal or disabled to follow the Mac style.
3938  int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize);
3939  QSize iconSize(smallIconSize, smallIconSize);
3940  if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) {
3941  iconSize = comboBox->iconSize();
3942  }
3943  QPixmap pixmap = mi->icon.pixmap(iconSize, mode);
3944  int pixw = pixmap.width();
3945  int pixh = pixmap.height();
3946  QRect cr(xpos, contentRect.y(), checkcol, contentRect.height());
3947  QRect pmr(0, 0, pixw, pixh);
3948  pmr.moveCenter(cr.center());
3949  p->drawPixmap(pmr.topLeft(), pixmap);
3950  xpos += pixw + 6;
3951  }
3952 
3953  QString s = mi->text;
3954  if (!s.isEmpty()) {
3955  int t = s.indexOf(QLatin1Char('\t'));
3958  int yPos = contentRect.y();
3959  if (widgetSize == QAquaSizeMini)
3960  yPos += 1;
3961  p->save();
3962  if (t >= 0) {
3963  p->setFont(qt_app_fonts_hash()->value("QMenuItem", p->font()));
3964  int xp = contentRect.right() - tabwidth - macRightBorder
3965  - macItemHMargin - macItemFrame + 1;
3966  p->drawText(xp, yPos, tabwidth, contentRect.height(), text_flags,
3967  s.mid(t + 1));
3968  s = s.left(t);
3969  }
3970 
3971  const int xm = macItemFrame + maxpmw + macItemHMargin;
3972  QFont myFont = mi->font;
3973  // myFont may not have any "hard" flags set. We override
3974  // the point size so that when it is resolved against the device, this font will win.
3975  // This is mainly to handle cases where someone sets the font on the window
3976  // and then the combo inherits it and passes it onward. At that point the resolve mask
3977  // is very, very weak. This makes it stonger.
3978  myFont.setPointSizeF(QFontInfo(mi->font).pointSizeF());
3979  p->setFont(myFont);
3980  p->drawText(xpos, yPos, contentRect.width() - xm - tabwidth + 1,
3981  contentRect.height(), text_flags ^ Qt::AlignRight, s);
3982  p->restore();
3983  }
3984  }
3985  break;
3986  case CE_MenuHMargin:
3987  case CE_MenuVMargin:
3988  case CE_MenuTearoff:
3989  case CE_MenuScroller:
3990  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
3991  p->fillRect(mi->rect, opt->palette.background());
3992 
3993  HIRect menuRect = qt_hirectForQRect(mi->menuRect);
3994  HIRect itemRect = qt_hirectForQRect(mi->rect);
3995  HIThemeMenuItemDrawInfo mdi;
3996  mdi.version = qt_mac_hitheme_version;
3997  if (!(opt->state & State_Enabled))
3998  mdi.state = kThemeMenuDisabled;
3999  else if (opt->state & State_Selected)
4000  mdi.state = kThemeMenuSelected;
4001  else
4002  mdi.state = kThemeMenuActive;
4003  if (ce == CE_MenuScroller) {
4004  if (opt->state & State_DownArrow)
4005  mdi.itemType = kThemeMenuItemScrollDownArrow;
4006  else
4007  mdi.itemType = kThemeMenuItemScrollUpArrow;
4008  } else {
4009  mdi.itemType = kThemeMenuItemPlain;
4010  }
4011  HIThemeDrawMenuItem(&menuRect, &itemRect, &mdi,
4012  cg,
4013  kHIThemeOrientationNormal, 0);
4014  if (ce == CE_MenuTearoff) {
4015  p->setPen(QPen(mi->palette.dark().color(), 1, Qt::DashLine));
4016  p->drawLine(mi->rect.x() + 2, mi->rect.y() + mi->rect.height() / 2 - 1,
4017  mi->rect.x() + mi->rect.width() - 4,
4018  mi->rect.y() + mi->rect.height() / 2 - 1);
4019  p->setPen(QPen(mi->palette.light().color(), 1, Qt::DashLine));
4020  p->drawLine(mi->rect.x() + 2, mi->rect.y() + mi->rect.height() / 2,
4021  mi->rect.x() + mi->rect.width() - 4,
4022  mi->rect.y() + mi->rect.height() / 2);
4023  }
4024  }
4025  break;
4026  case CE_MenuBarItem:
4027  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4028  HIRect menuRect = qt_hirectForQRect(mi->menuRect);
4029  HIRect itemRect = qt_hirectForQRect(mi->rect);
4030 
4031  if ((opt->state & State_Selected) && (opt->state & State_Enabled) && (opt->state & State_Sunken)){
4032  // Draw a selected menu item background:
4033  HIThemeMenuItemDrawInfo mdi;
4034  mdi.version = qt_mac_hitheme_version;
4035  mdi.state = kThemeMenuSelected;
4036  mdi.itemType = kThemeMenuItemPlain;
4037  HIThemeDrawMenuItem(&menuRect, &itemRect, &mdi, cg, kHIThemeOrientationNormal, 0);
4038  } else {
4039  // Draw the toolbar background:
4040  HIThemeMenuBarDrawInfo bdi;
4041  bdi.version = qt_mac_hitheme_version;
4042  bdi.state = kThemeMenuBarNormal;
4043  bdi.attributes = 0;
4044  HIThemeDrawMenuBarBackground(&menuRect, &bdi, cg, kHIThemeOrientationNormal);
4045  }
4046 
4047  if (!mi->icon.isNull()) {
4048  drawItemPixmap(p, mi->rect,
4051  mi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize),
4052  (mi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled));
4053  } else {
4054  drawItemText(p, mi->rect,
4057  mi->palette, mi->state & State_Enabled,
4058  mi->text, QPalette::ButtonText);
4059  }
4060  }
4061  break;
4062  case CE_MenuBarEmptyArea:
4063  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4064  HIThemeMenuBarDrawInfo bdi;
4065  bdi.version = qt_mac_hitheme_version;
4066  bdi.state = kThemeMenuBarNormal;
4067  bdi.attributes = 0;
4068  HIRect hirect = qt_hirectForQRect(mi->rect);
4069  HIThemeDrawMenuBarBackground(&hirect, &bdi, cg,
4070  kHIThemeOrientationNormal);
4071  break;
4072  }
4074  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
4075  HIThemeTrackDrawInfo tdi;
4076  tdi.version = qt_mac_hitheme_version;
4077  tdi.reserved = 0;
4078  bool isIndeterminate = (pb->minimum == 0 && pb->maximum == 0);
4079  bool vertical = false;
4080  bool inverted = false;
4081  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
4082  vertical = (pb2->orientation == Qt::Vertical);
4083  inverted = pb2->invertedAppearance;
4084  }
4085  bool reverse = (!vertical && (pb->direction == Qt::RightToLeft));
4086  if (inverted)
4087  reverse = !reverse;
4088  switch (d->aquaSizeConstrain(opt, w)) {
4089  case QAquaSizeUnknown:
4090  case QAquaSizeLarge:
4091  tdi.kind = !isIndeterminate ? kThemeLargeProgressBar
4092  : kThemeLargeIndeterminateBar;
4093  break;
4094  case QAquaSizeMini:
4095  case QAquaSizeSmall:
4096  tdi.kind = !isIndeterminate ? kThemeProgressBar : kThemeIndeterminateBar;
4097  break;
4098  }
4099  tdi.bounds = qt_hirectForQRect(pb->rect);
4100  tdi.max = pb->maximum;
4101  tdi.min = pb->minimum;
4102  tdi.value = pb->progress;
4103  tdi.attributes = vertical ? 0 : kThemeTrackHorizontal;
4104  tdi.trackInfo.progress.phase = d->progressFrame;
4105  if (!(pb->state & State_Active))
4106  tdi.enableState = kThemeTrackInactive;
4107  else if (!(pb->state & State_Enabled))
4108  tdi.enableState = kThemeTrackDisabled;
4109  else
4110  tdi.enableState = kThemeTrackActive;
4111  HIThemeOrientation drawOrientation = kHIThemeOrientationNormal;
4112  if (reverse) {
4113  if (vertical) {
4114  drawOrientation = kHIThemeOrientationInverted;
4115  } else {
4116  CGContextSaveGState(cg);
4117  CGContextTranslateCTM(cg, pb->rect.width(), 0);
4118  CGContextScaleCTM(cg, -1, 1);
4119  }
4120  }
4121  HIThemeDrawTrack(&tdi, 0, cg, drawOrientation);
4122  if (reverse && !vertical)
4123  CGContextRestoreGState(cg);
4124  }
4125  break;
4126  case CE_ProgressBarLabel:
4127  case CE_ProgressBarGroove:
4128  break;
4129  case CE_SizeGrip: {
4130  if (w && w->testAttribute(Qt::WA_MacOpaqueSizeGrip)) {
4131  HIThemeGrowBoxDrawInfo gdi;
4132  gdi.version = qt_mac_hitheme_version;
4133  gdi.state = tds;
4134  gdi.kind = kHIThemeGrowBoxKindNormal;
4135  gdi.direction = kThemeGrowRight | kThemeGrowDown;
4136  gdi.size = kHIThemeGrowBoxSizeNormal;
4137  HIPoint pt = CGPointMake(opt->rect.x(), opt->rect.y());
4138  HIThemeDrawGrowBox(&pt, &gdi, cg, kHIThemeOrientationNormal);
4139  } else {
4140  // It isn't possible to draw a transparent size grip with the
4141  // native API, so we do it ourselves here.
4142  const bool metal = qt_mac_is_metal(w);
4143  QPen lineColor = metal ? QColor(236, 236, 236) : QColor(82, 82, 82, 192);
4144  QPen metalHighlight = QColor(5, 5, 5, 192);
4145  lineColor.setWidth(1);
4146  p->save();
4148  p->setPen(lineColor);
4149  const Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : qApp->layoutDirection();
4150  const int NumLines = metal ? 4 : 3;
4151  for (int l = 0; l < NumLines; ++l) {
4152  const int offset = (l * 4 + (metal ? 2 : 3));
4153  QPoint start, end;
4154  if (layoutDirection == Qt::LeftToRight) {
4155  start = QPoint(opt->rect.width() - offset, opt->rect.height() - 1);
4156  end = QPoint(opt->rect.width() - 1, opt->rect.height() - offset);
4157  } else {
4158  start = QPoint(offset, opt->rect.height() - 1);
4159  end = QPoint(1, opt->rect.height() - offset);
4160  }
4161  p->drawLine(start, end);
4162  if (metal) {
4163  p->setPen(metalHighlight);
4165  p->drawLine(start + QPoint(0, -1), end + QPoint(0, -1));
4167  p->setPen(lineColor);
4168  }
4169  }
4170  p->restore();
4171  }
4172  break;
4173  }
4174  case CE_Splitter: {
4175  HIThemeSplitterDrawInfo sdi;
4176  sdi.version = qt_mac_hitheme_version;
4177  sdi.state = tds;
4178  sdi.adornment = qt_mac_is_metal(w) ? kHIThemeSplitterAdornmentMetal
4179  : kHIThemeSplitterAdornmentNone;
4180  HIRect hirect = qt_hirectForQRect(opt->rect);
4181  HIThemeDrawPaneSplitter(&hirect, &sdi, cg, kHIThemeOrientationNormal);
4182  break; }
4183  case CE_RubberBand:
4184  if (const QStyleOptionRubberBand *rubber = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
4185  QColor fillColor(opt->palette.color(QPalette::Disabled, QPalette::Highlight));
4186  if (!rubber->opaque) {
4187  QColor strokeColor;
4188  // I retrieved these colors from the Carbon-Dev mailing list
4189  strokeColor.setHsvF(0, 0, 0.86, 1.0);
4190  fillColor.setHsvF(0, 0, 0.53, 0.25);
4191  if (opt->rect.width() * opt->rect.height() <= 3) {
4192  p->fillRect(opt->rect, strokeColor);
4193  } else {
4194  QPen oldPen = p->pen();
4195  QBrush oldBrush = p->brush();
4196  QPen pen(strokeColor);
4197  p->setPen(pen);
4198  p->setBrush(fillColor);
4199  p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
4200  p->setPen(oldPen);
4201  p->setBrush(oldBrush);
4202  }
4203  } else {
4204  p->fillRect(opt->rect, fillColor);
4205  }
4206  }
4207  break;
4208  case CE_ToolBar: {
4209  // For unified tool bars, draw nothing.
4210  if (w) {
4211  if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) {
4212  if (mainWindow->unifiedTitleAndToolBarOnMac())
4213  break;
4214  }
4215  }
4216 
4217  // draw background gradient
4218  QLinearGradient linearGrad;
4219  if (opt->state & State_Horizontal)
4220  linearGrad = QLinearGradient(0, opt->rect.top(), 0, opt->rect.bottom());
4221  else
4222  linearGrad = QLinearGradient(opt->rect.left(), 0, opt->rect.right(), 0);
4223 
4224  linearGrad.setColorAt(0, mainWindowGradientBegin);
4225  linearGrad.setColorAt(1, mainWindowGradientEnd);
4226  p->fillRect(opt->rect, linearGrad);
4227 
4228  p->save();
4229  if (opt->state & State_Horizontal) {
4231  p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
4233  p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight());
4234 
4235  } else {
4237  p->drawLine(opt->rect.topLeft(), opt->rect.bottomLeft());
4239  p->drawLine(opt->rect.topRight(), opt->rect.bottomRight());
4240  }
4241  p->restore();
4242 
4243 
4244  } break;
4245  default:
4246  QWindowsStyle::drawControl(ce, opt, p, w);
4247  break;
4248  }
4249 }
const int qt_mac_hitheme_version
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
const int macRightBorder
QString qt_mac_removeMnemonics(const QString &original)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static CGColorSpaceRef macGenericColorSpace()
bool qt_mac_is_metal(const QWidget *w)
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
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
TabPosition
This enum describes the position of the tab.
Definition: qstyleoption.h:310
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
static QPixmap darkenPixmap(const QPixmap &pixmap)
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
void drawTabShape(QPainter *p, const QStyleOptionTabV3 *tabOpt)
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
virtual void drawItemText(QPainter *p, const QRect &r, 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.
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
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
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
static const QColor mainWindowGradientEnd(200, 200, 200)
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int pixelMetric(PixelMetric pm, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
SelectedPosition
This enum describes the position of the selected tab.
Definition: qstyleoption.h:311
static C reverse(const C &l)
static bool verticalTabs(QTabBar::Shape shape)
const int macItemHMargin
static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p)
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
static const int PushButtonBottomOffset
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QColor color() const
Returns the color of this pen&#39;s brush.
Definition: qpen.cpp:771
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
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
static QPalette palette()
Returns the application palette.
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
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
static const QRect qt_qrectForHIRect(const HIRect &hirect)
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QMacStylePrivate * d
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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
QTabBar::Shape shape
the tab shape used to draw the tab; by default QTabBar::RoundedNorth
Definition: qstyleoption.h:316
static const int PushButtonLeftOffset
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
static PtrHIShapeGetBounds ptrHIShapeGetBounds
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
int ascent() const
Returns the ascent of the font.
CFAbsoluteTime defaultButtonStart
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
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
void setHsvF(qreal h, qreal s, qreal v, qreal a=1.0)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition: qcolor.cpp:706
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
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
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool 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
#define qApp
static ThemeTabDirection getTabDirection(QTabBar::Shape shape)
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
static const QColor mainWindowGradientBegin(240, 240, 240)
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
QAquaWidgetSize
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
LayoutDirection
Definition: qnamespace.h:1580
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
FontHash * qt_app_fonts_hash()
The State element defines configurations of objects and properties.
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
The QFontInfo class provides general information about fonts.
Definition: qfontinfo.h:54
The QTableView class provides a default model/view implementation of a table view.
Definition: qtableview.h:58
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
int count() const
Definition: qstring.h:103
QSize rightButtonSize
the size for the right widget on the tab.
Definition: qstyleoption.h:353
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
bool documentMode
whether the tabbar is in document mode.
Definition: qstyleoption.h:351
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
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
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
Definition: qmainwindow.h:83
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
bool animatable(Animates, const QWidget *) const
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition: qpalette.h:124
QString text
the text of the tab
Definition: qstyleoption.h:317
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
static const int PushButtonTopOffset
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1117
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
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
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
qreal pointSizeF() const
Returns the point size of the matched window system font.
Definition: qfont.cpp:2710
The QStyleOptionTabV3 class is used to describe the parameters necessary for drawing a tabs in Qt 4...
Definition: qstyleoption.h:347
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
if(void) toggleToolbarShown
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFactoryLoader * l
static const int PushButtonContentPadding
static ThemeDrawState getDrawState(QStyle::State flags)
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, int left, int top, int right, int bottom)
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
static const int PushButtonRightOffset
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
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
ToolButtonStyle
Definition: qnamespace.h:1572
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
QSize leftButtonSize
the size for the left widget on the tab.
Definition: qstyleoption.h:352
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
int height() const
Returns the height of the font.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
static const KeyPair *const end
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define enabled
const int macItemFrame
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
#define text
Definition: qobjectdefs.h:80
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition: qpalette.h:129
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition: qpen.cpp:667
float CGFloat
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawItemText()

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

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

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

See also
Qt::Alignment, drawItemPixmap()

Reimplemented from QStyle.

Definition at line 5972 of file qmacstyle_mac.mm.

Referenced by drawComplexControl(), and drawControl().

5974 {
5975  if(flags & Qt::TextShowMnemonic)
5976  flags |= Qt::TextHideMnemonic;
5977  QWindowsStyle::drawItemText(p, r, flags, pal, enabled, text, textRole);
5978 }
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
#define enabled

◆ drawPrimitive()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2732 of file qmacstyle_mac.mm.

2734 {
2735  ThemeDrawState tds = d->getDrawState(opt->state);
2736  QMacCGContext cg(p);
2737  switch (pe) {
2738  case PE_IndicatorArrowUp:
2739  case PE_IndicatorArrowDown:
2741  case PE_IndicatorArrowLeft: {
2742  p->save();
2744  int xOffset = opt->direction == Qt::LeftToRight ? 2 : -1;
2745  QMatrix matrix;
2746  matrix.translate(opt->rect.center().x() + xOffset, opt->rect.center().y() + 2);
2747  QPainterPath path;
2748  switch(pe) {
2749  default:
2750  case PE_IndicatorArrowDown:
2751  break;
2752  case PE_IndicatorArrowUp:
2753  matrix.rotate(180);
2754  break;
2755  case PE_IndicatorArrowLeft:
2756  matrix.rotate(90);
2757  break;
2759  matrix.rotate(-90);
2760  break;
2761  }
2762  path.moveTo(0, 5);
2763  path.lineTo(-4, -3);
2764  path.lineTo(4, -3);
2765  p->setMatrix(matrix);
2766  p->setPen(Qt::NoPen);
2767  p->setBrush(QColor(0, 0, 0, 135));
2768  p->drawPath(path);
2769  p->restore();
2770  break; }
2771  case PE_FrameTabBarBase:
2772  if (const QStyleOptionTabBarBaseV2 *tbb
2773  = qstyleoption_cast<const QStyleOptionTabBarBaseV2 *>(opt)) {
2774  if (tbb->documentMode) {
2775  p->save();
2776  drawTabBase(p, tbb, w);
2777  p->restore();
2778  return;
2779  }
2780 
2781  QRegion region(tbb->rect);
2782  region -= tbb->tabBarRect;
2783  p->save();
2784  p->setClipRegion(region);
2786  twf.QStyleOption::operator=(*tbb);
2787  twf.shape = tbb->shape;
2788  switch (getTabDirection(twf.shape)) {
2789  case kThemeTabNorth:
2790  twf.rect = twf.rect.adjusted(0, 0, 0, 10);
2791  break;
2792  case kThemeTabSouth:
2793  twf.rect = twf.rect.adjusted(0, -10, 0, 0);
2794  break;
2795  case kThemeTabWest:
2796  twf.rect = twf.rect.adjusted(0, 0, 10, 0);
2797  break;
2798  case kThemeTabEast:
2799  twf.rect = twf.rect.adjusted(0, -10, 0, 0);
2800  break;
2801  }
2802  proxy()->drawPrimitive(PE_FrameTabWidget, &twf, p, w);
2803  p->restore();
2804  }
2805  break;
2806  case PE_PanelTipLabel:
2808  break;
2809  case PE_FrameGroupBox:
2810  if (const QStyleOptionFrame *groupBox = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2811  const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt);
2812  if (frame2 && frame2->features & QStyleOptionFrameV2::Flat) {
2813  QWindowsStyle::drawPrimitive(pe, groupBox, p, w);
2814  } else {
2815  HIThemeGroupBoxDrawInfo gdi;
2816  gdi.version = qt_mac_hitheme_version;
2817  gdi.state = tds;
2818  if (w && qobject_cast<QGroupBox *>(w->parentWidget()))
2819  gdi.kind = kHIThemeGroupBoxKindSecondary;
2820  else
2821  gdi.kind = kHIThemeGroupBoxKindPrimary;
2822  HIRect hirect = qt_hirectForQRect(opt->rect);
2823  HIThemeDrawGroupBox(&hirect, &gdi, cg, kHIThemeOrientationNormal);
2824  }
2825  }
2826  break;
2828  QPainterPath path;
2829  if (opt->state & State_Horizontal) {
2830  int xpoint = opt->rect.center().x();
2831  path.moveTo(xpoint + 0.5, opt->rect.top() + 1);
2832  path.lineTo(xpoint + 0.5, opt->rect.bottom());
2833  } else {
2834  int ypoint = opt->rect.center().y();
2835  path.moveTo(opt->rect.left() + 2 , ypoint + 0.5);
2836  path.lineTo(opt->rect.right() + 1, ypoint + 0.5);
2837  }
2838  QPainterPathStroker theStroker;
2839  theStroker.setCapStyle(Qt::FlatCap);
2840  theStroker.setDashPattern(QVector<qreal>() << 1 << 2);
2841  path = theStroker.createStroke(path);
2842  p->fillPath(path, QColor(0, 0, 0, 119));
2843  }
2844  break;
2845  case PE_FrameWindow:
2846  break;
2848  // The docwidget resize handle is drawn as a one-pixel wide line.
2849  p->save();
2850  if (opt->state & State_Horizontal) {
2851  p->setPen(QColor(160, 160, 160));
2852  p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
2853  } else {
2854  p->setPen(QColor(145, 145, 145));
2855  p->drawLine(opt->rect.topRight(), opt->rect.bottomRight());
2856  }
2857  p->restore();
2858  } break;
2860  p->save();
2861  QPainterPath path;
2862  int x = opt->rect.x() + 6;
2863  int y = opt->rect.y() + 5;
2864  static const int RectHeight = 2;
2865  if (opt->state & State_Horizontal) {
2866  while (y < opt->rect.height() - RectHeight - 6) {
2867  path.moveTo(x, y);
2868  path.addRect(x, y, RectHeight, RectHeight);
2869  y += 6;
2870  }
2871  } else {
2872  while (x < opt->rect.width() - RectHeight - 6) {
2873  path.moveTo(x, y);
2874  path.addRect(x, y, RectHeight, RectHeight);
2875  x += 6;
2876  }
2877  }
2878  p->setPen(Qt::NoPen);
2879  QColor dark = opt->palette.dark().color();
2880  dark.setAlphaF(0.75);
2881  QColor light = opt->palette.light().color();
2882  light.setAlphaF(0.6);
2883  p->fillPath(path, light);
2884  p->save();
2885  p->translate(1, 1);
2886  p->fillPath(path, dark);
2887  p->restore();
2888  p->translate(3, 3);
2889  p->fillPath(path, light);
2890  p->translate(1, 1);
2891  p->fillPath(path, dark);
2892  p->restore();
2893 
2894  break;
2895  }
2897  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2898  // In HITheme, up is down, down is up and hamburgers eat people.
2899  if (header->sortIndicator != QStyleOptionHeader::None)
2900  proxy()->drawPrimitive(
2901  (header->sortIndicator == QStyleOptionHeader::SortDown) ?
2902  PE_IndicatorArrowUp : PE_IndicatorArrowDown, header, p, w);
2903  }
2904  break;
2906  const int checkw = 8;
2907  const int checkh = 8;
2908  const int xoff = qMax(0, (opt->rect.width() - checkw) / 2);
2909  const int yoff = qMax(0, (opt->rect.width() - checkh) / 2);
2910  const int x1 = xoff + opt->rect.x();
2911  const int y1 = yoff + opt->rect.y() + checkw/2;
2912  const int x2 = xoff + opt->rect.x() + checkw/4;
2913  const int y2 = yoff + opt->rect.y() + checkh;
2914  const int x3 = xoff + opt->rect.x() + checkw;
2915  const int y3 = yoff + opt->rect.y();
2916 
2917  QVector<QLineF> a(2);
2918  a << QLineF(x1, y1, x2, y2);
2919  a << QLineF(x2, y2, x3, y3);
2920  if (opt->palette.currentColorGroup() == QPalette::Active) {
2921  if (opt->state & State_On)
2922  p->setPen(QPen(opt->palette.highlightedText().color(), 3));
2923  else
2924  p->setPen(QPen(opt->palette.text().color(), 3));
2925  } else {
2926  p->setPen(QPen(QColor(100, 100, 100), 3));
2927  }
2928  p->save();
2930  p->drawLines(a);
2931  p->restore();
2932  break; }
2937  case PE_IndicatorCheckBox: {
2938  bool drawColorless = (!(opt->state & State_Active))
2940  HIThemeButtonDrawInfo bdi;
2941  bdi.version = qt_mac_hitheme_version;
2942  bdi.state = tds;
2943  if (drawColorless && tds == kThemeStateInactive)
2944  bdi.state = kThemeStateActive;
2945  bdi.adornment = kThemeDrawIndicatorOnly;
2946  if (opt->state & State_HasFocus)
2947  bdi.adornment |= kThemeAdornmentFocus;
2948  bool isRadioButton = (pe == PE_Q3CheckListExclusiveIndicator
2949  || pe == PE_IndicatorRadioButton);
2950  switch (d->aquaSizeConstrain(opt, w)) {
2951  case QAquaSizeUnknown:
2952  case QAquaSizeLarge:
2953  if (isRadioButton)
2954  bdi.kind = kThemeRadioButton;
2955  else
2956  bdi.kind = kThemeCheckBox;
2957  break;
2958  case QAquaSizeMini:
2959  if (isRadioButton)
2960  bdi.kind = kThemeMiniRadioButton;
2961  else
2962  bdi.kind = kThemeMiniCheckBox;
2963  break;
2964  case QAquaSizeSmall:
2965  if (isRadioButton)
2966  bdi.kind = kThemeSmallRadioButton;
2967  else
2968  bdi.kind = kThemeSmallCheckBox;
2969  break;
2970  }
2971  if (opt->state & State_NoChange)
2972  bdi.value = kThemeButtonMixed;
2973  else if (opt->state & State_On)
2974  bdi.value = kThemeButtonOn;
2975  else
2976  bdi.value = kThemeButtonOff;
2977  HIRect macRect;
2979  macRect = qt_hirectForQRect(opt->rect);
2980  else
2981  macRect = qt_hirectForQRect(opt->rect);
2982  if (!drawColorless)
2983  HIThemeDrawButton(&macRect, &bdi, cg, kHIThemeOrientationNormal, 0);
2984  else
2985  d->drawColorlessButton(macRect, &bdi, p, opt);
2986  break; }
2987  case PE_FrameFocusRect:
2988  // Use the our own focus widget stuff.
2989  break;
2990  case PE_IndicatorBranch: {
2991  if (!(opt->state & State_Children))
2992  break;
2993  HIThemeButtonDrawInfo bi;
2994  bi.version = qt_mac_hitheme_version;
2995  bi.state = tds;
2996  if (tds == kThemeStateInactive && opt->palette.currentColorGroup() == QPalette::Active)
2997  bi.state = kThemeStateActive;
2998  if (opt->state & State_Sunken)
2999  bi.state |= kThemeStatePressed;
3000  bi.kind = kThemeDisclosureButton;
3001  if (opt->state & State_Open)
3002  bi.value = kThemeDisclosureDown;
3003  else
3004  bi.value = opt->direction == Qt::LeftToRight ? kThemeDisclosureRight : kThemeDisclosureLeft;
3005  bi.adornment = kThemeAdornmentNone;
3006  HIRect hirect = qt_hirectForQRect(opt->rect.adjusted(DisclosureOffset,0,-DisclosureOffset,0));
3007  HIThemeDrawButton(&hirect, &bi, cg, kHIThemeOrientationNormal, 0);
3008  break; }
3009 
3010  case PE_Frame: {
3011  QPen oldPen = p->pen();
3012  p->setPen(opt->palette.base().color().darker(140));
3013  p->drawRect(opt->rect.adjusted(0, 0, -1, -1));
3014  p->setPen(opt->palette.base().color().darker(180));
3015  p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
3016  p->setPen(oldPen);
3017  break; }
3018 
3019  case PE_FrameLineEdit:
3020  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
3021  if (frame->state & State_Sunken) {
3022  QColor baseColor(frame->palette.background().color());
3023  HIThemeFrameDrawInfo fdi;
3024  fdi.version = qt_mac_hitheme_version;
3025  fdi.state = tds;
3026  SInt32 frame_size;
3027  if (pe == PE_FrameLineEdit) {
3028  fdi.kind = kHIThemeFrameTextFieldSquare;
3029  GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
3030  if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
3031  fdi.state = kThemeStateInactive;
3032  } else {
3033  baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
3034  fdi.kind = kHIThemeFrameListBox;
3035  GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size);
3036  }
3037  fdi.isFocused = (frame->state & State_HasFocus);
3038  int lw = frame->lineWidth;
3039  if (lw <= 0)
3040  lw = proxy()->pixelMetric(PM_DefaultFrameWidth, frame, w);
3041  { //clear to base color
3042  p->save();
3043  p->setPen(QPen(baseColor, lw));
3044  p->setBrush(Qt::NoBrush);
3045  p->drawRect(frame->rect);
3046  p->restore();
3047  }
3048  HIRect hirect = qt_hirectForQRect(frame->rect,
3049  QRect(frame_size, frame_size,
3050  frame_size * 2, frame_size * 2));
3051 
3052  HIThemeDrawFrame(&hirect, &fdi, cg, kHIThemeOrientationNormal);
3053  } else {
3054  QWindowsStyle::drawPrimitive(pe, opt, p, w);
3055  }
3056  }
3057  break;
3058  case PE_PanelLineEdit:
3059  QWindowsStyle::drawPrimitive(pe, opt, p, w);
3060  // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit).
3061  // Focus frame is drawn outside the rectangle passed in the option-rect.
3062  if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
3063  if ((opt->state & State_HasFocus) && !qobject_cast<const QLineEdit*>(w)) {
3066  QStyleOptionFrame focusFrame = *panel;
3067  focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin);
3068  drawControl(CE_FocusFrame, &focusFrame, p, w);
3069  }
3070  }
3071 
3072  break;
3073  case PE_FrameTabWidget:
3074  if (const QStyleOptionTabWidgetFrame *twf
3075  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
3076  HIRect hirect = qt_hirectForQRect(twf->rect);
3077  HIThemeTabPaneDrawInfo tpdi;
3078  tpdi.version = qt_mac_hitheme_tab_version();
3079  tpdi.state = tds;
3080  tpdi.direction = getTabDirection(twf->shape);
3081  tpdi.size = kHIThemeTabSizeNormal;
3082  tpdi.kind = kHIThemeTabKindNormal;
3083  tpdi.adornment = kHIThemeTabPaneAdornmentNormal;
3084  HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal);
3085  }
3086  break;
3087  case PE_PanelScrollAreaCorner: {
3088  const QBrush brush(opt->palette.brush(QPalette::Base));
3089  p->fillRect(opt->rect, brush);
3090  p->setPen(QPen(QColor(217, 217, 217)));
3091  p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
3092  p->drawLine(opt->rect.topLeft(), opt->rect.bottomLeft());
3093  } break;
3094  case PE_FrameStatusBarItem:
3095  break;
3096  case PE_IndicatorTabClose: {
3097  bool hover = (opt->state & State_MouseOver);
3098  bool selected = (opt->state & State_Selected);
3099  bool active = (opt->state & State_Active);
3100  drawTabCloseButton(p, hover, active, selected);
3101  } break;
3102  case PE_PanelStatusBar: {
3104  QWindowsStyle::drawPrimitive(pe, opt, p, w);
3105  break;
3106  }
3107  // Use the Leopard style only if the status bar is the status bar for a
3108  // QMainWindow with a unifed toolbar.
3109  if (w == 0 || w->parent() == 0 || qobject_cast<QMainWindow *>(w->parent()) == 0 ||
3110  qobject_cast<QMainWindow *>(w->parent())->unifiedTitleAndToolBarOnMac() == false ) {
3111  QWindowsStyle::drawPrimitive(pe, opt, p, w);
3112  break;
3113  }
3114 
3115  // Fill the status bar with the titlebar gradient.
3116  QLinearGradient linearGrad(0, opt->rect.top(), 0, opt->rect.bottom());
3117  if (opt->state & QStyle::State_Active) {
3118  linearGrad.setColorAt(0, titlebarGradientActiveBegin);
3119  linearGrad.setColorAt(1, titlebarGradientActiveEnd);
3120  } else {
3121  linearGrad.setColorAt(0, titlebarGradientInactiveBegin);
3122  linearGrad.setColorAt(1, titlebarGradientInactiveEnd);
3123  }
3124  p->fillRect(opt->rect, linearGrad);
3125 
3126  // Draw the black separator line at the top of the status bar.
3127  if (opt->state & QStyle::State_Active)
3129  else
3131  p->drawLine(opt->rect.left(), opt->rect.top(), opt->rect.right(), opt->rect.top());
3132 
3133  break;
3134  }
3135 
3136  default:
3137  QWindowsStyle::drawPrimitive(pe, opt, p, w);
3138  break;
3139  }
3140 }
static int qt_mac_hitheme_tab_version()
const int qt_mac_hitheme_version
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected)
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
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
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 QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int pixelMetric(PixelMetric pm, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
static const QColor titlebarGradientInactiveEnd(207, 207, 207)
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static const QColor titlebarSeparatorLineInactive(131, 131, 131)
long ASN1_INTEGER_get ASN1_INTEGER * a
static const QColor titlebarGradientInactiveBegin(241, 241, 241)
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
T * qobject_cast(QObject *object)
Definition: qobject.h:375
static const QColor titlebarGradientActiveBegin(220, 220, 220)
QMacStylePrivate * d
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qmatrix.cpp:922
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void 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
static const int DisclosureOffset
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
ColorGroup currentColorGroup() const
Returns the palette&#39;s current color group.
Definition: qpalette.h:104
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
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
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
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
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 fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
static const QColor titlebarGradientActiveEnd(151, 151, 151)
static ThemeTabDirection getTabDirection(QTabBar::Shape shape)
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
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
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
The QStyleOptionTabBarBaseV2 class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:235
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
void setAlphaF(qreal alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1117
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
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setMatrix(const QMatrix &matrix, bool combine=false)
Use setWorldTransform() instead.
Definition: qpainter.cpp:3045
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
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
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static ThemeDrawState getDrawState(QStyle::State flags)
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
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const
static const QColor titlebarSeparatorLineActive(111, 111, 111)
void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget *w)
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QTabBar::Shape shape
the tab shape used to draw the tabs
Definition: qstyleoption.h:183
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
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

◆ event()

bool QMacStyle::event ( QEvent e)
virtual

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

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

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

Reimplemented from QObject.

Definition at line 5980 of file qmacstyle_mac.mm.

5981 {
5982  if(e->type() == QEvent::FocusIn) {
5983  QWidget *f = 0;
5984  QWidget *focusWidget = QApplication::focusWidget();
5985 #ifndef QT_NO_GRAPHICSVIEW
5986  if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget)) {
5987  QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0;
5988  if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) {
5989  QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget *>(focusItem);
5990  if (proxy->widget())
5991  focusWidget = proxy->widget()->focusWidget();
5992  }
5993  }
5994 #endif
5995  if (focusWidget && focusWidget->testAttribute(Qt::WA_MacShowFocusRect)) {
5996  f = focusWidget;
5997  QWidget *top = f->parentWidget();
5998  while (top && !top->isWindow() && !(top->windowType() == Qt::SubWindow))
5999  top = top->parentWidget();
6000 #ifndef QT_NO_MAINWINDOW
6001  if (qobject_cast<QMainWindow *>(top)) {
6002  QWidget *central = static_cast<QMainWindow *>(top)->centralWidget();
6003  for (const QWidget *par = f; par; par = par->parentWidget()) {
6004  if (par == central) {
6005  top = central;
6006  break;
6007  }
6008  if (par->isWindow())
6009  break;
6010  }
6011  }
6012 #endif
6013  }
6014  if (f) {
6015  if(!d->focusWidget)
6016  d->focusWidget = new QFocusFrame(f);
6017  d->focusWidget->setWidget(f);
6018  } else if(d->focusWidget) {
6019  d->focusWidget->setWidget(0);
6020  }
6021  } else if(e->type() == QEvent::FocusOut) {
6022  if(d->focusWidget)
6023  d->focusWidget->setWidget(0);
6024  }
6025  return false;
6026 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setWidget(QWidget *widget)
QFocusFrame will track changes to widget and resize itself automatically.
QMacStylePrivate * d
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene&#39;s current focus item, or 0 if no item curr...
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
virtual int type() const
Returns the type of an item as an int.
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QPointer< QFocusFrame > focusWidget
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QFocusFrame widget provides a focus frame which can be outside of a widget&#39;s normal paintable are...
Definition: qfocusframe.h:56
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
QWidget * widget() const
Returns a pointer to the embedded widget.

◆ focusRectPolicy()

QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy ( const QWidget w)
static

Definition at line 2704 of file qmacstyle_mac.mm.

2705 {
2707 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

◆ generatedIconPixmap()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2636 of file qmacstyle_mac.mm.

2638 {
2639  switch (iconMode) {
2640  case QIcon::Disabled: {
2642  int imgh = img.height();
2643  int imgw = img.width();
2644  QRgb pixel;
2645  for (int y = 0; y < imgh; ++y) {
2646  for (int x = 0; x < imgw; ++x) {
2647  pixel = img.pixel(x, y);
2648  img.setPixel(x, y, qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel),
2649  qAlpha(pixel) / 2));
2650  }
2651  }
2652  return QPixmap::fromImage(img);
2653  }
2654  default:
2655  ;
2656  }
2657  return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, opt);
2658 }
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
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
Reimplemented Function
QRgb pixel(int x, int y) const
Returns the color of the pixel at coordinates (x, y).
Definition: qimage.cpp:4240
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
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
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
void setPixel(int x, int y, uint index_or_rgb)
Sets the pixel index or color at (x, y) to index_or_rgb.
Definition: qimage.cpp:4311
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
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60

◆ hitTestComplexControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5170 of file qmacstyle_mac.mm.

5173 {
5175  switch (cc) {
5176  case CC_ComboBox:
5177  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
5178  sc = QWindowsStyle::hitTestComplexControl(cc, cmb, pt, widget);
5179  if (!cmb->editable && sc != QStyle::SC_None)
5180  sc = SC_ComboBoxArrow; // A bit of a lie, but what we want
5181  }
5182  break;
5183  case CC_Slider:
5184  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5185  HIThemeTrackDrawInfo tdi;
5186  d->getSliderInfo(cc, slider, &tdi, widget);
5187  ControlPartCode part;
5188  HIPoint pos = CGPointMake(pt.x(), pt.y());
5189  if (HIThemeHitTestTrack(&tdi, &pos, &part)) {
5190  if (part == kControlPageUpPart || part == kControlPageDownPart)
5191  sc = SC_SliderGroove;
5192  else
5193  sc = SC_SliderHandle;
5194  }
5195  }
5196  break;
5197  case CC_ScrollBar:
5198  if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5199  HIScrollBarTrackInfo sbi;
5200  sbi.version = qt_mac_hitheme_version;
5201  if (!(sb->state & State_Active))
5202  sbi.enableState = kThemeTrackInactive;
5203  else if (sb->state & State_Enabled)
5204  sbi.enableState = kThemeTrackActive;
5205  else
5206  sbi.enableState = kThemeTrackDisabled;
5207 
5208  // The arrow buttons are not drawn if the scroll bar is to short,
5209  // exclude them from the hit test.
5210  const int scrollBarLength = (sb->orientation == Qt::Horizontal)
5211  ? sb->rect.width() : sb->rect.height();
5213  sbi.enableState = kThemeTrackNothingToScroll;
5214 
5215  sbi.viewsize = sb->pageStep;
5216  HIPoint pos = CGPointMake(pt.x(), pt.y());
5217 
5218  HIRect macSBRect = qt_hirectForQRect(sb->rect);
5219  ControlPartCode part;
5220  bool reverseHorizontal = (sb->direction == Qt::RightToLeft
5221  && sb->orientation == Qt::Horizontal
5222  && (!sb->upsideDown ||
5224  && sb->upsideDown)));
5225  if (HIThemeHitTestScrollBarArrows(&macSBRect, &sbi, sb->orientation == Qt::Horizontal,
5226  &pos, 0, &part)) {
5227  if (part == kControlUpButtonPart)
5228  sc = reverseHorizontal ? SC_ScrollBarAddLine : SC_ScrollBarSubLine;
5229  else if (part == kControlDownButtonPart)
5230  sc = reverseHorizontal ? SC_ScrollBarSubLine : SC_ScrollBarAddLine;
5231  } else {
5232  HIThemeTrackDrawInfo tdi;
5233  d->getSliderInfo(cc, sb, &tdi, widget);
5234  if(tdi.enableState == kThemeTrackInactive)
5235  tdi.enableState = kThemeTrackActive;
5236  if (HIThemeHitTestTrack(&tdi, &pos, &part)) {
5237  if (part == kControlPageUpPart)
5238  sc = reverseHorizontal ? SC_ScrollBarAddPage
5240  else if (part == kControlPageDownPart)
5241  sc = reverseHorizontal ? SC_ScrollBarSubPage
5243  else
5244  sc = SC_ScrollBarSlider;
5245  }
5246  }
5247  }
5248  break;
5249 /*
5250  I don't know why, but we only get kWindowContentRgn here, which isn't what we want at all.
5251  It would be very nice if this would work.
5252  case QStyle::CC_TitleBar:
5253  if (const QStyleOptionTitleBar *tbar = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
5254  HIThemeWindowDrawInfo wdi;
5255  memset(&wdi, 0, sizeof(wdi));
5256  wdi.version = qt_mac_hitheme_version;
5257  wdi.state = kThemeStateActive;
5258  wdi.windowType = QtWinType;
5259  wdi.titleWidth = tbar->rect.width();
5260  wdi.titleHeight = tbar->rect.height();
5261  if (tbar->titleBarState)
5262  wdi.attributes |= kThemeWindowHasFullZoom | kThemeWindowHasCloseBox
5263  | kThemeWindowHasCollapseBox;
5264  else if (tbar->titleBarFlags & Qt::WindowSystemMenuHint)
5265  wdi.attributes |= kThemeWindowHasCloseBox;
5266  QRect tmpRect = tbar->rect;
5267  tmpRect.setHeight(tmpRect.height() + 100);
5268  HIRect hirect = qt_hirectForQRect(tmpRect);
5269  WindowRegionCode hit;
5270  HIPoint hipt = CGPointMake(pt.x(), pt.y());
5271  if (HIThemeGetWindowRegionHit(&hirect, &wdi, &hipt, &hit)) {
5272  switch (hit) {
5273  case kWindowCloseBoxRgn:
5274  sc = QStyle::SC_TitleBarCloseButton;
5275  break;
5276  case kWindowCollapseBoxRgn:
5277  sc = QStyle::SC_TitleBarMinButton;
5278  break;
5279  case kWindowZoomBoxRgn:
5280  sc = QStyle::SC_TitleBarMaxButton;
5281  break;
5282  case kWindowTitleTextRgn:
5283  sc = QStyle::SC_TitleBarLabel;
5284  break;
5285  default:
5286  qDebug("got something else %d", hit);
5287  break;
5288  }
5289  }
5290  }
5291  break;
5292 */
5293  default:
5294  sc = QWindowsStyle::hitTestComplexControl(cc, opt, pt, widget);
5295  break;
5296  }
5297  return sc;
5298 }
const int qt_mac_hitheme_version
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
QPointer< QWidget > widget
QMacStylePrivate * d
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe)
static WidgetSizePolicy widgetSizePolicy(const QWidget *w)
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
if(void) toggleToolbarShown
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
static int scrollButtonsCutoffSize(ScrollBarCutoffType cutoffType, QMacStyle::WidgetSizePolicy widgetSize)

◆ layoutSpacingImplementation

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

Definition at line 6051 of file qmacstyle_mac.mm.

6056 {
6058  bool isMetal = (widget && widget->testAttribute(Qt::WA_MacBrushedMetal));
6059  int controlSize = getControlSize(option, widget);
6060 
6061  if (control2 == QSizePolicy::ButtonBox) {
6062  /*
6063  AHIG seems to prefer a 12-pixel margin between group
6064  boxes and the row of buttons. The 20 pixel comes from
6065  Builder.
6066  */
6067  if (isMetal // (AHIG, guess, guess)
6068  || (control1 & (QSizePolicy::Frame // guess
6069  | QSizePolicy::GroupBox // (AHIG, guess, guess)
6070  | QSizePolicy::TabWidget // guess
6071  | ButtonMask))) { // AHIG
6072  return_SIZE(14, 8, 8);
6073  } else if (control1 == QSizePolicy::LineEdit) {
6074  return_SIZE(8, 8, 8); // Interface Builder
6075  } else {
6076  return_SIZE(20, 7, 7); // Interface Builder
6077  }
6078  }
6079 
6080  if ((control1 | control2) & ButtonMask) {
6081  if (control1 == QSizePolicy::LineEdit)
6082  return_SIZE(8, 8, 8); // Interface Builder
6083  else if (control2 == QSizePolicy::LineEdit) {
6084  if (orientation == Qt::Vertical)
6085  return_SIZE(20, 7, 7); // Interface Builder
6086  else
6087  return_SIZE(20, 8, 8);
6088  }
6089  return_SIZE(14, 8, 8); // Interface Builder
6090  }
6091 
6092  switch (CT2(control1, control2)) {
6093  case CT1(QSizePolicy::Label): // guess
6094  case CT2(QSizePolicy::Label, QSizePolicy::DefaultType): // guess
6095  case CT2(QSizePolicy::Label, QSizePolicy::CheckBox): // AHIG
6096  case CT2(QSizePolicy::Label, QSizePolicy::ComboBox): // AHIG
6097  case CT2(QSizePolicy::Label, QSizePolicy::LineEdit): // guess
6098  case CT2(QSizePolicy::Label, QSizePolicy::RadioButton): // AHIG
6099  case CT2(QSizePolicy::Label, QSizePolicy::Slider): // guess
6100  case CT2(QSizePolicy::Label, QSizePolicy::SpinBox): // guess
6101  case CT2(QSizePolicy::Label, QSizePolicy::ToolButton): // guess
6102  return_SIZE(8, 6, 5);
6104  return 8; // AHIG
6105  case CT1(QSizePolicy::CheckBox):
6106  case CT2(QSizePolicy::CheckBox, QSizePolicy::RadioButton):
6107  case CT2(QSizePolicy::RadioButton, QSizePolicy::CheckBox):
6108  if (orientation == Qt::Vertical)
6109  return_SIZE(8, 8, 7); // AHIG and Builder
6110  break;
6112  if (orientation == Qt::Vertical)
6113  return 5; // (Builder, guess, AHIG)
6114  }
6115 
6116  if (orientation == Qt::Horizontal
6117  && (control2 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton)))
6118  return_SIZE(12, 10, 8); // guess
6119 
6120  if ((control1 | control2) & (QSizePolicy::Frame
6123  /*
6124  These values were chosen so that nested container widgets
6125  look good side by side. Builder uses 8, which looks way
6126  too small, and AHIG doesn't say anything.
6127  */
6128  return_SIZE(16, 10, 10); // guess
6129  }
6130 
6131  if ((control1 | control2) & (QSizePolicy::Line | QSizePolicy::Slider))
6132  return_SIZE(12, 10, 8); // AHIG
6133 
6134  if ((control1 | control2) & QSizePolicy::LineEdit)
6135  return_SIZE(10, 8, 8); // AHIG
6136 
6137  /*
6138  AHIG and Builder differ by up to 4 pixels for stacked editable
6139  comboboxes. We use some values that work fairly well in all
6140  cases.
6141  */
6142  if ((control1 | control2) & QSizePolicy::ComboBox)
6143  return_SIZE(10, 8, 7); // guess
6144 
6145  /*
6146  Builder defaults to 8, 6, 5 in lots of cases, but most of the time the
6147  result looks too cramped.
6148  */
6149  return_SIZE(10, 8, 6); // guess
6150 }
#define return_SIZE(large, small, mini)
#define CT2(c1, c2)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define CT1(c)
static int getControlSize(const QStyleOption *option, const QWidget *widget)
if(void) toggleToolbarShown
Definition: qnamespace.h:54
return(isPopup||isToolTip)

◆ pixelMetric()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1956 of file qmacstyle_mac.mm.

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

1957 {
1958  int controlSize = getControlSize(opt, widget);
1959  SInt32 ret = 0;
1960 
1961  switch (metric) {
1964  ret = closeButtonSize;
1965  break;
1966  case PM_ToolBarIconSize:
1968  break;
1969  case PM_FocusFrameVMargin:
1970  case PM_FocusFrameHMargin:
1971  GetThemeMetric(kThemeMetricFocusRectOutset, &ret);
1972  break;
1974  ret = -5;
1975  break;
1977  QSize sz;
1978  ret = d->aquaSizeConstrain(opt, 0, QStyle::CT_PushButton, QSize(-1, -1), &sz);
1979  if (sz == QSize(-1, -1))
1980  ret = 32;
1981  else
1982  ret = sz.height();
1983  break; }
1984  case PM_CheckListButtonSize: {
1985  switch (d->aquaSizeConstrain(opt, widget)) {
1986  case QAquaSizeUnknown:
1987  case QAquaSizeLarge:
1988  GetThemeMetric(kThemeMetricCheckBoxWidth, &ret);
1989  break;
1990  case QAquaSizeMini:
1991  GetThemeMetric(kThemeMetricMiniCheckBoxWidth, &ret);
1992  break;
1993  case QAquaSizeSmall:
1994  GetThemeMetric(kThemeMetricSmallCheckBoxWidth, &ret);
1995  break;
1996  }
1997  break; }
1999  QSize sz;
2000  ret = d->aquaSizeConstrain(opt, 0, QStyle::CT_PushButton, QSize(-1, -1), &sz);
2001  if (sz == QSize(-1, -1))
2002  ret = 70;
2003  else
2004  ret = sz.width();
2005  break; }
2006 
2007  case PM_MenuBarHMargin:
2008  ret = 8;
2009  break;
2010 
2011  case PM_MenuBarVMargin:
2012  ret = 0;
2013  break;
2014 
2016  ret = 5;
2017  break;
2018 
2021  ret = 2;
2022  break;
2023  case PM_MenuScrollerHeight:
2024 #if 0
2025  SInt16 ash, asw;
2026  GetThemeMenuItemExtra(kThemeMenuItemScrollUpArrow, &ash, &asw);
2027  ret = ash;
2028 #else
2029  ret = 15; // I hate having magic numbers in here...
2030 #endif
2031  break;
2032  case PM_DefaultFrameWidth:
2033 #ifndef QT_NO_MAINWINDOW
2034  if (widget && (widget->isWindow() || !widget->parentWidget()
2035  || (qobject_cast<const QMainWindow*>(widget->parentWidget())
2036  && static_cast<QMainWindow *>(widget->parentWidget())->centralWidget() == widget))
2038 #ifdef QT3_SUPPORT
2039  || widget->inherits("QScrollView")
2040 #endif
2041  || widget->inherits("QWorkspaceChild")))
2042  ret = 0;
2043  else
2044 #endif
2045  // The combo box popup has no frame.
2046  if (qstyleoption_cast<const QStyleOptionComboBox *>(opt) != 0)
2047  ret = 0;
2048  // Frame of mac style line edits is two pixels on top and one on the bottom
2049  else if (qobject_cast<const QLineEdit *>(widget) != 0)
2050  ret = 2;
2051  else
2052  ret = 1;
2053  break;
2055  ret = -1;
2056  break;
2057  case PM_ScrollBarSliderMin:
2058  ret = 24;
2059  break;
2060  case PM_SpinBoxFrameWidth:
2061  GetThemeMetric(kThemeMetricEditTextFrameOutset, &ret);
2062  switch (d->aquaSizeConstrain(opt, widget)) {
2063  default:
2064  ret += 2;
2065  break;
2066  case QAquaSizeMini:
2067  ret += 1;
2068  break;
2069  }
2070  break;
2073  ret = 0;
2074  break;
2075  case PM_SliderLength:
2076  ret = 17;
2077  break;
2079  ret = 0;
2080  break;
2081  case PM_TitleBarHeight:
2082  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
2083  HIThemeWindowDrawInfo wdi;
2084  wdi.version = qt_mac_hitheme_version;
2085  wdi.state = kThemeStateActive;
2086  wdi.windowType = QtWinType;
2087  if (tb->titleBarState)
2088  wdi.attributes = kThemeWindowHasFullZoom | kThemeWindowHasCloseBox
2089  | kThemeWindowHasCollapseBox;
2090  else if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
2091  wdi.attributes = kThemeWindowHasCloseBox;
2092  else
2093  wdi.attributes = 0;
2094  wdi.titleHeight = tb->rect.height();
2095  wdi.titleWidth = tb->rect.width();
2096  QCFType<HIShapeRef> region;
2097  HIRect hirect = qt_hirectForQRect(tb->rect);
2098  if (hirect.size.width <= 0)
2099  hirect.size.width = 100;
2100  if (hirect.size.height <= 0)
2101  hirect.size.height = 30;
2102 
2103  HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, &region);
2104  HIRect rect;
2105  ptrHIShapeGetBounds(region, &rect);
2106  ret = int(rect.size.height);
2107  ret += 4;
2108  }
2109  break;
2110  case PM_TabBarTabVSpace:
2111  ret = 4;
2112  break;
2115  ret = 0;
2116  break;
2117  case PM_TabBarBaseHeight:
2118  ret = 0;
2119  break;
2120  case PM_TabBarTabOverlap:
2121  ret = 0;
2122  break;
2123  case PM_TabBarBaseOverlap:
2124  switch (d->aquaSizeConstrain(opt, widget)) {
2125  case QAquaSizeUnknown:
2126  case QAquaSizeLarge:
2127  ret = 11;
2128  break;
2129  case QAquaSizeSmall:
2130  ret = 8;
2131  break;
2132  case QAquaSizeMini:
2133  ret = 7;
2134  break;
2135  }
2136  break;
2137  case PM_ScrollBarExtent: {
2138  switch (d->aquaSizeConstrain(opt, widget)) {
2139  case QAquaSizeUnknown:
2140  case QAquaSizeLarge:
2141  GetThemeMetric(kThemeMetricScrollBarWidth, &ret);
2142  break;
2143  case QAquaSizeMini:
2144  case QAquaSizeSmall:
2145  GetThemeMetric(kThemeMetricSmallScrollBarWidth, &ret);
2146  break;
2147  }
2148  break; }
2149  case PM_IndicatorHeight: {
2150  switch (d->aquaSizeConstrain(opt, widget)) {
2151  case QAquaSizeUnknown:
2152  case QAquaSizeLarge:
2153  GetThemeMetric(kThemeMetricCheckBoxHeight, &ret);
2154  break;
2155  case QAquaSizeMini:
2156  GetThemeMetric(kThemeMetricMiniCheckBoxHeight, &ret);
2157  break;
2158  case QAquaSizeSmall:
2159  GetThemeMetric(kThemeMetricSmallCheckBoxHeight, &ret);
2160  break;
2161  }
2162  break; }
2163  case PM_IndicatorWidth: {
2164  switch (d->aquaSizeConstrain(opt, widget)) {
2165  case QAquaSizeUnknown:
2166  case QAquaSizeLarge:
2167  GetThemeMetric(kThemeMetricCheckBoxWidth, &ret);
2168  break;
2169  case QAquaSizeMini:
2170  GetThemeMetric(kThemeMetricMiniCheckBoxWidth, &ret);
2171  break;
2172  case QAquaSizeSmall:
2173  GetThemeMetric(kThemeMetricSmallCheckBoxWidth, &ret);
2174  break;
2175  }
2176  ++ret;
2177  break; }
2179  switch (d->aquaSizeConstrain(opt, widget)) {
2180  case QAquaSizeUnknown:
2181  case QAquaSizeLarge:
2182  GetThemeMetric(kThemeMetricRadioButtonHeight, &ret);
2183  break;
2184  case QAquaSizeMini:
2185  GetThemeMetric(kThemeMetricMiniRadioButtonHeight, &ret);
2186  break;
2187  case QAquaSizeSmall:
2188  GetThemeMetric(kThemeMetricSmallRadioButtonHeight, &ret);
2189  break;
2190  }
2191  break; }
2193  switch (d->aquaSizeConstrain(opt, widget)) {
2194  case QAquaSizeUnknown:
2195  case QAquaSizeLarge:
2196  GetThemeMetric(kThemeMetricRadioButtonWidth, &ret);
2197  break;
2198  case QAquaSizeMini:
2199  GetThemeMetric(kThemeMetricMiniRadioButtonWidth, &ret);
2200  break;
2201  case QAquaSizeSmall:
2202  GetThemeMetric(kThemeMetricSmallRadioButtonWidth, &ret);
2203  break;
2204  }
2205  ++ret;
2206  break; }
2207  case PM_MenuVMargin:
2208  ret = 4;
2209  break;
2210  case PM_MenuPanelWidth:
2211  ret = 0;
2212  break;
2214  ret = 0;
2215  break;
2216  case PM_SizeGripSize: {
2217  QAquaWidgetSize aSize;
2218  if (widget && widget->window()->windowType() == Qt::Tool)
2219  aSize = QAquaSizeSmall;
2220  else
2221  aSize = QAquaSizeLarge;
2222  const QSize size = qt_aqua_get_known_size(CT_SizeGrip, widget, QSize(), aSize);
2223  ret = size.width();
2224  break; }
2226  ret = 1;
2227  break;
2229  ret = 2;
2230  break;
2232  ret = 0;
2233  break;
2235  ret = 1;
2236  break;
2238  ret = 11;
2239  break;
2240  case PM_ToolBarItemMargin:
2241  ret = 0;
2242  break;
2243  case PM_ToolBarItemSpacing:
2244  ret = 4;
2245  break;
2246  case PM_SplitterWidth:
2247  ret = qMax(7, QApplication::globalStrut().width());
2248  break;
2249  case PM_LayoutLeftMargin:
2250  case PM_LayoutTopMargin:
2251  case PM_LayoutRightMargin:
2252  case PM_LayoutBottomMargin:
2253  {
2254  bool isWindow = false;
2255  if (opt) {
2256  isWindow = (opt->state & State_Window);
2257  } else if (widget) {
2258  isWindow = widget->isWindow();
2259  }
2260 
2261  if (isWindow) {
2262  bool isMetal = widget && widget->testAttribute(Qt::WA_MacBrushedMetal);
2263  if (isMetal) {
2264  if (metric == PM_LayoutTopMargin) {
2265  return_SIZE(9 /* AHIG */, 6 /* guess */, 6 /* guess */);
2266  } else if (metric == PM_LayoutBottomMargin) {
2267  return_SIZE(18 /* AHIG */, 15 /* guess */, 13 /* guess */);
2268  } else {
2269  return_SIZE(14 /* AHIG */, 11 /* guess */, 9 /* guess */);
2270  }
2271  } else {
2272  /*
2273  AHIG would have (20, 8, 10) here but that makes
2274  no sense. It would also have 14 for the top margin
2275  but this contradicts both Builder and most
2276  applications.
2277  */
2278  return_SIZE(20, 10, 10); // AHIG
2279  }
2280  } else {
2281  // hack to detect QTabWidget
2282  if (widget && widget->parentWidget()
2284  if (metric == PM_LayoutTopMargin) {
2285  /*
2286  Builder would have 14 (= 20 - 6) instead of 12,
2287  but that makes the tab look disproportionate.
2288  */
2289  return_SIZE(12, 6, 6); // guess
2290  } else {
2291  return_SIZE(20 /* Builder */, 8 /* guess */, 8 /* guess */);
2292  }
2293  } else {
2294  /*
2295  Child margins are highly inconsistent in AHIG and Builder.
2296  */
2297  return_SIZE(12, 8, 6); // guess
2298  }
2299  }
2300  }
2303  return -1;
2305  switch (d->aquaSizeConstrain(opt, widget)) {
2306  case QAquaSizeLarge:
2307  case QAquaSizeUnknown:
2308  ret = QWindowsStyle::pixelMetric(metric, opt, widget);
2309  break;
2310  case QAquaSizeSmall:
2311  ret = 20;
2312  break;
2313  case QAquaSizeMini:
2314  ret = 16;
2315  break;
2316  }
2317  break;
2318  case PM_MenuHMargin:
2319  ret = 0;
2320  break;
2321  case PM_ToolBarFrameWidth:
2322  ret = 1;
2323  if (widget) {
2324  if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(widget->parent()))
2325  if (mainWindow->unifiedTitleAndToolBarOnMac())
2326  ret = 0;
2327  }
2328  break;
2329  default:
2330  ret = QWindowsStyle::pixelMetric(metric, opt, widget);
2331  break;
2332  }
2333  return ret;
2334 }
const int qt_mac_hitheme_version
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointer< QWidget > widget
static int closeButtonSize
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
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
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
static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg, QSize szHint, QAquaWidgetSize sz)
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QMacStylePrivate * d
const ThemeWindowType QtWinType
static PtrHIShapeGetBounds ptrHIShapeGetBounds
#define return_SIZE(large, small, mini)
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
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QAquaWidgetSize
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
static int getControlSize(const QStyleOption *option, const QWidget *widget)
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition: qwidget.h:171
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
int height() const
Returns the height.
Definition: qsize.h:129
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
ControlType controlType() const
Definition: qlayout.cpp:1670

◆ polish() [1/3]

void QMacStyle::polish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1875 of file qmacstyle_mac.mm.

1876 {
1877  d->addWidget(w);
1878  if (qt_mac_is_metal(w) && !w->testAttribute(Qt::WA_SetPalette)) {
1879  // Set a clear brush so that the metal shines through.
1880  QPalette pal = w->palette();
1881  QBrush background(Qt::transparent);
1882  pal.setBrush(QPalette::All, QPalette::Window, background);
1883  pal.setBrush(QPalette::All, QPalette::Button, background);
1884  w->setPalette(pal);
1885  w->setAttribute(Qt::WA_SetPalette, false);
1886  }
1887 
1888  if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) {
1889  w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94);
1890  if (!w->testAttribute(Qt::WA_SetPalette)) {
1891  QPixmap px(64, 64);
1892  px.fill(Qt::white);
1893  HIThemeMenuDrawInfo mtinfo;
1894  mtinfo.version = qt_mac_hitheme_version;
1895  mtinfo.menuType = kThemeMenuTypePopUp;
1896  HIRect rect = CGRectMake(0, 0, px.width(), px.height());
1897  HIThemeDrawMenuBackground(&rect, &mtinfo, QCFType<CGContextRef>(qt_mac_cg_context(&px)),
1898  kHIThemeOrientationNormal);
1899  QPalette pal = w->palette();
1900  QBrush background(px);
1901  pal.setBrush(QPalette::All, QPalette::Window, background);
1902  pal.setBrush(QPalette::All, QPalette::Button, background);
1903  w->setPalette(pal);
1904  w->setAttribute(Qt::WA_SetPalette, false);
1905  }
1906  }
1907 
1908  if (QTabBar *tb = qobject_cast<QTabBar*>(w)) {
1909  if (tb->documentMode()) {
1910  w->setAttribute(Qt::WA_Hover);
1911  w->setFont(qt_app_fonts_hash()->value("QSmallFont", QFont()));
1912  QPalette p = w->palette();
1913  p.setColor(QPalette::WindowText, QColor(17, 17, 17));
1914  w->setPalette(p);
1915  }
1916  }
1917 
1919 
1920  if (QRubberBand *rubber = qobject_cast<QRubberBand*>(w)) {
1921  rubber->setWindowOpacity(0.25);
1922  rubber->setAttribute(Qt::WA_PaintOnScreen, false);
1923  rubber->setAttribute(Qt::WA_NoSystemBackground, false);
1924  }
1925 }
const int qt_mac_hitheme_version
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void polish(QApplication *)
Reimplemented Function
bool addWidget(QWidget *)
bool qt_mac_is_metal(const QWidget *w)
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
QMacStylePrivate * d
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
FontHash * qt_app_fonts_hash()
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
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
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
CGContextRef qt_mac_cg_context(const QPaintDevice *)
Returns the CoreGraphics CGContextRef of the paint device.
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary...
Definition: qrubberband.h:58
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ polish() [2/3]

void QMacStyle::polish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1867 of file qmacstyle_mac.mm.

1868 {
1869 }

◆ polish() [3/3]

void QMacStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1844 of file qmacstyle_mac.mm.

1845 {
1846  if (!qt_mac_backgroundPattern) {
1847  if (!qApp)
1848  return;
1850  }
1851 
1852  QColor pc(Qt::black);
1853  pc = qcolorForTheme(kThemeBrushDialogBackgroundActive);
1854  QBrush background(pc, *qt_mac_backgroundPattern);
1855  pal.setBrush(QPalette::All, QPalette::Window, background);
1856  pal.setBrush(QPalette::All, QPalette::Button, background);
1857 
1858  QCFString theme;
1859  const OSErr err = CopyThemeIdentifier(&theme);
1860  if (err == noErr && CFStringCompare(theme, kThemeAppearanceAquaGraphite, 0) == kCFCompareEqualTo) {
1861  pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(240, 240, 240));
1862  } else {
1863  pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(237, 243, 254));
1864  }
1865 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QPixmap generateBackgroundPattern() const
QMacStylePrivate * d
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
#define qApp
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPixmap * qt_mac_backgroundPattern
QColor qcolorForTheme(ThemeBrush brush)
Definition: qt_mac.cpp:110
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ setFocusRectPolicy()

void QMacStyle::setFocusRectPolicy ( QWidget w,
FocusRectPolicy  policy 
)
static

Definition at line 2692 of file qmacstyle_mac.mm.

2693 {
2694  switch (policy) {
2695  case FocusDefault:
2696  break;
2697  case FocusEnabled:
2698  case FocusDisabled:
2700  break;
2701  }
2702 }
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setWidgetSizePolicy()

void QMacStyle::setWidgetSizePolicy ( const QWidget w,
WidgetSizePolicy  policy 
)
static

Definition at line 2709 of file qmacstyle_mac.mm.

2710 {
2711  QWidget *wadget = const_cast<QWidget *>(widget);
2712  wadget->setAttribute(Qt::WA_MacNormalSize, policy == SizeLarge);
2713  wadget->setAttribute(Qt::WA_MacSmallSize, policy == SizeSmall);
2714  wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
2715 }
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ sizeFromContents()

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

Reimplemented Function

This is supposed to show the relationship between the tabBar and
the stack widget of a QTabWidget.
Unfortunately ascii is not a good way of representing graphics.....
PS: The '=' line is the painted frame.

   top    ---+
             |
             |
             |
             |                vvv just outside the painted frame is the "pane"
          - -|- - - - - - - - - - <-+
TAB BAR      +=====^============    | +2 pixels
        - - -|- - -|- - - - - - - <-+
             |     |      ^   ^^^ just inside the painted frame is the "contentsRect"
             |     |      |
             |   overlap  |
             |     |      |
bottom ------+   <-+     +14 pixels
                          |
                          v
    ------------------------------  <- top of stack widget

To summarize: 2 is the distance between the pane and the contentsRect The 14 and the 1's are the distance from the contentsRect to the stack widget. (same value as used in SE_TabWidgetTabContents) overlap is how much the pane should overlap the tab bar

Reimplemented from QCommonStyle.

Definition at line 5646 of file qmacstyle_mac.mm.

5648 {
5649  QSize sz(csz);
5650  bool useAquaGuideline = true;
5651 
5652  switch (ct) {
5653  case QStyle::CT_SpinBox:
5654  // hack to work around horrible sizeHint() code in QAbstractSpinBox
5655  sz.setHeight(sz.height() - 3);
5656  break;
5657  case QStyle::CT_TabWidget:
5658  // the size between the pane and the "contentsRect" (+4,+4)
5659  // (the "contentsRect" is on the inside of the pane)
5660  sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget);
5691  // then add the size between the stackwidget and the "contentsRect"
5692 
5693  if (const QStyleOptionTabWidgetFrame *twf
5694  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
5695  QSize extra(0,0);
5696  const int overlap = pixelMetric(PM_TabBarBaseOverlap, opt, widget);
5697  const int gapBetweenTabbarAndStackWidget = 2 + 14 - overlap;
5698 
5699  if (getTabDirection(twf->shape) == kThemeTabNorth || getTabDirection(twf->shape) == kThemeTabSouth) {
5700  extra = QSize(2, gapBetweenTabbarAndStackWidget + 1);
5701  } else {
5702  extra = QSize(gapBetweenTabbarAndStackWidget + 1, 2);
5703  }
5704  sz+= extra;
5705  }
5706 
5707  break;
5708  case QStyle::CT_TabBarTab:
5709  if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
5710  const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget);
5711  const bool differentFont = (widget && widget->testAttribute(Qt::WA_SetFont))
5713  ThemeTabDirection ttd = getTabDirection(tab->shape);
5714  bool vertTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
5715  if (vertTabs)
5716  sz.transpose();
5717  int defaultTabHeight;
5718  int defaultExtraSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK)
5719  QFontMetrics fm = opt->fontMetrics;
5720  switch (AquaSize) {
5721  case QAquaSizeUnknown:
5722  case QAquaSizeLarge:
5723  if (tab->documentMode)
5724  defaultTabHeight = 23;
5725  else
5726  defaultTabHeight = 21;
5727  break;
5728  case QAquaSizeSmall:
5729  defaultTabHeight = 18;
5730  break;
5731  case QAquaSizeMini:
5732  defaultTabHeight = 16;
5733  break;
5734  }
5735  bool setWidth = false;
5736  if (differentFont || !tab->icon.isNull()) {
5737  sz.rheight() = qMax(defaultTabHeight, sz.height());
5738  } else {
5739  QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text);
5740  sz.rheight() = qMax(defaultTabHeight, textSize.height());
5741  sz.rwidth() = textSize.width() + defaultExtraSpace;
5742  setWidth = true;
5743  }
5744 
5745  if (vertTabs)
5746  sz.transpose();
5747 
5748  int maxWidgetHeight = qMax(tab->leftButtonSize.height(), tab->rightButtonSize.height());
5749  int maxWidgetWidth = qMax(tab->leftButtonSize.width(), tab->rightButtonSize.width());
5750 
5751  int widgetWidth = 0;
5752  int widgetHeight = 0;
5753  int padding = 0;
5754  if (tab->leftButtonSize.isValid()) {
5755  padding += 8;
5756  widgetWidth += tab->leftButtonSize.width();
5757  widgetHeight += tab->leftButtonSize.height();
5758  }
5759  if (tab->rightButtonSize.isValid()) {
5760  padding += 8;
5761  widgetWidth += tab->rightButtonSize.width();
5762  widgetHeight += tab->rightButtonSize.height();
5763  }
5764 
5765  if (vertTabs) {
5766  sz.setHeight(sz.height() + widgetHeight + padding);
5767  sz.setWidth(qMax(sz.width(), maxWidgetWidth));
5768  } else {
5769  if (setWidth)
5770  sz.setWidth(sz.width() + widgetWidth + padding);
5771  sz.setHeight(qMax(sz.height(), maxWidgetHeight));
5772  }
5773  }
5774  break;
5775  case QStyle::CT_PushButton:
5776  // By default, we fit the contents inside a normal rounded push button.
5777  // Do this by add enough space around the contents so that rounded
5778  // borders (including highlighting when active) will show.
5781  break;
5782  case QStyle::CT_MenuItem:
5783  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
5784  int maxpmw = mi->maxIconWidth;
5785  const QComboBox *comboBox = qobject_cast<const QComboBox *>(widget);
5786  int w = sz.width(),
5787  h = sz.height();
5788  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
5789  w = 10;
5790  SInt16 ash;
5791  GetThemeMenuSeparatorHeight(&ash);
5792  h = ash;
5793  } else {
5794  h = mi->fontMetrics.height() + 2;
5795  if (!mi->icon.isNull()) {
5796  if (comboBox) {
5797  const QSize &iconSize = comboBox->iconSize();
5798  h = qMax(h, iconSize.height() + 4);
5799  maxpmw = qMax(maxpmw, iconSize.width());
5800  } else {
5801  int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
5802  h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
5803  }
5804  }
5805  }
5806  if (mi->text.contains(QLatin1Char('\t')))
5807  w += 12;
5808  if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
5809  w += 20;
5810  if (maxpmw)
5811  w += maxpmw + 6;
5812  // add space for a check. All items have place for a check too.
5813  w += 20;
5814  if (comboBox && comboBox->isVisible()) {
5816  cmb.initFrom(comboBox);
5817  cmb.editable = false;
5822  comboBox).width());
5823  } else {
5824  w += 12;
5825  }
5826  sz = QSize(w, h);
5827  }
5828  break;
5829  case CT_ToolButton:
5830  if (widget && qobject_cast<const QToolBar *>(widget->parentWidget())) {
5831  if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(widget->parent())) {
5832  if (mainWindow->unifiedTitleAndToolBarOnMac()) {
5833  sz.rwidth() += 4;
5834  if (sz.height() <= 32) {
5835  // Workaround strange HIToolBar bug when getting constraints.
5836  sz.rheight() += 1;
5837  }
5838  return sz;
5839  }
5840  }
5841  }
5842  sz.rwidth() += 10;
5843  sz.rheight() += 10;
5844  return sz;
5845  case CT_ComboBox:
5846  sz.rwidth() += 50;
5847  break;
5848  case CT_Menu: {
5849  QStyleHintReturnMask menuMask;
5850  QStyleOption myOption = *opt;
5851  myOption.rect.setSize(sz);
5852  if (proxy()->styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) {
5853  sz = menuMask.region.boundingRect().size();
5854  }
5855  break; }
5856  case CT_HeaderSection:{
5857  const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt);
5858  sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget);
5859  if (header->text.contains(QLatin1Char('\n')))
5860  useAquaGuideline = false;
5861  break; }
5862  case CT_ScrollBar :
5863  // Make sure that the scroll bar is large enough to display the thumb indicator.
5864  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5865  const int minimumSize = scrollButtonsCutoffSize(thumbIndicatorCutoff, widgetSizePolicy(widget));
5866  if (slider->orientation == Qt::Horizontal)
5867  sz = sz.expandedTo(QSize(minimumSize, sz.height()));
5868  else
5869  sz = sz.expandedTo(QSize(sz.width(), minimumSize));
5870  }
5871  break;
5872  case CT_ItemViewItem:
5873  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
5874  sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget);
5875  sz.setHeight(sz.height() + 2);
5876  }
5877  break;
5878 
5879  default:
5880  sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget);
5881  }
5882 
5883  if (useAquaGuideline){
5884  QSize macsz;
5885  if (d->aquaSizeConstrain(opt, widget, ct, sz, &macsz) != QAquaSizeUnknown) {
5886  if (macsz.width() != -1)
5887  sz.setWidth(macsz.width());
5888  if (macsz.height() != -1)
5889  sz.setHeight(macsz.height());
5890  }
5891  }
5892 
5893  // The sizes that Carbon and the guidelines gives us excludes the focus frame.
5894  // We compensate for this by adding some extra space here to make room for the frame when drawing:
5895  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
5896  QAquaWidgetSize widgetSize = d->aquaSizeConstrain(opt, widget);
5897  int bkind = 0;
5898  switch (widgetSize) {
5899  default:
5900  case QAquaSizeLarge:
5901  bkind = combo->editable ? kThemeComboBox : kThemePopupButton;
5902  break;
5903  case QAquaSizeSmall:
5904  bkind = combo->editable ? int(kThemeComboBoxSmall) : int(kThemePopupButtonSmall);
5905  break;
5906  case QAquaSizeMini:
5907  bkind = combo->editable ? kThemeComboBoxMini : kThemePopupButtonMini;
5908  break;
5909  }
5910  HIRect tmpRect = {{0, 0}, {0, 0}};
5911  HIRect diffRect = QMacStylePrivate::comboboxInnerBounds(tmpRect, bkind);
5912  sz.rwidth() -= qRound(diffRect.size.width);
5913  sz.rheight() -= qRound(diffRect.size.height);
5914  } else if (ct == CT_PushButton || ct == CT_ToolButton){
5915  ThemeButtonKind bkind;
5916  QAquaWidgetSize widgetSize = d->aquaSizeConstrain(opt, widget);
5917  switch (ct) {
5918  default:
5919  case CT_PushButton:
5920  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
5921  if (btn->features & QStyleOptionButton::CommandLinkButton) {
5922  return QWindowsStyle::sizeFromContents(ct, opt, sz, widget);
5923  }
5924  }
5925 
5926  switch (widgetSize) {
5927  default:
5928  case QAquaSizeLarge:
5929  bkind = kThemePushButton;
5930  break;
5931  case QAquaSizeSmall:
5932  bkind = kThemePushButtonSmall;
5933  break;
5934  case QAquaSizeMini:
5935  bkind = kThemePushButtonMini;
5936  break;
5937  }
5938  break;
5939  case CT_ToolButton:
5940  switch (widgetSize) {
5941  default:
5942  case QAquaSizeLarge:
5943  bkind = kThemeLargeBevelButton;
5944  break;
5945  case QAquaSizeMini:
5946  case QAquaSizeSmall:
5947  bkind = kThemeSmallBevelButton;
5948  }
5949  break;
5950  }
5951 
5952  HIThemeButtonDrawInfo bdi;
5953  bdi.version = qt_mac_hitheme_version;
5954  bdi.state = kThemeStateActive;
5955  bdi.kind = bkind;
5956  bdi.value = kThemeButtonOff;
5957  bdi.adornment = kThemeAdornmentNone;
5958  HIRect macRect, myRect;
5959  myRect = CGRectMake(0, 0, sz.width(), sz.height());
5960  HIThemeGetButtonBackgroundBounds(&myRect, &bdi, &macRect);
5961  // Mini buttons only return their actual size in HIThemeGetButtonBackgroundBounds, so help them out a bit (guess),
5962  if (bkind == kThemePushButtonMini)
5963  macRect.size.height += 8.;
5964  else if (bkind == kThemePushButtonSmall)
5965  macRect.size.height -= 10;
5966  sz.setWidth(sz.width() + int(macRect.size.width - myRect.size.width));
5967  sz.setHeight(sz.height() + int(macRect.size.height - myRect.size.height));
5968  }
5969  return sz;
5970 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
const int qt_mac_hitheme_version
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
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
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
bool isVisible() const
Definition: qwidget.h:1005
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int pixelMetric(PixelMetric pm, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
static const int PushButtonBottomOffset
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
QSize iconSize
the size of the icons shown in the combobox.
Definition: qcombobox.h:77
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
bool editable
whether or not the combobox is editable or not
Definition: qstyleoption.h:802
QString text
the text of the header
Definition: qstyleoption.h:263
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
QMacStylePrivate * d
static const int PushButtonLeftOffset
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 QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int width() const
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
static ThemeTabDirection getTabDirection(QTabBar::Shape shape)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
QAquaWidgetSize
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
static const int PushButtonTopOffset
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
static WidgetSizePolicy widgetSizePolicy(const QWidget *w)
virtual int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
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
const QStyle * proxy() const
Definition: qstyle.cpp:2546
static const int PushButtonRightOffset
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
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
static int scrollButtonsCutoffSize(ScrollBarCutoffType cutoffType, QMacStyle::WidgetSizePolicy widgetSize)
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind)
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ standardIconImplementation

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

Definition at line 6028 of file qmacstyle_mac.mm.

Referenced by standardPixmap().

6030 {
6031  switch (standardIcon) {
6032  default:
6036  QPixmap pixmap(qt_mac_toolbar_ext);
6038  QPixmap pix2(pixmap.height(), pixmap.width());
6039  pix2.fill(Qt::transparent);
6040  QPainter p(&pix2);
6041  p.translate(pix2.width(), 0);
6042  p.rotate(90);
6043  p.drawPixmap(0, 0, pixmap);
6044  return pix2;
6045  }
6046  return pixmap;
6047  }
6048  }
6049 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget=0) const
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 fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
static const char *const qt_mac_toolbar_ext[]
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ standardPalette()

QPalette QMacStyle::standardPalette ( ) const
virtual

Returns the style's standard palette.

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

Reimplemented from QStyle.

Definition at line 2336 of file qmacstyle_mac.mm.

2337 {
2339  pal.setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191));
2340  pal.setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191));
2341  pal.setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191));
2342  return pal;
2343 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
virtual QPalette standardPalette() const
Returns the style&#39;s standard palette.
Definition: qstyle.cpp:2283
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
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ standardPixmap()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2661 of file qmacstyle_mac.mm.

2663 {
2664  // The default implementation of QStyle::standardIconImplementation() is to call standardPixmap()
2665  // I don't want infinite recursion so if we do get in that situation, just return the Window's
2666  // standard pixmap instead (since there is no mac-specific icon then). This should be fine until
2667  // someone changes how Windows standard
2668  // pixmap works.
2669  static bool recursionGuard = false;
2670 
2671  if (recursionGuard)
2672  return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
2673 
2674  recursionGuard = true;
2675  QIcon icon = standardIconImplementation(standardPixmap, opt, widget);
2676  recursionGuard = false;
2677  int size;
2678  switch (standardPixmap) {
2679  default:
2680  size = 32;
2681  break;
2682  case SP_MessageBoxCritical:
2683  case SP_MessageBoxQuestion:
2685  case SP_MessageBoxWarning:
2686  size = 64;
2687  break;
2688  }
2689  return icon.pixmap(size, size);
2690 }
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
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 QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ styleHint()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2345 of file qmacstyle_mac.mm.

Referenced by drawControl(), and sizeFromContents().

2347 {
2348  SInt32 ret = 0;
2349  switch (sh) {
2350  case SH_Menu_SelectionWrap:
2351  ret = false;
2352  break;
2354  ret = true;
2355  break;
2357  ret = true;
2358  break;
2361  break;
2363  ret = 0;
2364  break;
2366  ret = false;
2367  break;
2368  case SH_TitleBar_AutoRaise:
2369  ret = true;
2370  break;
2372  ret = false;
2373  break;
2375  ret = 100;
2376  break;
2378  extern bool qt_scrollbar_jump_to_pos; //qapplication_mac.cpp
2380  ret = !qt_scrollbar_jump_to_pos;
2381  else
2383  break; }
2385  ret = true;
2386  break;
2388  ret = kBulletUnicode;
2389  break;
2390  /*
2391  case SH_DialogButtons_DefaultButton:
2392  ret = QDialogButtons::Reject;
2393  break;
2394  */
2396  ret = Qt::AlignTop;
2397  break;
2399  if (w && (w->isWindow() || !w->parentWidget() || w->parentWidget()->isWindow())
2400  && (w->inherits("QWorkspaceChild")
2401 #ifdef QT3_SUPPORT
2402  || w->inherits("QScrollView")
2403 #endif
2404  ))
2405  ret = true;
2406  else
2407  ret = QWindowsStyle::styleHint(sh, opt, w, hret);
2408  break;
2410  ret = false;
2411  break;
2412  case SH_Menu_Scrollable:
2413  ret = true;
2414  break;
2416  ret = true;
2417  break;
2419  ret = false;
2420  break;
2422  ret = true;
2423  break;
2426  break;
2428  if (const QStyleOptionTabBarBaseV2 *opt2 = qstyleoption_cast<const QStyleOptionTabBarBaseV2 *>(opt)) {
2429  ret = opt2->documentMode ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
2430  } else {
2432  }
2433  break;
2434  case SH_ComboBox_Popup:
2435  if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt))
2436  ret = !cmb->editable;
2437  else
2438  ret = 0;
2439  break;
2441  ret = true;
2442  break;
2444  ret = true;
2445  break;
2447  ret = Qt::AlignRight;
2448  break;
2449  case SH_TabBar_Alignment: {
2450  if (const QTabWidget *tab = qobject_cast<const QTabWidget*>(w)) {
2451  if (tab->documentMode()) {
2452  ret = Qt::AlignLeft;
2453  break;
2454  }
2455  }
2456  if (const QTabBar *tab = qobject_cast<const QTabBar*>(w)) {
2457  if (tab->documentMode()) {
2458  ret = Qt::AlignLeft;
2459  break;
2460  }
2461  }
2462  ret = Qt::AlignCenter;
2463  } break;
2464  case SH_UnderlineShortcut:
2465  ret = false;
2466  break;
2468  ret = 242; // About 95%
2469  break;
2470  case SH_Button_FocusPolicy:
2471  ret = Qt::TabFocus;
2472  break;
2473  case SH_EtchDisabledText:
2474  ret = false;
2475  break;
2476  case SH_FocusFrame_Mask: {
2477  ret = true;
2478  if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
2479  const uchar fillR = 192, fillG = 191, fillB = 190;
2480  QImage img;
2481 
2482  QSize pixmapSize = opt->rect.size();
2483  if (pixmapSize.isValid()) {
2484  QPixmap pix(pixmapSize);
2485  pix.fill(QColor(fillR, fillG, fillB));
2486  QPainter pix_paint(&pix);
2487  proxy()->drawControl(CE_FocusFrame, opt, &pix_paint, w);
2488  pix_paint.end();
2489  img = pix.toImage();
2490  }
2491 
2492  const QRgb *sptr = (QRgb*)img.bits(), *srow;
2493  const int sbpl = img.bytesPerLine();
2494  const int w = sbpl/4, h = img.height();
2495 
2496  QImage img_mask(img.width(), img.height(), QImage::Format_ARGB32);
2497  QRgb *dptr = (QRgb*)img_mask.bits(), *drow;
2498  const int dbpl = img_mask.bytesPerLine();
2499 
2500  for (int y = 0; y < h; ++y) {
2501  srow = sptr+((y*sbpl)/4);
2502  drow = dptr+((y*dbpl)/4);
2503  for (int x = 0; x < w; ++x) {
2504  const int diff = (((qRed(*srow)-fillR)*(qRed(*srow)-fillR)) +
2505  ((qGreen(*srow)-fillG)*((qGreen(*srow)-fillG))) +
2506  ((qBlue(*srow)-fillB)*((qBlue(*srow)-fillB))));
2507  (*drow++) = (diff < 100) ? 0xffffffff : 0xff000000;
2508  ++srow;
2509  }
2510  }
2511  QBitmap qmask = QBitmap::fromImage(img_mask);
2512  mask->region = QRegion(qmask);
2513  }
2514  break; }
2515  case SH_TitleBar_NoBorder:
2516  ret = 1;
2517  break;
2518  case SH_RubberBand_Mask:
2519  ret = 0;
2520  break;
2522  ret = Qt::LeftToRight;
2523  break;
2525  ret = Qt::AlignHCenter;
2526  break;
2528  ret = true;
2529  break;
2531  ret = false;
2532  break;
2534  ret = true;
2535  break;
2536  case SH_WindowFrame_Mask:
2537  ret = 1;
2538  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(hret)) {
2539  mask->region = opt->rect;
2540  mask->region -= QRect(opt->rect.left(), opt->rect.top(), 5, 1);
2541  mask->region -= QRect(opt->rect.left(), opt->rect.top() + 1, 3, 1);
2542  mask->region -= QRect(opt->rect.left(), opt->rect.top() + 2, 2, 1);
2543  mask->region -= QRect(opt->rect.left(), opt->rect.top() + 3, 1, 2);
2544 
2545  mask->region -= QRect(opt->rect.right() - 4, opt->rect.top(), 5, 1);
2546  mask->region -= QRect(opt->rect.right() - 2, opt->rect.top() + 1, 3, 1);
2547  mask->region -= QRect(opt->rect.right() - 1, opt->rect.top() + 2, 2, 1);
2548  mask->region -= QRect(opt->rect.right() , opt->rect.top() + 3, 1, 2);
2549  }
2550  break;
2551  case SH_TabBar_ElideMode:
2552  ret = Qt::ElideRight;
2553  break;
2554  case SH_DialogButtonLayout:
2556  break;
2559  break;
2562  break;
2565  break;
2567  ret = Qt::AlignRight;
2568  break;
2571  break;
2574  break;
2577  break;
2579  ret = false;
2580  break;
2582  ret = false;
2583  break;
2585  ret = false;
2586  break;
2588  ret = true;
2589  break;
2590  case SH_WizardStyle:
2591  ret = QWizard::MacStyle;
2592  break;
2594  ret = false;
2595  break;
2597  ret = true;
2598  break;
2599  case SH_Menu_FadeOutOnHide:
2600  ret = true;
2601  break;
2602  case SH_Menu_Mask:
2603  if (opt) {
2604  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
2605  ret = true;
2606  HIRect menuRect = CGRectMake(opt->rect.x(), opt->rect.y() + 4,
2607  opt->rect.width(), opt->rect.height() - 8);
2608  HIThemeMenuDrawInfo mdi;
2609  mdi.version = 0;
2610  if (w && qobject_cast<QMenu *>(w->parentWidget()))
2611  mdi.menuType = kThemeMenuTypeHierarchical;
2612  else
2613  mdi.menuType = kThemeMenuTypePopUp;
2614  QCFType<HIShapeRef> shape;
2615  HIThemeGetMenuBackgroundShape(&menuRect, &mdi, &shape);
2616  mask->region = QRegion::fromHIShapeRef(shape);
2617  }
2618  }
2619  break;
2621  ret = true;
2622  break;
2624  ret = QTabBar::LeftSide;
2625  break;
2627  ret = false;
2628  break;
2629  default:
2630  ret = QWindowsStyle::styleHint(sh, opt, w, hret);
2631  break;
2632  }
2633  return ret;
2634 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
unsigned int QRgb
Definition: qrgb.h:53
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
bool qt_scrollbar_jump_to_pos
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static Bigint * diff(Bigint *a, Bigint *b)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
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
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
The QStyleOptionTabBarBaseV2 class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:235
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
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
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
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
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
static QBitmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Returns a copy of the given image converted to a bitmap using the specified image conversion flags...
Definition: qbitmap.cpp:281
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QTabWidget class provides a stack of tabbed widgets.
Definition: qtabwidget.h:60
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ subControlRect()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5300 of file qmacstyle_mac.mm.

Referenced by sizeFromContents().

5302 {
5303  QRect ret;
5304  switch (cc) {
5305  case CC_Slider:
5306  case CC_ScrollBar:
5307  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
5308  HIThemeTrackDrawInfo tdi;
5309  d->getSliderInfo(cc, slider, &tdi, widget);
5310  HIRect macRect;
5311  QCFType<HIShapeRef> shape;
5312  bool scrollBar = cc == CC_ScrollBar;
5313  if ((scrollBar && sc == SC_ScrollBarSlider)
5314  || (!scrollBar && sc == SC_SliderHandle)) {
5315  HIThemeGetTrackThumbShape(&tdi, &shape);
5316  ptrHIShapeGetBounds(shape, &macRect);
5317  } else if (!scrollBar && sc == SC_SliderGroove) {
5318  HIThemeGetTrackBounds(&tdi, &macRect);
5319  } else if (sc == SC_ScrollBarGroove) { // Only scroll bar parts available...
5320  HIThemeGetTrackDragRect(&tdi, &macRect);
5321  } else {
5322  ControlPartCode cpc;
5323  if (sc == SC_ScrollBarSubPage || sc == SC_ScrollBarAddPage) {
5324  cpc = sc == SC_ScrollBarSubPage ? kControlPageDownPart
5325  : kControlPageUpPart;
5326  } else {
5327  cpc = sc == SC_ScrollBarSubLine ? kControlUpButtonPart
5328  : kControlDownButtonPart;
5329  if (slider->direction == Qt::RightToLeft
5330  && slider->orientation == Qt::Horizontal) {
5331  if (cpc == kControlDownButtonPart)
5332  cpc = kControlUpButtonPart;
5333  else if (cpc == kControlUpButtonPart)
5334  cpc = kControlDownButtonPart;
5335  }
5336  }
5337  HIThemeGetTrackPartBounds(&tdi, cpc, &macRect);
5338  }
5339  ret = qt_qrectForHIRect(macRect);
5340 
5341  // Tweak: the dark line between the sub/add line buttons belong to only one of the buttons
5342  // when doing hit-testing, but both of them have to repaint it. Extend the rect to cover
5343  // the line in the cases where HIThemeGetTrackPartBounds returns a rect that doesn't.
5344  if (slider->orientation == Qt::Horizontal) {
5345  if (slider->direction == Qt::LeftToRight && sc == SC_ScrollBarSubLine)
5346  ret.adjust(0, 0, 1, 0);
5347  else if (slider->direction == Qt::RightToLeft && sc == SC_ScrollBarAddLine)
5348  ret.adjust(-1, 0, 1, 0);
5349  } else if (sc == SC_ScrollBarAddLine) {
5350  ret.adjust(0, -1, 0, 1);
5351  }
5352  }
5353  break;
5354  case CC_TitleBar:
5355  if (const QStyleOptionTitleBar *titlebar
5356  = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
5357  HIThemeWindowDrawInfo wdi;
5358  memset(&wdi, 0, sizeof(wdi));
5359  wdi.version = qt_mac_hitheme_version;
5360  wdi.state = kThemeStateActive;
5361  wdi.windowType = QtWinType;
5362  wdi.titleHeight = titlebar->rect.height();
5363  wdi.titleWidth = titlebar->rect.width();
5364  wdi.attributes = kThemeWindowHasTitleText;
5365  if (titlebar->subControls & SC_TitleBarCloseButton)
5366  wdi.attributes |= kThemeWindowHasCloseBox;
5367  if (titlebar->subControls & SC_TitleBarMaxButton
5369  wdi.attributes |= kThemeWindowHasFullZoom;
5370  if (titlebar->subControls & SC_TitleBarMinButton)
5371  wdi.attributes |= kThemeWindowHasCollapseBox;
5372  WindowRegionCode wrc = kWindowGlobalPortRgn;
5373 
5374  if (sc == SC_TitleBarCloseButton)
5375  wrc = kWindowCloseBoxRgn;
5376  else if (sc == SC_TitleBarMinButton)
5377  wrc = kWindowCollapseBoxRgn;
5378  else if (sc == SC_TitleBarMaxButton)
5379  wrc = kWindowZoomBoxRgn;
5380  else if (sc == SC_TitleBarLabel)
5381  wrc = kWindowTitleTextRgn;
5382  else if (sc == SC_TitleBarSysMenu)
5383  ret.setRect(-1024, -1024, 10, proxy()->pixelMetric(PM_TitleBarHeight,
5384  titlebar, widget));
5385  if (wrc != kWindowGlobalPortRgn) {
5386  QCFType<HIShapeRef> region;
5387  QRect tmpRect = titlebar->rect;
5388  HIRect titleRect = qt_hirectForQRect(tmpRect);
5389  HIThemeGetWindowShape(&titleRect, &wdi, kWindowTitleBarRgn, &region);
5390  ptrHIShapeGetBounds(region, &titleRect);
5391  CFRelease(region);
5392  tmpRect.translate(tmpRect.x() - int(titleRect.origin.x),
5393  tmpRect.y() - int(titleRect.origin.y));
5394  titleRect = qt_hirectForQRect(tmpRect);
5395  HIThemeGetWindowShape(&titleRect, &wdi, wrc, &region);
5396  ptrHIShapeGetBounds(region, &titleRect);
5397  ret = qt_qrectForHIRect(titleRect);
5398  }
5399  }
5400  break;
5401  case CC_ComboBox:
5402  if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
5403  HIThemeButtonDrawInfo bdi;
5404  d->initComboboxBdi(combo, &bdi, widget, d->getDrawState(opt->state));
5405 
5406  switch (sc) {
5407  case SC_ComboBoxEditField:{
5408  ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
5409  // hack to posistion the edit feld correctly for QDateTimeEdits
5410  // in calendarPopup mode.
5411  if (qobject_cast<const QDateTimeEdit *>(widget)) {
5412  ret.moveTop(ret.top() - 2);
5413  ret.setHeight(ret.height() +1);
5414  }
5415  break; }
5416  case SC_ComboBoxArrow:{
5417  ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
5418  ret.setX(ret.x() + ret.width());
5419  ret.setWidth(combo->rect.right() - ret.right());
5420  break; }
5422  if (combo->editable) {
5423  HIRect inner = QMacStylePrivate::comboboxInnerBounds(qt_hirectForQRect(combo->rect), bdi.kind);
5424  QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
5425  const int comboTop = combo->rect.top();
5426  ret = QRect(qRound(inner.origin.x),
5427  comboTop,
5428  qRound(inner.origin.x - combo->rect.left() + inner.size.width),
5429  editRect.bottom() - comboTop + 2);
5430  } else {
5431  QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
5432  ret = QRect(combo->rect.x() + 4 - 11,
5433  combo->rect.y() + 1,
5434  editRect.width() + 10 + 11,
5435  1);
5436  }
5437  break; }
5438  default:
5439  break;
5440  }
5441  }
5442  break;
5443  case CC_GroupBox:
5444  if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
5445  bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
5446  bool flat = (groupBox->features & QStyleOptionFrameV2::Flat);
5447  bool hasNoText = !checkable && groupBox->text.isEmpty();
5448  switch (sc) {
5449  case SC_GroupBoxLabel:
5450  case SC_GroupBoxCheckBox: {
5451  // Cheat and use the smaller font if we need to
5452  bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
5453  bool fontIsSet = (widget && widget->testAttribute(Qt::WA_SetFont))
5455  int tw;
5456  int h;
5457  int margin = flat || hasNoText ? 0 : 12;
5458  ret = groupBox->rect.adjusted(margin, 0, -margin, 0);
5459 
5460  if (!fontIsSet) {
5461  HIThemeTextInfo tti;
5462  tti.version = qt_mac_hitheme_version;
5463  tti.state = kThemeStateActive;
5464  tti.fontID = checkable ? kThemeSystemFont : kThemeSmallSystemFont;
5465  tti.horizontalFlushness = kHIThemeTextHorizontalFlushCenter;
5466  tti.verticalFlushness = kHIThemeTextVerticalFlushCenter;
5467  tti.options = kHIThemeTextBoxOptionNone;
5468  tti.truncationPosition = kHIThemeTextTruncationNone;
5469  tti.truncationMaxLines = 1 + groupBox->text.count(QLatin1Char('\n'));
5470  CGFloat width;
5471  CGFloat height;
5472  QCFString groupText = qt_mac_removeMnemonics(groupBox->text);
5473  HIThemeGetTextDimensions(groupText, 0, &tti, &width, &height, 0);
5474  tw = qRound(width);
5475  h = qCeil(height);
5476  } else {
5477  QFontMetricsF fm = QFontMetricsF(groupBox->fontMetrics);
5478  h = qCeil(fm.height());
5479  tw = qCeil(fm.size(Qt::TextShowMnemonic, groupBox->text).width());
5480  }
5481  ret.setHeight(h);
5482 
5483  QRect labelRect = alignedRect(groupBox->direction, groupBox->textAlignment,
5484  QSize(tw, h), ret);
5485  int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget);
5486  bool rtl = groupBox->direction == Qt::RightToLeft;
5487  if (sc == SC_GroupBoxLabel) {
5488  if (checkable) {
5489  int newSum = indicatorWidth + 1;
5490  int newLeft = labelRect.left() + (rtl ? -newSum : newSum);
5491  labelRect.moveLeft(newLeft);
5492  } else if (flat) {
5493  int newLeft = labelRect.left() - (rtl ? 3 : -3);
5494  labelRect.moveLeft(newLeft);
5495  labelRect.moveTop(labelRect.top() + 3);
5496  } else {
5497  int newLeft = labelRect.left() - (rtl ? 3 : 2);
5498  labelRect.moveLeft(newLeft);
5499  labelRect.moveTop(labelRect.top() + 5);
5500  }
5501  ret = labelRect;
5502  }
5503 
5504  if (sc == SC_GroupBoxCheckBox) {
5505  int left = rtl ? labelRect.right() - indicatorWidth : labelRect.left();
5506  ret.setRect(left, ret.top(),
5507  indicatorWidth, proxy()->pixelMetric(PM_IndicatorHeight, opt, widget));
5508  }
5509  break;
5510  }
5511  case SC_GroupBoxContents:
5512  case SC_GroupBoxFrame: {
5513  if (flat) {
5514  ret = QWindowsStyle::subControlRect(cc, groupBox, sc, widget);
5515  break;
5516  }
5517  QFontMetrics fm = groupBox->fontMetrics;
5518  bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
5519  int yOffset = 3;
5520  if (!checkable) {
5523  fm = QFontMetrics(qt_app_fonts_hash()->value("QSmallFont", QFont()));
5524  yOffset = 5;
5525  if (hasNoText)
5526  yOffset = -qCeil(QFontMetricsF(fm).height());
5527  }
5528 
5529  ret = opt->rect.adjusted(0, qCeil(QFontMetricsF(fm).height()) + yOffset, 0, 0);
5530  if (sc == SC_GroupBoxContents)
5531  ret.adjust(3, 3, -3, -4); // guess
5532  }
5533  break;
5534  default:
5535  ret = QWindowsStyle::subControlRect(cc, groupBox, sc, widget);
5536  break;
5537  }
5538  }
5539  break;
5540  case CC_SpinBox:
5541  if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
5542  QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget);
5543  int spinner_w;
5544  int spinBoxSep;
5545  int fw = proxy()->pixelMetric(PM_SpinBoxFrameWidth, spin, widget);
5546  switch (aquaSize) {
5547  default:
5548  case QAquaSizeUnknown:
5549  case QAquaSizeLarge:
5550  spinner_w = 14;
5551  spinBoxSep = 2;
5552  break;
5553  case QAquaSizeSmall:
5554  spinner_w = 12;
5555  spinBoxSep = 2;
5556  break;
5557  case QAquaSizeMini:
5558  spinner_w = 10;
5559  spinBoxSep = 1;
5560  break;
5561  }
5562 
5563  switch (sc) {
5564  case SC_SpinBoxUp:
5565  case SC_SpinBoxDown: {
5566  if (spin->buttonSymbols == QAbstractSpinBox::NoButtons)
5567  break;
5568 
5569  const int y = fw;
5570  const int x = spin->rect.width() - spinner_w;
5571  ret.setRect(x + spin->rect.x(), y + spin->rect.y(), spinner_w, spin->rect.height() - y * 2);
5572  HIThemeButtonDrawInfo bdi;
5573  bdi.version = qt_mac_hitheme_version;
5574  bdi.kind = kThemeIncDecButton;
5575  int hackTranslateX;
5576  switch (aquaSize) {
5577  default:
5578  case QAquaSizeUnknown:
5579  case QAquaSizeLarge:
5580  bdi.kind = kThemeIncDecButton;
5581  hackTranslateX = 0;
5582  break;
5583  case QAquaSizeSmall:
5584  bdi.kind = kThemeIncDecButtonSmall;
5585  hackTranslateX = -2;
5586  break;
5587  case QAquaSizeMini:
5588  bdi.kind = kThemeIncDecButtonMini;
5589  hackTranslateX = -1;
5590  break;
5591  }
5592  bdi.state = kThemeStateActive;
5593  bdi.value = kThemeButtonOff;
5594  bdi.adornment = kThemeAdornmentNone;
5595  HIRect hirect = qt_hirectForQRect(ret);
5596 
5597  HIRect outRect;
5598  HIThemeGetButtonBackgroundBounds(&hirect, &bdi, &outRect);
5599  ret = qt_qrectForHIRect(outRect);
5600  switch (sc) {
5601  case SC_SpinBoxUp:
5602  ret.setHeight(ret.height() / 2);
5603  break;
5604  case SC_SpinBoxDown:
5605  ret.setY(ret.y() + ret.height() / 2);
5606  break;
5607  default:
5608  Q_ASSERT(0);
5609  break;
5610  }
5611  ret.translate(hackTranslateX, 0); // hack: position the buttons correctly (weird that we need this)
5612  ret = visualRect(spin->direction, spin->rect, ret);
5613  break;
5614  }
5615  case SC_SpinBoxEditField:
5616  if (spin->buttonSymbols == QAbstractSpinBox::NoButtons) {
5617  ret.setRect(fw, fw,
5618  spin->rect.width() - fw * 2,
5619  spin->rect.height() - fw * 2);
5620  } else {
5621  ret.setRect(fw, fw,
5622  spin->rect.width() - fw * 2 - spinBoxSep - spinner_w,
5623  spin->rect.height() - fw * 2);
5624  }
5625  ret = visualRect(spin->direction, spin->rect, ret);
5626  break;
5627  default:
5628  ret = QWindowsStyle::subControlRect(cc, spin, sc, widget);
5629  break;
5630  }
5631  }
5632  break;
5633  case CC_ToolButton:
5634  ret = QWindowsStyle::subControlRect(cc, opt, sc, widget);
5635  if (sc == SC_ToolButtonMenu && widget && !qobject_cast<QToolBar*>(widget->parentWidget())) {
5636  ret.adjust(-1, 0, 0, 0);
5637  }
5638  break;
5639  default:
5640  ret = QWindowsStyle::subControlRect(cc, opt, sc, widget);
5641  break;
5642  }
5643  return ret;
5644 }
const int qt_mac_hitheme_version
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
QString qt_mac_removeMnemonics(const QString &original)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
QPointer< QWidget > widget
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
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
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
int pixelMetric(PixelMetric pm, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
qreal width() const
Returns the width.
Definition: qsize.h:284
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QSizeF size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of the characters in the given text.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
static const QRect qt_qrectForHIRect(const HIRect &hirect)
QMacStylePrivate * d
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const ThemeWindowType QtWinType
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static PtrHIShapeGetBounds ptrHIShapeGetBounds
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
QAquaWidgetSize
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
qreal height() const
Returns the height of the font.
FontHash * qt_app_fonts_hash()
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
static HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect=QRect())
void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe)
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
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
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 x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi)
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
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
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static ThemeDrawState getDrawState(QStyle::State flags)
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 QFontMetricsF class provides font metrics information.
Definition: qfontmetrics.h:145
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, const QWidget *widget, const ThemeDrawState &tds)
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 QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function
float CGFloat

◆ subElementRect()

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

Reimplemented Function

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

Reimplemented from QCommonStyle.

Definition at line 4260 of file qmacstyle_mac.mm.

Referenced by drawControl().

4262 {
4263  QRect rect;
4264  int controlSize = getControlSize(opt, widget);
4265 
4266  switch (sr) {
4267  case SE_ItemViewItemText:
4268  if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
4269  int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget);
4270  // We add the focusframeargin between icon and text in commonstyle
4271  rect = QCommonStyle::subElementRect(sr, opt, widget);
4272  if (vopt->features & QStyleOptionViewItemV2::HasDecoration)
4273  rect.adjust(-fw, 0, 0, 0);
4274  }
4275  break;
4276  case SE_ToolBoxTabContents:
4277  rect = QCommonStyle::subElementRect(sr, opt, widget);
4278  break;
4279  case SE_PushButtonContents:
4280  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4281  // Unlike Carbon, we want the button to always be drawn inside its bounds.
4282  // Therefore, the button is a bit smaller, so that even if it got focus,
4283  // the focus 'shadow' will be inside. Adjust the content rect likewise.
4284  HIThemeButtonDrawInfo bdi;
4285  d->initHIThemePushButton(btn, widget, d->getDrawState(opt->state), &bdi);
4286  HIRect contentRect = d->pushButtonContentBounds(btn, &bdi);
4287  rect = qt_qrectForHIRect(contentRect);
4288  }
4289  break;
4290  case SE_HeaderLabel:
4291  if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
4292  rect = QWindowsStyle::subElementRect(sr, opt, widget);
4293  if (widget && widget->height() <= 22){
4294  // We need to allow the text a bit more space when the header is
4295  // small, otherwise it gets clipped:
4296  rect.setY(0);
4297  rect.setHeight(widget->height());
4298  }
4299  }
4300  break;
4301  case SE_ProgressBarGroove:
4302  case SE_ProgressBarLabel:
4303  break;
4305  rect = opt->rect;
4306  break;
4308  HIRect inRect = CGRectMake(opt->rect.x(), opt->rect.y(),
4309  opt->rect.width(), opt->rect.height());
4310  HIThemeButtonDrawInfo bdi;
4311  bdi.version = qt_mac_hitheme_version;
4312  bdi.state = kThemeStateActive;
4313  bdi.kind = kThemeDisclosureButton;
4314  bdi.value = kThemeDisclosureRight;
4315  bdi.adornment = kThemeAdornmentNone;
4316  HIRect contentRect;
4317  HIThemeGetButtonContentBounds(&inRect, &bdi, &contentRect);
4318  QCFType<HIShapeRef> shape;
4319  HIRect outRect;
4320  HIThemeGetButtonShape(&inRect, &bdi, &shape);
4321  ptrHIShapeGetBounds(shape, &outRect);
4322  rect = QRect(int(outRect.origin.x + DisclosureOffset), int(outRect.origin.y),
4323  int(contentRect.origin.x - outRect.origin.x + DisclosureOffset),
4324  int(outRect.size.height));
4325  break;
4326  }
4328  if (const QStyleOptionTabWidgetFrame *twf
4329  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
4330  switch (twf->shape) {
4331  case QTabBar::RoundedNorth:
4333  rect = QRect(QPoint(0, 0), twf->leftCornerWidgetSize);
4334  break;
4335  case QTabBar::RoundedSouth:
4337  rect = QRect(QPoint(0, twf->rect.height() - twf->leftCornerWidgetSize.height()),
4338  twf->leftCornerWidgetSize);
4339  break;
4340  default:
4341  break;
4342  }
4343  rect = visualRect(twf->direction, twf->rect, rect);
4344  }
4345  break;
4347  if (const QStyleOptionTabWidgetFrame *twf
4348  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
4349  switch (twf->shape) {
4350  case QTabBar::RoundedNorth:
4352  rect = QRect(QPoint(twf->rect.width() - twf->rightCornerWidgetSize.width(), 0),
4353  twf->rightCornerWidgetSize);
4354  break;
4355  case QTabBar::RoundedSouth:
4357  rect = QRect(QPoint(twf->rect.width() - twf->rightCornerWidgetSize.width(),
4358  twf->rect.height() - twf->rightCornerWidgetSize.height()),
4359  twf->rightCornerWidgetSize);
4360  break;
4361  default:
4362  break;
4363  }
4364  rect = visualRect(twf->direction, twf->rect, rect);
4365  }
4366  break;
4368  rect = QWindowsStyle::subElementRect(sr, opt, widget);
4369  if (const QStyleOptionTabWidgetFrame *twf
4370  = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
4371  if (twf->lineWidth != 0) {
4372  switch (getTabDirection(twf->shape)) {
4373  case kThemeTabNorth:
4374  rect.adjust(+1, +14, -1, -1);
4375  break;
4376  case kThemeTabSouth:
4377  rect.adjust(+1, +1, -1, -14);
4378  break;
4379  case kThemeTabWest:
4380  rect.adjust(+14, +1, -1, -1);
4381  break;
4382  case kThemeTabEast:
4383  rect.adjust(+1, +1, -14, -1);
4384  }
4385  }
4386  }
4387  break;
4388  case SE_LineEditContents:
4389  rect = QWindowsStyle::subElementRect(sr, opt, widget);
4390  if(widget->parentWidget() && qobject_cast<const QComboBox*>(widget->parentWidget()))
4391  rect.adjust(-1, -2, 0, 0);
4392  else
4393  rect.adjust(-1, -1, 0, +1);
4394  break;
4395  case SE_CheckBoxLayoutItem:
4396  rect = opt->rect;
4397  if (controlSize == QAquaSizeLarge) {
4398  setLayoutItemMargins(+2, +3, -9, -4, &rect, opt->direction);
4399  } else if (controlSize == QAquaSizeSmall) {
4400  setLayoutItemMargins(+1, +5, 0 /* fix */, -6, &rect, opt->direction);
4401  } else {
4402  setLayoutItemMargins(0, +7, 0 /* fix */, -6, &rect, opt->direction);
4403  }
4404  break;
4405  case SE_ComboBoxLayoutItem:
4406  if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
4407  // Do nothing, because QToolbar needs the entire widget rect.
4408  // Otherwise it will be clipped. Equivalent to
4409  // widget->setAttribute(Qt::WA_LayoutUsesWidgetRect), but without
4410  // all the hassle.
4411  } else {
4412  rect = opt->rect;
4413  if (controlSize == QAquaSizeLarge) {
4414  rect.adjust(+3, +2, -3, -4);
4415  } else if (controlSize == QAquaSizeSmall) {
4416  setLayoutItemMargins(+2, +1, -3, -4, &rect, opt->direction);
4417  } else {
4418  setLayoutItemMargins(+1, 0, -2, 0, &rect, opt->direction);
4419  }
4420  }
4421  break;
4422  case SE_LabelLayoutItem:
4423  rect = opt->rect;
4424  setLayoutItemMargins(+1, 0 /* SHOULD be -1, done for alignment */, 0, 0 /* SHOULD be -1, done for alignment */, &rect, opt->direction);
4425  break;
4426  case SE_ProgressBarLayoutItem: {
4427  rect = opt->rect;
4428  int bottom = SIZE(3, 8, 8);
4429  if (opt->state & State_Horizontal) {
4430  rect.adjust(0, +1, 0, -bottom);
4431  } else {
4432  setLayoutItemMargins(+1, 0, -bottom, 0, &rect, opt->direction);
4433  }
4434  break;
4435  }
4437  if (const QStyleOptionButton *buttonOpt
4438  = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4439  if ((buttonOpt->features & QStyleOptionButton::Flat))
4440  break; // leave rect alone
4441  }
4442  rect = opt->rect;
4443  if (controlSize == QAquaSizeLarge) {
4444  rect.adjust(+6, +4, -6, -8);
4445  } else if (controlSize == QAquaSizeSmall) {
4446  rect.adjust(+5, +4, -5, -6);
4447  } else {
4448  rect.adjust(+1, 0, -1, -2);
4449  }
4450  break;
4452  rect = opt->rect;
4453  if (controlSize == QAquaSizeLarge) {
4454  setLayoutItemMargins(+2, +2 /* SHOULD BE +3, done for alignment */,
4455  0, -4 /* SHOULD BE -3, done for alignment */, &rect, opt->direction);
4456  } else if (controlSize == QAquaSizeSmall) {
4457  rect.adjust(0, +6, 0 /* fix */, -5);
4458  } else {
4459  rect.adjust(0, +6, 0 /* fix */, -7);
4460  }
4461  break;
4462  case SE_SliderLayoutItem:
4463  if (const QStyleOptionSlider *sliderOpt
4464  = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4465  rect = opt->rect;
4466  if (sliderOpt->tickPosition == QSlider::NoTicks) {
4467  int above = SIZE(3, 0, 2);
4468  int below = SIZE(4, 3, 0);
4469  if (sliderOpt->orientation == Qt::Horizontal) {
4470  rect.adjust(0, +above, 0, -below);
4471  } else {
4472  rect.adjust(+above, 0, -below, 0); //### Seems that QSlider flip the position of the ticks in reverse mode.
4473  }
4474  } else if (sliderOpt->tickPosition == QSlider::TicksAbove) {
4475  int below = SIZE(3, 2, 0);
4476  if (sliderOpt->orientation == Qt::Horizontal) {
4477  rect.setHeight(rect.height() - below);
4478  } else {
4479  rect.setWidth(rect.width() - below);
4480  }
4481  } else if (sliderOpt->tickPosition == QSlider::TicksBelow) {
4482  int above = SIZE(3, 2, 0);
4483  if (sliderOpt->orientation == Qt::Horizontal) {
4484  rect.setTop(rect.top() + above);
4485  } else {
4486  rect.setLeft(rect.left() + above);
4487  }
4488  }
4489  }
4490  break;
4491  case SE_FrameLayoutItem:
4492  // hack because QStyleOptionFrameV2 doesn't have a frameStyle member
4493  if (const QFrame *frame = qobject_cast<const QFrame *>(widget)) {
4494  rect = opt->rect;
4495  switch (frame->frameStyle() & QFrame::Shape_Mask) {
4496  case QFrame::HLine:
4497  rect.adjust(0, +1, 0, -1);
4498  break;
4499  case QFrame::VLine:
4500  rect.adjust(+1, 0, -1, 0);
4501  break;
4502  default:
4503  ;
4504  }
4505  }
4506  break;
4507  case SE_GroupBoxLayoutItem:
4508  rect = opt->rect;
4509  if (const QStyleOptionGroupBox *groupBoxOpt =
4510  qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4511  /*
4512  AHIG is very inconsistent when it comes to group boxes.
4513  Basically, we make sure that (non-checkable) group boxes
4514  and tab widgets look good when laid out side by side.
4515  */
4516  if (groupBoxOpt->subControls & (QStyle::SC_GroupBoxCheckBox
4518  int delta;
4519  if (groupBoxOpt->subControls & QStyle::SC_GroupBoxCheckBox) {
4520  delta = SIZE(8, 4, 4); // guess
4521  } else {
4522  delta = SIZE(15, 12, 12); // guess
4523  }
4524  rect.setTop(rect.top() + delta);
4525  }
4526  }
4527  rect.setBottom(rect.bottom() - 1);
4528  break;
4530  if (const QStyleOptionTabWidgetFrame *tabWidgetOpt =
4531  qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
4532  /*
4533  AHIG specifies "12 or 14" as the distance from the window
4534  edge. We choose 14 and since the default top margin is 20,
4535  the overlap is 6.
4536  */
4537  rect = tabWidgetOpt->rect;
4538  if (tabWidgetOpt->shape == QTabBar::RoundedNorth)
4539  rect.setTop(rect.top() + SIZE(6 /* AHIG */, 3 /* guess */, 2 /* AHIG */));
4540  }
4541  break;
4542 #ifndef QT_NO_DOCKWIDGET
4546  case SE_DockWidgetIcon: {
4547  int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
4548  int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget);
4549  QRect srect = opt->rect;
4550 
4551  const QStyleOptionDockWidget *dwOpt
4553  bool canClose = dwOpt == 0 ? true : dwOpt->closable;
4554  bool canFloat = dwOpt == 0 ? false : dwOpt->floatable;
4555  const QStyleOptionDockWidgetV2 *v2
4557  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
4558 
4559  // If this is a vertical titlebar, we transpose and work as if it was
4560  // horizontal, then transpose again.
4561  if (verticalTitleBar) {
4562  QSize size = srect.size();
4563  size.transpose();
4564  srect.setSize(size);
4565  }
4566 
4567  do {
4568  int right = srect.right();
4569  int left = srect.left();
4570 
4571  QRect closeRect;
4572  if (canClose) {
4574  opt, widget).actualSize(QSize(iconSize, iconSize));
4575  sz += QSize(buttonMargin, buttonMargin);
4576  if (verticalTitleBar)
4577  sz.transpose();
4578  closeRect = QRect(left,
4579  srect.center().y() - sz.height()/2,
4580  sz.width(), sz.height());
4581  left = closeRect.right() + 1;
4582  }
4583  if (sr == SE_DockWidgetCloseButton) {
4584  rect = closeRect;
4585  break;
4586  }
4587 
4588  QRect floatRect;
4589  if (canFloat) {
4591  opt, widget).actualSize(QSize(iconSize, iconSize));
4592  sz += QSize(buttonMargin, buttonMargin);
4593  if (verticalTitleBar)
4594  sz.transpose();
4595  floatRect = QRect(left,
4596  srect.center().y() - sz.height()/2,
4597  sz.width(), sz.height());
4598  left = floatRect.right() + 1;
4599  }
4600  if (sr == SE_DockWidgetFloatButton) {
4601  rect = floatRect;
4602  break;
4603  }
4604 
4605  QRect iconRect;
4606  if (const QDockWidget *dw = qobject_cast<const QDockWidget*>(widget)) {
4607  QIcon icon;
4608  if (dw->isFloating())
4609  icon = dw->windowIcon();
4610  if (!icon.isNull()
4611  && icon.cacheKey() != QApplication::windowIcon().cacheKey()) {
4612  QSize sz = icon.actualSize(QSize(rect.height(), rect.height()));
4613  if (verticalTitleBar)
4614  sz.transpose();
4615  iconRect = QRect(right - sz.width(), srect.center().y() - sz.height()/2,
4616  sz.width(), sz.height());
4617  right = iconRect.left() - 1;
4618  }
4619  }
4620  if (sr == SE_DockWidgetIcon) {
4621  rect = iconRect;
4622  break;
4623  }
4624 
4625  QRect textRect = QRect(left, srect.top(),
4626  right - left, srect.height());
4627  if (sr == SE_DockWidgetTitleBarText) {
4628  rect = textRect;
4629  break;
4630  }
4631  } while (false);
4632 
4633  if (verticalTitleBar) {
4634  rect = QRect(srect.left() + rect.top() - srect.top(),
4635  srect.top() + srect.right() - rect.right(),
4636  rect.height(), rect.width());
4637  } else {
4638  rect = visualRect(opt->direction, srect, rect);
4639  }
4640  break;
4641  }
4642 #endif
4643  default:
4644  rect = QWindowsStyle::subElementRect(sr, opt, widget);
4645  break;
4646  }
4647  return rect;
4648 }
const int qt_mac_hitheme_version
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
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
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
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
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
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
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setY(int y)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:285
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
static const QRect qt_qrectForHIRect(const HIRect &hirect)
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QMacStylePrivate * d
#define SIZE(large, small, mini)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
static PtrHIShapeGetBounds ptrHIShapeGetBounds
static const int DisclosureOffset
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
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
static ThemeTabDirection getTabDirection(QTabBar::Shape shape)
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
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 QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
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 QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
bool floatable
whether the dock window is floatable
Definition: qstyleoption.h:513
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
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
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
static int getControlSize(const QStyleOption *option, const QWidget *widget)
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 QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyleOptionGroupBox class describes the parameters for drawing a group box.
Definition: qstyleoption.h:834
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
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
static ThemeDrawState getDrawState(QStyle::State flags)
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
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
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const
HIRect pushButtonContentBounds(const QStyleOptionButton *btn, const HIThemeButtonDrawInfo *bdi) const
static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
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
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ unpolish() [1/2]

void QMacStyle::unpolish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1927 of file qmacstyle_mac.mm.

1928 {
1929  d->removeWidget(w);
1930  if ((qobject_cast<QMenu*>(w) || qt_mac_is_metal(w)) && !w->testAttribute(Qt::WA_SetPalette)) {
1931  QPalette pal = qApp->palette(w);
1932  w->setPalette(pal);
1933  w->setAttribute(Qt::WA_SetPalette, false);
1934  w->setWindowOpacity(1.0);
1935  }
1936 
1937  if (QComboBox *combo = qobject_cast<QComboBox *>(w)) {
1938  if (!combo->isEditable()) {
1939  if (QWidget *widget = combo->findChild<QComboBoxPrivateContainer *>())
1940  widget->setWindowOpacity(1.0);
1941  }
1942  }
1943 
1944  if (QRubberBand *rubber = ::qobject_cast<QRubberBand*>(w)) {
1945  rubber->setWindowOpacity(1.0);
1946  rubber->setAttribute(Qt::WA_PaintOnScreen, true);
1947  rubber->setAttribute(Qt::WA_NoSystemBackground, true);
1948  }
1949 
1950  if (QFocusFrame *frame = qobject_cast<QFocusFrame *>(w))
1951  frame->setAttribute(Qt::WA_NoSystemBackground, true);
1952 
1954 }
void unpolish(QApplication *)
Reimplemented Function
bool qt_mac_is_metal(const QWidget *w)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void removeWidget(QWidget *)
QMacStylePrivate * d
#define qApp
The QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
The QFocusFrame widget provides a focus frame which can be outside of a widget&#39;s normal paintable are...
Definition: qfocusframe.h:56
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary...
Definition: qrubberband.h:58
void setWindowOpacity(qreal level)
Definition: qwidget.cpp:11497
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ unpolish() [2/2]

void QMacStyle::unpolish ( QApplication application)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1871 of file qmacstyle_mac.mm.

1872 {
1873 }

◆ widgetSizePolicy()

QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy ( const QWidget w)
static

Definition at line 2717 of file qmacstyle_mac.mm.

Referenced by QMacStylePrivate::aquaSizeConstrain(), drawComplexControl(), getControlSize(), hitTestComplexControl(), QStyleOption::init(), and sizeFromContents().

2718 {
2719  while (widget) {
2721  return SizeMini;
2722  } else if (widget->testAttribute(Qt::WA_MacSmallSize)) {
2723  return SizeSmall;
2724  } else if (widget->testAttribute(Qt::WA_MacNormalSize)) {
2725  return SizeLarge;
2726  }
2727  widget = widget->parentWidget();
2728  }
2729  return SizeDefault;
2730 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QPointer< QWidget > widget
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041

Friends and Related Functions

◆ qt_mac_buttonIsRenderedFlat

bool qt_mac_buttonIsRenderedFlat ( const QPushButton pushButton,
const QStyleOptionButton option 
)
friend

Definition at line 1062 of file qmacstyle_mac.mm.

1063 {
1064  QMacStyle *macStyle = qobject_cast<QMacStyle *>(pushButton->style());
1065  if (!macStyle)
1066  return true; // revert to 'flat' behavior if not Mac style
1067  HIThemeButtonDrawInfo bdi;
1068  macStyle->d->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi);
1069  return bdi.kind == kThemeBevelButton;
1070 }
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QMacStylePrivate * d
QStyle * style() const
Definition: qwidget.cpp:2742
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const

Properties

◆ d

QMacStylePrivate* QMacStyle::d
private

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