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

The QMotifStyle class provides Motif look and feel. More...

#include <qmotifstyle.h>

Inheritance diagram for QMotifStyle:
QCommonStyle QStyle QObject QCDEStyle

Public Functions

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

Protected Slots

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

Protected Functions

bool eventFilter (QObject *o, QEvent *e)
 
 QMotifStyle (QMotifStylePrivate &dd, bool useHighlightCols=false)
 
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

QPointer< QFocusFramefocus
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Properties

bool highlightCols
 

Additional Inherited Members

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

Detailed Description

The QMotifStyle class provides Motif look and feel.

This class implements the Motif look and feel. It closely resembles the original Motif look as defined by the Open Group, but with some minor improvements. The Motif style is Qt's default GUI style on Unix platforms.

qmotifstyle.png
See also
QWindowsXPStyle, QMacStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle

Definition at line 60 of file qmotifstyle.h.

Constructors and Destructors

◆ QMotifStyle() [1/2]

QMotifStyle::QMotifStyle ( bool  useHighlightCols = false)
explicit

Constructs a QMotifStyle.

If useHighlightCols is false (the default), the style will polish the application's color palette to emulate the Motif way of highlighting, which is a simple inversion between the base and the text color.

Definition at line 123 of file qmotifstyle.cpp.

125 {
126  focus = 0;
127  highlightCols = useHighlightCols;
128 }
bool highlightCols
Definition: qmotifstyle.h:119
QCommonStyle()
Constructs a QCommonStyle.
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110

◆ ~QMotifStyle()

QMotifStyle::~QMotifStyle ( )
virtual

Destroys the style.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 150 of file qmotifstyle.cpp.

151 {
152  delete focus;
153 }
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110

◆ QMotifStyle() [2/2]

QMotifStyle::QMotifStyle ( QMotifStylePrivate dd,
bool  useHighlightColors = false 
)
protected
Warning
This function is not part of the public interface.

Definition at line 134 of file qmotifstyle.cpp.

135  : QCommonStyle(dd)
136 {
137  focus = 0;
139 }
bool highlightCols
Definition: qmotifstyle.h:119
QCommonStyle()
Constructs a QCommonStyle.
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
bool useHighlightColors() const
Returns true if the style treats the highlight colors of the palette in a Motif-like manner...

Functions

◆ drawComplexControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1444 of file qmotifstyle.cpp.

1446 {
1447  switch (cc) {
1448  case CC_ToolButton:
1449  if (const QStyleOptionToolButton *toolbutton
1450  = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1451  QRect button, menuarea;
1452  button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
1453  menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
1454 
1455  State bflags = toolbutton->state & ~State_Sunken;
1456  if (bflags & State_AutoRaise) {
1457  if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
1458  bflags &= ~State_Raised;
1459  }
1460  }
1461  State mflags = bflags;
1462  if (toolbutton->state & State_Sunken) {
1463  if (toolbutton->activeSubControls & SC_ToolButton)
1464  bflags |= State_Sunken;
1465  mflags |= State_Sunken;
1466  }
1467 
1468  QStyleOption tool(0);
1469  tool.palette = toolbutton->palette;
1470  if (toolbutton->subControls & SC_ToolButton) {
1471  if (bflags & (State_Sunken | State_On | State_Raised)) {
1472  tool.rect = button;
1473  tool.state = bflags;
1475  }
1476  }
1477 
1478  if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1480  fr.QStyleOption::operator=(*toolbutton);
1481  fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
1483  }
1484  QStyleOptionToolButton label = *toolbutton;
1485  label.state = bflags;
1486  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1487  label.rect = button.adjusted(fw, fw, -fw, -fw);
1488  proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
1489 
1490  if (toolbutton->subControls & SC_ToolButtonMenu) {
1491  tool.rect = menuarea;
1492  tool.state = mflags;
1493  if (mflags & (State_Sunken | State_On | State_Raised))
1496  } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
1497  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
1498  QRect ir = toolbutton->rect;
1499  QStyleOptionToolButton newBtn = *toolbutton;
1500  newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6);
1502  }
1503  }
1504  break;
1505 #ifndef QT_NO_SPINBOX
1506  case CC_SpinBox:
1507  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1508  QStyleOptionSpinBox copy = *spinbox;
1509  PrimitiveElement pe;
1510 
1511  if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) {
1514 
1516  r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw);
1517  QStyleOptionFrame lineOpt;
1518  lineOpt.QStyleOption::operator=(*opt);
1519  lineOpt.rect = r;
1520  lineOpt.lineWidth = fw;
1521  lineOpt.midLineWidth = 0;
1522  lineOpt.state |= QStyle::State_Sunken;
1524  }
1525 
1526  if (spinbox->subControls & SC_SpinBoxUp) {
1527  copy.subControls = SC_SpinBoxUp;
1528  QPalette pal2 = spinbox->palette;
1529  if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
1531  copy.state &= ~State_Enabled;
1532  }
1533 
1534  copy.palette = pal2;
1535 
1536  if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) {
1537  copy.state |= State_On;
1538  copy.state |= State_Sunken;
1539  } else {
1540  copy.state |= State_Raised;
1541  copy.state &= ~State_Sunken;
1542  }
1543  pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
1544  : PE_IndicatorSpinUp);
1545 
1546  copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget);
1547  proxy()->drawPrimitive(pe, &copy, p, widget);
1548  }
1549 
1550  if (spinbox->subControls & SC_SpinBoxDown) {
1551  copy.subControls = SC_SpinBoxDown;
1552  copy.state = spinbox->state;
1553  QPalette pal2 = spinbox->palette;
1554  if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
1556  copy.state &= ~State_Enabled;
1557  }
1558  copy.palette = pal2;
1559 
1560  if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) {
1561  copy.state |= State_On;
1562  copy.state |= State_Sunken;
1563  } else {
1564  copy.state |= State_Raised;
1565  copy.state &= ~State_Sunken;
1566  }
1567  pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
1569 
1570  copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget);
1571  proxy()->drawPrimitive(pe, &copy, p, widget);
1572  }
1573  }
1574  break;
1575 #endif // QT_NO_SPINBOX
1576 #ifndef QT_NO_SLIDER
1577  case CC_Slider:
1578  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1580  handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget);
1581 
1582  if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
1583  qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
1585  if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1586  QStyleOption focusOpt = *opt;
1587  focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
1588  proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
1589  }
1590  }
1591 
1592  if ((opt->subControls & SC_SliderHandle) && handle.isValid()) {
1593  QStyleOption bevelOpt = *opt;
1594  bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken;
1595  bevelOpt.rect = handle;
1596  p->save();
1597  p->setBrushOrigin(bevelOpt.rect.topLeft());
1598  proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
1599  p->restore();
1600 
1601  if (slider->orientation == Qt::Horizontal) {
1602  int mid = handle.x() + handle.width() / 2;
1603  qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2,
1604  opt->palette, true, 1);
1605  } else {
1606  int mid = handle.y() + handle.height() / 2;
1607  qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette,
1608  true, 1);
1609  }
1611  p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern));
1612  }
1613 
1614  if (slider->subControls & SC_SliderTickmarks) {
1615  QStyleOptionSlider tmpSlider = *slider;
1616  tmpSlider.subControls = SC_SliderTickmarks;
1617  int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
1618  tmpSlider.rect.translate(frameWidth - 1, 0);
1619  QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
1620  }
1621  }
1622  break;
1623 #endif // QT_NO_SLIDER
1624  case CC_ComboBox:
1625  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
1626  if (opt->subControls & SC_ComboBoxArrow) {
1627  int awh, ax, ay, sh, sy, dh, ew;
1628  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
1629 
1630  if (cb->frame) {
1631  QStyleOptionButton btn;
1632  btn.QStyleOption::operator=(*cb);
1633  btn.state |= QStyle::State_Raised;
1635  } else {
1636  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1637  }
1638 
1639  QRect tr = opt->rect;
1640  tr.adjust(fw, fw, -fw, -fw);
1641  get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
1642 
1643  QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh));
1644 
1645  QStyleOption arrowOpt = *opt;
1646  arrowOpt.rect = ar;
1647  arrowOpt.state |= State_Enabled;
1648  proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
1649 
1650 
1651  // draws the shaded line under the arrow
1652  p->setPen(opt->palette.light().color());
1653  p->drawLine(ar.x(), sy, ar.x()+awh-1, sy);
1654  p->drawLine(ar.x(), sy, ar.x(), sy+sh-1);
1655  p->setPen(opt->palette.dark().color());
1656  p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
1657  p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
1658 
1659  if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1661  focus.QStyleOption::operator=(*opt);
1663  focus.backgroundColor = opt->palette.button().color();
1664  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
1665  }
1666  }
1667 
1668  if (opt->subControls & SC_ComboBoxEditField) {
1669  if (cb->editable) {
1671  er.adjust(-1, -1, 1, 1);
1672  qDrawShadePanel(p, er, opt->palette, true, 1,
1673  &opt->palette.brush(QPalette::Base));
1674  }
1675  }
1676  p->setPen(opt->palette.buttonText().color());
1677  }
1678  break;
1679 
1680 #ifndef QT_NO_SCROLLBAR
1681  case CC_ScrollBar: {
1682  if (opt->subControls & SC_ScrollBarGroove)
1683  qDrawShadePanel(p, opt->rect, opt->palette, true,
1685  &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
1686 
1687  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1688  QStyleOptionSlider newScrollbar = *scrollbar;
1689  if (scrollbar->minimum == scrollbar->maximum)
1690  newScrollbar.state |= State_Enabled; // make sure that the slider is drawn.
1691  QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
1692  }
1693  break; }
1694 #endif
1695 
1696  case CC_Q3ListView:
1698  int i;
1699  if (opt->subControls & SC_Q3ListView)
1701  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
1702  QStyleOptionQ3ListViewItem item = lv->items.at(0);
1703  int y = opt->rect.y();
1704  int c;
1705  QPolygon dotlines;
1706  if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) {
1707  c = 2;
1708  dotlines.resize(2);
1709  dotlines[0] = QPoint(opt->rect.right(), opt->rect.top());
1710  dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom());
1711  } else {
1712  int linetop = 0, linebot = 0;
1713  // each branch needs at most two lines, ie. four end points
1714  dotlines.resize(item.childCount * 4);
1715  c = 0;
1716 
1717  // skip the stuff above the exposed rectangle
1718  for (i = 1; i < lv->items.size(); ++i) {
1719  QStyleOptionQ3ListViewItem child = lv->items.at(i);
1720  if (child.height + y > 0)
1721  break;
1722  y += child.totalHeight;
1723  }
1724 
1725  int bx = opt->rect.width() / 2;
1726 
1727  // paint stuff in the magical area
1728  while (i < lv->items.size() && y < lv->rect.height()) {
1729  QStyleOptionQ3ListViewItem child = lv->items.at(i);
1731  int lh;
1733  lh = child.height;
1734  else
1735  lh = p->fontMetrics().height() + 2 * lv->itemMargin;
1736  lh = qMax(lh, QApplication::globalStrut().height());
1737  if (lh % 2 > 0)
1738  lh++;
1739  linebot = y + lh/2;
1740  if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) &&
1741  child.height > 0) {
1742  // needs a box
1743  p->setPen(opt->palette.text().color());
1744  p->drawRect(bx-4, linebot-4, 9, 9);
1745  QPolygon a;
1746  if ((child.state & State_Open))
1747  a.setPoints(3, bx-2, linebot-2,
1748  bx, linebot+2,
1749  bx+2, linebot-2); //Qt::RightArrow
1750  else
1751  a.setPoints(3, bx-2, linebot-2,
1752  bx+2, linebot,
1753  bx-2, linebot+2); //Qt::DownArrow
1754  p->setBrush(opt->palette.text());
1755  p->drawPolygon(a);
1756  p->setBrush(Qt::NoBrush);
1757  // dotlinery
1758  dotlines[c++] = QPoint(bx, linetop);
1759  dotlines[c++] = QPoint(bx, linebot - 5);
1760  dotlines[c++] = QPoint(bx + 5, linebot);
1761  dotlines[c++] = QPoint(opt->rect.width(), linebot);
1762  linetop = linebot + 5;
1763  } else {
1764  // just dotlinery
1765  dotlines[c++] = QPoint(bx+1, linebot);
1766  dotlines[c++] = QPoint(opt->rect.width(), linebot);
1767  }
1768  y += child.totalHeight;
1769  }
1770  ++i;
1771  }
1772 
1773  // Expand line height to edge of rectangle if there's any
1774  // visible child below
1775  while (i < lv->items.size() && lv->items.at(i).height <= 0)
1776  ++i;
1777  if (i < lv->items.size())
1778  linebot = opt->rect.height();
1779 
1780  if (linetop < linebot) {
1781  dotlines[c++] = QPoint(bx, linetop);
1782  dotlines[c++] = QPoint(bx, linebot);
1783  }
1784  }
1785 
1786  int line; // index into dotlines
1787  p->setPen(opt->palette.text().color());
1788  if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
1789  p->drawLine(dotlines[line].x(), dotlines[line].y(),
1790  dotlines[line+1].x(), dotlines[line+1].y());
1791  }
1792  }
1793  break; }
1794 
1795  default:
1797  break;
1798  }
1799 }
int height
the height of the item
Definition: qstyleoption.h:474
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
static void get_combo_parameters(const QRect &r, int &ew, int &awh, int &ax, int &ay, int &sh, int &dh, int &sy)
unsigned char c[8]
Definition: qnumeric_p.h:62
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QPointer< QWidget > widget
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
bool isVisible() const
Definition: qwidget.h:1005
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int 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
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
long ASN1_INTEGER_get ASN1_INTEGER * a
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
The QStyleOptionToolButton class is used to describe the parameters for drawing a tool button...
Definition: qstyleoption.h:768
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QColor backgroundColor
the background color on which the focus rectangle is being drawn
Definition: qstyleoption.h:109
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
int lineWidth
the line width for drawing the frame
Definition: qstyleoption.h:124
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
Definition: qpainter.cpp:2077
int totalHeight
the total height of the item, including its children
Definition: qstyleoption.h:475
The QStyleOptionQ3ListViewItem class is used to describe an item drawn in a Q3ListView.
Definition: qstyleoption.h:463
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
Q3ListViewItemFeatures features
the features for this item
Definition: qstyleoption.h:473
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The State element defines configurations of objects and properties.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
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
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
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int midLineWidth
the mid-line width for drawing the frame
Definition: qstyleoption.h:125
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The 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
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
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
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
int height() const
Returns the height of the font.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
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
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawControl()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 854 of file qmotifstyle.cpp.

