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

The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE. More...

#include <qplastiquestyle.h>

Inheritance diagram for QPlastiqueStyle:
QWindowsStyle QCommonStyle QStyle QObject

Public Functions

void drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
 Reimplemented Function More...
 
void drawControl (ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
 Reimplemented Function More...
 
void drawPrimitive (PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=0) const
 Reimplemented Function More...
 
SubControl hitTestComplexControl (ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=0) const
 Reimplemented Function More...
 
int pixelMetric (PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
 Reimplemented Function More...
 
void polish (QWidget *widget)
 Reimplemented Function More...
 
void polish (QApplication *app)
 Reimplemented Function More...
 
void polish (QPalette &pal)
 Reimplemented Function More...
 
 QPlastiqueStyle ()
 Constructs a QPlastiqueStyle object. More...
 
QSize sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) 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 *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
 Reimplemented Function More...
 
QRect subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
 Reimplemented Function More...
 
QRect subElementRect (SubElement element, const QStyleOption *option, const QWidget *widget) const
 Reimplemented Function More...
 
void unpolish (QWidget *widget)
 Reimplemented Function More...
 
void unpolish (QApplication *app)
 Reimplemented Function More...
 
 ~QPlastiqueStyle ()
 Destructs the QPlastiqueStyle object. More...
 
- Public Functions inherited from QWindowsStyle
void drawComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
 Reimplemented Function More...
 
void drawControl (ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
 Reimplemented Function More...
 
void drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
 Reimplemented Function More...
 
int pixelMetric (PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
 Reimplemented Function More...
 
void polish (QApplication *)
 Reimplemented Function More...
 
void polish (QWidget *)
 Reimplemented Function More...
 
void polish (QPalette &)
 Reimplemented Function More...
 
 QWindowsStyle ()
 Constructs a QWindowsStyle object. More...
 
QSize sizeFromContents (ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
 Reimplemented Function More...
 
QPixmap standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
 Reimplemented Function More...
 
int styleHint (StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
 Reimplemented Function More...
 
QRect subElementRect (SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
 Reimplemented Function More...
 
void unpolish (QApplication *)
 Reimplemented Function More...
 
void unpolish (QWidget *)
 Reimplemented Function More...
 
 ~QWindowsStyle ()
 Destroys the QWindowsStyle object. More...
 
- Public Functions inherited from QCommonStyle
QPixmap generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) 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...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Slots

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

Protected Functions

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

Properties

void * reserved
 

Additional Inherited Members

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

Detailed Description

The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE.

The Plastique style provides a default look and feel for widgets on X11 that closely resembles the Plastik style, introduced by Sandro Giessl in KDE 3.2.

qplastiquestyle.png
See also
QWindowsXPStyle, QMacStyle, QWindowsStyle, QCDEStyle, QMotifStyle

Definition at line 56 of file qplastiquestyle.h.

Constructors and Destructors

◆ QPlastiqueStyle()

QPlastiqueStyle::QPlastiqueStyle ( )

Constructs a QPlastiqueStyle object.

Definition at line 1036 of file qplastiquestyle.cpp.

1038 {
1039  setObjectName(QLatin1String("Plastique"));
1040 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
QWindowsStyle()
Constructs a QWindowsStyle object.

◆ ~QPlastiqueStyle()

QPlastiqueStyle::~QPlastiqueStyle ( )

Destructs the QPlastiqueStyle object.

Definition at line 1045 of file qplastiquestyle.cpp.

1046 {
1047 }

Functions

◆ drawComplexControl()

void QPlastiqueStyle::drawComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
QPainter painter,
const QWidget widget 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 3773 of file qplastiquestyle.cpp.

3775 {
3776  QColor borderColor = option->palette.background().color().darker(178);
3777  QColor alphaCornerColor;
3778  if (widget) {
3779  // ### backgroundrole/foregroundrole should be part of the style option
3780  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
3781  } else {
3782  alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
3783  }
3784  QColor gradientStartColor = option->palette.button().color().lighter(104);
3785  QColor gradientStopColor = option->palette.button().color().darker(105);
3786 
3787  switch (control) {
3788 #ifndef QT_NO_SLIDER
3789  case CC_Slider:
3790  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3791  QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
3792  QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
3793  bool horizontal = slider->orientation == Qt::Horizontal;
3794  bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
3795  bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
3796 
3797  QRect groove;
3798  //The clickable region is 5 px wider than the visible groove for improved usability
3799  if (grooveRegion.isValid())
3800  groove = horizontal ? grooveRegion.adjusted(0, 5, 0, -5) : grooveRegion.adjusted(5, 0, -5, 0);
3801 
3802 
3803  QPixmap cache;
3804 
3805  if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
3806  BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("slider_groove-%0-%1").arg(ticksAbove).arg(ticksBelow))
3807  p->fillRect(groove, option->palette.background());
3808 
3809  // draw groove
3810  if (horizontal) {
3811  p->setPen(borderColor);
3812  const QLine lines[4] = {
3813  QLine(groove.left() + 1, groove.top(),
3814  groove.right() - 1, groove.top()),
3815  QLine(groove.left() + 1, groove.bottom(),
3816  groove.right() - 1, groove.bottom()),
3817  QLine(groove.left(), groove.top() + 1,
3818  groove.left(), groove.bottom() - 1),
3819  QLine(groove.right(), groove.top() + 1,
3820  groove.right(), groove.bottom() - 1) };
3821  p->drawLines(lines, 4);
3822 
3823  p->setPen(alphaCornerColor);
3824  const QPoint points[4] = {
3825  QPoint(groove.left(), groove.top()),
3826  QPoint(groove.left(), groove.bottom()),
3827  QPoint(groove.right(), groove.top()),
3828  QPoint(groove.right(), groove.bottom()) };
3829  p->drawPoints(points, 4);
3830  } else {
3831  p->setPen(borderColor);
3832  const QLine lines[4] = {
3833  QLine(groove.left() + 1, groove.top(),
3834  groove.right() - 1, groove.top()),
3835  QLine(groove.left() + 1, groove.bottom(),
3836  groove.right() - 1, groove.bottom()),
3837  QLine(groove.left(), groove.top() + 1,
3838  groove.left(), groove.bottom() - 1),
3839  QLine(groove.right(), groove.top() + 1,
3840  groove.right(), groove.bottom() - 1) };
3841  p->drawLines(lines, 4);
3842 
3843  p->setPen(alphaCornerColor);
3844  const QPoint points[4] = {
3845  QPoint(groove.left(), groove.top()),
3846  QPoint(groove.right(), groove.top()),
3847  QPoint(groove.left(), groove.bottom()),
3848  QPoint(groove.right(), groove.bottom()) };
3849  p->drawPoints(points, 4);
3850  }
3852  }
3853 
3854  if ((option->subControls & SC_SliderHandle) && handle.isValid()) {
3855  QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
3856  if (ticksAbove && !ticksBelow)
3857  handlePixmapName += QLatin1String("-flipped");
3858  if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken))
3859  handlePixmapName += QLatin1String("-sunken");
3860 
3861  if (!QPixmapCache::find(handlePixmapName, cache)) {
3862  cache = QPixmap(handle.size());
3863  cache.fill(Qt::white);
3864  QRect pixmapRect(0, 0, handle.width(), handle.height());
3865  QPainter handlePainter(&cache);
3866  handlePainter.fillRect(pixmapRect, option->palette.background());
3867 
3868  // draw handle
3869  if (horizontal) {
3870  QPainterPath path;
3871  if (ticksAbove && !ticksBelow) {
3872  path.moveTo(QPoint(pixmapRect.right(), pixmapRect.bottom()));
3873  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom() - 10));
3874  path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.bottom() - 14));
3875  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom() - 10));
3876  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom()));
3877  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom()));
3878  } else {
3879  path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1));
3880  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 10));
3881  path.lineTo(QPoint(pixmapRect.right() - 5, pixmapRect.top() + 14));
3882  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 10));
3883  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1));
3884  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1));
3885  }
3886  if (slider->state & State_Enabled) {
3887  QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
3888  pixmapRect.center().x(), pixmapRect.bottom());
3889  if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) {
3890  gradient.setColorAt(0, gradientStartColor.lighter(110));
3891  gradient.setColorAt(1, gradientStopColor.lighter(110));
3892  } else {
3893  gradient.setColorAt(0, gradientStartColor);
3894  gradient.setColorAt(1, gradientStopColor);
3895  }
3896  handlePainter.fillPath(path, gradient);
3897  } else {
3898  handlePainter.fillPath(path, slider->palette.background());
3899  }
3900  } else {
3901  QPainterPath path;
3902  if (ticksAbove && !ticksBelow) {
3903  path.moveTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1));
3904  path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.top() + 1));
3905  path.lineTo(QPoint(pixmapRect.right() - 14, pixmapRect.top() + 5));
3906  path.lineTo(QPoint(pixmapRect.right() - 10, pixmapRect.bottom()));
3907  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.bottom()));
3908  path.lineTo(QPoint(pixmapRect.right(), pixmapRect.top() + 1));
3909  } else {
3910  path.moveTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1));
3911  path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.top() + 1));
3912  path.lineTo(QPoint(pixmapRect.left() + 14, pixmapRect.top() + 5));
3913  path.lineTo(QPoint(pixmapRect.left() + 10, pixmapRect.bottom()));
3914  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.bottom()));
3915  path.lineTo(QPoint(pixmapRect.left() + 1, pixmapRect.top() + 1));
3916  }
3917  if (slider->state & State_Enabled) {
3918  QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
3919  pixmapRect.center().x(), pixmapRect.bottom());
3920  gradient.setColorAt(0, gradientStartColor);
3921  gradient.setColorAt(1, gradientStopColor);
3922  handlePainter.fillPath(path, gradient);
3923  } else {
3924  handlePainter.fillPath(path, slider->palette.background());
3925  }
3926  }
3927 
3928  QImage image;
3929  if (horizontal) {
3931  } else {
3933  }
3934 
3935  image.setColor(1, borderColor.rgba());
3936  image.setColor(2, gradientStartColor.rgba());
3937  image.setColor(3, alphaCornerColor.rgba());
3938  if (option->state & State_Enabled) {
3939  image.setColor(4, 0x80ffffff);
3940  image.setColor(5, 0x25000000);
3941  }
3942  handlePainter.drawImage(pixmapRect, image);
3943  handlePainter.end();
3944  QPixmapCache::insert(handlePixmapName, cache);
3945  }
3946 
3947  painter->drawPixmap(handle.topLeft(), cache);
3948 
3949  if (slider->state & State_HasFocus) {
3950  QStyleOptionFocusRect fropt;
3951  fropt.QStyleOption::operator=(*slider);
3952  fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
3953  proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
3954  }
3955  }
3956 
3957  if (option->subControls & SC_SliderTickmarks) {
3958  QPen oldPen = painter->pen();
3959  painter->setPen(borderColor);
3960  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
3961  int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
3962  int interval = slider->tickInterval;
3963  if (interval <= 0) {
3964  interval = slider->singleStep;
3965  if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
3966  available)
3967  - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3968  0, available) < 3)
3969  interval = slider->pageStep;
3970  }
3971  if (interval <= 0)
3972  interval = 1;
3973 
3974  int v = slider->minimum;
3975  int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3977  while (v <= slider->maximum + 1) {
3978  if (v == slider->maximum + 1 && interval == 1)
3979  break;
3980  const int v_ = qMin(v, slider->maximum);
3981  int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
3982  v_, (horizontal
3983  ? slider->rect.width()
3984  : slider->rect.height()) - len,
3985  slider->upsideDown) + len / 2;
3986 
3987  int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
3988 
3989  if (horizontal) {
3990  if (ticksAbove) {
3991  lines.append(QLine(pos, slider->rect.top() + extra,
3992  pos, slider->rect.top() + tickSize));
3993  }
3994  if (ticksBelow) {
3995  lines.append(QLine(pos, slider->rect.bottom() - extra,
3996  pos, slider->rect.bottom() - tickSize));
3997  }
3998  } else {
3999  if (ticksAbove) {
4000  lines.append(QLine(slider->rect.left() + extra, pos,
4001  slider->rect.left() + tickSize, pos));
4002  }
4003  if (ticksBelow) {
4004  lines.append(QLine(slider->rect.right() - extra, pos,
4005  slider->rect.right() - tickSize, pos));
4006  }
4007  }
4008 
4009  // in the case where maximum is max int
4010  int nextInterval = v + interval;
4011  if (nextInterval < v)
4012  break;
4013  v = nextInterval;
4014  }
4015  painter->drawLines(lines.constData(), lines.size());
4016  painter->setPen(oldPen);
4017  }
4018  }
4019  break;
4020 #endif // QT_NO_SLIDER
4021 #ifndef QT_NO_SPINBOX
4022  case CC_SpinBox:
4023  if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
4024  painter->save();
4025  bool upSunken = (spinBox->activeSubControls & SC_SpinBoxUp) && (spinBox->state & (State_Sunken | State_On));
4026  bool downSunken = (spinBox->activeSubControls & SC_SpinBoxDown) && (spinBox->state & (State_Sunken | State_On));
4027  bool reverse = (spinBox->direction == Qt::RightToLeft);
4028 
4029  // Rects
4030  QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
4031  QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
4032  QRect buttonRect = upRect | downRect;
4033 
4034  // Brushes
4035  QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect);
4036  qBrushSetAlphaF(&corner, qreal(0.25));
4037  QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect);
4038  qBrushSetAlphaF(&border, qreal(0.4));
4039 
4041 
4042  Q_D(const QPlastiqueStyle);
4043  if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4044  QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
4045  QBrush baseBrush = qMapBrushToRect(option->palette.base(), filledRect);
4046  painter->setBrushOrigin(filledRect.topLeft());
4047  painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush);
4048  qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken);
4049  } else {
4050  d->drawPartialFrame(painter,
4051  option,
4052  proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget),
4053  widget);
4054  }
4055  // Paint buttons
4056  if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4057  painter->restore();
4058  break;
4059  }
4060  // Button outlines
4061  painter->setPen(QPen(border, 0));
4062  if (!reverse)
4063  painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1));
4064  else
4065  painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1));
4066 
4067  if (!reverse) {
4068  const QLine lines[4] = {
4069  QLine(upRect.left(), upRect.top(), upRect.right() - 2, upRect.top()),
4070  QLine(upRect.left() + 1, upRect.bottom(), upRect.right() - 1, upRect.bottom()),
4071  QLine(downRect.left(), downRect.bottom(), downRect.right() - 2, downRect.bottom()),
4072  QLine(buttonRect.right(), buttonRect.top() + 2, buttonRect.right(), buttonRect.bottom() - 2) };
4073  painter->drawLines(lines, 4);
4074 
4075  points.append(QPoint(upRect.right() - 1, upRect.top() + 1));
4076  points.append(QPoint(downRect.right() - 1, downRect.bottom() - 1));
4077  painter->drawPoints(points.constData(), points.size());
4078  points.clear();
4079  painter->setPen(QPen(corner, 0));
4080  points.append(QPoint(upRect.right() - 1, upRect.top()));
4081  points.append(QPoint(upRect.right(), upRect.top() + 1));
4082  points.append(QPoint(upRect.right(), downRect.bottom() - 1));
4083  points.append(QPoint(upRect.right() - 1, downRect.bottom()));
4084  } else {
4085  const QLine lines[4] = {
4086  QLine(upRect.right(), upRect.top(), upRect.left() + 2, upRect.top()),
4087  QLine(upRect.right() - 1, upRect.bottom(), upRect.left() + 1, upRect.bottom()),
4088  QLine(downRect.right(), downRect.bottom(), downRect.left() + 2, downRect.bottom()),
4089  QLine(buttonRect.left(), buttonRect.top() + 2, buttonRect.left(), buttonRect.bottom() - 2) };
4090  painter->drawLines(lines, 4);
4091 
4092  points.append(QPoint(upRect.left() + 1, upRect.top() + 1));
4093  points.append(QPoint(downRect.left() + 1, downRect.bottom() - 1));
4094  painter->drawPoints(points.constData(), points.size());
4095  points.clear();
4096  painter->setPen(QPen(corner, 0));
4097  points.append(QPoint(upRect.left() + 1, upRect.top()));
4098  points.append(QPoint(upRect.left(), upRect.top() + 1));
4099  points.append(QPoint(upRect.left(), downRect.bottom() - 1));
4100  points.append(QPoint(upRect.left() + 1, downRect.bottom()));
4101  }
4102  painter->drawPoints(points.constData(), points.size());
4103  points.clear();
4104 
4105  // Button colors
4106  QBrush buttonGradientBrush;
4107  QBrush leftLineGradientBrush;
4108  QBrush rightLineGradientBrush;
4109  QBrush sunkenButtonGradientBrush;
4110  QBrush sunkenLeftLineGradientBrush;
4111  QBrush sunkenRightLineGradientBrush;
4112  QBrush buttonBrush = qMapBrushToRect(option->palette.button(), buttonRect);
4113  if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) {
4114  buttonGradientBrush = buttonBrush;
4115  sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108);
4116  leftLineGradientBrush = qBrushLight(buttonBrush, 105);
4117  rightLineGradientBrush = qBrushDark(buttonBrush, 105);
4118  sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110);
4119  sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106);
4120  } else {
4121  // Generate gradients
4122  QLinearGradient buttonGradient(buttonRect.topLeft(), buttonRect.bottomLeft());
4123  buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104));
4124  buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110));
4125  buttonGradientBrush = QBrush(buttonGradient);
4126 
4127  QLinearGradient buttonGradient2(buttonRect.topLeft(), buttonRect.bottomLeft());
4128  buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113));
4129  buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103));
4130  sunkenButtonGradientBrush = QBrush(buttonGradient2);
4131 
4132  QLinearGradient buttonGradient3(buttonRect.topLeft(), buttonRect.bottomLeft());
4133  buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105));
4134  buttonGradient3.setColorAt(1.0, buttonBrush.color());
4135  leftLineGradientBrush = QBrush(buttonGradient3);
4136 
4137  QLinearGradient buttonGradient4(buttonRect.topLeft(), buttonRect.bottomLeft());
4138  buttonGradient4.setColorAt(0.0, buttonBrush.color());
4139  buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110));
4140  rightLineGradientBrush = QBrush(buttonGradient4);
4141 
4142  QLinearGradient buttonGradient5(buttonRect.topLeft(), buttonRect.bottomLeft());
4143  buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113));
4144  buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107));
4145  sunkenLeftLineGradientBrush = QBrush(buttonGradient5);
4146 
4147  QLinearGradient buttonGradient6(buttonRect.topLeft(), buttonRect.bottomLeft());
4148  buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108));
4149  buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103));
4150  sunkenRightLineGradientBrush = QBrush(buttonGradient6);
4151  }
4152 
4153  // Main fill
4154  painter->fillRect(upRect.adjusted(2, 2, -2, -2),
4155  qMapBrushToRect(upSunken ? sunkenButtonGradientBrush
4156  : buttonGradientBrush, upRect));
4157  painter->fillRect(downRect.adjusted(2, 2, -2, -2),
4158  qMapBrushToRect(downSunken ? sunkenButtonGradientBrush
4159  : buttonGradientBrush, downRect));
4160 
4161  // Top line
4162  painter->setPen(QPen(qBrushLight(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush
4163  : buttonGradientBrush, upRect), 105), 0));
4164  if (!reverse) {
4165  painter->drawLine(upRect.left() + 1, upRect.top() + 1,
4166  upRect.right() - 2, upRect.top() + 1);
4167  } else {
4168  painter->drawLine(upRect.right() - 1, upRect.top() + 1,
4169  upRect.left() + 2, upRect.top() + 1);
4170  }
4171  painter->setPen(QPen(qBrushLight(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush
4172  : buttonGradientBrush, downRect), 105), 0));
4173  if (!reverse) {
4174  painter->drawLine(downRect.left() + 1, downRect.top() + 1,
4175  downRect.right() - 1, downRect.top() + 1);
4176  } else {
4177  painter->drawLine(downRect.right() - 1, downRect.top() + 1,
4178  downRect.left() + 1, downRect.top() + 1);
4179  }
4180 
4181  // Left line
4182  painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenLeftLineGradientBrush
4183  : leftLineGradientBrush, upRect), 1));
4184  if (!reverse) {
4185  painter->drawLine(upRect.left() + 1, upRect.top() + 2,
4186  upRect.left() + 1, upRect.bottom() - 1);
4187  } else {
4188  painter->drawLine(upRect.left() + 1, upRect.top() + 2,
4189  upRect.left() + 1, upRect.bottom() - 1);
4190  }
4191  painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenLeftLineGradientBrush
4192  : leftLineGradientBrush, downRect), 1));
4193  if (!reverse) {
4194  painter->drawLine(downRect.left() + 1, downRect.top() + 2,
4195  downRect.left() + 1, downRect.bottom() - 1);
4196  } else {
4197  painter->drawLine(downRect.left() + 1, downRect.top() + 1,
4198  downRect.left() + 1, downRect.bottom() - 2);
4199  }
4200 
4201  // Bottom line
4202  painter->setPen(QPen(qBrushDark(qMapBrushToRect(upSunken ? sunkenButtonGradientBrush
4203  : buttonGradientBrush, upRect), 105), 0));
4204  if (!reverse) {
4205  painter->drawLine(upRect.left() + 2, upRect.bottom() - 1,
4206  upRect.right() - 1, upRect.bottom() - 1);
4207  } else {
4208  painter->drawLine(upRect.right() - 2, upRect.bottom() - 1,
4209  upRect.left() + 1, upRect.bottom() - 1);
4210  }
4211  painter->setPen(QPen(qBrushDark(qMapBrushToRect(downSunken ? sunkenButtonGradientBrush
4212  : buttonGradientBrush, downRect), 105), 0));
4213  if (!reverse) {
4214  painter->drawLine(downRect.left() + 2, downRect.bottom() - 1,
4215  downRect.right() - 2, downRect.bottom() - 1);
4216  } else {
4217  painter->drawLine(downRect.right() - 2, downRect.bottom() - 1,
4218  downRect.left() + 2, downRect.bottom() - 1);
4219  }
4220 
4221  // Right line
4222  painter->setPen(QPen(qMapBrushToRect(upSunken ? sunkenRightLineGradientBrush
4223  : rightLineGradientBrush, upRect), 1));
4224  if (!reverse) {
4225  painter->drawLine(upRect.right() - 1, upRect.top() + 2,
4226  upRect.right() - 1, upRect.bottom() - 1);
4227  } else {
4228  painter->drawLine(upRect.right() - 1, upRect.top() + 2,
4229  upRect.right() - 1, upRect.bottom() - 1);
4230  }
4231  painter->setPen(QPen(qMapBrushToRect(downSunken ? sunkenRightLineGradientBrush
4232  : rightLineGradientBrush, downRect), 1));
4233  if (!reverse) {
4234  painter->drawLine(downRect.right() - 1, downRect.top() + 1,
4235  downRect.right() - 1, downRect.bottom() - 2);
4236  } else {
4237  painter->drawLine(downRect.right() - 1, downRect.top() + 2,
4238  downRect.right() - 1, downRect.bottom() - 1);
4239  }
4240 
4241  QBrush indicatorBrush = qMapBrushToRect(option->palette.buttonText(), buttonRect);
4242  painter->setPen(QPen(indicatorBrush, 0));
4243  if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
4244  QPoint center;
4245  if (spinBox->subControls & SC_SpinBoxUp) {
4246  // .......
4247  // ...X...
4248  // ...X...
4249  // .XXXXX.
4250  // ...X...
4251  // ...X...
4252  // .......
4253  center = upRect.center();
4254  if (upSunken) {
4255  ++center.rx();
4256  ++center.ry();
4257  }
4258  painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2);
4259  painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y());
4260  }
4261  if (spinBox->subControls & SC_SpinBoxDown) {
4262  // .......
4263  // .......
4264  // .......
4265  // .XXXXX.
4266  // .......
4267  // .......
4268  // .......
4269  center = downRect.center();
4270  if (downSunken) {
4271  ++center.rx();
4272  ++center.ry();
4273  }
4274  painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y());
4275  }
4276  } else {
4277  int offset;
4278  int centerX;
4279  if (spinBox->subControls & SC_SpinBoxUp) {
4280  // ...........
4281  // .....X.....
4282  // ....XXX....
4283  // ...XXXXX...
4284  // ..XXXXXXX..
4285  // ...........
4286  offset = upSunken ? 1 : 0;
4287  QRect upArrowRect(upRect.center().x() - 3 + offset, upRect.center().y() - 2 + offset, 7, 4);
4288  centerX = upArrowRect.center().x();
4289  painter->drawPoint(centerX, upArrowRect.top());
4290  const QLine lines[3] = {
4291  QLine(centerX - 1, upArrowRect.top() + 1, centerX + 1, upArrowRect.top() + 1),
4292  QLine(centerX - 2, upArrowRect.top() + 2, centerX + 2, upArrowRect.top() + 2),
4293  QLine(centerX - 3, upArrowRect.top() + 3, centerX + 3, upArrowRect.top() + 3) };
4294  painter->drawLines(lines, 3);
4295  }
4296  if (spinBox->subControls & SC_SpinBoxDown) {
4297  // ...........
4298  // ..XXXXXXX..
4299  // ...XXXXX...
4300  // ....XXX....
4301  // .....X.....
4302  // ...........
4303  offset = downSunken ? 1 : 0;
4304  QRect downArrowRect(downRect.center().x() - 3 + offset, downRect.center().y() - 2 + offset + 1, 7, 4);
4305  centerX = downArrowRect.center().x();
4306  const QLine lines[3] = {
4307  QLine(centerX - 3, downArrowRect.top(), centerX + 3, downArrowRect.top()),
4308  QLine(centerX - 2, downArrowRect.top() + 1, centerX + 2, downArrowRect.top() + 1),
4309  QLine(centerX - 1, downArrowRect.top() + 2, centerX + 1, downArrowRect.top() + 2) };
4310  painter->drawLines(lines, 3);
4311  painter->drawPoint(centerX, downArrowRect.top() + 3);
4312  }
4313  }
4314  painter->restore();
4315  }
4316  break;
4317 #endif // QT_NO_SPINBOX
4318 #ifndef QT_NO_COMBOBOX
4319  case CC_ComboBox:
4320  if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
4321  bool sunken = comboBox->state & State_On; // play dead if combobox has no items
4322  bool reverse = comboBox->direction == Qt::RightToLeft;
4323  int menuButtonWidth = 16;
4324  int xoffset = sunken ? (reverse ? -1 : 1) : 0;
4325  int yoffset = sunken ? 1 : 0;
4326  QRect rect = comboBox->rect;
4327  QPen oldPen = painter->pen();
4328 
4329  // Fill
4330  if (comboBox->editable) {
4331  // Button colors
4332  QBrush alphaCornerBrush = qBrushDark(option->palette.button(), 165);
4333  qBrushSetAlphaF(&alphaCornerBrush, 0.5);
4334  QBrush buttonGradientBrush;
4335  QBrush leftLineGradientBrush;
4336  QBrush rightLineGradientBrush;
4337  QBrush sunkenButtonGradientBrush;
4338  QBrush sunkenLeftLineGradientBrush;
4339  QBrush sunkenRightLineGradientBrush;
4340  QBrush button = option->palette.button();
4341  if (button.gradient() || !button.texture().isNull()) {
4342  buttonGradientBrush = button;
4343  sunkenButtonGradientBrush = qBrushDark(button, 108);
4344  leftLineGradientBrush = qBrushLight(button, 105);
4345  rightLineGradientBrush = qBrushDark(button, 105);
4346  sunkenLeftLineGradientBrush = qBrushDark(button, 110);
4347  sunkenRightLineGradientBrush = qBrushDark(button, 106);
4348  } else {
4349  // Generate gradients
4350  QLinearGradient buttonGradient(option->rect.topLeft(), option->rect.bottomLeft());
4351  buttonGradient.setColorAt(0.0, button.color().lighter(104));
4352  buttonGradient.setColorAt(1.0, button.color().darker(110));
4353  buttonGradientBrush = QBrush(buttonGradient);
4354 
4355  QLinearGradient buttonGradient2(option->rect.topLeft(), option->rect.bottomLeft());
4356  buttonGradient2.setColorAt(0.0, button.color().darker(113));
4357  buttonGradient2.setColorAt(1.0, button.color().darker(103));
4358  sunkenButtonGradientBrush = QBrush(buttonGradient2);
4359 
4360  QLinearGradient buttonGradient3(option->rect.topLeft(), option->rect.bottomLeft());
4361  buttonGradient3.setColorAt(0.0, button.color().lighter(105));
4362  buttonGradient3.setColorAt(1.0, button.color());
4363  leftLineGradientBrush = QBrush(buttonGradient3);
4364 
4365  QLinearGradient buttonGradient4(option->rect.topLeft(), option->rect.bottomLeft());
4366  buttonGradient4.setColorAt(0.0, button.color());
4367  buttonGradient4.setColorAt(1.0, button.color().darker(110));
4368  rightLineGradientBrush = QBrush(buttonGradient4);
4369 
4370  QLinearGradient buttonGradient5(option->rect.topLeft(), option->rect.bottomLeft());
4371  buttonGradient5.setColorAt(0.0, button.color().darker(113));
4372  buttonGradient5.setColorAt(1.0, button.color().darker(107));
4373  sunkenLeftLineGradientBrush = QBrush(buttonGradient5);
4374 
4375  QLinearGradient buttonGradient6(option->rect.topLeft(), option->rect.bottomLeft());
4376  buttonGradient6.setColorAt(0.0, button.color().darker(108));
4377  buttonGradient6.setColorAt(1.0, button.color().darker(103));
4378  sunkenRightLineGradientBrush = QBrush(buttonGradient6);
4379  }
4380 
4381  // ComboBox starts with a lineedit in place already.
4382  QRect buttonRect;
4383  if (!reverse) {
4384  buttonRect.setRect(rect.right() - menuButtonWidth, rect.top(), menuButtonWidth + 1, rect.height());
4385  } else {
4386  buttonRect.setRect(rect.left(), rect.top(), menuButtonWidth + 1, rect.height());
4387  }
4388 
4389  Q_D(const QPlastiqueStyle);
4390  d->drawPartialFrame(painter,
4391  option,
4393  widget);
4394 
4395  QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect);
4396  qBrushSetAlphaF(&border, qreal(0.4));
4397  painter->setPen(QPen(border, 0));
4398  if (!reverse)
4399  painter->drawLine(buttonRect.topLeft() + QPoint(0, 1), buttonRect.bottomLeft() + QPoint(0, -1));
4400  else
4401  painter->drawLine(buttonRect.topRight() + QPoint(0, -1), buttonRect.bottomRight() + QPoint(0, 1));
4402 
4403  // Outline the button border
4404  if (!reverse) {
4405  const QLine lines[3] = {
4406  QLine(buttonRect.left(), buttonRect.top(),
4407  buttonRect.right() - 2, buttonRect.top()),
4408  QLine(buttonRect.right(), buttonRect.top() + 2,
4409  buttonRect.right(), buttonRect.bottom() - 2),
4410  QLine(buttonRect.left(), buttonRect.bottom(),
4411  buttonRect.right() - 2, buttonRect.bottom()) };
4412  painter->drawLines(lines, 3);
4413  {
4414  const QPoint points[2] = {
4415  QPoint(buttonRect.right() - 1, buttonRect.top() + 1),
4416  QPoint(buttonRect.right() - 1, buttonRect.bottom() - 1) };
4417  painter->drawPoints(points, 2);
4418  }
4419 
4420  QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect);
4421  qBrushSetAlphaF(&corner, qreal(0.16));
4422  painter->setPen(QPen(corner, 0));
4423  {
4424  const QPoint points[4] = {
4425  QPoint(buttonRect.right() - 1, buttonRect.top()),
4426  QPoint(buttonRect.right() - 1, buttonRect.bottom()),
4427  QPoint(buttonRect.right(), buttonRect.top() + 1),
4428  QPoint(buttonRect.right(), buttonRect.bottom() - 1) };
4429  painter->drawPoints(points, 4);
4430  }
4431  } else {
4432  const QLine lines[3] = {
4433  QLine(buttonRect.right(), buttonRect.top(),
4434  buttonRect.left() + 2, buttonRect.top()),
4435  QLine(buttonRect.left(), buttonRect.top() + 2,
4436  buttonRect.left(), buttonRect.bottom() - 2),
4437  QLine(buttonRect.right(), buttonRect.bottom(),
4438  buttonRect.left() + 2, buttonRect.bottom()) };
4439  painter->drawLines(lines, 3);
4440  {
4441  const QPoint points[2] = {
4442  QPoint(buttonRect.left() + 1, buttonRect.top() + 1),
4443  QPoint(buttonRect.left() + 1, buttonRect.bottom() - 1) };
4444  painter->drawPoints(points, 2);
4445  }
4446 
4447  QBrush corner = qMapBrushToRect(option->palette.shadow(), buttonRect);
4448  qBrushSetAlphaF(&corner, qreal(0.16));
4449  painter->setPen(QPen(corner, 0));
4450  {
4451  const QPoint points[4] = {
4452  QPoint(buttonRect.left() + 1, buttonRect.top()),
4453  QPoint(buttonRect.left() + 1, buttonRect.bottom()),
4454  QPoint(buttonRect.left(), buttonRect.top() + 1),
4455  QPoint(buttonRect.left(), buttonRect.bottom() - 1) };
4456  painter->drawPoints(points, 4);
4457  }
4458  }
4459 
4460  QRect fillRect = buttonRect.adjusted(2, 2, -2, -2);
4461  // Main fill
4462  painter->fillRect(fillRect,
4463  qMapBrushToRect(sunken ? sunkenButtonGradientBrush
4464  : buttonGradientBrush, option->rect));
4465 
4466  // Top line
4467  painter->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush
4468  : buttonGradientBrush, option->rect), 105), 0));
4469  if (!reverse) {
4470  painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 1),
4471  QPointF(buttonRect.right() - 2, buttonRect.top() + 1));
4472  } else {
4473  painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 1),
4474  QPointF(buttonRect.left() + 2, buttonRect.top() + 1));
4475  }
4476 
4477  // Bottom line
4478  painter->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush
4479  : buttonGradientBrush, option->rect), 105), 0));
4480  if (!reverse) {
4481  painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.bottom() - 1),
4482  QPointF(buttonRect.right() - 2, buttonRect.bottom() - 1));
4483  } else {
4484  painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.bottom() - 1),
4485  QPointF(buttonRect.left() + 2, buttonRect.bottom() - 1));
4486  }
4487 
4488  // Left line
4489  painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush
4490  : leftLineGradientBrush, option->rect), 1));
4491  if (!reverse) {
4492  painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2),
4493  QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2));
4494  } else {
4495  painter->drawLine(QPointF(buttonRect.left() + 1, buttonRect.top() + 2),
4496  QPointF(buttonRect.left() + 1, buttonRect.bottom() - 2));
4497  }
4498 
4499  // Right line
4500  painter->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush
4501  : rightLineGradientBrush, option->rect), 1));
4502  if (!reverse) {
4503  painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2),
4504  QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2));
4505  } else {
4506  painter->drawLine(QPointF(buttonRect.right() - 1, buttonRect.top() + 2),
4507  QPointF(buttonRect.right() - 1, buttonRect.bottom() - 2));
4508  }
4509  } else {
4510  // Start with a standard panel button fill
4511  QStyleOptionButton buttonOption;
4512  buttonOption.QStyleOption::operator=(*comboBox);
4513  if (!sunken) {
4514  buttonOption.state &= ~State_Sunken;
4515  }
4516  proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
4517 
4518  // Draw the menu button separator line
4519  QBrush border = qMapBrushToRect(option->palette.shadow(), rect);
4520  qBrushSetAlphaF(&border, qreal(0.35));
4521  painter->setPen(QPen(border, 0));
4522  if (!reverse) {
4523  painter->drawLine(rect.right() - menuButtonWidth + xoffset, rect.top() + 1,
4524  rect.right() - menuButtonWidth + xoffset, rect.bottom() - 1);
4525  } else {
4526  painter->drawLine(rect.left() + menuButtonWidth + xoffset, rect.top() + 1,
4527  rect.left() + menuButtonWidth + xoffset, rect.bottom() - 1);
4528  }
4529  }
4530 
4531  // Draw the little arrow
4532  if (comboBox->subControls & SC_ComboBoxArrow) {
4533  int left = !reverse ? rect.right() - menuButtonWidth : rect.left();
4534  int right = !reverse ? rect.right() : rect.left() + menuButtonWidth;
4535  QRect arrowRect((left + right) / 2 - 3 + xoffset,
4536  rect.center().y() - 1 + yoffset, 7, 4);
4537  painter->setPen(QPen(qMapBrushToRect(option->palette.buttonText(), rect), 0));
4538  const QLine lines[3] = {
4539  QLine(arrowRect.topLeft(), arrowRect.topRight()),
4540  QLine(arrowRect.left() + 1, arrowRect.top() + 1,
4541  arrowRect.right() - 1, arrowRect.top() + 1),
4542  QLine(arrowRect.left() + 2, arrowRect.top() + 2,
4543  arrowRect.right() - 2, arrowRect.top() + 2) };
4544  painter->drawLines(lines, 3);
4545  painter->drawPoint(arrowRect.center().x(), arrowRect.bottom());
4546  }
4547 
4548  // Draw the focus rect
4549  if ((option->state & State_HasFocus) && !comboBox->editable
4550  && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) {
4551  QStyleOptionFocusRect focus;
4552  focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget)
4553  .adjusted(-2, 0, 2, 0);
4554  proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
4555  }
4556 
4557  painter->setPen(oldPen);
4558  }
4559  break;
4560 #endif // QT_NO_COMBOBOX
4561  case CC_TitleBar:
4562  if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
4563  painter->save();
4564  bool active = (titleBar->titleBarState & State_Active);
4565  QRect fullRect = titleBar->rect;
4566 
4567  // ### use palette colors instead
4568  QColor titleBarGradientStart(active ? 0x3b508a : 0x6e6e6e);
4569  QColor titleBarGradientStop(active ? 0x5d6e9e : 0x818181);
4570  QColor titleBarFrameBorder(0x393939);
4571  QColor titleBarAlphaCorner(active ? 0x4b5e7f : 0x6a6a6a);
4572  QColor titleBarInnerTopLine(active ? 0x8e98ba : 0xa4a4a4);
4573  QColor titleBarInnerInnerTopLine(active ? 0x57699b : 0x808080);
4574  QColor leftCorner(active ? 0x6f7ea8 : 0x8e8e8e);
4575  QColor rightCorner(active ? 0x44537d : 0x676767);
4576  QColor textColor(active ? 0x282e40 : 0x282e40);
4577  QColor textAlphaColor(active ? 0x3f4862 : 0x3f4862);
4578 
4579 #ifdef QT3_SUPPORT
4580  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
4581  QStyleOptionDockWidgetV2 dockwidget;
4582  dockwidget.QStyleOption::operator=(*option);
4583  dockwidget.title = titleBar->text;
4584  proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
4585  } else
4586 #endif // QT3_SUPPORT
4587 
4588  {
4589  // Fill title bar gradient
4590  qt_plastique_draw_gradient(painter, option->rect.adjusted(1, 1, -1, 0),
4591  titleBarGradientStart,
4592  titleBarGradientStop);
4593 
4594  // Frame and rounded corners
4595  painter->setPen(titleBarFrameBorder);
4596 
4597  // top border line
4598  {
4599  const QLine lines[3] = {
4600  QLine(fullRect.left() + 2, fullRect.top(), fullRect.right() - 2, fullRect.top()),
4601  QLine(fullRect.left(), fullRect.top() + 2, fullRect.left(), fullRect.bottom()),
4602  QLine(fullRect.right(), fullRect.top() + 2, fullRect.right(), fullRect.bottom()) };
4603  painter->drawLines(lines, 3);
4604  const QPoint points[2] = {
4605  QPoint(fullRect.left() + 1, fullRect.top() + 1),
4606  QPoint(fullRect.right() - 1, fullRect.top() + 1) };
4607  painter->drawPoints(points, 2);
4608  }
4609 
4610  // alpha corners
4611  painter->setPen(titleBarAlphaCorner);
4612  {
4613  const QPoint points[4] = {
4614  QPoint(fullRect.left() + 2, fullRect.top() + 1),
4615  QPoint(fullRect.left() + 1, fullRect.top() + 2),
4616  QPoint(fullRect.right() - 2, fullRect.top() + 1),
4617  QPoint(fullRect.right() - 1, fullRect.top() + 2) };
4618  painter->drawPoints(points, 4);
4619  }
4620 
4621  // inner top line
4622  painter->setPen(titleBarInnerTopLine);
4623  painter->drawLine(fullRect.left() + 3, fullRect.top() + 1, fullRect.right() - 3, fullRect.top() + 1);
4624 
4625  // inner inner top line
4626  painter->setPen(titleBarInnerInnerTopLine);
4627  painter->drawLine(fullRect.left() + 2, fullRect.top() + 2, fullRect.right() - 2, fullRect.top() + 2);
4628 
4629  // left and right inner
4630  painter->setPen(leftCorner);
4631  painter->drawLine(fullRect.left() + 1, fullRect.top() + 3, fullRect.left() + 1, fullRect.bottom());
4632  painter->setPen(rightCorner);
4633  painter->drawLine(fullRect.right() - 1, fullRect.top() + 3, fullRect.right() - 1, fullRect.bottom());
4634 
4635  if (titleBar->titleBarState & Qt::WindowMinimized) {
4636  painter->setPen(titleBarFrameBorder);
4637  painter->drawLine(fullRect.left() + 2, fullRect.bottom(), fullRect.right() - 2, fullRect.bottom());
4638  {
4639  const QPoint points[2] = {
4640  QPoint(fullRect.left() + 1, fullRect.bottom() - 1),
4641  QPoint(fullRect.right() - 1, fullRect.bottom() - 1) };
4642  painter->drawPoints(points, 2);
4643  }
4644  painter->setPen(rightCorner);
4645  painter->drawLine(fullRect.left() + 2, fullRect.bottom() - 1, fullRect.right() - 2, fullRect.bottom() - 1);
4646  painter->setPen(titleBarAlphaCorner);
4647  {
4648  const QPoint points[4] = {
4649  QPoint(fullRect.left() + 1, fullRect.bottom() - 2),
4650  QPoint(fullRect.left() + 2, fullRect.bottom() - 1),
4651  QPoint(fullRect.right() - 1, fullRect.bottom() - 2),
4652  QPoint(fullRect.right() - 2, fullRect.bottom() - 1) };
4653  painter->drawPoints(points, 4);
4654  }
4655  }
4656  // draw title
4657  QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
4658 
4659  QFont font = painter->font();
4660  font.setBold(true);
4661  painter->setFont(font);
4662  painter->setPen(titleBar->palette.text().color());
4663 
4664  // Attempt to align left if there is not enough room for the title
4665  // text. Otherwise, align center. QWorkspace does elliding for us,
4666  // and it doesn't know about the bold title, so we need to work
4667  // around some of the width mismatches.
4668  bool tooWide = (QFontMetrics(font).width(titleBar->text) > textRect.width());
4670  option.setWrapMode(QTextOption::NoWrap);
4671 
4672  painter->drawText(textRect.adjusted(1, 1, 1, 1), titleBar->text, option);
4673  painter->setPen(titleBar->palette.highlightedText().color());
4674  painter->drawText(textRect, titleBar->text, option);
4675  }
4676 
4677  // min button
4678  if ((titleBar->subControls & SC_TitleBarMinButton)
4679  && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint)
4680  && !(titleBar->titleBarState & Qt::WindowMinimized)) {
4681  bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
4682  bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
4683 
4684  QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
4685  qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
4686 
4687  int xoffset = minButtonRect.width() / 3;
4688  int yoffset = minButtonRect.height() / 3;
4689 
4690  QRect minButtonIconRect(minButtonRect.left() + xoffset, minButtonRect.top() + yoffset,
4691  minButtonRect.width() - xoffset * 2, minButtonRect.height() - yoffset * 2);
4692 
4693  painter->setPen(textColor);
4694  {
4695  const QLine lines[2] = {
4696  QLine(minButtonIconRect.center().x() - 2,
4697  minButtonIconRect.center().y() + 3,
4698  minButtonIconRect.center().x() + 3,
4699  minButtonIconRect.center().y() + 3),
4700  QLine(minButtonIconRect.center().x() - 2,
4701  minButtonIconRect.center().y() + 4,
4702  minButtonIconRect.center().x() + 3,
4703  minButtonIconRect.center().y() + 4) };
4704  painter->drawLines(lines, 2);
4705  }
4706  painter->setPen(textAlphaColor);
4707  {
4708  const QLine lines[2] = {
4709  QLine(minButtonIconRect.center().x() - 3,
4710  minButtonIconRect.center().y() + 3,
4711  minButtonIconRect.center().x() - 3,
4712  minButtonIconRect.center().y() + 4),
4713  QLine(minButtonIconRect.center().x() + 4,
4714  minButtonIconRect.center().y() + 3,
4715  minButtonIconRect.center().x() + 4,
4716  minButtonIconRect.center().y() + 4) };
4717  painter->drawLines(lines, 2);
4718  }
4719  }
4720 
4721  // max button
4722  if ((titleBar->subControls & SC_TitleBarMaxButton)
4723  && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint)
4724  && !(titleBar->titleBarState & Qt::WindowMaximized)) {
4725  bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
4726  bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
4727 
4728  QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
4729  qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
4730 
4731  int xoffset = maxButtonRect.width() / 3;
4732  int yoffset = maxButtonRect.height() / 3;
4733 
4734  QRect maxButtonIconRect(maxButtonRect.left() + xoffset, maxButtonRect.top() + yoffset,
4735  maxButtonRect.width() - xoffset * 2, maxButtonRect.height() - yoffset * 2);
4736 
4737  painter->setPen(textColor);
4738  painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
4739  painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
4740  maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
4741  painter->setPen(textAlphaColor);
4742  const QPoint points[4] = {
4743  maxButtonIconRect.topLeft(), maxButtonIconRect.topRight(),
4744  maxButtonIconRect.bottomLeft(), maxButtonIconRect.bottomRight() };
4745  painter->drawPoints(points, 4);
4746  }
4747 
4748  // close button
4749  if (titleBar->subControls & SC_TitleBarCloseButton && titleBar->titleBarFlags & Qt::WindowSystemMenuHint) {
4750  bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
4751  bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
4752 
4753  QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
4754  qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
4755 
4756  int xoffset = closeButtonRect.width() / 3;
4757  int yoffset = closeButtonRect.height() / 3;
4758 
4759  QRect closeIconRect(closeButtonRect.left() + xoffset, closeButtonRect.top() + yoffset,
4760  closeButtonRect.width() - xoffset * 2, closeButtonRect.height() - yoffset * 2);
4761 
4762  painter->setPen(textAlphaColor);
4763  {
4764  const QLine lines[4] = {
4765  QLine(closeIconRect.left() + 1, closeIconRect.top(),
4766  closeIconRect.right(), closeIconRect.bottom() - 1),
4767  QLine(closeIconRect.left(), closeIconRect.top() + 1,
4768  closeIconRect.right() - 1, closeIconRect.bottom()),
4769  QLine(closeIconRect.right() - 1, closeIconRect.top(),
4770  closeIconRect.left(), closeIconRect.bottom() - 1),
4771  QLine(closeIconRect.right(), closeIconRect.top() + 1,
4772  closeIconRect.left() + 1, closeIconRect.bottom()) };
4773  painter->drawLines(lines, 4);
4774  const QPoint points[4] = {
4775  closeIconRect.topLeft(), closeIconRect.topRight(),
4776  closeIconRect.bottomLeft(), closeIconRect.bottomRight() };
4777  painter->drawPoints(points, 4);
4778  }
4779  painter->setPen(textColor);
4780  {
4781  const QLine lines[2] = {
4782  QLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
4783  closeIconRect.right() - 1, closeIconRect.bottom() - 1),
4784  QLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
4785  closeIconRect.right() - 1, closeIconRect.top() + 1) };
4786  painter->drawLines(lines, 2);
4787  }
4788  }
4789 
4790  // normalize button
4791  if ((titleBar->subControls & SC_TitleBarNormalButton) &&
4792  (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
4793  (titleBar->titleBarState & Qt::WindowMinimized)) ||
4794  ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
4795  (titleBar->titleBarState & Qt::WindowMaximized)))) {
4796  bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
4797  bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
4798 
4799  QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
4800  qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
4801  int xoffset = int(normalButtonRect.width() / 3.5);
4802  int yoffset = int(normalButtonRect.height() / 3.5);
4803 
4804  QRect normalButtonIconRect(normalButtonRect.left() + xoffset, normalButtonRect.top() + yoffset,
4805  normalButtonRect.width() - xoffset * 2, normalButtonRect.height() - yoffset * 2);
4806 
4807  QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
4808  painter->setPen(textColor);
4809  painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
4810  painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
4811  frontWindowRect.right() - 1, frontWindowRect.top() + 1);
4812  painter->setPen(textAlphaColor);
4813  {
4814  const QPoint points[4] = {
4815  frontWindowRect.topLeft(), frontWindowRect.topRight(),
4816  frontWindowRect.bottomLeft(), frontWindowRect.bottomRight() };
4817  painter->drawPoints(points, 4);
4818  }
4819 
4820  QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
4821  QRegion clipRegion = backWindowRect;
4822  clipRegion -= frontWindowRect;
4823  painter->save();
4824  painter->setClipRegion(clipRegion);
4825  painter->setPen(textColor);
4826  painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
4827  painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
4828  backWindowRect.right() - 1, backWindowRect.top() + 1);
4829  painter->setPen(textAlphaColor);
4830  {
4831  const QPoint points[4] = {
4832  backWindowRect.topLeft(), backWindowRect.topRight(),
4833  backWindowRect.bottomLeft(), backWindowRect.bottomRight() };
4834  painter->drawPoints(points, 4);
4835  }
4836  painter->restore();
4837  }
4838 
4839  // context help button
4840  if (titleBar->subControls & SC_TitleBarContextHelpButton
4841  && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
4842  bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
4843  bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
4844 
4845  QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
4846 
4847  qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
4848 
4849  QColor blend;
4850  // ### Use palette colors
4851  if (active) {
4852  blend = mergedColors(QColor(hover ? 0x7d8bb1 : 0x55689a),
4853  QColor(hover ? 0x939ebe : 0x7381ab));
4854  } else {
4855  blend = mergedColors(QColor(hover ? 0x9e9e9e : 0x818181),
4856  QColor(hover ? 0xababab : 0x929292));
4857  }
4859  image.setColor(4, textColor.rgba());
4860  image.setColor(3, mergedColors(blend, textColor, 30).rgba());
4861  image.setColor(2, mergedColors(blend, textColor, 70).rgba());
4862  image.setColor(1, mergedColors(blend, textColor, 90).rgba());
4863 
4864  painter->drawImage(contextHelpButtonRect, image);
4865  }
4866 
4867  // shade button
4868  if (titleBar->subControls & SC_TitleBarShadeButton) {
4869  bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
4870  bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
4871 
4872  QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
4873  qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
4874 
4875  int xoffset = shadeButtonRect.width() / 3;
4876  int yoffset = shadeButtonRect.height() / 3;
4877 
4878  QRect shadeButtonIconRect(shadeButtonRect.left() + xoffset, shadeButtonRect.top() + yoffset,
4879  shadeButtonRect.width() - xoffset * 2, shadeButtonRect.height() - yoffset * 2);
4880 
4881  QPainterPath path(shadeButtonIconRect.bottomLeft());
4882  path.lineTo(shadeButtonIconRect.center().x(), shadeButtonIconRect.bottom() - shadeButtonIconRect.height() / 2);
4883  path.lineTo(shadeButtonIconRect.bottomRight());
4884  path.lineTo(shadeButtonIconRect.bottomLeft());
4885 
4886  painter->setPen(textAlphaColor);
4887  painter->setBrush(textColor);
4888  painter->drawPath(path);
4889  }
4890 
4891  // unshade button
4892  if (titleBar->subControls & SC_TitleBarUnshadeButton) {
4893  bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
4894  bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
4895 
4896  QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
4897  qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
4898 
4899  int xoffset = unshadeButtonRect.width() / 3;
4900  int yoffset = unshadeButtonRect.height() / 3;
4901 
4902  QRect unshadeButtonIconRect(unshadeButtonRect.left() + xoffset, unshadeButtonRect.top() + yoffset,
4903  unshadeButtonRect.width() - xoffset * 2, unshadeButtonRect.height() - yoffset * 2);
4904 
4905  int midY = unshadeButtonIconRect.bottom() - unshadeButtonIconRect.height() / 2;
4906  QPainterPath path(QPoint(unshadeButtonIconRect.left(), midY));
4907  path.lineTo(unshadeButtonIconRect.right(), midY);
4908  path.lineTo(unshadeButtonIconRect.center().x(), unshadeButtonIconRect.bottom());
4909  path.lineTo(unshadeButtonIconRect.left(), midY);
4910 
4911  painter->setPen(textAlphaColor);
4912  painter->setBrush(textColor);
4913  painter->drawPath(path);
4914  }
4915 
4916  // from qwindowsstyle.cpp
4917  if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
4918  bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver);
4919  bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken);
4920 
4921  QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
4922  if (hover)
4923  qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken);
4924 
4925  if (!titleBar->icon.isNull()) {
4926  titleBar->icon.paint(painter, iconRect);
4927  } else {
4928  QStyleOption tool(0);
4929  tool.palette = titleBar->palette;
4930  QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget);
4931  tool.rect = iconRect;
4932  painter->save();
4933  proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
4934  painter->restore();
4935  }
4936  }
4937  painter->restore();
4938  }
4939  break;
4940 #ifndef QT_NO_DIAL
4941  case CC_Dial:
4942  if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
4943  QStyleHelper::drawDial(dial, painter);
4944  break;
4945 #endif // QT_NO_DIAL
4946  default:
4947  QWindowsStyle::drawComplexControl(control, option, painter, widget);
4948  break;
4949  }
4950 }
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition: qstyle_p.h:76
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static const char *const qt_plastique_slider_horizontalhandle_up[]
const T * constData() const
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
static QBrush qBrushDark(QBrush brush, int dark)
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
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect)
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
double qreal
Definition: qglobal.h:1193
static const char *const qt_plastique_slider_verticalhandle_left[]
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
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 QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
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...
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.
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
Reimplemented Function
static C reverse(const C &l)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
#define END_STYLE_PIXMAPCACHE
Definition: qstyle_p.h:96
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) 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
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
void append(const T &t)
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
static void qt_plastique_draw_frame(QPainter *painter, const QRect &rect, const QStyleOption *option, QFrame::Shadow shadow=QFrame::Plain)
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition: qstyle.cpp:2176
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static QPixmap * find(const QString &key)
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
static const char *const qt_plastique_slider_horizontalhandle[]
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
static QBrush qBrushLight(QBrush brush, int light)
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
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 & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static void qt_plastique_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
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
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop)
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
static const char *const qt_titlebar_context_help[]
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
const QStyle * proxy() const
Definition: qstyle.cpp:2546
QString title
the title of the dock window
Definition: qstyleoption.h:510
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE...
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
static void qBrushSetAlphaF(QBrush *brush, qreal alpha)
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
static const char *const qt_plastique_slider_verticalhandle[]
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
int size() const
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ drawControl()

