Update to new style API

pull/16/head
Timothy Pearson 12 years ago
parent d26d6ac236
commit 884e5fa202

@ -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);
}

@ -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,

@ -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:

@ -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;

@ -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 );

@ -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;

@ -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();

@ -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 );
};

@ -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;

@ -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;

@ -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);
}

Loading…
Cancel
Save