diff options
Diffstat (limited to 'src/styles/qsgistyle.cpp')
-rw-r--r-- | src/styles/qsgistyle.cpp | 340 |
1 files changed, 171 insertions, 169 deletions
diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index 86dcef363..930a34d09 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -65,7 +65,7 @@ struct SliderLastPosition { SliderLastPosition() : rect(0,-1,0,-1), slider(0) {} TQRect rect; - const TQSlider* slider; + const void* slider; }; #endif @@ -74,7 +74,7 @@ struct ScrollbarLastPosition { ScrollbarLastPosition() : rect( 0,-1, 0,-1 ), scrollbar(0) {} TQRect rect; - const TQScrollBar *scrollbar; + const void* scrollbar; }; #endif @@ -86,7 +86,7 @@ public: { } - const TQWidget *hotWidget; + const void* hotWidget; TQPoint mousePos; #ifndef QT_NO_SCROLLBAR ScrollbarLastPosition lastScrollbarRect; @@ -136,10 +136,10 @@ TQSGIStyle::~TQSGIStyle() bold italic font for menu options. */ void -TQSGIStyle::polish( TQApplication* app) +TQSGIStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { isApplicationStyle = 1; - TQMotifStyle::polish( app ); + TQMotifStyle::polish( ceData, elementFlags, ptr ); TQPalette pal = TQApplication::palette(); // check this on SGI-Boxes @@ -181,7 +181,7 @@ TQSGIStyle::polish( TQApplication* app) /*! \reimp */ void -TQSGIStyle::unPolish( TQApplication* /* app */ ) +TQSGIStyle::applicationUnPolish( TQStyleControlElementData, ControlElementFlags, void * ) { TQFont f = TQApplication::font(); TQApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes @@ -194,9 +194,9 @@ TQSGIStyle::unPolish( TQApplication* /* app */ ) hovering. */ void -TQSGIStyle::polish( TQWidget* w ) +TQSGIStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - TQMotifStyle::polish(w); + TQMotifStyle::polish(ceData, elementFlags, ptr); if ( !isApplicationStyle ) { TQPalette sgiPal = TQApplication::palette(); @@ -214,7 +214,7 @@ TQSGIStyle::polish( TQWidget* w ) sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().base() ); } - if ( ::tqt_cast<TQLineEdit*>(w) || ::tqt_cast<TQTextEdit*>(w) ) { + if ( (ceData.widgetObjectTypes.contains("TQLineEdit")) || (ceData.widgetObjectTypes.contains("TQTextEdit")) ) { // different basecolor and highlighting in Q(Multi)LineEdit sgiPal.setColor( TQColorGroup::Base, TQColor(211,181,181) ); sgiPal.setColor( TQPalette::Active, TQColorGroup::Highlight, sgiPal.active().midlight() ); @@ -224,89 +224,89 @@ TQSGIStyle::polish( TQWidget* w ) sgiPal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, sgiPal.disabled().midlight() ); sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().text() ); - } else if ( ::tqt_cast<TQMenuBar*>(w) || ::tqt_cast<TQToolBar*>(w) ) { + } else if ( (ceData.widgetObjectTypes.contains("TQMenuBar")) || (ceData.widgetObjectTypes.contains("TQToolBar")) ) { sgiPal.setColor( TQColorGroup::Button, sgiPal.active().midlight() ); } - w->setPalette( sgiPal ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetPalette, TQStyleWidgetActionRequestData(sgiPal)); } - if ( ::tqt_cast<TQButton*>(w) || ::tqt_cast<TQSlider*>(w) || ::tqt_cast<TQScrollBar*>(w) ) { - w->installEventFilter( this ); - w->setMouseTracking( TRUE ); + if ( (ceData.widgetObjectTypes.contains("TQButton")) || (ceData.widgetObjectTypes.contains("TQSlider")) || (ceData.widgetObjectTypes.contains("TQScrollBar")) ) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); #ifndef QT_NO_SCROLLBAR - if ( ::tqt_cast<TQScrollBar*>(w) ) - w->setBackgroundMode( TQWidget::NoBackground ); + if ( ceData.widgetObjectTypes.contains("TQScrollBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::NoBackground)); + } #endif - } else if ( ::tqt_cast<TQComboBox*>(w) ) { + } else if ( ceData.widgetObjectTypes.contains("TQComboBox") ) { TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #ifndef QT_NO_MENUBAR - } else if ( ::tqt_cast<TQMenuBar*>(w) ) { - ((TQFrame*) w)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised); - w->setBackgroundMode( TQWidget::PaletteBackground ); + } else if ( ceData.widgetObjectTypes.contains("TQMenuBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, TQStyleWidgetActionRequestData(TQFrame::StyledPanel | TQFrame::Raised)); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::PaletteBackground)); TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #endif #ifndef QT_NO_POPUPMENU - } else if ( ::tqt_cast<TQPopupMenu*>(w) ) { - ((TQFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) + 1 ); + } else if ( ceData.widgetObjectTypes.contains("TQPopupMenu") ) { + TQStyleWidgetActionRequestData requestData; + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, TQStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ) + 1)); TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #endif - } else if ( ::tqt_cast<TQToolBar*>(w) || w->inherits("TQToolBarSeparator") ) { - w->setBackgroundMode( TQWidget::PaletteBackground ); + } else if ( (ceData.widgetObjectTypes.contains("TQToolBar")) || (ceData.widgetObjectTypes.contains("TQToolBarSeparator")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::PaletteBackground)); } } /*! \reimp */ void -TQSGIStyle::unPolish( TQWidget* w ) +TQSGIStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if ( ::tqt_cast<TQButton*>(w) || ::tqt_cast<TQSlider*>(w) || ::tqt_cast<TQScrollBar*>(w) ) { - w->removeEventFilter( this ); + if ( (ceData.widgetObjectTypes.contains("TQButton")) || (ceData.widgetObjectTypes.contains("TQSlider")) || (ceData.widgetObjectTypes.contains("TQScrollBar")) ) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); #ifndef QT_NO_POPUPMENU - } else if ( ::tqt_cast<TQPopupMenu*>(w) ) { - ((TQFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth ) ); - w->setFont( TQApplication::font() ); + } else if ( ceData.widgetObjectTypes.contains("TQPopupMenu") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, TQStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ))); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(TQApplication::font())); #endif #if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX) - } else if ( ::tqt_cast<TQMenuBar*>(w) || ::tqt_cast<TQComboBox*>(w) ) { - w->setFont( TQApplication::font() ); + } else if ( (ceData.widgetObjectTypes.contains("TQMenuBar")) || (ceData.widgetObjectTypes.contains("TQComboBox")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(TQApplication::font())); #endif } } /*! \reimp */ -bool TQSGIStyle::eventFilter( TQObject* o, TQEvent* e ) +bool TQSGIStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { - if ( !o->isWidgetType() || e->type() == TQEvent::Paint ) - return TQMotifStyle::eventFilter( o, e ); - - TQWidget *widget = (TQWidget*)o; + if ( (!(ceData.widgetObjectTypes.contains("TQWidget"))) || (e->type() == TQEvent::Paint) ) + return TQMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); switch ( e->type() ) { case TQEvent::MouseButtonPress: { #ifndef QT_NO_SCROLLBAR - if ( ::tqt_cast<TQScrollBar*>(widget) ) { - d->lastScrollbarRect.rect = ((TQScrollBar*)widget)->sliderRect(); - d->lastScrollbarRect.scrollbar = ((TQScrollBar*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("TQScrollBar")) { + d->lastScrollbarRect.rect = ceData.sliderRect; + d->lastScrollbarRect.scrollbar = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } else #endif { #ifndef QT_NO_SLIDER - if ( ::tqt_cast<TQSlider*>(widget) ) { - d->lastSliderRect.rect = ((TQSlider*)widget)->sliderRect(); - d->lastSliderRect.slider = ((TQSlider*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("TQSlider")) { + d->lastSliderRect.rect = ceData.sliderRect; + d->lastSliderRect.slider = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } #endif } @@ -317,52 +317,52 @@ bool TQSGIStyle::eventFilter( TQObject* o, TQEvent* e ) { if ( 0 ) { #ifndef QT_NO_SCROLLBAR - } else if ( ::tqt_cast<TQScrollBar*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("TQScrollBar")) { TQRect oldRect = d->lastScrollbarRect.rect; d->lastScrollbarRect.rect = TQRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, TQStyleWidgetActionRequestData(oldRect)); #endif #ifndef QT_NO_SLIDER - } else if ( ::tqt_cast<TQSlider*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("TQSlider")) { TQRect oldRect = d->lastSliderRect.rect; d->lastSliderRect.rect = TQRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, TQStyleWidgetActionRequestData(oldRect)); #endif } } break; case TQEvent::MouseMove: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; if ( ((TQMouseEvent*)e)->button() ) break; - d->hotWidget = widget; + d->hotWidget = source; d->mousePos = ((TQMouseEvent*)e)->pos(); - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case TQEvent::Enter: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - d->hotWidget = widget; - widget->repaint( FALSE ); + d->hotWidget = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case TQEvent::Leave: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - if ( widget == d->hotWidget) { + if ( source == d->hotWidget) { d->hotWidget = 0; - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } break; default: break; } - return TQMotifStyle::eventFilter( o, e ); + return TQMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); } static const int sgiItemFrame = 2; // menu item frame width @@ -375,7 +375,7 @@ static const int sgiTabSpacing = 12; // space between text and tab static const int sgiCheckMarkSpace = 20; /*! \reimp */ -int TQSGIStyle::pixelMetric( PixelMetric metric, const TQWidget *widget ) const +int TQSGIStyle::pixelMetric( PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget ) const { switch ( metric ) { case PM_DefaultFrameWidth: @@ -401,7 +401,7 @@ int TQSGIStyle::pixelMetric( PixelMetric metric, const TQWidget *widget ) const default: break; } - return TQMotifStyle::pixelMetric( metric, widget ); + return TQMotifStyle::pixelMetric( metric, ceData, elementFlags, widget ); } static void drawPanel( TQPainter *p, int x, int y, int w, int h, @@ -552,6 +552,8 @@ static void get_combo_parameters( const TQRect &r, /*! \reimp */ void TQSGIStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, @@ -562,7 +564,7 @@ void TQSGIStyle::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 TQSGIStyle::drawPrimitive( PrimitiveElement pe, case PE_ButtonBevel: case PE_ButtonTool: { - drawPrimitive( PE_ButtonCommand, p, TQRect( x+1, y+1, w-2, h-2 ), cg, flags, opt ); + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, TQRect( x+1, y+1, w-2, h-2 ), cg, flags, opt ); TQPen oldPen = p->pen(); TQPointArray a; @@ -642,11 +644,11 @@ void TQSGIStyle::drawPrimitive( PrimitiveElement pe, TQRect 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 & TQStyle::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 TQSGIStyle::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 TQSGIStyle::drawPrimitive( PrimitiveElement pe, TQPixmap pm( r.width(), r.height() ); TQPainter bp( &pm ); - drawPrimitive(PE_ButtonBevel, &bp, TQRect(0,0,r.width(),r.height()), cg, flags | Style_Enabled | Style_Raised); + drawPrimitive(PE_ButtonBevel, &bp, ceData, elementFlags, TQRect(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 TQSGIStyle::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 TQSGIStyle::drawPrimitive( PrimitiveElement pe, qDrawShadeLine( p, xPos, kPos + kSize - 1 , xPos, h, cg ); - drawPrimitive( PE_ButtonBevel, p, TQRect(xPos-sw/2+1, kPos, kSize, kSize+1), cg, flags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, TQRect(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 TQSGIStyle::drawPrimitive( PrimitiveElement pe, int kSize = sw - 2; qDrawShadeLine( p, 0, yPos, kPos, yPos, cg ); - drawPrimitive( PE_ButtonBevel, p, TQRect( kPos, yPos-sw/2+1, kSize+1, kSize ), cg, flags, opt ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, TQRect( kPos, yPos-sw/2+1, kSize+1, kSize ), cg, flags, opt ); qDrawShadeLine( p, kPos + kSize+1, yPos, w, yPos, cg ); } } break; default: - TQMotifStyle::drawPrimitive( pe, p, r, cg, flags, opt ); + TQMotifStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); break; } } @@ -885,11 +887,13 @@ void TQSGIStyle::drawPrimitive( PrimitiveElement pe, /*! \reimp */ void TQSGIStyle::drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { if ( widget == d->hotWidget ) flags |= Style_MouseOver; @@ -898,17 +902,16 @@ void TQSGIStyle::drawControl( ControlElement element, case CE_PushButton: { #ifndef QT_NO_PUSHBUTTON - const TQPushButton *btn = (TQPushButton*)widget; int x1, y1, x2, y2; r.coords( &x1, &y1, &x2, &y2 ); p->setPen( cg.foreground() ); p->setBrush( TQBrush( cg.button(),TQt::NoBrush ) ); - p->setBrushOrigin( -widget->backgroundOffset().x(), - -widget->backgroundOffset().y() ); + p->setBrushOrigin( -ceData.bgOffset.x(), + -ceData.bgOffset.y() ); - int diw = pixelMetric( TQStyle::PM_ButtonDefaultIndicator ); - if ( btn->isDefault() || btn->autoDefault() ) { + int diw = pixelMetric( TQStyle::PM_ButtonDefaultIndicator, ceData, elementFlags ); + if ( ( elementFlags & CEF_IsDefault ) || ( elementFlags & CEF_AutoDefault ) ) { x1 += diw; y1 += diw; x2 -= diw; @@ -916,7 +919,7 @@ void TQSGIStyle::drawControl( ControlElement element, } TQPointArray 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 TQSGIStyle::drawControl( ControlElement element, x2 -= 2; y2 -= 2; } else { - qDrawShadePanel( p, btn->rect(), cg, TRUE ); + qDrawShadePanel( p, ceData.rect, cg, TRUE ); } } TQBrush fill = cg.brush( TQColorGroup::Button ); - if ( !btn->isFlat() || btn->isOn() || btn->isDown() ) - drawPrimitive( PE_ButtonBevel, p, TQRect( 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, TQRect( x1, y1, x2-x1+1, y2-y1+1 ), cg, flags, opt ); if ( p->brush().style() != TQt::NoBrush ) p->setBrush( TQt::NoBrush ); @@ -945,16 +948,15 @@ void TQSGIStyle::drawControl( ControlElement element, case CE_PopupMenuItem: { #ifndef QT_NO_POPUPMENU - if (! widget || opt.isDefault()) + if ( ( elementFlags & CEF_UseGenericParameters ) || opt.isDefault()) break; TQMenuItem *mi = opt.menuItem(); if ( !mi ) break; - const TQPopupMenu *popupmenu = (const TQPopupMenu *) 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 TQSGIStyle::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( TQColorGroup::Light ) ); else @@ -1024,12 +1026,12 @@ void TQSGIStyle::drawControl( ControlElement element, if ( mi->isChecked() ) { TQRect 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 TQSGIStyle::drawControl( ControlElement element, } if ( mi->popup() ) { int dim = (h-2*sgiItemFrame) / 2; - drawPrimitive( PE_ArrowRight, p, TQRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags ); + drawPrimitive( PE_ArrowRight, p, ceData, elementFlags, TQRect( x+w-sgiArrowHMargin-sgiItemFrame-dim, y+h/2-dim/2, dim, dim ), cg, flags ); } #endif } @@ -1128,11 +1130,11 @@ void TQSGIStyle::drawControl( ControlElement element, break; case CE_CheckBox: - TQMotifStyle::drawControl( element, p, widget, r, cg, flags, opt ); + TQMotifStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget ); break; default: - TQMotifStyle::drawControl( element, p, widget, r, cg, flags, opt ); + TQMotifStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget ); break; } } @@ -1140,13 +1142,15 @@ void TQSGIStyle::drawControl( ControlElement element, /*! \reimp */ void TQSGIStyle::drawComplexControl( ComplexControl control, TQPainter *p, - const TQWidget* widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect& r, const TQColorGroup& cg, SFlags flags, SCFlags sub, SCFlags subActive, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget* widget ) const { if ( widget == d->hotWidget ) flags |= Style_MouseOver; @@ -1155,33 +1159,31 @@ void TQSGIStyle::drawComplexControl( ComplexControl control, case CC_Slider: { #ifndef QT_NO_SLIDER - const TQSlider * slider = (const TQSlider *) widget; - - TQRect groove = querySubControlMetrics(CC_Slider, widget, SC_SliderGroove, - opt), - handle = querySubControlMetrics(CC_Slider, widget, SC_SliderHandle, - opt); + TQRect 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()) { TQRegion 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 ); TQRect 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 ) { - TQRect fr = subRect( SR_SliderFocusRect, widget ); - drawPrimitive( PE_FocusRect, p, fr, cg, flags & ~Style_MouseOver ); + TQRect 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 TQSGIStyle::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 ) { TQCOORD mid = handle.x() + handle.width() / 2; qDrawShadeLine( p, mid, handle.y(), mid, handle.y() + handle.height() - 2, @@ -1211,50 +1213,48 @@ void TQSGIStyle::drawComplexControl( ComplexControl control, } if ( sub & SC_SliderTickmarks ) - TQMotifStyle::drawComplexControl( control, p, widget, r, cg, flags, + TQMotifStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, SC_SliderTickmarks, subActive, - opt ); + opt, widget ); #endif break; } case CC_ComboBox: { #ifndef QT_NO_COMBOBOX - const TQComboBox * cb = (TQComboBox *) widget; - if (sub & SC_ComboBoxFrame) { TQRect fr = - TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, - SC_ComboBoxFrame ), cb ); - drawPrimitive( PE_ButtonBevel, p, fr, cg, flags ); + TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxFrame, TQStyleOption::Default, widget ), ceData, elementFlags ); + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, fr, cg, flags ); } if ( sub & SC_ComboBoxArrow ) { p->save(); TQRect er = - TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, SC_ComboBoxArrow ), cb ); + TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, TQStyleOption::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 ); TQBrush arrow = cg.brush( TQColorGroup::Dark ); p->fillRect( ax, sy-1, awh, sh, arrow ); p->restore(); - if ( cb->hasFocus() ) { - TQRect re = TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), cb ); - drawPrimitive( PE_FocusRect, p, re, cg ); + if ( elementFlags & CEF_HasFocus ) { + TQRect re = TQStyle::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 ) { TQRect er = - TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, cb, - SC_ComboBoxEditField ), cb ); + TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags ); er.addCoords( -1, -1, 1, 1); qDrawShadePanel( p, TQRect( er.x()-1, er.y()-1, er.width()+2, er.height()+2 ), @@ -1269,27 +1269,26 @@ void TQSGIStyle::drawComplexControl( ComplexControl control, case CC_ScrollBar: { #ifndef QT_NO_SCROLLBAR - TQScrollBar *scrollbar = (TQScrollBar*)widget; - bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); + bool maxedOut = (ceData.minSteps == ceData.maxSteps); if ( maxedOut ) flags &= ~Style_Enabled; - TQRect handle = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSlider, opt ), widget ); + TQRect handle = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarSlider, opt, widget ), ceData, elementFlags ); if ( sub & SC_ScrollBarGroove ) { } if ( sub & SC_ScrollBarAddLine ) { - TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddLine, opt ), widget ); - drawPrimitive( PE_ScrollBarAddLine, p, er, cg, flags, opt ); + TQRect er = TQStyle::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 ) { - TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubLine, opt ), widget ); - drawPrimitive( PE_ScrollBarSubLine, p, er, cg, flags, opt ); + TQRect er = TQStyle::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 ) { - TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarAddPage, opt ), widget ); + TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarAddPage, opt, widget ), ceData, elementFlags ); TQRegion 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 TQSGIStyle::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 TQSGIStyle::drawComplexControl( ComplexControl control, p->setClipping( FALSE ); } if ( sub & SC_ScrollBarSubPage ) { - TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, widget, SC_ScrollBarSubPage, opt ), widget ); + TQRect er = TQStyle::visualRect( querySubControlMetrics( CC_ScrollBar, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget ), ceData, elementFlags ); TQRegion 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 TQSGIStyle::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 TQSGIStyle::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: - TQMotifStyle::drawComplexControl( control, p, widget, r, cg, flags, sub, subActive, opt ); +// TQMotifStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget ); break; } } @@ -1364,9 +1363,11 @@ void TQSGIStyle::drawComplexControl( ComplexControl control, /*!\reimp */ TQSize TQSGIStyle::sizeFromContents( ContentsType contents, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQSize &contentsSize, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { TQSize sz(contentsSize); @@ -1374,15 +1375,14 @@ TQSize TQSGIStyle::sizeFromContents( ContentsType contents, case CT_PopupMenuItem: { #ifndef QT_NO_POPUPMENU - if (! widget || opt.isDefault()) + if ((elementFlags & CEF_UseGenericParameters) || opt.isDefault()) break; TQMenuItem *mi = opt.menuItem(); - sz = TQMotifStyle::sizeFromContents( contents, widget, contentsSize, - opt ); + sz = TQMotifStyle::sizeFromContents( contents, ceData, elementFlags, contentsSize, + opt, widget ); // SGI checkmark items needs a bit more room - const TQPopupMenu *popup = (TQPopupMenu *) 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 @@ TQSize TQSGIStyle::sizeFromContents( ContentsType contents, break; default: - sz = TQMotifStyle::sizeFromContents( contents, widget, contentsSize, opt ); + sz = TQMotifStyle::sizeFromContents( contents, ceData, elementFlags, contentsSize, opt, widget ); break; } @@ -1403,7 +1403,7 @@ TQSize TQSGIStyle::sizeFromContents( ContentsType contents, } /*! \reimp */ -TQRect TQSGIStyle::subRect( SubRect r, const TQWidget *widget ) const +TQRect TQSGIStyle::subRect( SubRect r, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget ) const { TQRect rect; @@ -1411,8 +1411,8 @@ TQRect TQSGIStyle::subRect( SubRect r, const TQWidget *widget ) const case SR_ComboBoxFocusRect: { int awh, ax, ay, sh, sy, dh, ew; - int fw = pixelMetric( PM_DefaultFrameWidth, widget ); - TQRect tr = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + TQRect tr = ceData.rect; tr.addCoords( fw, fw, -fw, -fw ); get_combo_parameters( tr, ew, awh, ax, ay, sh, dh, sy ); @@ -1420,7 +1420,7 @@ TQRect TQSGIStyle::subRect( SubRect r, const TQWidget *widget ) const } break; default: - return TQMotifStyle::subRect( r, widget ); + return TQMotifStyle::subRect( r, ceData, elementFlags, widget ); } return rect; @@ -1428,27 +1428,29 @@ TQRect TQSGIStyle::subRect( SubRect r, const TQWidget *widget ) const /*! \reimp */ TQRect TQSGIStyle::querySubControlMetrics( ComplexControl control, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, SubControl sub, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *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 ); - TQRect cr = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + TQRect cr = ceData.rect; cr.addCoords( fw, fw, -fw, -fw ); get_combo_parameters( cr, ew, awh, ax, ay, sh, dh, sy ); return TQRect( ax, ay, awh, awh ); } case SC_ComboBoxEditField: { - int fw = pixelMetric( PM_DefaultFrameWidth, widget ); - TQRect rect = widget->rect(); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ); + TQRect 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 @@ TQRect TQSGIStyle::querySubControlMetrics( ComplexControl control, } break; case CC_ScrollBar: - return TQCommonStyle::querySubControlMetrics( control, widget, sub, opt ); + return TQCommonStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); default: break; } - return TQMotifStyle::querySubControlMetrics( control, widget, sub, opt ); + return TQMotifStyle::querySubControlMetrics( control, ceData, elementFlags, sub, opt, widget ); } #endif // QT_NO_STYLE_SGI |