void QPlastiqueStyle::drawControl ( ControlElement  element,
const QStyleOption option,
QPainter painter,
const QWidget widget 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 2002 of file qplastiquestyle.cpp.

2004 {
2005  QColor borderColor = option->palette.background().color().darker(178);
2006  QColor alphaCornerColor;
2007  if (widget) {
2008  // ### backgroundrole/foregroundrole should be part of the style option
2009  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
2010  } else {
2011  alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
2012  }
2013 
2014  QColor gradientStartColor = option->palette.button().color().lighter(104);
2015  QColor gradientStopColor = option->palette.button().color().darker(105);
2016 
2017  QColor highlightedGradientStartColor = option->palette.button().color().lighter(101);
2018  QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
2019 
2020  QColor lightShadowGradientStartColor = highlightedGradientStartColor.lighter(105);
2021  QColor lightShadowGradientStopColor = highlightedGradientStopColor.lighter(105);
2022 
2023  QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
2024  QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
2025 
2026  QColor alphaInnerColor = mergedColors(highlightedDarkInnerBorderColor, option->palette.base().color());
2027 
2028  switch (element) {
2029 #ifndef QT_NO_TABBAR
2030  case CE_TabBarTabShape:
2031  if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
2032 
2033  if (tab->shape != QTabBar::RoundedNorth && tab->shape != QTabBar::RoundedWest &&
2034  tab->shape != QTabBar::RoundedSouth && tab->shape != QTabBar::RoundedEast) {
2035  QWindowsStyle::drawControl(element, option, painter, widget);
2036  break;
2037  }
2038 
2039  painter->save();
2040 
2041  // Set up some convenience variables
2042  bool disabled = !(tab->state & State_Enabled);
2043  bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab;
2044  bool selected = tab->state & State_Selected;
2045  bool mouseOver = (tab->state & State_MouseOver) && !selected && !disabled;
2046  bool previousSelected = tab->selectedPosition == QStyleOptionTab::PreviousIsSelected;
2047  bool nextSelected = tab->selectedPosition == QStyleOptionTab::NextIsSelected;
2048  bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget);
2049  bool reverse = (tab->direction == Qt::RightToLeft);
2050 
2051  int lowerTop = selected ? 0 : 3; // to make the selected tab bigger than the rest
2052  bool atEnd = (tab->position == QStyleOptionTab::End) || onlyTab;
2053  bool atBeginning = ((tab->position == QStyleOptionTab::Beginning) || onlyTab)
2054  && !leftCornerWidget;
2055  bool reverseShadow = false;
2056 
2057  int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
2058  int marginLeft = 0;
2059  if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) {
2060  marginLeft = 1;
2061  }
2062 
2063  // I've set the names based on the natural coordinate system. Vectors are used to rotate everything
2064  // if the orientation of the tab bare is different than north.
2065  {
2066  // Coordinates of corners of rectangle for transformation
2067  QPoint topLeft;
2068  QPoint topRight;
2069  QPoint bottomLeft;
2070  QPoint bottomRight;
2071 
2072  // Fill with normalized vectors in the direction of the coordinate system
2073  // (down and right should be complement of up and left, or it will look odd)
2074  QPoint vectorUp;
2075  QPoint vectorDown;
2076  QPoint vectorLeft;
2077  QPoint vectorRight;
2078 
2079  QBrush border = option->palette.shadow();
2080  qBrushSetAlphaF(&border, qreal(0.4));
2081  QBrush innerTopLeft = option->palette.shadow();
2082  qBrushSetAlphaF(&innerTopLeft, qreal(0.075));
2083  QBrush innerBottomRight = option->palette.shadow();
2084  qBrushSetAlphaF(&innerBottomRight, qreal(0.23));
2085  QBrush corner = option->palette.shadow();
2086  qBrushSetAlphaF(&corner, qreal(0.25));
2087 
2088  QBrush baseColor1;
2089  QBrush baseColor2;
2090 
2091  switch (tab->shape) {
2092  case QTabBar::RoundedNorth:
2093  vectorUp = QPoint(0, -1);
2094  vectorDown = QPoint(0, 1);
2095 
2096  if (reverse) {
2097  vectorLeft = QPoint(1, 0);
2098  vectorRight = QPoint(-1, 0);
2099  reverseShadow = true;
2100  } else {
2101  vectorLeft = QPoint(-1, 0);
2102  vectorRight = QPoint(1, 0);
2103  }
2104 
2105  if (reverse) {
2106  topLeft = tab->rect.topRight();
2107  topRight = tab->rect.topLeft();
2108  bottomLeft = tab->rect.bottomRight();
2109  bottomRight = tab->rect.bottomLeft();
2110  } else {
2111  topLeft = tab->rect.topLeft();
2112  topRight = tab->rect.topRight();
2113  bottomLeft = tab->rect.bottomLeft();
2114  bottomRight = tab->rect.bottomRight();
2115  }
2116 
2117 
2118  baseColor1 = border;
2119  baseColor2 = innerTopLeft;
2120  break ;
2121  case QTabBar::RoundedWest:
2122  vectorUp = QPoint(-1, 0);
2123  vectorDown = QPoint(1, 0);
2124  vectorLeft = QPoint(0, -1);
2125  vectorRight = QPoint(0, 1);
2126 
2127  topLeft = tab->rect.topLeft();
2128  topRight = tab->rect.bottomLeft();
2129  bottomLeft = tab->rect.topRight();
2130  bottomRight = tab->rect.bottomRight();
2131 
2132  baseColor1 = border;
2133  baseColor2 = innerTopLeft;
2134  break ;
2135  case QTabBar::RoundedEast:
2136  vectorUp = QPoint(1, 0);
2137  vectorDown = QPoint(-1, 0);
2138  vectorLeft = QPoint(0, -1);
2139  vectorRight = QPoint(0, 1);
2140 
2141  topLeft = tab->rect.topRight();
2142  topRight = tab->rect.bottomRight();
2143  bottomLeft = tab->rect.topLeft();
2144  bottomRight = tab->rect.bottomLeft();
2145 
2146  baseColor1 = border;
2147  baseColor2 = innerBottomRight;
2148  break ;
2149  case QTabBar::RoundedSouth:
2150  vectorUp = QPoint(0, 1);
2151  vectorDown = QPoint(0, -1);
2152 
2153  if (reverse) {
2154  vectorLeft = QPoint(1, 0);
2155  vectorRight = QPoint(-1, 0);
2156  reverseShadow = true;
2157 
2158  topLeft = tab->rect.bottomRight();
2159  topRight = tab->rect.bottomLeft();
2160  bottomLeft = tab->rect.topRight();
2161  bottomRight = tab->rect.topLeft();
2162  } else {
2163  vectorLeft = QPoint(-1, 0);
2164  vectorRight = QPoint(1, 0);
2165 
2166  topLeft = tab->rect.bottomLeft();
2167  topRight = tab->rect.bottomRight();
2168  bottomLeft = tab->rect.topLeft();
2169  bottomRight = tab->rect.topRight();
2170  }
2171 
2172  baseColor1 = border;
2173  baseColor2 = innerBottomRight;
2174  break ;
2175  default:
2176  break;
2177  }
2178 
2179  // Make the tab smaller when it's at the end, so that we are able to draw the corner
2180  if (atEnd) {
2181  topRight += vectorLeft;
2182  bottomRight += vectorLeft;
2183  }
2184 
2185  {
2186  // Outer border
2187  QLine topLine;
2188  {
2189  QPoint adjustTopLineLeft = (vectorRight * (marginLeft + (previousSelected ? 0 : 1))) +
2190  (vectorDown * lowerTop);
2191  QPoint adjustTopLineRight = (vectorDown * lowerTop);
2192  if (atBeginning || selected)
2193  adjustTopLineLeft += vectorRight;
2194  if (atEnd || selected)
2195  adjustTopLineRight += 2 * vectorLeft;
2196 
2197  topLine = QLine(topLeft + adjustTopLineLeft, topRight + adjustTopLineRight);
2198  }
2199 
2200  QLine leftLine;
2201  {
2202  QPoint adjustLeftLineTop = (vectorRight * marginLeft) + (vectorDown * (lowerTop + 1));
2203  QPoint adjustLeftLineBottom = (vectorRight * marginLeft) + (vectorUp * borderThickness);
2204  if (atBeginning || selected)
2205  adjustLeftLineTop += vectorDown; // Make place for rounded corner
2206  if (atBeginning && selected)
2207  adjustLeftLineBottom += borderThickness * vectorDown;
2208  else if (selected)
2209  adjustLeftLineBottom += vectorUp;
2210 
2211  leftLine = QLine(topLeft + adjustLeftLineTop, bottomLeft + adjustLeftLineBottom);
2212  }
2213 
2214  QLine rightLine;
2215  {
2216  QPoint adjustRightLineTop = vectorDown * (2 + lowerTop);
2217  QPoint adjustRightLineBottom = vectorUp * borderThickness;
2218  if (selected)
2219  adjustRightLineBottom += vectorUp;
2220 
2221  rightLine = QLine(topRight + adjustRightLineTop, bottomRight + adjustRightLineBottom);
2222  }
2223 
2224  // Background
2225  QPoint startPoint = topLine.p1() + vectorDown + vectorLeft;
2226  if (mouseOver)
2227  startPoint += vectorDown;
2228  QPoint endPoint = rightLine.p2();
2229 
2230  if (tab->state & State_Enabled) {
2231  QRect fillRect = QRect(startPoint, endPoint).normalized();
2232  if (fillRect.isValid()) {
2233  if (selected) {
2234  fillRect = QRect(startPoint, endPoint + vectorLeft + vectorDown * 3).normalized();
2235  painter->fillRect(fillRect, option->palette.window());
2236 
2237  // Connect to the base
2238  painter->setPen(QPen(option->palette.window(), 0));
2240  points.append(rightLine.p2() + vectorDown);
2241  points.append(rightLine.p2() + vectorDown + vectorDown);
2242  points.append(rightLine.p2() + vectorDown + vectorDown + vectorRight);
2243  if (tab->position != QStyleOptionTab::Beginning) {
2244  points.append(leftLine.p2() + vectorDown);
2245  points.append(leftLine.p2() + vectorDown + vectorDown);
2246  points.append(leftLine.p2() + vectorDown + vectorDown + vectorLeft);
2247  }
2248  painter->drawPoints(points.constData(), points.size());
2249  } else {
2250  QBrush buttonGradientBrush;
2251  QBrush buttonBrush = qMapBrushToRect(option->palette.button(), fillRect);
2252  if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) {
2253  buttonGradientBrush = buttonBrush;
2254  } else {
2255  // Generate gradients
2256  QLinearGradient buttonGradient(fillRect.topLeft(), fillRect.bottomLeft());
2257  buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104));
2258  buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110));
2259  buttonGradientBrush = QBrush(buttonGradient);
2260  }
2261 
2262  painter->fillRect(fillRect, buttonGradientBrush);
2263  }
2264  }
2265  }
2266 
2267  QPoint rightCornerDot = topRight + vectorLeft + (lowerTop + 1)*vectorDown;
2268  QPoint leftCornerDot = topLeft + (marginLeft + 1)*vectorRight + (lowerTop + 1)*vectorDown;
2269  QPoint bottomRightConnectToBase = rightLine.p2() + vectorRight + vectorDown;
2270  QPoint bottomLeftConnectToBase = leftLine.p2() + vectorLeft + vectorDown;
2271 
2272  painter->setPen(QPen(border, 0));
2273 
2276 
2277  lines.append(topLine);
2278 
2279  if (mouseOver) {
2280  painter->drawLines(lines.constData(), lines.count());
2281  lines.clear();
2282 
2283  QLine secondHoverLine = QLine(topLine.p1() + vectorDown * 2 + vectorLeft, topLine.p2() + vectorDown * 2 + vectorRight);
2284  painter->setPen(highlightedLightInnerBorderColor);
2285  painter->drawLine(secondHoverLine);
2286  }
2287 
2288  if (mouseOver)
2289  painter->setPen(QPen(border, 0));
2290 
2291  if (!previousSelected)
2292  lines.append(leftLine);
2293  if (atEnd || selected) {
2294  lines.append(rightLine);
2295  points.append(rightCornerDot);
2296  }
2297  if (atBeginning || selected)
2298  points.append(leftCornerDot);
2299  if (selected) {
2300  points.append(bottomRightConnectToBase);
2301  points.append(bottomLeftConnectToBase);
2302  }
2303  if (lines.size() > 0) {
2304  painter->drawLines(lines.constData(), lines.size());
2305  lines.clear();
2306  }
2307  if (points.size() > 0) {
2308  painter->drawPoints(points.constData(), points.size());
2309  points.clear();
2310  }
2311 
2312  // Antialiasing
2313  painter->setPen(QPen(corner, 0));
2314  if (atBeginning || selected)
2315  points.append(topLine.p1() + vectorLeft);
2316  if (!previousSelected)
2317  points.append(leftLine.p1() + vectorUp);
2318  if (atEnd || selected) {
2319  points.append(topLine.p2() + vectorRight);
2320  points.append(rightLine.p1() + vectorUp);
2321  }
2322 
2323  if (selected) {
2324  points.append(bottomRightConnectToBase + vectorLeft);
2325  if (!atBeginning) {
2326  points.append(bottomLeftConnectToBase + vectorRight);
2327 
2328  if (((tab->position == QStyleOptionTab::Beginning) || onlyTab) && leftCornerWidget) {
2329  // A special case: When the first tab is selected and
2330  // has a left corner widget, it needs to do more work
2331  // to connect to the base
2332  QPoint p1 = bottomLeftConnectToBase + vectorDown;
2333 
2334  points.append(p1);
2335  }
2336  }
2337  }
2338  if (points.size() > 0) {
2339  painter->drawPoints(points.constData(), points.size());
2340  points.clear();
2341  }
2342 
2343  // Inner border
2344  QLine innerTopLine = QLine(topLine.p1() + vectorDown, topLine.p2() + vectorDown);
2345  if (!selected) {
2346  QLinearGradient topLineGradient(innerTopLine.p1(),innerTopLine.p2());
2347  topLineGradient.setColorAt(0, lightShadowGradientStartColor);
2348  topLineGradient.setColorAt(1, lightShadowGradientStopColor);
2349  painter->setPen(QPen(mouseOver ? QBrush(highlightedDarkInnerBorderColor) : QBrush(topLineGradient), 1));
2350  } else {
2351  painter->setPen(QPen(innerTopLeft, 0));
2352  }
2353  painter->drawLine(innerTopLine);
2354 
2355  QLine innerLeftLine = QLine(leftLine.p1() + vectorRight + vectorDown, leftLine.p2() + vectorRight);
2356  QLine innerRightLine = QLine(rightLine.p1() + vectorLeft + vectorDown, rightLine.p2() + vectorLeft);
2357 
2358  if (selected) {
2359  innerRightLine = QLine(innerRightLine.p1() + vectorUp, innerRightLine.p2());
2360  innerLeftLine = QLine(innerLeftLine.p1() + vectorUp, innerLeftLine.p2());
2361  }
2362 
2363  if (selected || atBeginning) {
2364  QBrush leftLineGradientBrush;
2365  QRect rect = QRect(innerLeftLine.p1(), innerLeftLine.p2()).normalized();
2366  QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect);
2367  if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) {
2368  leftLineGradientBrush = qBrushLight(buttonBrush, 105);
2369  } else {
2370  QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft());
2371  buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105));
2372  buttonGradient3.setColorAt(1.0, buttonBrush.color());
2373  leftLineGradientBrush = QBrush(buttonGradient3);
2374  }
2375 
2376  if (!selected)
2377  painter->setPen(QPen(leftLineGradientBrush, 0));
2378 
2379  // Assume the sun is on the same side in Right-To-Left layouts and draw the
2380  // light shadow on the left side always (the right line is on the left side in
2381  // reverse layouts for north and south)
2382  if (reverseShadow)
2383  painter->drawLine(innerRightLine);
2384  else
2385  painter->drawLine(innerLeftLine);
2386  }
2387 
2388  if (atEnd || selected) {
2389  if (!selected) {
2390  QBrush rightLineGradientBrush;
2391  QRect rect = QRect(innerRightLine.p1(), innerRightLine.p2()).normalized();
2392  QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect);
2393  if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) {
2394  rightLineGradientBrush = qBrushDark(buttonBrush, 105);
2395  } else {
2396  QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft());
2397  buttonGradient4.setColorAt(0.0, buttonBrush.color());
2398  buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110));
2399  rightLineGradientBrush = QBrush(buttonGradient4);
2400  }
2401 
2402  painter->setPen(QPen(rightLineGradientBrush, 0));
2403  } else {
2404  painter->setPen(QPen(innerBottomRight, 0));
2405  }
2406 
2407  if (reverseShadow)
2408  painter->drawLine(innerLeftLine);
2409  else
2410  painter->drawLine(innerRightLine);
2411  }
2412 
2413 
2414  // Base
2415  QLine baseLine = QLine(bottomLeft + marginLeft * 2 * vectorRight, bottomRight);
2416  {
2417 
2418  QPoint adjustedLeft;
2419  QPoint adjustedRight;
2420 
2421  if (atEnd && !selected) {
2422  baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorRight);
2423  }
2424 
2425  if (nextSelected) {
2426  adjustedRight += vectorLeft;
2427  baseLine = QLine(baseLine.p1(), baseLine.p2() + vectorLeft);
2428  }
2429  if (previousSelected) {
2430  adjustedLeft += vectorRight;
2431  baseLine = QLine(baseLine.p1() + vectorRight, baseLine.p2());
2432  }
2433  if (atBeginning)
2434  adjustedLeft += vectorRight;
2435 
2436  painter->setPen(QPen(baseColor2, 0));
2437  if (!selected)
2438  painter->drawLine(baseLine);
2439 
2440  if (atEnd && !selected)
2441  painter->drawPoint(baseLine.p2() + vectorRight);
2442 
2443  if (atBeginning && !selected)
2444  adjustedLeft = vectorRight;
2445  else
2446  adjustedLeft = QPoint(0, 0);
2447  painter->setPen(QPen(baseColor1, 0));
2448  if (!selected)
2449  painter->drawLine(bottomLeft + vectorUp + adjustedLeft, baseLine.p2() + vectorUp);
2450 
2451  QPoint endPoint = bottomRight + vectorUp;
2452  if (atEnd && !selected)
2453  painter->drawPoint(endPoint);
2454 
2455  // For drawing a lower left "fake" corner on the base when the first tab is unselected
2456  if (atBeginning && !selected) {
2457  painter->drawPoint(baseLine.p1() + vectorLeft);
2458  }
2459 
2460  painter->setPen(QPen(corner, 0));
2461  if (nextSelected)
2462  painter->drawPoint(endPoint);
2463  else if (selected)
2464  painter->drawPoint(endPoint + vectorRight);
2465 
2466  // For drawing a lower left "fake" corner on the base when the first tab is unselected
2467  if (atBeginning && !selected) {
2468  painter->drawPoint(baseLine.p1() + 2 * vectorLeft);
2469  }
2470  }
2471  }
2472  }
2473 
2474  // Yay we're done
2475 
2476  painter->restore();
2477  }
2478  break;
2479 #endif // QT_NO_TABBAR
2480 #ifndef QT_NO_PROGRESSBAR
2481  case CE_ProgressBarGroove:
2482  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2483  QRect rect = bar->rect;
2484  QPen oldPen = painter->pen();
2485 
2486  QLine lines[4];
2487 
2488  // outline
2489  painter->setPen(borderColor);
2490  lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top());
2491  lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom());
2492  lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2);
2493  lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2);
2494  painter->drawLines(lines, 4);
2495 
2496  QPoint points[8];
2497  points[0] = QPoint(rect.left() + 1, rect.top() + 1);
2498  points[1] = QPoint(rect.right() - 1, rect.top() + 1);
2499  points[2] = QPoint(rect.left() + 1, rect.bottom() - 1);
2500  points[3] = QPoint(rect.right() - 1, rect.bottom() - 1);
2501  painter->drawPoints(points, 4);
2502 
2503  // alpha corners
2504  painter->setPen(alphaCornerColor);
2505  points[0] = QPoint(rect.left(), rect.top() + 1);
2506  points[1] = QPoint(rect.left() + 1, rect.top());
2507  points[2] = QPoint(rect.right(), rect.top() + 1);
2508  points[3] = QPoint(rect.right() - 1, rect.top());
2509  points[4] = QPoint(rect.left(), rect.bottom() - 1);
2510  points[5] = QPoint(rect.left() + 1, rect.bottom());
2511  points[6] = QPoint(rect.right(), rect.bottom() - 1);
2512  points[7] = QPoint(rect.right() - 1, rect.bottom());
2513  painter->drawPoints(points, 8);
2514 
2515  // inner outline, north-west
2516  painter->setPen(gradientStartColor.darker(105));
2517  lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1);
2518  lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
2519  painter->drawLines(lines, 2);
2520 
2521  // base of the groove
2522  painter->setPen(QPen());
2523  painter->fillRect(rect.adjusted(2, 2, -2, -1), QBrush(bar->palette.base().color()));
2524  painter->setPen(bar->palette.base().color());
2525  painter->drawLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
2526 
2527  painter->setPen(oldPen);
2528  }
2529  break;
2530  case CE_ProgressBarLabel:
2531  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2532  // The busy indicator doesn't draw a label
2533  if (bar->minimum == 0 && bar->maximum == 0)
2534  return;
2535 
2536  painter->save();
2537 
2538  QRect rect = bar->rect;
2539  QRect leftRect;
2540 
2541  QFont font;
2542  font.setBold(true);
2543  painter->setFont(font);
2544  painter->setPen(bar->palette.text().color());
2545 
2546  bool vertical = false;
2547  bool inverted = false;
2548  bool bottomToTop = false;
2549  // Get extra style options if version 2
2550  if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
2551  vertical = (bar2->orientation == Qt::Vertical);
2552  inverted = bar2->invertedAppearance;
2553  bottomToTop = bar2->bottomToTop;
2554  }
2555 
2556  if (vertical) {
2557  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
2558  QTransform m;
2559  if (bottomToTop) {
2560  m.translate(0.0, rect.width());
2561  m.rotate(-90);
2562  } else {
2563  m.translate(rect.height(), 0.0);
2564  m.rotate(90);
2565  }
2566  painter->setTransform(m, true);
2567  }
2568 
2569  int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width();
2570 
2571  bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted)
2572  || ((bar->direction == Qt::LeftToRight) && inverted))) || (vertical && ((!inverted && !bottomToTop) || (inverted && bottomToTop)));
2573  if (flip) {
2574  int indicatorPos = rect.width() - progressIndicatorPos;
2575  if (indicatorPos >= 0 && indicatorPos <= rect.width()) {
2576  painter->setPen(bar->palette.base().color());
2577  leftRect = QRect(rect.left(), rect.top(), indicatorPos, rect.height());
2578  } else if (indicatorPos > rect.width()) {
2579  painter->setPen(bar->palette.text().color());
2580  } else {
2581  painter->setPen(bar->palette.base().color());
2582  }
2583  } else {
2584  if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) {
2585  leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
2586  } else if (progressIndicatorPos > rect.width()) {
2587  painter->setPen(bar->palette.base().color());
2588  } else {
2589  painter->setPen(bar->palette.text().color());
2590  }
2591  }
2592 
2593  QRegion rightRect = rect;
2594  rightRect = rightRect.subtracted(leftRect);
2595  painter->setClipRegion(rightRect);
2597  if (!leftRect.isNull()) {
2598  painter->setPen(flip ? bar->palette.text().color() : bar->palette.base().color());
2599  painter->setClipRect(leftRect);
2601  }
2602 
2603  painter->restore();
2604  }
2605  break;
2607  if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
2608  Q_D(const QPlastiqueStyle);
2609  QRect rect = bar->rect;
2610  bool vertical = false;
2611  bool inverted = false;
2612  bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
2613  if (!indeterminate && bar->progress == -1)
2614  break;
2615 
2616  painter->save();
2617 
2618  // Get extra style options if version 2
2619  if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
2620  vertical = (bar2->orientation == Qt::Vertical);
2621  inverted = bar2->invertedAppearance;
2622  }
2623 
2624  // If the orientation is vertical, we use a transform to rotate
2625  // the progress bar 90 degrees clockwise. This way we can use the
2626  // same rendering code for both orientations.
2627  if (vertical) {
2628  rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
2629  QTransform m = QTransform::fromTranslate(rect.height()-1, 0);
2630  m.rotate(90.0);
2631  painter->setTransform(m, true);
2632  }
2633 
2634  int maxWidth = rect.width() - 4;
2635  int minWidth = 4;
2636  qint64 progress = qMax<qint64>(bar->progress, bar->minimum); // workaround for bug in QProgressBar
2637  double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth);
2638  int width = indeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth);
2639  bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
2640  if (inverted)
2641  reverse = !reverse;
2642 
2643  QRect progressBar;
2644  if (!indeterminate) {
2645  if (!reverse) {
2646  progressBar.setRect(rect.left() + 2, rect.top() + 2, width, rect.height() - 4);
2647  } else {
2648  progressBar.setRect(rect.right() - 1 - width, rect.top() + 2, width, rect.height() - 4);
2649  }
2650  } else {
2651  int slideWidth = ((rect.width() - 4) * 2) / 3;
2652  int step = ((d->animateStep * slideWidth) / ProgressBarFps) % slideWidth;
2653  if ((((d->animateStep * slideWidth) / ProgressBarFps) % (2 * slideWidth)) >= slideWidth)
2654  step = slideWidth - step;
2655  progressBar.setRect(rect.left() + 2 + step, rect.top() + 2,
2656  slideWidth / 2, rect.height() - 4);
2657  }
2658 
2659  // outline
2660  painter->setPen(highlightedDarkInnerBorderColor);
2661 
2664  if (!reverse) {
2665  if (width == minWidth) {
2666  points.append(QPoint(progressBar.left() + 1, progressBar.top()));
2667  points.append(QPoint(progressBar.left() + 1, progressBar.bottom()));
2668  } else {
2669  if (indeterminate) {
2670  lines.append(QLine(progressBar.left() + 2, progressBar.top(),
2671  progressBar.right() - 2, progressBar.top()));
2672  lines.append(QLine(progressBar.left() + 2, progressBar.bottom(),
2673  progressBar.right() - 2, progressBar.bottom()));
2674  } else {
2675  lines.append(QLine(progressBar.left() + 1, progressBar.top(),
2676  progressBar.right() - 2, progressBar.top()));
2677  lines.append(QLine(progressBar.left() + 1, progressBar.bottom(),
2678  progressBar.right() - 2, progressBar.bottom()));
2679  }
2680  }
2681 
2682  if (indeterminate) {
2683  lines.append(QLine(progressBar.left(), progressBar.top() + 2,
2684  progressBar.left(), progressBar.bottom() - 2));
2685  } else {
2686  lines.append(QLine(progressBar.left(), progressBar.top() + 1,
2687  progressBar.left(), progressBar.bottom() - 1));
2688  }
2689  lines.append(QLine(progressBar.right(), progressBar.top() + 2,
2690  progressBar.right(), progressBar.bottom() - 2));
2691  } else {
2692  if (width == minWidth) {
2693  points.append(QPoint(progressBar.right() - 1, progressBar.top()));
2694  points.append(QPoint(progressBar.right() - 1, progressBar.bottom()));
2695  } else {
2696  if (indeterminate) {
2697  lines.append(QLine(progressBar.right() - 2, progressBar.top(),
2698  progressBar.left() + 2, progressBar.top()));
2699  lines.append(QLine(progressBar.right() - 2, progressBar.bottom(),
2700  progressBar.left() + 2, progressBar.bottom()));
2701  } else {
2702  lines.append(QLine(progressBar.right() - 1, progressBar.top(),
2703  progressBar.left() + 2, progressBar.top()));
2704  lines.append(QLine(progressBar.right() - 1, progressBar.bottom(),
2705  progressBar.left() + 2, progressBar.bottom()));
2706  }
2707  }
2708  if (indeterminate) {
2709  lines.append(QLine(progressBar.right(), progressBar.top() + 2,
2710  progressBar.right(), progressBar.bottom() - 2));
2711  } else {
2712  lines.append(QLine(progressBar.right(), progressBar.top() + 1,
2713  progressBar.right(), progressBar.bottom() - 1));
2714  }
2715  lines.append(QLine(progressBar.left(), progressBar.top() + 2,
2716  progressBar.left(), progressBar.bottom() - 2));
2717  }
2718 
2719  if (points.size() > 0) {
2720  painter->drawPoints(points.constData(), points.size());
2721  points.clear();
2722  }
2723  painter->drawLines(lines.constData(), lines.size());
2724  lines.clear();
2725 
2726  // alpha corners
2727  painter->setPen(alphaInnerColor);
2728  if (!reverse) {
2729  if (indeterminate) {
2730  points.append(QPoint(progressBar.left() + 1, progressBar.top()));
2731  points.append(QPoint(progressBar.left(), progressBar.top() + 1));
2732  points.append(QPoint(progressBar.left() + 1, progressBar.bottom()));
2733  points.append(QPoint(progressBar.left(), progressBar.bottom() - 1));
2734  } else {
2735  points.append(QPoint(progressBar.left(), progressBar.top()));
2736  points.append(QPoint(progressBar.left(), progressBar.bottom()));
2737  }
2738  points.append(QPoint(progressBar.right() - 1, progressBar.top()));
2739  points.append(QPoint(progressBar.right(), progressBar.top() + 1));
2740  points.append(QPoint(progressBar.right() - 1, progressBar.bottom()));
2741  points.append(QPoint(progressBar.right(), progressBar.bottom() - 1));
2742  } else {
2743  if (indeterminate) {
2744  points.append(QPoint(progressBar.right() - 1, progressBar.top()));
2745  points.append(QPoint(progressBar.right(), progressBar.top() + 1));
2746  points.append(QPoint(progressBar.right() - 1, progressBar.bottom()));
2747  points.append(QPoint(progressBar.right(), progressBar.bottom() - 1));
2748  } else {
2749  points.append(QPoint(progressBar.right(), progressBar.top()));
2750  points.append(QPoint(progressBar.right(), progressBar.bottom()));
2751  }
2752  points.append(QPoint(progressBar.left() + 1, progressBar.top()));
2753  points.append(QPoint(progressBar.left(), progressBar.top() + 1));
2754  points.append(QPoint(progressBar.left() + 1, progressBar.bottom()));
2755  points.append(QPoint(progressBar.left(), progressBar.bottom() - 1));
2756  }
2757 
2758  painter->drawPoints(points.constData(), points.size());
2759  points.clear();
2760 
2761  // contents
2762  painter->setPen(QPen());
2763 
2764  QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"),
2765  option, rect.size());
2766  QPixmap cache;
2767  if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) {
2768  QSize size = rect.size();
2769  cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6));
2770  cache.fill(Qt::white);
2771  QPainter cachePainter(&cache);
2772  QRect pixmapRect(0, 0, cache.width(), cache.height());
2773 
2774  int leftEdge = 0;
2775  bool flip = false;
2776  while (leftEdge < cache.width() + 1) {
2777  QColor rectColor = option->palette.highlight().color();
2778  QColor lineColor = option->palette.highlight().color();
2779  if (flip) {
2780  flip = false;
2781  rectColor = rectColor.lighter(105);
2782  lineColor = lineColor.lighter(105);
2783  } else {
2784  flip = true;
2785  }
2786 
2787  cachePainter.setPen(lineColor);
2788  const QLine cacheLines[2] = {
2789  QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.top(),
2790  pixmapRect.left() + leftEdge + 9, pixmapRect.top()),
2791  QLine(pixmapRect.left() + leftEdge - 1, pixmapRect.bottom(),
2792  pixmapRect.left() + leftEdge + 9, pixmapRect.bottom()) };
2793  cachePainter.drawLines(cacheLines, 2);
2794  cachePainter.fillRect(QRect(pixmapRect.left() + leftEdge, pixmapRect.top(),
2795  10, pixmapRect.height()), rectColor);
2796 
2797  leftEdge += 10;
2798  }
2799 
2800  QPixmapCache::insert(progressBarName, cache);
2801  }
2802  painter->setClipRect(progressBar.adjusted(1, 0, -1, -1));
2803 
2804  if (!vertical)
2805  progressBar.adjust(0, 1, 0, 1);
2806  if (!indeterminate) {
2807  int step = (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) ? (d->animateStep % 20) : 0;
2808  if (reverse)
2809  painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache);
2810  else
2811  painter->drawPixmap(progressBar.left() - 25 - step + width % 20, progressBar.top(), cache);
2812  } else {
2813  painter->drawPixmap(progressBar.left(), progressBar.top(), cache);
2814  }
2815 
2816  painter->restore();
2817  }
2818  break;
2819 #endif // QT_NO_PROGRESSBAR
2820  case CE_HeaderSection:
2821  // Draws the header in tables.
2822  if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2823  QPixmap cache;
2824  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
2825  pixmapName += QString::number(- int(header->position));
2826  pixmapName += QString::number(- int(header->orientation));
2827 
2828  if (!QPixmapCache::find(pixmapName, cache)) {
2829  cache = QPixmap(option->rect.size());
2830  cache.fill(Qt::white);
2831  QRect pixmapRect(0, 0, option->rect.width(), option->rect.height());
2832  QPainter cachePainter(&cache);
2833 
2834  bool sunken = (header->state & State_Enabled) && (header->state & State_Sunken);
2835 
2836  QColor headerGradientStart = sunken ? option->palette.background().color().darker(114) : gradientStartColor;
2837  QColor headerGradientStop = sunken ? option->palette.background().color().darker(106) : gradientStopColor;
2838 
2839  QColor lightLine = sunken ? option->palette.background().color().darker(118) : gradientStartColor;
2840  QColor darkLine = sunken ? option->palette.background().color().darker(110) : gradientStopColor.darker(105);
2841 
2842  qt_plastique_draw_gradient(&cachePainter, pixmapRect,
2843  headerGradientStart, headerGradientStop);
2844 
2845  cachePainter.setPen(borderColor);
2846  cachePainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1));
2847  cachePainter.setPen(alphaCornerColor);
2848 
2849  const QPoint points[4] = {
2850  pixmapRect.topLeft(), pixmapRect.topRight(),
2851  pixmapRect.bottomLeft(), pixmapRect.bottomRight() };
2852  cachePainter.drawPoints(points, 4);
2853 
2854  QLine lines[2];
2855 
2856  // inner lines
2857  cachePainter.setPen(lightLine);
2858  lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.top() + 1,
2859  pixmapRect.right() - 2, pixmapRect.top() + 1);
2860  lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2,
2861  pixmapRect.left() + 1, pixmapRect.bottom() - 2);
2862  cachePainter.drawLines(lines, 2);
2863 
2864  cachePainter.setPen(darkLine);
2865  lines[0] = QLine(pixmapRect.left() + 2, pixmapRect.bottom() - 1,
2866  pixmapRect.right() - 2, pixmapRect.bottom() - 1);
2867  lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.bottom() - 2,
2868  pixmapRect.right() - 1, pixmapRect.top() + 2);
2869  cachePainter.drawLines(lines, 2);
2870 
2871  cachePainter.end();
2872  QPixmapCache::insert(pixmapName, cache);
2873  }
2874  painter->drawPixmap(option->rect.topLeft(), cache);
2875 
2876  }
2877  break;
2878 #ifndef QT_NO_MENU
2879  case CE_MenuItem:
2880  // Draws one item in a popup menu.
2881  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
2882  painter->save();
2883  QBrush textBrush;
2884  if (option->palette.resolve() & (1 << QPalette::ButtonText))
2885  textBrush = option->palette.buttonText();
2886  else
2887  textBrush = option->palette.windowText(); // KDE uses windowText rather than buttonText for menus
2888 
2889  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
2890  painter->fillRect(menuItem->rect, option->palette.background().color().lighter(103));
2891 
2892  int w = 0;
2893  if (!menuItem->text.isEmpty()) {
2894  painter->setFont(menuItem->font);
2895  proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
2896  menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
2897  QPalette::Text);
2898  w = menuItem->fontMetrics.width(menuItem->text) + 5;
2899  }
2900 
2901  painter->setPen(alphaCornerColor);
2902  bool reverse = menuItem->direction == Qt::RightToLeft;
2903  painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
2904  menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
2905 
2906  painter->restore();
2907  break;
2908  }
2909 
2910  bool selected = menuItem->state & State_Selected;
2911  bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
2912  bool checked = menuItem->checked;
2913 
2914  if (selected) {
2915  qt_plastique_draw_gradient(painter, menuItem->rect,
2916  option->palette.highlight().color().lighter(105),
2917  option->palette.highlight().color().darker(110));
2918 
2919  painter->setPen(option->palette.highlight().color().lighter(110));
2920  painter->drawLine(option->rect.topLeft(), option->rect.topRight());
2921  painter->setPen(option->palette.highlight().color().darker(115));
2922  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
2923  } else {
2924  painter->fillRect(option->rect, option->palette.background().color().lighter(103));
2925  }
2926 
2927  // Check
2928  QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13);
2929  checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
2930  if (checkable) {
2931  if ((menuItem->checkType & QStyleOptionMenuItem::Exclusive) && menuItem->icon.isNull()) {
2932  QStyleOptionButton button;
2933  button.rect = checkRect;
2934  button.state = menuItem->state;
2935  if (checked)
2936  button.state |= State_On;
2937  button.palette = menuItem->palette;
2938  proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget);
2939  } else {
2940  if (menuItem->icon.isNull()) {
2941  QStyleOptionButton button;
2942  button.rect = checkRect;
2943  button.state = menuItem->state;
2944  if (checked)
2945  button.state |= State_On;
2946  button.palette = menuItem->palette;
2947  proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
2948  } else if (checked) {
2949  int iconSize = qMax(menuItem->maxIconWidth, 20);
2950  QRect sunkenRect(option->rect.left() + 1,
2951  option->rect.top() + (option->rect.height() - iconSize) / 2 + 1,
2952  iconSize, iconSize);
2953  sunkenRect = visualRect(menuItem->direction, menuItem->rect, sunkenRect);
2954 
2955  QStyleOption opt = *option;
2956  opt.state |= State_Sunken;
2957  opt.rect = sunkenRect;
2958  qt_plastique_drawShadedPanel(painter, &opt, false, widget);
2959  }
2960  }
2961  }
2962 
2963  // Text and icon, ripped from windows style
2964  bool dis = !(menuItem->state & State_Enabled);
2965  bool act = menuItem->state & State_Selected;
2966  const QStyleOption *opt = option;
2967  const QStyleOptionMenuItem *menuitem = menuItem;
2968  int checkcol = qMax(menuitem->maxIconWidth, 20);
2969  QPainter *p = painter;
2970  QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
2971  QRect(menuitem->rect.x(), menuitem->rect.y(),
2972  checkcol, menuitem->rect.height()));
2973  if (!menuItem->icon.isNull()) {
2974  QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
2975  if (act && !dis)
2976  mode = QIcon::Active;
2977  QPixmap pixmap;
2978  if (checked)
2979  pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
2980  else
2981  pixmap = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode);
2982  int pixw = pixmap.width();
2983  int pixh = pixmap.height();
2984 
2985  QRect pmr(0, 0, pixw, pixh);
2986  pmr.moveCenter(vCheckRect.center());
2987  painter->setPen(textBrush.color());
2988  if (checkable && checked)
2989  painter->drawPixmap(QPoint(pmr.left() + 1, pmr.top() + 1), pixmap);
2990  else
2991  painter->drawPixmap(pmr.topLeft(), pixmap);
2992  }
2993 
2994  if (selected) {
2995  painter->setPen(menuItem->palette.highlightedText().color());
2996  } else {
2997  painter->setPen(textBrush.color());
2998  }
2999  int x, y, w, h;
3000  menuitem->rect.getRect(&x, &y, &w, &h);
3001  int tab = menuitem->tabWidth;
3002  QColor discol;
3003  if (dis) {
3004  discol = textBrush.color();
3005  p->setPen(discol);
3006  }
3007  int xm = windowsItemFrame + checkcol + windowsItemHMargin;
3008  int xpos = menuitem->rect.x() + xm;
3009  QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
3010  QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
3011  QString s = menuitem->text;
3012  if (!s.isEmpty()) { // draw text
3013  p->save();
3014  int t = s.indexOf(QLatin1Char('\t'));
3016  if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
3017  text_flags |= Qt::TextHideMnemonic;
3018  text_flags |= Qt::AlignLeft;
3019  if (t >= 0) {
3020  QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
3021  QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
3022  if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {
3023  p->setPen(menuitem->palette.light().color());
3024  p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
3025  p->setPen(discol);
3026  }
3027  p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
3028  s = s.left(t);
3029  }
3030  QFont font = menuitem->font;
3032  font.setBold(true);
3033  p->setFont(font);
3034  if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {
3035  p->setPen(menuitem->palette.light().color());
3036  p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
3037  p->setPen(discol);
3038  }
3039  p->drawText(vTextRect, text_flags, s.left(t));
3040  p->restore();
3041  }
3042 
3043  // Arrow
3044  if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
3045  int dim = (menuItem->rect.height() - 4) / 2;
3046  PrimitiveElement arrow;
3048  int xpos = menuItem->rect.left() + menuItem->rect.width() - 6 - 2 - dim;
3049  QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
3050  QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
3051  QStyleOptionMenuItem newMI = *menuItem;
3052  newMI.rect = vSubMenuRect;
3053  newMI.state = option->state & State_Enabled;
3054  if (selected)
3056  newMI.palette.highlightedText().color());
3057  else
3058  newMI.palette.setColor(QPalette::ButtonText, textBrush.color());
3059  proxy()->drawPrimitive(arrow, &newMI, painter, widget);
3060  }
3061 
3062  painter->restore();
3063  }
3064  break;
3065 #endif // QT_NO_MENU
3066 #ifndef QT_NO_MENUBAR
3067  case CE_MenuBarItem:
3068  // Draws a menu bar item; File, Edit, Help etc..
3069  if ((option->state & State_Selected)) {
3070  QPixmap cache;
3071  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size());
3072  if (!QPixmapCache::find(pixmapName, cache)) {
3073  cache = QPixmap(option->rect.size());
3074  cache.fill(Qt::white);
3075  QRect pixmapRect(0, 0, option->rect.width(), option->rect.height());
3076  QPainter cachePainter(&cache);
3077 
3078  QRect rect = pixmapRect;
3079 
3080  // gradient fill
3081  if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On)) {
3082  qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
3083  option->palette.button().color().darker(114),
3084  option->palette.button().color().darker(106));
3085  } else {
3086  qt_plastique_draw_gradient(&cachePainter, rect.adjusted(1, 1, -1, -1),
3087  option->palette.background().color().lighter(105),
3088  option->palette.background().color().darker(102));
3089  }
3090 
3091  // outer border and corners
3092  cachePainter.setPen(borderColor);
3093  cachePainter.drawRect(rect.adjusted(0, 0, -1, -1));
3094  cachePainter.setPen(alphaCornerColor);
3095 
3096  const QPoint points[4] = {
3097  rect.topLeft(),
3098  rect.topRight(),
3099  rect.bottomLeft(),
3100  rect.bottomRight() };
3101  cachePainter.drawPoints(points, 4);
3102 
3103  // inner border
3104  if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On))
3105  cachePainter.setPen(option->palette.button().color().darker(118));
3106  else
3107  cachePainter.setPen(gradientStartColor);
3108 
3109  QLine lines[2];
3110  lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1);
3111  lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
3112  cachePainter.drawLines(lines, 2);
3113 
3114  if ((option->state & QStyle::State_Sunken) || (option->state & QStyle::State_On))
3115  cachePainter.setPen(option->palette.button().color().darker(114));
3116  else
3117  cachePainter.setPen(gradientStopColor.darker(102));
3118  lines[0] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1);
3119  lines[1] = QLine(rect.right() - 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 2);
3120  cachePainter.drawLines(lines, 2);
3121  cachePainter.end();
3122  QPixmapCache::insert(pixmapName, cache);
3123  }
3124  painter->drawPixmap(option->rect.topLeft(), cache);
3125  } else {
3126  painter->fillRect(option->rect, option->palette.background());
3127  }
3128 
3129  if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
3130  QStyleOptionMenuItem newMI = *mbi;
3131  if (!(option->palette.resolve() & (1 << QPalette::ButtonText))) //KDE uses windowText rather than buttonText for menus
3133  QCommonStyle::drawControl(element, &newMI, painter, widget);
3134  }
3135  break;
3136 
3137 #ifndef QT_NO_MAINWINDOW
3138  case CE_MenuBarEmptyArea:
3139  if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
3140  painter->fillRect(option->rect, option->palette.window());
3141  QPen oldPen = painter->pen();
3142  painter->setPen(QPen(option->palette.dark().color()));
3143  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
3144  painter->setPen(oldPen);
3145  }
3146  break;
3147 #endif // QT_NO_MAINWINDOW
3148 
3149 #endif // QT_NO_MENUBAR
3150 
3151 #ifndef QT_NO_TOOLBOX
3152  case CE_ToolBoxTabShape:
3153  if (const QStyleOptionToolBox *toolBox = qstyleoption_cast<const QStyleOptionToolBox *>(option)) {
3154  painter->save();
3155 
3156  int width = toolBox->rect.width();
3157  int diag = toolBox->rect.height() - 2;
3158 
3159  // The essential points
3160  QPoint rightMost;
3161  QPoint rightEdge;
3162  QPoint leftEdge;
3163  QPoint leftMost;
3164  QPoint leftOne;
3165  QPoint rightOne;
3166  QPoint upOne(0, -1);
3167  QPoint downOne(0, 1);
3168 
3169  if (toolBox->direction != Qt::RightToLeft) {
3170  rightMost = QPoint(toolBox->rect.right(), toolBox->rect.bottom() - 2);
3171  rightEdge = QPoint(toolBox->rect.right() - width / 10, toolBox->rect.bottom() - 2);
3172  leftEdge = QPoint(toolBox->rect.right() - width / 10 - diag, toolBox->rect.top());
3173  leftMost = QPoint(toolBox->rect.left(), toolBox->rect.top());
3174  leftOne = QPoint(-1, 0);
3175  rightOne = QPoint(1, 0);
3176  } else {
3177  rightMost = QPoint(toolBox->rect.left(), toolBox->rect.bottom() - 2);
3178  rightEdge = QPoint(toolBox->rect.left() + width / 10, toolBox->rect.bottom() - 2);
3179  leftEdge = QPoint(toolBox->rect.left() + width / 10 + diag, toolBox->rect.top());
3180  leftMost = QPoint(toolBox->rect.right(), toolBox->rect.top());
3181  leftOne = QPoint(1, 0);
3182  rightOne = QPoint(-1, 0);
3183  }
3184 
3185  QLine lines[3];
3186 
3187  // Draw the outline
3188  painter->setPen(borderColor);
3189  lines[0] = QLine(rightMost, rightEdge);
3190  lines[1] = QLine(rightEdge + leftOne, leftEdge);
3191  lines[2] = QLine(leftEdge + leftOne, leftMost);
3192  painter->drawLines(lines, 3);
3193  painter->setPen(toolBox->palette.base().color());
3194  lines[0] = QLine(rightMost + downOne, rightEdge + downOne);
3195  lines[1] = QLine(rightEdge + leftOne + downOne, leftEdge + downOne);
3196  lines[2] = QLine(leftEdge + leftOne + downOne, leftMost + downOne);
3197  painter->drawLines(lines, 3);
3198 
3199  painter->restore();
3200  }
3201  break;
3202 #endif // QT_NO_TOOLBOX
3203 #ifndef QT_NO_SPLITTER
3204  case CE_Splitter:
3205  if ((option->state & State_Enabled) && (option->state & State_MouseOver))
3206  painter->fillRect(option->rect, QColor(255, 255, 255, 128));
3207  if (option->state & State_Horizontal) {
3208  int height = option->rect.height() / 3;
3209  QRect rect(option->rect.left() + (option->rect.width() / 2 - 1),
3210  option->rect.center().y() - height / 2, 3, height);
3211  qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget);
3212  } else {
3213  int width = option->rect.width() / 3;
3214  QRect rect(option->rect.center().x() - width / 2,
3215  option->rect.top() + (option->rect.height() / 2) - 1, width, 3);
3216  qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget);
3217  }
3218  break;
3219 #endif // QT_NO_SPLITTER
3220 #ifndef QT_NO_DOCKWIDGET
3221  case CE_DockWidgetTitle:
3222  if (const QStyleOptionDockWidget *dockWidget = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
3223  painter->save();
3224 
3225  const QStyleOptionDockWidgetV2 *v2
3226  = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dockWidget);
3227  bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
3228 
3229  // Find text width and title rect
3230  int textWidth = option->fontMetrics.width(dockWidget->title);
3231  int margin = 4;
3232  QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
3233  QRect rect = dockWidget->rect;
3234 
3235  if (verticalTitleBar) {
3236  QRect r = rect;
3237  QSize s = r.size();
3238  s.transpose();
3239  r.setSize(s);
3240 
3241  titleRect = QRect(r.left() + rect.bottom()
3242  - titleRect.bottom(),
3243  r.top() + titleRect.left() - rect.left(),
3244  titleRect.height(), titleRect.width());
3245 
3246  painter->translate(r.left(), r.top() + r.width());
3247  painter->rotate(-90);
3248  painter->translate(-r.left(), -r.top());
3249 
3250  rect = r;
3251  }
3252 
3253  // Chop and insert ellide into title if text is too wide
3254  QString title = elliditide(dockWidget->title, dockWidget->fontMetrics, titleRect, &textWidth);
3255 
3256  // Draw the toolbar handle pattern to the left and right of the text
3257  QImage handle(qt_toolbarhandle);
3258  alphaCornerColor.setAlpha(170);
3259  handle.setColor(1, alphaCornerColor.rgba());
3260  handle.setColor(2, mergedColors(alphaCornerColor, option->palette.light().color()).rgba());
3261  handle.setColor(3, option->palette.light().color().rgba());
3262 
3263  if (title.isEmpty()) {
3264  // Joint handle if there's no title
3265  QRect r;
3266 #ifdef QT3_SUPPORT
3267  // Q3DockWindow doesn't need space for buttons
3268  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
3269  r = rect;
3270  } else
3271 #endif
3272  r.setRect(titleRect.left(), titleRect.top(), titleRect.width(), titleRect.bottom());
3273  int nchunks = (r.width() / handle.width()) - 1;
3274  int indent = (r.width() - (nchunks * handle.width())) / 2;
3275  for (int i = 0; i < nchunks; ++i) {
3276  painter->drawImage(QPoint(r.left() + indent + i * handle.width(),
3277  r.center().y() - handle.height() / 2),
3278  handle);
3279  }
3280  } else {
3281  // Handle pattern to the left of the title
3282  QRect leftSide(titleRect.left(), titleRect.top(),
3283  titleRect.width() / 2 - textWidth / 2 - margin, titleRect.bottom());
3284  int nchunks = leftSide.width() / handle.width();
3285  int indent = (leftSide.width() - (nchunks * handle.width())) / 2;
3286  for (int i = 0; i < nchunks; ++i) {
3287  painter->drawImage(QPoint(leftSide.left() + indent
3288  + i * handle.width(),
3289  leftSide.center().y()
3290  - handle.height() / 2),
3291  handle);
3292  }
3293 
3294  // Handle pattern to the right of the title
3295  QRect rightSide = titleRect.adjusted(titleRect.width() / 2 + textWidth / 2 + margin, 0, 0, 0);
3296  nchunks = rightSide.width() / handle.width();
3297  indent = (rightSide.width() - (nchunks * handle.width())) / 2;
3298  for (int j = 0; j < nchunks; ++j) {
3299  painter->drawImage(QPoint(rightSide.left() + indent + j * handle.width(),
3300  rightSide.center().y() - handle.height() / 2),
3301  handle);
3302  }
3303  }
3304 
3305  // Draw the text centered
3306  QFont font = painter->font();
3307  font.setPointSize(QFontInfo(font).pointSize() - 1);
3308  painter->setFont(font);
3309  painter->setPen(dockWidget->palette.windowText().color());
3310  painter->drawText(titleRect,
3312  title);
3313 
3314  painter->restore();
3315  }
3316 
3317  break;
3318 #endif // QT_NO_DOCKWIDGET
3319 #ifndef QT_NO_TOOLBAR
3320  case CE_ToolBar:
3321  if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
3322  // Draws the light line above and the dark line below menu bars and
3323  // tool bars.
3324  QPen oldPen = painter->pen();
3325  if (toolBar->toolBarArea == Qt::TopToolBarArea) {
3326  if (toolBar->positionOfLine == QStyleOptionToolBar::End
3327  || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
3328  // The end and onlyone top toolbar lines draw a double
3329  // line at the bottom to blend with the central
3330  // widget.
3331  painter->setPen(option->palette.background().color().lighter(104));
3332  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
3333  painter->setPen(alphaCornerColor);
3334  painter->drawLine(option->rect.left(), option->rect.bottom() - 1,
3335  option->rect.right(), option->rect.bottom() - 1);
3336  } else {
3337  // All others draw a single dark line at the bottom.
3338  painter->setPen(alphaCornerColor);
3339  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
3340  }
3341  // All top toolbar lines draw a light line at the top.
3342  painter->setPen(option->palette.background().color().lighter(104));
3343  painter->drawLine(option->rect.topLeft(), option->rect.topRight());
3344  } else if (toolBar->toolBarArea == Qt::BottomToolBarArea) {
3345  if (toolBar->positionOfLine == QStyleOptionToolBar::End
3346  || toolBar->positionOfLine == QStyleOptionToolBar::Middle) {
3347  // The end and middle bottom tool bar lines draw a dark
3348  // line at the bottom.
3349  painter->setPen(alphaCornerColor);
3350  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
3351  }
3352  if (toolBar->positionOfLine == QStyleOptionToolBar::Beginning
3353  || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
3354  // The beginning and only one tool bar lines draw a
3355  // double line at the bottom to blend with the
3356  // status bar.
3357  // ### The styleoption could contain whether the
3358  // main window has a menu bar and a status bar, and
3359  // possibly dock widgets.
3360  painter->setPen(alphaCornerColor);
3361  painter->drawLine(option->rect.left(), option->rect.bottom() - 1,
3362  option->rect.right(), option->rect.bottom() - 1);
3363  painter->setPen(option->palette.background().color().lighter(104));
3364  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
3365  }
3366  if (toolBar->positionOfLine == QStyleOptionToolBar::End) {
3367  painter->setPen(alphaCornerColor);
3368  painter->drawLine(option->rect.topLeft(), option->rect.topRight());
3369  painter->setPen(option->palette.background().color().lighter(104));
3370  painter->drawLine(option->rect.left(), option->rect.top() + 1,
3371  option->rect.right(), option->rect.top() + 1);
3372 
3373  } else {
3374  // All other bottom toolbars draw a light line at the top.
3375  painter->setPen(option->palette.background().color().lighter(104));
3376  painter->drawLine(option->rect.topLeft(), option->rect.topRight());
3377  }
3378  }
3379  if (toolBar->toolBarArea == Qt::LeftToolBarArea) {
3380  if (toolBar->positionOfLine == QStyleOptionToolBar::Middle
3381  || toolBar->positionOfLine == QStyleOptionToolBar::End) {
3382  // The middle and left end toolbar lines draw a light
3383  // line to the left.
3384  painter->setPen(option->palette.background().color().lighter(104));
3385  painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
3386  }
3387  if (toolBar->positionOfLine == QStyleOptionToolBar::End) {
3388  // All other left toolbar lines draw a dark line to the right
3389  painter->setPen(alphaCornerColor);
3390  painter->drawLine(option->rect.right() - 1, option->rect.top(),
3391  option->rect.right() - 1, option->rect.bottom());
3392  painter->setPen(option->palette.background().color().lighter(104));
3393  painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
3394  } else {
3395  // All other left toolbar lines draw a dark line to the right
3396  painter->setPen(alphaCornerColor);
3397  painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
3398  }
3399  } else if (toolBar->toolBarArea == Qt::RightToolBarArea) {
3400  if (toolBar->positionOfLine == QStyleOptionToolBar::Middle
3401  || toolBar->positionOfLine == QStyleOptionToolBar::End) {
3402  // Right middle and end toolbar lines draw the dark right line
3403  painter->setPen(alphaCornerColor);
3404  painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
3405  }
3406  if (toolBar->positionOfLine == QStyleOptionToolBar::End
3407  || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
3408  // The right end and single toolbar draws the dark
3409  // line on its left edge
3410  painter->setPen(alphaCornerColor);
3411  painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
3412  // And a light line next to it
3413  painter->setPen(option->palette.background().color().lighter(104));
3414  painter->drawLine(option->rect.left() + 1, option->rect.top(),
3415  option->rect.left() + 1, option->rect.bottom());
3416  } else {
3417  // Other right toolbars draw a light line on its left edge
3418  painter->setPen(option->palette.background().color().lighter(104));
3419  painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
3420  }
3421  }
3422  painter->setPen(oldPen);
3423  }
3424  break;
3425 #endif // QT_NO_TOOLBAR
3426 #ifndef QT_NO_SCROLLBAR
3427  case CE_ScrollBarAddLine:
3428  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3429 
3430  bool horizontal = scrollBar->orientation == Qt::Horizontal;
3431  bool reverse = scrollBar->direction == Qt::RightToLeft;
3432  bool sunken = scrollBar->state & State_Sunken;
3433 
3434  QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size());
3435  QPixmap cache;
3436  if (!QPixmapCache::find(addLinePixmapName, cache)) {
3437  cache = QPixmap(option->rect.size());
3438  cache.fill(Qt::white);
3439  QRect pixmapRect(0, 0, cache.width(), cache.height());
3440  QPainter addLinePainter(&cache);
3441  addLinePainter.fillRect(pixmapRect, option->palette.background());
3442 
3443  if (option->state & State_Enabled) {
3444  // Gradient
3445  QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top() + 2,
3446  pixmapRect.center().x(), pixmapRect.bottom() - 2);
3447  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
3448  gradient.setColorAt(0, gradientStopColor);
3449  gradient.setColorAt(1, gradientStopColor);
3450  } else {
3451  gradient.setColorAt(0, gradientStartColor.lighter(105));
3452  gradient.setColorAt(1, gradientStopColor);
3453  }
3454  addLinePainter.fillRect(pixmapRect.left() + 2, pixmapRect.top() + 2,
3455  pixmapRect.right() - 3, pixmapRect.bottom() - 3,
3456  gradient);
3457  }
3458 
3459  // Details
3460  QImage addButton;
3461  if (horizontal) {
3463  } else {
3464  addButton = QImage(qt_scrollbar_button_down);
3465  }
3466  addButton.setColor(1, alphaCornerColor.rgba());
3467  addButton.setColor(2, borderColor.rgba());
3468  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
3469  addButton.setColor(3, gradientStopColor.rgba());
3470  addButton.setColor(4, gradientStopColor.rgba());
3471  } else {
3472  addButton.setColor(3, gradientStartColor.lighter(105).rgba());
3473  addButton.setColor(4, gradientStopColor.rgba());
3474  }
3475  addButton.setColor(5, scrollBar->palette.text().color().rgba());
3476  addLinePainter.drawImage(pixmapRect, addButton);
3477 
3478  // Arrow
3479  if (horizontal) {
3481  arrow.setColor(1, scrollBar->palette.foreground().color().rgba());
3482 
3483  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken)
3484  addLinePainter.translate(1, 1);
3485  addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow);
3486  } else {
3488  arrow.setColor(1, scrollBar->palette.foreground().color().rgba());
3489 
3490  if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken)
3491  addLinePainter.translate(1, 1);
3492  addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow);
3493  }
3494  addLinePainter.end();
3495  QPixmapCache::insert(addLinePixmapName, cache);
3496  }
3497  painter->drawPixmap(option->rect.topLeft(), cache);
3498  }
3499  break;
3500  case CE_ScrollBarSubPage:
3501  case CE_ScrollBarAddPage:
3502  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3503  bool sunken = scrollBar->state & State_Sunken;
3504  bool horizontal = scrollBar->orientation == Qt::Horizontal;
3505 
3506  QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size());
3507  if (sunken)
3508  groovePixmapName += QLatin1String("-sunken");
3509  if (element == CE_ScrollBarAddPage)
3510  groovePixmapName += QLatin1String("-addpage");
3511 
3512  QPixmap cache;
3513  if (!QPixmapCache::find(groovePixmapName, cache)) {
3514  cache = QPixmap(option->rect.size());
3515  cache.fill(option->palette.background().color());
3516  QPainter groovePainter(&cache);
3517  QRect pixmapRect = QRect(0, 0, option->rect.width(), option->rect.height());
3518  QColor color = scrollBar->palette.base().color().darker(sunken ? 125 : 100);
3519  groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 0,
3520  (element == CE_ScrollBarAddPage) ? pixmapRect.height() : 0);
3521  groovePainter.fillRect(pixmapRect, QBrush(color, Qt::Dense4Pattern));
3522 
3523  QColor edgeColor = scrollBar->palette.base().color().darker(125);
3524  if (horizontal) {
3525  groovePainter.setBrushOrigin((element == CE_ScrollBarAddPage) ? pixmapRect.width() : 1, 0);
3526  groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(pixmapRect.width(), 1)),
3527  QBrush(edgeColor, Qt::Dense4Pattern));
3528  groovePainter.fillRect(QRect(pixmapRect.bottomLeft(), QSize(pixmapRect.width(), 1)),
3529  QBrush(edgeColor, Qt::Dense4Pattern));
3530  } else {
3531  groovePainter.setBrushOrigin(0, (element == CE_ScrollBarAddPage) ? pixmapRect.height() : 1);
3532  groovePainter.fillRect(QRect(pixmapRect.topLeft(), QSize(1, pixmapRect.height())),
3533  QBrush(edgeColor, Qt::Dense4Pattern));
3534  groovePainter.fillRect(QRect(pixmapRect.topRight(), QSize(1, pixmapRect.height())),
3535  QBrush(edgeColor, Qt::Dense4Pattern));
3536  }
3537 
3538  groovePainter.end();
3539  QPixmapCache::insert(groovePixmapName, cache);
3540  }
3541  painter->drawPixmap(option->rect.topLeft(), cache);
3542  }
3543  break;
3544  case CE_ScrollBarSubLine:
3545  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3546  QRect scrollBarSubLine = scrollBar->rect;
3547 
3548  bool horizontal = scrollBar->orientation == Qt::Horizontal;
3549  bool isEnabled = scrollBar->state & State_Enabled;
3550  bool reverse = scrollBar->direction == Qt::RightToLeft;
3551  bool sunken = scrollBar->state & State_Sunken;
3552 
3553  // The SubLine (up/left) buttons
3554  QRect button1;
3555  QRect button2;
3556  int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
3557  if (horizontal) {
3558  button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height());
3559  button2.setRect(scrollBarSubLine.right() - (scrollBarExtent - 1), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height());
3560  } else {
3561  button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarSubLine.width(), scrollBarExtent);
3562  button2.setRect(scrollBarSubLine.left(), scrollBarSubLine.bottom() - (scrollBarExtent - 1), scrollBarSubLine.width(), scrollBarExtent);
3563  }
3564 
3565  QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size());
3566  QPixmap cache;
3567  if (!QPixmapCache::find(subLinePixmapName, cache)) {
3568  cache = QPixmap(button1.size());
3569  cache.fill(Qt::white);
3570  QRect pixmapRect(0, 0, cache.width(), cache.height());
3571  QPainter subLinePainter(&cache);
3572  subLinePainter.fillRect(pixmapRect, option->palette.background());
3573 
3574  if (isEnabled) {
3575  // Gradients
3576  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
3577  qt_plastique_draw_gradient(&subLinePainter,
3578  QRect(pixmapRect.left() + 2, pixmapRect.top() + 2,
3579  pixmapRect.right() - 3, pixmapRect.bottom() - 3),
3580  gradientStopColor,
3581  gradientStopColor);
3582  } else {
3583  qt_plastique_draw_gradient(&subLinePainter,
3584  QRect(pixmapRect.left() + 2, pixmapRect.top() + 2,
3585  pixmapRect.right() - 3, pixmapRect.bottom() - 3),
3586  gradientStartColor.lighter(105),
3587  gradientStopColor);
3588  }
3589  }
3590 
3591  // Details
3592  QImage subButton;
3593  if (horizontal) {
3595  } else {
3596  subButton = QImage(qt_scrollbar_button_up);
3597  }
3598  subButton.setColor(1, alphaCornerColor.rgba());
3599  subButton.setColor(2, borderColor.rgba());
3600  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
3601  subButton.setColor(3, gradientStopColor.rgba());
3602  subButton.setColor(4, gradientStopColor.rgba());
3603  } else {
3604  subButton.setColor(3, gradientStartColor.lighter(105).rgba());
3605  subButton.setColor(4, gradientStopColor.rgba());
3606  }
3607  subButton.setColor(5, scrollBar->palette.text().color().rgba());
3608  subLinePainter.drawImage(pixmapRect, subButton);
3609 
3610  // Arrows
3611  if (horizontal) {
3613  arrow.setColor(1, scrollBar->palette.foreground().color().rgba());
3614 
3615  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken)
3616  subLinePainter.translate(1, 1);
3617  subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 2, pixmapRect.center().y() - 3), arrow);
3618  } else {
3620  arrow.setColor(1, scrollBar->palette.foreground().color().rgba());
3621 
3622  if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken)
3623  subLinePainter.translate(1, 1);
3624  subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow);
3625  }
3626  subLinePainter.end();
3627  QPixmapCache::insert(subLinePixmapName, cache);
3628  }
3629  painter->drawPixmap(button1.topLeft(), cache);
3630  painter->drawPixmap(button2.topLeft(), cache);
3631  }
3632  break;
3633  case CE_ScrollBarSlider:
3634  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3635  bool horizontal = scrollBar->orientation == Qt::Horizontal;
3636  bool isEnabled = scrollBar->state & State_Enabled;
3637 
3638  // The slider
3639  if (option->rect.isValid()) {
3640  QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size());
3641  if (horizontal)
3642  sliderPixmapName += QLatin1String("-horizontal");
3643 
3644  QPixmap cache;
3645  if (!QPixmapCache::find(sliderPixmapName, cache)) {
3646  cache = QPixmap(option->rect.size());
3647  cache.fill(Qt::white);
3648  QRect pixmapRect(0, 0, cache.width(), cache.height());
3649  QPainter sliderPainter(&cache);
3650  bool sunken = (scrollBar->state & State_Sunken);
3651 
3652  if (isEnabled) {
3653  QLinearGradient gradient(pixmapRect.left(), pixmapRect.center().y(),
3654  pixmapRect.right(), pixmapRect.center().y());
3655  if (horizontal)
3656  gradient = QLinearGradient(pixmapRect.center().x(), pixmapRect.top(),
3657  pixmapRect.center().x(), pixmapRect.bottom());
3658 
3659  if (sunken) {
3660  gradient.setColorAt(0, gradientStartColor.lighter(110));
3661  gradient.setColorAt(1, gradientStopColor.lighter(105));
3662  } else {
3663  gradient.setColorAt(0, gradientStartColor.lighter(105));
3664  gradient.setColorAt(1, gradientStopColor);
3665  }
3666  sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), gradient);
3667  } else {
3668  sliderPainter.fillRect(pixmapRect.adjusted(2, 2, -2, -2), option->palette.background());
3669  }
3670 
3671  sliderPainter.setPen(borderColor);
3672  sliderPainter.drawRect(pixmapRect.adjusted(0, 0, -1, -1));
3673  sliderPainter.setPen(alphaCornerColor);
3674  QPoint points[4] = {
3675  QPoint(pixmapRect.left(), pixmapRect.top()),
3676  QPoint(pixmapRect.left(), pixmapRect.bottom()),
3677  QPoint(pixmapRect.right(), pixmapRect.top()),
3678  QPoint(pixmapRect.right(), pixmapRect.bottom()) };
3679  sliderPainter.drawPoints(points, 4);
3680 
3681  QLine lines[2];
3682  sliderPainter.setPen(sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105));
3683  lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 1,
3684  pixmapRect.right() - 1, pixmapRect.top() + 1);
3685  lines[1] = QLine(pixmapRect.left() + 1, pixmapRect.top() + 2,
3686  pixmapRect.left() + 1, pixmapRect.bottom() - 2);
3687  sliderPainter.drawLines(lines, 2);
3688 
3689  sliderPainter.setPen(sunken ? gradientStopColor.lighter(105) : gradientStopColor);
3690  lines[0] = QLine(pixmapRect.left() + 1, pixmapRect.bottom() - 1,
3691  pixmapRect.right() - 1, pixmapRect.bottom() - 1);
3692  lines[1] = QLine(pixmapRect.right() - 1, pixmapRect.top() + 2,
3693  pixmapRect.right() - 1, pixmapRect.bottom() - 1);
3694  sliderPainter.drawLines(lines, 2);
3695 
3696  int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
3697  if ((horizontal && scrollBar->rect.width() > sliderMinLength)
3698  || (!horizontal && scrollBar->rect.height() > sliderMinLength)) {
3699  QImage pattern(horizontal ? qt_scrollbar_slider_pattern_horizontal
3701  pattern.setColor(1, alphaCornerColor.rgba());
3702  pattern.setColor(2, (sunken ? gradientStartColor.lighter(110) : gradientStartColor.lighter(105)).rgba());
3703 
3704  if (horizontal) {
3705  sliderPainter.drawImage(pixmapRect.center().x() - pattern.width() / 2 + 1,
3706  pixmapRect.center().y() - 4,
3707  pattern);
3708  } else {
3709  sliderPainter.drawImage(pixmapRect.center().x() - 4,
3710  pixmapRect.center().y() - pattern.height() / 2 + 1,
3711  pattern);
3712  }
3713  }
3714  sliderPainter.end();
3715  // insert the slider into the cache
3716  QPixmapCache::insert(sliderPixmapName, cache);
3717  }
3718  painter->drawPixmap(option->rect.topLeft(), cache);
3719  }
3720  }
3721  break;
3722 #endif
3723 #ifndef QT_NO_COMBOBOX
3724  case CE_ComboBoxLabel:
3725  if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3726  painter->save();
3727  if (!comboBox->editable) {
3728  // Plastique's non-editable combo box is drawn as a button, so
3729  // we need the label to be drawn using ButtonText where it
3730  // would usually use Text.
3731  painter->setPen(QPen(comboBox->palette.buttonText(), 0));
3732  QWindowsStyle::drawControl(element, option, painter, widget);
3733  } else if (!comboBox->currentIcon.isNull()) {
3734  {
3735  QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget);
3736  if (comboBox->direction == Qt::RightToLeft)
3737  editRect.adjust(0, 2, -2, -2);
3738  else
3739  editRect.adjust(2, 2, 0, -2);
3740  painter->save();
3741  painter->setClipRect(editRect);
3742  if (!comboBox->currentIcon.isNull()) {
3743  QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal
3744  : QIcon::Disabled;
3745  QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode);
3746  QRect iconRect(editRect);
3747  iconRect.setWidth(comboBox->iconSize.width() + 5);
3748  iconRect = alignedRect(comboBox->direction,
3750  iconRect.size(), editRect);
3751  painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
3752  proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
3753  }
3754  painter->restore();
3755  }
3756  } else {
3757  QWindowsStyle::drawControl(element, option, painter, widget);
3758  }
3759 
3760  painter->restore();
3761  }
3762  break;
3763 #endif
3764  default:
3765  QWindowsStyle::drawControl(element, option, painter, widget);
3766  break;
3767  }
3768 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
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
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
Definition: qstyle.cpp:2120
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
const T * constData() const
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
static QBrush qBrushDark(QBrush brush, int dark)
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
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
const QBrush & base() const
Returns the base brush of the current color group.
Definition: qpalette.h:130
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect)
void setColor(int i, QRgb c)
Sets the color at the given index in the color table, to the given to colorValue. ...
Definition: qimage.cpp:1850
double qreal
Definition: qglobal.h:1193
#define disabled
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *option, bool base, const QWidget *widget)
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
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 QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
Definition: qstyleoption.h:251
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
QPoint p1() const
Returns the line&#39;s start point.
Definition: qline.h:132
static const char *const qt_toolbarhandle[]
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
void rotate(qreal a)
Rotates the coordinate system the given angle clockwise.
Definition: qpainter.cpp:3287
const QBrush & background() const
Use window() instead.
Definition: qpalette.h:134
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QFont font
the font used for the menu item text
Definition: qstyleoption.h:454
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
Reimplemented Function
QPoint p2() const
Returns the line&#39;s end point.
Definition: qline.h:137
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
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
QRect normalized() const
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height...
Definition: qrect.cpp:322
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int maxIconWidth
the maximum icon width for the icon in the menu item
Definition: qstyleoption.h:452
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int styleHint(StyleHint hint, const QStyleOption *option=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
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
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
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
The QStyleOptionToolBox class is used to describe the parameters needed for drawing a tool box...
Definition: qstyleoption.h:633
static const char *const qt_scrollbar_slider_pattern_horizontal[]
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void append(const T &t)
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen&#39;s color.
Definition: qpainter.h:676
QString text
the text for the menu item
Definition: qstyleoption.h:450
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
static QPixmap * find(const QString &key)
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
static const char *const qt_scrollbar_button_arrow_right[]
static const char *const qt_scrollbar_slider_pattern_vertical[]
The QStyleOptionProgressBarV2 class is used to describe the parameters necessary for drawing a progre...
Definition: qstyleoption.h:417
int width() const
Returns the width.
Definition: qsize.h:126
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
static const int windowsRightBorder
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
static const char *const qt_scrollbar_button_arrow_left[]
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QBrush qBrushLight(QBrush brush, int light)
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
static const int windowsItemVMargin
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void transpose()
Swaps the width and height values.
Definition: qsize.cpp:196
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static const char *const qt_scrollbar_button_down[]
__int64 qint64
Definition: qglobal.h:942
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
MenuItemType menuItemType
the type of menu item
Definition: qstyleoption.h:445
int count() 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 t...
Definition: qobject.h:275
The QFontInfo class provides general information about fonts.
Definition: qfontinfo.h:54
static const int windowsItemHMargin
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
static const bool AnimateBusyProgressBar
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
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition: qpalette.h:124
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static const char *const qt_scrollbar_button_arrow_up[]
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 ProgressBarFps
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition: qpalette.h:141
static void qt_plastique_draw_handle(QPainter *painter, const QStyleOption *option, const QRect &rect, Qt::Orientation orientation, const QWidget *widget)
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
static const bool AnimateProgressBar
int tabWidth
the tab width for the menu item
Definition: qstyleoption.h:453
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static const char *const qt_scrollbar_button_left[]
static QString elliditide(const QString &text, const QFontMetrics &fontMetrics, const QRect &rect, int *textWidth=0)
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop)
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void 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
int height() const
Returns the height.
Definition: qsize.h:129
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static const int windowsItemFrame
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
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
int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
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 QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE...
The QStyleOptionTab class is used to describe the parameters for drawing a tab bar.
Definition: qstyleoption.h:304
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
The 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
static void qBrushSetAlphaF(QBrush *brush, qreal alpha)
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition: qpalette.h:138
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
QRegion subtracted(const QRegion &r) const
Returns a region which is r subtracted from this region.
Definition: qregion.h:114
static const char *const qt_scrollbar_button_arrow_down[]
static const char *const qt_scrollbar_button_up[]
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QStyleOptionProgressBar class is used to describe the parameters necessary for drawing a progress...
Definition: qstyleoption.h:396
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition: qpalette.h:135
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
static const char *const qt_scrollbar_button_right[]
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
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

