diff options
Diffstat (limited to 'src/styles')
-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 |
6 files changed, 36 insertions, 280 deletions
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, |