Fix crashes in some styles when used with third party toolkits

pull/16/head
Timothy Pearson 12 years ago
parent 9f835b0b50
commit 03733ab120

@ -2113,7 +2113,12 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
} }
p2.end(); p2.end();
bitBlt((TQWidget*)w, r.x(), r.y(), &pix); if (w) {
bitBlt((TQWidget*)w, r.x(), r.y(), &pix);
}
else {
p->drawPixmap(r.topLeft(), pix);
}
break; break;
} }
@ -2429,10 +2434,6 @@ TQRect AsteroidStyle::querySubControlMetrics(TQ_ComplexControl cc,
SC_ListViewExpand SC_ListViewExpand
*/ */
case CC_ComboBox: { case CC_ComboBox: {
if (!w) {
return TQRect();
}
TQRect r(ceData.rect); TQRect r(ceData.rect);
switch (sc) { switch (sc) {
@ -2552,12 +2553,11 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct,
} }
case CT_PopupMenuItem: { case CT_PopupMenuItem: {
if (!w || o.isDefault()) { if (o.isDefault()) {
return TQSize(0, 0); return TQSize(0, 0);
} }
int sw = s.width(), sh = s.height(); int sw = s.width(), sh = s.height();
const TQPopupMenu *popup = dynamic_cast<const TQPopupMenu *>(w);
TQMenuItem *mi = o.menuItem(); TQMenuItem *mi = o.menuItem();
if (mi->custom()) { if (mi->custom()) {
@ -2588,7 +2588,7 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct,
int miw = o.maxIconWidth(); int miw = o.maxIconWidth();
if (miw) { if (miw) {
sw += miw; sw += miw;
if (popup->isCheckable()) { if (elementFlags & CEF_IsCheckable) {
sw += 20 - miw; sw += 20 - miw;
} }
} }

@ -838,15 +838,15 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
case CE_PushButton: { case CE_PushButton: {
TQPushButton *button = (TQPushButton*) widget; TQPushButton *button = (TQPushButton*) widget;
TQRect br = r; TQRect br = r;
bool btnDefault = button->isDefault(); bool btnDefault = (elementFlags & CEF_IsDefault);
if (( btnDefault || button->autoDefault() ) && (button->isEnabled())) { if (( btnDefault || (elementFlags & CEF_AutoDefault) ) && (elementFlags & CEF_IsEnabled)) {
// Compensate for default indicator // Compensate for default indicator
static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags );
addOffset (&br, di); addOffset (&br, di);
} }
if ( btnDefault && (button->isEnabled())) if ( btnDefault && (elementFlags & CEF_IsEnabled))
tqdrawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags ); tqdrawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags );
tqdrawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags ); tqdrawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags );
@ -875,8 +875,7 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
r.rect( &x, &y, &w, &h ); r.rect( &x, &y, &w, &h );
if (element == CE_ProgressBarLabel) { if (element == CE_ProgressBarLabel) {
TQProgressBar* progressbar = (TQProgressBar*) widget; text = ceData.progressText;
text = progressbar->progressString();
setColorsNormal (p, cg, flags); setColorsNormal (p, cg, flags);
} }
else if (element == CE_TabBarLabel) { else if (element == CE_TabBarLabel) {
@ -887,27 +886,24 @@ void HighContrastStyle::drawControl (TQ_ControlElement element,
setColorsNormal (p, cg, flags, Style_Selected); setColorsNormal (p, cg, flags, Style_Selected);
} }
else if (element == CE_ToolButtonLabel) { else if (element == CE_ToolButtonLabel) {
TQToolButton* toolbutton = (TQToolButton*) widget; text = ceData.text;
text = toolbutton->text(); pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap;
pixmap = toolbutton->pixmap(); if (!ceData.iconSet.isNull())
if (!toolbutton->iconSet().isNull()) icon = ceData.iconSet.pixmap (TQIconSet::Small, mode, state);
icon = toolbutton->iconSet().pixmap (TQIconSet::Small, mode, state); popup = (elementFlags & CEF_HasPopupMenu);
popup = toolbutton->popup();
setColorsButton (p, cg, flags); setColorsButton (p, cg, flags);
} }
else if (element == CE_PushButtonLabel) { else if (element == CE_PushButtonLabel) {
TQPushButton* pushbutton = (TQPushButton*) widget; text = ceData.text;
text = pushbutton->text(); pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap;
pixmap = pushbutton->pixmap(); if (!ceData.iconSet.isNull())
if (pushbutton->iconSet() && !pushbutton->iconSet()->isNull()) icon = ceData.iconSet.pixmap (TQIconSet::Small, mode, state);
icon = pushbutton->iconSet()->pixmap (TQIconSet::Small, mode, state); popup = (elementFlags & CEF_HasPopupMenu);
popup = pushbutton->popup();
setColorsButton (p, cg, flags); setColorsButton (p, cg, flags);
} }
else { else {
const TQButton* button = (const TQButton*)widget; pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap;
pixmap = button->pixmap(); text = ceData.text;
text = button->text();
setColorsNormal (p, cg); setColorsNormal (p, cg);
} }
@ -1331,8 +1327,8 @@ void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
drawArrow (p, menuarea, PE_ArrowDown); drawArrow (p, menuarea, PE_ArrowDown);
} }
if (toolbutton->hasFocus() && !toolbutton->focusProxy()) { if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
TQRect fr = toolbutton->rect(); TQRect fr = ceData.rect;
addOffset (&fr, 3); addOffset (&fr, 3);
tqdrawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor())); tqdrawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor()));
} }