◆ drawPrimitive()

void QPlastiqueStyle::drawPrimitive ( PrimitiveElement  element,
const QStyleOption option,
QPainter painter,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 1104 of file qplastiquestyle.cpp.

1106 {
1107  Q_ASSERT(option);
1108 
1109  QColor borderColor = option->palette.background().color().darker(178);
1110  QColor alphaCornerColor;
1111  if (widget) {
1112  // ### backgroundrole/foregroundrole should be part of the style option
1113  alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
1114  } else {
1115  alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
1116  }
1117  QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
1118 
1119  switch (element) {
1121  proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget);
1122  break;
1123  case PE_FrameDefaultButton: {
1124  if (!(option->state & QStyle::State_Enabled))
1125  break;
1126  painter->setPen(QPen(QColor(0, 0, 0, 127), 0));
1127  const QLine lines[4] = {
1128  QLine(option->rect.left() + 2, option->rect.top(),
1129  option->rect.right() - 2, option->rect.top()),
1130  QLine(option->rect.left() + 2, option->rect.bottom(),
1131  option->rect.right() - 2, option->rect.bottom()),
1132  QLine(option->rect.left(), option->rect.top() + 2,
1133  option->rect.left(), option->rect.bottom() - 2),
1134  QLine(option->rect.right(), option->rect.top() + 2,
1135  option->rect.right(), option->rect.bottom() - 2) };
1136  painter->drawLines(lines, 4);
1137 
1138  QPoint points[8];
1139  points[0] = QPoint(option->rect.left() + 1, option->rect.top() + 1);
1140  points[1] = QPoint(option->rect.right() - 1, option->rect.top() + 1);
1141  points[2] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1);
1142  points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1);
1143  painter->drawPoints(points, 4);
1144 
1145  painter->setPen(QPen(QColor(0, 0, 0, 63), 0));
1146  points[0] = QPoint(option->rect.left() + 1, option->rect.top());
1147  points[1] = QPoint(option->rect.right() - 1, option->rect.top());
1148  points[2] = QPoint(option->rect.left(), option->rect.top() + 1);
1149  points[3] = QPoint(option->rect.right(), option->rect.top() + 1);
1150  points[4] = QPoint(option->rect.left() + 1, option->rect.bottom());
1151  points[5] = QPoint(option->rect.right() - 1, option->rect.bottom());
1152  points[6] = QPoint(option->rect.left(), option->rect.bottom() - 1);
1153  points[7] = QPoint(option->rect.right(), option->rect.bottom() - 1);
1154  painter->drawPoints(points, 8);
1155 
1156  break;
1157  }
1158 #ifndef QT_NO_TABWIDGET
1159  case PE_FrameTabWidget:
1160  if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
1161  if (twf->shape != QTabBar::RoundedNorth && twf->shape != QTabBar::RoundedWest &&
1162  twf->shape != QTabBar::RoundedSouth && twf->shape != QTabBar::RoundedEast) {
1163  QWindowsStyle::drawPrimitive(element, option, painter, widget);
1164  break;
1165  }
1166 
1167  int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget);
1168  bool reverse = (twf->direction == Qt::RightToLeft);
1169 
1170  painter->save();
1171 
1172  // Start by filling the contents of the tab widget frame (which is
1173  // actually a panel).
1174  painter->fillRect(option->rect.adjusted(1, 1, -1, -1), option->palette.window());
1175 
1176  QRect tabBarRect;
1177  switch (twf->shape) {
1178  case QTabBar::RoundedNorth:
1179  if (reverse)
1180  tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1, twf->rect.top(), twf->tabBarSize.width(), borderThickness);
1181  else
1182  tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(), twf->rect.top(), twf->tabBarSize.width(), borderThickness);
1183  break ;
1184  case QTabBar::RoundedWest:
1185  tabBarRect = QRect(twf->rect.left(), twf->rect.top() + twf->leftCornerWidgetSize.height(), borderThickness, twf->tabBarSize.height());
1186  break ;
1187  case QTabBar::RoundedEast:
1188  tabBarRect = QRect(twf->rect.right() - borderThickness + 1, twf->rect.top() + twf->leftCornerWidgetSize.height(),
1189  borderThickness, twf->tabBarSize.height());
1190  break ;
1191  case QTabBar::RoundedSouth:
1192  if (reverse)
1193  tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1,
1194  twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness);
1195  else
1196  tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
1197  twf->rect.bottom() - borderThickness + 1, twf->tabBarSize.width(), borderThickness);
1198  break ;
1199  default:
1200  break;
1201  }
1202 
1203  QRegion region(twf->rect);
1204  region -= tabBarRect;
1205  painter->setClipRegion(region);
1206 
1207  // Outer border
1208  QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2));
1209  QLine rightLine = QLine(twf->rect.topRight() + QPoint(0, 2), twf->rect.bottomRight() - QPoint(0, 2));
1210  QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0));
1211  QLine topLine = QLine(twf->rect.topLeft() + QPoint(2, 0), twf->rect.topRight() - QPoint(2, 0));
1212 
1213  QBrush border = option->palette.shadow();
1214  qBrushSetAlphaF(&border, qreal(0.4));
1215  painter->setPen(QPen(border, 0));
1216 
1219 
1220  lines.append(topLine);
1221 
1222  // Inner border
1223  QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0));
1224  QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, 0), rightLine.p2() - QPoint(1, 0));
1225  QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1));
1226  QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(0, 1));
1227 
1228  // Rounded Corner
1229  QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1));
1230  QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1));
1231  QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0));
1232  QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1));
1233  QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1));
1234  QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0));
1235  QPoint rightTopOuterCorner = QPoint(innerRightLine.p1() - QPoint(0, 1));
1236  QPoint rightTopInnerCorner1 = QPoint(rightLine.p1() - QPoint(0, 1));
1237  QPoint rightTopInnerCorner2 = QPoint(topLine.p2() + QPoint(1, 0));
1238  QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1));
1239  QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1));
1240  QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0));
1241 
1242  lines.append(leftLine);
1243  lines.append(rightLine);
1244  lines.append(bottomLine);
1245 
1246  painter->drawLines(lines.constData(), lines.size());
1247  lines.clear();
1248 
1249  points.append(leftBottomOuterCorner);
1250  points.append(rightBottomOuterCorner);
1251  points.append(rightTopOuterCorner);
1252  points.append(leftTopOuterCorner);
1253 
1254  painter->drawPoints(points.constData(), points.size());
1255  points.clear();
1256 
1257  QBrush innerTopLeft = option->palette.shadow();
1258  qBrushSetAlphaF(&innerTopLeft, qreal(0.075));
1259  painter->setPen(QPen(innerTopLeft, 0));
1260 
1261  lines.append(innerLeftLine);
1262  lines.append(innerTopLine);
1263  painter->drawLines(lines.constData(), lines.size());
1264  lines.clear();
1265 
1266  QBrush innerBottomRight = option->palette.shadow();
1267  qBrushSetAlphaF(&innerBottomRight, qreal(0.23));
1268  painter->setPen(QPen(innerBottomRight, 0));
1269  lines.append(innerRightLine);
1270  lines.append(innerBottomLine);
1271  painter->drawLines(lines.constData(), lines.size());
1272  lines.clear();
1273 
1274  QBrush corner = option->palette.shadow();
1275  qBrushSetAlphaF(&corner, 0.25);
1276  painter->setPen(QPen(corner, 0));
1277  points.append(leftBottomInnerCorner1);
1278  points.append(leftBottomInnerCorner2);
1279  points.append(rightBottomInnerCorner1);
1280  points.append(rightBottomInnerCorner2);
1281  points.append(rightTopInnerCorner1);
1282  points.append(rightTopInnerCorner2);
1283  points.append(leftTopInnerCorner1);
1284  points.append(leftTopInnerCorner2);
1285  painter->drawPoints(points.constData(), points.size());
1286  points.clear();
1287 
1288  painter->restore();
1289  }
1290  break ;
1291 #endif // QT_NO_TABWIDGET
1292 #ifndef QT_NO_TABBAR
1293  case PE_FrameTabBarBase:
1294  if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
1295  if (tbb->shape != QTabBar::RoundedNorth && tbb->shape != QTabBar::RoundedWest &&
1296  tbb->shape != QTabBar::RoundedSouth && tbb->shape != QTabBar::RoundedEast) {
1297  QWindowsStyle::drawPrimitive(element, option, painter, widget);
1298  break;
1299  }
1300 
1301  painter->save();
1302 
1303  QRegion region(tbb->rect);
1304  region -= tbb->tabBarRect;
1305  painter->setClipRegion(region);
1306 
1307  QLine topLine = QLine(tbb->rect.bottomLeft() - QPoint(0, 1), tbb->rect.bottomRight() - QPoint(0, 1));
1308  QLine bottomLine = QLine(tbb->rect.bottomLeft(), tbb->rect.bottomRight());
1309 
1310  QBrush border = option->palette.shadow();
1311  qBrushSetAlphaF(&border, qreal(0.4));
1312  QBrush innerTopLeft = option->palette.shadow();
1313  qBrushSetAlphaF(&innerTopLeft, qreal(0.075));
1314  QBrush innerBottomRight = option->palette.shadow();
1315  qBrushSetAlphaF(&innerBottomRight, qreal(0.23));
1316  QBrush corner = option->palette.shadow();
1317  qBrushSetAlphaF(&corner, 0.25);
1318 
1319  if (tbb->shape == QTabBar::RoundedSouth)
1320  painter->setPen(QPen(corner, 0));
1321  else
1322  painter->setPen(QPen(border, 0));
1323  painter->drawLine(topLine);
1324 
1325  if (tbb->shape != QTabBar::RoundedSouth)
1326  painter->setPen(QPen(innerTopLeft, 0));
1327  else
1328  painter->setPen(QPen(border, 0));
1329  painter->drawLine(bottomLine);
1330 
1331  painter->restore();
1332  }
1333  break ;
1334 #endif // QT_NO_TABBAR
1335 #ifndef QT_NO_GROUPBOX
1336  case PE_FrameGroupBox:
1337  if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
1338  QStyleOptionFrameV2 frameV2(*frame);
1339  if (frameV2.features & QStyleOptionFrameV2::Flat) {
1340  QPen oldPen = painter->pen();
1341  painter->setPen(borderColor);
1342  painter->drawLine(frameV2.rect.topLeft(), frameV2.rect.topRight());
1343  painter->setPen(oldPen);
1344  } else {
1345  frameV2.state &= ~(State_Sunken | State_HasFocus);
1346  proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget);
1347  }
1348  }
1349  break;
1350 #endif // QT_NO_GROUPBOX
1351  case PE_Frame: {
1352  QFrame::Shadow shadow = QFrame::Plain;
1353  if (option->state & State_Sunken)
1354  shadow = QFrame::Sunken;
1355  else if (option->state & State_Raised)
1356  shadow = QFrame::Raised;
1357  qt_plastique_draw_frame(painter, option->rect, option, shadow);
1358  break;
1359  }
1360 #ifndef QT_NO_LINEEDIT
1361  case PE_FrameLineEdit:
1362  qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken);
1363  break;
1364  case PE_PanelLineEdit:
1365  if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
1366  // Panel of a line edit inside combo box or spin box is drawn in CC_ComboBox and CC_SpinBox
1367  if (widget) {
1368 #ifndef QT_NO_SPINBOX
1369  // Spinbox doesn't need a separate palette for the lineedit
1370  if (qobject_cast<const QAbstractSpinBox *>(widget->parentWidget()))
1371  break;
1372 #endif
1373  }
1374 
1375  painter->save();
1376 
1377  // Fill the line edit insides
1378  QRect filledRect = lineEdit->rect.adjusted(1, 1, -1, -1);
1379  QBrush baseBrush = qMapBrushToRect(lineEdit->palette.base(), filledRect);
1380  painter->setBrushOrigin(filledRect.topLeft());
1381  painter->fillRect(filledRect.adjusted(1, 1, -1, -1), baseBrush);
1382 
1383  painter->setPen(QPen(baseBrush, 0));
1384  const QLine lines[4] = {
1385  QLine(filledRect.left(), filledRect.top() + 1,
1386  filledRect.left(), filledRect.bottom() - 1),
1387  QLine(filledRect.right(), filledRect.top() + 1,
1388  filledRect.right(), filledRect.bottom() - 1),
1389  QLine(filledRect.left() + 1, filledRect.top(),
1390  filledRect.right() - 1, filledRect.top()),
1391  QLine(filledRect.left() + 1, filledRect.bottom(),
1392  filledRect.right() - 1, filledRect.bottom()) };
1393  painter->drawLines(lines, 4);
1394 
1395  if (lineEdit->lineWidth != 0)
1396  qt_plastique_draw_frame(painter, option->rect, option, QFrame::Sunken);
1397 
1398  painter->restore();
1399  break;
1400  }
1401 #endif // QT_NO_LINEEDIT
1402  case PE_FrameDockWidget:
1403  case PE_FrameMenu:
1404  case PE_FrameStatusBarItem: {
1405  // Draws the frame around a popup menu.
1406  QPen oldPen = painter->pen();
1407  painter->setPen(borderColor);
1408  painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
1409  painter->setPen(alphaCornerColor);
1410  const QPoint points[4] = {
1411  QPoint(option->rect.topLeft()),
1412  QPoint(option->rect.topRight()),
1413  QPoint(option->rect.bottomLeft()),
1414  QPoint(option->rect.bottomRight()) };
1415  painter->drawPoints(points, 4);
1416  painter->setPen(oldPen);
1417  break;
1418  }
1419 #ifdef QT3_SUPPORT
1420  case PE_Q3DockWindowSeparator: {
1421  QPen oldPen = painter->pen();
1422  painter->setPen(alphaCornerColor);
1423  QRect rect = option->rect;
1424  if (option->state & State_Horizontal) {
1425  painter->drawLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 1);
1426  } else {
1427  painter->drawLine(rect.left() + 2, rect.bottom(), rect.right() - 1, rect.bottom());
1428  }
1429  painter->setPen(oldPen);
1430  break;
1431  }
1432  case PE_Q3Separator: {
1433  QPen oldPen = painter->pen();
1434  painter->setPen(alphaCornerColor);
1435  if ((option->state & State_Horizontal) == 0)
1436  painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1437  else
1438  painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
1439  painter->setPen(option->palette.background().color().lighter(104));
1440  if ((option->state & State_Horizontal) == 0)
1441  painter->drawLine(option->rect.topLeft(), option->rect.topRight());
1442  else
1443  painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
1444  painter->setPen(oldPen);
1445  break;
1446  }
1447 #endif // QT3_SUPPORT
1448 #ifndef QT_NO_MAINWINDOW
1449  case PE_PanelMenuBar:
1450  if ((widget && qobject_cast<const QMainWindow *>(widget->parentWidget()))
1451 #ifdef QT3_SUPPORT
1452  || (widget && widget->parentWidget() && widget->parentWidget()->inherits("Q3MainWindow"))
1453 #endif
1454  ) {
1455  // Draws the light line above and the dark line below menu bars and
1456  // tool bars.
1457  QPen oldPen = painter->pen();
1458  if (element == PE_PanelMenuBar || (option->state & State_Horizontal)) {
1459  painter->setPen(alphaCornerColor);
1460  painter->drawLine(option->rect.left(), option->rect.bottom(),
1461  option->rect.right(), option->rect.bottom());
1462  painter->setPen(option->palette.background().color().lighter(104));
1463  painter->drawLine(option->rect.left(), option->rect.top(),
1464  option->rect.right(), option->rect.top());
1465  } else {
1466  painter->setPen(option->palette.background().color().lighter(104));
1467  painter->drawLine(option->rect.left(), option->rect.top(),
1468  option->rect.left(), option->rect.bottom());
1469  painter->setPen(alphaCornerColor);
1470  painter->drawLine(option->rect.right(), option->rect.top(),
1471  option->rect.right(), option->rect.bottom());
1472  }
1473  painter->setPen(oldPen);
1474  }
1475  break;
1476 #endif // QT_NO_MAINWINDOW
1477  case PE_IndicatorHeaderArrow: {
1478  bool usedAntialiasing = painter->renderHints() & QPainter::Antialiasing;
1479  if (!usedAntialiasing)
1481  QWindowsStyle::drawPrimitive(element, option, painter, widget);
1482  if (!usedAntialiasing)
1483  painter->setRenderHint(QPainter::Antialiasing, false);
1484  break;
1485  }
1486  case PE_PanelButtonTool:
1487  // Draws a tool button (f.ex., in QToolBar and QTabBar)
1488  if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise))
1489  qt_plastique_drawShadedPanel(painter, option, true, widget);
1490  break;
1491 #ifndef QT_NO_TOOLBAR
1493  QPixmap cache;
1494  QRect rect = option->rect;
1495 #ifdef QT3_SUPPORT
1496  if (widget && widget->inherits("Q3DockWindowHandle") && widget->parentWidget()->inherits("Q3DockWindow")) {
1497  if (!(option->state & State_Horizontal))
1498  rect.adjust(2, 0, -2, 0);
1499  }
1500 #endif
1501  QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size());
1502  if (!QPixmapCache::find(pixmapName, cache)) {
1503  cache = QPixmap(rect.size());
1504  cache.fill(Qt::transparent);
1505  QPainter cachePainter(&cache);
1506  QRect cacheRect(QPoint(0, 0), rect.size());
1507  if (widget)
1508  cachePainter.fillRect(cacheRect, option->palette.brush(widget->backgroundRole()));
1509  else
1510  cachePainter.fillRect(cacheRect, option->palette.background());
1511 
1512  QImage handle(qt_toolbarhandle);
1513  alphaCornerColor.setAlpha(170);
1514  handle.setColor(1, alphaCornerColor.rgba());
1515  handle.setColor(2, mergedColors(alphaCornerColor, option->palette.light().color()).rgba());
1516  handle.setColor(3, option->palette.light().color().rgba());
1517 
1518  if (option->state & State_Horizontal) {
1519  int nchunks = cacheRect.height() / handle.height();
1520  int indent = (cacheRect.height() - (nchunks * handle.height())) / 2;
1521  for (int i = 0; i < nchunks; ++i)
1522  cachePainter.drawImage(QPoint(cacheRect.left() + 3, cacheRect.top() + indent + i * handle.height()),
1523  handle);
1524  } else {
1525  int nchunks = cacheRect.width() / handle.width();
1526  int indent = (cacheRect.width() - (nchunks * handle.width())) / 2;
1527  for (int i = 0; i < nchunks; ++i)
1528  cachePainter.drawImage(QPoint(cacheRect.left() + indent + i * handle.width(), cacheRect.top() + 3),
1529  handle);
1530  }
1531  cachePainter.end();
1532  QPixmapCache::insert(pixmapName, cache);
1533  }
1534  painter->drawPixmap(rect.topLeft(), cache);
1535  break;
1536  }
1538  QPen oldPen = painter->pen();
1539  painter->setPen(alphaCornerColor);
1540  if (option->state & State_Horizontal) {
1541  painter->drawLine(option->rect.left(), option->rect.top() + 1, option->rect.left(), option->rect.bottom() - 2);
1542  painter->setPen(option->palette.base().color());
1543  painter->drawLine(option->rect.right(), option->rect.top() + 1, option->rect.right(), option->rect.bottom() - 2);
1544  } else {
1545  painter->drawLine(option->rect.left() + 1, option->rect.top(), option->rect.right() - 2, option->rect.top());
1546  painter->setPen(option->palette.base().color());
1547  painter->drawLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 2, option->rect.bottom());
1548  }
1549  painter->setPen(oldPen);
1550  break;
1551  }
1552 #endif // QT_NO_TOOLBAR
1553  case PE_PanelButtonCommand:
1554  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1555  bool sunken = (button->state & State_Sunken) || (button->state & State_On);
1556  if ((button->features & QStyleOptionButton::Flat) && !sunken)
1557  break;
1558 
1559  bool defaultButton = (button->features & (QStyleOptionButton::DefaultButton
1561 
1562  BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(defaultButton))
1563 
1564  QPen oldPen = p->pen();
1565  bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver);
1566 
1567  // Give the painter a different brush origin for sunken buttons
1568  if (sunken) {
1569  // ### No such function
1570  // p->setPenOrigin(rect.left() + 1, rect.top() + 1);
1571  p->setBrushOrigin(rect.left() + 1, rect.top() + 1);
1572  }
1573 
1574  // Draw border
1575  qt_plastique_draw_frame(p, rect, option);
1576 
1577  // Fill the panel
1578  QRectF fillRect = rect.adjusted(2, 2, -2, -2);
1579 
1580  // Button colors
1581  QBrush alphaCornerBrush = qMapBrushToRect(qBrushDark(option->palette.button(), 165), rect);
1582  qBrushSetAlphaF(&alphaCornerBrush, 0.5);
1583  QBrush buttonGradientBrush;
1584  QBrush leftLineGradientBrush;
1585  QBrush rightLineGradientBrush;
1586  QBrush sunkenButtonGradientBrush;
1587  QBrush sunkenLeftLineGradientBrush;
1588  QBrush sunkenRightLineGradientBrush;
1589  QBrush buttonBrush = qMapBrushToRect(option->palette.button(), rect);
1590  if (buttonBrush.gradient() || !buttonBrush.texture().isNull()) {
1591  buttonGradientBrush = buttonBrush;
1592  sunkenButtonGradientBrush = qBrushDark(buttonBrush, 108);
1593  leftLineGradientBrush = qBrushLight(buttonBrush, 105);
1594  rightLineGradientBrush = qBrushDark(buttonBrush, 105);
1595  sunkenLeftLineGradientBrush = qBrushDark(buttonBrush, 110);
1596  sunkenRightLineGradientBrush = qBrushDark(buttonBrush, 106);
1597  } else {
1598  // Generate gradients
1599  QLinearGradient buttonGradient(rect.topLeft(), rect.bottomLeft());
1600  if (hover) {
1601  buttonGradient.setColorAt(0.0, mergedColors(option->palette.highlight().color(),
1602  buttonBrush.color().lighter(104), 6));
1603  buttonGradient.setColorAt(1.0, mergedColors(option->palette.highlight().color(),
1604  buttonBrush.color().darker(110), 6));
1605  } else {
1606  buttonGradient.setColorAt(0.0, buttonBrush.color().lighter(104));
1607  buttonGradient.setColorAt(1.0, buttonBrush.color().darker(110));
1608  }
1609  buttonGradientBrush = QBrush(buttonGradient);
1610 
1611  QLinearGradient buttonGradient2(rect.topLeft(), rect.bottomLeft());
1612  buttonGradient2.setColorAt(0.0, buttonBrush.color().darker(113));
1613  buttonGradient2.setColorAt(1.0, buttonBrush.color().darker(103));
1614  sunkenButtonGradientBrush = QBrush(buttonGradient2);
1615 
1616  QLinearGradient buttonGradient3(rect.topLeft(), rect.bottomLeft());
1617  buttonGradient3.setColorAt(0.0, buttonBrush.color().lighter(105));
1618  buttonGradient3.setColorAt(1.0, buttonBrush.color());
1619  leftLineGradientBrush = QBrush(buttonGradient3);
1620 
1621  QLinearGradient buttonGradient4(rect.topLeft(), rect.bottomLeft());
1622  buttonGradient4.setColorAt(0.0, buttonBrush.color());
1623  buttonGradient4.setColorAt(1.0, buttonBrush.color().darker(110));
1624  rightLineGradientBrush = QBrush(buttonGradient4);
1625 
1626  QLinearGradient buttonGradient5(rect.topLeft(), rect.bottomLeft());
1627  buttonGradient5.setColorAt(0.0, buttonBrush.color().darker(113));
1628  buttonGradient5.setColorAt(1.0, buttonBrush.color().darker(107));
1629  sunkenLeftLineGradientBrush = QBrush(buttonGradient5);
1630 
1631  QLinearGradient buttonGradient6(rect.topLeft(), rect.bottomLeft());
1632  buttonGradient6.setColorAt(0.0, buttonBrush.color().darker(108));
1633  buttonGradient6.setColorAt(1.0, buttonBrush.color().darker(103));
1634  sunkenRightLineGradientBrush = QBrush(buttonGradient6);
1635  }
1636 
1637  // Main fill
1638  p->fillRect(fillRect,
1639  qMapBrushToRect(sunken ? sunkenButtonGradientBrush
1640  : buttonGradientBrush, rect));
1641 
1642  // Top line
1643  p->setPen(QPen(qBrushLight(qMapBrushToRect(sunken ? sunkenButtonGradientBrush
1644  : buttonGradientBrush, rect), 105), 0));
1645  p->drawLine(QPointF(rect.left() + 2, rect.top() + 1),
1646  QPointF(rect.right() - 2, rect.top() + 1));
1647 
1648  // Bottom line
1649  p->setPen(QPen(qBrushDark(qMapBrushToRect(sunken ? sunkenButtonGradientBrush
1650  : buttonGradientBrush, rect), 105), 0));
1651  p->drawLine(QPointF(rect.left() + 2, rect.bottom() - 1),
1652  QPointF(rect.right() - 2, rect.bottom() - 1));
1653 
1654  // Left line
1655  p->setPen(QPen(qMapBrushToRect(sunken ? sunkenLeftLineGradientBrush
1656  : leftLineGradientBrush, rect), 1));
1657  p->drawLine(QPointF(rect.left() + 1, rect.top() + 2),
1658  QPointF(rect.left() + 1, rect.bottom() - 2));
1659 
1660  // Right line
1661  p->setPen(QPen(qMapBrushToRect(sunken ? sunkenRightLineGradientBrush
1662  : rightLineGradientBrush, rect), 1));
1663  p->drawLine(QPointF(rect.right() - 1, rect.top() + 2),
1664  QPointF(rect.right() - 1, rect.bottom() - 2));
1665 
1666  // Hovering
1667  if (hover && !sunken) {
1668  QBrush hover = qMapBrushToRect(option->palette.highlight(), rect);
1669  QBrush hoverOuter = hover;
1670  qBrushSetAlphaF(&hoverOuter, qreal(0.7));
1671 
1672  QLine lines[2];
1673 
1674  p->setPen(QPen(hoverOuter, 0));
1675  lines[0] = QLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1);
1676  lines[1] = QLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.bottom() - 1);
1677  p->drawLines(lines, 2);
1678 
1679  QBrush hoverInner = hover;
1680  qBrushSetAlphaF(&hoverInner, qreal(0.45));
1681  p->setPen(QPen(hoverInner, 0));
1682  lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.right() - 1, rect.top() + 2);
1683  lines[1] = QLine(rect.left() + 1, rect.bottom() - 2, rect.right() - 1, rect.bottom() - 2);
1684  p->drawLines(lines, 2);
1685 
1686  QBrush hoverSide = hover;
1687  qBrushSetAlphaF(&hoverSide, qreal(0.075));
1688  p->setPen(QPen(hoverSide, 0));
1689  lines[0] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
1690  lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
1691  p->drawLines(lines, 2);
1692  }
1693 
1694  p->setPen(oldPen);
1695 
1697  }
1698  break;
1699  case PE_IndicatorCheckBox:
1700  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1702 
1703  p->save();
1704 
1705  // Outline
1706  QBrush border = option->palette.shadow();
1707  qBrushSetAlphaF(&border, qreal(0.4));
1708  p->setPen(QPen(border, 0));
1709  const QLine lines[4] = {
1710  QLine(rect.left() + 1, rect.top(), rect.right() - 1, rect.top()),
1711  QLine(rect.left() + 1, rect.bottom(), rect.right() - 1, rect.bottom()),
1712  QLine(rect.left(), rect.top() + 1, rect.left(), rect.bottom() - 1),
1713  QLine(rect.right(), rect.top() + 1, rect.right(), rect.bottom() - 1) };
1714  p->drawLines(lines, 4);
1715 
1716  QBrush corner = option->palette.shadow();
1717  qBrushSetAlphaF(&corner, qreal(0.2));
1718  p->setPen(QPen(corner, 0));
1719  const QPoint points[4] = {
1720  rect.topLeft(), rect.topRight(),
1721  rect.bottomLeft(), rect.bottomRight() };
1722  p->drawPoints(points, 4);
1723 
1724  // Fill
1725  QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect);
1726  if (!baseBrush.gradient() && baseBrush.texture().isNull()) {
1727  QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom());
1728  gradient.setColorAt(0, baseBrush.color());
1729  gradient.setColorAt(1, baseBrush.color().darker(105));
1730  baseBrush = gradient;
1731  }
1732  p->fillRect(rect.adjusted(1, 1, -1, -1), baseBrush);
1733 
1734  // Hover
1735  if ((button->state & State_Enabled) && (button->state & State_MouseOver)) {
1736  QBrush pen = qMapBrushToRect(button->palette.highlight(), rect);
1737  qBrushSetAlphaF(&pen, qreal(0.8));
1738  p->setPen(QPen(pen, 0));
1739  p->drawRect(rect.adjusted(1, 1, -2, -2));
1740  qBrushSetAlphaF(&pen, 0.5);
1741  p->setPen(QPen(pen, 0));
1742  p->drawRect(rect.adjusted(2, 2, -3, -3));
1743 
1744  qBrushSetAlphaF(&pen, qreal(0.2));
1745  p->setBrush(pen);
1746  p->drawRect(rect.adjusted(2, 2, -3, -3));
1747  }
1748 
1749  // Indicator
1750  bool on = button->state & State_On;
1751  bool sunken = button->state & State_Sunken;
1752  bool unchanged = button->state & State_NoChange;
1753  bool enabled = button->state & State_Enabled;
1754  if (on || (enabled && sunken) || unchanged) {
1755  p->setRenderHint(QPainter::Antialiasing);
1756  QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect);
1757  if (sunken)
1758  qBrushSetAlphaF(&pointBrush, qreal(0.5));
1759  else if (unchanged)
1760  qBrushSetAlphaF(&pointBrush, qreal(0.3));
1761  p->setPen(QPen(pointBrush, 3));
1762  const QLine lines[2] = {
1763  QLine(rect.left() + 4, rect.top() + 4, rect.right() - 3, rect.bottom() - 3),
1764  QLine(rect.right() - 3, rect.top() + 4, rect.left() + 4, rect.bottom() - 3) };
1765  p->drawLines(lines, 2);
1766  }
1767 
1768  p->restore();
1770  }
1771  break;
1773  if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1774  BEGIN_STYLE_PIXMAPCACHE(QLatin1String("radiobutton"))
1775 
1776  p->save();
1777  p->setRenderHint(QPainter::Antialiasing);
1778 
1779  // The the filled ellipse
1780  QBrush border = qMapBrushToRect(option->palette.shadow(), rect);
1781  qBrushSetAlphaF(&border, qreal(0.51));
1782  p->setPen(QPen(border, 0));
1783 
1784  QBrush baseBrush = qMapBrushToRect(button->palette.base(), rect);
1785  if (!baseBrush.gradient() && baseBrush.texture().isNull()) {
1786  QLinearGradient gradient(rect.center().x(), rect.top(), rect.center().x(), rect.bottom());
1787  gradient.setColorAt(0, baseBrush.color());
1788  gradient.setColorAt(1, baseBrush.color().darker(105));
1789  baseBrush = gradient;
1790  }
1791  p->setBrush(baseBrush);
1792  p->drawEllipse(QRectF(rect).adjusted(1, 1, -1, -1));
1793 
1794  // Hover
1795  if ((button->state & State_Enabled) && (button->state & State_MouseOver)) {
1796  QBrush pen = qMapBrushToRect(button->palette.highlight(), rect);
1797  qBrushSetAlphaF(&pen, qreal(0.8));
1798  p->setPen(QPen(pen, 0));
1799  qBrushSetAlphaF(&pen, qreal(0.2));
1800  p->setBrush(pen);
1801  p->drawEllipse(QRectF(rect).adjusted(2, 2, -2, -2));
1802  }
1803 
1804  // Indicator
1805  bool on = button->state & State_On;
1806  bool sunken = button->state & State_Sunken;
1807  bool enabled = button->state & State_Enabled;
1808  if (on || (enabled && sunken)) {
1809  p->setPen(Qt::NoPen);
1810  QBrush pointBrush = qMapBrushToRect(button->palette.text(), rect);
1811  if (sunken)
1812  qBrushSetAlphaF(&pointBrush, 0.5);
1813  p->setBrush(pointBrush);
1814  p->drawEllipse(QRectF(rect).adjusted(3, 3, -3, -3));
1815  }
1816 
1817  p->restore();
1819  }
1820  break;
1821 #ifndef QT_NO_DOCKWIDGET
1823  if ((option->state & State_Enabled) && (option->state & State_MouseOver))
1824  painter->fillRect(option->rect, QColor(255, 255, 255, 128));
1825  if (option->state & State_Horizontal) {
1826  int width = option->rect.width() / 3;
1827  QRect rect(option->rect.center().x() - width / 2,
1828  option->rect.top() + (option->rect.height() / 2) - 1, width, 3);
1829  qt_plastique_draw_handle(painter, option, rect, Qt::Vertical, widget);
1830  } else {
1831  int height = option->rect.height() / 3;
1832  QRect rect(option->rect.left() + (option->rect.width() / 2 - 1),
1833  option->rect.center().y() - height / 2, 3, height);
1834  qt_plastique_draw_handle(painter, option, rect, Qt::Horizontal, widget);
1835  }
1836  break;
1837 #endif // QT_NO_DOCKWIDGET
1839  QStyleOptionButton button;
1840  button.QStyleOption::operator=(*option);
1841  button.state &= ~State_MouseOver;
1842  proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
1843  break;
1844  }
1845  case PE_FrameWindow: {
1846  painter->save();
1847  bool active = (option->state & State_Active);
1848  int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget);
1849 
1850  QPalette palette = option->palette;
1851  if (!active)
1853 
1854  // Frame and rounded corners
1855  painter->setPen(mergedColors(palette.highlight().color(), Qt::black, 50));
1856 
1857  QLine lines[3];
1858  QPoint points[4];
1859 
1860  // bottom border line
1861  lines[0] = QLine(option->rect.left() + 1, option->rect.bottom(), option->rect.right() - 1, option->rect.bottom());
1862 
1863  // bottom left and right side border lines
1864  lines[1] = QLine(option->rect.left(), titleBarStop, option->rect.left(), option->rect.bottom() - 1);
1865  lines[2] = QLine(option->rect.right(), titleBarStop, option->rect.right(), option->rect.bottom() - 1);
1866  painter->drawLines(lines, 3);
1867  points[0] = QPoint(option->rect.left() + 1, option->rect.bottom() - 1);
1868  points[1] = QPoint(option->rect.right() - 1, option->rect.bottom() - 1);
1869  painter->drawPoints(points, 2);
1870 
1871 #ifdef QT3_SUPPORT
1872  if (widget && widget->inherits("Q3DockWindow")) {
1873  // also draw the frame on the title bar
1874  lines[0] = QLine(option->rect.left() + 1, option->rect.top(),
1875  option->rect.right() - 1, option->rect.top());
1876  lines[1] = QLine(option->rect.left(), option->rect.top() + 1,
1877  option->rect.left(), titleBarStop);
1878  lines[2] = QLine(option->rect.right(), option->rect.top() + 1,
1879  option->rect.right(), titleBarStop);
1880  painter->drawLines(lines, 3);
1881  }
1882 #endif
1883 
1884  // alpha corners
1885  painter->setPen(mergedColors(palette.highlight().color(), palette.background().color(), 55));
1886  points[0] = QPoint(option->rect.left() + 2, option->rect.bottom() - 1);
1887  points[1] = QPoint(option->rect.left() + 1, option->rect.bottom() - 2);
1888  points[2] = QPoint(option->rect.right() - 2, option->rect.bottom() - 1);
1889  points[3] = QPoint(option->rect.right() - 1, option->rect.bottom() - 2);
1890  painter->drawPoints(points, 4);
1891 
1892 #ifdef QT3_SUPPORT
1893  if (widget && widget->inherits("Q3DockWindow")) {
1894  // also draw the frame on the title bar
1895  points[0] = option->rect.topLeft();
1896  points[1] = option->rect.topRight();
1897  painter->drawPoints(points, 2);
1898  }
1899 #endif
1900 
1901  // upper and lower left inner
1902  painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color()) : palette.background().color().darker(120));
1903  painter->drawLine(option->rect.left() + 1, titleBarStop, option->rect.left() + 1, option->rect.bottom() - 2);
1904 
1905 #ifdef QT3_SUPPORT
1906  if (widget && widget->inherits("Q3DockWindow")) {
1907  // also draw the frame on the title bar
1908  lines[0] = QLine(option->rect.left() + 1, option->rect.top() + 1,
1909  option->rect.left() + 1, titleBarStop);
1910  lines[1] = QLine(option->rect.right() - 1, option->rect.top() + 1,
1911  option->rect.right() - 1, titleBarStop);
1912  lines[2] = QLine(option->rect.left() + 1, option->rect.top() + 1,
1913  option->rect.right() - 1, option->rect.top() + 1);
1914  painter->drawLines(lines, 3);
1915  }
1916 #endif
1917 
1918  painter->setPen(active ? mergedColors(palette.highlight().color(), palette.background().color(), 57) : palette.background().color().darker(130));
1919  lines[0] = QLine(option->rect.right() - 1, titleBarStop, option->rect.right() - 1, option->rect.bottom() - 2);
1920  lines[1] = QLine(option->rect.left() + 1, option->rect.bottom() - 1, option->rect.right() - 1, option->rect.bottom() - 1);
1921  painter->drawLines(lines, 2);
1922 
1923  painter->restore();
1924  }
1925  break;
1926  case PE_IndicatorBranch: {
1927  int mid_h = option->rect.x() + option->rect.width() / 2;
1928  int mid_v = option->rect.y() + option->rect.height() / 2;
1929  int bef_h = mid_h;
1930  int bef_v = mid_v;
1931  int aft_h = mid_h;
1932  int aft_v = mid_v;
1933  QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
1934  if (option->state & State_Item) {
1935  if (option->direction == Qt::RightToLeft)
1936  painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
1937  else
1938  painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
1939  }
1940  if (option->state & State_Sibling)
1941  painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
1942  if (option->state & (State_Open | State_Children | State_Item | State_Sibling))
1943  painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
1944 
1945  if (option->state & State_Children) {
1946  painter->save();
1947  QPoint center = option->rect.center();
1948  // border
1949  QRect fullRect(center.x() - 4, center.y() - 4, 9, 9);
1950  painter->setPen(borderColor);
1951 
1952  const QLine lines[4] = {
1953  QLine(fullRect.left() + 1, fullRect.top(),
1954  fullRect.right() - 1, fullRect.top()),
1955  QLine(fullRect.left() + 1, fullRect.bottom(),
1956  fullRect.right() - 1, fullRect.bottom()),
1957  QLine(fullRect.left(), fullRect.top() + 1,
1958  fullRect.left(), fullRect.bottom() - 1),
1959  QLine(fullRect.right(), fullRect.top() + 1,
1960  fullRect.right(), fullRect.bottom() - 1) };
1961  painter->drawLines(lines, 4);
1962 
1963  // "antialiased" corners
1964  painter->setPen(alphaCornerColor);
1965  const QPoint points[4] = {
1966  fullRect.topLeft(),
1967  fullRect.topRight(),
1968  fullRect.bottomLeft(),
1969  fullRect.bottomRight() };
1970  painter->drawPoints(points, 4);
1971 
1972  // fill
1973  QRect adjustedRect = fullRect;
1974  QRect gradientRect(adjustedRect.left() + 1, adjustedRect.top() + 1,
1975  adjustedRect.right() - adjustedRect.left() - 1,
1976  adjustedRect.bottom() - adjustedRect.top() - 1);
1977  if (option->palette.base().style() == Qt::SolidPattern) {
1978  QColor baseGradientStartColor = option->palette.base().color().darker(101);
1979  QColor baseGradientStopColor = option->palette.base().color().darker(106);
1980  qt_plastique_draw_gradient(painter, gradientRect, baseGradientStartColor, baseGradientStopColor);
1981  } else {
1982  painter->fillRect(gradientRect, option->palette.base());
1983  }
1984  // draw "+" or "-"
1985  painter->setPen(alphaTextColor);
1986  painter->drawLine(center.x() - 2, center.y(), center.x() + 2, center.y());
1987  if (!(option->state & State_Open))
1988  painter->drawLine(center.x(), center.y() - 2, center.x(), center.y() + 2);
1989  painter->restore();
1990  }
1991  }
1992  break;
1993  default:
1994  QWindowsStyle::drawPrimitive(element, option, painter, widget);
1995  break;
1996  }
1997 }
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition: qstyle_p.h:76
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
const T * constData() const
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition: qpalette.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static QBrush qBrushDark(QBrush brush, int dark)
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
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
static QBrush qMapBrushToRect(const QBrush &brush, const QRectF &rect)
double qreal
Definition: qglobal.h:1193
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition: qbrush.cpp:1475
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
static void qt_plastique_drawShadedPanel(QPainter *painter, const QStyleOption *option, bool base, const QWidget *widget)
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
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 QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
QPoint p1() const
Returns the line&#39;s start point.
Definition: qline.h:132
static const char *const qt_toolbarhandle[]
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.
QPoint p2() const
Returns the line&#39;s end point.
Definition: qline.h:137
static C reverse(const C &l)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
#define END_STYLE_PIXMAPCACHE
Definition: qstyle_p.h:96
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition: qwidget.cpp:4677
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const
Reimplemented Function
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
static const uint base
Definition: qurl.cpp:268
void append(const T &t)
static void qt_plastique_draw_frame(QPainter *painter, const QRect &rect, const QStyleOption *option, QFrame::Shadow shadow=QFrame::Plain)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
static QPixmap * find(const QString &key)
void setCurrentColorGroup(ColorGroup cg)
Set the palette&#39;s current color group to cg.
Definition: qpalette.h:105
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
static QBrush qBrushLight(QBrush brush, int light)
Shadow
This enum type defines the types of shadow that are used to give a 3D effect to frames.
Definition: qframe.h:96
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
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 QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QStyleOptionFrame class is used to describe the parameters for drawing a frame.
Definition: qstyleoption.h:118
The QStyleOptionTabWidgetFrame class is used to describe the parameters for drawing the frame around ...
Definition: qstyleoption.h:175
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QStyleOptionTabBarBase class is used to describe the base of a tab bar, i.e.
Definition: qstyleoption.h:218
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QPoint topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:294
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
QPalette palette
the palette that should be used when painting the control
Definition: qstyleoption.h:92
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition: qpalette.h:139
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
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
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
Definition: qbrush.h:280
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static void qt_plastique_draw_handle(QPainter *painter, const QStyleOption *option, const QRect &rect, Qt::Orientation orientation, const QWidget *widget)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop)
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
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
The QStyleOptionFrameV2 class is used to describe the parameters necessary for drawing a frame in Qt ...
Definition: qstyleoption.h:134
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
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
static void qBrushSetAlphaF(QBrush *brush, qreal alpha)
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
const QBrush & button() const
Returns the button brush of the current color group.
Definition: qpalette.h:125
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition: qpalette.h:135
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
#define enabled
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
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
int size() const
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