Referenced by QCDEStyle::drawControl().

856 {
857  switch(element) {
858  case CE_Splitter: {
859  QStyleOption handleOpt = *opt;
860  if (handleOpt.state & State_Horizontal)
861  handleOpt.state &= ~State_Horizontal;
862  else
863  handleOpt.state |= State_Horizontal;
865  break; }
866 
867  case CE_ScrollBarSubLine:
868  case CE_ScrollBarAddLine:{
869  PrimitiveElement pe;
870  if (element == CE_ScrollBarAddLine)
872  else
873  pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp;
874  QStyleOption arrowOpt = *opt;
875  arrowOpt.state |= State_Enabled;
876  proxy()->drawPrimitive(pe, &arrowOpt, p, widget);
879  p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern));
880  }
881  }break;
882 
883  case CE_ScrollBarSubPage:
884  case CE_ScrollBarAddPage:
886  break;
887 
888  case CE_ScrollBarSlider: {
889  QStyleOption bevelOpt = *opt;
890  bevelOpt.state |= State_Raised;
891  bevelOpt.state &= ~(State_Sunken | State_On);
892  p->save();
893  p->setBrushOrigin(bevelOpt.rect.topLeft());
894  proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
895  p->restore();
898  break; }
899 
900  case CE_RadioButton:
901  case CE_CheckBox:
902  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
903  bool isRadio = (element == CE_RadioButton);
904  QStyleOptionButton subopt = *btn;
905  subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
906  : SE_CheckBoxIndicator, btn, widget);
908  &subopt, p, widget);
909  subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
910  : SE_CheckBoxContents, btn, widget);
911  proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
912  if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
913  QStyleOptionFocusRect fropt;
914  fropt.QStyleOption::operator=(*btn);
916  : SE_CheckBoxFocusRect, btn, widget);
918  }
919  }
920  break;
921  case CE_PushButton:
922  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
924  QStyleOptionButton subopt = *btn;
926  proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
927  if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
928  QStyleOptionFocusRect fropt;
929  fropt.QStyleOption::operator=(*btn);
932  }
933  }
934  break;
935  case CE_PushButtonBevel:
936  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
937  int diw, x1, y1, x2, y2;
938  p->setPen(opt->palette.foreground().color());
941  opt->rect.getCoords(&x1, &y1, &x2, &y2);
943  x1 += diw;
944  y1 += diw;
945  x2 -= diw;
946  y2 -= diw;
947  }
948  if (btn->features & QStyleOptionButton::DefaultButton) {
949  if (diw == 0) {
950  QPolygon a;
951  a.setPoints(9,
952  x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
953  x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1);
954  p->setPen(opt->palette.shadow().color());
955  p->drawPolygon(a);
956  x1 += 2;
957  y1 += 2;
958  x2 -= 2;
959  y2 -= 2;
960  } else {
961  qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true);
962  }
963  }
964  if (!(btn->features & QStyleOptionButton::Flat) ||
965  (btn->state & (State_Sunken | State_On))) {
966  QStyleOptionButton newOpt = *btn;
967  newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
968  p->setBrushOrigin(p->brushOrigin());
970  }
971  if (btn->features & QStyleOptionButton::HasMenu) {
972  int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
973  QRect ir = btn->rect;
974  QStyleOptionButton newBtn = *btn;
975  newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8);
977  }
978  break;
979  }
980 
981 #ifndef QT_NO_TABBAR
982  case CE_TabBarTabShape:
983  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
984  const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget);
985  const int frame_offset = (default_frame > 1) ? 1 : 0;
986 
987  if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
988  tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
989  p->save();
990  QRect tabRect = opt->rect;
991  QColor tabLight = opt->palette.light().color();
992  QColor tabDark = opt->palette.dark().color();
993 
994  p->fillRect(opt->rect.adjusted(default_frame, default_frame,
995  -default_frame, -default_frame),
996  tab->palette.background());
997 
998  if(tab->shape == QTabBar::RoundedWest) {
999  tabDark = opt->palette.light().color();
1000  tabLight = opt->palette.dark().color();
1001  tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
1002  p->translate(opt->rect.left(), opt->rect.bottom());
1003  p->rotate(-90);
1004  } else if(tab->shape == QTabBar::RoundedSouth) {
1005  tabDark = opt->palette.light().color();
1006  tabLight = opt->palette.dark().color();
1007  tabRect = QRect(0, 0, tabRect.width(), tabRect.height());
1008  p->translate(opt->rect.right(), opt->rect.bottom());
1009  p->rotate(180);
1010  } else if(tab->shape == QTabBar::RoundedEast) {
1011  tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
1012  p->translate(opt->rect.right(), opt->rect.top());
1013  p->rotate(90);
1014  }
1015 
1016  if (default_frame > 1) {
1017  p->setPen(tabLight);
1018  p->drawLine(tabRect.left(), tabRect.bottom(),
1019  tabRect.right(), tabRect.bottom());
1020  p->setPen(tabLight);
1021  p->drawLine(tabRect.left(), tabRect.bottom()-1,
1022  tabRect.right(), tabRect.bottom()-1);
1023  if (tabRect.left() == 0)
1024  p->drawPoint(tabRect.bottomLeft());
1025  } else {
1026  p->setPen(tabLight);
1027  p->drawLine(tabRect.left(), tabRect.bottom(),
1028  tabRect.right(), tabRect.bottom());
1029  }
1030 
1031  if (opt->state & State_Selected) {
1032  p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset,
1033  tabRect.width()-3, 2),
1034  tab->palette.brush(QPalette::Active, QPalette::Background));
1035  p->setPen(tab->palette.background().color());
1036  p->drawLine(tabRect.left()+1, tabRect.bottom(),
1037  tabRect.left()+1, tabRect.top()+2);
1038  p->setPen(tabLight);
1039  } else {
1040  p->setPen(tabLight);
1041  }
1042  p->drawLine(tabRect.left(), tabRect.bottom()-1,
1043  tabRect.left(), tabRect.top() + 2);
1044  p->drawPoint(tabRect.left()+1, tabRect.top() + 1);
1045  p->drawLine(tabRect.left()+2, tabRect.top(),
1046  tabRect.right() - 2, tabRect.top());
1047  p->drawPoint(tabRect.left(), tabRect.bottom());
1048 
1049  if (default_frame > 1) {
1050  p->drawLine(tabRect.left()+1, tabRect.bottom(),
1051  tabRect.left()+1, tabRect.top() + 2);
1052  p->drawLine(tabRect.left()+2, tabRect.top()+1,
1053  tabRect.right() - 2, tabRect.top()+1);
1054  }
1055 
1056  p->setPen(tabDark);
1057  p->drawLine(tabRect.right() - 1, tabRect.top() + 2,
1058  tabRect.right() - 1, tabRect.bottom() - 1 +
1059  ((opt->state & State_Selected) ? frame_offset : -frame_offset));
1060  if (default_frame > 1) {
1061  p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
1062  p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(),
1063  tabRect.bottom() -
1064  ((opt->state & State_Selected) ?
1065  ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset));
1066  p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
1067  }
1068  p->restore();
1069  } else {
1070  QCommonStyle::drawControl(element, opt, p, widget);
1071  }
1072  break; }
1073 #endif // QT_NO_TABBAR
1074  case CE_ProgressBarGroove:
1075  qDrawShadePanel(p, opt->rect, opt->palette, true, 2);
1076  break;
1077 
1078  case CE_ProgressBarLabel:
1079  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1080  QTransform oldMatrix = p->transform();
1081  QRect rect = pb->rect;
1082  bool vertical = false;
1083  bool invert = false;
1084  bool bottomToTop = false;
1085  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
1086  vertical = (pb2->orientation == Qt::Vertical);
1087  invert = pb2->invertedAppearance;
1088  bottomToTop = pb2->bottomToTop;
1089  }
1090  if (vertical) {
1091  QTransform m;
1092  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1093  if (bottomToTop) {
1094  m.translate(0.0, rect.width());
1095  m.rotate(-90);
1096  } else {
1097  m.translate(rect.height(), 0.0);
1098  m.rotate(90);
1099  }
1100  p->setTransform(m, true);
1101  }
1102  const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget);
1103  int u = rect.width() / unit_width;
1104  int p_v = pb->progress - pb->minimum;
1105  int t_s = qMax(0, pb->maximum - pb->minimum);
1106  if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) {
1107  // scale down to something usable.
1108  p_v /= u;
1109  t_s /= u;
1110  }
1111  if (pb->textVisible && t_s) {
1112  int nu = (u * p_v + t_s/2) / t_s;
1113  int x = unit_width * nu;
1114  QRect left(rect.x(), rect.y(), x, rect.height());
1115  QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height());
1116  Qt::LayoutDirection dir;
1117  dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction;
1118  if (invert)
1119  dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight;
1120  const QRect highlighted = visualRect(dir, rect, left);
1121  const QRect background = visualRect(dir, rect, right);
1122  p->setPen(opt->palette.highlightedText().color());
1123  p->setClipRect(highlighted);
1124  p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
1125 
1126  if (pb->progress != pb->maximum) {
1127  p->setClipRect(background);
1128  p->setPen(opt->palette.highlight().color());
1129  p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
1130  }
1131  }
1132  p->setTransform(oldMatrix, false);
1133  break;
1134  }
1135 
1136  case CE_MenuTearoff: {
1137  if(opt->state & State_Selected) {
1138  if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1)
1139  qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(),
1140  opt->rect.height(), opt->palette, false, motifItemFrame,
1141  &opt->palette.brush(QPalette::Button));
1142  else
1143  qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2,
1144  opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button));
1145  } else {
1146  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1147  }
1148  p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1149  p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4,
1150  opt->rect.y()+opt->rect.height()/2-1);
1151  p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1152  p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4,
1153  opt->rect.y()+opt->rect.height()/2);
1154  break; }
1155 
1156  case CE_MenuItem:
1157  if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1158  int maxpmw = menuitem->maxIconWidth;
1159  if(menuitem->menuHasCheckableItems)
1160  maxpmw = qMax(maxpmw, motifCheckMarkSpace);
1161 
1162  int x, y, w, h;
1163  opt->rect.getRect(&x, &y, &w, &h);
1164 
1165  if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator
1166  int textWidth = 0;
1167  if (!menuitem->text.isEmpty()) {
1168  QFont oldFont = p->font();
1169  p->setFont(menuitem->font);
1170  p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
1171  proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
1172  menuitem->palette, menuitem->state & State_Enabled, menuitem->text,
1173  QPalette::Text);
1174  textWidth = menuitem->fontMetrics.width(menuitem->text) + 10;
1175  y += menuitem->fontMetrics.height() / 2;
1176  p->setFont(oldFont);
1177  }
1178  p->setPen(opt->palette.dark().color());
1179  p->drawLine(x, y, x + 5, y);
1180  p->drawLine(x + 5 + textWidth, y, x+w, y);
1181  p->setPen(opt->palette.light().color());
1182  p->drawLine(x, y + 1, x + 5, y + 1);
1183  p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1);
1184  return;
1185  }
1186 
1187  int pw = motifItemFrame;
1188  if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame
1189  if(pixelMetric(PM_MenuPanelWidth, opt) > 1)
1190  qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw,
1191  &opt->palette.brush(QPalette::Button));
1192  else
1193  qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1,
1194  &opt->palette.brush(QPalette::Button));
1195  } else { // incognito frame
1196  p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
1197  }
1198 
1199  QRect vrect = visualRect(opt->direction, opt->rect,
1200  QRect(x+motifItemFrame, y+motifItemFrame, maxpmw,
1201  h-2*motifItemFrame));
1202  int xvis = vrect.x();
1203  if (menuitem->checked) {
1204  if(!menuitem->icon.isNull())
1205  qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
1206  opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight));
1207  } else if (!(opt->state & State_Selected)) {
1208  p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
1210  }
1211 
1212  if(!menuitem->icon.isNull()) { // draw icon
1213  QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif
1214  if ((opt->state & State_Selected) && !!(opt->state & State_Enabled))
1215  mode = QIcon::Active;
1216  QPixmap pixmap;
1217  if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked)
1218  pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
1219  else
1220  pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode);
1221 
1222  int pixw = pixmap.width();
1223  int pixh = pixmap.height();
1224  QRect pmr(0, 0, pixw, pixh);
1225  pmr.moveCenter(vrect.center());
1226  p->setPen(opt->palette.text().color());
1227  p->drawPixmap(pmr.topLeft(), pixmap);
1228 
1229  } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"...
1230  int mh = h - 2*motifItemFrame;
1231 
1232  QStyleOptionButton newMenuItem;
1233  newMenuItem.state = menuitem->checked ? State_On : State_None;
1234  if (opt->state & State_Enabled) {
1235  newMenuItem.state |= State_Enabled;
1236  if (menuitem->state & State_Sunken)
1237  newMenuItem.state |= State_Sunken;
1238  }
1239  if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) {
1240  newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11);
1241  proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget);
1242  } else {
1243  newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9);
1244  proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget);
1245  }
1246  }
1247 
1248  p->setPen(opt->palette.buttonText().color());
1249 
1250  QColor discol;
1251  if (!(opt->state & State_Enabled)) {
1252  discol = opt->palette.text().color();
1253  p->setPen(discol);
1254  }
1255 
1256  int xm = motifItemFrame + maxpmw + motifItemHMargin;
1257 
1258  vrect = visualRect(opt->direction, opt->rect,
1259  QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth,
1260  h-2*motifItemVMargin));
1261  xvis = vrect.x();
1262 
1263  QString s = menuitem->text;
1264  if (!s.isNull()) { // draw text
1265  int t = s.indexOf(QLatin1Char('\t'));
1266  int m = motifItemVMargin;
1268  text_flags |= Qt::AlignLeft;
1269  QFont oldFont = p->font();
1270  p->setFont(menuitem->font);
1271  if (t >= 0) { // draw tab text
1272  QRect vr = visualRect(opt->direction, opt->rect,
1273  QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame,
1274  y+motifItemVMargin, menuitem->tabWidth,
1275  h-2*motifItemVMargin));
1276  int xv = vr.x();
1277  QRect tr(xv, y+m, menuitem->tabWidth, h-2*m);
1278  p->drawText(tr, text_flags, s.mid(t+1));
1281  s = s.left(t);
1282  }
1283  QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m);
1284  p->drawText(tr, text_flags, s.left(t));
1285  p->setFont(oldFont);
1288  }
1289  if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow
1290  int dim = (h-2*motifItemFrame) / 2;
1292  QStyleOption arrowOpt = *opt;
1293  arrowOpt.rect = visualRect(opt->direction, opt->rect,
1294  QRect(x+w - motifArrowHMargin - motifItemFrame - dim,
1295  y+h/2-dim/2, dim, dim));
1296  if ((opt->state & State_Selected))
1297  arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None));
1298  else
1299  arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None);
1300  proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
1301  }
1302  break; }
1303 
1304  case CE_MenuBarItem:
1305  if (opt->state & State_Selected) // active item
1306  qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame,
1307  &opt->palette.brush(QPalette::Button));
1308  else // other item
1309  p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1310  QCommonStyle::drawControl(element, opt, p, widget);
1311  break;
1312 
1313  case CE_HeaderSection:
1314  p->save();
1315  p->setBrushOrigin(opt->rect.topLeft());
1316  qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)),
1319  p->restore();
1320  break;
1321  case CE_RubberBand: {
1322  QPixmap tiledPixmap(16, 16);
1323  QPainter pixmapPainter(&tiledPixmap);
1324  pixmapPainter.setPen(Qt::NoPen);
1325  pixmapPainter.setBrush(Qt::Dense4Pattern);
1326  pixmapPainter.setBackground(QBrush(opt->palette.base()));
1327  pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1328  pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1329  pixmapPainter.end();
1330  // ### workaround for borked XRENDER
1331  tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1332 
1333  p->save();
1334  QRect r = opt->rect;
1335  QStyleHintReturnMask mask;
1336  if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1337  p->setClipRegion(mask.region);
1338  p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1339  p->restore();
1340  }
1341  break;
1342 #ifndef QT_NO_PROGRESSBAR
1344  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1345  QRect rect = pb->rect;
1346  bool vertical = false;
1347  bool inverted = false;
1348 
1349  // Get extra style options if version 2
1351  if (pb2) {
1352  vertical = (pb2->orientation == Qt::Vertical);
1353  inverted = pb2->invertedAppearance;
1354  }
1355 
1356  QTransform m;
1357  if (vertical) {
1358  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1359  m.rotate(90);
1360  m.translate(0, -(rect.height() + rect.y()*2));
1361  }
1362 
1363  QPalette pal2 = pb->palette;
1364  // Correct the highlight color if it is the same as the background
1365  if (pal2.highlight() == pal2.background())
1366  pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1368  bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1369  if (inverted)
1370  reverse = !reverse;
1371  int w = rect.width();
1372  if (pb->minimum == 0 && pb->maximum == 0) {
1373  QRect progressBar;
1374  Q_D(const QMotifStyle);
1375  // draw busy indicator
1376  int x = (d->animateStep*8)% (w * 2);
1377  if (x > w)
1378  x = 2 * w - x;
1379  x = reverse ? rect.right() - x : x + rect.x();
1380  p->setTransform(m, true);
1381  p->setPen(QPen(pal2.highlight().color(), 4));
1382  p->drawLine(x, rect.y(), x, rect.height());
1383 
1384  } else
1385  QCommonStyle::drawControl(element, opt, p, widget);
1386  }
1387  break;
1388 #endif // QT_NO_PROGRESSBAR
1389  default:
1390  QCommonStyle::drawControl(element, opt, p, widget);
1391  break; }
1392 }
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPointer< QWidget > widget
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
bool isVisible() const
Definition: qwidget.h:1005
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
static C reverse(const C &l)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
Qt::Orientation orientation
the progress bar&#39;s orientation (horizontal or vertical); the default orentation is Qt::Horizontal ...
Definition: qstyleoption.h:422
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
static const int motifCheckMarkSpace
Definition: qmotifstyle.cpp:89
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
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
const QBrush & foreground() const
Use windowText() instead.
Definition: qpalette.h:123
quint16 u
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void getCoords(int *x1, int *y1, int *x2, int *y2) const
Extracts the position of the rectangle&#39;s top-left corner to *x1 and *y1, and the position of the bott...
Definition: qrect.h:408
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
static const int motifItemHMargin
Definition: qmotifstyle.cpp:84
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
LayoutDirection
Definition: qnamespace.h:1580
static const int motifArrowHMargin
Definition: qmotifstyle.cpp:86
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
The QMotifStyle class provides Motif look and feel.
Definition: qmotifstyle.h:60
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
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QPoint bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:297
PrimitiveElement
This enum describes the various primitive elements.
Definition: qstyle.h:145
static const int motifItemFrame
Definition: qmotifstyle.cpp:82
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
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
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
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
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
void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle&#39;s top-left corner to *x and *y, and its dimensions to *width a...
Definition: qrect.h:392
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
bool invertedAppearance
whether the progress bar&#39;s appearance is inverted
Definition: qstyleoption.h:423
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define INT_MAX
static const int motifItemVMargin
Definition: qmotifstyle.cpp:85
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
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawPrimitive()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 366 of file qmotifstyle.cpp.

