From 884e5fa2022260e446ed13b9ed082023311442d2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 31 Oct 2012 14:12:48 -0500 Subject: [PATCH] Update to new style API --- kstyles/asteroid/asteroid.cpp | 21 ++++++++++- kstyles/highcolor/highcolor.cpp | 53 ++++++++++++++++++++++----- kstyles/highcolor/highcolor.h | 4 ++ kstyles/highcontrast/highcontrast.cpp | 47 ++++++++++++++++++++---- kstyles/highcontrast/highcontrast.h | 4 ++ kstyles/keramik/keramik.cpp | 46 ++++++++++++++++++++--- kstyles/keramik/keramik.h | 4 ++ kstyles/kthemestyle/kthemestyle.cpp | 38 +++++++++++++++---- kstyles/light/lightstyle-v2.cpp | 36 ++++++++++++++++-- kstyles/light/lightstyle-v3.cpp | 36 ++++++++++++++++-- kstyles/plastik/plastik.cpp | 32 +++++++++++++--- 11 files changed, 275 insertions(+), 46 deletions(-) diff --git a/kstyles/asteroid/asteroid.cpp b/kstyles/asteroid/asteroid.cpp index 432756032..05a669e18 100644 --- a/kstyles/asteroid/asteroid.cpp +++ b/kstyles/asteroid/asteroid.cpp @@ -316,6 +316,10 @@ int AsteroidStyle::styleHint( TQ_StyleHint stylehint, // case SH_ComboBox_ListMouseTracking: // case SH_ScrollBar_StopMouseOverSlider: return 1; + + case SH_MenuIndicatorColumnWidth: { + return TQMAX(option.maxIconWidth(), 12); + } default: return KStyle::styleHint(stylehint, ceData, elementFlags, option, returnData, widget); @@ -937,9 +941,16 @@ void AsteroidStyle::drawPrimitive(TQ_PrimitiveElement pe, break; } + case PE_MenuItemIndicatorIconFrame: + case PE_MenuItemIndicatorFrame: { + // Draw nothing + break; + } + case PE_MenuItemIndicatorCheck: { int x, y, w, h; r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, o, NULL, NULL); bool active = sf & Style_Active; bool disabled = !(sf & Style_Enabled); @@ -955,7 +966,7 @@ void AsteroidStyle::drawPrimitive(TQ_PrimitiveElement pe, p->setPen(active ? cg.highlightedText() : cg.buttonText()); - TQRect rr = TQRect(xp, y, w, h); + TQRect rr = TQRect(xp, y, checkcol, h); if (backwards) { rr = visualRect(rr, r); } @@ -1600,7 +1611,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce, p->drawPixmap(pmr.topLeft(), pixmap); } else if (checkable) { if (mi->isChecked()) { - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(x, y, checkcol, sh), cg, sf); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, sf, o); } } @@ -2327,6 +2338,12 @@ int AsteroidStyle::pixelMetric(PixelMetric pm, TQStyleControlElementData ceData, case PM_SplitterWidth: return TQMAX( 4, TQApplication::globalStrut().width() ); + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 0; + default: { return KStyle::pixelMetric(pm, ceData, elementFlags, w); } diff --git a/kstyles/highcolor/highcolor.cpp b/kstyles/highcolor/highcolor.cpp index c659f7451..01da51717 100644 --- a/kstyles/highcolor/highcolor.cpp +++ b/kstyles/highcolor/highcolor.cpp @@ -856,21 +856,23 @@ void HighColorStyle::drawPrimitive( TQ_PrimitiveElement pe, case PE_MenuItemIndicatorFrame: { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect(x, y, w, h), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); - int cx = reverse ? x+w - w : x; + int cx = reverse ? x+w - checkcol : x; // We only have to draw the background if the menu item is inactive - // if it's active the "pressed" background is already drawn if ( ! active ) - qDrawShadePanel( p, cx, y, w, h, cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); + qDrawShadePanel( p, cx, y, checkcol, h, cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); } break; case PE_MenuItemIndicatorIconFrame: { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect(x, y, w, h), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); } break; @@ -878,15 +880,16 @@ void HighColorStyle::drawPrimitive( TQ_PrimitiveElement pe, case PE_MenuItemIndicatorCheck: { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect(x, y, w, h), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); - int cx = reverse ? x+w - w : x; + int cx = reverse ? x+w - checkcol : x; // Draw the checkmark SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( cx + itemFrame, y + itemFrame, w - itemFrame*2, h - itemFrame*2), cg, cflags ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( cx + itemFrame, y + itemFrame, checkcol - itemFrame*2, h - itemFrame*2), cg, cflags ); } break; @@ -1383,7 +1386,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element, // Do we have an icon and are checked at the same time? // Then draw a "pressed" background behind the icon if ( checkable && !active && mi->isChecked() ) - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags, opt); // Draw the icon TQPixmap pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode ); TQRect pmr( 0, 0, pixmap.width(), pixmap.height() ); @@ -1393,8 +1396,8 @@ void HighColorStyle::drawControl( TQ_ControlElement element, // Are we checked? (This time without an icon) else if ( checkable && mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags, opt); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags, opt); } // Time to draw the menu item label... @@ -1854,11 +1857,41 @@ int HighColorStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, return 13; // 13x13 } + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 0; + default: return KStyle::pixelMetric(m, ceData, elementFlags, widget); } } +/*! \reimp */ +int HighColorStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + ret = checkcol; + } + break; + default: + ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} TQSize HighColorStyle::sizeFromContents( ContentsType contents, TQStyleControlElementData ceData, diff --git a/kstyles/highcolor/highcolor.h b/kstyles/highcolor/highcolor.h index 461902403..7f3d7a8e8 100644 --- a/kstyles/highcolor/highcolor.h +++ b/kstyles/highcolor/highcolor.h @@ -158,6 +158,10 @@ class HighColorStyle : public KStyle const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; + int styleHint(TQ_StyleHint, TQStyleControlElementData ceData, ControlElementFlags elementFlags, + const TQStyleOption & = TQStyleOption::Default, + TQStyleHintReturn * = 0, const TQWidget * = 0 ) const; + virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); protected: diff --git a/kstyles/highcontrast/highcontrast.cpp b/kstyles/highcontrast/highcontrast.cpp index d54caf69b..82734b7b3 100644 --- a/kstyles/highcontrast/highcontrast.cpp +++ b/kstyles/highcontrast/highcontrast.cpp @@ -642,7 +642,8 @@ void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect(x, y, w, h), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); drawRect (p, cr, 0, false); break; } @@ -650,9 +651,12 @@ void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect(x, y, w, h), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); - TQRect rc (x, y, w, h); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); + bool reverse = TQApplication::reverseLayout(); + int cx = reverse ? x+w - checkcol : x; + TQRect rc (cx, y, checkcol, h); addOffset (&rc, 2*basicLineWidth); TQPoint center = rc.center(); if (rc.width() > rc.height()) @@ -1078,15 +1082,13 @@ void HighContrastStyle::drawControl (TQ_ControlElement element, // Then draw a square border around the icon if ( checkable && mi->isChecked() ) { - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); } } // Are we checked? (This time without an icon) else if ( checkable && mi->isChecked() ) { - int cx = reverse ? x+w - checkcol : x; - - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(cx, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } // Time to draw the menu item label... @@ -1686,6 +1688,12 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa return 5*basicLineWidth; } + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 0; + default: return KStyle::pixelMetric(m, ceData, elementFlags, widget); } @@ -1846,5 +1854,30 @@ bool HighContrastStyle::objectEventHandler( TQStyleControlElementData ceData, Co return KStyle::objectEventHandler (ceData, elementFlags, source, event); } +/*! \reimp */ +int HighContrastStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + ret = checkcol; + } + break; + default: + ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + // vim: set noet ts=4 sw=4: // kate: indent-width 4; replace-tabs off; smart-indent on; tab-width 4; diff --git a/kstyles/highcontrast/highcontrast.h b/kstyles/highcontrast/highcontrast.h index 0831163fe..a01f733d7 100644 --- a/kstyles/highcontrast/highcontrast.h +++ b/kstyles/highcontrast/highcontrast.h @@ -149,6 +149,10 @@ class HighContrastStyle : public KStyle TQRect subRect (SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const; + int styleHint(TQ_StyleHint, TQStyleControlElementData ceData, ControlElementFlags elementFlags, + const TQStyleOption & = TQStyleOption::Default, + TQStyleHintReturn * = 0, const TQWidget * = 0 ) const; + protected: virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); diff --git a/kstyles/keramik/keramik.cpp b/kstyles/keramik/keramik.cpp index 5cad1a6ee..55534a03f 100644 --- a/kstyles/keramik/keramik.cpp +++ b/kstyles/keramik/keramik.cpp @@ -1140,7 +1140,8 @@ void KeramikStyle::drawPrimitive( TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); } break; @@ -1148,7 +1149,8 @@ void KeramikStyle::drawPrimitive( TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); } break; @@ -1156,7 +1158,8 @@ void KeramikStyle::drawPrimitive( TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; @@ -1707,7 +1710,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element, // Do we have an icon and are checked at the same time? // Then draw a "pressed" background behind the icon if ( checkable && /*!active &&*/ mi->isChecked() ) - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); // Draw the icon TQPixmap pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode ); TQRect pmr( 0, 0, pixmap.width(), pixmap.height() ); @@ -1721,9 +1724,9 @@ void KeramikStyle::drawControl( TQ_ControlElement element, // We only have to draw the background if the menu item is inactive - // if it's active the "pressed" background is already drawn // if ( ! active ) - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); // Draw the checkmark - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } // Time to draw the menu item label... @@ -2448,6 +2451,12 @@ int KeramikStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, C case PM_TitleBarHeight: return titleBarH; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 2; + default: return KStyle::pixelMetric(m, ceData, elementFlags, widget); } @@ -2962,5 +2971,30 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control return false; } +/*! \reimp */ +int KeramikStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + ret = checkcol; + } + break; + default: + ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + // vim: ts=4 sw=4 noet // kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off; diff --git a/kstyles/keramik/keramik.h b/kstyles/keramik/keramik.h index d40b21dda..c9ec49639 100644 --- a/kstyles/keramik/keramik.h +++ b/kstyles/keramik/keramik.h @@ -135,6 +135,10 @@ public: const TQStyleOption& opt = TQStyleOption::Default, const TQWidget* widget = 0 ) const; + int styleHint(TQ_StyleHint, TQStyleControlElementData ceData, ControlElementFlags elementFlags, + const TQStyleOption & = TQStyleOption::Default, + TQStyleHintReturn * = 0, const TQWidget * = 0 ) const; + private slots: //Animation slots. void updateProgressPos(); diff --git a/kstyles/kthemestyle/kthemestyle.cpp b/kstyles/kthemestyle/kthemestyle.cpp index f79bb3765..d6da82173 100644 --- a/kstyles/kthemestyle/kthemestyle.cpp +++ b/kstyles/kthemestyle/kthemestyle.cpp @@ -390,6 +390,12 @@ int KThemeStyle::pixelMetric ( PixelMetric metric, TQStyleControlElementData ceD case PM_SplitterWidth: return ( splitWidth() ); + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 0; + default: return KThemeBase::pixelMetric ( metric, ceData, elementFlags, widget ); } @@ -1096,7 +1102,11 @@ void KThemeStyle::drawPrimitive ( PrimitiveElement pe, TQPainter * p, TQStyleCon { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x, y, w, h ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + bool reverse = TQApplication::reverseLayout(); + + int cx = reverse ? x + w - checkcol : x; + TQRect cr = visualRect( TQRect( x, y, checkcol, h ), r ); const TQColorGroup& cg_ours = *colorGroup( g_base, active ? MenuItemDown : MenuItem ); drawBaseButton( p, cr.x(), cr.y(), cr.width(), cr.height(), *colorGroup( cg_ours, BevelDown ), true, false, BevelDown ); break; @@ -1105,13 +1115,17 @@ void KThemeStyle::drawPrimitive ( PrimitiveElement pe, TQPainter * p, TQStyleCon { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x, y, w, h ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + bool reverse = TQApplication::reverseLayout(); + + int cx = reverse ? x + w - checkcol : x; + TQRect cr = visualRect( TQRect( x, y, checkcol, h ), r ); const TQColorGroup& cg_ours = *colorGroup( g_base, active ? MenuItemDown : MenuItem ); SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; - drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( x + itemFrame, y + itemFrame, w - itemFrame * 2, h - itemFrame * 2 ), cg_ours, cflags ); + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( x + itemFrame, y + itemFrame, checkcol - itemFrame * 2, h - itemFrame * 2 ), cg_ours, cflags ); break; } default: @@ -1554,7 +1568,7 @@ void KThemeStyle::drawControl( ControlElement element, // Do we have an icon and are checked at the same time? // Then draw a "pressed" background behind the icon if ( checkable && mi->isChecked() ) //!active && -- ?? - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(x, y, checkcol, h), cg, how); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, how, opt); // Draw the icon TQPixmap pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode ); @@ -1569,8 +1583,6 @@ void KThemeStyle::drawControl( ControlElement element, // Are we checked? (This time without an icon) else if ( checkable && mi->isChecked() ) { - int cx = reverse ? x + w - checkcol : x; - // We only have to draw the background if the menu item is inactive - // if it's active the "pressed" background is already drawn //if ( ! active ) @@ -1578,7 +1590,7 @@ void KThemeStyle::drawControl( ControlElement element, // &cg_ours.brush(TQColorGroup::Midlight) ); // Draw the checkmark - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(cx, y, checkcol, h), cg, how); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, how, opt); } // Time to draw the menu item label... @@ -2256,6 +2268,18 @@ int KThemeStyle::styleHint( StyleHint sh, TQStyleControlElementData ceData, Cont case SH_ScrollBar_BackgroundMode: return NoBackground; + case SH_MenuIndicatorColumnWidth: + { + int checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + return checkcol; + break; + } + default: return KThemeBase::styleHint( sh, ceData, elementFlags, opt, shr, w ); }; diff --git a/kstyles/light/lightstyle-v2.cpp b/kstyles/light/lightstyle-v2.cpp index e39c7c9b1..c96f636de 100644 --- a/kstyles/light/lightstyle-v2.cpp +++ b/kstyles/light/lightstyle-v2.cpp @@ -562,12 +562,24 @@ void LightStyleV2::drawPrimitive( TQ_PrimitiveElement pe, case PE_MenuItemIndicatorFrame: case PE_MenuItemIndicatorIconFrame: { - qDrawShadePanel(p, r, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, data, NULL, NULL); + TQRect cr(r.left(), r.top(), checkcol, r.height()); + bool reverse = TQApplication::reverseLayout(); + if ( reverse ) { + cr = visualRect( cr, r ); + } + qDrawShadePanel(p, cr, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); } break; case PE_MenuItemIndicatorCheck: { - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | Style_On); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, data, NULL, NULL); + TQRect cr(r.left(), r.top(), checkcol, r.height()); + bool reverse = TQApplication::reverseLayout(); + if ( reverse ) { + cr = visualRect( cr, r ); + } + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg, (flags & Style_Enabled) | Style_On); } break; @@ -849,7 +861,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, if (mi->isChecked() && ! (flags & Style_Active) & (flags & Style_Enabled)) - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, cr, cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, data); if (mi->iconSet()) { TQIconSet::Mode mode = @@ -868,7 +880,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, p->setPen(cg.text()); p->drawPixmap(pmr.topLeft(), pixmap); } else if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, cr, cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, data); TQColor textcolor; TQColor embosscolor; @@ -1496,6 +1508,13 @@ int LightStyleV2::pixelMetric( PixelMetric metric, TQStyleControlElementData ceD ret = -1; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 0; + break; + default: ret = TQCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -1638,6 +1657,15 @@ int LightStyleV2::styleHint( TQ_StyleHint stylehint, ret = 0; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = option.maxIconWidth(); + maxpmw = QMAX(maxpmw, 16); + + ret = maxpmw; + } + break; + default: ret = TQCommonStyle::styleHint(stylehint, ceData, elementFlags, option, returnData, widget); break; diff --git a/kstyles/light/lightstyle-v3.cpp b/kstyles/light/lightstyle-v3.cpp index b76c7bda3..d14035c17 100644 --- a/kstyles/light/lightstyle-v3.cpp +++ b/kstyles/light/lightstyle-v3.cpp @@ -751,12 +751,24 @@ void LightStyleV3::drawPrimitive( TQ_PrimitiveElement pe, case PE_MenuItemIndicatorFrame: case PE_MenuItemIndicatorIconFrame: { - qDrawShadePanel(p, r, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, data, NULL, NULL); + TQRect cr(r.left(), r.top(), checkcol, r.height()); + bool reverse = TQApplication::reverseLayout(); + if ( reverse ) { + cr = visualRect( cr, r ); + } + qDrawShadePanel(p, cr, cg, true, 1, &cg.brush(TQColorGroup::Midlight)); } break; case PE_MenuItemIndicatorCheck: { - drawPrimitive(PE_CheckMark, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | Style_On); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, data, NULL, NULL); + TQRect cr(r.left(), r.top(), checkcol, r.height()); + bool reverse = TQApplication::reverseLayout(); + if ( reverse ) { + cr = visualRect( cr, r ); + } + drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg, (flags & Style_Enabled) | Style_On); } break; @@ -969,7 +981,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, if (mi->isChecked() && ! (flags & Style_Active) & (flags & Style_Enabled)) - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, cr, cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, data); if (mi->iconSet()) { TQIconSet::Mode mode = @@ -988,7 +1000,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, p->setPen(cg.text()); p->drawPixmap(pmr.topLeft(), pixmap); } else if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, cr, cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, data); TQColor textcolor; TQColor embosscolor; @@ -1711,6 +1723,13 @@ int LightStyleV3::pixelMetric( PixelMetric metric, TQStyleControlElementData ceD ret = -1; break; + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + ret = 0; + break; + default: ret = TQCommonStyle::pixelMetric(metric, ceData, elementFlags, widget); break; @@ -1870,6 +1889,15 @@ int LightStyleV3::styleHint( TQ_StyleHint stylehint, ret = NoBackground; break; + case SH_MenuIndicatorColumnWidth: + { + int maxpmw = option.maxIconWidth(); + maxpmw = QMAX(maxpmw, 16); + + ret = maxpmw; + } + break; + default: ret = TQCommonStyle::styleHint(stylehint, ceData, elementFlags, option, returnData, widget); break; diff --git a/kstyles/plastik/plastik.cpp b/kstyles/plastik/plastik.cpp index 5c50ced8c..393780b50 100644 --- a/kstyles/plastik/plastik.cpp +++ b/kstyles/plastik/plastik.cpp @@ -2074,7 +2074,8 @@ void PlastikStyle::drawPrimitive(TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); break; } @@ -2082,7 +2083,8 @@ void PlastikStyle::drawPrimitive(TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); qDrawShadePanel( p, cr.x(), cr.y(), cr.width(), cr.height(), cg, true, 1, &cg.brush(TQColorGroup::Midlight) ); break; } @@ -2090,7 +2092,8 @@ void PlastikStyle::drawPrimitive(TQ_PrimitiveElement pe, { int x, y, w, h; r.rect( &x, &y, &w, &h ); - TQRect cr = visualRect( TQRect( x + 2, y + 2, w - 1, h - 4 ), r );; + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect( x + 2, y + 2, checkcol - 1, h - 4 ), r ); // Draw the checkmark SFlags cflags = Style_On; if (enabled) @@ -2574,7 +2577,7 @@ void PlastikStyle::drawControl(TQ_ControlElement element, // Do we have an icon and are checked at the same time? // Then draw a "pressed" background behind the icon if ( checkable && /*!active &&*/ mi->isChecked() ) - drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, TQRect(r.x(), r.y(), checkcol, r.height()), cg, flags); + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); // Draw the icon TQPixmap pixmap = mi->iconSet()->pixmap(TQIconSet::Small, mode); TQRect pmr( 0, 0, pixmap.width(), pixmap.height() ); @@ -2588,9 +2591,9 @@ void PlastikStyle::drawControl(TQ_ControlElement element, // We only have to draw the background if the menu item is inactive - // if it's active the "pressed" background is already drawn // if ( ! active ) - drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, TQRect(r.x(), r.y(), checkcol, r.height()), cg, flags); + drawPrimitive(PE_MenuItemIndicatorFrame, p, ceData, elementFlags, r, cg, flags, opt); - drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, TQRect(r.x(), r.y(), checkcol, r.height()), cg, flags); + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); } // Time to draw the menu item label... @@ -3373,6 +3376,12 @@ int PlastikStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, C return 1; } + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 2; + default: return KStyle::pixelMetric(m, ceData, elementFlags, widget); } @@ -3478,6 +3487,17 @@ int PlastikStyle::styleHint( TQ_StyleHint stylehint, case SH_PopupMenu_SubMenuPopupDelay: return 96; // Motif-like delay... + case SH_MenuIndicatorColumnWidth: + { + int checkcol = option.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + return checkcol; + } + default: return KStyle::styleHint(stylehint, ceData, elementFlags, option, returnData, widget); }