diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-08 17:42:21 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-08 17:42:21 -0500 |
commit | 8805afa8c607ac6028207434f78a7cd90a9df64b (patch) | |
tree | 839aeaab6a6a79a4b4e04beabc65658354b179b1 /src | |
parent | 47132557a4c58d4ad69bc2898bb2bd9c424b3b64 (diff) | |
download | qt3-8805afa8c607ac6028207434f78a7cd90a9df64b.tar.gz qt3-8805afa8c607ac6028207434f78a7cd90a9df64b.zip |
Fix problems in prior style API changes
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/qapplication_x11.cpp | 6 | ||||
-rw-r--r-- | src/kernel/qeventloop_unix.cpp | 6 | ||||
-rw-r--r-- | src/kernel/qprocess_unix.cpp | 8 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 192 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 72 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 208 | ||||
-rw-r--r-- | src/styles/qcommonstyle.h | 90 | ||||
-rw-r--r-- | src/styles/qmotifstyle.cpp | 7 | ||||
-rw-r--r-- | src/styles/qmotifstyle.h | 2 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 7 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.h | 2 |
11 files changed, 285 insertions, 315 deletions
diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index ef6571a..6a68604 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -4445,7 +4445,9 @@ bool QETWidget::translateXinputEvent( const XEvent *ev ) QPair<int, int> tId; XEvent xinputMotionEvent; XEvent mouseMotionEvent; +#if defined (Q_OS_IRIX) XDevice *dev; +#endif const XDeviceMotionEvent *motion = 0; XDeviceButtonEvent *button = 0; QEvent::Type t; @@ -4501,18 +4503,14 @@ bool QETWidget::translateXinputEvent( const XEvent *ev ) #else if ( ev->type == xinput_motion ) { if ( motion->deviceid == devStylus->device_id ) { - dev = devStylus; deviceType = QTabletEvent::Stylus; } else if ( motion->deviceid == devEraser->device_id ) { - dev = devEraser; deviceType = QTabletEvent::Eraser; } } else { if ( button->deviceid == devStylus->device_id ) { - dev = devStylus; deviceType = QTabletEvent::Stylus; } else if ( button->deviceid == devEraser->device_id ) { - dev = devEraser; deviceType = QTabletEvent::Eraser; } } diff --git a/src/kernel/qeventloop_unix.cpp b/src/kernel/qeventloop_unix.cpp index 743eb1d..b0ad8b9 100644 --- a/src/kernel/qeventloop_unix.cpp +++ b/src/kernel/qeventloop_unix.cpp @@ -505,7 +505,11 @@ void QEventLoop::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) + qWarning( "QEventLoop: Internal error (failed thread pipe write)" ); +#endif + } } } diff --git a/src/kernel/qprocess_unix.cpp b/src/kernel/qprocess_unix.cpp index 40476d3..2a4a2fd 100644 --- a/src/kernel/qprocess_unix.cpp +++ b/src/kernel/qprocess_unix.cpp @@ -813,7 +813,9 @@ bool QProcess::start( QStringList *env ) ::dup2( STDOUT_FILENO, STDERR_FILENO ); } #ifndef QT_NO_DIR - ::chdir( workingDir.absPath().latin1() ); + if (::chdir( workingDir.absPath().latin1() ) < 0) { + qWarning( "Could not chdir" ); + } #endif if ( fd[0] ) ::close( fd[0] ); @@ -890,7 +892,9 @@ bool QProcess::start( QStringList *env ) } if ( fd[1] ) { char buf = 0; - ::write( fd[1], &buf, 1 ); + if (::write( fd[1], &buf, 1 ) < 0) { + qWarning( "Could not write to file descriptor" ); + } ::close( fd[1] ); } ::_exit( -1 ); diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index fc4daa2..1d085f3 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -46,6 +46,8 @@ #include "qpixmapcache.h" #include "qframe.h" #include "qlayout.h" +#include "qlistview.h" +#include "qpopupmenu.h" #include "qobjectlist.h" #include "qwidgetlist.h" @@ -592,7 +594,18 @@ void QStyle::polish( QPalette&) (\l{QPopupMenu::setMouseTracking()}) and whether the menu is checkable by default (\l{QPopupMenu::setCheckable()}). */ -void QStyle::polishPopupMenu( QPopupMenu *) +void QStyle::polishPopupMenu( QPopupMenu *pm ) { + QStyleControlElementData ceData = populateControlElementDataFromWidget(pm, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(pm, ceData.widgetObjectTypes, QStyleOption()), pm); +} + +/*! + Polishes the popup menu according to the GUI style. This usually + means setting the mouse tracking + (\l{QPopupMenu::setMouseTracking()}) and whether the menu is + checkable by default (\l{QPopupMenu::setCheckable()}). +*/ +void QStyle::polishPopupMenu( QStyleControlElementData, ControlElementFlags, void * ) { } @@ -2204,6 +2217,18 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen else if (request == WAR_DisableMouseTracking) { widget->setMouseTracking(FALSE); } + else if (request == WAR_SetCheckable) { + QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget); + if (pm) { + pm->setCheckable(TRUE); + } + } + else if (request == WAR_UnSetCheckable) { + QPopupMenu *pm = dynamic_cast<QPopupMenu*>(widget); + if (pm) { + pm->setCheckable(FALSE); + } + } else if (request == WAR_FrameSetStyle) { QFrame* frame = dynamic_cast<QFrame*>(widget); if (frame) { @@ -2265,6 +2290,10 @@ bool QStyle::widgetActionRequest( QStyleControlElementData ceData, ControlElemen } void QStyle::acceleratorKeypressEventMonitor( QObject *o, QEvent *e ) { + // RAJA FIXME + // Also, SH_HideUnderlineAcceleratorWhenAltUp should probably be set to 1 in the QWindowsStyle::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, QStyleControlElementData(), CEF_None, QStyleOption::Default, NULL, NULL) != 0) { QWidget *widget = dynamic_cast<QWidget*>(o); if (widget) { @@ -2324,6 +2353,167 @@ QStyleWidgetActionRequestData::~QStyleWidgetActionRequestData() { // } +// ============================================================================================ +// Interface methods +// ============================================================================================ + +void QStyle::drawPrimitive( PrimitiveElement pe, + QPainter *p, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ + const QWidget* widget = 0; + + // Determine if the request needs widget information and set widget appropriately + // FIXME + if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { + QCheckListItem *item = opt.checkListItem(); + if (item) { + QListView *lv = item->listView(); + widget = dynamic_cast<QWidget*>(lv); + } + } + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt); +} + +void QStyle::drawControl( ControlElement element, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + const QStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (!widget) { + qWarning("QStyle::drawControl: widget parameter cannot be zero!"); + return; + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget); +} + +void QStyle::drawControlMask( ControlElement control, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QStyleOption& opt ) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget); +} + +QRect QStyle::subRect(SubRect r, const QWidget *widget) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::subRect: widget parameter cannot be zero!"); + return QRect(); + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +void QStyle::drawComplexControl( ComplexControl control, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QColorGroup &cg, + SFlags flags, + SCFlags controls, + SCFlags active, + const QStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::drawComplexControl: widget parameter cannot be zero!"); + return; + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, controls, active, opt, widget); +} + +void QStyle::drawComplexControlMask( ComplexControl control, + QPainter *p, + const QWidget *widget, + const QRect &r, + const QStyleOption& opt ) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, opt, widget); +} + +QRect QStyle::querySubControlMetrics( ComplexControl control, + const QWidget *widget, + SubControl sc, + const QStyleOption &opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::querySubControlMetrics: widget parameter cannot be zero!"); + return QRect(); + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false); + return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget); +} + +QStyle::SubControl QStyle::querySubControl(ComplexControl control, + const QWidget *widget, + const QPoint &pos, + const QStyleOption& opt ) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); + return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); +} + +int QStyle::pixelMetric(PixelMetric m, const QWidget *widget) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); +} + +QSize QStyle::sizeFromContents(ContentsType contents, + const QWidget *widget, + const QSize &contentsSize, + const QStyleOption& opt ) const +{ + QSize sz(contentsSize); + +#if defined(QT_CHECK_STATE) + if (! widget) { + qWarning("QStyle::sizeFromContents: widget parameter cannot be zero!"); + return sz; + } +#endif + + QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), contentsSize, opt, widget); +} + +int QStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption(), false); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w); +} + +QPixmap QStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const +{ + QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption()); + return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, w); +} + /*! \fn int QStyle::defaultFrameWidth() const \obsolete diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index bb2efbc..c99fb78 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -63,26 +63,26 @@ class QStyleOption { public: enum StyleOptionDefault { Default }; - QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL) {} + QStyleOption(StyleOptionDefault=Default) : def(TRUE), tb(NULL), cli(NULL) {} // Note: we don't use default arguments since that is unnecessary // initialization. QStyleOption(int in1) : - def(FALSE), tb(NULL), i1(in1) {} + def(FALSE), tb(NULL), i1(in1), cli(NULL) {} QStyleOption(int in1, int in2) : - def(FALSE), tb(NULL), i1(in1), i2(in2) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), cli(NULL) {} QStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4) {} - QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL) {} - QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1) {} - QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2) {} - QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c) {} - QStyleOption(QTab* t) : def(FALSE), tb(t) {} - QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i) {} + def(FALSE), tb(NULL), i1(in1), i2(in2), i3(in3), i4(in4), cli(NULL) {} + QStyleOption(QMenuItem* m) : def(FALSE), mi(m), tb(NULL), cli(NULL) {} + QStyleOption(QMenuItem* m, int in1) : def(FALSE), mi(m), tb(NULL), i1(in1), cli(NULL) {} + QStyleOption(QMenuItem* m, int in1, int in2) : def(FALSE), mi(m), tb(NULL), i1(in1), i2(in2), cli(NULL) {} + QStyleOption(const QColor& c) : def(FALSE), tb(NULL), cl(&c), cli(NULL) {} + QStyleOption(QTab* t) : def(FALSE), tb(t), cli(NULL) {} + QStyleOption(QListViewItem* i) : def(FALSE), tb(NULL), li(i), cli(NULL) {} QStyleOption(QCheckListItem* i) : def(FALSE), tb(NULL), cli(i) {} - QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a) {} - QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()),i4(r.height()){} - QStyleOption(QWidget *w) : def(FALSE), tb(NULL), p1((void*)w) {} + QStyleOption(Qt::ArrowType a) : def(FALSE), tb(NULL), i1((int)a), cli(NULL) {} + QStyleOption(const QRect& r) : def(FALSE), tb(NULL), i1(r.x()), i2(r.y()), i3(r.width()), i4(r.height()), cli(NULL) {} + QStyleOption(QWidget *w) : def(FALSE), tb(NULL), cli(NULL), p1((void*)w) {} bool isDefault() const { return def; } @@ -134,6 +134,14 @@ class QStyleControlElementPopupMenuData { // }; +class QStyleControlElementCheckListItemData { + public: + bool dataValid; + bool enabled; + bool hasParent; + int height; +}; + class QStyleControlElementTabBarData { public: int tabCount; @@ -176,6 +184,7 @@ class QStyleControlElementGenericWidgetData { QStringList widgetObjectTypes; bool allDataPopulated; Qt::WFlags wflags; + Qt::WindowState windowState; QPixmap bgPixmap; QBrush bgBrush; QColor bgColor; @@ -196,6 +205,7 @@ class QStyleControlElementData { QStringList widgetObjectTypes; bool allDataPopulated; Qt::WFlags wflags; + Qt::WindowState windowState; QPixmap bgPixmap; QBrush bgBrush; QColor bgColor; @@ -237,12 +247,13 @@ class QStyleControlElementData { QStyleControlElementGenericWidgetData viewportData; QStyleControlElementListViewData listViewData; QStyleControlElementTabBarData tabBarData; + QStyleControlElementCheckListItemData checkListItemData; Q_UINT32 comboBoxLineEditFlags; Q_UINT32 frameStyle; QRect sliderRect; }; -class QStyleWidgetActionRequestData { +class Q_EXPORT QStyleWidgetActionRequestData { public: QStyleWidgetActionRequestData(); QStyleWidgetActionRequestData(int metric1, int metric2=0); @@ -326,7 +337,12 @@ public: virtual void polish( QPalette & ); - virtual void polishPopupMenu( QPopupMenu* ) = 0; + // Old API + // DEPRECATED + virtual void polishPopupMenu( QPopupMenu* ); + + // New API + virtual void polishPopupMenu( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ) = 0; virtual QRect itemRect( QPainter *p, const QRect &r, int flags, bool enabled, @@ -445,7 +461,7 @@ public: const QRect &r, const QColorGroup &cg, SFlags flags = Style_Default, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual void drawPrimitive( PrimitiveElement pe, @@ -500,7 +516,7 @@ public: const QRect &r, const QColorGroup &cg, SFlags how = Style_Default, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual void drawControl( ControlElement element, @@ -519,7 +535,7 @@ public: QPainter *p, const QWidget *widget, const QRect &r, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual void drawControlMask( ControlElement element, @@ -572,7 +588,7 @@ public: // Old API // DEPRECATED - virtual QRect subRect( SubRect r, const QWidget *widget ) const = 0; + virtual QRect subRect( SubRect r, const QWidget *widget ) const; // New API virtual QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const = 0; @@ -653,7 +669,7 @@ public: SCFlags sub = (uint)SC_All, #endif SCFlags subActive = SC_None, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; virtual void drawComplexControl( ComplexControl control, QPainter *p, @@ -677,7 +693,7 @@ public: QPainter *p, const QWidget *widget, const QRect &r, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual void drawComplexControlMask( ComplexControl control, @@ -693,7 +709,7 @@ public: virtual QRect querySubControlMetrics( ComplexControl control, const QWidget *widget, SubControl sc, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual QRect querySubControlMetrics( ComplexControl control, @@ -708,7 +724,7 @@ public: virtual SubControl querySubControl( ComplexControl control, const QWidget *widget, const QPoint &pos, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; // New API virtual SubControl querySubControl( ComplexControl control, @@ -790,7 +806,7 @@ public: // Old API // DEPRECATED virtual int pixelMetric( PixelMetric metric, - const QWidget *widget = 0 ) const = 0; + const QWidget *widget = 0 ) const; // New API virtual int pixelMetric( PixelMetric metric, @@ -828,7 +844,7 @@ public: virtual QSize sizeFromContents( ContentsType contents, const QWidget *widget, const QSize &contentsSize, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; virtual QSize sizeFromContents( ContentsType contents, QStyleControlElementData ceData, @@ -992,7 +1008,7 @@ public: const QWidget *widget = 0, const QStyleOption& = QStyleOption::Default, QStyleHintReturn* returnData = 0 - ) const = 0; + ) const; // New API virtual int styleHint( StyleHint stylehint, @@ -1025,7 +1041,7 @@ public: // DEPRECATED virtual QPixmap stylePixmap( StylePixmap stylepixmap, const QWidget *widget = 0, - const QStyleOption& = QStyleOption::Default ) const = 0; + const QStyleOption& = QStyleOption::Default ) const; virtual QPixmap stylePixmap( StylePixmap stylepixmap, QStyleControlElementData 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/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index e46f264..b81018e 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -184,7 +184,6 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec if (button) { if (button->isDown()) cef = cef | QStyle::CEF_IsDown; if (button->isOn()) cef = cef | QStyle::CEF_IsOn; - if (button->isEnabled()) cef = cef | QStyle::CEF_IsEnabled; if (button->isToggleButton()) cef = cef | QStyle::CEF_BiState; } } @@ -223,6 +222,7 @@ QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* objec // Generic flags const QWidget* widget = dynamic_cast<const QWidget*>(object); if (widget) { + if (widget->isEnabled()) cef = cef | QStyle::CEF_IsEnabled; if (widget->parentWidget()) cef = cef | QStyle::CEF_HasParentWidget; if (widget->focusProxy()) cef = cef | QStyle::CEF_HasFocusProxy; if (widget->hasFocus()) cef = cef | QStyle::CEF_HasFocus; @@ -254,6 +254,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.bgBrush = widget->backgroundBrush(); } ceData.wflags = widget->getWFlags(); + if (populateReliantFields) { + ceData.windowState = (Qt::WindowState)(widget->windowState()); + } ceData.bgColor = widget->eraseColor(); ceData.bgOffset = widget->backgroundOffset(); ceData.backgroundMode = widget->backgroundMode(); @@ -419,10 +422,10 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid const QTitleBar *tb = dynamic_cast<const QTitleBar*>(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 = (Qt::WindowState)(tb->window()->windowState()); + } ceData.titleBarData.usesActiveColor = tb->usesActiveColor(); } ceData.titleBarData.visibleText = tb->visibleText(); @@ -455,6 +458,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.viewportData.bgBrush = viewport->backgroundBrush(); } ceData.viewportData.wflags = viewport->getWFlags(); + if (populateReliantFields) { + ceData.viewportData.windowState = (Qt::WindowState)(widget->windowState()); + } ceData.viewportData.bgColor = viewport->eraseColor(); ceData.viewportData.bgOffset = viewport->backgroundOffset(); ceData.viewportData.backgroundMode = viewport->backgroundMode(); @@ -502,6 +508,9 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.parentWidgetData.bgBrush = parentWidget->backgroundBrush(); } ceData.parentWidgetData.wflags = parentWidget->getWFlags(); + if (populateReliantFields) { + ceData.parentWidgetData.windowState = (Qt::WindowState)(widget->windowState()); + } ceData.parentWidgetData.bgColor = parentWidget->eraseColor(); ceData.parentWidgetData.bgOffset = parentWidget->backgroundOffset(); ceData.parentWidgetData.backgroundMode = parentWidget->backgroundMode(); @@ -531,33 +540,20 @@ QStyleControlElementData populateControlElementDataFromWidget(const QWidget* wid ceData.dwData.closeEnabled = dw->isCloseEnabled(); } } - } - return ceData; -} - -/*! \reimp */ -void QCommonStyle::drawPrimitive( PrimitiveElement pe, - QPainter *p, - const QRect &r, - const QColorGroup &cg, - SFlags flags, - const QStyleOption& opt ) const -{ - const QWidget* widget = 0; - - // Determine if the request needs widget information and set widget appropriately - // FIXME - if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { QCheckListItem *item = opt.checkListItem(); if (item) { - QListView *lv = item->listView(); - widget = dynamic_cast<QWidget*>(lv); + ceData.checkListItemData.dataValid = true; + ceData.checkListItemData.enabled = item->isEnabled(); + ceData.checkListItemData.hasParent = ( item->parent() && (item->parent()->rtti() == 1) && (((QCheckListItem*) item->parent())->type() == QCheckListItem::Controller) ); + ceData.checkListItemData.height = item->height(); + } + else { + ceData.checkListItemData.dataValid = false; } } - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt); + return ceData; } /*! \reimp */ @@ -578,8 +574,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe, p->drawPixmap(r, QPixmap((const char **)check_list_controller_xpm)); break; } case PE_CheckListExclusiveIndicator: { - QCheckListItem *item = opt.checkListItem(); - if(!item) + if(!ceData.checkListItemData.dataValid) return; int x = r.x(), y = r.y(); #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) @@ -630,8 +625,7 @@ void QCommonStyle::drawPrimitive( PrimitiveElement pe, } break; } case PE_CheckListIndicator: { - QCheckListItem *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 QCommonStyle::drawPrimitive( PrimitiveElement pe, else p->setPen( QPen( ceData.palette.color( QPalette::Disabled, QColorGroup::Text ), 2 ) ); - bool parentControl = FALSE; - if ( item->parent() && item->parent()->rtti() == 1 && - ((QCheckListItem*) item->parent())->type() == QCheckListItem::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( QColorGroup::Highlight ) ); - if ( item->isEnabled() ) + if ( ceData.checkListItemData.enabled ) p->setPen( QPen( cg.highlightedText(), 2 ) ); } @@ -1047,26 +1037,6 @@ void qt_style_erase_region(QPainter* p, const QRegion& region, QStyleControlElem /*! \reimp */ void QCommonStyle::drawControl( ControlElement element, QPainter *p, - const QWidget *widget, - const QRect &r, - const QColorGroup &cg, - SFlags flags, - const QStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (!widget) { - qWarning("QCommonStyle::drawControl: widget parameter cannot be zero!"); - return; - } -#endif - - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget); -} - -/*! \reimp */ -void QCommonStyle::drawControl( ControlElement element, - QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, @@ -1544,16 +1514,6 @@ void QCommonStyle::drawControl( ControlElement element, activePainter = 0; } -void QCommonStyle::drawControlMask( ControlElement control, - QPainter *p, - const QWidget *widget, - const QRect &r, - const QStyleOption& opt ) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget); -} - /*! \reimp */ void QCommonStyle::drawControlMask( ControlElement control, QPainter *p, @@ -1593,20 +1553,6 @@ void QCommonStyle::drawControlMask( ControlElement control, } /*! \reimp */ -QRect QCommonStyle::subRect(SubRect r, const QWidget *widget) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - qWarning("QCommonStyle::subRect: widget parameter cannot be zero!"); - return QRect(); - } -#endif - - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); -} - -/*! \reimp */ QRect QCommonStyle::subRect(SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget) const { QRect rect, wrect(ceData.rect); @@ -1936,28 +1882,6 @@ static int qPositionFromValue( QStyleControlElementData ceData, int logical_val, /*! \reimp */ void QCommonStyle::drawComplexControl( ComplexControl control, QPainter *p, - const QWidget *widget, - const QRect &r, - const QColorGroup &cg, - SFlags flags, - SCFlags controls, - SCFlags active, - const QStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - qWarning("QCommonStyle::drawComplexControl: widget parameter cannot be zero!"); - return; - } -#endif - - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, controls, active, opt, widget); -} - -/*! \reimp */ -void QCommonStyle::drawComplexControl( ComplexControl control, - QPainter *p, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QRect &r, @@ -2360,17 +2284,6 @@ void QCommonStyle::drawComplexControl( ComplexControl control, /*! \reimp */ void QCommonStyle::drawComplexControlMask( ComplexControl control, QPainter *p, - const QWidget *widget, - const QRect &r, - const QStyleOption& opt ) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, opt, widget); -} - -/*! \reimp */ -void QCommonStyle::drawComplexControlMask( ComplexControl control, - QPainter *p, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QRect &r, @@ -2388,23 +2301,6 @@ void QCommonStyle::drawComplexControlMask( ComplexControl control, /*! \reimp */ QRect QCommonStyle::querySubControlMetrics( ComplexControl control, - const QWidget *widget, - SubControl sc, - const QStyleOption &opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - qWarning("QCommonStyle::querySubControlMetrics: widget parameter cannot be zero!"); - return QRect(); - } -#endif - - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false); - return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget); -} - -/*! \reimp */ -QRect QCommonStyle::querySubControlMetrics( ComplexControl control, QStyleControlElementData ceData, ControlElementFlags elementFlags, SubControl sc, @@ -2637,17 +2533,6 @@ QRect QCommonStyle::querySubControlMetrics( ComplexControl control, return QRect(); } - -/*! \reimp */ -QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control, - const QWidget *widget, - const QPoint &pos, - const QStyleOption& opt ) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); -} - /*! \reimp */ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control, QStyleControlElementData ceData, @@ -2724,14 +2609,6 @@ QStyle::SubControl QCommonStyle::querySubControl(ComplexControl control, return ret; } - -/*! \reimp */ -int QCommonStyle::pixelMetric(PixelMetric m, const QWidget *widget) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); -} - /*! \reimp */ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget) const { @@ -2954,25 +2831,6 @@ int QCommonStyle::pixelMetric(PixelMetric m, QStyleControlElementData ceData, Co /*! \reimp */ QSize QCommonStyle::sizeFromContents(ContentsType contents, - const QWidget *widget, - const QSize &contentsSize, - const QStyleOption& opt ) const -{ - QSize sz(contentsSize); - -#if defined(QT_CHECK_STATE) - if (! widget) { - qWarning("QCommonStyle::sizeFromContents: widget parameter cannot be zero!"); - return sz; - } -#endif - - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), contentsSize, opt, widget); -} - -/*! \reimp */ -QSize QCommonStyle::sizeFromContents(ContentsType contents, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QSize &contentsSize, @@ -3143,13 +3001,6 @@ QSize QCommonStyle::sizeFromContents(ContentsType contents, } /*! \reimp */ -int QCommonStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption(), false); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w); -} - -/*! \reimp */ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const { Q_UNUSED(w); @@ -3233,13 +3084,6 @@ int QCommonStyle::styleHint(StyleHint sh, QStyleControlElementData ceData, Contr } /*! \reimp */ -QPixmap QCommonStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const -{ - QStyleControlElementData ceData = populateControlElementDataFromWidget(w, QStyleOption()); - return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, w); -} - -/*! \reimp */ QPixmap QCommonStyle::stylePixmap(StylePixmap, QStyleControlElementData, ControlElementFlags, const QStyleOption&, const QWidget *) const { return QPixmap(); diff --git a/src/styles/qcommonstyle.h b/src/styles/qcommonstyle.h index e6378e6..c445740 100644 --- a/src/styles/qcommonstyle.h +++ b/src/styles/qcommonstyle.h @@ -55,15 +55,6 @@ public: QCommonStyle(); ~QCommonStyle(); - // Old API - // DEPRECATED - void drawPrimitive( PrimitiveElement pe, - QPainter *p, - const QRect &r, - const QColorGroup &cg, - SFlags flags = Style_Default, - const QStyleOption& = QStyleOption::Default ) const; - // New API void drawPrimitive( PrimitiveElement pe, QPainter *p, @@ -74,16 +65,6 @@ public: SFlags flags = Style_Default, const QStyleOption& = QStyleOption::Default ) const; - // Old API - // DEPRECATED - void drawControl( ControlElement element, - QPainter *p, - const QWidget *widget, - const QRect &r, - const QColorGroup &cg, - SFlags how = Style_Default, - const QStyleOption& = QStyleOption::Default ) const; - // New API void drawControl( ControlElement element, QPainter *p, @@ -95,14 +76,6 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - void drawControlMask( ControlElement element, - QPainter *p, - const QWidget *widget, - const QRect &r, - const QStyleOption& = QStyleOption::Default ) const; - // New API void drawControlMask( ControlElement element, QPainter *p, @@ -112,29 +85,9 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - QRect subRect( SubRect r, const QWidget *widget ) const; - // New API QRect subRect( SubRect r, const QStyleControlElementData ceData, const ControlElementFlags elementFlags, const QWidget *widget ) const; - // Old API - // DEPRECATED - void drawComplexControl( ComplexControl control, - QPainter *p, - const QWidget *widget, - const QRect &r, - const QColorGroup &cg, - SFlags how = Style_Default, -#ifdef Q_QDOC - SCFlags sub = SC_All, -#else - SCFlags sub = (uint)SC_All, -#endif - SCFlags subActive = SC_None, - const QStyleOption& = QStyleOption::Default ) const; - // New API void drawComplexControl( ComplexControl control, QPainter *p, @@ -152,14 +105,6 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - void drawComplexControlMask( ComplexControl control, - QPainter *p, - const QWidget *widget, - const QRect &r, - const QStyleOption& = QStyleOption::Default ) const; - // New API void drawComplexControlMask( ComplexControl control, QPainter *p, @@ -169,13 +114,6 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - QRect querySubControlMetrics( ComplexControl control, - const QWidget *widget, - SubControl sc, - const QStyleOption& = QStyleOption::Default ) const; - // New API QRect querySubControlMetrics( ComplexControl control, QStyleControlElementData ceData, @@ -184,13 +122,6 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - SubControl querySubControl( ComplexControl control, - const QWidget *widget, - const QPoint &pos, - const QStyleOption& = QStyleOption::Default ) const; - // New API SubControl querySubControl( ComplexControl control, QStyleControlElementData ceData, @@ -199,20 +130,9 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - int pixelMetric( PixelMetric m, const QWidget *widget = 0 ) const; - // New API int pixelMetric( PixelMetric m, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - QSize sizeFromContents( ContentsType s, - const QWidget *widget, - const QSize &contentsSize, - const QStyleOption& = QStyleOption::Default ) const; - // New API QSize sizeFromContents( ContentsType s, QStyleControlElementData ceData, @@ -221,19 +141,9 @@ public: const QStyleOption& = QStyleOption::Default, const QWidget *widget = 0 ) const; - // Old API - // DEPRECATED - int styleHint(StyleHint sh, const QWidget *, const QStyleOption &, QStyleHintReturn *) const; - // New API int styleHint(StyleHint sh, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QStyleOption &, QStyleHintReturn *, const QWidget * w) const; - // Old API - // DEPRECATED - QPixmap stylePixmap( StylePixmap sp, - const QWidget *widget = 0, - const QStyleOption& = QStyleOption::Default ) const; - // New API QPixmap stylePixmap( StylePixmap sp, QStyleControlElementData ceData, diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index 4c6a0c8..e91e0d0 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -1907,11 +1907,12 @@ QRect QMotifStyle::subRect( SubRect r, QStyleControlElementData ceData, ControlE /*! \reimp */ -void QMotifStyle::polishPopupMenu( QPopupMenu* p) +void QMotifStyle::polishPopupMenu( QStyleControlElementData 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/qmotifstyle.h b/src/styles/qmotifstyle.h index 213795f..31ec525 100644 --- a/src/styles/qmotifstyle.h +++ b/src/styles/qmotifstyle.h @@ -70,7 +70,7 @@ public: void polish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void applicationPolish( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); - void polishPopupMenu( QPopupMenu* ); + void polishPopupMenu( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); // new style API void drawPrimitive( PrimitiveElement pe, diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index ec05b80..4bdb421 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -1155,11 +1155,12 @@ QSize QWindowsStyle::sizeFromContents( ContentsType contents, /*! \reimp */ -void QWindowsStyle::polishPopupMenu( QPopupMenu* p) +void QWindowsStyle::polishPopupMenu( QStyleControlElementData 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 } diff --git a/src/styles/qwindowsstyle.h b/src/styles/qwindowsstyle.h index d768a04..4ffc849 100644 --- a/src/styles/qwindowsstyle.h +++ b/src/styles/qwindowsstyle.h @@ -69,7 +69,7 @@ public: void polish( QPalette & ); - virtual void polishPopupMenu( QPopupMenu* ); + virtual void polishPopupMenu( QStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); // new stuff void drawPrimitive( PrimitiveElement pe, |