summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-11-11 18:04:45 -0600
committerTimothy Pearson <[email protected]>2012-11-11 18:04:45 -0600
commitcb48b1e673e66bb80ae7d804200721429e9ff335 (patch)
tree622adb288890813bff49c5bc879de764654fb554 /style
parent7e54430051de46008830a2b837ff26cf81a9503f (diff)
downloadtde-style-lipstik-cb48b1e673e66bb80ae7d804200721429e9ff335.tar.gz
tde-style-lipstik-cb48b1e673e66bb80ae7d804200721429e9ff335.zip
Fix crashes when used with third party toolkits
Diffstat (limited to 'style')
-rw-r--r--style/lipstik.cpp74
1 files changed, 30 insertions, 44 deletions
diff --git a/style/lipstik.cpp b/style/lipstik.cpp
index b5d581d..e587bbd 100644
--- a/style/lipstik.cpp
+++ b/style/lipstik.cpp
@@ -2686,9 +2686,9 @@ void LipstikStyle::drawControl(ControlElement element,
case CE_PushButton: {
TQPushButton *button = (TQPushButton *)widget;
- const bool isDefault = enabled && button->isDefault();
+ const bool isDefault = enabled && (elementFlags & CEF_IsDefault);
- if (button->isFlat() )
+ if (elementFlags & CEF_IsFlat)
flatMode = true;
TQColorGroup g2 = cg;
@@ -2710,8 +2710,7 @@ void LipstikStyle::drawControl(ControlElement element,
int x, y, w, h;
r.rect( &x, &y, &w, &h );
- const TQPushButton* button = static_cast<const TQPushButton *>( widget );
- bool active = button->isOn() || button->isDown();
+ bool active = (elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown);
bool cornArrow = false;
// Shift button contents if pushed.
@@ -2723,11 +2722,11 @@ void LipstikStyle::drawControl(ControlElement element,
}
// Does the button have a popup menu?
- if ( button->isMenuButton() )
+ if (elementFlags & CEF_IsMenuWidget)
{
int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget );
- if ( button->iconSet() && !button->iconSet()->isNull() &&
- (dx + button->iconSet()->pixmap (TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off ).width()) >= w )
+ if ( !ceData.iconSet.isNull() &&
+ (dx + ceData.iconSet.pixmap (TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off ).width()) >= w )
{
cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust the widget
}
@@ -2741,19 +2740,19 @@ void LipstikStyle::drawControl(ControlElement element,
}
// Draw the icon if there is one
- if ( button->iconSet() && !button->iconSet()->isNull() )
+ if ( !ceData.iconSet.isNull() )
{
TQIconSet::Mode mode = TQIconSet::Disabled;
TQIconSet::State state = TQIconSet::Off;
- if (button->isEnabled())
- mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal;
- if (button->isToggleButton() && button->isOn())
+ if (elementFlags & CEF_IsEnabled)
+ mode = (elementFlags & CEF_HasFocus) ? TQIconSet::Active : TQIconSet::Normal;
+ if ((elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn))
state = TQIconSet::On;
- TQPixmap pixmap = button->iconSet()->pixmap( TQIconSet::Small, mode, state );
+ TQPixmap pixmap = ceData.iconSet.pixmap( TQIconSet::Small, mode, state );
- if (button->text().isEmpty() && !button->pixmap())
+ if (ceData.text.isEmpty() && ceData.fgPixmap.isNull())
p->drawPixmap( x + w/2 - pixmap.width()/2, y + h / 2 - pixmap.height() / 2,
pixmap );
else
@@ -2770,9 +2769,9 @@ void LipstikStyle::drawControl(ControlElement element,
}
// Make the label indicate if the button is a default button or not
- drawItem( p, TQRect(x, y, w, h), AlignCenter|ShowPrefix, button->colorGroup(),
- button->isEnabled(), button->pixmap(), button->text(), -1,
- &button->colorGroup().buttonText() );
+ drawItem( p, TQRect(x, y, w, h), AlignCenter|ShowPrefix, ceData.colorGroup,
+ (elementFlags & CEF_IsEnabled), (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text, -1,
+ &ceData.colorGroup.buttonText() );
if ( flags & Style_HasFocus )
@@ -3234,14 +3233,10 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
static const unsigned int handleWidth = 15;
const TQComboBox *cb = dynamic_cast<const TQComboBox *>(widget);
- // at the moment cb is only needed to check if the combo box is editable or not.
- // if cb doesn't exist, just assume false and the app (gideon! ;) ) at least doesn't crash.
bool editable = false;
bool hasFocus = false;
- if (cb) {
- editable = cb->editable();
- hasFocus = cb->hasFocus();
- }
+ editable = (elementFlags & CEF_IsEditable);
+ hasFocus = (elementFlags & CEF_HasFocus);
const TQColor buttonColor = enabled?cg.button():cg.background();
const TQColor inputColor = enabled?(editable?cg.base():cg.button())
@@ -3397,8 +3392,6 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
// TOOLBUTTON
// ----------
case CC_ToolButton: {
- const TQToolButton *tb = (const TQToolButton *) widget;
-
TQRect button, menuarea;
button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget);
menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget);
@@ -3444,16 +3437,14 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
if (controls & SC_ToolButton) {
// If we're pressed, on, or raised...
if (bflags & (Style_Down | Style_On | Style_Raised) || (flags & Style_MouseOver)) {
- if ( (flags & Style_MouseOver) && tb->parentWidget()->inherits( "KTabWidget" )) {
+ if ( (flags & Style_MouseOver) && ceData.parentWidgetData.widgetObjectTypes.contains( "KTabWidget" )) {
renderButton(p, r, cg, false, true, false, true, false );
} else {
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt);
}
- } else if (tb->parentWidget() &&
- tb->parentWidget()->backgroundPixmap() &&
- !tb->parentWidget()->backgroundPixmap()->isNull()) {
- TQPixmap pixmap = *(tb->parentWidget()->backgroundPixmap());
- p->drawTiledPixmap( r, pixmap, tb->pos() );
+ } else if (!ceData.parentWidgetData.bgPixmap.isNull()) {
+ TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
+ p->drawTiledPixmap( r, pixmap, ceData.pos );
}
}
@@ -3465,8 +3456,8 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt);
}
- if (tb->hasFocus() && !tb->focusProxy()) {
- TQRect fr = tb->rect();
+ if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
+ TQRect fr = ceData.rect;
fr.addCoords(2, 2, -2, -2);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg);
}
@@ -3483,13 +3474,11 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
case CC_SpinWidget: {
static const unsigned int handleWidth = 15;
- const TQSpinWidget *sw = dynamic_cast<const TQSpinWidget *>(widget);
SFlags sflags = flags;
PrimitiveElement pe;
bool hasFocus = false;
- if (sw)
- hasFocus = sw->hasFocus();
+ hasFocus = (elementFlags & CEF_HasFocus);
const TQColor buttonColor = enabled?cg.button():cg.background();
const TQColor inputColor = enabled?cg.base():cg.background();
@@ -3588,7 +3577,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
sflags |= Style_Sunken;
} else
sflags |= Style_Raised;
- if (sw->buttonSymbols() == TQSpinWidget::PlusMinus)
+ if (ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus)
pe = PE_SpinWidgetPlus;
else
pe = PE_SpinWidgetUp;
@@ -3601,7 +3590,7 @@ void LipstikStyle::drawComplexControl(ComplexControl control,
sflags |= Style_Sunken;
} else
sflags |= Style_Raised;
- if (sw->buttonSymbols() == TQSpinWidget::PlusMinus)
+ if (ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus)
pe = PE_SpinWidgetMinus;
else
pe = PE_SpinWidgetDown;
@@ -3873,14 +3862,13 @@ TQSize LipstikStyle::sizeFromContents(ContentsType t,
{
switch (t) {
case CT_PopupMenuItem: {
- if (!widget || opt.isDefault())
+ if (opt.isDefault())
return s;
- const TQPopupMenu *popup = dynamic_cast<const TQPopupMenu *>(widget);
TQMenuItem *mi = opt.menuItem();
int maxpmw = opt.maxIconWidth();
int w = s.width(), h = s.height() + _menuSpacing;
- bool checkable = popup->isCheckable();
+ bool checkable = (elementFlags & CEF_IsCheckable);
if (mi->custom()) {
w = mi->custom()->sizeHint().width();
@@ -3897,7 +3885,7 @@ TQSize LipstikStyle::sizeFromContents(ContentsType t,
h = TQMAX(h, mi->pixmap()->height() + 2);
} else {
h = TQMAX(h, 16 + 2);
- h = TQMAX(h, popup->fontMetrics().height() + 4 );
+ h = TQMAX(h, TQFontMetrics(ceData.font).height() + 4 );
}
if (mi->iconSet()) {
@@ -3928,11 +3916,9 @@ TQSize LipstikStyle::sizeFromContents(ContentsType t,
case CT_PushButton:
{
- const TQPushButton* btn = static_cast<const TQPushButton*>(widget);
-
int w = s.width() + 2 * pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget);
int h = s.height() + 2 * pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget);
- if ( btn->text().isEmpty() && s.width() < 32 ) return TQSize(w, h);
+ if ( ceData.text.isEmpty() && s.width() < 32 ) return TQSize(w, h);
return TQSize( w+25, h+5 );
}