Referenced by QCDEStyle::drawPrimitive().

368 {
369  switch(pe) {
371  if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
372  if (lv->items.isEmpty())
373  return;
374 
375  if (lv->state & State_Enabled)
376  p->setPen(QPen(opt->palette.text().color()));
377  else
378  p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text)));
379  QPolygon a;
380 
381  int cx = opt->rect.width()/2 - 1;
382  int cy = opt->rect.height()/2;
383  int e = opt->rect.width()/2 - 1;
384  for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work
385  a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
386  p->drawPolygon(a);
387  e--;
388  }
389  if (opt->state & State_On) {
390  if (lv->state & State_Enabled)
391  p->setPen(QPen(opt->palette.text().color()));
392  else
393  p->setPen(QPen(lv->palette.color(QPalette::Disabled,
394  QPalette::Text)));
395  QBrush saveBrush = p->brush();
396  p->setBrush(opt->palette.text());
397  e = e - 2;
398  a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
399  p->drawPolygon(a);
400  p->setBrush(saveBrush);
401  }
402  }
403  break;
404 
405  case PE_FrameTabWidget:
406  case PE_FrameWindow:
408  break;
409  case PE_FrameFocusRect:
410  if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
411  if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
412  && !(fropt->state & QStyle::State_Item))
413  break;
414  QCommonStyle::drawPrimitive(pe, opt, p, w);
415  }
416  break;
417 
419  p->save();
420  p->translate(opt->rect.x(), opt->rect.y());
421 
422  QColor dark(opt->palette.dark().color());
423  QColor light(opt->palette.light().color());
424  int i;
425  if (opt->state & State_Horizontal) {
426  int h = opt->rect.height();
427  if (h > 6) {
428  if (opt->state & State_On)
429  p->fillRect(1, 1, 8, h - 2, opt->palette.highlight());
430  QPolygon a(2 * ((h-6)/3));
431  int y = 3 + (h%3)/2;
432  p->setPen(dark);
433  p->drawLine(8, 1, 8, h-2);
434  for (i=0; 2*i < a.size(); ++i) {
435  a.setPoint(2*i, 5, y+1+3*i);
436  a.setPoint(2*i+1, 2, y+2+3*i);
437  }
438  p->drawPoints(a);
439  p->setPen(light);
440  p->drawLine(9, 1, 9, h-2);
441  for (i=0; 2*i < a.size(); i++) {
442  a.setPoint(2*i, 4, y+3*i);
443  a.setPoint(2*i+1, 1, y+1+3*i);
444  }
445  p->drawPoints(a);
446  // if (drawBorder) {
447  // p->setPen(QPen(Qt::darkGray));
448  // p->drawLine(0, opt->rect.height() - 1,
449  // tbExtent, opt->rect.height() - 1);
450  // }
451  }
452  } else {
453  int w = opt->rect.width();
454  if (w > 6) {
455  if (opt->state & State_On)
456  p->fillRect(1, 1, w - 2, 9, opt->palette.highlight());
457  QPolygon a(2 * ((w-6)/3));
458 
459  int x = 3 + (w%3)/2;
460  p->setPen(dark);
461  p->drawLine(1, 8, w-2, 8);
462  for (i=0; 2*i < a.size(); ++i) {
463  a.setPoint(2*i, x+1+3*i, 6);
464  a.setPoint(2*i+1, x+2+3*i, 3);
465  }
466  p->drawPoints(a);
467  p->setPen(light);
468  p->drawLine(1, 9, w-2, 9);
469  for (i=0; 2*i < a.size(); ++i) {
470  a.setPoint(2*i, x+3*i, 5);
471  a.setPoint(2*i+1, x+1+3*i, 2);
472  }
473  p->drawPoints(a);
474  // if (drawBorder) {
475  // p->setPen(QPen(Qt::darkGray));
476  // p->drawLine(opt->rect.width() - 1, 0,
477  // opt->rect.width() - 1, tbExtent);
478  // }
479  }
480  }
481  p->restore();
482  break; }
483 
485  case PE_PanelButtonBevel:
486  case PE_PanelButtonTool: {
487  QBrush fill;
488  if (opt->state & State_Sunken)
489  fill = opt->palette.brush(QPalette::Mid);
490  else if ((opt->state & State_On) && (opt->state & State_Enabled))
491  fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern);
492  else
493  fill = opt->palette.brush(QPalette::Button);
494  if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise))
495  qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)),
497  break; }
498 
499  case PE_IndicatorCheckBox: {
500  bool on = opt->state & State_On;
501  bool down = opt->state & State_Sunken;
502  bool showUp = !(down ^ on);
503  QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid);
504  if (opt->state & State_NoChange) {
505  qDrawPlainRect(p, opt->rect, opt->palette.text().color(),
506  1, &fill);
507  p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(),
508  opt->rect.x(), opt->rect.y() + opt->rect.height() - 1);
509  } else {
510  qDrawShadePanel(p, opt->rect, opt->palette, !showUp,
512  }
515  break; }
516 
518 #define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
519  int inner_pts[] = { // used for filling diamond
520  2,opt->rect.height()/2,
521  opt->rect.width()/2,2,
522  opt->rect.width()-3,opt->rect.height()/2,
523  opt->rect.width()/2,opt->rect.height()-3
524  };
525  int top_pts[] = { // top (^) of diamond
526  0,opt->rect.height()/2,
527  opt->rect.width()/2,0,
528  opt->rect.width()-2,opt->rect.height()/2-1,
529  opt->rect.width()-3,opt->rect.height()/2-1,
530  opt->rect.width()/2,1,
531  1,opt->rect.height()/2,
532  2,opt->rect.height()/2,
533  opt->rect.width()/2,2,
534  opt->rect.width()-4,opt->rect.height()/2-1
535  };
536  int bottom_pts[] = { // bottom (v) of diamond
537  1,opt->rect.height()/2+1,
538  opt->rect.width()/2,opt->rect.height()-1,
539  opt->rect.width()-1,opt->rect.height()/2,
540  opt->rect.width()-2,opt->rect.height()/2,
541  opt->rect.width()/2,opt->rect.height()-2,
542  2,opt->rect.height()/2+1,
543  3,opt->rect.height()/2+1,
544  opt->rect.width()/2,opt->rect.height()-3,
545  opt->rect.width()-3,opt->rect.height()/2
546  };
547  bool on = opt->state & State_On;
548  bool down = opt->state & State_Sunken;
549  bool showUp = !(down ^ on);
550  QPen oldPen = p->pen();
551  QBrush oldBrush = p->brush();
552  QPolygon a(INTARRLEN(inner_pts), inner_pts);
553  p->setPen(Qt::NoPen);
554  p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid));
555  a.translate(opt->rect.x(), opt->rect.y());
556  p->drawPolygon(a);
557  p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color());
558  p->setBrush(Qt::NoBrush);
559  a.setPoints(INTARRLEN(top_pts), top_pts);
560  a.translate(opt->rect.x(), opt->rect.y());
561  p->drawPolyline(a);
562  p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color());
563  a.setPoints(INTARRLEN(bottom_pts), bottom_pts);
564  a.translate(opt->rect.x(), opt->rect.y());
565  p->drawPolyline(a);
568  p->setPen(oldPen);
569  p->setBrush(oldBrush);
570  break; }
571 
572  case PE_IndicatorSpinUp:
576  case PE_IndicatorArrowUp:
579  case PE_IndicatorArrowLeft: {
580  QRect rect = opt->rect;
581  QPolygon bFill;
582  QPolygon bTop;
583  QPolygon bBot;
584  QPolygon bLeft;
585  if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp)
586  pe = PE_IndicatorArrowUp;
587  else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown)
589  bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown;
590  bool horizontal = !vertical;
591  int dim = rect.width() < rect.height() ? rect.width() : rect.height();
592  int colspec = 0x0000;
593 
594  if (!(opt->state & State_Enabled))
595  dim -= 2;
596  if(dim < 2)
597  break;
598 
599  // adjust size and center (to fix rotation below)
600  if (rect.width() > dim) {
601  rect.setX(rect.x() + ((rect.width() - dim) / 2));
602  rect.setWidth(dim);
603  }
604  if (rect.height() > dim) {
605  rect.setY(rect.y() + ((rect.height() - dim) / 2));
606  rect.setHeight(dim);
607  }
608 
609  if (dim > 3) {
610  if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style
611  bFill.resize( dim & 1 ? 3 : 4 );
612  bTop.resize( 2 );
613  bBot.resize( 2 );
614  bLeft.resize( 2 );
615  bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
616  bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
617  bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
618 
619  if ( dim > 6 ) { // dim>6: must fill interior
620  bFill.putPoints( 0, 2, 0, dim-1, 0, 0 );
621  if ( dim & 1 ) // if size is an odd number
622  bFill.setPoint( 2, dim - 1, dim / 2 );
623  else
624  bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 );
625  }
626  } else {
627  if (dim > 6)
628  bFill.resize(dim & 1 ? 3 : 4);
629  bTop.resize((dim/2)*2);
630  bBot.resize(dim & 1 ? dim + 1 : dim);
631  bLeft.resize(dim > 4 ? 4 : 2);
632  bLeft.putPoints(0, 2, 0,0, 0,dim-1);
633  if (dim > 4)
634  bLeft.putPoints(2, 2, 1,2, 1,dim-3);
635  bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
636  bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
637 
638  for(int i=0; i<dim/2-2 ; i++) {
639  bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
640  bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
641  }
642  if (dim & 1) // odd number size: extra line
643  bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
644  if (dim > 6) { // dim>6: must fill interior
645  bFill.putPoints(0, 2, 1,dim-3, 1,2);
646  if (dim & 1) // if size is an odd number
647  bFill.setPoint(2, dim - 3, dim / 2);
648  else
649  bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
650  }
651  }
652  } else {
653  if (dim == 3) { // 3x3 arrow pattern
654  bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
655  bTop .setPoints(2, 1,0, 1,0);
656  bBot .setPoints(2, 1,2, 2,1);
657  }
658  else { // 2x2 arrow pattern
659  bLeft.setPoints(2, 0,0, 0,1);
660  bTop .setPoints(2, 1,0, 1,0);
661  bBot .setPoints(2, 1,1, 1,1);
662  }
663  }
664 
665  // We use rot() and translate() as it is more efficient that
666  // matrix transformations on the painter, and because it still
667  // works with QT_NO_TRANSFORMATIONS defined.
668 
669  if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) {
670  if (vertical) {
671  rot(bFill,3);
672  rot(bLeft,3);
673  rot(bTop,3);
674  rot(bBot,3);
675  bFill.translate(0, rect.height() - 1);
676  bLeft.translate(0, rect.height() - 1);
677  bTop.translate(0, rect.height() - 1);
678  bBot.translate(0, rect.height() - 1);
679  } else {
680  rot(bFill,2);
681  rot(bLeft,2);
682  rot(bTop,2);
683  rot(bBot,2);
684  bFill.translate(rect.width() - 1, rect.height() - 1);
685  bLeft.translate(rect.width() - 1, rect.height() - 1);
686  bTop.translate(rect.width() - 1, rect.height() - 1);
687  bBot.translate(rect.width() - 1, rect.height() - 1);
688  }
689  if (opt->state & State_Sunken)
690  colspec = horizontal ? 0x2334 : 0x2343;
691  else
692  colspec = horizontal ? 0x1443 : 0x1434;
693  } else {
694  if (vertical) {
695  rot(bFill,1);
696  rot(bLeft,1);
697  rot(bTop,1);
698  rot(bBot,1);
699  bFill.translate(rect.width() - 1, 0);
700  bLeft.translate(rect.width() - 1, 0);
701  bTop.translate(rect.width() - 1, 0);
702  bBot.translate(rect.width() - 1, 0);
703  }
704  if (opt->state & State_Sunken)
705  colspec = horizontal ? 0x2443 : 0x2434;
706  else
707  colspec = horizontal ? 0x1334 : 0x1343;
708  }
709  bFill.translate(rect.x(), rect.y());
710  bLeft.translate(rect.x(), rect.y());
711  bTop.translate(rect.x(), rect.y());
712  bBot.translate(rect.x(), rect.y());
713 
714  const QColor *cols[5];
715  if (opt->state & State_Enabled) {
716  cols[0] = 0;
717  cols[1] = &opt->palette.button().color();
718  cols[2] = &opt->palette.mid().color();
719  cols[3] = &opt->palette.light().color();
720  cols[4] = &opt->palette.dark().color();
721  } else {
722  cols[0] = 0;
723  cols[1] = &opt->palette.mid().color();
724  cols[2] = &opt->palette.mid().color();
725  cols[3] = &opt->palette.mid().color();
726  cols[4] = &opt->palette.mid().color();
727  }
728 
729 #define CMID *cols[(colspec>>12) & 0xf]
730 #define CLEFT *cols[(colspec>>8) & 0xf]
731 #define CTOP *cols[(colspec>>4) & 0xf]
732 #define CBOT *cols[colspec & 0xf]
733 
734  QPen savePen = p->pen();
735  QBrush saveBrush = p->brush();
736  QPen pen(Qt::NoPen);
737  QBrush brush = opt->palette.brush((opt->state & State_Enabled) ?
738  QPalette::Button : QPalette::Mid);
739  p->setPen(pen);
740  p->setBrush(brush);
741  p->drawPolygon(bFill);
742  p->setBrush(Qt::NoBrush);
743 
744  p->setPen(CLEFT);
745  p->drawPolyline(bLeft);
746  p->setPen(CTOP);
747  p->drawPolyline(bTop);
748  p->setPen(CBOT);
749  p->drawPolyline(bBot);
750 
751  p->setBrush(saveBrush);
752  p->setPen(savePen);
753 #undef CMID
754 #undef CLEFT
755 #undef CTOP
756 #undef CBOT
759  break; }
760 
762  const int motifOffset = 10;
763  int sw = proxy()->pixelMetric(PM_SplitterWidth);
764  if (opt->state & State_Horizontal) {
765  int yPos = opt->rect.y() + opt->rect.height() / 2;
766  int kPos = opt->rect.right() - motifOffset - sw;
767  int kSize = sw - 2;
768 
769  qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette);
770  qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize,
771  opt->palette, false, 1, &opt->palette.brush(QPalette::Button));
772  qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette);
773  } else {
774  int xPos = opt->rect.x() + opt->rect.width() / 2;
775  int kPos = motifOffset;
776  int kSize = sw - 2;
777 
778  qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette);
779  qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette,
780  false, 1, &opt->palette.brush(QPalette::Button));
781  qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette);
782  }
783  break; }
784 
786  const int markW = 6;
787  const int markH = 6;
788  int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1;
789  int posY = opt->rect.y() + (opt->rect.height() - markH) / 2;
790  int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
791 
792  if (dfw < 2) {
793  // Could do with some optimizing/caching...
794  QPolygon a(7*2);
795  int i, xx, yy;
796  xx = posX;
797  yy = 3 + posY;
798  for (i=0; i<3; i++) {
799  a.setPoint(2*i, xx, yy);
800  a.setPoint(2*i+1, xx, yy+2);
801  xx++; yy++;
802  }
803  yy -= 2;
804  for (i=3; i<7; i++) {
805  a.setPoint(2*i, xx, yy);
806  a.setPoint(2*i+1, xx, yy+2);
807  xx++; yy--;
808  }
809  if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) {
810  int pnt;
811  p->setPen(opt->palette.highlightedText().color());
812  QPoint offset(1,1);
813  for (pnt = 0; pnt < (int)a.size(); pnt++)
814  a[pnt] += offset;
815  p->drawPolyline(a);
816  for (pnt = 0; pnt < (int)a.size(); pnt++)
817  a[pnt] -= offset;
818  }
819  p->setPen(opt->palette.text().color());
820  p->drawPolyline(a);
821 
822  qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw);
823  } else
824  qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw,
825  &opt->palette.brush(QPalette::Mid));
826 
827  break; }
828 
830  {
831  bool vertical = false;
832  if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
833  vertical = (pb2->orientation == Qt::Vertical);
834  if (!vertical) {
835  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(),
837  } else {
838  p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
840  }
841  }
842  break;
843 
844  default:
845  QCommonStyle::drawPrimitive(pe, opt, p, w);
846  break;
847  }
848 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:511
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen&#39;s color.
Definition: qpainter.cpp:3816
const QBrush & background() const
Returns the current background brush.
Definition: qpainter.cpp:2482
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
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.
The QStyleOptionQ3ListView class is used to describe the parameters for drawing a Q3ListView...
Definition: qstyleoption.h:747
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
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
long ASN1_INTEGER_get ASN1_INTEGER * a
void putPoints(int index, int nPoints, const int *points)
Copies nPoints points from the points coord array into this point array, and resizes the point array ...
Definition: qpolygon.cpp:406
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void 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 QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
#define CTOP
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
void translate(int dx, int dy)
Translates all points in the polygon by ({dx}, {dy}).
Definition: qpolygon.cpp:238
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
static void rot(QPolygon &a, int n)
#define CBOT
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition: qpalette.h:128
The QStyleOptionFocusRect class is used to describe the parameters for drawing a focus rectangle with...
Definition: qstyleoption.h:103
#define INTARRLEN(x)
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Definition: qdrawutil.cpp:303
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
void setX(int x)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:282
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
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
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
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
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Definition: qpolygon.h:120
#define CLEFT
const QStyle * proxy() const
Definition: qstyle.cpp:2546
void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Definition: qpolygon.cpp:350
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition: qdrawutil.cpp:93
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
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
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ event()

