Fix style crashes when used with third party toolkits

pull/16/head
Timothy Pearson 12 years ago
parent 03733ab120
commit 189c12d0b1

@ -588,7 +588,7 @@ void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe,
setColorsText (p, cg, flags, 0);
drawRoundRect (p, r);
if (flags & (Style_HasFocus | Style_Active))
tqdrawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
break;
}
case PE_PanelTabWidget:
@ -687,7 +687,7 @@ void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe,
}
default: {
KStyle::tqdrawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
KStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
}
}
}
@ -847,9 +847,9 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
}
if ( btnDefault && (elementFlags & CEF_IsEnabled))
tqdrawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags );
drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags );
tqdrawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags );
drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags );
break;
}
@ -931,7 +931,7 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
// Draw a focus rect if the button has focus
if (flags & Style_HasFocus)
tqdrawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
// Draw the label itself
TQColor color = p->pen().color();
@ -976,14 +976,14 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
// CHECKBOX
// -------------------------------------------------------------------
case CE_CheckBox: {
tqdrawPrimitive (PE_Indicator, p, ceData, elementFlags, r, cg, flags);
drawPrimitive (PE_Indicator, p, ceData, elementFlags, r, cg, flags);
break;
}
// RADIOBUTTON
// -------------------------------------------------------------------
case CE_RadioButton: {
tqdrawPrimitive (PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags);
drawPrimitive (PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags);
break;
}
@ -991,31 +991,25 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
// -------------------------------------------------------------------
case CE_ProgressBarGroove: {
setColorsText (p, cg, flags);
const TQProgressBar *progressbar = dynamic_cast<const TQProgressBar*>(widget);
if (progressbar) {
TQRect r2 (r);
r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, progressbar->progressString()).right()
r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, ceData.progressText).right()
+ 4*basicLineWidth);
drawRoundRect (p, r2);
}
break;
}
case CE_ProgressBarContents: {
const TQProgressBar *progressbar = dynamic_cast<const TQProgressBar*>(widget);
if (progressbar)
{
TQRect r2 (r);
r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, progressbar->progressString()).right()
r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, ceData.progressText).right()
+ 4*basicLineWidth);
long progress = r2.width() * progressbar->progress();
if (progressbar->totalSteps() > 0)
long progress = r2.width() * ceData.currentStep;
if (ceData.totalSteps > 0)
{
r2.setWidth (progress / progressbar->totalSteps());
r2.setWidth (progress / ceData.totalSteps);
}
else
{
int width = r2.width() / 5;
int left = progressbar->progress() % (2*(r2.width() - width));
int left = ceData.currentStep % (2*(r2.width() - width));
if (left > r2.width() - width)
left = 2*(r2.width() - width) - left;
r2.setLeft (r2.left() + left);
@ -1024,7 +1018,6 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
setColorsHighlight (p, cg, flags);
if (r2.width() > 0)
drawRoundRect (p, r2);
}
break;
}
@ -1242,7 +1235,7 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
else
r3.setLeft (r2.right()-basicLineWidth+1);
tqdrawPrimitive (PE_FocusRect, p, ceData, elementFlags, r3, cg, flags, TQStyleOption (p->backgroundColor()));
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r3, cg, flags, TQStyleOption (p->backgroundColor()));
}
setColorsButton (p, cg, flags);
@ -1263,7 +1256,7 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
setColorsText (p, cg, flags);
drawRoundRect (p, r);
if (flags & Style_HasFocus)
tqdrawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
}
setColorsButton (p, cg, flags);
@ -1286,8 +1279,6 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
// TOOLBUTTON
// -------------------------------------------------------------------
case CC_ToolButton: {
const TQToolButton *toolbutton = (const TQToolButton *) widget;
setColorsButton (p, cg, flags);
p->fillRect (r, p->backgroundColor ());
@ -1307,15 +1298,13 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
{
// If we're pressed, on, or raised...
if (bflags & (Style_Down | Style_On | Style_Raised))
tqdrawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt);
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt);
// Check whether to draw a background pixmap
else if ( toolbutton->parentWidget() &&
toolbutton->parentWidget()->backgroundPixmap() &&
!toolbutton->parentWidget()->backgroundPixmap()->isNull() )
else if ( !ceData.parentWidgetData.bgPixmap.isNull() )
{
TQPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap());
p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, ceData.pos );
}
}
@ -1323,14 +1312,14 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
if (controls & SC_ToolButtonMenu)
{
if (mflags & (Style_Down | Style_On | Style_Raised))
tqdrawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt);
drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt);
drawArrow (p, menuarea, PE_ArrowDown);
}
if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
TQRect fr = ceData.rect;
addOffset (&fr, 3);
tqdrawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor()));
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor()));
}
break;

