From c73edd8f63289c619c20a8e5d031a24d870c62ee Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 5 Aug 2012 01:01:34 -0500 Subject: Automated update from Qt3 --- src/kernel/ntqstyle.h | 358 ++++++++++++++++++++++++++++++++++++++++++++++--- src/kernel/ntqwidget.h | 6 +- src/kernel/qstyle.cpp | 143 +++++++++++++++----- 3 files changed, 453 insertions(+), 54 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 0cacb8b20..25ffd5778 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -42,11 +42,19 @@ #ifndef QT_H #include "ntqobject.h" +#include "ntqpixmap.h" +#include "ntqcolor.h" +#include "ntqiconset.h" +#include "ntqtabbar.h" +#include "ntqtoolbutton.h" #endif // QT_H #ifndef QT_NO_STYLE +/* DEV ONLY */ +/* #define MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED 1 */ + class TQPopupMenu; class TQStylePrivate; class TQMenuItem; @@ -58,26 +66,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 +129,118 @@ private: class TQStyleHintReturn; // not defined yet +typedef TQMap DialogButtonSizeMap; +typedef TQMap 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; + 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; + 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; +}; + class Q_EXPORT TQStyle: public TQObject { TQ_OBJECT @@ -151,6 +271,30 @@ public: const TQPixmap *pixmap, const TQString &text, int len = -1, const TQColor *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, TQPainter *p, const TQRect &r, @@ -259,6 +408,16 @@ public: 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, + const TQStyleOption& = TQStyleOption::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, TQPainter *p, const TQWidget *widget, @@ -301,12 +465,38 @@ 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 +537,16 @@ public: SR_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 +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, TQPainter *p, const TQWidget *widget, @@ -424,21 +627,79 @@ 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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,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 TQWidget *widget = 0 ) const = 0; + // New API + virtual int pixelMetric( PixelMetric metric, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQWidget *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 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 @@ -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 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,13 +1009,32 @@ public: SP_CustomBase = 0xf0000000 }; + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif 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 ); @@ -728,19 +1045,19 @@ public: #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 @@ -754,5 +1071,8 @@ private: #endif }; +inline TQStyle::ControlElementFlags operator|(const TQStyle::ControlElementFlags a, const TQStyle::ControlElementFlags b) { return static_cast(static_cast(a) | static_cast(b)); } +// inline TQStyle::ControlElementFlags operator|=(TQStyle::ControlElementFlags &a, const TQStyle::ControlElementFlags b) { a = static_cast(static_cast(a) | static_cast(b)); return a; } + #endif // QT_NO_STYLE #endif // TQSTYLE_H diff --git a/src/kernel/ntqwidget.h b/src/kernel/ntqwidget.h index 6529236a8..c4a288d4b 100644 --- a/src/kernel/ntqwidget.h +++ b/src/kernel/ntqwidget.h @@ -456,6 +456,9 @@ public: WState testWState( WState s ) const; WFlags testWFlags( WFlags f ) const; NFlags testNFlags( NFlags f ) const; + uint getWState() const; + WFlags getWFlags() const; + NFlags getNFlags() const; static TQWidget * find( WId ); static TQWidgetMapper *wmapper(); @@ -573,13 +576,10 @@ protected: bool destroyOldWindow = TRUE ); virtual void destroy( bool destroyWindow = TRUE, bool destroySubWindows = TRUE ); - uint getWState() const; virtual void setWState( uint ); void clearWState( uint n ); - WFlags getWFlags() const; virtual void setWFlags( WFlags ); void clearWFlags( WFlags n ); - NFlags getNFlags() const; virtual void setNFlags( NFlags ); void clearNFlags( NFlags n ); diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 25c9b1801..3a3a2775c 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -802,11 +802,14 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn void TQStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt) const + \fn void TQStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt) const Draws the style PrimitiveElement \a pe using the painter \a p in the area \a r. Colors are used from the color group \a cg. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in screen coordinates. The \a flags argument is used to control how the PrimitiveElement @@ -932,20 +935,25 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn void TQStyle::drawControl( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags how, const TQStyleOption& opt) const + \fn void TQStyle::drawControl( ControlElement element, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, const TQStyleOption& opt, const TQWidget *widget) const Draws the ControlElement \a element using the painter \a p in the area \a r. Colors are used from the color group \a cg. The rect \a r should be in screen coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a how argument is used to control how the ControlElement is drawn. Multiple flags can be OR'ed together. See the table below for an explanation of which flags are used with the various ControlElements. The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based + subclasses. Note that usage of the widget argument is deprecated + in favor of specifying widget parameters via \a ceData and \a elementFlags. + The widget can be cast to the appropriate type based on the value of \a element. The \a opt argument can be used to pass extra information required when drawing the ControlElement. Note that \a opt may be the default value even for ControlElements @@ -1086,14 +1094,19 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn void TQStyle::drawControlMask( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& opt) const + \fn void TQStyle::drawControlMask( ControlElement element, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const Draw a bitmask for the ControlElement \a element using the painter \a p in the area \a r. See drawControl() for an explanation of the use of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in screen coordinates. + \a widget is deprecated and should not be used. + \sa drawControl(), ControlElement */ @@ -1154,15 +1167,19 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn TQRect TQStyle::subRect( SubRect subrect, const TQWidget *widget ) const; + \fn TQRect TQStyle::subRect( SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; Returns the sub-area \a subrect for the \a widget in logical coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a subrect. See the table below for the - appropriate \a widget casts: + subclasses. Note that usage of \a widget is deprecated in favor + of \a ceData and \a elementFlags. The widget can be cast to the + appropriate type based on the value of \a subrect. See the table + below for the appropriate \a widget casts: \table \header \i SubRect \i Widget Cast @@ -1282,7 +1299,7 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn void TQStyle::drawComplexControl( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const TQStyleOption& opt ) const + \fn void TQStyle::drawComplexControl( ComplexControl control, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const TQStyleOption& opt, const TQWidget *widget ) const Draws the ComplexControl \a control using the painter \a p in the area \a r. Colors are used from the color group \a cg. The \a sub @@ -1295,6 +1312,9 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, coordinates into screen coordinates when using drawPrimitive() and drawControl(). + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a how argument is used to control how the ComplexControl is drawn. Multiple flags can OR'ed together. See the table below for an explanation of which flags are used with the various @@ -1302,11 +1322,13 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, The \a widget argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based - on the value of \a control. The \a opt argument can be used to - pass extra information required when drawing the ComplexControl. - Note that \a opt may be the default value even for ComplexControls - that can make use of the extra options. See the table below for - the appropriate \a widget and \a opt usage: + on the value of \a control. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags. The \a opt + argument can be used to pass extra information required when + drawing the ComplexControl. Note that \a opt may be the default + value even for ComplexControls that can make use of the extra + options. See the table below for the appropriate \a widget and + \a opt usage: \table \header \i ComplexControl
\& Widget Cast @@ -1375,26 +1397,34 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn void TQStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& opt) const + \fn void TQStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const Draw a bitmask for the ComplexControl \a control using the painter \a p in the area \a r. See drawComplexControl() for an explanation of the use of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The rect \a r should be in logical coordinates. Reimplementations of this function should use visualRect() to change the logical corrdinates into screen coordinates when using drawPrimitive() and drawControl(). + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl() ComplexControl */ /*! - \fn TQRect TQStyle::querySubControlMetrics( ComplexControl control, const TQWidget *widget, SubControl subcontrol, const TQStyleOption& opt = TQStyleOption::Default ) const; + \fn TQRect TQStyle::querySubControlMetrics( ComplexControl control, TQStyleControlElementData ceData, ControlElementFlags elementFlags, SubControl subcontrol, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; Returns the rect for the SubControl \a subcontrol for \a widget in logical coordinates. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \a control. The \a opt argument can be used to @@ -1403,11 +1433,13 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, that can make use of the extra options. See drawComplexControl() for an explanation of the \a widget and \a opt arguments. + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl(), ComplexControl, SubControl */ /*! - \fn SubControl TQStyle::querySubControl( ComplexControl control, const TQWidget *widget, const TQPoint &pos, const TQStyleOption& opt = TQStyleOption::Default ) const; + \fn SubControl TQStyle::querySubControl( ComplexControl control, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQPoint &pos, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; Returns the SubControl for \a widget at the point \a pos. The \a widget argument is a pointer to a TQWidget or one of its @@ -1418,11 +1450,16 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, that can make use of the extra options. See drawComplexControl() for an explanation of the \a widget and \a opt arguments. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + Note that \a pos is passed in screen coordinates. When using querySubControlMetrics() to check for hits and misses, use visualRect() to change the logical coordinates into screen coordinates. + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + \sa drawComplexControl(), ComplexControl, SubControl, querySubControlMetrics() */ @@ -1528,14 +1565,20 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn int TQStyle::pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const; + \fn int TQStyle::pixelMetric( PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; + + Returns the pixel metric for \a metric. - Returns the pixel metric for \a metric. The \a widget argument is - a pointer to a TQWidget or one of its subclasses. The widget can be - cast to the appropriate type based on the value of \a metric. Note - that \a widget may be zero even for PixelMetrics that can make use - of \a widget. See the table below for the appropriate \a widget - casts: + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a metric. Note that \a widget may be zero even + for PixelMetrics that can make use of \a widget. Note also that + usage of \a widget is deprecated in favor of \a ceData and + \a elementFlags. See the table below for the appropriate + \a widget casts: \table \header \i PixelMetric \i Widget Cast @@ -1584,18 +1627,22 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn TQSize TQStyle::sizeFromContents( ContentsType contents, const TQWidget *widget, const TQSize &contentsSize, const TQStyleOption& opt = TQStyleOption::Default ) const; + \fn TQSize TQStyle::sizeFromContents( ContentsType contents, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQSize &contentsSize, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; Returns the size of \a widget based on the contents size \a contentsSize. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a widget argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \a contents. The \a opt argument can be used to pass extra information required when calculating the size. Note that \a opt may be the default value even for ContentsTypes that - can make use of the extra options. See the table below for the - appropriate \a widget and \a opt usage: + can make use of the extra options. Note that usage of \a widget + is deprecated in favor of \a ceData and \a elementFlags. See the + table below for the appropriate \a widget and \a opt usage: \table \header \i ContentsType \i Widget Cast \i Options \i Notes @@ -1770,12 +1817,18 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn int TQStyle::styleHint( StyleHint stylehint, const TQWidget *widget = 0, const TQStyleOption &opt = TQStyleOption::Default, TQStyleHintReturn *returnData = 0 ) const; + \fn int TQStyle::styleHint( StyleHint stylehint, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt = TQStyleOption::Default, TQStyleHintReturn *returnData = 0, const TQWidget *widget = 0 ) const; Returns the style hint \a stylehint for \a widget. Currently, \a widget, \a opt, and \a returnData are unused; they're included to allow for future enhancements. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + Note that usage of \a widget is deprecated in favor of \a ceData + and \a elementFlags. + For an explanation of the return value see \l StyleHint. */ @@ -1811,10 +1864,13 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, */ /*! - \fn TQPixmap TQStyle::stylePixmap( StylePixmap stylepixmap, const TQWidget *widget = 0, const TQStyleOption& opt = TQStyleOption::Default ) const; + \fn TQPixmap TQStyle::stylePixmap( StylePixmap stylepixmap, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; Returns a pixmap for \a stylepixmap. + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + The \a opt argument can be used to pass extra information required when drawing the ControlElement. Note that \a opt may be the default value even for StylePixmaps that can make use of the extra @@ -1822,8 +1878,9 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, The \a widget argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based - on the value of \a stylepixmap. See the table below for the - appropriate \a widget casts: + on the value of \a stylepixmap. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags.See the table + below for the appropriate \a widget casts: \table \header \i StylePixmap \i Widget Cast @@ -1847,11 +1904,33 @@ void TQStyle::drawItem( TQPainter *p, const TQRect &r, function is provided to aid style implementors in supporting right-to-left mode. + Note that this function is deprecated in favor of visualRect( const TQRect &logical, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags ); + \sa TQApplication::reverseLayout() */ TQRect TQStyle::visualRect( const TQRect &logical, const TQWidget *w ) { - TQRect boundingRect = w->rect(); + TQStyleControlElementData ceData; + ceData.rect = w->rect(); + return visualRect(logical, ceData, CEF_None); +} + +/*! + \fn TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags ); + + Returns the rect \a logical in screen coordinates. The bounding + rect for the widget described by \a ceData and \a elementFlags + is used to perform the translation. This function is provided to + aid style implementors in supporting + right-to-left mode. + + \sa TQApplication::reverseLayout() +*/ +TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags ) +{ + Q_UNUSED(elementFlags) + + TQRect boundingRect = ceData.rect; TQRect r = logical; if ( TQApplication::reverseLayout() ) r.moveBy( 2*(boundingRect.right() - logical.right()) + -- cgit v1.2.1 From 74dac1c21d3ad1f446874fd29f7e670e77a196b5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 7 Aug 2012 01:32:24 -0500 Subject: Automated update from Qt3 --- src/kernel/ntqstyle.h | 152 +++++++++++++++++--- src/kernel/qstyle.cpp | 391 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 510 insertions(+), 33 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 25ffd5778..e2338fc49 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -177,6 +177,7 @@ class TQStyleControlElementDockWidgetData { class TQStyleControlElementGenericWidgetData { public: TQStringList widgetObjectTypes; + bool allDataPopulated; TQt::WFlags wflags; TQPixmap bgPixmap; TQBrush bgBrush; @@ -196,6 +197,7 @@ class TQStyleControlElementGenericWidgetData { class TQStyleControlElementData { public: TQStringList widgetObjectTypes; + bool allDataPopulated; TQt::WFlags wflags; TQPixmap bgPixmap; TQBrush bgBrush; @@ -239,6 +241,24 @@ class TQStyleControlElementData { 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 @@ -249,28 +269,6 @@ public: TQStyle(); virtual ~TQStyle(); - // New TQStyle API - most of these should probably be pure virtual - - virtual void polish( TQWidget * ); - virtual void unPolish( TQWidget * ); - - virtual void polish( TQApplication * ); - virtual void unPolish( TQApplication * ); - - virtual void polish( TQPalette & ); - - virtual void polishPopupMenu( TQPopupMenu* ) = 0; - - virtual TQRect itemRect( TQPainter *p, const TQRect &r, - int flags, bool enabled, - const TQPixmap *pixmap, - const TQString &text, int len = -1 ) const; - - virtual void drawItem( TQPainter *p, const TQRect &r, - int flags, const TQColorGroup &g, bool enabled, - const TQPixmap *pixmap, const TQString &text, - int len = -1, const TQColor *penColor = 0 ) const; - enum ControlElementFlags { CEF_None = 0x00000000, CEF_IsDefault = 0x00000001, @@ -293,9 +291,68 @@ public: CEF_IsCheckable = 0x00020000, CEF_HasFocusProxy = 0x00040000, CEF_IsEditable = 0x00080000, - CEF_IsFlat = 0x00100000 + 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 +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void polish( TQWidget * ); + + // New API + virtual void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void unPolish( TQWidget * ); + + // New API + virtual void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void polish( TQApplication * ); + + // New API + virtual void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED +#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED + __attribute__ ((deprecated)) +#endif + virtual void unPolish( TQApplication * ); + + // New API + virtual void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + + virtual void polish( TQPalette & ); + + virtual void polishPopupMenu( TQPopupMenu* ) = 0; + + virtual TQRect itemRect( TQPainter *p, const TQRect &r, + int flags, bool enabled, + const TQPixmap *pixmap, + const TQString &text, int len = -1 ) const; + + virtual void drawItem( TQPainter *p, const TQRect &r, + int flags, const TQColorGroup &g, bool enabled, + const TQPixmap *pixmap, const TQString &text, + int len = -1, const TQColor *penColor = 0 ) const; + enum PrimitiveElement { PE_ButtonCommand, PE_ButtonDefault, @@ -967,6 +1024,9 @@ 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 }; @@ -1038,7 +1098,35 @@ public: static TQRect visualRect( const TQRect &logical, const TQRect &bounding ); + // Object event handling API + typedef TQMap ObjectEventSourceToHandlerMap; + typedef TQMap ObjectEventSourceDataToHandlerMap; + typedef TQMap 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 @@ -1061,6 +1149,12 @@ public: } #endif +public: + virtual bool eventFilter( TQObject *, TQEvent * ); + bool acceleratorsShown() const; + +protected: + void acceleratorKeypressEventMonitor( TQObject *, TQEvent * ); private: TQStylePrivate * d; @@ -1069,10 +1163,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(static_cast(a) | static_cast(b)); } // inline TQStyle::ControlElementFlags operator|=(TQStyle::ControlElementFlags &a, const TQStyle::ControlElementFlags b) { a = static_cast(static_cast(a) | static_cast(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 diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 3a3a2775c..d100d5f1e 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -44,6 +44,10 @@ #include "ntqpainter.h" #include "ntqbitmap.h" #include "ntqpixmapcache.h" +#include "ntqframe.h" +#include "ntqlayout.h" +#include "ntqobjectlist.h" +#include "ntqwidgetlist.h" #include @@ -394,6 +398,10 @@ public: */ TQStyle::TQStyle() { + m_eventHandlerInstallationHook = NULL; + m_eventHandlerRemovalHook = NULL; + m_widgetActionRequestHook = NULL; + conditionalAcceleratorsEnabled = false; d = new TQStylePrivate; } @@ -414,8 +422,6 @@ TQStyle::~TQStyle() style. Current supported values are TQt::WindowsStyle and TQt::MotifStyle. */ - - /*! Initializes the appearance of a widget. @@ -439,8 +445,9 @@ TQStyle::~TQStyle() \sa unPolish() */ -void TQStyle::polish( TQWidget*) -{ +void TQStyle::polish( TQWidget *widget ) { + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + polish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); } /*! @@ -453,10 +460,62 @@ void TQStyle::polish( TQWidget*) \sa polish() */ -void TQStyle::unPolish( TQWidget*) -{ +void TQStyle::unPolish( TQWidget *widget ) { + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); +} + +/*! + Initializes the appearance of a widget. + + This function is called for every widget at some point after it + has been fully created but just \e before it is shown the very + first time. + + Reasonable actions in this function might be to install a widget + event handler for the style. An example of highly unreasonable + use would be setting the geometry! With TQt 3.0's style engine + you will rarely need to write your own polish(); instead reimplement + drawItem(), drawPrimitive(), etc. + + The \a objectTypes object may provide enough information to + allow class-specific customizations. But be careful not to + hard-code things too much because new TQStyle subclasses are + expected to work reasonably with all current and \e future + widgets. + + You may specify either a TQWidget pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void TQStyle::polish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + // Enable dynamic hide/show of accelerator shortcuts + TQWidget* widget = reinterpret_cast(ptr); + widget->installEventFilter(this); + } } +/*! + Undoes the initialization of a widget's appearance. + + This function is the counterpart to polish. It is called for every + polished widget when the style is dynamically changed. The former + style has to unpolish its settings before the new style can polish + them again. + + \sa polish() +*/ +void TQStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + // Disable dynamic hide/show of accelerator shortcuts + TQWidget* widget = reinterpret_cast(ptr); + widget->installEventFilter(this); + } +} /*! \overload @@ -464,8 +523,10 @@ void TQStyle::unPolish( TQWidget*) \sa unPolish() */ -void TQStyle::polish( TQApplication*) -{ +void TQStyle::polish( TQApplication *app ) { + TQStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, TQStyleOption()), app); } /*! @@ -475,8 +536,41 @@ void TQStyle::polish( TQApplication*) \sa polish() */ -void TQStyle::unPolish( TQApplication*) -{ +void TQStyle::unPolish( TQApplication *app ) { + TQStyleControlElementData ceData; + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, TQStyleOption()), app); +} + +/*! + \overload + Late initialization of the TQApplication object or other global application object. + + You may specify either a TQApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void TQStyle::applicationPolish( TQStyleControlElementData, ControlElementFlags, void * ) { + // +} + +/*! + \overload + + Undoes the application polish. + + You may specify either a TQApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa polish() +*/ +void TQStyle::applicationUnPolish( TQStyleControlElementData, ControlElementFlags, void * ) { + // } /*! @@ -1957,6 +2051,283 @@ TQRect TQStyle::visualRect( const TQRect &logical, const TQRect &boundingRect ) return r; } +/*! + \fn void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + + Intercepts events generated by \a source and sends them to \a handler via + the bool TQStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) virtual method. + + \sa void TQStyle::removeObjectEventHandler( TQObject* source, TQStyle* handler ) + \sa bool TQStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) +*/ +void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { + bool cbret = false; + if (m_eventHandlerInstallationHook) { + cbret = (*m_eventHandlerInstallationHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQObject")) { + TQObject* o = reinterpret_cast(source); + o->installEventFilter(this); + m_objectEventSourceToHandlerMap[source] = handler; + m_objectEventSourceDataToHandlerMap[source] = ceData; + m_objectEventSourceFlagsToHandlerMap[source] = elementFlags; + } + } +} + +/*! + \fn void TQStyle::removeObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + + Stops intercepting events generated by \a source. + + \sa void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::removeObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { + bool cbret = false; + if (m_eventHandlerRemovalHook) { + cbret = (*m_eventHandlerRemovalHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQObject")) { + TQObject* o = reinterpret_cast(source); + m_objectEventSourceToHandlerMap.remove(source); + m_objectEventSourceDataToHandlerMap.remove(source); + m_objectEventSourceFlagsToHandlerMap.remove(source); + o->removeEventFilter(this); + } + } +} + +/*! + \fn void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept request + is made via the TQStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ) { + m_eventHandlerInstallationHook = hook; +} + +/*! + \fn void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept deactivation request + is made via the TQStyle::removeObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::removeObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ) { + m_eventHandlerRemovalHook = hook; +} + +/*! + \fn bool TQStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); + + Override this virtual function to intercept events requested by a previous call to + TQStyle::installObjectEventHandler. + + \sa void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) + \sa void TQStyle::removeObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +bool TQStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { + Q_UNUSED(ceData); + Q_UNUSED(elementFlags); + Q_UNUSED(source); + Q_UNUSED(e); + return false; +} + +/*! + \fn bool TQStyle::eventFilter(TQObject *o, TQEvent *e); + \internal +*/ +bool TQStyle::eventFilter(TQObject *o, TQEvent *e) { + acceleratorKeypressEventMonitor(o, e); + + if (m_objectEventSourceToHandlerMap.contains(o)) { + TQStyle* handler = m_objectEventSourceToHandlerMap[o]; + TQStyleControlElementData ceData = m_objectEventSourceDataToHandlerMap[o]; + ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; + bool ret = handler->objectEventHandler(ceData, elementFlags, o, e); + if (ret) { + return ret; + } + else { + return TQObject::eventFilter(o, e); + } + } + else { + return TQObject::eventFilter(o, e); + } +} + +/*! + \fn void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new widget action request + is made via the TQStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::installObjectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ) { + m_widgetActionRequestHook = hook; +} + +/*! + \fn bool widgetActionRequestHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request ); + + Handles widget action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData ) { + bool cbret = false; + if (m_widgetActionRequestHook) { + cbret = (*m_widgetActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + TQWidget* widget = reinterpret_cast(source); + if (request == WAR_Repaint) { + widget->repaint(FALSE); + } + else if (request == WAR_RepaintRect) { + widget->repaint(requestData.rect, FALSE); + } + else if (request == WAR_EnableMouseTracking) { + widget->setMouseTracking(TRUE); + } + else if (request == WAR_DisableMouseTracking) { + widget->setMouseTracking(FALSE); + } + else if (request == WAR_FrameSetStyle) { + TQFrame* frame = dynamic_cast(widget); + if (frame) { + frame->setFrameStyle(requestData.metric1); + } + } + else if (request == WAR_FrameSetLineWidth) { + TQFrame* frame = dynamic_cast(widget); + if (frame) { + frame->setLineWidth(requestData.metric1); + } + } + else if (request == WAR_SetLayoutMargin) { + TQLayout* layout = widget->layout(); + if (layout) { + layout->setMargin(requestData.metric1); + } + } + else if (request == WAR_SetPalette) { + widget->setPalette(requestData.palette); + } + else if (request == WAR_SetBackgroundMode) { + widget->setBackgroundMode((TQt::BackgroundMode)requestData.metric1); + } + else if (request == WAR_SetFont) { + widget->setFont(requestData.font); + } + else if (request == WAR_RepaintAllAccelerators) { + TQWidgetList *list = TQApplication::topLevelWidgets(); + TQWidgetListIt it( *list ); + TQWidget * widget; + while ((widget=it.current()) != 0) { + ++it; + + TQObjectList *l = widget->queryList("TQWidget"); + TQObjectListIt it2( *l ); + TQWidget *w; + while ( (w = (TQWidget*)it2.current()) != 0 ) { + ++it2; + if (w->isTopLevel() || !w->isVisible() || w->style().styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, w)) { + l->removeRef(w); + } + } + + // Repaint all relevant widgets + it2.toFirst(); + while ( (w = (TQWidget*)it2.current()) != 0 ) { + ++it2; + w->repaint(FALSE); + } + delete l; + } + delete list; + } + return true; + } + } + return true; +} + +void TQStyle::acceleratorKeypressEventMonitor( TQObject *o, TQEvent *e ) { + // RAJA FIXME + // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the TQWindowsStyle::styleHint overridden method + // Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint + + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { + TQWidget *widget = dynamic_cast(o); + if (widget) { + switch(e->type()) { + case TQEvent::KeyPress: + if (((TQKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = true; + widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + case TQEvent::KeyRelease: + if (((TQKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = false; + widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + default: + break; + } + } + } + else { + conditionalAcceleratorsEnabled = false; + } +} + +bool TQStyle::acceleratorsShown() const { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { + return conditionalAcceleratorsEnabled; + } + else { + return true; + } +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData() { + // +} +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(int param1, int param2) { + metric1 = param1; + metric2 = param2; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPalette param) { + palette = param; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQFont param) { + font = param; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQRect param) { + rect = param; +} + +TQStyleWidgetActionRequestData::~TQStyleWidgetActionRequestData() { + // +} + /*! \fn int TQStyle::defaultFrameWidth() const \obsolete -- cgit v1.2.1 From 9e79d29898cbd4338491b4981a3e75a0f2bb8d81 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 7 Aug 2012 01:35:48 -0500 Subject: Automated update from Qt3 --- src/kernel/qstyle.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index d100d5f1e..26fbf0cb8 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -2265,10 +2265,6 @@ bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElem } void TQStyle::acceleratorKeypressEventMonitor( TQObject *o, TQEvent *e ) { - // RAJA FIXME - // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the TQWindowsStyle::styleHint overridden method - // Additionally, the common styleHint code in TDE (that controls popupmenu settings and such via configuration files) needs to be modified to add a config option for this new style hint - if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { TQWidget *widget = dynamic_cast(o); if (widget) { -- cgit v1.2.1 From 85b69937a320d0f7fdb4fd7703cfe41e92d6a67b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 7 Aug 2012 14:22:21 -0500 Subject: Automated update from Qt3 --- src/kernel/qapplication_x11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index abf1e9538..03e7a7794 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -2147,7 +2147,7 @@ void tqt_init_internal( int *argcptr, char **argv, for (i = 0; i < map->max_keypermod; i++) { if (map->modifiermap[mapIndex]) { KeySym sym = - XKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0); + XkbKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], 0, 0); if ( qt_alt_mask == 0 && ( sym == XK_Alt_L || sym == XK_Alt_R ) ) { qt_alt_mask = 1 << maskIndex; @@ -2177,7 +2177,7 @@ void tqt_init_internal( int *argcptr, char **argv, for ( i = 0; i < map->max_keypermod; i++ ) { if ( map->modifiermap[ mapIndex ] ) { KeySym sym = - XKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0 ); + XkbKeycodeToKeysym( appDpy, map->modifiermap[ mapIndex ], 0, 0 ); if ( sym == XK_Mode_switch ) { qt_mode_switch_remove_mask |= 1 << maskIndex; } -- cgit v1.2.1 From 605772f9f09b53568cdf7b8b10b326b32594f93d Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 8 Aug 2012 01:46:33 -0500 Subject: Automated update from Qt3 --- src/kernel/ntqstyle.h | 54 --------------------------------------------------- 1 file changed, 54 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index e2338fc49..c77ab6e47 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -52,9 +52,6 @@ #ifndef QT_NO_STYLE -/* DEV ONLY */ -/* #define MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED 1 */ - class TQPopupMenu; class TQStylePrivate; class TQMenuItem; @@ -301,9 +298,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void polish( TQWidget * ); // New API @@ -311,9 +305,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void unPolish( TQWidget * ); // New API @@ -321,9 +312,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void polish( TQApplication * ); // New API @@ -331,9 +319,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void unPolish( TQApplication * ); // New API @@ -455,9 +440,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void drawPrimitive( PrimitiveElement pe, TQPainter *p, const TQRect &r, @@ -512,9 +494,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void drawControl( ControlElement element, TQPainter *p, const TQWidget *widget, @@ -536,9 +515,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void drawControlMask( ControlElement element, TQPainter *p, const TQWidget *widget, @@ -596,9 +572,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual TQRect subRect( SubRect r, const TQWidget *widget ) const = 0; // New API @@ -668,9 +641,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void drawComplexControl( ComplexControl control, TQPainter *p, const TQWidget *widget, @@ -703,9 +673,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual void drawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, @@ -723,9 +690,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual TQRect querySubControlMetrics( ComplexControl control, const TQWidget *widget, SubControl sc, @@ -741,9 +705,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual SubControl querySubControl( ComplexControl control, const TQWidget *widget, const TQPoint &pos, @@ -828,9 +789,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual int pixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const = 0; @@ -867,9 +825,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual TQSize sizeFromContents( ContentsType contents, const TQWidget *widget, const TQSize &contentsSize, @@ -1033,9 +988,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual int styleHint( StyleHint stylehint, const TQWidget *widget = 0, const TQStyleOption& = TQStyleOption::Default, @@ -1071,9 +1023,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif virtual TQPixmap stylePixmap( StylePixmap stylepixmap, const TQWidget *widget = 0, const TQStyleOption& = TQStyleOption::Default ) const = 0; @@ -1087,9 +1036,6 @@ public: // Old API // DEPRECATED -#ifdef MARK_OLD_VIRTUAL_STYLE_API_CALLS_DEPRECATED - __attribute__ ((deprecated)) -#endif static TQRect visualRect( const TQRect &logical, const TQWidget *w ); // New API -- cgit v1.2.1