diff options
Diffstat (limited to 'kstyles/highcolor')
-rw-r--r-- | kstyles/highcolor/highcolor.cpp | 53 | ||||
-rw-r--r-- | kstyles/highcolor/highcolor.h | 4 |
2 files changed, 47 insertions, 10 deletions
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: |