Do not use direct widget access when drawing tabs and popup menus

pull/1/head
Timothy Pearson 12 years ago
parent 84e18380bc
commit dc6c9f70cf

@ -4525,22 +4525,21 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
{
case CE_TabBarTab:
{
const TQTabBar *tb((const TQTabBar *)widget);
int tabIndex(tb->indexOf(data.tab()->identifier())),
int tabIndex(ceData.tabBarData.identIndexMap[data.tab()->identifier()]),
dark(APPEARANCE_FLAT==opts.appearance ? ORIGINAL_SHADE : FRAME_DARK_SHADOW),
moOffset(ROUNDED_NONE==opts.round || TAB_MO_TOP!=opts.tabMouseOver ? 1 : opts.round);
bool cornerWidget(false),
bottomCornerWidget(false),
reverse(TQApplication::reverseLayout()),
firstTab(0==tabIndex),
lastTab((tb->count()-1)==tabIndex),
lastTab((ceData.tabBarData.tabCount-1)==tabIndex),
// isFirstKTabCtlTab(firstTab && widget->parent()
// ? 0==qstrcmp("KTabCtl", widget->parent()->className())
// : false),
active(flags & Style_Selected),
itsHover(itsHoverTab && itsHoverTab->isEnabled() && data.tab()==itsHoverTab &&
!(flags&Style_Selected) &&
tb->currentTab()!=tabIndex),
ceData.tabBarData.currentTabIndex!=tabIndex),
glowMo(!active && itsHover && opts.coloredMouseOver && TAB_MO_GLOW==opts.tabMouseOver);
int sizeAdjust(!active && TAB_MO_GLOW==opts.tabMouseOver ? 1 : 0);
const TQColor &fill(getTabFill(flags&Style_Selected, itsHover, itsBackgroundCols));
@ -4560,19 +4559,15 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
firstTab=oldLast;
}
if(::tqqt_cast<const TQTabWidget *>(tb->parent()))
{
const TQTabWidget *tw((const TQTabWidget*)tb->parent());
// is there a corner widget in the (top) left edge?
if(tw->cornerWidget(TQt::TopLeft))
if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes.isEmpty()) {
cornerWidget=true;
if(tw->cornerWidget(TQt::BottomLeft))
}
if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes.isEmpty()) {
bottomCornerWidget=true;
}
TQRect tr(r);
bool top(TQTabBar::TriangularAbove==tb->shape() || TQTabBar::RoundedAbove==tb->shape());
bool top(TQTabBar::TriangularAbove==ceData.tabBarData.shape || TQTabBar::RoundedAbove==ceData.tabBarData.shape);
if(active && opts.tabBgnd)
{
@ -4773,13 +4768,13 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
TQRect tr(r);
int shift(pixelMetric(PM_TabBarTabShiftVertical, ceData, elementFlags, tb));
if (t->identifier() == tb->currentTab())
if (t->identifier() == ceData.tabBarData.currentTabIndex)
{
if(TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape())
if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
tr.addCoords(0, -shift, 0, -shift);
}
else
if(TQTabBar::RoundedBelow==tb->shape() || TQTabBar::TriangularBelow==tb->shape())
if(TQTabBar::RoundedBelow==ceData.tabBarData.shape || TQTabBar::TriangularBelow==ceData.tabBarData.shape)
tr.addCoords(0, shift, 0, shift);
if(APP_MACTOR==itsThemedApp)
@ -4788,7 +4783,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
if(t->iconSet())
{
TQIconSet::Mode mode((t->isEnabled() && tb->isEnabled())
TQIconSet::Mode mode((t->isEnabled() && (elementFlags & CEF_IsEnabled))
? TQIconSet::Normal : TQIconSet::Disabled);
if (mode == TQIconSet::Normal && (flags&Style_HasFocus))
@ -4815,7 +4810,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
{
TQRect fr(r);
if(TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape())
if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
fr.addCoords(0, 1, 0, -1);
else
fr.addCoords(0, 0, 0, -1);
@ -4942,7 +4937,6 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
if(!widget || data.isDefault())
break;
const TQPopupMenu *popupmenu((const TQPopupMenu *)widget);
TQMenuItem *mi(data.menuItem());
int tab(data.tabWidth()),
maxpmw(data.maxIconWidth()),
@ -5015,7 +5009,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
// Do we have an icon and are checked at the same time?
// Then draw a "pressed" background behind the icon
if(popupmenu->isCheckable() && mi->isChecked())
if((elementFlags & CEF_IsCheckable) && mi->isChecked())
drawLightBevel((flags & Style_Active)&&(flags & Style_Enabled)
? itsHighlightCols[ORIGINAL_SHADE]
: cg.background(), p, TQRect(cr.x()+1, cr.y()+2, cr.width()-2, cr.height()-4),
@ -5030,7 +5024,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
pmr.moveCenter(cr.center());
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|(opts.useHighlightForMenu ? Style_Active : 0)))| Style_On|MENU_ITEM);
@ -6832,10 +6826,8 @@ int QtCurveStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceDa
#if 0x039999 >= 0x030200
case PM_TabBarTabShiftVertical:
{
const TQTabBar *tb=widget ? ::tqqt_cast<const TQTabBar *>(widget) : 0;
return tb
? TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape()
return (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING))
? TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape
? 1
: -1
: BASE_STYLE::pixelMetric(metric, ceData, elementFlags, widget);
@ -6966,7 +6958,6 @@ TQSize QtCurveStyle::sizeFromContents(ContentsType contents, TQStyleControlEleme
const int constMinH(opts.thinnerMenuItems ? 25 : 27);
TQMenuItem *mi(data.menuItem());
const TQPopupMenu *popupmenu(static_cast<const TQPopupMenu *>(widget));
int maxpmw(data.maxIconWidth()),
w(contentsSize.width()), h(contentsSize.height());
@ -6993,7 +6984,7 @@ TQSize QtCurveStyle::sizeFromContents(ContentsType contents, TQStyleControlEleme
if (mi->pixmap())
h = TQMAX(h, mi->pixmap()->height());
else if (!mi->text().isNull())
h = TQMAX(h, popupmenu->fontMetrics().height() + 2);
h = TQMAX(h, TQFontMetrics(ceData.font).height() + 2);
if (mi->iconSet()!= 0)
h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height());
h+=(opts.thinnerMenuItems ? 2 : 4);

Loading…
Cancel
Save