diff options
Diffstat (limited to 'src/styles/qwindowsstyle.cpp')
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 322 |
1 files changed, 104 insertions, 218 deletions
diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index e716a53e7..5c5c996e5 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -66,10 +66,6 @@ #include "ntqobjectlist.h" #include "ntqmenubar.h" -#if defined(Q_WS_WIN) -#include "qt_windows.h" -#endif - #include <limits.h> @@ -143,7 +139,7 @@ bool TQWindowsStyle::Private::eventFilter(TQObject *o, TQEvent *e) while ( (w = (TQWidget*)it.current()) != 0 ) { ++it; if (w->isTopLevel() || !w->isVisible() || - w->style().styleHint(SH_UnderlineAccelerator, w)) + w->style().styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, w)) l->removeRef(w); } // Update states before repainting @@ -237,7 +233,7 @@ TQWindowsStyle::~TQWindowsStyle() void TQWindowsStyle::polish(TQApplication *app) { // We only need the overhead when shortcuts are sometimes hidden - if (!styleHint(SH_UnderlineAccelerator, 0)) { + if (!styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, 0)) { d = new Private(this); app->installEventFilter(d); } @@ -271,6 +267,8 @@ void TQWindowsStyle::polish( TQPalette &pal ) /*! \reimp */ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, @@ -315,31 +313,6 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, p->fillRect(r, fill); break; } -#if defined(Q_WS_WIN) - case PE_HeaderArrow: - p->save(); - if ( flags & Style_Up ) { // invert logic to follow Windows style guide - TQPointArray pa( 3 ); - p->setPen( cg.light() ); - p->drawLine( r.x() + r.width(), r.y(), r.x() + r.width() / 2, r.height() ); - p->setPen( cg.dark() ); - pa.setPoint( 0, r.x() + r.width() / 2, r.height() ); - pa.setPoint( 1, r.x(), r.y() ); - pa.setPoint( 2, r.x() + r.width(), r.y() ); - p->drawPolyline( pa ); - } else { - TQPointArray pa( 3 ); - p->setPen( cg.light() ); - pa.setPoint( 0, r.x(), r.height() ); - pa.setPoint( 1, r.x() + r.width(), r.height() ); - pa.setPoint( 2, r.x() + r.width() / 2, r.y() ); - p->drawPolyline( pa ); - p->setPen( cg.dark() ); - p->drawLine( r.x(), r.height(), r.x() + r.width() / 2, r.y() ); - } - p->restore(); - break; -#endif case PE_ButtonDefault: p->setPen(cg.shadow()); @@ -507,7 +480,7 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, case PE_Panel: case PE_PanelPopup: { - int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth) + int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags) : opt.lineWidth(); if (lw == 2) { @@ -518,7 +491,7 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, } qDrawWinPanel(p, r, popupCG, flags & Style_Sunken); } else { - TQCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt); + TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); } break; } @@ -572,13 +545,13 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, p->setBrush( cg.brush( TQColorGroup::Button ) ); p->drawRect( r ); } else - drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised); + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, flags | Style_Raised); } else - drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) | + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | ((flags & Style_Down) ? Style_Down : Style_Raised)); drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp), - p, r, cg, flags); + p, ceData, elementFlags, r, cg, flags); break; case PE_ScrollBarAddLine: @@ -588,13 +561,13 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, p->setBrush( cg.brush( TQColorGroup::Button ) ); p->drawRect( r ); } else - drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Raised); + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, flags | Style_Raised); } else - drawPrimitive(PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) | + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | ((flags & Style_Down) ? Style_Down : Style_Raised)); drawPrimitive(((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown), - p, r, cg, flags); + p, ceData, elementFlags, r, cg, flags); break; case PE_ScrollBarAddPage: @@ -632,7 +605,7 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, p->setBackgroundMode(OpaqueMode); p->drawRect(r); } else - drawPrimitive(PE_ButtonBevel, p, r, cg, Style_Enabled | Style_Raised); + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, Style_Enabled | Style_Raised); break; case PE_WindowFrame: @@ -674,8 +647,8 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, p->save(); if ( flags & Style_Down ) - p->translate( pixelMetric( PM_ButtonShiftHorizontal ), - pixelMetric( PM_ButtonShiftVertical ) ); + p->translate( pixelMetric( PM_ButtonShiftHorizontal, ceData, elementFlags ), + pixelMetric( PM_ButtonShiftVertical, ceData, elementFlags ) ); if ( flags & Style_Enabled ) { a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 ); @@ -694,7 +667,7 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, } p->restore(); } else - TQCommonStyle::drawPrimitive(pe, p, r, cg, flags, opt); + TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); } } @@ -704,33 +677,34 @@ void TQWindowsStyle::drawPrimitive( PrimitiveElement pe, */ void TQWindowsStyle::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 { switch (element) { #ifndef QT_NO_TABBAR case CE_TabBarTab: { - if ( !widget || !widget->parentWidget() || !opt.tab() ) + if ( ( elementFlags & CEF_UseGenericParameters ) || (!( elementFlags & CEF_HasParentWidget )) || !opt.tab() ) break; - const TQTabBar * tb = (const TQTabBar *) widget; const TQTab * t = opt.tab(); bool selected = flags & Style_Selected; - bool lastTab = (tb->indexOf( t->identifier() ) == tb->count()-1) ? + bool lastTab = (ceData.tabBarData.identIndexMap[t->identifier()] == ceData.tabBarData.tabCount-1) ? TRUE : FALSE; TQRect r2( r ); - if ( tb->shape() == TQTabBar::RoundedAbove ) { + if ( ceData.tabBarData.shape == TQTabBar::RoundedAbove ) { p->setPen( cg.midlight() ); p->drawLine( r2.left(), r2.bottom(), r2.right(), r2.bottom() ); p->setPen( cg.light() ); p->drawLine( r2.left(), r2.bottom()-1, r2.right(), r2.bottom()-1 ); if ( r2.left() == 0 ) - p->drawPoint( tb->rect().bottomLeft() ); + p->drawPoint( ceData.rect.bottomLeft() ); if ( selected ) { p->fillRect( TQRect( r2.left()+1, r2.bottom()-1, r2.width()-3, 2), @@ -774,9 +748,9 @@ void TQWindowsStyle::drawControl( ControlElement element, x2++; p->drawLine( x2, r2.top() + 2, x2, r2.bottom() - (selected ? (lastTab ? 0:1) :2)); - } else if ( tb->shape() == TQTabBar::RoundedBelow ) { - bool rightAligned = styleHint( SH_TabBar_Alignment, tb ) == AlignRight; - bool firstTab = tb->indexOf( t->identifier() ) == 0; + } else if ( ceData.tabBarData.shape == TQTabBar::RoundedBelow ) { + bool rightAligned = styleHint( SH_TabBar_Alignment, ceData, elementFlags, TQStyleOption::Default, 0, widget ) == AlignRight; + bool firstTab = ceData.tabBarData.identIndexMap[t->identifier()] == 0; if ( selected ) { p->fillRect( TQRect( r2.left()+1, r2.top(), r2.width()-3, 1), cg.brush( TQColorGroup::Background )); @@ -823,7 +797,7 @@ void TQWindowsStyle::drawControl( ControlElement element, p->drawLine( r2.left(), r2.top() + (selected ? 0 : 2), r2.left(), r2.bottom() - 2 ); } else { - TQCommonStyle::drawControl(element, p, widget, r, cg, flags, opt); + TQCommonStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); } break; } @@ -838,10 +812,9 @@ void TQWindowsStyle::drawControl( ControlElement element, #ifndef QT_NO_POPUPMENU case CE_PopupMenuItem: { - if (! widget || opt.isDefault()) + if (( elementFlags & CEF_UseGenericParameters ) || opt.isDefault()) break; - const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget; TQMenuItem *mi = opt.menuItem(); if ( !mi ) break; @@ -849,7 +822,7 @@ void TQWindowsStyle::drawControl( ControlElement element, 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; @@ -937,7 +910,7 @@ void TQWindowsStyle::drawControl( ControlElement element, if (act) cflags |= Style_On; - drawPrimitive(PE_CheckMark, p, + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, visualRect( TQRect(xp, y + windowsItemFrame, checkcol - 2*windowsItemFrame, h - 2*windowsItemFrame), r ), cg, cflags); @@ -973,7 +946,7 @@ void TQWindowsStyle::drawControl( ControlElement element, if ( !s.isNull() ) { // draw text int t = s.find( '\t' ); int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; - if (!styleHint(SH_UnderlineAccelerator, widget)) + if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) text_flags |= NoAccel; text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft ); if ( t >= 0 ) { // draw tab text @@ -1014,10 +987,10 @@ void TQWindowsStyle::drawControl( ControlElement element, if ( act ) { TQColorGroup g2 = cg; g2.setColor( TQColorGroup::ButtonText, g2.highlightedText() ); - drawPrimitive(arrow, p, vrect, + drawPrimitive(arrow, p, ceData, elementFlags, vrect, g2, dis ? Style_Default : Style_Enabled); } else { - drawPrimitive(arrow, p, vrect, + drawPrimitive(arrow, p, ceData, elementFlags, vrect, cg, dis ? Style_Default : Style_Enabled ); } } @@ -1042,17 +1015,17 @@ void TQWindowsStyle::drawControl( ControlElement element, qDrawShadeRect( p, r.x(), r.y(), r.width(), r.height(), cg, active && down, 1, 0, &b ); if ( active && down ) { - pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, widget), - pixelMetric(PM_ButtonShiftVertical, widget) ); + pr.moveBy( pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget), + pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget) ); p->setBrushOrigin(p->brushOrigin() - TQPoint(1,1)); } } - TQCommonStyle::drawControl(element, p, widget, pr, cg, flags, opt); + TQCommonStyle::drawControl(element, p, ceData, elementFlags, pr, cg, flags, opt, widget); break; } default: - TQCommonStyle::drawControl(element, p, widget, r, cg, flags, opt); + TQCommonStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); } } @@ -1060,7 +1033,7 @@ void TQWindowsStyle::drawControl( ControlElement element, /*! \reimp */ -int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) const +int TQWindowsStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const { int ret; @@ -1085,10 +1058,9 @@ int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) cons // equally between the tickmark regions. case PM_SliderControlThickness: { - const TQSlider * sl = (const TQSlider *) widget; - int space = (sl->orientation() == Horizontal) ? sl->height() - : sl->width(); - int ticks = sl->tickmarks(); + int space = (ceData.orientation == Horizontal) ? ceData.rect.height() + : ceData.rect.width(); + int ticks = ceData.tickMarkSetting; int n = 0; if ( ticks & TQSlider::Above ) n++; if ( ticks & TQSlider::Below ) n++; @@ -1099,7 +1071,7 @@ int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) cons int thick = 6; // Magic constant to get 5 + 16 + 5 if ( ticks != TQSlider::Both && ticks != TQSlider::NoMarks ) - thick += pixelMetric( PM_SliderLength, sl ) / 4; + thick += pixelMetric( PM_SliderLength, ceData, elementFlags, widget ) / 4; space -= thick; //### the two sides may be unequal in size @@ -1114,46 +1086,12 @@ int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) cons ret = 0; break; -#if defined(Q_WS_WIN) - case PM_TitleBarHeight: - if ( widget && ( widget->testWFlags( WStyle_Tool ) || ::tqt_cast<TQDockWindow*>(widget) ) ) { - // MS always use one less than they say -#if defined(Q_OS_TEMP) - ret = GetSystemMetrics( SM_CYCAPTION ) - 1; -#else - ret = GetSystemMetrics( SM_CYSMCAPTION ) - 1; -#endif - } else { - ret = GetSystemMetrics( SM_CYCAPTION ) - 1; - } - break; - - case PM_ScrollBarExtent: - { -#ifndef Q_OS_TEMP - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(NONCLIENTMETRICS); - if ( SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0 ) ) - ret = TQMAX( ncm.iScrollHeight, ncm.iScrollWidth ); - else -#endif - ret = TQCommonStyle::pixelMetric( metric, widget ); - } - break; -#endif - case PM_SplitterWidth: ret = TQMAX( 6, TQApplication::globalStrut().width() ); break; -#if defined(Q_WS_WIN) - case PM_MDIFrameWidth: - ret = GetSystemMetrics(SM_CYFRAME); - break; -#endif - default: - ret = TQCommonStyle::pixelMetric(metric, widget); + ret = TQCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; } @@ -1165,9 +1103,11 @@ int TQWindowsStyle::pixelMetric(PixelMetric metric, const TQWidget *widget) cons \reimp */ TQSize TQWindowsStyle::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); @@ -1175,15 +1115,14 @@ TQSize TQWindowsStyle::sizeFromContents( ContentsType contents, case CT_PushButton: { #ifndef QT_NO_PUSHBUTTON - const TQPushButton *button = (const TQPushButton *) widget; - sz = TQCommonStyle::sizeFromContents(contents, widget, contentsSize, opt); + sz = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, opt, widget); int w = sz.width(), h = sz.height(); int defwidth = 0; - if (button->isDefault() || button->autoDefault()) - defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, widget ); + if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) + defwidth = 2*pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags, widget ); - if (w < 80+defwidth && !button->pixmap()) + if (w < 80+defwidth && ceData.fgPixmap.isNull()) w = 80+defwidth; if (h < 23+defwidth) h = 23+defwidth; @@ -1196,11 +1135,10 @@ TQSize TQWindowsStyle::sizeFromContents( ContentsType contents, case CT_PopupMenuItem: { #ifndef QT_NO_POPUPMENU - if (! widget || opt.isDefault()) + if (( elementFlags & CEF_UseGenericParameters ) || opt.isDefault()) break; - const TQPopupMenu *popup = (const TQPopupMenu *) widget; - bool checkable = popup->isCheckable(); + bool checkable = ( elementFlags & CEF_IsCheckable ); TQMenuItem *mi = opt.menuItem(); int maxpmw = opt.maxIconWidth(); int w = sz.width(), h = sz.height(); @@ -1218,7 +1156,7 @@ TQSize TQWindowsStyle::sizeFromContents( ContentsType contents, if (mi->pixmap()) h = TQMAX(h, mi->pixmap()->height() + 2*windowsItemFrame); else if (! mi->text().isNull()) - h = TQMAX(h, popup->fontMetrics().height() + 2*windowsItemVMargin + + h = TQMAX(h, TQFontMetrics(ceData.font).height() + 2*windowsItemVMargin + 2*windowsItemFrame); if (mi->iconSet() != 0) @@ -1256,7 +1194,7 @@ TQSize TQWindowsStyle::sizeFromContents( ContentsType contents, } default: - sz = TQCommonStyle::sizeFromContents(contents, widget, sz, opt); + sz = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, sz, opt, widget); break; } @@ -1556,8 +1494,10 @@ static const char *const question_xpm[] = { \reimp */ TQPixmap TQWindowsStyle::stylePixmap(StylePixmap stylepixmap, - const TQWidget *widget, - const TQStyleOption& opt) const + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQStyleOption& opt, + const TQWidget *widget) const { #ifndef QT_NO_IMAGEIO_XPM switch (stylepixmap) { @@ -1587,26 +1527,28 @@ TQPixmap TQWindowsStyle::stylePixmap(StylePixmap stylepixmap, break; } #endif //QT_NO_IMAGEIO_XPM - return TQCommonStyle::stylePixmap(stylepixmap, widget, opt); + return TQCommonStyle::stylePixmap(stylepixmap, ceData, elementFlags, opt, widget); } /*!\reimp */ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, 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 { switch (ctrl) { #ifndef QT_NO_LISTVIEW case CC_ListView: { if ( sub & SC_ListView ) { - TQCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, subActive, opt ); + TQCommonStyle::drawComplexControl( ctrl, p, ceData, elementFlags, r, cg, flags, sub, subActive, opt, widget ); } if ( sub & ( SC_ListViewBranch | SC_ListViewExpand ) ) { if (opt.isDefault()) @@ -1769,13 +1711,13 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, if ( sub & SC_ComboBoxArrow ) { SFlags flags = Style_Default; - qDrawWinPanel( p, r, cg, TRUE, widget->isEnabled() ? + qDrawWinPanel( p, r, cg, TRUE, ( elementFlags & CEF_IsEnabled ) ? &cg.brush( TQColorGroup::Base ): &cg.brush( TQColorGroup::Background ) ); TQRect ar = - TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, - SC_ComboBoxArrow ), widget ); + TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxArrow, TQStyleOption::Default, widget ), ceData, elementFlags ); if ( subActive == SC_ComboBoxArrow ) { p->setPen( cg.dark() ); p->setBrush( cg.brush( TQColorGroup::Button ) ); @@ -1785,25 +1727,24 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, &cg.brush( TQColorGroup::Button ) ); ar.addCoords( 2, 2, -2, -2 ); - if ( widget->isEnabled() ) + if ( elementFlags & CEF_IsEnabled ) flags |= Style_Enabled; if ( subActive == SC_ComboBoxArrow ) { flags |= Style_Sunken; } - drawPrimitive( PE_ArrowDown, p, ar, cg, flags ); + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, ar, cg, flags ); } if ( sub & SC_ComboBoxEditField ) { - const TQComboBox * cb = (const TQComboBox *) widget; TQRect re = - TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, widget, - SC_ComboBoxEditField ), widget ); - if ( cb->hasFocus() && !cb->editable() ) + TQStyle::visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags ); + if ( ( elementFlags & CEF_HasFocus ) && (!( elementFlags & CEF_IsEditable )) ) p->fillRect( re.x(), re.y(), re.width(), re.height(), cg.brush( TQColorGroup::Highlight ) ); - if ( cb->hasFocus() ) { + if ( elementFlags & CEF_HasFocus ) { p->setPen( cg.highlightedText() ); p->setBackgroundColor( cg.highlight() ); @@ -1812,10 +1753,10 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, p->setBackgroundColor( cg.background() ); } - if ( cb->hasFocus() && !cb->editable() ) { + if ( ( elementFlags & CEF_HasFocus ) && (!( elementFlags & CEF_IsEditable )) ) { TQRect re = - TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, cb ), widget ); - drawPrimitive( PE_FocusRect, p, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight())); + TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), ceData, elementFlags ); + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight())); } } @@ -1825,15 +1766,14 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, #ifndef QT_NO_SLIDER case CC_Slider: { - const TQSlider *sl = (const TQSlider *) widget; - int thickness = pixelMetric( PM_SliderControlThickness, widget ); - int len = pixelMetric( PM_SliderLength, widget ); - int ticks = sl->tickmarks(); + int thickness = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget ); + int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); + int ticks = ceData.tickMarkSetting; - 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()) { int mid = thickness / 2; @@ -1844,7 +1784,7 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, mid -= len / 8; p->setPen( cg.shadow() ); - if ( sl->orientation() == Horizontal ) { + if ( ceData.orientation == Horizontal ) { qDrawWinPanel( p, groove.x(), groove.y() + mid - 2, groove.width(), 4, cg, TRUE ); p->drawLine( groove.x() + 1, groove.y() + mid - 1, @@ -1859,9 +1799,9 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, } if (sub & SC_SliderTickmarks) - TQCommonStyle::drawComplexControl(ctrl, p, widget, r, cg, flags, + TQCommonStyle::drawComplexControl(ctrl, p, ceData, elementFlags, r, cg, flags, SC_SliderTickmarks, subActive, - opt ); + opt, widget ); if ( sub & SC_SliderHandle ) { // 4444440 @@ -1887,15 +1827,15 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, int y1 = y; int y2 = y+he-1; - Orientation orient = sl->orientation(); - bool tickAbove = sl->tickmarks() == TQSlider::Above; - bool tickBelow = sl->tickmarks() == TQSlider::Below; + Orientation orient = ceData.orientation; + bool tickAbove = ceData.tickMarkSetting == TQSlider::Above; + bool tickBelow = ceData.tickMarkSetting == TQSlider::Below; p->fillRect( x, y, wi, he, cg.brush( TQColorGroup::Background ) ); if ( flags & Style_HasFocus ) { - TQRect re = subRect( SR_SliderFocusRect, sl ); - drawPrimitive( PE_FocusRect, p, re, cg ); + TQRect re = subRect( SR_SliderFocusRect, ceData, elementFlags, widget ); + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg ); } if ( (tickAbove && tickBelow) || (!tickAbove && !tickBelow) ) { @@ -2032,8 +1972,8 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, #endif // QT_NO_SLIDER default: - TQCommonStyle::drawComplexControl( ctrl, p, widget, r, cg, flags, sub, - subActive, opt ); + TQCommonStyle::drawComplexControl( ctrl, p, ceData, elementFlags, r, cg, flags, sub, + subActive, opt, widget ); break; } } @@ -2041,9 +1981,11 @@ void TQWindowsStyle::drawComplexControl( ComplexControl ctrl, TQPainter *p, /*! \reimp */ int TQWindowsStyle::styleHint( StyleHint hint, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQStyleOption &opt, - TQStyleHintReturn *returnData ) const + TQStyleHintReturn *returnData, + const TQWidget *widget ) const { int ret; @@ -2063,11 +2005,6 @@ int TQWindowsStyle::styleHint( StyleHint hint, break; case SH_ItemView_ChangeHighlightOnFocus: -#if defined(Q_WS_WIN) - if ( qWinVersion() != WV_95 && qWinVersion() != WV_NT ) - ret = 1; - else -#endif ret = 0; break; @@ -2075,59 +2012,8 @@ int TQWindowsStyle::styleHint( StyleHint hint, ret = 0; break; -#if defined(Q_WS_WIN) - case SH_UnderlineAccelerator: - ret = 1; - if ( qWinVersion() != WV_95 && qWinVersion() != WV_98 && qWinVersion() != WV_NT ) { - BOOL cues; - SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0); - ret = cues ? 1 : 0; - // Do nothing if we always paint underlines - if (!ret && widget && d) { - TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(widget); - TQPopupMenu *popupMenu = 0; - if (!menuBar) - popupMenu = ::tqt_cast<TQPopupMenu*>(widget); - - // If we paint a menubar draw underlines if it has focus, or if alt is down, - // or if a popup menu belonging to the menubar is active and paints underlines - if (menuBar) { - if (menuBar->hasFocus()) { - ret = 1; - } else if (d->altDown()) { - ret = 1; - } else if (tqApp->focusWidget() && tqApp->focusWidget()->isPopup()) { - popupMenu = ::tqt_cast<TQPopupMenu*>(tqApp->focusWidget()); - TQMenuData *pm = popupMenu ? (TQMenuData*)popupMenu->tqt_cast("TQMenuData") : 0; - if (pm && ((FriendlyMenuData*)pm)->parentMenu == menuBar) { - if (d->hasSeenAlt(menuBar)) - ret = 1; - } - } - // If we paint a popup menu draw underlines if the respective menubar does - } else if (popupMenu) { - TQMenuData *pm = (TQMenuData*)popupMenu->tqt_cast("TQMenuData"); - while (pm) { - if (((FriendlyMenuData*)pm)->isMenuBar) { - menuBar = (TQMenuBar*)pm; - if (d->hasSeenAlt(menuBar)) - ret = 1; - break; - } - pm = ((FriendlyMenuData*)pm)->parentMenu; - } - // Otherwise draw underlines if the toplevel widget has seen an alt-press - } else if (d->hasSeenAlt(widget)) { - ret = 1; - } - } - - } - break; -#endif - default: - ret = TQCommonStyle::styleHint(hint, widget, opt, returnData); + ret = TQCommonStyle::styleHint(hint, ceData, elementFlags, opt, returnData, widget); break; } @@ -2135,7 +2021,7 @@ int TQWindowsStyle::styleHint( StyleHint hint, } /*! \reimp */ -TQRect TQWindowsStyle::subRect(SubRect r, const TQWidget *widget) const +TQRect TQWindowsStyle::subRect(SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const { TQRect rect; @@ -2143,15 +2029,15 @@ TQRect TQWindowsStyle::subRect(SubRect r, const TQWidget *widget) const #ifndef QT_NO_SLIDER case SR_SliderFocusRect: { - rect = widget->rect(); + rect = ceData.rect; break; } #endif // QT_NO_SLIDER case SR_ToolBoxTabContents: - rect = widget->rect(); + rect = ceData.rect; break; default: - rect = TQCommonStyle::subRect( r, widget ); + rect = TQCommonStyle::subRect( r, ceData, elementFlags, widget ); break; } |