bool QMotifStyle::event ( QEvent e)
virtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 2623 of file qmotifstyle.cpp.

2624 {
2625  if(e->type() == QEvent::FocusIn) {
2626  if (QWidget *focusWidget = QApplication::focusWidget()) {
2627 #ifndef QT_NO_GRAPHICSVIEW
2628  if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget)) {
2629  QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0;
2630  if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) {
2631  QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget *>(focusItem);
2632  if (proxy->widget())
2633  focusWidget = proxy->widget()->focusWidget();
2634  }
2635  }
2636 #endif
2637  if(!focus)
2638  focus = new QFocusFrame(focusWidget);
2639  focus->setWidget(focusWidget);
2640  } else {
2641  if(focus)
2642  focus->setWidget(0);
2643  }
2644  } else if(e->type() == QEvent::FocusOut) {
2645  if(focus)
2646  focus->setWidget(0);
2647  }
2648  return QCommonStyle::event(e);
2649 }
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
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.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene&#39;s current focus item, or 0 if no item curr...
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...
QPointer< QFocusFrame > focus
Definition: qmotifstyle.h:110
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
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.

◆ eventFilter()

bool QMotifStyle::eventFilter ( QObject o,
QEvent e 
)
protectedvirtual
Warning
This function is not part of the public interface. Animate indeterminate progress bars only when visible

