diff options
Diffstat (limited to 'src/kernel/ntqstyle.h')
-rw-r--r-- | src/kernel/ntqstyle.h | 412 |
1 files changed, 392 insertions, 20 deletions
diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 0cacb8b20..c77ab6e47 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -42,6 +42,11 @@ #ifndef QT_H #include "ntqobject.h" +#include "ntqpixmap.h" +#include "ntqcolor.h" +#include "ntqiconset.h" +#include "ntqtabbar.h" +#include "ntqtoolbutton.h" #endif // QT_H @@ -58,26 +63,26 @@ class TQStyleOption { public: enum StyleOptionDefault { Default }; - TQStyleOption(StyleOptionDefault=Default) : def(TRUE) {} + TQStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. TQStyleOption(int in1) : - def(FALSE), i1(in1) {} + def(FALSE), tb(NULL), i1(in1) {} TQStyleOption(int in1, int in2) : - def(FALSE), i1(in1), i2(in2) {} + def(FALSE), tb(NULL), i1(in1), i2(in2) {} TQStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), i1(in1), i2(in2), i3(in3), i4(in4) {} - TQStyleOption(TQMenuItem* m) : def(FALSE), mi(m) {} - TQStyleOption(TQMenuItem* m, int in1) : def(FALSE), mi(m), i1(in1) {} - TQStyleOption(TQMenuItem* m, int in1, int in2) : def(FALSE), mi(m), i1(in1), i2(in2) {} - TQStyleOption(const TQColor& c) : def(FALSE), cl(&c) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4) {} + TQStyleOption(TQMenuItem* m) : def(FALSE), mi(m), tb(NULL) {} + TQStyleOption(TQMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1) {} + TQStyleOption(TQMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2) {} + TQStyleOption(const TQColor& c) : def(FALSE), tb(NULL), cl(&c) {} TQStyleOption(TQTab* t) : def(FALSE), tb(t) {} - TQStyleOption(TQListViewItem* i) : def(FALSE), li(i) {} - TQStyleOption(TQCheckListItem* i) : def(FALSE), cli(i) {} - TQStyleOption(TQt::ArrowType a) : def(FALSE), i1((int)a) {} - TQStyleOption(const TQRect& r) : def(FALSE), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} - TQStyleOption(TQWidget *w) : def(FALSE), p1((void*)w) {} + TQStyleOption(TQListViewItem* i) : def(FALSE), tb(NULL), li(i) {} + TQStyleOption(TQCheckListItem* i) : def(FALSE), tb(NULL), cli(i) {} + TQStyleOption(TQt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a) {} + TQStyleOption(const TQRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} + TQStyleOption(TQWidget *w) : def(FALSE), tb(NULL), p1((void*)w) {} bool isDefault() const { return def; } @@ -121,6 +126,138 @@ private: class TQStyleHintReturn; // not defined yet +typedef TQMap<TQ_UINT32, TQSize> DialogButtonSizeMap; +typedef TQMap<TQ_INT32, TQ_INT32> TabIdentifierIndexMap; + +class TQStyleControlElementPopupMenuData { + public: + // +}; + +class TQStyleControlElementTabBarData { + public: + int tabCount; + TQTabBar::Shape shape; + TabIdentifierIndexMap identIndexMap; +}; + +class TQStyleControlElementListViewData { + public: + bool rootDecorated; + int itemMargin; +}; + +class TQStyleControlElementSpinWidgetData { + public: + TQ_UINT32 buttonSymbols; + TQRect upRect; + TQRect downRect; + bool upEnabled; + bool downEnabled; +}; + +class TQStyleControlElementTitleBarData { + public: + bool hasWindow; + bool usesActiveColor; + int windowState; + TQString visibleText; +}; + +class TQStyleControlElementDockWidgetData { + public: + bool hasDockArea; + bool closeEnabled; + TQt::Orientation areaOrientation; +}; + +class TQStyleControlElementGenericWidgetData { + public: + TQStringList widgetObjectTypes; + bool allDataPopulated; + TQt::WFlags wflags; + TQPixmap bgPixmap; + TQBrush bgBrush; + TQColor bgColor; + TQPoint bgOffset; + TQt::BackgroundMode backgroundMode; + TQColor fgColor; + TQColorGroup colorGroup; + TQRect geometry; + TQRect rect; + TQPoint pos; + TQPixmap icon; + TQPalette palette; + TQFont font; +}; + +class TQStyleControlElementData { + public: + TQStringList widgetObjectTypes; + bool allDataPopulated; + TQt::WFlags wflags; + TQPixmap bgPixmap; + TQBrush bgBrush; + TQColor bgColor; + TQPoint bgOffset; + TQt::BackgroundMode backgroundMode; + TQPixmap fgPixmap; + TQColor fgColor; + TQColorGroup colorGroup; + TQRect geometry; + TQRect rect; + TQPoint pos; + TQPixmap icon; + TQIconSet iconSet; + TQString text; + TQt::Orientation orientation; + TQColor activeItemPaletteBgColor; + TQPalette palette; + int totalSteps; + int currentStep; + TQ_UINT32 tickMarkSetting; + int tickInterval; + int minSteps; + int maxSteps; + int startStep; + int pageStep; + int lineStep; + int dlgVisibleButtons; + DialogButtonSizeMap dlgVisibleSizeHints; + TQString progressText; + TQString textLabel; + TQFont font; + int percentageVisible; + TQStyleControlElementDockWidgetData dwData; + TQToolButton::TextPosition toolButtonTextPosition; + int popupDelay; + TQStyleControlElementTitleBarData titleBarData; + TQStyleControlElementSpinWidgetData spinWidgetData; + TQStyleControlElementGenericWidgetData parentWidgetData; + TQStyleControlElementGenericWidgetData viewportData; + TQStyleControlElementListViewData listViewData; + TQStyleControlElementTabBarData tabBarData; + TQ_UINT32 comboBoxLineEditFlags; + TQ_UINT32 frameStyle; + TQRect sliderRect; +}; + +class TQStyleWidgetActionRequestData { + public: + TQStyleWidgetActionRequestData(); + TQStyleWidgetActionRequestData(int metric1, int metric2=0); + TQStyleWidgetActionRequestData(TQPalette palette); + TQStyleWidgetActionRequestData(TQFont font); + TQStyleWidgetActionRequestData(TQRect rect); + ~TQStyleWidgetActionRequestData(); + public: + int metric1; + int metric2; + TQPalette palette; + TQFont font; + TQRect rect; +}; + class Q_EXPORT TQStyle: public TQObject { TQ_OBJECT @@ -129,14 +266,64 @@ public: TQStyle(); virtual ~TQStyle(); + 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, + CEF_IsActiveWindow = 0x00200000, + CEF_IsTopLevel = 0x00400000, + CEF_IsVisible = 0x00800000, + }; + // New TQStyle API - most of these should probably be pure virtual + // Old API + // DEPRECATED virtual void polish( TQWidget * ); + + // New API + virtual void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void unPolish( TQWidget * ); + // New API + virtual void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void polish( TQApplication * ); + + // New API + virtual void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED virtual void unPolish( TQApplication * ); + // New API + virtual void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + virtual void polish( TQPalette & ); virtual void polishPopupMenu( TQPopupMenu* ) = 0; @@ -151,7 +338,6 @@ public: const TQPixmap *pixmap, const TQString &text, int len = -1, const TQColor *penColor = 0 ) const; - enum PrimitiveElement { PE_ButtonCommand, PE_ButtonDefault, @@ -252,8 +438,20 @@ public: }; typedef uint SFlags; + // Old API + // DEPRECATED + virtual void drawPrimitive( PrimitiveElement pe, + TQPainter *p, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default ) const = 0; + + // New API virtual void drawPrimitive( PrimitiveElement pe, TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, @@ -294,6 +492,8 @@ public: CE_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual void drawControl( ControlElement element, TQPainter *p, const TQWidget *widget, @@ -301,12 +501,35 @@ public: const TQColorGroup &cg, SFlags how = Style_Default, const TQStyleOption& = TQStyleOption::Default ) const = 0; + + // New API + virtual void drawControl( ControlElement element, + TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + + // Old API + // DEPRECATED virtual void drawControlMask( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& = TQStyleOption::Default ) const = 0; + // New API + virtual void drawControlMask( ControlElement element, + TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + enum SubRect { SR_PushButtonContents, SR_PushButtonFocusRect, @@ -347,8 +570,13 @@ public: SR_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual TQRect subRect( SubRect r, const TQWidget *widget ) const = 0; + // New API + virtual TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const = 0; + enum ComplexControl{ CC_SpinWidget, @@ -411,6 +639,8 @@ public: typedef uint SCFlags; + // Old API + // DEPRECATED virtual void drawComplexControl( ComplexControl control, TQPainter *p, const TQWidget *widget, @@ -424,21 +654,70 @@ public: #endif SCFlags subActive = SC_None, const TQStyleOption& = TQStyleOption::Default ) const = 0; + + virtual void drawComplexControl( ComplexControl control, + TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, +#ifdef Q_QDOC + SCFlags sub = SC_All, +#else + SCFlags sub = (uint)SC_All, +#endif + SCFlags subActive = SC_None, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual void drawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& = TQStyleOption::Default ) const = 0; + // New API + virtual void drawComplexControlMask( ComplexControl control, + TQPainter *p, + const TQStyleControlElementData ceData, + const ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual TQRect querySubControlMetrics( ComplexControl control, const TQWidget *widget, SubControl sc, const TQStyleOption& = TQStyleOption::Default ) const = 0; + + // New API + virtual TQRect querySubControlMetrics( ComplexControl control, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + SubControl sc, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED virtual SubControl querySubControl( ComplexControl control, const TQWidget *widget, const TQPoint &pos, const TQStyleOption& = TQStyleOption::Default ) const = 0; + // New API + virtual SubControl querySubControl( ComplexControl control, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQPoint &pos, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + enum PixelMetric { PM_ButtonMargin, @@ -508,7 +787,15 @@ public: PM_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED + virtual int pixelMetric( PixelMetric metric, + const TQWidget *widget = 0 ) const = 0; + + // New API virtual int pixelMetric( PixelMetric metric, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const = 0; @@ -536,11 +823,20 @@ public: CT_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual TQSize sizeFromContents( ContentsType contents, const TQWidget *widget, const TQSize &contentsSize, const TQStyleOption& = TQStyleOption::Default ) const = 0; + virtual TQSize sizeFromContents( ContentsType contents, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQSize &contentsSize, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + enum StyleHint { // ... // the general hints @@ -683,16 +979,30 @@ public: // when the mouse is over the button SH_ToolButton_Uses3D, + // bool - hide underlined accelerators uless Alt key is currently down + SH_HideUnderlineAcceleratorWhenAltUp, + // do not add any values below/greater than this SH_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual int styleHint( StyleHint stylehint, const TQWidget *widget = 0, const TQStyleOption& = TQStyleOption::Default, TQStyleHintReturn* returnData = 0 ) const = 0; + // New API + virtual int styleHint( StyleHint stylehint, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, + TQStyleHintReturn* returnData = 0, + const TQWidget *widget = 0 + ) const = 0; + enum StylePixmap { SP_TitleBarMinButton, @@ -711,39 +1021,86 @@ public: SP_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED virtual TQPixmap stylePixmap( StylePixmap stylepixmap, const TQWidget *widget = 0, const TQStyleOption& = TQStyleOption::Default ) const = 0; + virtual TQPixmap stylePixmap( StylePixmap stylepixmap, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED static TQRect visualRect( const TQRect &logical, const TQWidget *w ); + // New API + static TQRect visualRect( const TQRect &logical, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags ); + static TQRect visualRect( const TQRect &logical, const TQRect &bounding ); + // Object event handling API + typedef TQMap<void*, TQStyle*> ObjectEventSourceToHandlerMap; + typedef TQMap<void*, TQStyleControlElementData> ObjectEventSourceDataToHandlerMap; + typedef TQMap<void*, ControlElementFlags> ObjectEventSourceFlagsToHandlerMap; + typedef bool (*EventHandlerInstallationHook)(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); + typedef bool (*EventHandlerRemovalHook)(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); + void installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + void removeObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + void setEventHandlerInstallationHook( EventHandlerInstallationHook ); + void setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); + + enum WidgetActionRequest { + WAR_Repaint, + WAR_RepaintRect, + WAR_EnableMouseTracking, + WAR_DisableMouseTracking, + WAR_FrameSetStyle, + WAR_FrameSetLineWidth, + WAR_SetLayoutMargin, + WAR_SetPalette, + WAR_SetBackgroundMode, + WAR_SetFont, + WAR_RepaintAllAccelerators + }; + typedef bool (*WidgetActionRequestHook)(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData); + void setWidgetActionRequestHook( WidgetActionRequestHook ); + virtual bool widgetActionRequest( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData = TQStyleWidgetActionRequestData() ); // Old 2.x TQStyle API #ifndef QT_NO_COMPAT int defaultFrameWidth() const { - return pixelMetric( PM_DefaultFrameWidth ); + return pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ); } void tabbarMetrics( const TQWidget* 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, TQStyleControlElementData(), CEF_None, t ); + vf = pixelMetric( PM_TabBarTabVSpace, TQStyleControlElementData(), CEF_None, t ); + ov = pixelMetric( PM_TabBarBaseOverlap, TQStyleControlElementData(), CEF_None, t ); } TQSize scrollBarExtent() const { - return TQSize(pixelMetric(PM_ScrollBarExtent), - pixelMetric(PM_ScrollBarExtent)); + return TQSize(pixelMetric(PM_ScrollBarExtent, TQStyleControlElementData(), CEF_None), + pixelMetric(PM_ScrollBarExtent, TQStyleControlElementData(), CEF_None)); } #endif +public: + virtual bool eventFilter( TQObject *, TQEvent * ); + bool acceleratorsShown() const; + +protected: + void acceleratorKeypressEventMonitor( TQObject *, TQEvent * ); private: TQStylePrivate * d; @@ -752,7 +1109,22 @@ private: TQStyle( const TQStyle & ); TQStyle& operator=( const TQStyle & ); #endif + + EventHandlerInstallationHook m_eventHandlerInstallationHook; + EventHandlerRemovalHook m_eventHandlerRemovalHook; + WidgetActionRequestHook m_widgetActionRequestHook; + ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; + ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; + ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; + bool conditionalAcceleratorsEnabled; }; +inline TQStyle::ControlElementFlags operator|(const TQStyle::ControlElementFlags a, const TQStyle::ControlElementFlags b) { return static_cast<TQStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); } +// inline TQStyle::ControlElementFlags operator|=(TQStyle::ControlElementFlags &a, const TQStyle::ControlElementFlags b) { a = static_cast<TQStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; } + +Q_EXPORT TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT TQStringList getObjectTypeListForObject(const TQObject* object); + #endif // QT_NO_STYLE #endif // TQSTYLE_H |