@ -2184,15 +2184,14 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
}
case CC_ScrollBar:
{
const TQScrollBar* sb = static_cast< const TQScrollBar* >( widget );
if (highlightScrollBar && sb->parentWidget()) //Don't do the check if not highlighting anyway
if (highlightScrollBar && (elementFlags & CEF_HasParentWidget)) //Don't do the check if not highlighting anyway
{
if (sb->parentWidget()->colorGroup().button() != sb->colorGroup().button())
if (ceData.parentWidgetData.colorGroup.button() != ceData.colorGroup.button())
customScrollMode = true;
}
bool horizontal = sb->orientation() == Qt::Horizontal;
bool horizontal = ceData.orientation == TQt::Horizontal;
TQRect slider, subpage, addpage, subline, addline;
if ( sb->minValue() == sb->maxValue() ) flags &= ~Style_Enabled;
if ( ceData.minSteps == ceData.maxSteps ) flags &= ~Style_Enabled;
slider = querySubControlMetrics( control, ceData, elementFlags, SC_ScrollBarSlider, opt, widget );
subpage = querySubControlMetrics( control, ceData, elementFlags, SC_ScrollBarSubPage, opt, widget );
@ -2208,9 +2207,9 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if ( controls & SC_ScrollBarSubPage ) clip |= subpage;
if ( controls & SC_ScrollBarAddPage ) clip |= addpage;
if ( horizontal )
clip |= TQRect( slider.x(), 0, slider.width(), sb->height() );
clip |= TQRect( slider.x(), 0, slider.width(), ceData.rect.height() );
else
clip |= TQRect( 0, slider.y(), sb->width(), slider.height() );
clip |= TQRect( 0, slider.y(), ceData.rect.width(), slider.height() );
clip ^= slider;
p->setClipRegion( clip );

@ -2958,8 +2958,6 @@ void PlastikStyle::drawComplexControl(TQ_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);
@ -2986,11 +2984,10 @@ void PlastikStyle::drawComplexControl(TQ_ComplexControl control,
// If we're pressed, on, or raised...
if (bflags & (Style_Down | Style_On | Style_Raised) || (flags & Style_MouseOver) ) {
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 ((elementFlags & CEF_HasParentWidget) &&
!ceData.parentWidgetData.bgPixmap.isNull()) {
TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, ceData.pos );
}
}
@ -3002,8 +2999,8 @@ void PlastikStyle::drawComplexControl(TQ_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);
}

@ -1471,7 +1471,7 @@ TQRect KStyle::querySubControlMetrics( TQ_ComplexControl control,
bool platinumScrollBar = d->scrollbarType & PlatinumStyleScrollBar;
bool nextScrollBar = d->scrollbarType & NextStyleScrollBar;
bool horizontal = ceData.orientation == Qt::Horizontal;
bool horizontal = ceData.orientation == TQt::Horizontal;
int sliderstart = ceData.startStep;
int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
int maxlen = (horizontal ? ceData.rect.width() : ceData.rect.height())

Loading…
Cancel
Save