Reimplemented from QObject.

Definition at line 159 of file qmotifstyle.cpp.

160 {
161 #ifndef QT_NO_PROGRESSBAR
162  Q_D(QMotifStyle);
163  switch(e->type()) {
164  case QEvent::StyleChange:
165  case QEvent::Show:
166  if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
167  d->bars << bar;
168  if (d->bars.size() == 1) {
169  Q_ASSERT(d->animationFps> 0);
170  d->animateTimer = startTimer(1000 / d->animationFps);
171  }
172  }
173  break;
174  case QEvent::Destroy:
175  case QEvent::Hide:
176  // reinterpret_cast because there is no type info when getting
177  // the destroy event. We know that it is a QProgressBar.
178  if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
179  d->bars.removeAll(bar);
180  if (d->bars.isEmpty() && d->animateTimer) {
181  killTimer(d->animateTimer);
182  d->animateTimer = 0;
183  }
184  }
185  default:
186  break;
187  }
188 #endif // QT_NO_PROGRESSBAR
189  return QStyle::eventFilter(o, e);
190 }
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
double d
Definition: qnumeric_p.h:62
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QMotifStyle class provides Motif look and feel.
Definition: qmotifstyle.h:60
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650

◆ pixelMetric()

int QMotifStyle::pixelMetric ( PixelMetric  metric,
const QStyleOption option = 0,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1803 of file qmotifstyle.cpp.

Referenced by drawComplexControl(), drawControl(), drawPrimitive(), and QCDEStyle::pixelMetric().

1805 {
1806  int ret = 0;
1807 
1808  switch(pm) {
1810  ret = 5;
1811  break;
1812 
1815  ret = 10;
1816  break;
1817 
1818  case PM_ToolBarFrameWidth:
1820  break;
1821 
1822  case PM_ToolBarItemMargin:
1823  ret = 1;
1824  break;
1825 
1828  ret = 0;
1829  break;
1830 
1831  case PM_SplitterWidth:
1832  ret = qMax(10, QApplication::globalStrut().width());
1833  break;
1834 
1835  case PM_SliderLength:
1836  ret = 30;
1837  break;
1838 
1839  case PM_SliderThickness:
1840  ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth);
1841  break;
1842 #ifndef QT_NO_SLIDER
1844  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1845  int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
1846  int ticks = sl->tickPosition;
1847  int n = 0;
1848  if (ticks & QSlider::TicksAbove)
1849  n++;
1850  if (ticks & QSlider::TicksBelow)
1851  n++;
1852  if (!n) {
1853  ret = space;
1854  break;
1855  }
1856 
1857  int thick = 6; // Magic constant to get 5 + 16 + 5
1858 
1859  space -= thick;
1860  //### the two sides may be unequal in size
1861  if (space > 0)
1862  thick += (space * 2) / (n + 2);
1863  ret = thick;
1864  }
1865  break;
1866 
1868  if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1869  if (sl->orientation == Qt::Horizontal)
1870  ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1871  else
1872  ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
1873  }
1874  break;
1875 #endif // QT_NO_SLIDER
1877  ret = 2;
1878  break;
1879 
1881  ret = 9;
1882  break;
1883 
1885  ret = 1;
1886  break;
1887 
1890  ret = 13;
1891  break;
1892 
1893  case PM_MenuBarHMargin:
1894  ret = 2; // really ugly, but Motif
1895  break;
1896 
1898  if (!opt)
1899  ret = 12;
1900  else
1901  ret = qMax(12, (opt->rect.height() - 4) / 3);
1902  break;
1903  default:
1904  ret = QCommonStyle::pixelMetric(pm, opt, widget);
1905  break;
1906  }
1907  return ret;
1908 }
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int pixelMetric(PixelMetric m, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
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

◆ polish() [1/3]

void QMotifStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 257 of file qmotifstyle.cpp.

258 {
260  QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
264  }
265 
266  if (highlightCols)
267  return;
268 
269  // force the ugly motif way of highlighting *sigh*
282 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
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
bool highlightCols
Definition: qmotifstyle.h:119
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
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
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

◆ polish() [2/3]

void QMotifStyle::polish ( QWidget widget)
virtual

Keep QStyle::polish() visible.

Reimplemented Function

Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 292 of file qmotifstyle.cpp.

293 {
294  QStyle::polish(widget);
295 #ifndef QT_NO_PROGRESSBAR
296  if (qobject_cast<QProgressBar *>(widget))
297  widget->installEventFilter(this);
298 #endif
299 }
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
virtual void polish(QWidget *)
Initializes the appearance of the given widget.
Definition: qstyle.cpp:390

◆ polish() [3/3]

void QMotifStyle::polish ( QApplication a)
virtual

Keep QStyle::polish() visible.

Reimplemented Function

Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 330 of file qmotifstyle.cpp.

331 {
333 }
void polish(QPalette &)
Reimplemented Function

◆ setUseHighlightColors()

void QMotifStyle::setUseHighlightColors ( bool  arg)

If arg is false, the style will polish the application's color palette to emulate the Motif way of highlighting, which is a simple inversion between the base and the text color.

The effect will show up the next time an application palette is set via QApplication::setPalette(). The current color palette of the application remains unchanged.

See also
QStyle::polish()

Definition at line 239 of file qmotifstyle.cpp.

240 {
241  highlightCols = arg;
242 }
bool highlightCols
Definition: qmotifstyle.h:119

◆ sizeFromContents()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2044 of file qmotifstyle.cpp.

2046 {
2047  QSize sz(contentsSize);
2048 
2049  switch(ct) {
2050  case CT_RadioButton:
2051  case CT_CheckBox:
2052  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2053  sz.rwidth() += motifItemFrame;
2054  break;
2055 
2056  case CT_PushButton:
2057  if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2058  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2059  if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)))
2060  sz.setWidth(qMax(75, sz.width()));
2061  sz += QSize(0, 1); // magical extra pixel
2062  }
2063  break;
2064 
2065  case CT_MenuBarItem: {
2066  if(!sz.isEmpty())
2068  break; }
2069 
2070  case CT_MenuItem:
2071  if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
2072  sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget);
2073  int w = sz.width(), h = sz.height();
2074 
2075  if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
2076  w = 10;
2077  h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height();
2078  }
2079 
2080  // a little bit of border can never harm
2081  w += 2*motifItemHMargin + 2*motifItemFrame;
2082 
2083  if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0)
2084  // string contains tab
2085  w += motifTabSpacing;
2086  else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
2087  // submenu indicator needs some room if we don't have a tab column
2089 
2090  int checkColumn = mi->maxIconWidth;
2091  if (mi->menuHasCheckableItems)
2092  checkColumn = qMax(checkColumn, motifCheckMarkSpace);
2093  if (checkColumn > 0)
2094  w += checkColumn + motifCheckMarkHMargin;
2095 
2096  sz = QSize(w, h);
2097  }
2098  break;
2099 
2100 
2101  default:
2102  sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
2103  break;
2104  }
2105 
2106  return sz;
2107 }
static const int motifCheckMarkHMargin
Definition: qmotifstyle.cpp:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
static const int motifCheckMarkSpace
Definition: qmotifstyle.cpp:89
static const int motifSepHeight
Definition: qmotifstyle.cpp:83
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static const int motifItemHMargin
Definition: qmotifstyle.cpp:84
static const int motifArrowHMargin
Definition: qmotifstyle.cpp:86
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
static const int motifItemFrame
Definition: qmotifstyle.cpp:82
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static const int motifItemVMargin
Definition: qmotifstyle.cpp:85
static const int motifTabSpacing
Definition: qmotifstyle.cpp:87