◆ eventFilter()

bool QPlastiqueStyle::eventFilter ( QObject watched,
QEvent event 
)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 5929 of file qplastiquestyle.cpp.

5930 {
5931 #ifndef QT_NO_PROGRESSBAR
5933 
5934  switch (event->type()) {
5935  case QEvent::Show:
5936  if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched)) {
5937  d->bars.append(bar);
5938  if (d->bars.size() == 1) {
5939  Q_ASSERT(ProgressBarFps > 0);
5940  d->timer.start();
5941  d->progressBarAnimateTimer = startTimer(1000 / ProgressBarFps);
5942  }
5943  }
5944  break;
5945  case QEvent::Destroy:
5946  case QEvent::Hide:
5947  if(!d->bars.isEmpty()) {
5948  d->bars.removeAll(reinterpret_cast<QProgressBar*>(watched));
5949  if (d->bars.isEmpty()) {
5950  killTimer(d->progressBarAnimateTimer);
5951  d->progressBarAnimateTimer = 0;
5952  }
5953  }
5954  break;
5955 #if defined QPlastique_MaskButtons
5956  case QEvent::Resize:
5957  if (qobject_cast<QPushButton *>(watched) || qobject_cast<QToolButton *>(watched)) {
5958  QWidget *widget = qobject_cast<QWidget *>(watched);
5959  QRect rect = widget->rect();
5960  QRegion region(rect);
5961  region -= QRect(rect.left(), rect.top(), 2, 1);
5962  region -= QRect(rect.left(), rect.top() + 1, 1, 1);
5963  region -= QRect(rect.left(), rect.bottom(), 2, 1);
5964  region -= QRect(rect.left(), rect.bottom() - 1, 1, 1);
5965  region -= QRect(rect.right() - 1, rect.top(), 2, 1);
5966  region -= QRect(rect.right(), rect.top() + 1, 1, 1);
5967  region -= QRect(rect.right() - 1, rect.bottom(), 2, 1);
5968  region -= QRect(rect.right(), rect.bottom() - 1, 1, 1);
5969  widget->setMask(region);
5970  }
5971  break;
5972 #endif
5973  default:
5974  break;
5975  }
5976 #endif // QT_NO_PROGRESSBAR
5977 
5978  return QWindowsStyle::eventFilter(watched, event);
5979 }
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
QPointer< QWidget > widget
bool eventFilter(QObject *o, QEvent *e)
Reimplemented Function
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QProgressBar widget provides a horizontal or vertical progress bar.
Definition: qprogressbar.h:58
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setMask(const QBitmap &)
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible...
Definition: qwidget.cpp:13309
static const int ProgressBarFps
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE...
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

