diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-05 01:00:53 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-08-05 01:00:53 -0500 |
commit | 0008bc5bcd95694b38b0d0322aac2ea6fdb21298 (patch) | |
tree | e36a2a63a9784451af847fc952b281969cb8c0c0 /src/styles/qsgistyle.cpp | |
parent | ebcb1d80bf517aceb69778e1e9f67e5f4da8c484 (diff) | |
download | qt3-0008bc5bcd95694b38b0d0322aac2ea6fdb21298.tar.gz qt3-0008bc5bcd95694b38b0d0322aac2ea6fdb21298.zip |
Update style API to function without an active widget object
Diffstat (limited to 'src/styles/qsgistyle.cpp')
-rw-r--r-- | src/styles/qsgistyle.cpp | 220 |
1 files changed, 111 insertions, 109 deletions
diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index 1bfc113..5695348 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -254,7 +254,7 @@ QSGIStyle::polish( QWidget* w ) #endif #ifndef QT_NO_POPUPMENU } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) + 1 ); + ((QFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) + 1 ); QFont f = QApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); @@ -273,7 +273,7 @@ QSGIStyle::unPolish( QWidget* w ) w->removeEventFilter( this ); #ifndef QT_NO_POPUPMENU } else if ( ::qt_cast<QPopupMenu*>(w) ) { - ((QFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) ); + ((QFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, QStyleControlElementData(), CEF_None ) ); w->setFont( QApplication::font() ); #endif #if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX) @@ -375,7 +375,7 @@ static const int sgiTabSpacing = 12; // space between text and tab static const int sgiCheckMarkSpace = 20; /*! \reimp */ -int QSGIStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const +int QSGIStyle::pixelMetric( PixelMetric metric, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget ) const { switch ( metric ) { case PM_DefaultFrameWidth: @@ -401,7 +401,7 @@ int QSGIStyle::pixelMetric( PixelMetric metric, const QWidget *widget ) const default: break; } - return QMotifStyle::pixelMetric( metric, widget ); + return QMotifStyle::pixelMetric( metric, ceData, elementFlags, widget ); } static void drawPanel( QPainter *p, int x, int y, int w, int h, @@ -552,6 +552,8 @@ static void get_combo_parameters( const QRect &r, /*! \reimp */ void QSGIStyle::drawPrimitive( PrimitiveElement pe, QPainter *p, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags flags, @@ -562,7 +564,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, const int w = r.width(); const int h = r.height(); const bool sunken = flags & ( Style_Sunken | Style_Down | Style_On ); - const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth ); + const int defaultFrameWidth = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags ); bool hot = ( flags & Style_MouseOver ) && ( flags & Style_Enabled ); switch ( pe ) { @@ -588,7 +590,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, case PE_ButtonBevel: case PE_ButtonTool: { - drawPrimitive( PE_ButtonCommand, p, QRect( x+1, y+1, w-2, h-2 ), cg, flags, opt ); + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, QRect( x+1, y+1, w-2, h-2 ), cg, flags, opt ); QPen oldPen = p->pen(); QPointArray a; @@ -642,11 +644,11 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, QRect er = r; er.addCoords( 1, 1, -1, -1 ); int iflags = flags & ~Style_On; - drawPrimitive( PE_ButtonBevel, p, er, cg, iflags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, iflags, opt ); if ( !(flags & QStyle::Style_Off) ) { er = r; er.addCoords( 1, 2, 1, 1 ); - drawPrimitive( PE_CheckMark, p, er, cg, flags, opt ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, flags, opt ); } } break; @@ -795,17 +797,17 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, case PE_ScrollBarSubLine: if ( !r.contains( d->mousePos ) && !(flags & Style_Active) ) flags &= ~Style_MouseOver; - drawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt ); + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags, opt ); drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp), - p, r, cg, Style_Enabled | flags); + p, ceData, elementFlags, r, cg, Style_Enabled | flags); break; case PE_ScrollBarAddLine: if ( !r.contains( d->mousePos ) ) flags &= ~Style_MouseOver; - drawPrimitive( PE_ButtonCommand, p, r, cg, flags, opt ); + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags, opt ); drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown), - p, r, cg, Style_Enabled | flags); + p, ceData, elementFlags, r, cg, Style_Enabled | flags); break; case PE_ScrollBarSubPage: @@ -825,7 +827,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, QPixmap pm( r.width(), r.height() ); QPainter bp( &pm ); - drawPrimitive(PE_ButtonBevel, &bp, QRect(0,0,r.width(),r.height()), cg, flags | Style_Enabled | Style_Raised); + drawPrimitive(PE_ButtonBevel, &bp, ceData, elementFlags, QRect(0,0,r.width(),r.height()), cg, flags | Style_Enabled | Style_Raised); if ( flags & Style_Horizontal ) { const int sliderM = r.width() / 2; if ( r.width() > 20 ) { @@ -853,7 +855,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, case PE_Splitter: { const int motifOffset = 10; - int sw = pixelMetric( PM_SplitterWidth ); + int sw = pixelMetric( PM_SplitterWidth, ceData, elementFlags ); if ( flags & Style_Horizontal ) { int xPos = x + w/2; int kPos = motifOffset; @@ -862,7 +864,7 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, qDrawShadeLine( p, xPos, kPos + kSize - 1 , xPos, h, cg ); - drawPrimitive( PE_ButtonBevel, p, QRect(xPos-sw/2+1, kPos, kSize, kSize+1), cg, flags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, QRect(xPos-sw/2+1, kPos, kSize, kSize+1), cg, flags, opt ); qDrawShadeLine( p, xPos+2, 0, xPos, kPos, cg ); } else { int yPos = y + h/2; @@ -870,14 +872,14 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, int kSize = sw - 2; qDrawShadeLine( p, 0, yPos, kPos, yPos, cg ); - drawPrimitive( PE_ButtonBevel, p, QRect( kPos, yPos-sw/2+1, kSize+1, kSize ), cg, flags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, QRect( kPos, yPos-sw/2+1, kSize+1, kSize ), cg, flags, opt ); qDrawShadeLine( p, kPos + kSize+1, yPos, w, yPos, cg ); } } break; default: - QMotifStyle::drawPrimitive( pe, p, r, cg, flags, opt ); + QMotifStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; } } @@ -885,11 +887,13 @@ void QSGIStyle::drawPrimitive( PrimitiveElement pe, /*! \reimp */ void QSGIStyle::drawControl( ControlElement element, QPainter *p, - const QWidget *widget, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QRect &r, const QColorGroup &cg, SFlags flags, - const QStyleOption& opt ) const + const QStyleOption& opt, + const QWidget *widget ) const { if ( widget == d->hotWidget ) flags |= Style_MouseOver; @@ -898,17 +902,16 @@ void QSGIStyle::drawControl( ControlElement element, case CE_PushButton: { #ifndef QT_NO_PUSHBUTTON - const QPushButton *btn = (QPushButton*)widget; int x1, y1, x2, y2; r.coords( &x1, &y1, &x2, &y2 ); p->setPen( cg.foreground() ); p->setBrush( QBrush( cg.button(),Qt::NoBrush ) ); - p->setBrushOrigin( -widget->backgroundOffset().x(), - -widget->backgroundOffset().y() ); + p->setBrushOrigin( -ceData.bgOffset.x(), + -ceData.bgOffset.y() ); - int diw = pixelMetric( QStyle::PM_ButtonDefaultIndicator ); - if ( btn->isDefault() || btn->autoDefault() ) { + int diw = pixelMetric( QStyle::PM_ButtonDefaultIndicator, ceData, elementFlags ); + if ( ( elementFlags & CEF_IsDefault ) || ( elementFlags & CEF_AutoDefault ) ) { x1 += diw; y1 += diw; x2 -= diw; @@ -916,7 +919,7 @@ void QSGIStyle::drawControl( ControlElement element, } QPointArray a; - if ( btn->isDefault() ) { + if ( elementFlags & CEF_IsDefault ) { if ( diw == 0 ) { a.setPoints( 9, x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1, @@ -928,13 +931,13 @@ void QSGIStyle::drawControl( ControlElement element, x2 -= 2; y2 -= 2; } else { - qDrawShadePanel( p, btn->rect(), cg, TRUE ); + qDrawShadePanel( p, ceData.rect, cg, TRUE ); } } QBrush fill = cg.brush( QColorGroup::Button ); - if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) - drawPrimitive( PE_ButtonBevel, p, QRect( x1, y1, x2-x1+1, y2-y1+1 ), cg, flags, opt ); + if ( (!( elementFlags & CEF_IsFlat )) || ( elementFlags & CEF_IsOn ) || ( elementFlags & CEF_IsDown ) ) + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, QRect( x1, y1, x2-x1+1, y2-y1+1 ), cg, flags, opt ); if ( p->brush().style() != Qt::NoBrush ) p->setBrush( Qt::NoBrush ); @@ -945,16 +948,15 @@ void QSGIStyle::drawControl( ControlElement element, case CE_PopupMenuItem: { #ifndef QT_NO_POPUPMENU - if (! widget || opt.isDefault()) + if ( ( elementFlags & CEF_UseGenericParameters ) || opt.isDefault()) break; QMenuItem *mi = opt.menuItem(); if ( !mi ) break; - const QPopupMenu *popupmenu = (const QPopupMenu *) widget; int tab = opt.tabWidth(); int maxpmw = opt.maxIconWidth(); bool dis = ! (flags & Style_Enabled); - bool checkable = popupmenu->isCheckable(); + bool checkable = ( elementFlags & CEF_IsCheckable ); bool act = flags & Style_Active; int x, y, w, h; @@ -973,7 +975,7 @@ void QSGIStyle::drawControl( ControlElement element, int pw = sgiItemFrame; if ( act && !dis ) { - if ( pixelMetric( PM_DefaultFrameWidth ) > 1 ) + if ( pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags ) > 1 ) drawPanel( p, x, y, w, h, cg, FALSE, pw, &cg.brush( QColorGroup::Light ) ); else @@ -1024,12 +1026,12 @@ void QSGIStyle::drawControl( ControlElement element, if ( mi->isChecked() ) { QRect er( x+sgiItemFrame+1, y+sgiItemFrame+3, - pixelMetric(PM_IndicatorWidth), - pixelMetric(PM_IndicatorHeight) ); + pixelMetric(PM_IndicatorWidth, ceData, elementFlags), + pixelMetric(PM_IndicatorHeight, ceData, elementFlags) ); er.addCoords( 1, 1, -1, -1 ); - drawPrimitive( PE_ButtonBevel, p, er, cg, cflags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, er, cg, cflags, opt ); er.addCoords( 0, 1, 1, 1 ); - drawPrimitive( PE_CheckMark, p, er, cg, cflags | Style_On, opt ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, er, cg, cflags | Style_On, opt ); } } } @@ -1082,7 +1084,7 @@ void QSGIStyle::drawControl( ControlElement element, } if ( mi->popup() ) { int dim = (h-2*sgiItemFrame) / 2; - drawPrimitive( PE_ArrowRight, p, QRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags ); + drawPrimitive( PE_ArrowRight, p, ceData, elementFlags, QRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags ); } #endif } @@ -1128,11 +1130,11 @@ void QSGIStyle::drawControl( ControlElement element, break; case CE_CheckBox: - QMotifStyle::drawControl( element, p, widget, r, cg, flags, opt ); + QMotifStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget ); break; default: - QMotifStyle::drawControl( element, p, widget, r, cg, flags, opt ); + QMotifStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget ); break; } } @@ -1140,13 +1142,15 @@ void QSGIStyle::drawControl( ControlElement element, /*! \reimp */ void QSGIStyle::drawComplexControl( ComplexControl control, QPainter *p, - const QWidget* widget, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QRect& r, const QColorGroup& cg, SFlags flags, SCFlags sub, SCFlags subActive, - const QStyleOption& opt ) const + const QStyleOption& opt, + const QWidget* widget ) const { if ( widget == d->hotWidget ) flags |= Style_MouseOver; @@ -1155,33 +1159,31 @@ void QSGIStyle::drawComplexControl( ComplexControl control, case CC_Slider: { #ifndef QT_NO_SLIDER - const QSlider * slider = (const QSlider *) widget; - - QRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, - opt), - handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, - opt); + QRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, + opt, widget), + handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, + opt, widget); if ((sub & SC_SliderGroove) && groove.isValid()) { QRegion region( groove ); if ( ( sub & SC_SliderHandle ) && handle.isValid() ) region = region.subtract( handle ); - if ( d->lastSliderRect.slider == slider && d->lastSliderRect.rect.isValid() ) + if ( d->lastSliderRect.slider == widget && d->lastSliderRect.rect.isValid() ) region = region.subtract( d->lastSliderRect.rect ); p->setClipRegion( region ); QRect grooveTop = groove; grooveTop.addCoords( 1, 1, -1, -1 ); - drawPrimitive( PE_ButtonBevel, p, grooveTop, cg, flags & ~Style_MouseOver, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, grooveTop, cg, flags & ~Style_MouseOver, opt ); if ( flags & Style_HasFocus ) { - QRect fr = subRect( SR_SliderFocusRect, widget ); - drawPrimitive( PE_FocusRect, p, fr, cg, flags & ~Style_MouseOver ); + QRect fr = subRect( SR_SliderFocusRect, ceData, elementFlags, widget ); + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, fr, cg, flags & ~Style_MouseOver ); } - if ( d->lastSliderRect.slider == slider && d->lastSliderRect.rect.isValid() ) { + if ( d->lastSliderRect.slider == widget && d->lastSliderRect.rect.isValid() ) { if ( ( sub & SC_SliderHandle ) && handle.isValid() ) { - region = widget->rect(); + region = ceData.rect; region = region.subtract( handle ); p->setClipRegion( region ); } else { @@ -1195,9 +1197,9 @@ void QSGIStyle::drawComplexControl( ComplexControl control, if (( sub & SC_SliderHandle ) && handle.isValid()) { if ( flags & Style_MouseOver && !handle.contains( d->mousePos ) && subActive != SC_SliderHandle ) flags &= ~Style_MouseOver; - drawPrimitive( PE_ButtonBevel, p, handle, cg, flags ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, handle, cg, flags ); - if ( slider->orientation() == Horizontal ) { + if ( ceData.orientation == Horizontal ) { QCOORD mid = handle.x() + handle.width() / 2; qDrawShadeLine( p, mid, handle.y(), mid, handle.y() + handle.height() - 2, @@ -1211,50 +1213,48 @@ void QSGIStyle::drawComplexControl( ComplexControl control, } if ( sub & SC_SliderTickmarks ) - QMotifStyle::drawComplexControl( control, p, widget, r, cg, flags, + QMotifStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, SC_SliderTickmarks, subActive, - opt ); + opt, widget ); #endif break; } case CC_ComboBox: { #ifndef QT_NO_COMBOBOX - const QComboBox * cb = (QComboBox *) widget; - if (sub & SC_ComboBoxFrame) { QRect fr = - QStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, - SC_ComboBoxFrame ), cb ); - drawPrimitive( PE_ButtonBevel, p, fr, cg, flags ); + QStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxFrame, QStyleOption::Default, widget ), ceData, elementFlags ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, fr, cg, flags ); } if ( sub & SC_ComboBoxArrow ) { p->save(); QRect er = - QStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow ), cb ); + QStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, QStyleOption::Default, widget ), ceData, elementFlags ); er.addCoords( 0, 3, 0, 0 ); - drawPrimitive( PE_ArrowDown, p, er, cg, flags | Style_Enabled, opt ); + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, er, cg, flags | Style_Enabled, opt ); int awh, ax, ay, sh, sy, dh, ew; - get_combo_parameters( widget->rect(), ew, awh, ax, ay, sh, dh, sy ); + get_combo_parameters( ceData.rect, ew, awh, ax, ay, sh, dh, sy ); QBrush arrow = cg.brush( QColorGroup::Dark ); p->fillRect( ax, sy-1, awh, sh, arrow ); p->restore(); - if ( cb->hasFocus() ) { - QRect re = QStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), cb ); - drawPrimitive( PE_FocusRect, p, re, cg ); + if ( elementFlags & CEF_HasFocus ) { + QRect re = QStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), ceData, elementFlags ); + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg ); } } if ( sub & SC_ComboBoxEditField ) { - if ( cb->editable() ) { + if ( elementFlags & CEF_IsEditable ) { QRect er = - QStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, - SC_ComboBoxEditField ), cb ); + QStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, QStyleOption::Default, widget ), ceData, elementFlags ); er.addCoords( -1, -1, 1, 1); qDrawShadePanel( p, QRect( er.x()-1, er.y()-1, er.width()+2, er.height()+2 ), @@ -1269,27 +1269,26 @@ void QSGIStyle::drawComplexControl( ComplexControl control, case CC_ScrollBar: { #ifndef QT_NO_SCROLLBAR - QScrollBar *scrollbar = (QScrollBar*)widget; - bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); + bool maxedOut = (ceData.minSteps == ceData.maxSteps); if ( maxedOut ) flags &= ~Style_Enabled; - QRect handle = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSlider, opt ), widget ); + QRect handle = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarSlider, opt, widget ), ceData, elementFlags ); if ( sub & SC_ScrollBarGroove ) { } if ( sub & SC_ScrollBarAddLine ) { - QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddLine, opt ), widget ); - drawPrimitive( PE_ScrollBarAddLine, p, er, cg, flags, opt ); + QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarAddLine, opt, widget ), ceData, elementFlags ); + drawPrimitive( PE_ScrollBarAddLine, p, ceData, elementFlags, er, cg, flags, opt ); } if ( sub & SC_ScrollBarSubLine ) { - QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubLine, opt ), widget ); - drawPrimitive( PE_ScrollBarSubLine, p, er, cg, flags, opt ); + QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarSubLine, opt, widget ), ceData, elementFlags ); + drawPrimitive( PE_ScrollBarSubLine, p, ceData, elementFlags, er, cg, flags, opt ); } if ( sub & SC_ScrollBarAddPage ) { - QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddPage, opt ), widget ); + QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget ), ceData, elementFlags ); QRegion region( er ); - if ( d->lastScrollbarRect.scrollbar == scrollbar && + if ( d->lastScrollbarRect.scrollbar == widget && d->lastScrollbarRect.rect.isValid() && er.intersects( d->lastScrollbarRect.rect ) ) { region = region.subtract( d->lastScrollbarRect.rect ); @@ -1300,9 +1299,9 @@ void QSGIStyle::drawComplexControl( ComplexControl control, p->setClipRegion( region ); } - drawPrimitive( PE_ScrollBarAddPage, p, er, cg, flags & ~Style_MouseOver, opt ); + drawPrimitive( PE_ScrollBarAddPage, p, ceData, elementFlags, er, cg, flags & ~Style_MouseOver, opt ); - if ( d->lastScrollbarRect.scrollbar == scrollbar && + if ( d->lastScrollbarRect.scrollbar == widget && d->lastScrollbarRect.rect.isValid() && er.intersects( d->lastScrollbarRect.rect ) ) { if ( sub & SC_ScrollBarSlider && handle.isValid() ) { @@ -1317,9 +1316,9 @@ void QSGIStyle::drawComplexControl( ComplexControl control, p->setClipping( FALSE ); } if ( sub & SC_ScrollBarSubPage ) { - QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubPage, opt ), widget ); + QRect er = QStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget ), ceData, elementFlags ); QRegion region( er ); - if ( d->lastScrollbarRect.scrollbar == scrollbar && + if ( d->lastScrollbarRect.scrollbar == widget && d->lastScrollbarRect.rect.isValid() && er.intersects( d->lastScrollbarRect.rect ) ) { region = region.subtract( d->lastScrollbarRect.rect ); @@ -1329,8 +1328,8 @@ void QSGIStyle::drawComplexControl( ComplexControl control, region = region.subtract( handle ); p->setClipRegion( region ); } - drawPrimitive( PE_ScrollBarSubPage, p, er, cg, flags & ~Style_MouseOver, opt ); - if ( d->lastScrollbarRect.scrollbar == scrollbar && + drawPrimitive( PE_ScrollBarSubPage, p, ceData, elementFlags, er, cg, flags & ~Style_MouseOver, opt ); + if ( d->lastScrollbarRect.scrollbar == widget && d->lastScrollbarRect.rect.isValid() && er.intersects( d->lastScrollbarRect.rect ) ) { if ( sub & SC_ScrollBarSlider && handle.isValid() ) { @@ -1349,14 +1348,14 @@ void QSGIStyle::drawComplexControl( ComplexControl control, if ( subActive == SC_ScrollBarSlider ) flags |= Style_Active; - drawPrimitive( PE_ScrollBarSlider, p, handle, cg, flags, opt ); + drawPrimitive( PE_ScrollBarSlider, p, ceData, elementFlags, handle, cg, flags, opt ); } #endif } break; default: - QMotifStyle::drawComplexControl( control, p, widget, r, cg, flags, sub, subActive, opt ); +// QMotifStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget ); break; } } @@ -1364,9 +1363,11 @@ void QSGIStyle::drawComplexControl( ComplexControl control, /*!\reimp */ QSize QSGIStyle::sizeFromContents( ContentsType contents, - const QWidget *widget, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, const QSize &contentsSize, - const QStyleOption& opt ) const + const QStyleOption& opt, + const QWidget *widget ) const { QSize sz(contentsSize); @@ -1374,15 +1375,14 @@ QSize QSGIStyle::sizeFromContents( ContentsType contents, case CT_PopupMenuItem: { #ifndef QT_NO_POPUPMENU - if (! widget || opt.isDefault()) + if ((elementFlags & CEF_UseGenericParameters) || opt.isDefault()) break; QMenuItem *mi = opt.menuItem(); - sz = QMotifStyle::sizeFromContents( contents, widget, contentsSize, - opt ); + sz = QMotifStyle::sizeFromContents( contents, ceData, elementFlags, contentsSize, + opt, widget ); // SGI checkmark items needs a bit more room - const QPopupMenu *popup = (QPopupMenu *) widget; - if ( popup && popup->isCheckable() ) + if ( elementFlags & CEF_IsCheckable ) sz.setWidth( sz.width() + 8 ); // submenu indicator needs a bit more room if (mi->popup()) @@ -1395,7 +1395,7 @@ QSize QSGIStyle::sizeFromContents( ContentsType contents, break; default: - sz = QMotifStyle::sizeFromContents( contents, widget, contentsSize, opt ); + sz = QMotifStyle::sizeFromContents( contents, ceData, elementFlags, contentsSize, opt, widget ); break; } @@ -1403,7 +1403,7 @@ QSize QSGIStyle::sizeFromContents( ContentsType contents, } /*! \reimp */ -QRect QSGIStyle::subRect( SubRect r, const QWidget *widget ) const +QRect QSGIStyle::subRect( SubRect r, QStyleControlElementData ceData, ControlElementFlags elementFlags, const QWidget *widget ) const { QRect rect; @@ -1411,8 +1411,8 @@ QRect QSGIStyle::subRect( SubRect r, const QWidget *widget ) const case SR_ComboBoxFocusRect: { int awh, ax, ay, sh, sy, dh, ew; - int fw = pixelMetric( PM_DefaultFrameWidth, widget ); - QRect tr = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + QRect tr = ceData.rect; tr.addCoords( fw, fw, -fw, -fw ); get_combo_parameters( tr, ew, awh, ax, ay, sh, dh, sy ); @@ -1420,7 +1420,7 @@ QRect QSGIStyle::subRect( SubRect r, const QWidget *widget ) const } break; default: - return QMotifStyle::subRect( r, widget ); + return QMotifStyle::subRect( r, ceData, elementFlags, widget ); } return rect; @@ -1428,27 +1428,29 @@ QRect QSGIStyle::subRect( SubRect r, const QWidget *widget ) const /*! \reimp */ QRect QSGIStyle::querySubControlMetrics( ComplexControl control, - const QWidget *widget, + QStyleControlElementData ceData, + ControlElementFlags elementFlags, SubControl sub, - const QStyleOption& opt ) const + const QStyleOption& opt, + const QWidget *widget ) const { switch ( control ) { case CC_ComboBox: switch ( sub ) { case SC_ComboBoxFrame: - return widget->rect(); + return ceData.rect; case SC_ComboBoxArrow: { int ew, awh, sh, dh, ax, ay, sy; - int fw = pixelMetric( PM_DefaultFrameWidth, widget ); - QRect cr = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + QRect cr = ceData.rect; cr.addCoords( fw, fw, -fw, -fw ); get_combo_parameters( cr, ew, awh, ax, ay, sh, dh, sy ); return QRect( ax, ay, awh, awh ); } case SC_ComboBoxEditField: { - int fw = pixelMetric( PM_DefaultFrameWidth, widget ); - QRect rect = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + QRect rect = ceData.rect; rect.addCoords( fw, fw, -fw, -fw ); int ew = get_combo_extra_width( rect.height() ); rect.addCoords( 1, 1, -1-ew, -1 ); @@ -1459,10 +1461,10 @@ QRect QSGIStyle::querySubControlMetrics( ComplexControl control, } break; case CC_ScrollBar: - return QCommonStyle::querySubControlMetrics( control, widget, sub, opt ); + return QCommonStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); default: break; } - return QMotifStyle::querySubControlMetrics( control, widget, sub, opt ); + return QMotifStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); } #endif // QT_NO_STYLE_SGI |