◆ standardIconImplementation

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

Definition at line 195 of file qmotifstyle.cpp.

Referenced by QCDEStyle::standardIconImplementation().

197 {
199 }
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt=0, const QWidget *widget=0) const

◆ standardPalette()

QPalette QMotifStyle::standardPalette ( ) const
virtual

Reimplemented Function

Reimplemented from QStyle.

Definition at line 2716 of file qmotifstyle.cpp.

2717 {
2718 #ifdef Q_WS_X11
2719  QColor background(0xcf, 0xcf, 0xcf);
2720  if (QX11Info::appDepth() <= 8)
2721  background = QColor(0xc0, 0xc0, 0xc0);
2722 #else
2723  QColor background = QColor(0xcf, 0xcf, 0xcf);
2724 #endif
2725 
2726  QColor light = background.lighter();
2727  QColor mid = QColor(0xa6, 0xa6, 0xa6);
2728  QColor dark = QColor(0x79, 0x7d, 0x79);
2729  QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2730  palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
2731  palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2732  palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
2733  palette.setBrush(QPalette::Disabled, QPalette::Base, background);
2734  return palette;
2735 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ standardPixmap()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2530 of file qmotifstyle.cpp.

2532 {
2533 #ifndef QT_NO_IMAGEFORMAT_XPM
2534  switch (standardPixmap) {
2535  case SP_TitleBarMenuButton:
2536  return QPixmap(qt_menu_xpm);
2538  return QPixmap(qt_shade_xpm);
2540  return QPixmap(qt_unshade_xpm);
2542  return QPixmap(qt_normalizeup_xpm);
2543  case SP_TitleBarMinButton:
2544  return QPixmap(qt_minimize_xpm);
2545  case SP_TitleBarMaxButton:
2546  return QPixmap(qt_maximize_xpm);
2548  return QPixmap(qt_close_xpm);
2551 
2553  case SP_MessageBoxWarning:
2554  case SP_MessageBoxCritical:
2555  case SP_MessageBoxQuestion:
2556  {
2557  const char * const * xpm_data;
2558  switch (standardPixmap) {
2560  xpm_data = information_xpm;
2561  break;
2562  case SP_MessageBoxWarning:
2563  xpm_data = warning_xpm;
2564  break;
2565  case SP_MessageBoxCritical:
2566  xpm_data = critical_xpm;
2567  break;
2568  case SP_MessageBoxQuestion:
2569  xpm_data = question_xpm;
2570  break;
2571  default:
2572  xpm_data = 0;
2573  break;
2574  }
2575  QPixmap pm;
2576  if (xpm_data) {
2577  QImage image((const char **) xpm_data);
2578  // All that color looks ugly in Motif
2579  const QPalette &pal = QApplication::palette();
2580  switch (standardPixmap) {
2582  case SP_MessageBoxQuestion:
2583  image.setColor(2, 0xff000000 |
2585  image.setColor(3, 0xff000000 |
2587  image.setColor(4, 0xff000000 |
2589  break;
2590  case SP_MessageBoxWarning:
2591  image.setColor(1, 0xff000000 |
2593  image.setColor(2, 0xff000000 |
2595  image.setColor(3, 0xff000000 |
2597  break;
2598  case SP_MessageBoxCritical:
2599  image.setColor(1, 0xff000000 |
2601  image.setColor(2, 0xff000000 |
2603  image.setColor(3, 0xff000000 |
2605  break;
2606  default:
2607  break;
2608  }
2609  pm = QPixmap::fromImage(image);
2610  }
2611  return pm;
2612  }
2613 
2614  default:
2615  break;
2616  }
2617 #endif
2618 
2619  return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
2620 }
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
static const char *const information_xpm[]
static const char *const qt_normalizeup_xpm[]
static const char *const qt_menu_xpm[]
static QPalette palette()
Returns the application palette.
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
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=0, const QWidget *widget=0) const
Reimplemented Function
static const char *const qt_shade_xpm[]
static const char *const qt_close_xpm[]
static const char * dock_window_close_xpm[]
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
static const char *const qt_unshade_xpm[]
static const char *const qt_maximize_xpm[]
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static const char *const critical_xpm[]
static const char *const warning_xpm[]
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051
static const char *const qt_minimize_xpm[]
static const char *const question_xpm[]
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ styleHint()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2654 of file qmotifstyle.cpp.

Referenced by drawControl(), QCDEStyle::drawPrimitive(), and drawPrimitive().

2656 {
2657  int ret;
2658 
2659  switch (hint) {
2660 #ifdef QT3_SUPPORT
2661  case SH_GUIStyle:
2662  ret = Qt::MotifStyle;
2663  break;
2664 #endif
2666  ret = true;
2667  break;
2668 
2674  case SH_DitherDisabledText:
2675  ret = 1;
2676  break;
2677 
2679  ret = 96;
2680  break;
2681 
2684  break;
2685 
2687  ret = 0;
2688  break;
2689 
2691  ret = 1;
2692  break;
2693 
2695  ret = QPalette::Mid;
2696  break;
2697 
2698  case SH_DialogButtonLayout:
2700  break;
2702  ret = '*';
2703  break;
2705  ret = 0;
2706  break;
2707  default:
2708  ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
2709  break;
2710  }
2711 
2712  return ret;
2713 }
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function

◆ subControlRect()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1915 of file qmotifstyle.cpp.

1917 {
1918  switch (cc) {
1919 #ifndef QT_NO_SPINBOX
1920  case CC_SpinBox:
1921  if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1922  int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
1923  QSize bs;
1924  bs.setHeight(opt->rect.height()/2 - fw);
1925  bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean
1927  int y = fw + spinbox->rect.y();
1928  int x, lx, rx;
1929  x = spinbox->rect.x() + opt->rect.width() - fw - bs.width();
1930  lx = fw;
1931  rx = x - fw * 2;
1932  const int margin = spinbox->frame ? 4 : 0;
1933  switch (sc) {
1934  case SC_SpinBoxUp:
1935  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1936  return QRect();
1937  return visualRect(spinbox->direction, spinbox->rect,
1938  QRect(x, y, bs.width(), bs.height() - 1));
1939  case SC_SpinBoxDown:
1940  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1941  return QRect();
1942  return visualRect(spinbox->direction, spinbox->rect,
1943  QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1));
1944  case SC_SpinBoxEditField:
1945  if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
1946  return visualRect(spinbox->direction, spinbox->rect,
1947  QRect(lx + margin, y + margin,
1948  spinbox->rect.width() - 2*fw - 2*margin,
1949  spinbox->rect.height() - 2*fw - 2*margin));
1950 
1951  return visualRect(spinbox->direction, spinbox->rect,
1952  QRect(lx + margin, y + margin, rx - margin,
1953  spinbox->rect.height() - 2*fw - 2 * margin));
1954  case SC_SpinBoxFrame:
1955  return visualRect(spinbox->direction, spinbox->rect, spinbox->rect);
1956  default:
1957  break;
1958  }
1959  break; }
1960 #endif // QT_NO_SPINBOX
1961 #ifndef QT_NO_SLIDER
1962  case CC_Slider:
1963  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1964  if (sc == SC_SliderHandle) {
1965  int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget);
1966  int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget);
1967  bool horizontal = slider->orientation == Qt::Horizontal;
1968  int len = proxy()->pixelMetric(PM_SliderLength, opt, widget);
1969  int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth);
1970  int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
1971  horizontal ? slider->rect.width() - len - 2 * motifBorder
1972  : slider->rect.height() - len - 2 * motifBorder,
1973  slider->upsideDown);
1974  if (horizontal)
1975  return visualRect(slider->direction, slider->rect,
1976  QRect(sliderPos + motifBorder, tickOffset + motifBorder, len,
1977  thickness - 2 * motifBorder));
1978  return visualRect(slider->direction, slider->rect,
1979  QRect(tickOffset + motifBorder, sliderPos + motifBorder,
1980  thickness - 2 * motifBorder, len));
1981  }
1982  }
1983  break;
1984 #endif // QT_NO_SLIDER
1985 #ifndef QT_NO_SCROLLBAR
1986  case CC_ScrollBar:
1987  if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1988  int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
1989  QRect rect = visualRect(scrollbar->direction, scrollbar->rect,
1990  QCommonStyle::subControlRect(cc, scrollbar, sc, widget));
1991  if (sc == SC_ScrollBarSlider) {
1992  if (scrollbar->orientation == Qt::Horizontal)
1993  rect.adjust(-dfw, dfw, dfw, -dfw);
1994  else
1995  rect.adjust(dfw, -dfw, -dfw, dfw);
1996  } else if (sc != SC_ScrollBarGroove) {
1997  if (scrollbar->orientation == Qt::Horizontal)
1998  rect.adjust(0, dfw, 0, -dfw);
1999  else
2000  rect.adjust(dfw, 0, -dfw, 0);
2001  }
2002  return visualRect(scrollbar->direction, scrollbar->rect, rect);
2003  }
2004  break;
2005 #endif // QT_NO_SCROLLBAR
2006 #ifndef QT_NO_COMBOBOX
2007  case CC_ComboBox:
2008  if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2009  switch (sc) {
2010  case SC_ComboBoxArrow: {
2011  int ew, awh, sh, dh, ax, ay, sy;
2012  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
2013  QRect cr = opt->rect;
2014  cr.adjust(fw, fw, -fw, -fw);
2015  get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy);
2016  return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight()));
2017  }
2018 
2019  case SC_ComboBoxEditField: {
2020  int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
2021  QRect rect = opt->rect;
2022  rect.adjust(fw, fw, -fw, -fw);
2023  int ew = get_combo_extra_width(rect.height(), rect.width());
2024  rect.adjust(1, 1, -1-ew, -1);
2025  return visualRect(cb->direction, cb->rect, rect);
2026  }
2027 
2028  default:
2029  break;
2030  }
2031  }
2032  break;
2033 #endif // QT_NO_SCROLLBAR
2034  default:
2035  break;
2036  }
2037  return QCommonStyle::subControlRect(cc, opt, sc, widget);
2038 }
static void get_combo_parameters(const QRect &r, int &ew, int &awh, int &ax, int &ay, int &sh, int &dh, int &sy)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static int get_combo_extra_width(int h, int w, int *return_awh=0)
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.
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
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
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
int height() const
Returns the height.
Definition: qsize.h:129
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function