◆ hitTestComplexControl()

QStyle::SubControl QPlastiqueStyle::hitTestComplexControl ( ComplexControl  control,
const QStyleOptionComplex option,
const QPoint pos,
const QWidget widget = 0 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5449 of file qplastiquestyle.cpp.

5451 {
5452  SubControl ret = SC_None;
5453  switch (control) {
5454 #ifndef QT_NO_SCROLLBAR
5455  case CC_ScrollBar:
5456  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
5457  QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
5458  if (slider.contains(pos)) {
5459  ret = SC_ScrollBarSlider;
5460  break;
5461  }
5462 
5463  QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
5464  if (scrollBarAddLine.contains(pos)) {
5465  ret = SC_ScrollBarAddLine;
5466  break;
5467  }
5468 
5469  QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget);
5470  if (scrollBarSubPage.contains(pos)) {
5471  ret = SC_ScrollBarSubPage;
5472  break;
5473  }
5474 
5475  QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget);
5476  if (scrollBarAddPage.contains(pos)) {
5477  ret = SC_ScrollBarAddPage;
5478  break;
5479  }
5480 
5481  QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
5482  if (scrollBarSubLine.contains(pos)) {
5483  ret = SC_ScrollBarSubLine;
5484  break;
5485  }
5486  }
5487  break;
5488 #endif // QT_NO_SCROLLBAR
5489  default:
5490  break;
5491  }
5492 
5493  return ret != SC_None ? ret : QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
5494 }
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
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 contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=0) const
Reimplemented Function
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