@ -479,7 +479,7 @@ static void renderToolbarEntryBackground(TQPainter* paint,
toolWidth, toolHeight); toolWidth, toolHeight);
} }
static void renderToolbarWidgetBackground(TQPainter* painter, const TQWidget* widget) static void renderToolbarWidgetBackground(TQPainter* painter, const TQStyleControlElementData ceData, const TQStyle::ControlElementFlags elementFlags, const TQWidget* widget)
{ {
// Draw a gradient background for custom widgets in the toolbar // Draw a gradient background for custom widgets in the toolbar
// that have specified a "kde toolbar widget" name, or // that have specified a "kde toolbar widget" name, or
@ -487,8 +487,8 @@ static void renderToolbarWidgetBackground(TQPainter* painter, const TQWidget* wi
// Find the top-level toolbar of this widget, since it may be nested in other // Find the top-level toolbar of this widget, since it may be nested in other
// widgets that are on the toolbar. // widgets that are on the toolbar.
TQWidget *parent = TQT_TQWIDGET(widget->parentWidget()); TQWidget *parent = (widget)?TQT_TQWIDGET(widget->parentWidget()):(TQWidget*)NULL;
int x_offset = widget->x(), y_offset = widget->y(); int x_offset = ceData.rect.x(), y_offset = ceData.rect.y();
while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) ) while (parent && parent->parent() && !qstrcmp( parent->name(), kdeToolbarWidget ) )
{ {
x_offset += parent->x(); x_offset += parent->x();
@ -496,18 +496,18 @@ static void renderToolbarWidgetBackground(TQPainter* painter, const TQWidget* wi
parent = TQT_TQWIDGET(parent->parent()); parent = TQT_TQWIDGET(parent->parent());
} }
TQRect pr = parent->rect(); TQRect pr = ceData.parentWidgetData.rect;
bool horiz_grad = pr.width() > pr.height(); bool horiz_grad = pr.width() > pr.height();
int toolHeight = parent->height(); int toolHeight = ceData.parentWidgetData.rect.height();
int toolWidth = parent->width (); int toolWidth = ceData.parentWidgetData.rect.width ();
// Check if the parent is a QToolbar, and use its orientation, else guess. // Check if the parent is a QToolbar, and use its orientation, else guess.
//Also, get the height to use in the gradient from it. //Also, get the height to use in the gradient from it.
TQToolBar* tb = dynamic_cast<TQToolBar*>(parent); TQToolBar* tb = dynamic_cast<TQToolBar*>(parent);
if (tb) if (tb)
{ {
horiz_grad = tb->orientation() == Qt::Horizontal; horiz_grad = ceData.orientation == TQt::Horizontal;
//If floating, we need to skip the titlebar. //If floating, we need to skip the titlebar.
if (tb->place() == TQDockWindow::OutsideDock) if (tb->place() == TQDockWindow::OutsideDock)
@ -518,26 +518,26 @@ static void renderToolbarWidgetBackground(TQPainter* painter, const TQWidget* wi
//the bottom edge, minus the frame (except we use the current y_offset //the bottom edge, minus the frame (except we use the current y_offset
// to map to parent coordinates) // to map to parent coordinates)
int needToTouchBottom = tb->height() - tb->frameWidth() - int needToTouchBottom = tb->height() - tb->frameWidth() -
(widget->rect().bottom() + y_offset); (ceData.rect.bottom() + y_offset);
//Now, with that, we can see which portion to skip in the full-height //Now, with that, we can see which portion to skip in the full-height
//gradient -- which is the stuff other than the extended //gradient -- which is the stuff other than the extended
//widget //widget
y_offset = toolHeight - (widget->height() + needToTouchBottom) - 1; y_offset = toolHeight - (ceData.rect.height() + needToTouchBottom) - 1;
} }
} }
if (painter) if (painter)
{ {
Keramik::GradientPainter::renderGradient( painter, widget->rect(), Keramik::GradientPainter::renderGradient( painter, ceData.rect,
widget->colorGroup().button(), horiz_grad, false, ceData.colorGroup.button(), horiz_grad, false,
x_offset, y_offset, toolWidth, toolHeight); x_offset, y_offset, toolWidth, toolHeight);
} }
else else
{ {
TQPainter p( widget ); TQPainter p( widget );
Keramik::GradientPainter::renderGradient( &p, widget->rect(), Keramik::GradientPainter::renderGradient( &p, ceData.rect,
widget->colorGroup().button(), horiz_grad, false, ceData.colorGroup.button(), horiz_grad, false,
x_offset, y_offset, toolWidth, toolHeight); x_offset, y_offset, toolWidth, toolHeight);
} }
} }
@ -679,7 +679,7 @@ void KeramikStyle::drawPrimitive( TQ_PrimitiveElement pe,
if (toolbarBlendWidget && !flatMode ) if (toolbarBlendWidget && !flatMode )
{ {
//Render the toolbar gradient. //Render the toolbar gradient.
renderToolbarWidgetBackground(p, toolbarBlendWidget); renderToolbarWidgetBackground(p, ceData, elementFlags, toolbarBlendWidget);
//Draw and blend the actual bevel.. //Draw and blend the actual bevel..
Keramik::RectTilePainter( name, false ).draw(p, r, cg.button(), cg.background(), Keramik::RectTilePainter( name, false ).draw(p, r, cg.button(), cg.background(),
@ -1399,21 +1399,21 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CE_PushButton: case CE_PushButton:
{ {
const TQPushButton* btn = static_cast< const TQPushButton* >( widget ); const TQPushButton* btn = dynamic_cast< const TQPushButton* >( widget );
if (isFormWidget(ceData, elementFlags, btn)) if (isFormWidget(ceData, elementFlags, btn))
formMode = true; formMode = true;
if ( btn->isFlat( ) ) if ( elementFlags & CEF_IsFlat )
flatMode = true; flatMode = true;
if ( btn->isDefault( ) && !flatMode ) if ( (elementFlags & CEF_IsDefault) && !flatMode )
{ {
drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags ); drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags );
} }
else else
{ {
if (widget->parent() && widget->parent()->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING))
toolbarBlendWidget = widget; toolbarBlendWidget = widget;
drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags ); drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags );
@ -1429,8 +1429,8 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CE_PushButtonLabel: case CE_PushButtonLabel:
{ {
const TQPushButton* button = static_cast<const TQPushButton *>( widget ); const TQPushButton* button = dynamic_cast<const TQPushButton *>( widget );
bool active = button->isOn() || button->isDown(); bool active = ((elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown));
bool cornArrow = false; bool cornArrow = false;
// Shift button contents if pushed. // Shift button contents if pushed.
@ -1442,11 +1442,11 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
} }
// Does the button have a popup menu? // Does the button have a popup menu?
if ( button->isMenuButton() ) if (elementFlags & CEF_IsMenuWidget)
{ {
int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget ); int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget );
if ( button->iconSet() && !button->iconSet()->isNull() && if ( !ceData.iconSet.isNull() &&
(dx + button->iconSet()->pixmap (TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off ).width()) >= w ) (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 cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust the widget
} }
@ -1459,26 +1459,26 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
} }
// Draw the icon if there is one // Draw the icon if there is one
if ( button->iconSet() && !button->iconSet()->isNull() ) if ( !ceData.iconSet.isNull() )
{ {
TQIconSet::Mode mode = TQIconSet::Disabled; TQIconSet::Mode mode = TQIconSet::Disabled;
TQIconSet::State state = TQIconSet::Off; TQIconSet::State state = TQIconSet::Off;
if (button->isEnabled()) if (elementFlags & CEF_IsEnabled)
mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal; mode = (elementFlags & CEF_HasFocus) ? TQIconSet::Active : TQIconSet::Normal;
if (button->isToggleButton() && button->isOn()) if ((elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn))
state = TQIconSet::On; state = TQIconSet::On;
TQPixmap icon = button->iconSet()->pixmap( TQIconSet::Small, mode, state ); TQPixmap icon = ceData.iconSet.pixmap( TQIconSet::Small, mode, state );
if (!button->text().isEmpty()) if (!ceData.text.isEmpty())
{ {
const int TextToIconMargin = 6; const int TextToIconMargin = 6;
//Center text + icon w/margin in between.. //Center text + icon w/margin in between..
//Calculate length of both. //Calculate length of both.
int length = icon.width() + TextToIconMargin int length = icon.width() + TextToIconMargin
+ p->fontMetrics().size(ShowPrefix, button->text()).width(); + p->fontMetrics().size(ShowPrefix, ceData.text).width();
//Calculate offset. //Calculate offset.
int offset = (w - length)/2; int offset = (w - length)/2;
@ -1493,11 +1493,11 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
else else
{ {
//Icon only. Center it. //Icon only. Center it.
if (!button->pixmap()) if (ceData.fgPixmap.isNull())
p->drawPixmap( x + w/2 - icon.width()/2, y + h / 2 - icon.height() / 2, p->drawPixmap( x + w/2 - icon.width()/2, y + h / 2 - icon.height() / 2,
icon ); icon );
else //icon + pixmap. Ugh. else //icon + pixmap. Ugh.
p->drawPixmap( x + button->isDefault() ? 8 : 4 , y + h / 2 - icon.height() / 2, icon ); p->drawPixmap( x + (elementFlags & CEF_IsDefault) ? 8 : 4 , y + h / 2 - icon.height() / 2, icon );
} }
if (cornArrow) //Draw over the icon if (cornArrow) //Draw over the icon
@ -1506,9 +1506,9 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
} }
// Make the label indicate if the button is a default button or not // Make the label indicate if the button is a default button or not
drawItem( p, TQRect(x, y, w, h), AlignCenter | ShowPrefix, button->colorGroup(), drawItem( p, TQRect(x, y, w, h), AlignCenter | ShowPrefix, ceData.colorGroup,
button->isEnabled(), button->pixmap(), button->text(), -1, (elementFlags & CEF_IsEnabled), (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text, -1,
&button->colorGroup().buttonText() ); &ceData.colorGroup.buttonText() );
if ( flags & Style_HasFocus ) if ( flags & Style_HasFocus )
drawPrimitive( PE_FocusRect, p, ceData, elementFlags, drawPrimitive( PE_FocusRect, p, ceData, elementFlags,
@ -1519,17 +1519,15 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
case CE_ToolButtonLabel: case CE_ToolButtonLabel:
{ {
//const TQToolButton *toolbutton = static_cast<const TQToolButton * >(widget); bool onToolbar = ceData.parentWidgetData.widgetObjectTypes.contains( TQTOOLBAR_OBJECT_NAME_STRING );
bool onToolbar = widget->parentWidget() && widget->parentWidget()->inherits( TQTOOLBAR_OBJECT_NAME_STRING );
TQRect nr = r; TQRect nr = r;
if (!onToolbar) if (!onToolbar)
{ {
if (widget->parentWidget() && if (!qstrcmp(ceData.parentWidgetData.name.ascii(),"qt_maxcontrols" ) )
!qstrcmp(widget->parentWidget()->name(),"qt_maxcontrols" ) )
{ {
//Make sure we don't cut into the endline //Make sure we don't cut into the endline
if (!qstrcmp(widget->name(), "close")) if (!qstrcmp(ceData.name.ascii(), "close"))
{ {
nr.addCoords(0,0,-1,0); nr.addCoords(0,0,-1,0);
p->setPen(cg.dark()); p->setPen(cg.dark());
@ -1589,7 +1587,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
case CE_DockWindowEmptyArea: case CE_DockWindowEmptyArea:
{ {
TQRect pr = r; TQRect pr = r;
if (widget && widget->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) if (ceData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING))
{ {
const TQToolBar* tb = static_cast<const TQToolBar*>(widget); const TQToolBar* tb = static_cast<const TQToolBar*>(widget);
if (tb->place() == TQDockWindow::OutsideDock) if (tb->place() == TQDockWindow::OutsideDock)
@ -2030,8 +2028,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if (controls == SC_All) if (controls == SC_All)
{ {
//Double-buffer only when we are in the slower full-blend mode //Double-buffer only when we are in the slower full-blend mode
if (widget->parent() && if ( ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING) || !qstrcmp(ceData.parentWidgetData.name.ascii(), kdeToolbarWidget) )
( widget->parent()->inherits(TQTOOLBAR_OBJECT_NAME_STRING)|| !qstrcmp(widget->parent()->name(), kdeToolbarWidget) ) )
{ {
buf = new TQPixmap( r.width(), r.height() ); buf = new TQPixmap( r.width(), r.height() );
br.setX(0); br.setX(0);
@ -2260,15 +2257,14 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
// TOOLBUTTON // TOOLBUTTON
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CC_ToolButton: { case CC_ToolButton: {
const TQToolButton *toolbutton = (const TQToolButton *) widget; bool onToolbar = ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING);
bool onToolbar = widget->parentWidget() && widget->parentWidget()->inherits( TQTOOLBAR_OBJECT_NAME_STRING );
bool onExtender = !onToolbar && bool onExtender = !onToolbar &&
widget->parentWidget() && widget->parentWidget()->inherits( "QToolBarExtensionWidget") && ceData.parentWidgetData.widgetObjectTypes.contains( "QToolBarExtensionWidget") &&
widget->parentWidget()->parentWidget()->inherits( TQTOOLBAR_OBJECT_NAME_STRING ); widget && widget->parentWidget()->parentWidget()->inherits( TQTOOLBAR_OBJECT_NAME_STRING );
bool onControlButtons = false; bool onControlButtons = false;
if (!onToolbar && !onExtender && widget->parentWidget() && if (!onToolbar && !onExtender && !ceData.parentWidgetData.widgetObjectTypes.isEmpty() &&
!qstrcmp(widget->parentWidget()->name(),"qt_maxcontrols" ) ) !qstrcmp(ceData.parentWidgetData.name.ascii(),"qt_maxcontrols" ) )
{ {
onControlButtons = true; onControlButtons = true;
titleBarMode = Maximized; titleBarMode = Maximized;
@ -2306,11 +2302,11 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
else if ( !ceData.parentWidgetData.bgPixmap.isNull() ) else if ( !ceData.parentWidgetData.bgPixmap.isNull() )
{ {
TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); p->drawTiledPixmap( r, pixmap, ceData.pos );
} }
else if (onToolbar) else if (onToolbar)
{ {
renderToolbarWidgetBackground(p, widget); renderToolbarWidgetBackground(p, ceData, elementFlags, widget);
} }
else if (onExtender) else if (onExtender)
{ {
@ -2325,9 +2321,9 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
//which are relative to the parent, to be relative to the toolbar. //which are relative to the parent, to be relative to the toolbar.
int xoff = 0, yoff = 0; int xoff = 0, yoff = 0;
if (horiz) if (horiz)
yoff = parent->mapToParent(widget->pos()).y(); yoff = parent->mapToParent(ceData.pos).y();
else else
xoff = parent->mapToParent(widget->pos()).x(); xoff = parent->mapToParent(ceData.pos).x();
Keramik::GradientPainter::renderGradient( p, r, cg.button(), Keramik::GradientPainter::renderGradient( p, r, cg.button(),
horiz, false, /*Not a menubar*/ horiz, false, /*Not a menubar*/
@ -2344,8 +2340,8 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt);
} }
if (toolbutton->hasFocus() && !toolbutton->focusProxy()) { if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
TQRect fr = toolbutton->rect(); TQRect fr = ceData.rect;
fr.addCoords(3, 3, -3, -3); fr.addCoords(3, 3, -3, -3);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg);
} }
@ -2480,15 +2476,15 @@ TQSize KeramikStyle::sizeFromContents( ContentsType contents,
// ------------------------------------------------------------------ // ------------------------------------------------------------------
case CT_PushButton: case CT_PushButton:
{ {
const TQPushButton* btn = static_cast< const TQPushButton* >( widget ); const TQPushButton* btn = dynamic_cast< const TQPushButton* >( widget );
int w = contentSize.width() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); int w = contentSize.width() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget );
int h = contentSize.height() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); int h = contentSize.height() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget );
if ( btn->text().isEmpty() && contentSize.width() < 32 ) return TQSize( w, h ); if ( ceData.text.isEmpty() && contentSize.width() < 32 ) return TQSize( w, h );
//For some reason kcontrol no longer does this... //For some reason kcontrol no longer does this...
//if ( btn->isDefault() || btn->autoDefault() ) //if ( (elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault) )
// w = QMAX( w, 40 ); // w = QMAX( w, 40 );
return TQSize( w + 30, h + 5 ); //MX: No longer blank space -- can make a bit smaller return TQSize( w + 30, h + 5 ); //MX: No longer blank space -- can make a bit smaller
@ -2623,20 +2619,20 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
{ {
case SC_ComboBoxArrow: case SC_ComboBoxArrow:
if ( compact ) if ( compact )
return TQRect( widget->width() - arrow - 7, 0, arrow + 6, widget->height() ); return TQRect( ceData.rect.width() - arrow - 7, 0, arrow + 6, ceData.rect.height() );
else else
return TQRect( widget->width() - arrow - 14, 0, arrow + 13, widget->height() ); return TQRect( ceData.rect.width() - arrow - 14, 0, arrow + 13, ceData.rect.height() );
case SC_ComboBoxEditField: case SC_ComboBoxEditField:
{ {
if ( compact ) if ( compact )
return TQRect( 2, 4, widget->width() - arrow - 2 - 7, widget->height() - 8 ); return TQRect( 2, 4, ceData.rect.width() - arrow - 2 - 7, ceData.rect.height() - 8 );
else if ( widget->width() < 36 || widget->height() < 22 ) else if ( ceData.rect.width() < 36 || ceData.rect.height() < 22 )
return TQRect( 4, 3, widget->width() - arrow - 20, widget->height() - 6 ); return TQRect( 4, 3, ceData.rect.width() - arrow - 20, ceData.rect.height() - 6 );
else if ( static_cast< const TQComboBox* >( widget )->editable() ) else if ( elementFlags & CEF_IsEditable )
return TQRect( 8, 4, widget->width() - arrow - 26, widget->height() - 11 ); return TQRect( 8, 4, ceData.rect.width() - arrow - 26, ceData.rect.height() - 11 );
else else
return TQRect( 6, 4, widget->width() - arrow - 22, widget->height() - 9 ); return TQRect( 6, 4, ceData.rect.width() - arrow - 22, ceData.rect.height() - 9 );
} }
case SC_ComboBoxListBoxPopup: case SC_ComboBoxListBoxPopup:
@ -2815,7 +2811,7 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control
object->event( TQT_TQPAINTEVENT( event ) ); object->event( TQT_TQPAINTEVENT( event ) );
TQWidget* widget = TQT_TQWIDGET( object ); TQWidget* widget = TQT_TQWIDGET( object );
TQPainter p( widget ); TQPainter p( widget );
Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( &p, widget->rect(), Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( &p, ceData.rect,
widget->palette().color( TQPalette::Normal, TQColorGroup::Button ), widget->palette().color( TQPalette::Normal, TQColorGroup::Button ),
Qt::black, false, Keramik::TilePainter::PaintFullBlend); Qt::black, false, Keramik::TilePainter::PaintFullBlend);
recursion = false; recursion = false;
@ -2923,7 +2919,7 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control
{ {
// Draw a gradient background for custom widgets in the toolbar // Draw a gradient background for custom widgets in the toolbar
// that have specified a "kde toolbar widget" name. // that have specified a "kde toolbar widget" name.
renderToolbarWidgetBackground(0, TQT_TQWIDGET(object)); renderToolbarWidgetBackground(0, ceData, elementFlags, TQT_TQWIDGET(object));
return false; // Now draw the contents return false; // Now draw the contents
} }

@ -2384,9 +2384,9 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
case CE_PushButton: { case CE_PushButton: {
TQPushButton *button = (TQPushButton *)widget; 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; flatMode = true;
TQColorGroup g2 = cg; TQColorGroup g2 = cg;
@ -2409,7 +2409,7 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
r.rect( &x, &y, &w, &h ); r.rect( &x, &y, &w, &h );
const TQPushButton* button = static_cast<const TQPushButton *>( widget ); 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; bool cornArrow = false;
// Shift button contents if pushed. // Shift button contents if pushed.
@ -2421,11 +2421,11 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
} }
// Does the button have a popup menu? // Does the button have a popup menu?
if ( button->isMenuButton() ) if ( elementFlags & CEF_IsMenuWidget )
{ {
int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget ); int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget );
if ( button->iconSet() && !button->iconSet()->isNull() && if ( !ceData.iconSet.isNull() &&
(dx + button->iconSet()->pixmap (TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off ).width()) >= w ) (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 cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust the widget
} }
@ -2439,19 +2439,19 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
} }
// Draw the icon if there is one // Draw the icon if there is one
if ( button->iconSet() && !button->iconSet()->isNull() ) if ( !ceData.iconSet.isNull() )
{ {
TQIconSet::Mode mode = TQIconSet::Disabled; TQIconSet::Mode mode = TQIconSet::Disabled;
TQIconSet::State state = TQIconSet::Off; TQIconSet::State state = TQIconSet::Off;
if (button->isEnabled()) if (elementFlags & CEF_IsEnabled)
mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal; mode = (elementFlags & CEF_HasFocus) ? TQIconSet::Active : TQIconSet::Normal;
if (button->isToggleButton() && button->isOn()) if ((elementFlags & CEF_BiState) && (elementFlags & CEF_IsOn))
state = TQIconSet::On; 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, p->drawPixmap( x + w/2 - pixmap.width()/2, y + h / 2 - pixmap.height() / 2,
pixmap ); pixmap );
else else
@ -2468,9 +2468,9 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
} }
// Make the label indicate if the button is a default button or not // Make the label indicate if the button is a default button or not
drawItem( p, TQRect(x, y, w, h), AlignCenter|ShowPrefix, button->colorGroup(), drawItem( p, TQRect(x, y, w, h), AlignCenter|ShowPrefix, ceData.colorGroup,
button->isEnabled(), button->pixmap(), button->text(), -1, (elementFlags & CEF_IsEnabled), (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text, -1,
&button->colorGroup().buttonText() ); &ceData.colorGroup.buttonText() );
if ( flags & Style_HasFocus ) if ( flags & Style_HasFocus )

Loading…
Cancel
Save