◆ subElementRect()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2113 of file qmotifstyle.cpp.

Referenced by drawComplexControl(), and drawControl().

2114 {
2115  QRect rect;
2116 
2117  switch (sr) {
2118  case SE_SliderFocusRect:
2119  rect = QCommonStyle::subElementRect(sr, opt, widget);
2120  rect.adjust(2, 2, -2, -2);
2121  break;
2122 
2123  case SE_CheckBoxIndicator:
2125  {
2126  rect = visualRect(opt->direction, opt->rect,
2127  QCommonStyle::subElementRect(sr, opt, widget));
2129  rect = visualRect(opt->direction, opt->rect, rect);
2130  }
2131  break;
2132 
2133  case SE_ComboBoxFocusRect:
2134  {
2135  int awh, ax, ay, sh, sy, dh, ew;
2136  int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
2137  QRect tr = opt->rect;
2138 
2139  tr.adjust(fw, fw, -fw, -fw);
2140  get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
2141  rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
2142  break;
2143  }
2144 
2146  if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
2147  if (!dw->docked || !dw->closeEnabled)
2148  rect.setRect(0, 0, opt->rect.width(), opt->rect.height());
2149  else {
2150  if (dw->state == State_Horizontal)
2151  rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15);
2152  else
2153  rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2);
2154  }
2155  rect = visualRect(dw->direction, dw->rect, rect);
2156  }
2157  break;
2158 
2159  case SE_ProgressBarLabel:
2160  case SE_ProgressBarGroove:
2162  if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2163  int textw = 0;
2164  if (pb->textVisible)
2165  textw = pb->fontMetrics.width(QLatin1String("100%")) + 6;
2166 
2167  if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) {
2168  rect = opt->rect;
2169  } else {
2170  if(sr == SE_ProgressBarLabel)
2171  rect.setCoords(opt->rect.right() - textw, opt->rect.top(),
2172  opt->rect.right(), opt->rect.bottom());
2173  else
2174  rect.setCoords(opt->rect.left(), opt->rect.top(),
2175  opt->rect.right() - textw, opt->rect.bottom());
2176  }
2177  if (sr == SE_ProgressBarContents)
2178  rect.adjust(2, 2, -2, -2);
2179  rect = visualRect(pb->direction, pb->rect, rect);
2180  }
2181  break;
2182  case SE_CheckBoxClickRect:
2184  rect = visualRect(opt->direction, opt->rect, opt->rect);
2185  break;
2186 
2187  default:
2188  rect = QCommonStyle::subElementRect(sr, opt, widget);
2189  }
2190  return rect;
2191 }
static void get_combo_parameters(const QRect &r, int &ew, int &awh, int &ax, int &ay, int &sh, int &dh, int &sy)
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
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
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QStyleOptionQ3DockWindow class is used to describe the parameters for drawing various parts of a ...
Definition: qstyleoption.h:488
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
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
static const int motifItemFrame
Definition: qmotifstyle.cpp:82
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
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ timerEvent()