◆ layoutSpacingImplementation

int QPlastiqueStyle::layoutSpacingImplementation ( QSizePolicy::ControlType  control1,
QSizePolicy::ControlType  control2,
Qt::Orientation  orientation,
const QStyleOption option = 0,
const QWidget widget = 0 
) const
protectedslot
Warning
This function is not part of the public interface.

Definition at line 5873 of file qplastiquestyle.cpp.

5878 {
5880 
5881  if (control2 == QSizePolicy::ButtonBox)
5882  return 11;
5883 
5884  if ((control1 | control2) & ButtonMask)
5885  return (orientation == Qt::Horizontal) ? 10 : 9;
5886 
5887  switch (CT2(control1, control2)) {
5888  case CT1(QSizePolicy::Label):
5889  case CT2(QSizePolicy::Label, QSizePolicy::DefaultType):
5890  case CT2(QSizePolicy::Label, QSizePolicy::CheckBox):
5891  case CT2(QSizePolicy::Label, QSizePolicy::ComboBox):
5892  case CT2(QSizePolicy::Label, QSizePolicy::LineEdit):
5893  case CT2(QSizePolicy::Label, QSizePolicy::RadioButton):
5894  case CT2(QSizePolicy::Label, QSizePolicy::Slider):
5895  case CT2(QSizePolicy::Label, QSizePolicy::SpinBox):
5896  case CT2(QSizePolicy::Label, QSizePolicy::ToolButton):
5897  return 5;
5899  case CT2(QSizePolicy::RadioButton, QSizePolicy::CheckBox):
5900  case CT1(QSizePolicy::CheckBox):
5901  if (orientation == Qt::Vertical)
5902  return 2;
5904  if (orientation == Qt::Vertical)
5905  return 1;
5906  }
5907 
5908  if (orientation == Qt::Horizontal
5909  && (control2 & (QSizePolicy::CheckBox | QSizePolicy::RadioButton)))
5910  return 8;
5911 
5912  if ((control1 | control2) & (QSizePolicy::Frame
5915  return 11;
5916  }
5917 
5918  if ((control1 | control2) & (QSizePolicy::Line | QSizePolicy::Slider
5921  return 7;
5922 
5923  return 6;
5924 }
if(void) toggleToolbarShown
Definition: qnamespace.h:54
return(isPopup||isToolTip)
#define CT1(c)
#define CT2(c1, c2)

◆ pixelMetric()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5499 of file qplastiquestyle.cpp.

Referenced by drawControl().

5500 {
5501  int ret = -1;
5502  switch (metric) {
5503  case PM_MenuVMargin:
5504  case PM_MenuHMargin:
5505  ret = 0;
5506  break;
5509  ret = 1;
5510  break;
5512  ret = 0;
5513  break;
5514 #ifndef QT_NO_SLIDER
5515  case PM_SliderThickness:
5516  ret = 15;
5517  break;
5518  case PM_SliderLength:
5520  ret = 11;
5521  break;
5523  ret = 5;
5524  break;
5526  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
5527  int size = 15;
5528  if (slider->tickPosition & QSlider::TicksBelow)
5529  ++size;
5530  if (slider->tickPosition & QSlider::TicksAbove)
5531  ++size;
5532  ret = size;
5533  break;
5534  }
5535 #endif // QT_NO_SLIDER
5536  case PM_ScrollBarExtent:
5537  ret = 16;
5538  break;
5539  case PM_ScrollBarSliderMin:
5540  ret = 26;
5541  break;
5543  ret = 1;
5544  break;
5545  case PM_MenuBarItemSpacing:
5546  ret = 3;
5547  break;
5548  case PM_MenuBarVMargin:
5549  ret = 2;
5550  break;
5551  case PM_MenuBarHMargin:
5552  ret = 0;
5553  break;
5554  case PM_MenuBarPanelWidth:
5555  ret = 1;
5556  break;
5558  ret = 9;
5559  break;
5561  ret = 2;
5562  break;
5563  case PM_ToolBarItemSpacing:
5564  ret = 1;
5565  break;
5566  case PM_ToolBarItemMargin:
5567  ret = 1;
5568  break;
5569  case PM_ToolBarFrameWidth:
5570  ret = 2;
5571  break;
5572  case PM_SplitterWidth:
5573  ret = 6;
5574  break;
5576  ret = 6;
5577  break;
5579  ret = 20;
5580  break;
5581  case PM_DefaultFrameWidth:
5582 #ifndef QT_NO_MENU
5583  if (qobject_cast<const QMenu *>(widget)) {
5584  ret = 1;
5585  break;
5586  }
5587 #endif
5588  ret = 2;
5589  break;
5591  ret = 4;
5592  break;
5593  case PM_TitleBarHeight:
5594 #ifdef QT3_SUPPORT
5595  if (widget && widget->inherits("Q3DockWindowTitleBar")) {
5596  // Q3DockWindow has smaller title bars than QDockWidget
5597  ret = qMax(widget->fontMetrics().height(), 20);
5598  } else
5599 #endif
5600  ret = qMax(widget ? widget->fontMetrics().height() :
5601  (option ? option->fontMetrics.height() : 0), 30);
5602  break;
5604  return -1;
5606  return 2;
5609  return -1; // rely on layoutHorizontalSpacing()
5610  case PM_LayoutLeftMargin:
5611  case PM_LayoutTopMargin:
5612  case PM_LayoutRightMargin:
5613  case PM_LayoutBottomMargin:
5614  {
5615  bool isWindow = false;
5616  if (option) {
5617  isWindow = (option->state & State_Window);
5618  } else if (widget) {
5619  isWindow = widget->isWindow();
5620  }
5621 
5622  if (isWindow) {
5623  ret = 11;
5624  } else {
5625  ret = 9;
5626  }
5627  }
5628  default:
5629  break;
5630  }
5631 
5632  return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget);
5633 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
QFontMetrics fontMetrics
the font metrics that should be used when drawing text in the control
Definition: qstyleoption.h:91
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
int pixelMetric(PixelMetric pm, const QStyleOption *option=0, const QWidget *widget=0) const
Reimplemented Function
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
int height() const
Returns the height of the font.

◆ polish() [1/3]

void QPlastiqueStyle::polish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5699 of file qplastiquestyle.cpp.

5700 {
5701  if (qobject_cast<QPushButton *>(widget)
5702 #ifndef QT_NO_COMBOBOX
5703  || qobject_cast<QComboBox *>(widget)
5704 #endif
5705 #ifndef QT_NO_SPINBOX
5706  || qobject_cast<QAbstractSpinBox *>(widget)
5707 #endif
5708  || qobject_cast<QCheckBox *>(widget)
5709 #ifndef QT_NO_GROUPBOX
5710  || qobject_cast<QGroupBox *>(widget)
5711 #endif
5712  || qobject_cast<QRadioButton *>(widget)
5713 #ifndef QT_NO_SPLITTER
5714  || qobject_cast<QSplitterHandle *>(widget)
5715 #endif
5716 #ifndef QT_NO_TABBAR
5717  || qobject_cast<QTabBar *>(widget)
5718 #endif
5719  ) {
5720  widget->setAttribute(Qt::WA_Hover);
5721  }
5722 
5723  if (widget->inherits("QWorkspaceTitleBar")
5724  || widget->inherits("QDockSeparator")
5725  || widget->inherits("QDockWidgetSeparator")
5726  || widget->inherits("Q3DockWindowResizeHandle")) {
5727  widget->setAttribute(Qt::WA_Hover);
5728  }
5729 
5730  if (false // to simplify the #ifdefs
5731 #ifndef QT_NO_MENUBAR
5732  || qobject_cast<QMenuBar *>(widget)
5733 #endif
5734 #ifdef QT3_SUPPORT
5735  || widget->inherits("Q3ToolBar")
5736 #endif
5737 #ifndef QT_NO_TOOLBAR
5739  || (widget && qobject_cast<QToolBar *>(widget->parent()))
5740 #endif
5741  ) {
5743  }
5744 
5745 #ifndef QT_NO_PROGRESSBAR
5746  if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget))
5747  widget->installEventFilter(this);
5748 #endif
5749 
5750 #if defined QPlastique_MaskButtons
5751  if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget))
5752  widget->installEventFilter(this);
5753 #endif
5754 }
#define QT_NO_GROUPBOX
QPointer< QWidget > widget
#define QT_NO_SPLITTER
#define QT_NO_MENUBAR
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static const bool AnimateBusyProgressBar
#define QT_NO_SPINBOX
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
#define QT_NO_COMBOBOX
#define QT_NO_TABBAR

