diff options
Diffstat (limited to 'src/kernel/qstyle.h')
-rw-r--r-- | src/kernel/qstyle.h | 358 |
1 files changed, 339 insertions, 19 deletions
diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index 64152ed..9a10b7f 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -42,11 +42,19 @@ #ifndef QT_H #include "qobject.h" +#include "qpixmap.h" +#include "qcolor.h" +#include "qiconset.h" +#include "qtabbar.h" +#include "qtoolbutton.h" #endif // QT_H #ifndef QT_NO_STYLE +/* DEV ONLY */ +/* #define MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED 1 */ + class QPopupMenu; class QStylePrivate; class QMenuItem; @@ -58,26 +66,26 @@ class QStyleOption { public: enum StyleOptionDefault { Default }; - QStyleOption(StyleOptionDefault=Default) : def(TRUE) {} + QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. QStyleOption(int in1) : - def(FALSE), i1(in1) {} + def(FALSE), tb(NULL), i1(in1) {} QStyleOption(int in1, int in2) : - def(FALSE), i1(in1), i2(in2) {} + def(FALSE), tb(NULL), i1(in1), i2(in2) {} QStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), i1(in1), i2(in2), i3(in3), i4(in4) {} - QStyleOption(QMenuItem* m) : def(FALSE), mi(m) {} - QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), i1(in1) {} - QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), i1(in1), i2(in2) {} - QStyleOption(const QColor& c) : def(FALSE), cl(&c) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4) {} + QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL) {} + QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1) {} + QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2) {} + QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c) {} QStyleOption(QTab* t) : def(FALSE), tb(t) {} - QStyleOption(QListViewItem* i) : def(FALSE), li(i) {} - QStyleOption(QCheckListItem* i) : def(FALSE), cli(i) {} - QStyleOption(Qt::ArrowType a) : def(FALSE), i1((int)a) {} - QStyleOption(const QRect& r) : def(FALSE), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} - QStyleOption(QWidget *w) : def(FALSE), p1((void*)w) {} + QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i) {} + QStyleOption(QCheckListItem* i) : def(FALSE), tb(NULL), cli(i) {} + QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a) {} + QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} + QStyleOption(QWidget *w) : def(FALSE), tb(NULL), p1((void*)w) {} bool isDefault() const { return def; } @@ -121,6 +129,118 @@ private: class QStyleHintReturn; // not defined yet +typedef QMap<Q_UINT32, QSize> DialogButtonSizeMap; +typedef QMap<Q_INT32, Q_INT32> TabIdentifierIndexMap; + +class QStyleControlElementPopupMenuData { + public: + // +}; + +class QStyleControlElementTabBarData { + public: + int tabCount; + QTabBar::Shape shape; + TabIdentifierIndexMap identIndexMap; +}; + +class QStyleControlElementListViewData { + public: + bool rootDecorated; + int itemMargin; +}; + +class QStyleControlElementSpinWidgetData { + public: + Q_UINT32 buttonSymbols; + QRect upRect; + QRect downRect; + bool upEnabled; + bool downEnabled; +}; + +class QStyleControlElementTitleBarData { + public: + bool hasWindow; + bool usesActiveColor; + int windowState; + QString visibleText; +}; + +class QStyleControlElementDockWidgetData { + public: + bool hasDockArea; + bool closeEnabled; + Qt::Orientation areaOrientation; +}; + +class QStyleControlElementGenericWidgetData { + public: + QStringList widgetObjectTypes; + Qt::WFlags wflags; + QPixmap bgPixmap; + QBrush bgBrush; + QColor bgColor; + QPoint bgOffset; + Qt::BackgroundMode backgroundMode; + QColor fgColor; + QColorGroup colorGroup; + QRect geometry; + QRect rect; + QPoint pos; + QPixmap icon; + QPalette palette; + QFont font; +}; + +class QStyleControlElementData { + public: + QStringList widgetObjectTypes; + Qt::WFlags wflags; + QPixmap bgPixmap; + QBrush bgBrush; + QColor bgColor; + QPoint bgOffset; + Qt::BackgroundMode backgroundMode; + QPixmap fgPixmap; + QColor fgColor; + QColorGroup colorGroup; + QRect geometry; + QRect rect; + QPoint pos; + QPixmap icon; + QIconSet iconSet; + QString text; + Qt::Orientation orientation; + QColor activeItemPaletteBgColor; + QPalette palette; + int totalSteps; + int currentStep; + Q_UINT32 tickMarkSetting; + int tickInterval; + int minSteps; + int maxSteps; + int startStep; + int pageStep; + int lineStep; + int dlgVisibleButtons; + DialogButtonSizeMap dlgVisibleSizeHints; + QString progressText; + QString textLabel; + QFont font; + int percentageVisible; + QStyleControlElementDockWidgetData dwData; + QToolButton::TextPosition toolButtonTextPosition; + int popupDelay; + QStyleControlElementTitleBarData titleBarData; + QStyleControlElementSpinWidgetData spinWidgetData; + QStyleControlElementGenericWidgetData parentWidgetData; + QStyleControlElementGenericWidgetData viewportData; + QStyleControlElementListViewData listViewData; + QStyleControlElementTabBarData tabBarData; + Q_UINT32 comboBoxLineEditFlags; +}; + class Q_EXPORT QStyle: public QObject { Q_OBJECT @@ -151,6 +271,30 @@ public: const QPixmap *pixmap, const QString &text, int len = -1, const QColor *penColor = 0 ) const; + enum ControlElementFlags { + CEF_None = 0x00000000, + CEF_IsDefault = 0x00000001, + CEF_AutoDefault = 0x00000002, + CEF_IsActive = 0x00000004, + CEF_IsDown = 0x00000008, + CEF_IsOn = 0x00000010, + CEF_IsEnabled = 0x00000020, + CEF_BiState = 0x00000040, + CEF_HasFocus = 0x00000080, + CEF_IsMenuWidget = 0x00000100, + CEF_IsContainerEmpty = 0x00000200, + CEF_CenterIndicator = 0x00000400, + CEF_IndicatorFollowsStyle = 0x00000800, + CEF_UsesTextLabel = 0x00001000, + CEF_UsesBigPixmap = 0x00002000, + CEF_UseGenericParameters = 0x00004000, + CEF_HasParentWidget = 0x00008000, + CEF_HasPopupMenu = 0x00010000, + CEF_IsCheckable = 0x00020000, + CEF_HasFocusProxy = 0x00040000, + CEF_IsEditable = 0x00080000, + CEF_IsFlat = 0x00100000 + }; enum PrimitiveElement { PE_ButtonCommand, @@ -252,6 +396,11 @@ public: }; typedef uint SFlags; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual void drawPrimitive( PrimitiveElement pe, QPainter *p, const QRect &r, @@ -259,6 +408,16 @@ public: SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual void drawPrimitive( PrimitiveElement pe, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags flags = Style_Default, + const QStyleOption& = QStyleOption::Default ) const = 0; + enum ControlElement { CE_PushButton, @@ -294,6 +453,11 @@ public: CE_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual void drawControl( ControlElement element, QPainter *p, const QWidget *widget, @@ -301,12 +465,38 @@ public: const QColorGroup &cg, SFlags how = Style_Default, const QStyleOption& = QStyleOption::Default ) const = 0; + + // New API + virtual void drawControl( ControlElement element, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags how = Style_Default, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual void drawControlMask( ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual void drawControlMask( ControlElement element, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + enum SubRect { SR_PushButtonContents, SR_PushButtonFocusRect, @@ -347,8 +537,16 @@ public: SR_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual QRect subRect( SubRect r, const QWidget *widget ) const = 0; + // New API + virtual QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const = 0; + enum ComplexControl{ CC_SpinWidget, @@ -411,6 +609,11 @@ public: typedef uint SCFlags; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual void drawComplexControl( ComplexControl control, QPainter *p, const QWidget *widget, @@ -424,21 +627,79 @@ public: #endif SCFlags subActive = SC_None, const QStyleOption& = QStyleOption::Default ) const = 0; + + virtual void drawComplexControl( ComplexControl control, + QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QRect &r, + const QColorGroup &cg, + SFlags how = Style_Default, +#ifdef Q_QDOC + SCFlags sub = SC_All, +#else + SCFlags sub = (uint)SC_All, +#endif + SCFlags subActive = SC_None, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual void drawComplexControlMask( ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual void drawComplexControlMask( ComplexControl control, + QPainter *p, + const QStyleControlElementData ceData, + const ControlElementFlags elementFlags, + const QRect &r, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual QRect querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl sc, const QStyleOption& = QStyleOption::Default ) const = 0; + + // New API + virtual QRect querySubControlMetrics( ComplexControl control, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + SubControl sc, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual SubControl querySubControl( ComplexControl control, const QWidget *widget, const QPoint &pos, const QStyleOption& = QStyleOption::Default ) const = 0; + // New API + virtual SubControl querySubControl( ComplexControl control, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QPoint &pos, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + enum PixelMetric { PM_ButtonMargin, @@ -508,9 +769,20 @@ public: PM_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual int pixelMetric( PixelMetric metric, const QWidget *widget = 0 ) const = 0; + // New API + virtual int pixelMetric( PixelMetric metric, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QWidget *widget = 0 ) const = 0; + enum ContentsType { CT_PushButton, @@ -536,11 +808,23 @@ public: CT_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, const QStyleOption& = QStyleOption::Default ) const = 0; + virtual QSize sizeFromContents( ContentsType contents, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QSize &contentsSize, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + enum StyleHint { // ... // the general hints @@ -687,12 +971,26 @@ public: SH_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual int styleHint( StyleHint stylehint, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default, QStyleHintReturn* returnData = 0 ) const = 0; + // New API + virtual int styleHint( StyleHint stylehint, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QStyleOption& = QStyleOption::Default, + QStyleHintReturn* returnData = 0, + const QWidget *widget = 0 + ) const = 0; + enum StylePixmap { SP_TitleBarMinButton, @@ -711,13 +1009,32 @@ public: SP_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif virtual QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default ) const = 0; + virtual QPixmap stylePixmap( StylePixmap stylepixmap, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, + const QStyleOption& = QStyleOption::Default, + const QWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif static QRect visualRect( const QRect &logical, const QWidget *w ); + // New API + static QRect visualRect( const QRect &logical, const QStyleControlElementData ceData, const ControlElementFlags elementFlags ); + static QRect visualRect( const QRect &logical, const QRect &bounding ); @@ -728,19 +1045,19 @@ public: #ifndef QT_NO_COMPAT int defaultFrameWidth() const { - return pixelMetric( PM_DefaultFrameWidth ); + return pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ); } void tabbarMetrics( const QWidget* t, int& hf, int& vf, int& ov ) const { - hf = pixelMetric( PM_TabBarTabHSpace, t ); - vf = pixelMetric( PM_TabBarTabVSpace, t ); - ov = pixelMetric( PM_TabBarBaseOverlap, t ); + hf = pixelMetric( PM_TabBarTabHSpace, QStyleControlElementData(), CEF_None, t ); + vf = pixelMetric( PM_TabBarTabVSpace, QStyleControlElementData(), CEF_None, t ); + ov = pixelMetric( PM_TabBarBaseOverlap, QStyleControlElementData(), CEF_None, t ); } QSize scrollBarExtent() const { - return QSize(pixelMetric(PM_ScrollBarExtent), - pixelMetric(PM_ScrollBarExtent)); + return QSize(pixelMetric(PM_ScrollBarExtent, QStyleControlElementData(), CEF_None), + pixelMetric(PM_ScrollBarExtent, QStyleControlElementData(), CEF_None)); } #endif @@ -754,5 +1071,8 @@ private: #endif }; +inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a, const QStyle::ControlElementFlags b) { return static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); } +// inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; } + #endif // QT_NO_STYLE #endif // QSTYLE_H |