void QMotifStyle::timerEvent ( QTimerEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 204 of file qmotifstyle.cpp.

205 {
206 #ifndef QT_NO_PROGRESSBAR
207  Q_D(QMotifStyle);
208  if (event->timerId() == d->animateTimer) {
209  Q_ASSERT(d->animationFps > 0);
210  d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
211  foreach (QProgressBar *bar, d->bars) {
212  if ((bar->minimum() == 0 && bar->maximum() == 0))
213  bar->update();
214  }
215  }
216 #endif // QT_NO_PROGRESSBAR
217  event->ignore();
218 }
double d
Definition: qnumeric_p.h:62
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
int maximum
the progress bar&#39;s maximum value
Definition: qprogressbar.h:63
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
The QMotifStyle class provides Motif look and feel.
Definition: qmotifstyle.h:60
int minimum
the progress bar&#39;s minimum value
Definition: qprogressbar.h:62

◆ unpolish() [1/2]

void QMotifStyle::unpolish ( QWidget widget)
virtual

Keep QStyle::polish() visible.

Reimplemented Function

Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 309 of file qmotifstyle.cpp.

310 {
311  QCommonStyle::unpolish(widget);
312 #ifndef QT_NO_PROGRESSBAR
313  if (qobject_cast<QProgressBar *>(widget)) {
314  Q_D(QMotifStyle);
315  widget->removeEventFilter(this);
316  d->bars.removeAll(static_cast<QProgressBar*>(widget));
317  }
318 #endif
319 }
double d
Definition: qnumeric_p.h:62
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
#define Q_D(Class)
Definition: qglobal.h:2482
The QMotifStyle class provides Motif look and feel.
Definition: qmotifstyle.h:60
void unpolish(QWidget *widget)
Reimplemented Function

◆ unpolish() [2/2]

void QMotifStyle::unpolish ( QApplication a)
virtual

Keep QStyle::polish() visible.

Reimplemented Function

Warning
This function is not part of the public interface.

Reimplemented from QCommonStyle.

Definition at line 344 of file qmotifstyle.cpp.

345 {
347 }
void unpolish(QWidget *widget)
Reimplemented Function

◆ useHighlightColors()

bool QMotifStyle::useHighlightColors ( ) const

Returns true if the style treats the highlight colors of the palette in a Motif-like manner, which is a simple inversion between the base and the text color; otherwise returns false.

The default is false.

Definition at line 250 of file qmotifstyle.cpp.

Referenced by QMotifStyle().

251 {
252  return highlightCols;
253 }
bool highlightCols
Definition: qmotifstyle.h:119

Properties

◆ focus

QMotifStyle::focus
protected
Warning
This function is not part of the public interface.

Definition at line 110 of file qmotifstyle.h.

Referenced by drawComplexControl(), drawControl(), drawPrimitive(), event(), QMotifStyle(), and ~QMotifStyle().

◆ highlightCols

bool QMotifStyle::highlightCols
private

Definition at line 119 of file qmotifstyle.h.

Referenced by polish(), QMotifStyle(), setUseHighlightColors(), and useHighlightColors().


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