◆ polish() [2/3]

void QPlastiqueStyle::polish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5824 of file qplastiquestyle.cpp.

5825 {
5826  QWindowsStyle::polish(app);
5827 }
void polish(QApplication *)
Reimplemented Function

◆ polish() [3/3]

void QPlastiqueStyle::polish ( QPalette pal)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5832 of file qplastiquestyle.cpp.

5833 {
5834  QWindowsStyle::polish(pal);
5835 #ifdef Q_WS_MAC
5837 #endif
5838 }
void polish(QApplication *)
Reimplemented Function
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206

◆ sizeFromContents()

QSize QPlastiqueStyle::sizeFromContents ( ContentsType  type,
const QStyleOption option,
const QSize size,
const QWidget widget 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 4955 of file qplastiquestyle.cpp.

4957 {
4958  QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
4959 
4960  switch (type) {
4961  case CT_RadioButton:
4962  ++newSize.rheight();
4963  ++newSize.rwidth();
4964  break;
4965 #ifndef QT_NO_SLIDER
4966  case CT_Slider:
4967  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
4968  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
4969  if (slider->tickPosition & QSlider::TicksBelow) {
4970  if (slider->orientation == Qt::Horizontal)
4971  newSize.rheight() += tickSize;
4972  else
4973  newSize.rwidth() += tickSize;
4974  }
4975  if (slider->tickPosition & QSlider::TicksAbove) {
4976  if (slider->orientation == Qt::Horizontal)
4977  newSize.rheight() += tickSize;
4978  else
4979  newSize.rwidth() += tickSize;
4980  }
4981  }
4982  break;
4983 #endif // QT_NO_SLIDER
4984 #ifndef QT_NO_SCROLLBAR
4985  case CT_ScrollBar:
4986  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
4987  int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
4988  int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget);
4989  if (scrollBar->orientation == Qt::Horizontal) {
4990  newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent);
4991  } else {
4992  newSize = QSize(scrollBarExtent, scrollBarExtent * 3 + scrollBarSliderMinimum);
4993  }
4994  }
4995  break;
4996 #endif // QT_NO_SCROLLBAR
4997 #ifndef QT_NO_SPINBOX
4998  case CT_SpinBox:
4999  // Make sure the size is odd
5000  newSize.setHeight(sizeFromContents(CT_LineEdit, option, size, widget).height());
5001  newSize.rheight() -= ((1 - newSize.rheight()) & 1);
5002  break;
5003 #endif
5004 #ifndef QT_NO_TOOLBUTTON
5005  case CT_ToolButton:
5006  newSize.rheight() += 3;
5007  newSize.rwidth() += 3;
5008  break;
5009 #endif
5010 #ifndef QT_NO_COMBOBOX
5011  case CT_ComboBox:
5012  newSize = sizeFromContents(CT_PushButton, option, size, widget);
5013  newSize.rwidth() += 30; // Make room for drop-down indicator
5014  newSize.rheight() += 4;
5015  break;
5016 #endif
5017  case CT_MenuItem:
5018  if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
5019  if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
5020  newSize.setHeight(menuItem->text.isEmpty() ? 2 : menuItem->fontMetrics.height());
5021  }
5022  break;
5023  case CT_MenuBarItem:
5024  newSize.setHeight(newSize.height());
5025  break;
5026  default:
5027  break;
5028  }
5029 
5030  return newSize;
5031 }
int type
Definition: qmetatype.cpp:239
The QStyleOptionMenuItem class is used to describe the parameter necessary for drawing a menu item...
Definition: qstyleoption.h:435
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
Reimplemented Function
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=0) const
Reimplemented Function
int & rheight()
Returns a reference to the height.
Definition: qsize.h:144
int height() const
Returns the height.
Definition: qsize.h:129
const QStyle * proxy() const
Definition: qstyle.cpp:2546
The QStyleOptionSlider class is used to describe the parameters needed for drawing a slider...
Definition: qstyleoption.h:701
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int & rwidth()
Returns a reference to the width.
Definition: qsize.h:141

