From fb2b1442644d0b35d004f3896efc0afa5a5b81a5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 17 Oct 2012 15:05:01 -0500 Subject: Do not use direct widget access when drawing tabs and popup menus --- kstyles/light/lightstyle-v2.cpp | 11 ++++------- kstyles/light/lightstyle-v3.cpp | 13 +++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'kstyles/light') diff --git a/kstyles/light/lightstyle-v2.cpp b/kstyles/light/lightstyle-v2.cpp index 8df9606ad..a77a5fe03 100644 --- a/kstyles/light/lightstyle-v2.cpp +++ b/kstyles/light/lightstyle-v2.cpp @@ -631,7 +631,6 @@ void LightStyleV2::drawControl( TQ_ControlElement control, switch (control) { case CE_TabBarTab: { - const TQTabBar* tb = static_cast(widget); bool below = false; TQRect tr(r); TQRect fr(r); @@ -639,7 +638,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, tr.addCoords(0, 0, 0, -1); fr.addCoords(2, 2, -2, -2); - if ( tb->shape() == TQTabBar::RoundedBelow || tb->shape() == TQTabBar::TriangularBelow) { + if ( ceData.tabBarData.shape == TQTabBar::RoundedBelow || ceData.tabBarData.shape == TQTabBar::TriangularBelow) { tr = r; tr.addCoords(0, 1, 0, 0); fr = r; fr.addCoords(2, 2,-2, -4); below = true; @@ -784,7 +783,6 @@ void LightStyleV2::drawControl( TQ_ControlElement control, if (! widget || data.isDefault()) break; - const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget; TQMenuItem *mi = data.menuItem(); int tab = data.tabWidth(); int maxpmw = data.maxIconWidth(); @@ -847,7 +845,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, if ((flags & Style_Active) && (flags & Style_Enabled)) mode = TQIconSet::Active; TQPixmap pixmap; - if (popupmenu->isCheckable() && mi->isChecked()) + if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On ); else @@ -857,7 +855,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control, pmr.moveCenter(cr.center()); p->setPen(cg.text()); p->drawPixmap(pmr.topLeft(), pixmap); - } else if (popupmenu->isCheckable() && mi->isChecked()) + } else if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg, (flags & Style_Enabled) | Style_On); @@ -1538,7 +1536,6 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents, break; TQMenuItem *mi = data.menuItem(); - const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget; int maxpmw = data.maxIconWidth(); int w = contentsSize.width(), h = contentsSize.height(); @@ -1558,7 +1555,7 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents, if (mi->pixmap()) h = QMAX(h, mi->pixmap()->height()); else if (! mi->text().isNull()) - h = QMAX(h, popupmenu->fontMetrics().height() + 2); + h = QMAX(h, TQFontMetrics(ceData.font).height() + 2); if (mi->iconSet() != 0) h = QMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height()); diff --git a/kstyles/light/lightstyle-v3.cpp b/kstyles/light/lightstyle-v3.cpp index 97c9d2e0b..565b8ac2c 100644 --- a/kstyles/light/lightstyle-v3.cpp +++ b/kstyles/light/lightstyle-v3.cpp @@ -819,10 +819,9 @@ void LightStyleV3::drawControl( TQ_ControlElement control, switch (control) { case CE_TabBarTab: { - const TQTabBar *tb = (const TQTabBar *) widget; TQRect br = r; - if ( tb->shape() == TQTabBar::RoundedAbove ) { + if ( ceData.tabBarData.shape == TQTabBar::RoundedAbove ) { if ( ! ( flags & Style_Selected ) ) { p->setPen( cg.background() ); p->drawLine( br.left(), br.bottom(), @@ -857,7 +856,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, else br.addCoords( 1, 1, -1, 0 ); p->fillRect( br, cg.background() ); - } else if ( tb->shape() == TQTabBar::RoundedBelow ) { + } else if ( ceData.tabBarData.shape == TQTabBar::RoundedBelow ) { if ( ! ( flags & Style_Selected ) ) { p->setPen( cg.background() ); p->drawLine( br.left(), br.top(), @@ -906,7 +905,6 @@ void LightStyleV3::drawControl( TQ_ControlElement control, if (! widget || data.isDefault()) break; - const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget; TQMenuItem *mi = data.menuItem(); int tab = data.tabWidth(); int maxpmw = data.maxIconWidth(); @@ -967,7 +965,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, if ((flags & Style_Active) && (flags & Style_Enabled)) mode = TQIconSet::Active; TQPixmap pixmap; - if (popupmenu->isCheckable() && mi->isChecked()) + if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode, TQIconSet::On ); else @@ -977,7 +975,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control, pmr.moveCenter(cr.center()); p->setPen(cg.text()); p->drawPixmap(pmr.topLeft(), pixmap); - } else if (popupmenu->isCheckable() && mi->isChecked()) + } else if ((elementFlags & CEF_IsCheckable) && mi->isChecked()) drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg, (flags & Style_Enabled) | Style_On); @@ -1765,7 +1763,6 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents, break; TQMenuItem *mi = data.menuItem(); - const TQPopupMenu *popupmenu = (const TQPopupMenu *) widget; int maxpmw = data.maxIconWidth(); int w = contentsSize.width(), h = contentsSize.height(); @@ -1785,7 +1782,7 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents, if (mi->pixmap()) h = QMAX(h, mi->pixmap()->height()); else if (! mi->text().isNull()) - h = QMAX(h, popupmenu->fontMetrics().height() + 2); + h = QMAX(h, TQFontMetrics(ceData.font).height() + 2); if (mi->iconSet() != 0) h = QMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height()); -- cgit v1.2.1