diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2012-08-11 14:14:42 -0500 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2012-08-11 14:14:42 -0500 |
commit | 43eac4e25d7d4b892ae74b4a2c8c4b8e8395b8af (patch) | |
tree | 644a90f58d13622d2400016e64ecc3e43c41f5b3 /src | |
parent | 34ddcfd05b2b4772eeb70493726e0f8c8b40a3af (diff) | |
parent | 33875614a6eddef3a881601a00ea0427e6c55003 (diff) | |
download | tqt3-43eac4e25d7d4b892ae74b4a2c8c4b8e8395b8af.tar.gz tqt3-43eac4e25d7d4b892ae74b4a2c8c4b8e8395b8af.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tqt3
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/ntqstyle.h | 24 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 66 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 12 |
3 files changed, 90 insertions, 12 deletions
diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index 20c1b6fd4..75a79c79a 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -257,18 +257,24 @@ class Q_EXPORT TQStyleWidgetActionRequestData { public: TQStyleWidgetActionRequestData(); TQStyleWidgetActionRequestData(int metric1, int metric2=0); - TQStyleWidgetActionRequestData(TQPalette palette); - TQStyleWidgetActionRequestData(TQFont font); + TQStyleWidgetActionRequestData(TQPalette palette, bool informWidgets = FALSE, const char* className = 0); + TQStyleWidgetActionRequestData(TQFont font, bool informWidgets = FALSE, const char* className = 0); TQStyleWidgetActionRequestData(TQRect rect); ~TQStyleWidgetActionRequestData(); public: + bool bool1; + bool bool2; int metric1; int metric2; TQPalette palette; TQFont font; TQRect rect; + const char * cstr; + TQString string; }; +typedef TQStyleWidgetActionRequestData TQStyleApplicationActionRequestData; + class Q_EXPORT TQStyle: public TQObject { TQ_OBJECT @@ -1077,6 +1083,8 @@ public: WAR_RepaintRect, WAR_EnableMouseTracking, WAR_DisableMouseTracking, + WAR_SetAutoMask, + WAR_UnSetAutoMask, WAR_SetCheckable, WAR_UnSetCheckable, WAR_FrameSetStyle, @@ -1084,6 +1092,7 @@ public: WAR_SetLayoutMargin, WAR_SetPalette, WAR_SetBackgroundMode, + WAR_SetBackgroundOrigin, WAR_SetFont, WAR_RepaintAllAccelerators }; @@ -1092,6 +1101,15 @@ public: void setWidgetActionRequestHook( WidgetActionRequestHook ); virtual bool widgetActionRequest( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData = TQStyleWidgetActionRequestData() ); + enum ApplicationActionRequest { + AAR_SetPalette, + AAR_SetFont + }; + + typedef bool (*ApplicationActionRequestHook)(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData); + void setApplicationActionRequestHook( ApplicationActionRequestHook ); + virtual bool applicationActionRequest( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData = TQStyleApplicationActionRequestData() ); + // Old 2.x TQStyle API #ifndef QT_NO_COMPAT @@ -1131,6 +1149,7 @@ private: EventHandlerInstallationHook m_eventHandlerInstallationHook; EventHandlerRemovalHook m_eventHandlerRemovalHook; WidgetActionRequestHook m_widgetActionRequestHook; + ApplicationActionRequestHook m_applicationActionRequestHook; ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; @@ -1141,6 +1160,7 @@ inline TQStyle::ControlElementFlags operator|(const TQStyle::ControlElementFlags // 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 TQStyleControlElementData populateControlElementDataFromApplication(const TQApplication* app, 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); diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 7799e59ed..2195382e7 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -403,6 +403,7 @@ TQStyle::TQStyle() m_eventHandlerInstallationHook = NULL; m_eventHandlerRemovalHook = NULL; m_widgetActionRequestHook = NULL; + m_applicationActionRequestHook = NULL; conditionalAcceleratorsEnabled = false; d = new TQStylePrivate; } @@ -526,8 +527,7 @@ void TQStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags, v \sa unPolish() */ void TQStyle::polish( TQApplication *app ) { - TQStyleControlElementData ceData; - ceData.widgetObjectTypes = getObjectTypeListForObject(app); + TQStyleControlElementData ceData = populateControlElementDataFromApplication(app, TQStyleOption()); applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, TQStyleOption()), app); } @@ -539,8 +539,7 @@ void TQStyle::polish( TQApplication *app ) { \sa polish() */ void TQStyle::unPolish( TQApplication *app ) { - TQStyleControlElementData ceData; - ceData.widgetObjectTypes = getObjectTypeListForObject(app); + TQStyleControlElementData ceData = populateControlElementDataFromApplication(app, TQStyleOption()); applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, TQStyleOption()), app); } @@ -2217,6 +2216,12 @@ bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElem else if (request == WAR_DisableMouseTracking) { widget->setMouseTracking(FALSE); } + else if (request == WAR_SetAutoMask) { + widget->setAutoMask(TRUE); + } + else if (request == WAR_UnSetAutoMask) { + widget->setAutoMask(FALSE); + } else if (request == WAR_SetCheckable) { TQPopupMenu *pm = dynamic_cast<TQPopupMenu*>(widget); if (pm) { @@ -2253,6 +2258,9 @@ bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElem else if (request == WAR_SetBackgroundMode) { widget->setBackgroundMode((TQt::BackgroundMode)requestData.metric1); } + else if (request == WAR_SetBackgroundOrigin) { + widget->setBackgroundOrigin((TQWidget::BackgroundOrigin)requestData.metric1); + } else if (request == WAR_SetFont) { widget->setFont(requestData.font); } @@ -2289,11 +2297,45 @@ bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElem 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 +/*! + \fn void TQStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new application 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::setApplicationActionRequestHook( ApplicationActionRequestHook hook ) { + m_applicationActionRequestHook = hook; +} + +/*! + \fn bool applicationActionRequestHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request ); + Handles application action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool TQStyle::applicationActionRequest( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData ) { + bool cbret = false; + if (m_applicationActionRequestHook) { + cbret = (*m_applicationActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQApplication")) { + TQApplication* application = reinterpret_cast<TQApplication*>(source); + if (request == AAR_SetPalette) { + application->setPalette(requestData.palette, requestData.bool1, requestData.cstr); + } + else if (request == AAR_SetFont) { + application->setFont(requestData.font, requestData.bool1, requestData.cstr); + } + return true; + } + } + return true; +} + +void TQStyle::acceleratorKeypressEventMonitor( TQObject *o, TQEvent *e ) { if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { TQWidget *widget = dynamic_cast<TQWidget*>(o); if (widget) { @@ -2337,12 +2379,16 @@ TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(int param1, int p metric2 = param2; } -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPalette param) { +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPalette param, bool informWidgets, const char* className) { palette = param; + bool1 = informWidgets; + cstr = className; } -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQFont param) { +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQFont param, bool informWidgets, const char* className) { font = param; + bool1 = informWidgets; + cstr = className; } TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQRect param) { diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 7162c4c0d..dafef39a2 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -556,6 +556,18 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w return ceData; } +TQStyleControlElementData populateControlElementDataFromApplication(const TQApplication* app, const TQStyleOption&, bool) { + TQStyleControlElementData ceData; + + if (app) { + ceData.widgetObjectTypes = getObjectTypeListForObject(app); + ceData.palette = app->palette(); + ceData.font = app->font(); + } + + return ceData; +} + /*! \reimp */ void TQCommonStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, |