From b6053b1b40b51e3d9b1b679a8a1751e5472e06e2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 8 Aug 2012 17:42:40 -0500 Subject: Automated update from Qt3 --- src/kernel/ntqstyle.h | 72 ++++++++------ src/kernel/qapplication_x11.cpp | 6 +- src/kernel/qeventloop_unix.cpp | 6 +- src/kernel/qprocess_unix.cpp | 8 +- src/kernel/qstyle.cpp | 192 ++++++++++++++++++++++++++++++++++++- src/styles/ntqcommonstyle.h | 90 ----------------- src/styles/ntqmotifstyle.h | 2 +- src/styles/ntqwindowsstyle.h | 2 +- src/styles/qcommonstyle.cpp | 208 +++++----------------------------------- src/styles/qmotifstyle.cpp | 7 +- src/styles/qwindowsstyle.cpp | 7 +- 11 files changed, 285 insertions(+), 315 deletions(-) diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h index c77ab6e47..20c1b6fd4 100644 --- a/src/kernel/ntqstyle.h +++ b/src/kernel/ntqstyle.h @@ -63,26 +63,26 @@ class TQStyleOption { public: enum StyleOptionDefault { Default }; - TQStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL) {} + TQStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL), cli(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. TQStyleOption(int in1) : - def(FALSE), tb(NULL), i1(in1) {} + def(FALSE), tb(NULL), i1(in1), cli(NULL) {} TQStyleOption(int in1, int in2) : - def(FALSE), tb(NULL), i1(in1), i2(in2) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), cli(NULL) {} TQStyleOption(int in1, int in2, int in3, int in4) : - 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), tb(NULL), li(i) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4), cli(NULL) {} + TQStyleOption(TQMenuItem* m) : def(FALSE), mi(m), tb(NULL), cli(NULL) {} + TQStyleOption(TQMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1), cli(NULL) {} + TQStyleOption(TQMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2), cli(NULL) {} + TQStyleOption(const TQColor& c) : def(FALSE), tb(NULL), cl(&c), cli(NULL) {} + TQStyleOption(TQTab* t) : def(FALSE), tb(t), cli(NULL) {} + TQStyleOption(TQListViewItem* i) : def(FALSE), tb(NULL), li(i), cli(NULL) {} 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) {} + TQStyleOption(TQt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a), cli(NULL) {} + TQStyleOption(const TQRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()), i4(r.height()), cli(NULL) {} + TQStyleOption(TQWidget *w) : def(FALSE), tb(NULL), cli(NULL), p1((void*)w) {} bool isDefault() const { return def; } @@ -134,6 +134,14 @@ class TQStyleControlElementPopupMenuData { // }; +class TQStyleControlElementCheckListItemData { + public: + bool dataValid; + bool enabled; + bool hasParent; + int height; +}; + class TQStyleControlElementTabBarData { public: int tabCount; @@ -176,6 +184,7 @@ class TQStyleControlElementGenericWidgetData { TQStringList widgetObjectTypes; bool allDataPopulated; TQt::WFlags wflags; + TQt::WindowState windowState; TQPixmap bgPixmap; TQBrush bgBrush; TQColor bgColor; @@ -196,6 +205,7 @@ class TQStyleControlElementData { TQStringList widgetObjectTypes; bool allDataPopulated; TQt::WFlags wflags; + TQt::WindowState windowState; TQPixmap bgPixmap; TQBrush bgBrush; TQColor bgColor; @@ -237,12 +247,13 @@ class TQStyleControlElementData { TQStyleControlElementGenericWidgetData viewportData; TQStyleControlElementListViewData listViewData; TQStyleControlElementTabBarData tabBarData; + TQStyleControlElementCheckListItemData checkListItemData; TQ_UINT32 comboBoxLineEditFlags; TQ_UINT32 frameStyle; TQRect sliderRect; }; -class TQStyleWidgetActionRequestData { +class Q_EXPORT TQStyleWidgetActionRequestData { public: TQStyleWidgetActionRequestData(); TQStyleWidgetActionRequestData(int metric1, int metric2=0); @@ -326,7 +337,12 @@ public: virtual void polish( TQPalette & ); - virtual void polishPopupMenu( TQPopupMenu* ) = 0; + // Old API + // DEPRECATED + virtual void polishPopupMenu( TQPopupMenu* ); + + // New API + virtual void polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ) = 0; virtual TQRect itemRect( TQPainter *p, const TQRect &r, int flags, bool enabled, @@ -445,7 +461,7 @@ public: const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual void drawPrimitive( PrimitiveElement pe, @@ -500,7 +516,7 @@ public: const TQRect &r, const TQColorGroup &cg, SFlags how = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual void drawControl( ControlElement element, @@ -519,7 +535,7 @@ public: TQPainter *p, const TQWidget *widget, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual void drawControlMask( ControlElement element, @@ -572,7 +588,7 @@ public: // Old API // DEPRECATED - virtual TQRect subRect( SubRect r, const TQWidget *widget ) const = 0; + virtual TQRect subRect( SubRect r, const TQWidget *widget ) const; // New API virtual TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const = 0; @@ -653,7 +669,7 @@ public: SCFlags sub = (uint)SC_All, #endif SCFlags subActive = SC_None, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; virtual void drawComplexControl( ComplexControl control, TQPainter *p, @@ -677,7 +693,7 @@ public: TQPainter *p, const TQWidget *widget, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual void drawComplexControlMask( ComplexControl control, @@ -693,7 +709,7 @@ public: virtual TQRect querySubControlMetrics( ComplexControl control, const TQWidget *widget, SubControl sc, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual TQRect querySubControlMetrics( ComplexControl control, @@ -708,7 +724,7 @@ public: virtual SubControl querySubControl( ComplexControl control, const TQWidget *widget, const TQPoint &pos, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; // New API virtual SubControl querySubControl( ComplexControl control, @@ -790,7 +806,7 @@ public: // Old API // DEPRECATED virtual int pixelMetric( PixelMetric metric, - const TQWidget *widget = 0 ) const = 0; + const TQWidget *widget = 0 ) const; // New API virtual int pixelMetric( PixelMetric metric, @@ -828,7 +844,7 @@ public: virtual TQSize sizeFromContents( ContentsType contents, const TQWidget *widget, const TQSize &contentsSize, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; virtual TQSize sizeFromContents( ContentsType contents, TQStyleControlElementData ceData, @@ -992,7 +1008,7 @@ public: const TQWidget *widget = 0, const TQStyleOption& = TQStyleOption::Default, TQStyleHintReturn* returnData = 0 - ) const = 0; + ) const; // New API virtual int styleHint( StyleHint stylehint, @@ -1025,7 +1041,7 @@ public: // DEPRECATED virtual TQPixmap stylePixmap( StylePixmap stylepixmap, const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default ) const = 0; + const TQStyleOption& = TQStyleOption::Default ) const; virtual TQPixmap stylePixmap( StylePixmap stylepixmap, TQStyleControlElementData ceData, @@ -1061,6 +1077,8 @@ public: WAR_RepaintRect, WAR_EnableMouseTracking, WAR_DisableMouseTracking, + WAR_SetCheckable, + WAR_UnSetCheckable, WAR_FrameSetStyle, WAR_FrameSetLineWidth, WAR_SetLayoutMargin, diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 03e7a7794..aba4fcd50 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -4445,7 +4445,9 @@ bool TQETWidget::translateXinputEvent( const XEvent *ev ) TQPair tId; XEvent xinputMotionEvent; XEvent mouseMotionEvent; +#if defined (Q_OS_IRIX) XDevice *dev; +#endif const XDeviceMotionEvent *motion = 0; XDeviceButtonEvent *button = 0; TQEvent::Type t; @@ -4501,18 +4503,14 @@ bool TQETWidget::translateXinputEvent( const XEvent *ev ) #else if ( ev->type == xinput_motion ) { if ( motion->deviceid == devStylus->device_id ) { - dev = devStylus; deviceType = TQTabletEvent::Stylus; } else if ( motion->deviceid == devEraser->device_id ) { - dev = devEraser; deviceType = TQTabletEvent::Eraser; } } else { if ( button->deviceid == devStylus->device_id ) { - dev = devStylus; deviceType = TQTabletEvent::Stylus; } else if ( button->deviceid == devEraser->device_id ) { - dev = devEraser; deviceType = TQTabletEvent::Eraser; } } diff --git a/src/kernel/qeventloop_unix.cpp b/src/kernel/qeventloop_unix.cpp index 1441b78c5..aa13ef8b6 100644 --- a/src/kernel/qeventloop_unix.cpp +++ b/src/kernel/qeventloop_unix.cpp @@ -505,7 +505,11 @@ void TQEventLoop::wakeUp() size_t nbytes = 0; char c = 0; if ( ::ioctl( d->thread_pipe[0], FIONREAD, (char*)&nbytes ) >= 0 && nbytes == 0 ) { - ::write( d->thread_pipe[1], &c, 1 ); + if (::write( d->thread_pipe[1], &c, 1 ) < 0) { +#if defined(QT_CHECK_RANGE) + tqWarning( "TQEventLoop: Internal error (failed thread pipe write)" ); +#endif + } } } diff --git a/src/kernel/qprocess_unix.cpp b/src/kernel/qprocess_unix.cpp index ff68a8860..01eb202df 100644 --- a/src/kernel/qprocess_unix.cpp +++ b/src/kernel/qprocess_unix.cpp @@ -813,7 +813,9 @@ bool TQProcess::start( TQStringList *env ) ::dup2( STDOUT_FILENO, STDERR_FILENO ); } #ifndef QT_NO_DIR - ::chdir( workingDir.absPath().latin1() ); + if (::chdir( workingDir.absPath().latin1() ) < 0) { + tqWarning( "Could not chdir" ); + } #endif if ( fd[0] ) ::close( fd[0] ); @@ -890,7 +892,9 @@ bool TQProcess::start( TQStringList *env ) } if ( fd[1] ) { char buf = 0; - ::write( fd[1], &buf, 1 ); + if (::write( fd[1], &buf, 1 ) < 0) { + tqWarning( "Could not write to file descriptor" ); + } ::close( fd[1] ); } ::_exit( -1 ); diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 26fbf0cb8..7799e59ed 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -46,6 +46,8 @@ #include "ntqpixmapcache.h" #include "ntqframe.h" #include "ntqlayout.h" +#include "ntqlistview.h" +#include "ntqpopupmenu.h" #include "ntqobjectlist.h" #include "ntqwidgetlist.h" @@ -592,7 +594,18 @@ void TQStyle::polish( TQPalette&) (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is checkable by default (\l{TQPopupMenu::setCheckable()}). */ -void TQStyle::polishPopupMenu( TQPopupMenu *) +void TQStyle::polishPopupMenu( TQPopupMenu *pm ) { + TQStyleControlElementData ceData = populateControlElementDataFromWidget(pm, TQStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(pm, ceData.widgetObjectTypes, TQStyleOption()), pm); +} + +/*! + Polishes the popup menu according to the GUI style. This usually + means setting the mouse tracking + (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is + checkable by default (\l{TQPopupMenu::setCheckable()}). +*/ +void TQStyle::polishPopupMenu( TQStyleControlElementData, ControlElementFlags, void * ) { } @@ -2204,6 +2217,18 @@ bool TQStyle::widgetActionRequest( TQStyleControlElementData ceData, ControlElem else if (request == WAR_DisableMouseTracking) { widget->setMouseTracking(FALSE); } + else if (request == WAR_SetCheckable) { + TQPopupMenu *pm = dynamic_cast(widget); + if (pm) { + pm->setCheckable(TRUE); + } + } + else if (request == WAR_UnSetCheckable) { + TQPopupMenu *pm = dynamic_cast(widget); + if (pm) { + pm->setCheckable(FALSE); + } + } else if (request == WAR_FrameSetStyle) { TQFrame* frame = dynamic_cast(widget); if (frame) { @@ -2265,6 +2290,10 @@ 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) { @@ -2324,6 +2353,167 @@ TQStyleWidgetActionRequestData::~TQStyleWidgetActionRequestData() { // } +// ============================================================================================ +// Interface methods +// ============================================================================================ + +void TQStyle::drawPrimitive( PrimitiveElement pe, + TQPainter *p, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt ) const +{ + const TQWidget* widget = 0; + + // Determine if the request needs widget information and set widget appropriately + // FIXME + if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { + TQCheckListItem *item = opt.checkListItem(); + if (item) { + TQListView *lv = item->listView(); + widget = dynamic_cast(lv); + } + } + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, cg, flags, opt); +} + +void TQStyle::drawControl( ControlElement element, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (!widget) { + tqWarning("TQStyle::drawControl: widget parameter cannot be zero!"); + return; + } +#endif + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget); +} + +void TQStyle::drawControlMask( ControlElement control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& opt ) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget); +} + +TQRect TQStyle::subRect(SubRect r, const TQWidget *widget) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::subRect: widget parameter cannot be zero!"); + return TQRect(); + } +#endif + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); +} + +void TQStyle::drawComplexControl( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + SCFlags controls, + SCFlags active, + const TQStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::drawComplexControl: widget parameter cannot be zero!"); + return; + } +#endif + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, cg, flags, controls, active, opt, widget); +} + +void TQStyle::drawComplexControlMask( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& opt ) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, opt, widget); +} + +TQRect TQStyle::querySubControlMetrics( ComplexControl control, + const TQWidget *widget, + SubControl sc, + const TQStyleOption &opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::querySubControlMetrics: widget parameter cannot be zero!"); + return TQRect(); + } +#endif + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption(), false); + return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), sc, opt, widget); +} + +TQStyle::SubControl TQStyle::querySubControl(ComplexControl control, + const TQWidget *widget, + const TQPoint &pos, + const TQStyleOption& opt ) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); +} + +int TQStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); +} + +TQSize TQStyle::sizeFromContents(ContentsType contents, + const TQWidget *widget, + const TQSize &contentsSize, + const TQStyleOption& opt ) const +{ + TQSize sz(contentsSize); + +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::sizeFromContents: widget parameter cannot be zero!"); + return sz; + } +#endif + + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), contentsSize, opt, widget); +} + +int TQStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &so, TQStyleHintReturn *shr) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(w, TQStyleOption(), false); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption(), false), so, shr, w); +} + +TQPixmap TQStyle::stylePixmap(StylePixmap sp, const TQWidget *w, const TQStyleOption &so) const +{ + TQStyleControlElementData ceData = populateControlElementDataFromWidget(w, TQStyleOption()); + return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption()), so, w); +} + /*! \fn int TQStyle::defaultFrameWidth() const \obsolete diff --git a/src/styles/ntqcommonstyle.h b/src/styles/ntqcommonstyle.h index ed02fe418..8fe9ecfa1 100644 --- a/src/styles/ntqcommonstyle.h +++ b/src/styles/ntqcommonstyle.h @@ -55,15 +55,6 @@ public: TQCommonStyle(); ~TQCommonStyle(); - // Old API - // DEPRECATED - void drawPrimitive( PrimitiveElement pe, - TQPainter *p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API void drawPrimitive( PrimitiveElement pe, TQPainter *p, @@ -74,16 +65,6 @@ public: SFlags flags = Style_Default, const TQStyleOption& = TQStyleOption::Default ) const; - // Old API - // DEPRECATED - void drawControl( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags how = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API void drawControl( ControlElement element, TQPainter *p, @@ -95,14 +76,6 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - void drawControlMask( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API void drawControlMask( ControlElement element, TQPainter *p, @@ -112,29 +85,9 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - TQRect subRect( SubRect r, const TQWidget *widget ) const; - // New API TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; - // Old API - // DEPRECATED - void drawComplexControl( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - 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; - // New API void drawComplexControl( ComplexControl control, TQPainter *p, @@ -152,14 +105,6 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - void drawComplexControlMask( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API void drawComplexControlMask( ComplexControl control, TQPainter *p, @@ -169,13 +114,6 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - TQRect querySubControlMetrics( ComplexControl control, - const TQWidget *widget, - SubControl sc, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API TQRect querySubControlMetrics( ComplexControl control, TQStyleControlElementData ceData, @@ -184,13 +122,6 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - SubControl querySubControl( ComplexControl control, - const TQWidget *widget, - const TQPoint &pos, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API SubControl querySubControl( ComplexControl control, TQStyleControlElementData ceData, @@ -199,20 +130,9 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - int pixelMetric( PixelMetric m, const TQWidget *widget = 0 ) const; - // New API int pixelMetric( PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - TQSize sizeFromContents( ContentsType s, - const TQWidget *widget, - const TQSize &contentsSize, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API TQSize sizeFromContents( ContentsType s, TQStyleControlElementData ceData, @@ -221,19 +141,9 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - // Old API - // DEPRECATED - int styleHint(StyleHint sh, const TQWidget *, const TQStyleOption &, TQStyleHintReturn *) const; - // New API int styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &, TQStyleHintReturn *, const TQWidget * w) const; - // Old API - // DEPRECATED - TQPixmap stylePixmap( StylePixmap sp, - const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default ) const; - // New API TQPixmap stylePixmap( StylePixmap sp, TQStyleControlElementData ceData, diff --git a/src/styles/ntqmotifstyle.h b/src/styles/ntqmotifstyle.h index 9b9d3650d..ec55406cc 100644 --- a/src/styles/ntqmotifstyle.h +++ b/src/styles/ntqmotifstyle.h @@ -70,7 +70,7 @@ public: void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void polishPopupMenu( TQPopupMenu* ); + void polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); // new style API void drawPrimitive( PrimitiveElement pe, diff --git a/src/styles/ntqwindowsstyle.h b/src/styles/ntqwindowsstyle.h index d626c3e3c..7220eacef 100644 --- a/src/styles/ntqwindowsstyle.h +++ b/src/styles/ntqwindowsstyle.h @@ -69,7 +69,7 @@ public: void polish( TQPalette & ); - virtual void polishPopupMenu( TQPopupMenu* ); + virtual void polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); // new stuff void drawPrimitive( PrimitiveElement pe, diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 20c6c9993..7162c4c0d 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -184,7 +184,6 @@ TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* obj if (button) { if (button->isDown()) cef = cef | TQStyle::CEF_IsDown; if (button->isOn()) cef = cef | TQStyle::CEF_IsOn; - if (button->isEnabled()) cef = cef | TQStyle::CEF_IsEnabled; if (button->isToggleButton()) cef = cef | TQStyle::CEF_BiState; } } @@ -223,6 +222,7 @@ TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* obj // Generic flags const TQWidget* widget = dynamic_cast(object); if (widget) { + if (widget->isEnabled()) cef = cef | TQStyle::CEF_IsEnabled; if (widget->parentWidget()) cef = cef | TQStyle::CEF_HasParentWidget; if (widget->focusProxy()) cef = cef | TQStyle::CEF_HasFocusProxy; if (widget->hasFocus()) cef = cef | TQStyle::CEF_HasFocus; @@ -254,6 +254,9 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.bgBrush = widget->backgroundBrush(); } ceData.wflags = widget->getWFlags(); + if (populateReliantFields) { + ceData.windowState = (TQt::WindowState)(widget->windowState()); + } ceData.bgColor = widget->eraseColor(); ceData.bgOffset = widget->backgroundOffset(); ceData.backgroundMode = widget->backgroundMode(); @@ -419,10 +422,10 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w const TQTitleBar *tb = dynamic_cast(widget); if (tb) { ceData.titleBarData.hasWindow = !!(tb->window()); - if (ceData.titleBarData.hasWindow) { - ceData.titleBarData.windowState = tb->window()->windowState(); - } if (populateReliantFields) { + if (ceData.titleBarData.hasWindow) { + ceData.titleBarData.windowState = (TQt::WindowState)(tb->window()->windowState()); + } ceData.titleBarData.usesActiveColor = tb->usesActiveColor(); } ceData.titleBarData.visibleText = tb->visibleText(); @@ -455,6 +458,9 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.viewportData.bgBrush = viewport->backgroundBrush(); } ceData.viewportData.wflags = viewport->getWFlags(); + if (populateReliantFields) { + ceData.viewportData.windowState = (TQt::WindowState)(widget->windowState()); + } ceData.viewportData.bgColor = viewport->eraseColor(); ceData.viewportData.bgOffset = viewport->backgroundOffset(); ceData.viewportData.backgroundMode = viewport->backgroundMode(); @@ -502,6 +508,9 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush(); } ceData.parentWidgetData.wflags = parentWidget->getWFlags(); + if (populateReliantFields) { + ceData.parentWidgetData.windowState = (TQt::WindowState)(widget->windowState()); + } ceData.parentWidgetData.bgColor = parentWidget->eraseColor(); ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset(); ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode(); @@ -531,33 +540,20 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.dwData.closeEnabled = dw->isCloseEnabled(); } } - } - return ceData; -} - -/*! \reimp */ -void TQCommonStyle::drawPrimitive( PrimitiveElement pe, - TQPainter *p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& opt ) const -{ - const TQWidget* widget = 0; - - // Determine if the request needs widget information and set widget appropriately - // FIXME - if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { TQCheckListItem *item = opt.checkListItem(); if (item) { - TQListView *lv = item->listView(); - widget = dynamic_cast(lv); + ceData.checkListItemData.dataValid = true; + ceData.checkListItemData.enabled = item->isEnabled(); + ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((TQCheckListItem*) item->parent())->type() == TQCheckListItem::Controller) ); + ceData.checkListItemData.height = item->height(); + } + else { + ceData.checkListItemData.dataValid = false; } } - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, cg, flags, opt); + return ceData; } /*! \reimp */ @@ -578,8 +574,7 @@ void TQCommonStyle::drawPrimitive( PrimitiveElement pe, p->drawPixmap(r, TQPixmap((const char **)check_list_controller_xpm)); break; } case PE_CheckListExclusiveIndicator: { - TQCheckListItem *item = opt.checkListItem(); - if(!item) + if(!ceData.checkListItemData.dataValid) return; int x = r.x(), y = r.y(); #define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2) @@ -630,8 +625,7 @@ void TQCommonStyle::drawPrimitive( PrimitiveElement pe, } break; } case PE_CheckListIndicator: { - TQCheckListItem *item = opt.checkListItem(); - if(!item) + if(!ceData.checkListItemData.dataValid) return; int x = r.x(), y = r.y(), w = r.width(), h = r.width(), marg = ceData.listViewData.itemMargin; @@ -640,14 +634,10 @@ void TQCommonStyle::drawPrimitive( PrimitiveElement pe, else p->setPen( TQPen( ceData.palette.color( TQPalette::Disabled, TQColorGroup::Text ), 2 ) ); - bool parentControl = FALSE; - if ( item->parent() && item->parent()->rtti() == 1 && - ((TQCheckListItem*) item->parent())->type() == TQCheckListItem::Controller ) - parentControl = TRUE; - if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !parentControl ) { - p->fillRect( 0, 0, x + marg + w + 4, item->height(), + if ( flags & Style_Selected && !ceData.listViewData.rootDecorated && !ceData.checkListItemData.hasParent ) { + p->fillRect( 0, 0, x + marg + w + 4, ceData.checkListItemData.height, cg.brush( TQColorGroup::Highlight ) ); - if ( item->isEnabled() ) + if ( ceData.checkListItemData.enabled ) p->setPen( TQPen( cg.highlightedText(), 2 ) ); } @@ -1044,26 +1034,6 @@ void qt_style_erase_region(TQPainter* p, const TQRegion& region, TQStyleControlE return; } -/*! \reimp */ -void TQCommonStyle::drawControl( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (!widget) { - tqWarning("TQCommonStyle::drawControl: widget parameter cannot be zero!"); - return; - } -#endif - - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget); -} - /*! \reimp */ void TQCommonStyle::drawControl( ControlElement element, TQPainter *p, @@ -1544,16 +1514,6 @@ void TQCommonStyle::drawControl( ControlElement element, activePainter = 0; } -void TQCommonStyle::drawControlMask( ControlElement control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& opt ) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget); -} - /*! \reimp */ void TQCommonStyle::drawControlMask( ControlElement control, TQPainter *p, @@ -1592,20 +1552,6 @@ void TQCommonStyle::drawControlMask( ControlElement control, activePainter = 0; } -/*! \reimp */ -TQRect TQCommonStyle::subRect(SubRect r, const TQWidget *widget) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQCommonStyle::subRect: widget parameter cannot be zero!"); - return TQRect(); - } -#endif - - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); -} - /*! \reimp */ TQRect TQCommonStyle::subRect(SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const { @@ -1933,28 +1879,6 @@ static int qPositionFromValue( TQStyleControlElementData ceData, int logical_val } #endif // QT_NO_RANGECONTROL -/*! \reimp */ -void TQCommonStyle::drawComplexControl( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - SCFlags controls, - SCFlags active, - const TQStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQCommonStyle::drawComplexControl: widget parameter cannot be zero!"); - return; - } -#endif - - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, cg, flags, controls, active, opt, widget); -} - /*! \reimp */ void TQCommonStyle::drawComplexControl( ComplexControl control, TQPainter *p, @@ -2357,17 +2281,6 @@ void TQCommonStyle::drawComplexControl( ComplexControl control, activePainter = 0; } -/*! \reimp */ -void TQCommonStyle::drawComplexControlMask( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& opt ) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), r, opt, widget); -} - /*! \reimp */ void TQCommonStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, @@ -2386,23 +2299,6 @@ void TQCommonStyle::drawComplexControlMask( ComplexControl control, p->fillRect(r, color1); } -/*! \reimp */ -TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control, - const TQWidget *widget, - SubControl sc, - const TQStyleOption &opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQCommonStyle::querySubControlMetrics: widget parameter cannot be zero!"); - return TQRect(); - } -#endif - - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption(), false); - return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), sc, opt, widget); -} - /*! \reimp */ TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control, TQStyleControlElementData ceData, @@ -2637,17 +2533,6 @@ TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control, return TQRect(); } - -/*! \reimp */ -TQStyle::SubControl TQCommonStyle::querySubControl(ComplexControl control, - const TQWidget *widget, - const TQPoint &pos, - const TQStyleOption& opt ) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); -} - /*! \reimp */ TQStyle::SubControl TQCommonStyle::querySubControl(ComplexControl control, TQStyleControlElementData ceData, @@ -2724,14 +2609,6 @@ TQStyle::SubControl TQCommonStyle::querySubControl(ComplexControl control, return ret; } - -/*! \reimp */ -int TQCommonStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), widget); -} - /*! \reimp */ int TQCommonStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const { @@ -2952,25 +2829,6 @@ int TQCommonStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, return ret; } -/*! \reimp */ -TQSize TQCommonStyle::sizeFromContents(ContentsType contents, - const TQWidget *widget, - const TQSize &contentsSize, - const TQStyleOption& opt ) const -{ - TQSize sz(contentsSize); - -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQCommonStyle::sizeFromContents: widget parameter cannot be zero!"); - return sz; - } -#endif - - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), contentsSize, opt, widget); -} - /*! \reimp */ TQSize TQCommonStyle::sizeFromContents(ContentsType contents, TQStyleControlElementData ceData, @@ -3142,13 +3000,6 @@ TQSize TQCommonStyle::sizeFromContents(ContentsType contents, return sz; } -/*! \reimp */ -int TQCommonStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &so, TQStyleHintReturn *shr) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(w, TQStyleOption(), false); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption(), false), so, shr, w); -} - /*! \reimp */ int TQCommonStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &, TQStyleHintReturn *, const TQWidget * w) const { @@ -3232,13 +3083,6 @@ int TQCommonStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Con return ret; } -/*! \reimp */ -TQPixmap TQCommonStyle::stylePixmap(StylePixmap sp, const TQWidget *w, const TQStyleOption &so) const -{ - TQStyleControlElementData ceData = populateControlElementDataFromWidget(w, TQStyleOption()); - return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption()), so, w); -} - /*! \reimp */ TQPixmap TQCommonStyle::stylePixmap(StylePixmap, TQStyleControlElementData, ControlElementFlags, const TQStyleOption&, const TQWidget *) const { diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index 37a5a34cf..b404dc917 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -1907,11 +1907,12 @@ TQRect TQMotifStyle::subRect( SubRect r, TQStyleControlElementData ceData, Contr /*! \reimp */ -void TQMotifStyle::polishPopupMenu( TQPopupMenu* p) +void TQMotifStyle::polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { #ifndef QT_NO_POPUPMENU - if ( !p->testWState( WState_Polished ) ) - p->setCheckable( FALSE ); + if ( !(ceData.windowState & WState_Polished ) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetCheckable); + } #endif } diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 5a1289dca..dae52362f 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -1155,11 +1155,12 @@ TQSize TQWindowsStyle::sizeFromContents( ContentsType contents, /*! \reimp */ -void TQWindowsStyle::polishPopupMenu( TQPopupMenu* p) +void TQWindowsStyle::polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { #ifndef QT_NO_POPUPMENU - if ( !p->testWState( WState_Polished ) ) - p->setCheckable( TRUE ); + if ( !(ceData.windowState & WState_Polished ) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetCheckable); + } #endif } -- cgit v1.2.1