◆ standardIconImplementation

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

Definition at line 5851 of file qplastiquestyle.cpp.

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

◆ standardPalette()

QPalette QPlastiqueStyle::standardPalette ( ) const
virtual

Reimplemented Function

Reimplemented from QStyle.

Definition at line 5638 of file qplastiquestyle.cpp.

5639 {
5640  QPalette palette;
5641 
5643  palette.setBrush(QPalette::Disabled, QPalette::Button, QColor(QRgb(0xffdddfe4)));
5644  palette.setBrush(QPalette::Disabled, QPalette::Light, QColor(QRgb(0xffffffff)));
5645  palette.setBrush(QPalette::Disabled, QPalette::Midlight, QColor(QRgb(0xffffffff)));
5646  palette.setBrush(QPalette::Disabled, QPalette::Dark, QColor(QRgb(0xff555555)));
5647  palette.setBrush(QPalette::Disabled, QPalette::Mid, QColor(QRgb(0xffc7c7c7)));
5648  palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(QRgb(0xffc7c7c7)));
5651  palette.setBrush(QPalette::Disabled, QPalette::Base, QColor(QRgb(0xffefefef)));
5653  palette.setBrush(QPalette::Disabled, QPalette::Window, QColor(QRgb(0xffefefef)));
5654  palette.setBrush(QPalette::Disabled, QPalette::Shadow, QColor(QRgb(0xff000000)));
5655  palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(QRgb(0xff567594)));
5657  palette.setBrush(QPalette::Disabled, QPalette::Link, QColor(QRgb(0xff0000ee)));
5659  palette.setBrush(QPalette::Active, QPalette::WindowText, QColor(QRgb(0xff000000)));
5660  palette.setBrush(QPalette::Active, QPalette::Button, QColor(QRgb(0xffdddfe4)));
5661  palette.setBrush(QPalette::Active, QPalette::Light, QColor(QRgb(0xffffffff)));
5662  palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(QRgb(0xffffffff)));
5663  palette.setBrush(QPalette::Active, QPalette::Dark, QColor(QRgb(0xff555555)));
5664  palette.setBrush(QPalette::Active, QPalette::Mid, QColor(QRgb(0xffc7c7c7)));
5665  palette.setBrush(QPalette::Active, QPalette::Text, QColor(QRgb(0xff000000)));
5666  palette.setBrush(QPalette::Active, QPalette::BrightText, QColor(QRgb(0xffffffff)));
5667  palette.setBrush(QPalette::Active, QPalette::ButtonText, QColor(QRgb(0xff000000)));
5668  palette.setBrush(QPalette::Active, QPalette::Base, QColor(QRgb(0xffffffff)));
5670  palette.setBrush(QPalette::Active, QPalette::Window, QColor(QRgb(0xffefefef)));
5671  palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(QRgb(0xff000000)));
5672  palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(QRgb(0xff678db2)));
5674  palette.setBrush(QPalette::Active, QPalette::Link, QColor(QRgb(0xff0000ee)));
5675  palette.setBrush(QPalette::Active, QPalette::LinkVisited, QColor(QRgb(0xff52188b)));
5677  palette.setBrush(QPalette::Inactive, QPalette::Button, QColor(QRgb(0xffdddfe4)));
5678  palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(QRgb(0xffffffff)));
5679  palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(QRgb(0xffffffff)));
5680  palette.setBrush(QPalette::Inactive, QPalette::Dark, QColor(QRgb(0xff555555)));
5681  palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(QRgb(0xffc7c7c7)));
5682  palette.setBrush(QPalette::Inactive, QPalette::Text, QColor(QRgb(0xff000000)));
5685  palette.setBrush(QPalette::Inactive, QPalette::Base, QColor(QRgb(0xffffffff)));
5687  palette.setBrush(QPalette::Inactive, QPalette::Window, QColor(QRgb(0xffefefef)));
5688  palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(QRgb(0xff000000)));
5689  palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(QRgb(0xff678db2)));
5691  palette.setBrush(QPalette::Inactive, QPalette::Link, QColor(QRgb(0xff0000ee)));
5693  return palette;
5694 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
unsigned int QRgb
Definition: qrgb.h:53
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
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette...
Definition: qpalette.h:206
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ standardPixmap()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5860 of file qplastiquestyle.cpp.

Referenced by drawComplexControl().

5862 {
5863  return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
5864 }
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function

◆ styleHint()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5363 of file qplastiquestyle.cpp.

Referenced by drawComplexControl(), and drawControl().

5365 {
5366  int ret = 0;
5367  switch (hint) {
5368  case SH_WindowFrame_Mask:
5369  ret = 1;
5370  if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
5371  mask->region = option->rect;
5372  mask->region -= QRect(option->rect.left(), option->rect.top(), 2, 1);
5373  mask->region -= QRect(option->rect.right() - 1, option->rect.top(), 2, 1);
5374  mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 1, 1);
5375  mask->region -= QRect(option->rect.right(), option->rect.top() + 1, 1, 1);
5376 
5377  const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option);
5378  if (titleBar && (titleBar->titleBarState & Qt::WindowMinimized)) {
5379  mask->region -= QRect(option->rect.left(), option->rect.bottom(), 2, 1);
5380  mask->region -= QRect(option->rect.right() - 1, option->rect.bottom(), 2, 1);
5381  mask->region -= QRect(option->rect.left(), option->rect.bottom() - 1, 1, 1);
5382  mask->region -= QRect(option->rect.right(), option->rect.bottom() - 1, 1, 1);
5383  } else {
5384  mask->region -= QRect(option->rect.bottomLeft(), QSize(1, 1));
5385  mask->region -= QRect(option->rect.bottomRight(), QSize(1, 1));
5386  }
5387  }
5388  break;
5389  case SH_TitleBar_NoBorder:
5390  ret = 1;
5391  break;
5392  case SH_TitleBar_AutoRaise:
5393  ret = 1;
5394  break;
5396  ret = true;
5397  break;
5400  ret = true;
5401  break;
5403  ret = 0;
5404  break;
5407  break;
5410  break;
5412  ret = Qt::AlignLeft | Qt::AlignTop;
5413  break;
5415  ret = Qt::AlignRight;
5416  break;
5419  break;
5421  ret = QCommonStyle::styleHint(hint, option, widget, returnData);
5422  break;
5424  ret = true;
5425  break;
5427  ret = 96; // from Plastik
5428  break;
5429 #ifdef Q_WS_X11
5431  ret = true;
5432  break;
5433 #endif
5434 #ifndef Q_OS_WIN
5436  ret = false;
5437  break;
5438 #endif
5439  default:
5440  ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
5441  break;
5442  }
5443  return ret;
5444 }
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
int styleHint(StyleHint hint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const
Reimplemented Function
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int 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
T qstyleoption_cast(const QStyleOption *opt)
Definition: qstyleoption.h:885
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
int styleHint(StyleHint sh, const QStyleOption *opt=0, const QWidget *w=0, QStyleHintReturn *shret=0) const
Reimplemented Function

◆ subControlRect()

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

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5060 of file qplastiquestyle.cpp.

Referenced by drawComplexControl().

5062 {
5063  QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
5064 
5065  switch (control) {
5066 #ifndef QT_NO_SLIDER
5067  case CC_Slider:
5068  if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
5069  int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
5070 
5071  switch (subControl) {
5072  case SC_SliderHandle:
5073  if (slider->orientation == Qt::Horizontal) {
5074  rect.setWidth(11);
5075  rect.setHeight(15);
5076  int centerY = slider->rect.center().y() - rect.height() / 2;
5077  if (slider->tickPosition & QSlider::TicksAbove)
5078  centerY += tickSize;
5079  if (slider->tickPosition & QSlider::TicksBelow)
5080  centerY -= tickSize;
5081  rect.moveTop(centerY);
5082  } else {
5083  rect.setWidth(15);
5084  rect.setHeight(11);
5085  int centerX = slider->rect.center().x() - rect.width() / 2;
5086  if (slider->tickPosition & QSlider::TicksAbove)
5087  centerX += tickSize;
5088  if (slider->tickPosition & QSlider::TicksBelow)
5089  centerX -= tickSize;
5090  rect.moveLeft(centerX);
5091  }
5092  break;
5093  case SC_SliderGroove: {
5094  QPoint grooveCenter = slider->rect.center();
5095  if (slider->orientation == Qt::Horizontal) {
5096  rect.setHeight(14);
5097  --grooveCenter.ry();
5098  if (slider->tickPosition & QSlider::TicksAbove)
5099  grooveCenter.ry() += tickSize;
5100  if (slider->tickPosition & QSlider::TicksBelow)
5101  grooveCenter.ry() -= tickSize;
5102  } else {
5103  rect.setWidth(14);
5104  --grooveCenter.rx();
5105  if (slider->tickPosition & QSlider::TicksAbove)
5106  grooveCenter.rx() += tickSize;
5107  if (slider->tickPosition & QSlider::TicksBelow)
5108  grooveCenter.rx() -= tickSize;
5109  }
5110  rect.moveCenter(grooveCenter);
5111  break;
5112  }
5113  default:
5114  break;
5115  }
5116  }
5117  break;
5118 #endif // QT_NO_SLIDER
5119 #ifndef QT_NO_SCROLLBAR
5120  case CC_ScrollBar:
5121  if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
5122  int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget);
5123  int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
5124  scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3);
5125  int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget);
5126  int sliderLength;
5127 
5128  // calculate slider length
5129  if (scrollBar->maximum != scrollBar->minimum) {
5130  uint valueRange = scrollBar->maximum - scrollBar->minimum;
5131  sliderLength = (scrollBar->pageStep * sliderMaxLength) / (valueRange + scrollBar->pageStep);
5132 
5133  if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
5134  sliderLength = sliderMinLength;
5135  if (sliderLength > sliderMaxLength)
5136  sliderLength = sliderMaxLength;
5137  } else {
5138  sliderLength = sliderMaxLength;
5139  }
5140 
5141  int sliderStart = scrollBarExtent + sliderPositionFromValue(scrollBar->minimum,
5142  scrollBar->maximum,
5143  scrollBar->sliderPosition,
5144  sliderMaxLength - sliderLength,
5145  scrollBar->upsideDown);
5146 
5147  QRect scrollBarRect = scrollBar->rect;
5148 
5149  switch (subControl) {
5150  case SC_ScrollBarSubLine: // top/left button
5151  if (scrollBar->orientation == Qt::Horizontal) {
5152  rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width() - scrollBarExtent, scrollBarRect.height());
5153  } else {
5154  rect.setRect(scrollBarRect.left(), scrollBarRect.top(), scrollBarRect.width(), scrollBarRect.height() - scrollBarExtent);
5155  }
5156  break;
5157  case SC_ScrollBarAddLine: // bottom/right button
5158  if (scrollBar->orientation == Qt::Horizontal) {
5159  rect.setRect(scrollBarRect.right() - (scrollBarExtent - 1), scrollBarRect.top(), scrollBarExtent, scrollBarRect.height());
5160  } else {
5161  rect.setRect(scrollBarRect.left(), scrollBarRect.bottom() - (scrollBarExtent - 1), scrollBarRect.width(), scrollBarExtent);
5162  }
5163  break;
5164  case SC_ScrollBarSubPage:
5165  if (scrollBar->orientation == Qt::Horizontal) {
5166  rect.setRect(scrollBarRect.left() + scrollBarExtent, scrollBarRect.top(),
5167  sliderStart - (scrollBarRect.left() + scrollBarExtent), scrollBarRect.height());
5168  } else {
5169  rect.setRect(scrollBarRect.left(), scrollBarRect.top() + scrollBarExtent,
5170  scrollBarRect.width(), sliderStart - (scrollBarRect.left() + scrollBarExtent));
5171  }
5172  break;
5173  case SC_ScrollBarAddPage:
5174  if (scrollBar->orientation == Qt::Horizontal)
5175  rect.setRect(sliderStart + sliderLength, 0,
5176  sliderMaxLength - sliderStart - sliderLength + scrollBarExtent, scrollBarRect.height());
5177  else
5178  rect.setRect(0, sliderStart + sliderLength,
5179  scrollBarRect.width(), sliderMaxLength - sliderStart - sliderLength + scrollBarExtent);
5180  break;
5181  case SC_ScrollBarGroove:
5182  if (scrollBar->orientation == Qt::Horizontal) {
5183  rect = scrollBarRect.adjusted(scrollBarExtent, 0, -2 * scrollBarExtent, 0);
5184  } else {
5185  rect = scrollBarRect.adjusted(0, scrollBarExtent, 0, -2 * scrollBarExtent);
5186  }
5187  break;
5188  case SC_ScrollBarSlider:
5189  if (scrollBar->orientation == Qt::Horizontal) {
5190  rect.setRect(sliderStart, 0, sliderLength, scrollBarRect.height());
5191  } else {
5192  rect.setRect(0, sliderStart, scrollBarRect.width(), sliderLength);
5193  }
5194  break;
5195  default:
5196  break;
5197  }
5198  rect = visualRect(scrollBar->direction, scrollBarRect, rect);
5199  }
5200  break;
5201 #endif // QT_NO_SCROLLBAR
5202 #ifndef QT_NO_SPINBOX
5203  case CC_SpinBox:
5204  if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
5205  int center = spinBox->rect.height() / 2;
5206  switch (subControl) {
5207  case SC_SpinBoxUp:
5208  if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons)
5209  return QRect();
5210  rect = visualRect(spinBox->direction, spinBox->rect, rect);
5211  rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top(), 17, center + 1);
5212  rect = visualRect(spinBox->direction, spinBox->rect, rect);
5213  break;
5214  case SC_SpinBoxDown:
5215  if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons)
5216  return QRect();
5217  rect = visualRect(spinBox->direction, spinBox->rect, rect);
5218  rect.setRect(spinBox->rect.right() - 16, spinBox->rect.top() + center, 17, spinBox->rect.height() - center);
5219  rect = visualRect(spinBox->direction, spinBox->rect, rect);
5220  break;
5221  case SC_SpinBoxEditField:
5222  if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
5223  rect = spinBox->rect.adjusted(0, 0, -16, 0);
5224  } else {
5225  rect = spinBox->rect;
5226  }
5228  rect = visualRect(spinBox->direction, spinBox->rect, rect);
5229  break;
5230  default:
5231  break;
5232  }
5233  }
5234  break;
5235 #endif // QT_NO_SPINBOX
5236 #ifndef QT_NO_COMBOBOX
5237  case CC_ComboBox:
5238  switch (subControl) {
5239  case SC_ComboBoxArrow:
5240  rect = visualRect(option->direction, option->rect, rect);
5241  rect.setRect(rect.right() - 17, rect.top() - 2,
5242  19, rect.height() + 4);
5243  rect = visualRect(option->direction, option->rect, rect);
5244  break;
5245  case SC_ComboBoxEditField: {
5246  if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
5247  int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
5248  rect = visualRect(option->direction, option->rect, rect);
5249 
5250  if (box->editable) {
5252  rect.setRight(rect.right() - 16); // Overlaps the combobox button by 2 pixels
5253  } else {
5254  rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
5255  option->rect.width() - 16 - 2 * frameWidth,
5256  option->rect.height() - 2 * frameWidth);
5257  rect.setLeft(rect.left() + 2);
5258  rect.setRight(rect.right() - 2);
5259  if (box->state & (State_Sunken | State_On))
5260  rect.translate(1, 1);
5261  }
5262  rect = visualRect(option->direction, option->rect, rect);
5263  }
5264  break;
5265  }
5266  default:
5267  break;
5268  }
5269  break;
5270 #endif // QT_NO_COMBOBOX
5271  case CC_TitleBar:
5272  if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
5273  SubControl sc = subControl;
5274  QRect &ret = rect;
5275  const int indent = 3;
5276  const int controlTopMargin = 4;
5277  const int controlBottomMargin = 3;
5278  const int controlWidthMargin = 1;
5279  const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin;
5280  const int delta = controlHeight + controlWidthMargin;
5281  int offset = 0;
5282 
5283  bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
5284  bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
5285 
5286  switch (sc) {
5287  case SC_TitleBarLabel:
5288  if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
5289  ret = tb->rect;
5290  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
5291  ret.adjust(delta, 0, -delta, 0);
5292  if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
5293  ret.adjust(0, 0, -delta, 0);
5294  if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
5295  ret.adjust(0, 0, -delta, 0);
5296  if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
5297  ret.adjust(0, 0, -delta, 0);
5298  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
5299  ret.adjust(0, 0, -delta, 0);
5300  ret.adjusted(indent, 0, -indent, 0);
5301  }
5302  break;
5304  if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
5305  offset += delta;
5306  case SC_TitleBarMinButton:
5307  if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
5308  offset += delta;
5309  else if (sc == SC_TitleBarMinButton)
5310  break;
5312  if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
5313  offset += delta;
5314  else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
5315  offset += delta;
5316  else if (sc == SC_TitleBarNormalButton)
5317  break;
5318  case SC_TitleBarMaxButton:
5319  if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
5320  offset += delta;
5321  else if (sc == SC_TitleBarMaxButton)
5322  break;
5324  if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
5325  offset += delta;
5326  else if (sc == SC_TitleBarShadeButton)
5327  break;
5329  if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
5330  offset += delta;
5331  else if (sc == SC_TitleBarUnshadeButton)
5332  break;
5334  if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
5335  offset += delta;
5336  else if (sc == SC_TitleBarCloseButton)
5337  break;
5338  ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
5339  controlHeight, controlHeight);
5340  break;
5341  case SC_TitleBarSysMenu:
5342  if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
5343  ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
5344  controlHeight, controlHeight);
5345  }
5346  break;
5347  default:
5348  break;
5349  }
5350  ret = visualRect(tb->direction, tb->rect, ret);
5351  }
5352  break;
5353  default:
5354  break;
5355  }
5356 
5357  return rect;
5358 }
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
void moveLeft(int pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:350
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
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
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
static const int blueFrameWidth
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
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
unsigned int uint
Definition: qglobal.h:996
void moveCenter(const QPoint &p)
Moves the rectangle, leaving the center point at the given position.
Definition: qrect.cpp:840
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
Definition: qstyle.cpp:2087
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
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 moveTop(int pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top edge at the given y coordinate.
Definition: qrect.h:353
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
#define INT_MAX
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=0) const
Reimplemented Function

◆ subElementRect()

QRect QPlastiqueStyle::subElementRect ( SubElement  element,
const QStyleOption option,
const QWidget widget 
) const
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5036 of file qplastiquestyle.cpp.

Referenced by drawComplexControl(), and drawControl().

5037 {
5038  QRect rect;
5039  switch (element) {
5041  rect = visualRect(option->direction, option->rect,
5042  QWindowsStyle::subElementRect(element, option, widget)).adjusted(0, 0, 1, 1);
5043  break;
5044 #ifndef QT_NO_PROGRESSBAR
5045  case SE_ProgressBarLabel:
5047  case SE_ProgressBarGroove:
5048  return option->rect;
5049 #endif // QT_NO_PROGRESSBAR
5050  default:
5051  return QWindowsStyle::subElementRect(element, option, widget);
5052  }
5053 
5054  return visualRect(option->direction, option->rect, rect);
5055 }
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 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
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
Definition: qstyleoption.h:89
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=0) const
Reimplemented Function
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ timerEvent()

void QPlastiqueStyle::timerEvent ( QTimerEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Definition at line 5984 of file qplastiquestyle.cpp.

5985 {
5986 #ifndef QT_NO_PROGRESSBAR
5988 
5989  if (event->timerId() == d->progressBarAnimateTimer) {
5990  Q_ASSERT(ProgressBarFps > 0);
5991  d->animateStep = d->timer.elapsed() / (1000 / ProgressBarFps);
5992  foreach (QProgressBar *bar, d->bars) {
5993  if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0))
5994  bar->update();
5995  }
5996  }
5997 #endif // QT_NO_PROGRESSBAR
5998  event->ignore();
5999 }
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
static const int ProgressBarFps
static const bool AnimateProgressBar
The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE...
int minimum
the progress bar&#39;s minimum value
Definition: qprogressbar.h:62

◆ unpolish() [1/2]

void QPlastiqueStyle::unpolish ( QWidget widget)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5759 of file qplastiquestyle.cpp.

5760 {
5761  if (qobject_cast<QPushButton *>(widget)
5762 #ifndef QT_NO_COMBOBOX
5763  || qobject_cast<QComboBox *>(widget)
5764 #endif
5765 #ifndef QT_NO_SPINBOX
5766  || qobject_cast<QAbstractSpinBox *>(widget)
5767 #endif
5768  || qobject_cast<QCheckBox *>(widget)
5769 #ifndef QT_NO_GROUPBOX
5770  || qobject_cast<QGroupBox *>(widget)
5771 #endif
5772 #ifndef QT_NO_SPLITTER
5773  || qobject_cast<QSplitterHandle *>(widget)
5774 #endif
5775 #ifndef QT_NO_TABBAR
5776  || qobject_cast<QTabBar *>(widget)
5777 #endif
5778  || qobject_cast<QRadioButton *>(widget)) {
5779  widget->setAttribute(Qt::WA_Hover, false);
5780  }
5781 
5782  if (widget->inherits("QWorkspaceTitleBar")
5783  || widget->inherits("QDockSeparator")
5784  || widget->inherits("QDockWidgetSeparator")
5785  || widget->inherits("Q3DockWindowResizeHandle")) {
5786  widget->setAttribute(Qt::WA_Hover, false);
5787  }
5788 
5789  if (false // to simplify the #ifdefs
5790 #ifndef QT_NO_MENUBAR
5791  || qobject_cast<QMenuBar *>(widget)
5792 #endif
5793 #ifndef QT_NO_TOOLBOX
5794  || qobject_cast<QToolBox *>(widget)
5795 #endif
5796 #ifdef QT3_SUPPORT
5797  || widget->inherits("Q3ToolBar")
5798 #endif
5799 #ifndef QT_NO_TOOLBAR
5801  || (widget && qobject_cast<QToolBar *>(widget->parent()))
5802 #endif
5803  ) {
5805  }
5806 
5807 #ifndef QT_NO_PROGRESSBAR
5808  if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget)) {
5810  widget->removeEventFilter(this);
5811  d->bars.removeAll(static_cast<QProgressBar*>(widget));
5812  }
5813 #endif
5814 
5815 #if defined QPlastique_MaskButtons
5816  if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget))
5817  widget->removeEventFilter(this);
5818 #endif
5819 }
double d
Definition: qnumeric_p.h:62
#define QT_NO_GROUPBOX
QPointer< QWidget > widget
#define QT_NO_SPLITTER
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
#define QT_NO_MENUBAR
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition: qwidget.cpp:4708
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
static const bool AnimateBusyProgressBar
#define QT_NO_SPINBOX
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
#define QT_NO_TOOLBOX
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE...
#define QT_NO_COMBOBOX
#define QT_NO_TABBAR

◆ unpolish() [2/2]

void QPlastiqueStyle::unpolish ( QApplication app)
virtual

Reimplemented Function

Reimplemented from QCommonStyle.

Definition at line 5843 of file qplastiquestyle.cpp.

5844 {
5846 }
void unpolish(QApplication *)
Reimplemented Function

Properties

◆ reserved

void* QPlastiqueStyle::reserved
private

Definition at line 110 of file qplastiquestyle.h.


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