Fix a number of crashes in various TDE styles when used by a third party toolkit

pull/16/head
Timothy Pearson 12 years ago
parent 55c0d54a98
commit 6e12d65ff7

@ -192,10 +192,9 @@ void AsteroidStyle::drawKStylePrimitive(KStylePrimitive ksp,
switch (ksp) { switch (ksp) {
case KPE_SliderGroove: { case KPE_SliderGroove: {
const TQSlider* slider = (const TQSlider*)w;
int x, y, v, h; int x, y, v, h;
r.rect(&x, &y, &v, &h); r.rect(&x, &y, &v, &h);
bool horizontal = slider->orientation() ==Qt::Horizontal; bool horizontal = ceData.orientation == TQt::Horizontal;
int gcenter = (horizontal ? h : v) / 2; int gcenter = (horizontal ? h : v) / 2;
int pad = 3; int pad = 3;
@ -225,12 +224,11 @@ void AsteroidStyle::drawKStylePrimitive(KStylePrimitive ksp,
case KPE_SliderHandle: { case KPE_SliderHandle: {
const TQSlider* slider = (const TQSlider*)w;
int x, y, x2, y2, xmin, xmax, ymin, ymax, v, h; int x, y, x2, y2, xmin, xmax, ymin, ymax, v, h;
int pcenter; int pcenter;
r.coords(&xmin, &ymin, &xmax, &ymax); r.coords(&xmin, &ymin, &xmax, &ymax);
r.rect(&x, &y, &v, &h); r.rect(&x, &y, &v, &h);
bool horizontal = slider->orientation() ==Qt::Horizontal; bool horizontal = ceData.orientation == TQt::Horizontal;
if (horizontal) { if (horizontal) {
x = v / 5 + xmin; x = v / 5 + xmin;
@ -1023,7 +1021,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
#ifndef TQT_NO_TABBAR #ifndef TQT_NO_TABBAR
case CE_TabBarTab: case CE_TabBarTab:
{ {
if ( !w || !w->parentWidget() || !o.tab() ) if ( ceData.parentWidgetData.widgetObjectTypes.isEmpty() || !o.tab() )
break; break;
const TQTab * t = o.tab(); const TQTab * t = o.tab();
@ -1280,11 +1278,10 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
// ### Take into account totalSteps() for busy indicator // ### Take into account totalSteps() for busy indicator
const TQProgressBar* pb = (const TQProgressBar*)w;
TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, w); TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, w);
double progress = pb->progress(); double progress = ceData.currentStep;
bool reverse = TQApplication::reverseLayout(); bool reverse = TQApplication::reverseLayout();
int steps = pb->totalSteps(); int steps = ceData.totalSteps;
if (!cr.isValid()) if (!cr.isValid())
return; return;
@ -1356,10 +1353,8 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
} }
case CE_PushButton: { case CE_PushButton: {
const TQPushButton *pb = dynamic_cast<const TQPushButton *>(w);
// Get rid of ugliness in Konqueror and KDevelop tab bar buttons, respectively // Get rid of ugliness in Konqueror and KDevelop tab bar buttons, respectively
if ( w->inherits("KMultiTabBarButton") || w->inherits("Ideal::Button")) { if ( ceData.widgetObjectTypes.contains("KMultiTabBarButton") || ceData.widgetObjectTypes.contains("Ideal::Button")) {
p->setPen(cg.mid()); p->setPen(cg.mid());
p->setBrush(cg.background()); p->setBrush(cg.background());
p->drawRect(r); p->drawRect(r);
@ -1380,7 +1375,7 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
} }
} }
else { else {
if (pb->isDefault()) { if (elementFlags & CEF_IsDefault) {
drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, r, cg, sf); drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, r, cg, sf);
drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, TQRect(x+1, y+1, sw-2, sh-2), cg, sf); drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, TQRect(x+1, y+1, sw-2, sh-2), cg, sf);
} else { } else {
@ -1508,15 +1503,12 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
/* Note: This is very poorly documented by TT. I'm disappointed. -clee */ /* Note: This is very poorly documented by TT. I'm disappointed. -clee */
case CE_HeaderLabel: { case CE_HeaderLabel: {
const TQHeader *hw = dynamic_cast<const TQHeader *>(w);
int hs = o.headerSection();
const bool enabled = sf & Style_Enabled; const bool enabled = sf & Style_Enabled;
bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags ); bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags );
const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
TQIconSet *is = hw->iconSet(hs); if (!ceData.iconSet.isNull()) {
if (is) { TQPixmap pm = ceData.iconSet.pixmap(TQIconSet::Small, sf & Style_Enabled ? TQIconSet::Normal : TQIconSet::Disabled);
TQPixmap pm = is->pixmap(TQIconSet::Small, sf & Style_Enabled ? TQIconSet::Normal : TQIconSet::Disabled);
TQRect pr(0, 0, pm.width(), pm.height()); TQRect pr(0, 0, pm.width(), pm.height());
pr.moveCenter(r.center()); pr.moveCenter(r.center());
pr.setLeft(r.center().y() - (pm.height() - 1) / 2); pr.setLeft(r.center().y() - (pm.height() - 1) / 2);
@ -1527,20 +1519,20 @@ void AsteroidStyle::drawControl(TQ_ControlElement ce,
p->setPen( cg.dark()) ; p->setPen( cg.dark()) ;
TQPen savePen = p->pen(); TQPen savePen = p->pen();
p->setPen( cg.light() ); p->setPen( cg.light() );
p->drawText(pr_offset, text_flags, hw->label(hs)); p->drawText(pr_offset, text_flags, ceData.textLabel);
p->setPen(savePen); p->setPen(savePen);
} }
p->drawText(pr, text_flags, hw->label(hs)); p->drawText(pr, text_flags, ceData.textLabel);
} else { } else {
p->setPen( POPUPMENUITEM_TEXT_ETCH_CONDITIONS?cg.dark():cg.buttonText() ); p->setPen( POPUPMENUITEM_TEXT_ETCH_CONDITIONS?cg.dark():cg.buttonText() );
TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height()); TQRect r_offset = TQRect(r.x()+ETCH_X_OFFSET, r.y()+ETCH_Y_OFFSET, r.width(), r.height());
if HEADER_TEXT_ETCH_CONDITIONS { if HEADER_TEXT_ETCH_CONDITIONS {
TQPen savePen = p->pen(); TQPen savePen = p->pen();
p->setPen( cg.light() ); p->setPen( cg.light() );
p->drawText(r_offset, text_flags, hw->label(hs)); p->drawText(r_offset, text_flags, ceData.textLabel);
p->setPen(savePen); p->setPen(savePen);
} }
p->drawText(r, text_flags, hw->label(hs)); p->drawText(r, text_flags, ceData.textLabel);
} }
break; break;
} }
@ -1962,7 +1954,6 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
case CC_ComboBox: { case CC_ComboBox: {
int x, y, x2, y2, sw, sh; int x, y, x2, y2, sw, sh;
const TQComboBox *cb = dynamic_cast<const TQComboBox *>(w);
r.rect(&x, &y, &sw, &sh); r.rect(&x, &y, &sw, &sh);
r.coords(&x, &y, &x2, &y2); r.coords(&x, &y, &x2, &y2);
@ -2005,8 +1996,8 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
p->drawRect(hr); p->drawRect(hr);
bool draw_skinny_frame = false; bool draw_skinny_frame = false;
// if (!cb) draw_skinny_frame = true; // if (!ceData.widgetObjectTypes.contains(TQCOMBOBOX_OBJECT_NAME_STRING)) draw_skinny_frame = true;
if ((cb) && (cb->listBox() && cb->listBox()->isVisible())) draw_skinny_frame = true; if (ceData.comboBoxListBoxFlags & CEF_IsVisible) draw_skinny_frame = true;
if (draw_skinny_frame) { if (draw_skinny_frame) {
p->setPen(cg.mid()); p->setPen(cg.mid());
p->drawRect(hr); p->drawRect(hr);
@ -2027,7 +2018,7 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
TQRect cr(sw - handle_offset-1, y+2, handle_width, sh - 4); TQRect cr(sw - handle_offset-1, y+2, handle_width, sh - 4);
TQRect pmr(0, 0, 7, 4); TQRect pmr(0, 0, 7, 4);
pmr.moveCenter(cr.center()); pmr.moveCenter(cr.center());
if ((cb) && (cb->listBox() && cb->listBox()->isVisible())) { if (ceData.comboBoxListBoxFlags & CEF_IsVisible) {
pmr.moveBy(1, 1); pmr.moveBy(1, 1);
} }
@ -2042,11 +2033,9 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
#ifndef TQT_NO_TOOLBUTTON #ifndef TQT_NO_TOOLBUTTON
case CC_ToolButton: case CC_ToolButton:
{ {
const TQToolButton *toolbutton = (const TQToolButton *) w;
TQColorGroup c = cg; TQColorGroup c = cg;
if ( toolbutton->backgroundMode() != TQt::PaletteButton ) if ( ceData.backgroundMode != TQt::PaletteButton )
c.setBrush( TQColorGroup::Button, toolbutton->paletteBackgroundColor() ); c.setBrush( TQColorGroup::Button, ceData.paletteBgColor );
TQRect button, menuarea; TQRect button, menuarea;
button = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButton, o, w), ceData, elementFlags ); button = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButton, o, w), ceData, elementFlags );
menuarea = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButtonMenu, o, w), ceData, elementFlags ); menuarea = visualRect( querySubControlMetrics(cc, ceData, elementFlags, SC_ToolButtonMenu, o, w), ceData, elementFlags );
@ -2062,11 +2051,10 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
if (sc & SC_ToolButton) { if (sc & SC_ToolButton) {
if (bflags & (Style_Down | Style_On | Style_Raised)) { if (bflags & (Style_Down | Style_On | Style_Raised)) {
drawPrimitive(TQStyle::PE_ButtonTool, p, ceData, elementFlags, button, c, bflags, o); drawPrimitive(TQStyle::PE_ButtonTool, p, ceData, elementFlags, button, c, bflags, o);
} else if ( toolbutton->parentWidget() && toolbutton->parentWidget()->backgroundPixmap() && ! toolbutton->parentWidget()->backgroundPixmap()->isNull() ) { } else if ( ! ceData.parentWidgetData.bgPixmap.isNull() ) {
TQPixmap pixmap = TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
*(toolbutton->parentWidget()->backgroundPixmap());
p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); p->drawTiledPixmap( r, pixmap, ceData.pos );
} }
} }
@ -2076,8 +2064,8 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
drawPrimitive(TQStyle::PE_ArrowDown, p, ceData, elementFlags, menuarea, c, mflags, o); drawPrimitive(TQStyle::PE_ArrowDown, p, ceData, elementFlags, menuarea, c, mflags, o);
} }
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(TQStyle::PE_FocusRect, p, ceData, elementFlags, fr, c); drawPrimitive(TQStyle::PE_FocusRect, p, ceData, elementFlags, fr, c);
} }
@ -2087,20 +2075,17 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
#endif // TQT_NO_TOOLBUTTON #endif // TQT_NO_TOOLBUTTON
case CC_Slider: { case CC_Slider: {
const TQSlider* slider = (const TQSlider*)w;
TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, o, w); TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, o, w);
TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, o, w); TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, o, w);
// Double-buffer slider for no flicker // Double-buffer slider for no flicker
TQPixmap pix(w->size()); TQPixmap pix(ceData.rect.size());
TQPainter p2; TQPainter p2;
p2.begin(&pix); p2.begin(&pix);
if ( slider->parentWidget() && if ( !ceData.parentWidgetData.bgPixmap.isNull() ) {
slider->parentWidget()->backgroundPixmap() && TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
!slider->parentWidget()->backgroundPixmap()->isNull() ) { p2.drawTiledPixmap(r, pixmap, ceData.pos);
TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap());
p2.drawTiledPixmap(r, pixmap, slider->pos());
} else } else
pix.fill(cg.background()); pix.fill(cg.background());
@ -2109,7 +2094,7 @@ void AsteroidStyle::drawComplexControl(TQ_ComplexControl cc,
drawKStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, sf, o, w ); drawKStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, sf, o, w );
// Draw the focus rect around the groove // Draw the focus rect around the groove
if (slider->hasFocus()) if (elementFlags & CEF_HasFocus)
drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg); drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg);
} }
@ -2310,7 +2295,7 @@ int AsteroidStyle::pixelMetric(PixelMetric pm, TQStyleControlElementData ceData,
} }
case PM_DefaultFrameWidth: { case PM_DefaultFrameWidth: {
if (w && w->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) { if (ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) {
return 3; return 3;
} else { } else {
return KStyle::pixelMetric(pm, ceData, elementFlags, w); return KStyle::pixelMetric(pm, ceData, elementFlags, w);
@ -2448,7 +2433,7 @@ TQRect AsteroidStyle::querySubControlMetrics(TQ_ComplexControl cc,
return TQRect(); return TQRect();
} }
TQRect r(w->rect()); TQRect r(ceData.rect);
switch (sc) { switch (sc) {
case SC_ComboBoxEditField: { case SC_ComboBoxEditField: {
@ -2589,7 +2574,7 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct,
sh = TQMAX(sh, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 2); sh = TQMAX(sh, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 2);
} }
sh = TQMAX(sh, w->fontMetrics().height() + 4); sh = TQMAX(sh, TQFontMetrics(ceData.font).height() + 4);
} }
if (!mi->text().isNull()) { if (!mi->text().isNull()) {
@ -2624,7 +2609,7 @@ TQSize AsteroidStyle::sizeFromContents(ContentsType ct,
case CT_Header: { case CT_Header: {
// Fall through is intentional // Fall through is intentional
// const TQHeader *hw = dynamic_cast<const TQHeader *>(w); // const TQHeader *hw = dynamic_cast<const TQHeader *>(w);
// int sh = TQFontInfo(hw->font()).pixelSize() + 8; // int sh = TQFontInfo(ceData.font).pixelSize() + 8;
// int sw = 10; // int sw = 10;
// return TQSize(sw, sh); // return TQSize(sw, sh);
} }

@ -1054,8 +1054,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
// SLIDER GROOVE // SLIDER GROOVE
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case KPE_SliderGroove: { case KPE_SliderGroove: {
const TQSlider* slider = (const TQSlider*)widget; bool horizontal = ceData.orientation == TQt::Horizontal;
bool horizontal = slider->orientation() == Qt::Horizontal;
int gcenter = (horizontal ? r.height() : r.width()) / 2; int gcenter = (horizontal ? r.height() : r.width()) / 2;
TQRect gr; TQRect gr;
@ -1074,7 +1073,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
p->drawLine(x+2, y, x2-2, y); p->drawLine(x+2, y, x2-2, y);
p->drawLine(x, y+2, x, y2-2); p->drawLine(x, y+2, x, y2-2);
p->fillRect(x+2,y+2,w-4, h-4, p->fillRect(x+2,y+2,w-4, h-4,
slider->isEnabled() ? cg.dark() : cg.mid()); (elementFlags & CEF_IsEnabled) ? cg.dark() : cg.mid());
p->setPen(cg.shadow()); p->setPen(cg.shadow());
p->drawRect(x+1, y+1, w-2, h-2); p->drawRect(x+1, y+1, w-2, h-2);
p->setPen(cg.light()); p->setPen(cg.light());
@ -1088,8 +1087,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
// SLIDER HANDLE // SLIDER HANDLE
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case KPE_SliderHandle: { case KPE_SliderHandle: {
const TQSlider* slider = (const TQSlider*)widget; bool horizontal = ceData.orientation == TQt::Horizontal;
bool horizontal = slider->orientation() == Qt::Horizontal;
int x,y,w,h; int x,y,w,h;
r.rect(&x, &y, &w, &h); r.rect(&x, &y, &w, &h);
int x2 = x+w-1; int x2 = x+w-1;
@ -1123,7 +1121,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
p->drawLine(x+5, y+4, x+5, y2-4); p->drawLine(x+5, y+4, x+5, y2-4);
p->drawLine(x+8, y+4, x+8, y2-4); p->drawLine(x+8, y+4, x+8, y2-4);
p->drawLine(x+11,y+4, x+11, y2-4); p->drawLine(x+11,y+4, x+11, y2-4);
p->setPen(slider->isEnabled() ? cg.shadow(): cg.mid()); p->setPen((elementFlags & CEF_IsEnabled) ? cg.shadow(): cg.mid());
p->drawLine(x+6, y+4, x+6, y2-4); p->drawLine(x+6, y+4, x+6, y2-4);
p->drawLine(x+9, y+4, x+9, y2-4); p->drawLine(x+9, y+4, x+9, y2-4);
p->drawLine(x+12,y+4, x+12, y2-4); p->drawLine(x+12,y+4, x+12, y2-4);
@ -1132,7 +1130,7 @@ void HighColorStyle::drawKStylePrimitive( KStylePrimitive kpe,
p->drawLine(x+4, y+5, x2-4, y+5); p->drawLine(x+4, y+5, x2-4, y+5);
p->drawLine(x+4, y+8, x2-4, y+8); p->drawLine(x+4, y+8, x2-4, y+8);
p->drawLine(x+4, y+11, x2-4, y+11); p->drawLine(x+4, y+11, x2-4, y+11);
p->setPen(slider->isEnabled() ? cg.shadow() : cg.mid()); p->setPen((elementFlags & CEF_IsEnabled) ? cg.shadow() : cg.mid());
p->drawLine(x+4, y+6, x2-4, y+6); p->drawLine(x+4, y+6, x2-4, y+6);
p->drawLine(x+4, y+9, x2-4, y+9); p->drawLine(x+4, y+9, x2-4, y+9);
p->drawLine(x+4, y+12, x2-4, y+12); p->drawLine(x+4, y+12, x2-4, y+12);
@ -1162,11 +1160,10 @@ void HighColorStyle::drawControl( TQ_ControlElement element,
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CE_PushButton: { case CE_PushButton: {
if ( type != HighColor ) { if ( type != HighColor ) {
TQPushButton *button = (TQPushButton*) widget;
TQRect br = r; TQRect br = r;
bool btnDefault = button->isDefault(); bool btnDefault = (elementFlags & CEF_IsDefault);
if ( btnDefault || button->autoDefault() ) { if ( btnDefault || (elementFlags & CEF_AutoDefault) ) {
// Compensate for default indicator // Compensate for default indicator
static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags );
br.addCoords( di, di, -di, -di ); br.addCoords( di, di, -di, -di );
@ -1187,8 +1184,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element,
// PUSHBUTTON LABEL // PUSHBUTTON LABEL
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CE_PushButtonLabel: { case CE_PushButtonLabel: {
const TQPushButton* button = (const TQPushButton*)widget; bool active = ((elementFlags & CEF_IsOn) || (elementFlags & CEF_IsDown));
bool active = button->isOn() || button->isDown();
int x, y, w, h; int x, y, w, h;
r.rect( &x, &y, &w, &h ); r.rect( &x, &y, &w, &h );
@ -1200,7 +1196,7 @@ void HighColorStyle::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 );
drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect(x + w - dx - 2, y + 2, dx, h - 4), drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect(x + w - dx - 2, y + 2, dx, h - 4),
cg, flags, opt ); cg, flags, opt );
@ -1208,19 +1204,19 @@ void HighColorStyle::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 );
// Center the iconset if there's no text or pixmap // Center the iconset if there's no text or pixmap
if (button->text().isEmpty() && !button->pixmap()) if (ceData.text.isEmpty() && ceData.fgPixmap.isNull())
p->drawPixmap( x + (w - pixmap.width()) / 2, p->drawPixmap( x + (w - pixmap.width()) / 2,
y + (h - pixmap.height()) / 2, pixmap ); y + (h - pixmap.height()) / 2, pixmap );
else else
@ -1232,30 +1228,31 @@ void HighColorStyle::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
if ( active || button->isDefault() ) { if ( active || (elementFlags & CEF_IsDefault) ) {
// Draw "fake" bold text - this enables the font metrics to remain // Draw "fake" bold text - this enables the font metrics to remain
// the same as computed in TQPushButton::sizeHint(), but gives // the same as computed in TQPushButton::sizeHint(), but gives
// a reasonable bold effect. // a reasonable bold effect.
int i; int i;
// Text shadow // Text shadow
if (button->isEnabled()) // Don't draw double-shadow when disabled if (elementFlags & CEF_IsEnabled) // Don't draw double-shadow when disabled
for(i=0; i<2; i++) for(i=0; i<2; i++)
drawItem( p, TQRect(x+i+1, y+1, w, h), AlignCenter | ShowPrefix, drawItem( p, TQRect(x+i+1, y+1, w, h), AlignCenter | ShowPrefix,
button->colorGroup(), button->isEnabled(), NULL, ceData.colorGroup, (elementFlags & CEF_IsEnabled), NULL,
button->text(), -1, ceData.text, -1,
active ? &button->colorGroup().dark() : &button->colorGroup().mid() ); (active ? &ceData.colorGroup.dark() : &ceData.colorGroup.mid()) );
// Normal Text // Normal Text
for(i=0; i<2; i++) for(i=0; i<2; i++)
drawItem( p, TQRect(x+i, y, w, h), AlignCenter | ShowPrefix, drawItem( p, TQRect(x+i, y, w, h), AlignCenter | ShowPrefix,
button->colorGroup(), button->isEnabled(), i == 0 ? button->pixmap() : NULL, ceData.colorGroup, (elementFlags & CEF_IsEnabled), ((i == 0) ? (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap : NULL),
button->text(), -1, ceData.text, -1,
active ? &button->colorGroup().light() : &button->colorGroup().buttonText() ); (active ? &ceData.colorGroup.light() : &ceData.colorGroup.buttonText()) );
} else } else {
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,
active ? &button->colorGroup().light() : &button->colorGroup().buttonText() ); (active ? &ceData.colorGroup.light() : &ceData.colorGroup.buttonText()) );
}
// Draw a focus rect if the button has focus // Draw a focus rect if the button has focus
if ( flags & Style_HasFocus ) if ( flags & Style_HasFocus )
@ -1334,7 +1331,7 @@ void HighColorStyle::drawControl( TQ_ControlElement element,
if ( !mi ) { if ( !mi ) {
// Don't leave blank holes if we set NoBackground for the TQPopupMenu. // Don't leave blank holes if we set NoBackground for the TQPopupMenu.
// This only happens when the popupMenu spans more than one column. // This only happens when the popupMenu spans more than one column.
if (! (widget->erasePixmap() && !widget->erasePixmap()->isNull()) ) if (! (!ceData.bgPixmap.isNull()) )
p->fillRect(r, cg.brush(TQColorGroup::Button) ); p->fillRect(r, cg.brush(TQColorGroup::Button) );
break; break;
} }
@ -1366,8 +1363,8 @@ void HighColorStyle::drawControl( TQ_ControlElement element,
qDrawShadePanel( p, x, y, w, h, cg, true, 1, qDrawShadePanel( p, x, y, w, h, cg, true, 1,
&cg.brush(TQColorGroup::Midlight) ); &cg.brush(TQColorGroup::Midlight) );
// Draw the transparency pixmap // Draw the transparency pixmap
else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) else if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( x, y, *widget->erasePixmap(), x, y, w, h ); p->drawPixmap( x, y, ceData.bgPixmap, x, y, w, h );
// Draw a solid background // Draw a solid background
else else
p->fillRect( r, cg.button() ); p->fillRect( r, cg.button() );
@ -1609,7 +1606,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
ceData, elementFlags ); ceData, elementFlags );
// Are we enabled? // Are we enabled?
if ( widget->isEnabled() ) if ( elementFlags & CEF_IsEnabled )
flags |= Style_Enabled; flags |= Style_Enabled;
// Are we "pushed" ? // Are we "pushed" ?
@ -1628,13 +1625,13 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
SC_ComboBoxEditField, TQStyleOption::Default, widget), ceData, elementFlags ); SC_ComboBoxEditField, TQStyleOption::Default, widget), ceData, elementFlags );
// Draw the indent // Draw the indent
if (cb->editable()) { if ( elementFlags & CEF_IsEditable ) {
p->setPen( cg.dark() ); p->setPen( cg.dark() );
p->drawLine( re.x(), re.y()-1, re.x()+re.width(), re.y()-1 ); p->drawLine( re.x(), re.y()-1, re.x()+re.width(), re.y()-1 );
p->drawLine( re.x()-1, re.y(), re.x()-1, re.y()+re.height() ); p->drawLine( re.x()-1, re.y(), re.x()-1, re.y()+re.height() );
} }
if ( cb->hasFocus() ) { if ( elementFlags & CEF_HasFocus ) {
p->setPen( cg.highlightedText() ); p->setPen( cg.highlightedText() );
p->setBackgroundColor( cg.highlight() ); p->setBackgroundColor( cg.highlight() );
} else { } else {
@ -1642,7 +1639,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
p->setBackgroundColor( cg.button() ); p->setBackgroundColor( cg.button() );
} }
if ( cb->hasFocus() && !cb->editable() ) { if ( (elementFlags & CEF_HasFocus) && !(elementFlags & CEF_IsEditable) ) {
// Draw the contents // Draw the contents
p->fillRect( re.x(), re.y(), re.width(), re.height(), p->fillRect( re.x(), re.y(), re.width(), re.height(),
cg.brush( TQColorGroup::Highlight ) ); cg.brush( TQColorGroup::Highlight ) );
@ -1660,8 +1657,6 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
// TOOLBUTTON // TOOLBUTTON
// ------------------------------------------------------------------- // -------------------------------------------------------------------
case CC_ToolButton: { case CC_ToolButton: {
const TQToolButton *toolbutton = (const TQToolButton *) widget;
TQRect button, menuarea; TQRect button, menuarea;
button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget); button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget);
menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget); menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget);
@ -1681,16 +1676,14 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
drawPrimitive(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 // Check whether to draw a background pixmap
else if ( toolbutton->parentWidget() && else if ( !ceData.parentWidgetData.bgPixmap.isNull() )
toolbutton->parentWidget()->backgroundPixmap() &&
!toolbutton->parentWidget()->backgroundPixmap()->isNull() )
{ {
TQPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap()); TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); p->drawTiledPixmap( r, pixmap, ceData.pos );
} }
else if (widget->parent()) else if (!ceData.parentWidgetData.widgetObjectTypes.isEmpty())
{ {
if (widget->parent()->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING))
{ {
TQToolBar* parent = (TQToolBar*)widget->parent(); TQToolBar* parent = (TQToolBar*)widget->parent();
TQRect pr = parent->rect(); TQRect pr = parent->rect();
@ -1699,7 +1692,7 @@ void HighColorStyle::drawComplexControl( TQ_ComplexControl control,
parent->orientation() == Qt::Vertical, parent->orientation() == Qt::Vertical,
r.x(), r.y(), pr.width()-2, pr.height()-2); r.x(), r.y(), pr.width()-2, pr.height()-2);
} }
else if (widget->parent()->inherits("QToolBarExtensionWidget")) else if (ceData.parentWidgetData.widgetObjectTypes.contains("QToolBarExtensionWidget"))
{ {
TQWidget* parent = (TQWidget*)widget->parent(); TQWidget* parent = (TQWidget*)widget->parent();
TQToolBar* toolbar = (TQToolBar*)parent->parent(); TQToolBar* toolbar = (TQToolBar*)parent->parent();
@ -1724,8 +1717,8 @@ void HighColorStyle::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);
} }
@ -1804,11 +1797,10 @@ TQRect HighColorStyle::subRect(SubRect r, const TQStyleControlElementData ceData
// the Qt3 defaults to be similar to Qt 2's defaults. // the Qt3 defaults to be similar to Qt 2's defaults.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
if (r == SR_PushButtonFocusRect ) { if (r == SR_PushButtonFocusRect ) {
const TQPushButton* button = (const TQPushButton*) widget; TQRect wrect(ceData.rect);
TQRect wrect(widget->rect());
int dbw1 = 0, dbw2 = 0; int dbw1 = 0, dbw2 = 0;
if (button->isDefault() || button->autoDefault()) { if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget); dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dbw2 = dbw1 * 2; dbw2 = dbw1 * 2;
} }
@ -1886,7 +1878,7 @@ int HighColorStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Co
} }
break; break;
default: default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break; break;
} }
@ -1905,7 +1897,6 @@ TQSize HighColorStyle::sizeFromContents( ContentsType contents,
// PUSHBUTTON SIZE // PUSHBUTTON SIZE
// ------------------------------------------------------------------ // ------------------------------------------------------------------
case CT_PushButton: { case CT_PushButton: {
const TQPushButton* button = (const TQPushButton*) widget;
int w = contentSize.width(); int w = contentSize.width();
int h = contentSize.height(); int h = contentSize.height();
int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget );
@ -1915,8 +1906,8 @@ TQSize HighColorStyle::sizeFromContents( ContentsType contents,
h += bm + fw; h += bm + fw;
// Ensure we stick to standard width and heights. // Ensure we stick to standard width and heights.
if ( button->isDefault() || button->autoDefault() ) { if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
if ( w < 80 && !button->text().isEmpty() ) if ( w < 80 && !ceData.text.isEmpty() )
w = 80; w = 80;
if ( type != HighColor ) { if ( type != HighColor ) {
@ -2043,7 +2034,7 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr
// widgets that are on the toolbar. // widgets that are on the toolbar.
TQWidget *widget = TQT_TQWIDGET(object); TQWidget *widget = TQT_TQWIDGET(object);
TQWidget *parent = TQT_TQWIDGET(object->parent()); TQWidget *parent = TQT_TQWIDGET(object->parent());
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();
@ -2051,8 +2042,8 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr
parent = TQT_TQWIDGET(parent->parent()); parent = TQT_TQWIDGET(parent->parent());
} }
TQRect r = widget->rect(); TQRect r = ceData.rect;
TQRect pr = parent->rect(); TQRect pr = ceData.parentWidgetData.rect;
bool horiz_grad = pr.width() < pr.height(); bool horiz_grad = pr.width() < pr.height();
// 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.
@ -2077,7 +2068,7 @@ bool HighColorStyle::objectEventHandler( TQStyleControlElementData ceData, Contr
if ( event->type() == TQEvent::Paint ) { if ( event->type() == TQEvent::Paint ) {
TQWidget *widget = TQT_TQWIDGET(object); TQWidget *widget = TQT_TQWIDGET(object);
TQRect wr = widget->rect(), tr = toolbar->rect(); TQRect wr = ceData.rect, tr = ceData.parentWidgetData.rect;
TQPainter p( widget ); TQPainter p( widget );
renderGradient(&p, wr, toolbar->colorGroup().button(), renderGradient(&p, wr, toolbar->colorGroup().button(),
toolbar->orientation() == Qt::Vertical, toolbar->orientation() == Qt::Vertical,

@ -724,10 +724,9 @@ void HighContrastStyle::drawKStylePrimitive (KStylePrimitive kpe,
case KPE_SliderGroove: { case KPE_SliderGroove: {
setColorsText (p, cg, flags); setColorsText (p, cg, flags);
TQRect r2 (r); TQRect r2 (r);
const TQSlider *slider = dynamic_cast<const TQSlider*>(widget); if (ceData.widgetObjectTypes.contains(TQSLIDER_OBJECT_NAME_STRING))
if (slider != 0)
{ {
if (slider->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
{ {
if (r2.height() > 5*basicLineWidth) if (r2.height() > 5*basicLineWidth)
{ {
@ -1565,12 +1564,12 @@ TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control,
switch (subcontrol) switch (subcontrol)
{ {
case SC_ComboBoxFrame: case SC_ComboBoxFrame:
return TQRect (0, 0, widget->width(), widget->height()); return TQRect (0, 0, ceData.rect.width(), ceData.rect.height());
case SC_ComboBoxArrow: case SC_ComboBoxArrow:
return TQRect (widget->width() - arrow, 0, arrow, widget->height()); return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height());
case SC_ComboBoxEditField: case SC_ComboBoxEditField:
return TQRect (2*basicLineWidth, 2*basicLineWidth, return TQRect (2*basicLineWidth, 2*basicLineWidth,
widget->width() - arrow - 3*basicLineWidth, widget->height() - 4*basicLineWidth); ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth);
default: break; default: break;
} }
@ -1581,17 +1580,17 @@ TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control,
switch (subcontrol) switch (subcontrol)
{ {
case SC_SpinWidgetFrame: case SC_SpinWidgetFrame:
return TQRect (0, 0, widget->width(), widget->height()); return TQRect (0, 0, ceData.rect.width(), ceData.rect.height());
case SC_SpinWidgetButtonField: case SC_SpinWidgetButtonField:
return TQRect (widget->width() - arrow, 0, arrow, widget->height()); return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height());
case SC_SpinWidgetUp: case SC_SpinWidgetUp:
return TQRect (widget->width() - arrow, 0, arrow, widget->height()/2); return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()/2);
case SC_SpinWidgetDown: case SC_SpinWidgetDown:
return TQRect (widget->width() - arrow, widget->height()/2, return TQRect (ceData.rect.width() - arrow, ceData.rect.height()/2,
arrow, widget->height()-widget->height()/2); arrow, ceData.rect.height()-ceData.rect.height()/2);
case SC_SpinWidgetEditField: case SC_SpinWidgetEditField:
return TQRect (2*basicLineWidth, 2*basicLineWidth, return TQRect (2*basicLineWidth, 2*basicLineWidth,
widget->width() - arrow - 3*basicLineWidth, widget->height() - 4*basicLineWidth); ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth);
default: break; default: break;
} }
@ -1616,7 +1615,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
return 2*basicLineWidth; return 2*basicLineWidth;
case PM_ButtonDefaultIndicator: { case PM_ButtonDefaultIndicator: {
if ((widget != 0) && !widget->isEnabled()) if ((widget != 0) && !(elementFlags & CEF_IsEnabled))
return 0; return 0;
else else
return 2*basicLineWidth; return 2*basicLineWidth;
@ -1629,7 +1628,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
case PM_ScrollBarExtent: { case PM_ScrollBarExtent: {
int h = 0; int h = 0;
if (widget != 0) if (widget != 0)
h = (2*widget->fontMetrics().lineSpacing())/3; h = (2*TQFontMetrics(ceData.font).lineSpacing())/3;
if (h > 9*basicLineWidth+4) if (h > 9*basicLineWidth+4)
return h; return h;
@ -1638,7 +1637,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
} }
case PM_DefaultFrameWidth: { case PM_DefaultFrameWidth: {
if (widget && (widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING))) if (widget && (ceData.widgetObjectTypes.contains (TQLINEEDIT_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains (TQTEXTEDIT_OBJECT_NAME_STRING)))
return 2*basicLineWidth; return 2*basicLineWidth;
else else
return basicLineWidth; return basicLineWidth;
@ -1651,7 +1650,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
case PM_MenuButtonIndicator: { // Arrow width case PM_MenuButtonIndicator: { // Arrow width
int h = 0; int h = 0;
if (widget != 0) if (widget != 0)
h = widget->fontMetrics().lineSpacing()/2; h = TQFontMetrics(ceData.font).lineSpacing()/2;
if (h > 3*basicLineWidth) if (h > 3*basicLineWidth)
return h; return h;
@ -1667,7 +1666,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
case PM_IndicatorHeight: { case PM_IndicatorHeight: {
int h = 0; int h = 0;
if (widget != 0) if (widget != 0)
h = widget->fontMetrics().lineSpacing()-2*basicLineWidth; h = TQFontMetrics(ceData.font).lineSpacing()-2*basicLineWidth;
if (h > 6*basicLineWidth) if (h > 6*basicLineWidth)
return h; return h;
@ -1681,7 +1680,7 @@ int HighContrastStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceDa
case PM_DockWindowHandleExtent: { case PM_DockWindowHandleExtent: {
int w = 0; int w = 0;
if (widget != 0) if (widget != 0)
w = widget->fontMetrics().lineSpacing()/4; w = TQFontMetrics(ceData.font).lineSpacing()/4;
if (w > 5*basicLineWidth) if (w > 5*basicLineWidth)
return w; return w;
else else
@ -1843,7 +1842,7 @@ TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementD
case SR_ProgressBarGroove: case SR_ProgressBarGroove:
case SR_ProgressBarContents: case SR_ProgressBarContents:
case SR_ProgressBarLabel: case SR_ProgressBarLabel:
return widget->rect(); return ceData.rect;
default: default:
return KStyle::subRect (subrect, ceData, elementFlags, widget); return KStyle::subRect (subrect, ceData, elementFlags, widget);
} }
@ -1872,7 +1871,7 @@ int HighContrastStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData,
} }
break; break;
default: default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break; break;
} }

@ -198,10 +198,9 @@ TQRect KeramikStyle::subRect(SubRect r, const TQStyleControlElementData ceData,
{ {
case SR_PushButtonFocusRect: case SR_PushButtonFocusRect:
{ {
const TQPushButton* button = (const TQPushButton*) widget; TQRect wrect(ceData.rect);
TQRect wrect(widget->rect());
if (button->isDefault() || button->autoDefault()) if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault))
{ {
return TQRect(wrect.x() + 6, wrect.y() + 5, wrect.width() - 12, wrect.height() - 10); return TQRect(wrect.x() + 6, wrect.y() + 5, wrect.width() - 12, wrect.height() - 10);
} }
@ -220,12 +219,10 @@ TQRect KeramikStyle::subRect(SubRect r, const TQStyleControlElementData ceData,
case SR_CheckBoxFocusRect: case SR_CheckBoxFocusRect:
{ {
const TQCheckBox* cb = static_cast<const TQCheckBox*>(widget);
//Only checkbox, no label //Only checkbox, no label
if (cb->text().isEmpty() && (cb->pixmap() == 0) ) if (ceData.text.isEmpty() && (ceData.fgPixmap.isNull()) )
{ {
TQRect bounding = cb->rect(); TQRect bounding = ceData.rect;
TQSize checkDim = loader.size( keramik_checkbox_on); TQSize checkDim = loader.size( keramik_checkbox_on);
int cw = checkDim.width(); int cw = checkDim.width();
int ch = checkDim.height(); int ch = checkDim.height();
@ -1357,26 +1354,29 @@ void KeramikStyle::drawKStylePrimitive( KStylePrimitive kpe,
} }
} }
bool KeramikStyle::isFormWidget(const TQWidget* widget) const bool KeramikStyle::isFormWidget(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget* widget) const
{ {
//Form widgets are in the KHTMLView, but that has 2 further inner levels if (widget) {
//of widgets - QClipperWidget, and outside of that, QViewportWidget //Form widgets are in the KHTMLView, but that has 2 further inner levels
TQWidget* potentialClipPort = widget->parentWidget(); //of widgets - QClipperWidget, and outside of that, QViewportWidget
if ( !potentialClipPort || potentialClipPort->isTopLevel() ) TQWidget* potentialClipPort = widget->parentWidget();
return false; if ((ceData.parentWidgetData.widgetObjectTypes.isEmpty()) && (ceData.parentWidgetFlags & CEF_IsTopLevel)) {
return false;
TQWidget* potentialViewPort = potentialClipPort->parentWidget(); }
if (!potentialViewPort || potentialViewPort->isTopLevel() ||
qstrcmp(potentialViewPort->name(), "qt_viewport") ) TQWidget* potentialViewPort = potentialClipPort->parentWidget();
return false; if (!potentialViewPort || potentialViewPort->isTopLevel() ||
qstrcmp(potentialViewPort->name(), "qt_viewport") )
TQWidget* potentialKHTML = potentialViewPort->parentWidget(); return false;
if (!potentialKHTML || potentialKHTML->isTopLevel() ||
qstrcmp(potentialKHTML->className(), "KHTMLView") ) TQWidget* potentialKHTML = potentialViewPort->parentWidget();
return false; if (!potentialKHTML || potentialKHTML->isTopLevel() ||
qstrcmp(potentialKHTML->className(), "KHTMLView") )
return false;
return true;
return true;
}
} }
void KeramikStyle::drawControl( TQ_ControlElement element, void KeramikStyle::drawControl( TQ_ControlElement element,
@ -1401,7 +1401,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
{ {
const TQPushButton* btn = static_cast< const TQPushButton* >( widget ); const TQPushButton* btn = static_cast< const TQPushButton* >( widget );
if (isFormWidget(btn)) if (isFormWidget(ceData, elementFlags, btn))
formMode = true; formMode = true;
if ( btn->isFlat( ) ) if ( btn->isFlat( ) )
@ -1649,7 +1649,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
{ {
// Don't leave blank holes if we set NoBackground for the TQPopupMenu. // Don't leave blank holes if we set NoBackground for the TQPopupMenu.
// This only happens when the popupMenu spans more than one column. // This only happens when the popupMenu spans more than one column.
if (! ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) ) if (! ( !ceData.bgPixmap.isNull() ) )
p->fillRect( r, cg.background().light( 105 ) ); p->fillRect( r, cg.background().light( 105 ) );
break; break;
@ -1670,15 +1670,15 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
if ( enabled ) if ( enabled )
Keramik::RowPainter( keramik_menuitem ).draw( p, main, cg.highlight(), cg.background() ); Keramik::RowPainter( keramik_menuitem ).draw( p, main, cg.highlight(), cg.background() );
else { else {
if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( main.topLeft(), *widget->erasePixmap(), main ); p->drawPixmap( main.topLeft(), ceData.bgPixmap, main );
else p->fillRect( main, cg.background().light( 105 ) ); else p->fillRect( main, cg.background().light( 105 ) );
p->drawWinFocusRect( r ); p->drawWinFocusRect( r );
} }
} }
// Draw the transparency pixmap // Draw the transparency pixmap
else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) else if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( main.topLeft(), *widget->erasePixmap(), main ); p->drawPixmap( main.topLeft(), ceData.bgPixmap, main );
// Draw a solid background // Draw a solid background
else else
p->fillRect( main, cg.background().light( 105 ) ); p->fillRect( main, cg.background().light( 105 ) );
@ -1853,11 +1853,10 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
break; break;
} }
case CE_ProgressBarContents: { case CE_ProgressBarContents: {
const TQProgressBar* pb = (const TQProgressBar*)widget;
TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget); TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
double progress = pb->progress(); double progress = ceData.currentStep;
bool reverse = TQApplication::reverseLayout(); bool reverse = TQApplication::reverseLayout();
int steps = pb->totalSteps(); int steps = ceData.totalSteps;
if (!cr.isValid()) if (!cr.isValid())
return; return;
@ -1908,6 +1907,7 @@ void KeramikStyle::drawControl( TQ_ControlElement element,
////////////////////////////////////// //////////////////////////////////////
if (animateProgressBar) if (animateProgressBar)
{ {
const TQProgressBar* pb = (const TQProgressBar*)widget;
int progAnimShift = progAnimWidgets[const_cast<TQProgressBar*>(pb)]; int progAnimShift = progAnimWidgets[const_cast<TQProgressBar*>(pb)];
if (reverse) if (reverse)
{ {
@ -1978,16 +1978,22 @@ void KeramikStyle::drawControlMask( TQ_ControlElement element,
maskMode = false; maskMode = false;
} }
bool KeramikStyle::isSizeConstrainedCombo(const TQComboBox* combo) const bool KeramikStyle::isSizeConstrainedCombo(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQComboBox* combo) const
{ {
if (combo->width() >= 80) if (ceData.rect.width() >= 80)
return false; return false;
int suggestedWidth = combo->sizeHint().width();
if (combo->width() - suggestedWidth < -5)
return true;
return false; if (combo) {
int suggestedWidth = combo->sizeHint().width();
if (ceData.rect.width() - suggestedWidth < -5)
return true;
return false;
}
else {
return true;
}
} }
void KeramikStyle::drawComplexControl( TQ_ComplexControl control, void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
@ -2010,10 +2016,10 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
case CC_ComboBox: case CC_ComboBox:
{ {
bool toolbarMode = false; bool toolbarMode = false;
const TQComboBox* cb = static_cast< const TQComboBox* >( widget ); const TQComboBox* cb = dynamic_cast< const TQComboBox* >( widget );
bool compact = isSizeConstrainedCombo(cb); bool compact = isSizeConstrainedCombo(ceData, elementFlags, cb);
if (isFormWidget(cb)) if (isFormWidget(ceData, elementFlags, cb))
formMode = true; formMode = true;
TQPixmap * buf = 0; TQPixmap * buf = 0;
@ -2114,7 +2120,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if ( controls & SC_ComboBoxEditField ) if ( controls & SC_ComboBoxEditField )
{ {
if ( cb->editable() ) if ( elementFlags & CEF_IsEditable )
{ {
TQRect er = visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags ); TQRect er = visualRect( querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget ), ceData, elementFlags );
er.addCoords( -2, -2, 2, 2 ); er.addCoords( -2, -2, 2, 2 );
@ -2123,7 +2129,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( p2, er, cg.button(), Keramik::RectTilePainter( keramik_frame_shadow, false, false, 2, 2 ).draw( p2, er, cg.button(),
Qt::black, false, pmodeFullBlend() ); Qt::black, false, pmodeFullBlend() );
} }
else if ( cb->hasFocus() ) else if ( elementFlags & CEF_HasFocus )
{ {
TQRect re = TQStyle::visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, cb), ceData, elementFlags); TQRect re = TQStyle::visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, cb), ceData, elementFlags);
if ( compact ) if ( compact )
@ -2133,7 +2139,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
Style_FocusAtBorder, TQStyleOption( cg.highlight() ) ); Style_FocusAtBorder, TQStyleOption( cg.highlight() ) );
} }
// TQComboBox draws the text on its own and uses the painter's current colors // TQComboBox draws the text on its own and uses the painter's current colors
if ( cb->hasFocus() ) if ( elementFlags & CEF_HasFocus )
{ {
p->setPen( cg.highlightedText() ); p->setPen( cg.highlightedText() );
p->setBackgroundColor( cg.highlight() ); p->setBackgroundColor( cg.highlight() );
@ -2280,7 +2286,7 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
if (active & SC_ToolButtonMenu) if (active & SC_ToolButtonMenu)
mflags |= Style_Down; mflags |= Style_Down;
if (onToolbar && static_cast<TQToolBar*>(TQT_TQWIDGET(widget->parent()))->orientation() == Qt::Horizontal) if (onToolbar && ceData.toolBarData.orientation == TQt::Horizontal)
bflags |= Style_Horizontal; bflags |= Style_Horizontal;
if (controls & SC_ToolButton) if (controls & SC_ToolButton)
@ -2297,11 +2303,9 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
} }
// Check whether to draw a background pixmap // Check whether to draw a background pixmap
else if ( toolbutton->parentWidget() && else if ( !ceData.parentWidgetData.bgPixmap.isNull() )
toolbutton->parentWidget()->backgroundPixmap() &&
!toolbutton->parentWidget()->backgroundPixmap()->isNull() )
{ {
TQPixmap pixmap = *(toolbutton->parentWidget()->backgroundPixmap()); TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
p->drawTiledPixmap( r, pixmap, toolbutton->pos() ); p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
} }
else if (onToolbar) else if (onToolbar)
@ -2314,8 +2318,8 @@ void KeramikStyle::drawComplexControl( TQ_ComplexControl control,
//(so if we're on an extender, we're not floating) //(so if we're on an extender, we're not floating)
TQWidget* parent = static_cast<TQWidget*> (TQT_TQWIDGET(widget->parent())); TQWidget* parent = static_cast<TQWidget*> (TQT_TQWIDGET(widget->parent()));
TQToolBar* toolbar = static_cast<TQToolBar*>(TQT_TQWIDGET(parent->parent())); TQToolBar* toolbar = static_cast<TQToolBar*>(TQT_TQWIDGET(parent->parent()));
TQRect tr = toolbar->rect(); TQRect tr = ceData.parentWidgetData.rect;
bool horiz = toolbar->orientation() == Qt::Horizontal; bool horiz = ceData.toolBarData.orientation == TQt::Horizontal;
//Calculate offset. We do this by translating our coordinates, //Calculate offset. We do this by translating our coordinates,
//which are relative to the parent, to be relative to the toolbar. //which are relative to the parent, to be relative to the toolbar.
@ -2507,8 +2511,7 @@ TQSize KeramikStyle::sizeFromContents( ContentsType contents,
case CT_ComboBox: { case CT_ComboBox: {
int arrow = 11 + loader.size( keramik_ripple ).width(); int arrow = 11 + loader.size( keramik_ripple ).width();
const TQComboBox *cb = static_cast<const TQComboBox*>( widget ); return TQSize( contentSize.width() + arrow + ((elementFlags & CEF_IsEditable) ? 26 : 22),
return TQSize( contentSize.width() + arrow + (cb->editable() ? 26 : 22),
contentSize.height() + 10 ); contentSize.height() + 10 );
} }
@ -2608,7 +2611,7 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
{ {
int arrow; int arrow;
bool compact = false; bool compact = false;
if ( isSizeConstrainedCombo(static_cast<const TQComboBox*>(widget) ) ) //### constant if ( isSizeConstrainedCombo(ceData, elementFlags, dynamic_cast<const TQComboBox*>(widget)) ) //### constant
compact = true; compact = true;
if ( compact ) if ( compact )
@ -2715,10 +2718,9 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
} }
case CC_Slider: case CC_Slider:
{ {
const TQSlider* sl = static_cast< const TQSlider* >( widget ); bool horizontal = ceData.orientation == TQt::Horizontal;
bool horizontal = sl->orientation() == Qt::Horizontal; TQSlider::TickSetting ticks = (TQSlider::TickSetting)ceData.tickMarkSetting;
TQSlider::TickSetting ticks = sl->tickmarks(); int pos = ceData.startStep;
int pos = sl->sliderStart();
int size = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget ); int size = pixelMetric( PM_SliderControlThickness, ceData, elementFlags, widget );
int handleSize = pixelMetric( PM_SliderThickness, ceData, elementFlags, widget ); int handleSize = pixelMetric( PM_SliderThickness, ceData, elementFlags, widget );
int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
@ -2726,9 +2728,9 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
//Shrink the metrics if the widget is too small //Shrink the metrics if the widget is too small
//to fit our normal values for them. //to fit our normal values for them.
if (horizontal) if (horizontal)
handleSize = QMIN(handleSize, sl->height()); handleSize = QMIN(handleSize, ceData.rect.height());
else else
handleSize = QMIN(handleSize, sl->width()); handleSize = QMIN(handleSize, ceData.rect.width());
size = QMIN(size, handleSize); size = QMIN(size, handleSize);
@ -2738,34 +2740,34 @@ TQRect KeramikStyle::querySubControlMetrics( TQ_ComplexControl control,
if ( horizontal ) if ( horizontal )
{ {
if ( ticks == TQSlider::Both ) if ( ticks == TQSlider::Both )
return TQRect( 0, ( sl->height() - size ) / 2, sl->width(), size ); return TQRect( 0, ( ceData.rect.height() - size ) / 2, ceData.rect.width(), size );
else if ( ticks == TQSlider::Above ) else if ( ticks == TQSlider::Above )
return TQRect( 0, sl->height() - size - ( handleSize - size ) / 2, sl->width(), size ); return TQRect( 0, ceData.rect.height() - size - ( handleSize - size ) / 2, ceData.rect.width(), size );
return TQRect( 0, ( handleSize - size ) / 2, sl->width(), size ); return TQRect( 0, ( handleSize - size ) / 2, ceData.rect.width(), size );
} }
else else
{ {
if ( ticks == TQSlider::Both ) if ( ticks == TQSlider::Both )
return TQRect( ( sl->width() - size ) / 2, 0, size, sl->height() ); return TQRect( ( ceData.rect.width() - size ) / 2, 0, size, ceData.rect.height() );
else if ( ticks == TQSlider::Above ) else if ( ticks == TQSlider::Above )
return TQRect( sl->width() - size - ( handleSize - size ) / 2, 0, size, sl->height() ); return TQRect( ceData.rect.width() - size - ( handleSize - size ) / 2, 0, size, ceData.rect.height() );
return TQRect( ( handleSize - size ) / 2, 0, size, sl->height() ); return TQRect( ( handleSize - size ) / 2, 0, size, ceData.rect.height() );
} }
case SC_SliderHandle: case SC_SliderHandle:
if ( horizontal ) if ( horizontal )
{ {
if ( ticks == TQSlider::Both ) if ( ticks == TQSlider::Both )
return TQRect( pos, ( sl->height() - handleSize ) / 2, len, handleSize ); return TQRect( pos, ( ceData.rect.height() - handleSize ) / 2, len, handleSize );
else if ( ticks == TQSlider::Above ) else if ( ticks == TQSlider::Above )
return TQRect( pos, sl->height() - handleSize, len, handleSize ); return TQRect( pos, ceData.rect.height() - handleSize, len, handleSize );
return TQRect( pos, 0, len, handleSize ); return TQRect( pos, 0, len, handleSize );
} }
else else
{ {
if ( ticks == TQSlider::Both ) if ( ticks == TQSlider::Both )
return TQRect( ( sl->width() - handleSize ) / 2, pos, handleSize, len ); return TQRect( ( ceData.rect.width() - handleSize ) / 2, pos, handleSize, len );
else if ( ticks == TQSlider::Above ) else if ( ticks == TQSlider::Above )
return TQRect( sl->width() - handleSize, pos, handleSize, len ); return TQRect( ceData.rect.width() - handleSize, pos, handleSize, len );
return TQRect( 0, pos, handleSize, len ); return TQRect( 0, pos, handleSize, len );
} }
default: break; default: break;
@ -2925,6 +2927,9 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control
return false; // Now draw the contents return false; // Now draw the contents
} }
#if 0 // FIXME
// This does not work on modern systems
// Rather than resorting to hacks like this, which can stop working at any time, the required functionality should simply be added to TQt3!
else if (event->type() == TQEvent::Paint && object->parent() && ::tqqt_cast<TQToolBar*>(object->parent()) else if (event->type() == TQEvent::Paint && object->parent() && ::tqqt_cast<TQToolBar*>(object->parent())
&& !::tqqt_cast<TQPopupMenu*>(object) ) && !::tqqt_cast<TQPopupMenu*>(object) )
{ {
@ -2958,6 +2963,7 @@ bool KeramikStyle::objectEventHandler( TQStyleControlElementData ceData, Control
return true; return true;
} }
#endif
// Track show events for progress bars // Track show events for progress bars
if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) ) if ( animateProgressBar && ::tqqt_cast<TQProgressBar*>(object) )
{ {
@ -2988,8 +2994,11 @@ int KeramikStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Cont
ret = checkcol; ret = checkcol;
} }
break; break;
case SH_ScrollBar_CombineAddLineRegionDrawingAreas:
ret = 1;
break;
default: default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break; break;
} }

@ -146,8 +146,8 @@ private slots:
private: private:
bool isSizeConstrainedCombo(const TQComboBox* combo) const; bool isSizeConstrainedCombo(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQComboBox* widget) const;
bool isFormWidget (const TQWidget* widget) const; bool isFormWidget (const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget* widget) const;
///Configuration settings ///Configuration settings
bool animateProgressBar; bool animateProgressBar;

@ -804,7 +804,7 @@ void LightStyleV2::drawControl( TQ_ControlElement control,
case CE_PopupMenuItem: case CE_PopupMenuItem:
{ {
if (! widget || data.isDefault()) if (data.isDefault())
break; break;
TQMenuItem *mi = data.menuItem(); TQMenuItem *mi = data.menuItem();
@ -813,8 +813,8 @@ void LightStyleV2::drawControl( TQ_ControlElement control,
if ( mi && mi->isSeparator() ) { if ( mi && mi->isSeparator() ) {
// draw separator (bg first, though) // draw separator (bg first, though)
if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); p->drawPixmap( r.topLeft(), ceData.bgPixmap, r );
else else
p->fillRect(r, cg.brush(TQColorGroup::Button)); p->fillRect(r, cg.brush(TQColorGroup::Button));
@ -830,8 +830,8 @@ void LightStyleV2::drawControl( TQ_ControlElement control,
if (flags & Style_Active) if (flags & Style_Active)
qDrawShadePanel(p, r, cg, true, 1, qDrawShadePanel(p, r, cg, true, 1,
&cg.brush(TQColorGroup::Midlight)); &cg.brush(TQColorGroup::Midlight));
else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) else if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); p->drawPixmap( r.topLeft(), ceData.bgPixmap, r );
else else
p->fillRect(r, cg.brush(TQColorGroup::Button)); p->fillRect(r, cg.brush(TQColorGroup::Button));
@ -1020,14 +1020,13 @@ void LightStyleV2::drawControlMask( TQ_ControlElement control,
TQRect LightStyleV2::subRect(SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const TQRect LightStyleV2::subRect(SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const
{ {
TQRect rect, wrect(widget->rect()); TQRect rect, wrect(ceData.rect);
switch (subrect) { switch (subrect) {
case SR_PushButtonFocusRect: case SR_PushButtonFocusRect:
{ {
const TQPushButton *button = (const TQPushButton *) widget;
int dbw1 = 0, dbw2 = 0; int dbw1 = 0, dbw2 = 0;
if (button->isDefault() || button->autoDefault()) { if ((elementFlags & CEF_IsDefault) || (elementFlags & CEF_AutoDefault)) {
dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget); dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget);
dbw2 = dbw1 * 2; dbw2 = dbw1 * 2;
} }
@ -1089,7 +1088,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
if ((controls & SC_ComboBoxEditField) && field.isValid()) { if ((controls & SC_ComboBoxEditField) && field.isValid()) {
p->setPen(cg.dark()); p->setPen(cg.dark());
if (combobox->editable()) { if (elementFlags & CEF_IsEditable) {
field.addCoords(-1, -1, 1, 1); field.addCoords(-1, -1, 1, 1);
p->drawRect(field); p->drawRect(field);
} else } else
@ -1097,7 +1096,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
field.right() + 1, field.bottom()); field.right() + 1, field.bottom());
if (flags & Style_HasFocus) { if (flags & Style_HasFocus) {
if (! combobox->editable()) { if (! (elementFlags & CEF_IsEditable)) {
p->fillRect( field, cg.brush( TQColorGroup::Highlight ) ); p->fillRect( field, cg.brush( TQColorGroup::Highlight ) );
TQRect fr = TQRect fr =
TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ),
@ -1122,8 +1121,8 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags,
SC_SpinWidgetFrame, data, widget); SC_SpinWidgetFrame, data, widget);
up = spinwidget->upRect(); up = ceData.spinWidgetData.upRect;
down = spinwidget->downRect(); down = ceData.spinWidgetData.downRect;
if ((controls & SC_SpinWidgetFrame) && frame.isValid()) if ((controls & SC_SpinWidgetFrame) && frame.isValid())
drawLightBevel(p, frame, cg, flags | Style_Sunken, drawLightBevel(p, frame, cg, flags | Style_Sunken,
@ -1131,7 +1130,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
if ((controls & SC_SpinWidgetUp) && up.isValid()) { if ((controls & SC_SpinWidgetUp) && up.isValid()) {
TQ_PrimitiveElement pe = PE_SpinWidgetUp; TQ_PrimitiveElement pe = PE_SpinWidgetUp;
if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetPlus; pe = PE_SpinWidgetPlus;
p->setPen(cg.dark()); p->setPen(cg.dark());
@ -1164,7 +1163,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
if ((controls & SC_SpinWidgetDown) && down.isValid()) { if ((controls & SC_SpinWidgetDown) && down.isValid()) {
TQ_PrimitiveElement pe = PE_SpinWidgetDown; TQ_PrimitiveElement pe = PE_SpinWidgetDown;
if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetMinus; pe = PE_SpinWidgetMinus;
p->setPen(cg.dark()); p->setPen(cg.dark());
@ -1200,9 +1199,8 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
case CC_ScrollBar: case CC_ScrollBar:
{ {
const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
TQRect addline, subline, subline2, addpage, subpage, slider, first, last; TQRect addline, subline, subline2, addpage, subpage, slider, first, last;
bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); bool maxedOut = (ceData.minSteps == ceData.maxSteps);
subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget); subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget);
addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget); addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget);
@ -1213,7 +1211,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget); last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget);
subline2 = addline; subline2 = addline;
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
subline2.moveBy(-addline.width(), 0); subline2.moveBy(-addline.width(), 0);
else else
subline2.moveBy(0, -addline.height()); subline2.moveBy(0, -addline.height());
@ -1222,56 +1220,56 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Enabled | ((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if (subline2.isValid()) if (subline2.isValid())
drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg,
Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Enabled | ((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
} }
if ((controls & SC_ScrollBarAddLine) && addline.isValid()) if ((controls & SC_ScrollBarAddLine) && addline.isValid())
drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg, drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
Style_Enabled | ((active == SC_ScrollBarAddLine) ? Style_Enabled | ((active == SC_ScrollBarAddLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg, drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg,
Style_Enabled | ((active == SC_ScrollBarSubPage) ? Style_Enabled | ((active == SC_ScrollBarSubPage) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg, drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) | ((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddPage) ? ((active == SC_ScrollBarAddPage) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarFirst) && first.isValid()) if ((controls & SC_ScrollBarFirst) && first.isValid())
drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg,
Style_Enabled | ((active == SC_ScrollBarFirst) ? Style_Enabled | ((active == SC_ScrollBarFirst) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarLast) && last.isValid()) if ((controls & SC_ScrollBarLast) && last.isValid())
drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg,
Style_Enabled | ((active == SC_ScrollBarLast) ? Style_Enabled | ((active == SC_ScrollBarLast) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarSlider) && slider.isValid()) { if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
Style_Enabled | ((active == SC_ScrollBarSlider) ? Style_Enabled | ((active == SC_ScrollBarSlider) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
// ### perhaps this should not be able to accept focus if maxedOut? // ### perhaps this should not be able to accept focus if maxedOut?
if (scrollbar->hasFocus()) { if (elementFlags & CEF_HasFocus) {
TQRect fr(slider.x() + 2, slider.y() + 2, TQRect fr(slider.x() + 2, slider.y() + 2,
slider.width() - 5, slider.height() - 5); slider.width() - 5, slider.height() - 5);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default);
@ -1283,7 +1281,6 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
case CC_Slider: case CC_Slider:
{ {
const TQSlider *slider = (const TQSlider *) widget;
TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove,
data, widget), data, widget),
handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle,
@ -1293,7 +1290,7 @@ void LightStyleV2::drawComplexControl( TQ_ComplexControl control,
if (flags & Style_HasFocus) if (flags & Style_HasFocus)
drawPrimitive( PE_FocusRect, p, ceData, elementFlags, groove, cg ); drawPrimitive( PE_FocusRect, p, ceData, elementFlags, groove, cg );
if (slider->orientation() == Qt::Horizontal) { if (ceData.orientation == TQt::Horizontal) {
int dh = (groove.height() - 5) / 2; int dh = (groove.height() - 5) / 2;
groove.addCoords(0, dh, 0, -dh); groove.addCoords(0, dh, 0, -dh);
} else { } else {
@ -1344,18 +1341,17 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control,
switch (control) { switch (control) {
case CC_ScrollBar: case CC_ScrollBar:
{ {
const TQScrollBar *scrollbar = (const TQScrollBar *) widget; int sliderstart = ceData.startStep;
int sliderstart = scrollbar->sliderStart();
int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget); int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? int maxlen = ((ceData.orientation == TQt::Horizontal) ?
scrollbar->width() : scrollbar->height()) - (sbextent * 3); ceData.rect.width() : ceData.rect.height()) - (sbextent * 3);
int sliderlen; int sliderlen;
// calculate slider length // calculate slider length
if (scrollbar->maxValue() != scrollbar->minValue()) { if (ceData.maxSteps != ceData.minSteps) {
uint range = scrollbar->maxValue() - scrollbar->minValue(); uint range = ceData.maxSteps - ceData.minSteps;
sliderlen = (scrollbar->pageStep() * maxlen) / sliderlen = (ceData.pageStep * maxlen) /
(range + scrollbar->pageStep()); (range + ceData.pageStep);
int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget ); int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
if ( sliderlen < slidermin || range > INT_MAX / 2 ) if ( sliderlen < slidermin || range > INT_MAX / 2 )
@ -1373,15 +1369,15 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control,
case SC_ScrollBarAddLine: case SC_ScrollBarAddLine:
// bottom/right button // bottom/right button
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(scrollbar->width() - sbextent, 0, sbextent, sbextent); ret.setRect(ceData.rect.width() - sbextent, 0, sbextent, sbextent);
else else
ret.setRect(0, scrollbar->height() - sbextent, sbextent, sbextent); ret.setRect(0, ceData.rect.height() - sbextent, sbextent, sbextent);
break; break;
case SC_ScrollBarSubPage: case SC_ScrollBarSubPage:
// between top/left button and slider // between top/left button and slider
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent); ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent);
else else
ret.setRect(0, sbextent, sbextent, sliderstart - sbextent); ret.setRect(0, sbextent, sbextent, sliderstart - sbextent);
@ -1389,7 +1385,7 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control,
case SC_ScrollBarAddPage: case SC_ScrollBarAddPage:
// between bottom/right button and slider // between bottom/right button and slider
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sliderstart + sliderlen, 0, ret.setRect(sliderstart + sliderlen, 0,
maxlen - sliderstart - sliderlen + sbextent, sbextent); maxlen - sliderstart - sliderlen + sbextent, sbextent);
else else
@ -1398,16 +1394,16 @@ TQRect LightStyleV2::querySubControlMetrics( TQ_ComplexControl control,
break; break;
case SC_ScrollBarGroove: case SC_ScrollBarGroove:
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sbextent, 0, scrollbar->width() - sbextent * 3, ret.setRect(sbextent, 0, ceData.rect.width() - sbextent * 3,
scrollbar->height()); ceData.rect.height());
else else
ret.setRect(0, sbextent, scrollbar->width(), ret.setRect(0, sbextent, ceData.rect.width(),
scrollbar->height() - sbextent * 3); ceData.rect.height() - sbextent * 3);
break; break;
case SC_ScrollBarSlider: case SC_ScrollBarSlider:
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sliderstart, 0, sliderlen, sbextent); ret.setRect(sliderstart, 0, sliderlen, sbextent);
else else
ret.setRect(0, sliderstart, sbextent, sliderlen); ret.setRect(0, sliderstart, sbextent, sliderlen);
@ -1541,7 +1537,7 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents,
// only expand the button if we are displaying text... // only expand the button if we are displaying text...
if ( ! button->text().isEmpty() ) { if ( ! button->text().isEmpty() ) {
if ( button->isDefault() || button->autoDefault() ) { if ( (elementFlags & CEF_IsDefault) || button->autoDefault() ) {
// default button minimum size // default button minimum size
if ( w < 80 ) if ( w < 80 )
w = 80; w = 80;
@ -1562,7 +1558,7 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents,
case CT_PopupMenuItem: case CT_PopupMenuItem:
{ {
if (! widget || data.isDefault()) if (data.isDefault())
break; break;
TQMenuItem *mi = data.menuItem(); TQMenuItem *mi = data.menuItem();
@ -1606,22 +1602,20 @@ TQSize LightStyleV2::sizeFromContents( ContentsType contents,
} }
case CT_ProgressBar: case CT_ProgressBar:
{ {
const TQProgressBar* pb = static_cast<const TQProgressBar*>(widget);
//If we have to display the indicator, and we do it on RHS, give some more room //If we have to display the indicator, and we do it on RHS, give some more room
//for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents //for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents
//sizing in TQCommonStyle. //sizing in TQCommonStyle.
if (pb->percentageVisible() && if (ceData.percentageVisible &&
(pb->indicatorFollowsStyle() || ! pb->centerIndicator())) ((elementFlags & CEF_IndicatorFollowsStyle) || ! (elementFlags & CEF_CenterIndicator)))
{ {
int addw = pb->fontMetrics().width("100%") + 6; int addw = TQFontMetrics(ceData.font).width("100%") + 6;
return TQSize(contentsSize.width() + addw, contentsSize.height()); return TQSize(contentsSize.width() + addw, contentsSize.height());
} }
else else
return contentsSize; //Otherwise leave unchanged return contentsSize; //Otherwise leave unchanged
break; break;
} }
default: default:
ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget); ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget);

@ -926,7 +926,7 @@ void LightStyleV3::drawControl( TQ_ControlElement control,
case CE_PopupMenuItem: case CE_PopupMenuItem:
{ {
if (! widget || data.isDefault()) if (data.isDefault())
break; break;
TQMenuItem *mi = data.menuItem(); TQMenuItem *mi = data.menuItem();
@ -934,8 +934,8 @@ void LightStyleV3::drawControl( TQ_ControlElement control,
int maxpmw = data.maxIconWidth(); int maxpmw = data.maxIconWidth();
if ( mi && mi->isSeparator() ) { if ( mi && mi->isSeparator() ) {
if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); p->drawPixmap( r.topLeft(), ceData.bgPixmap, r );
else else
p->fillRect(r, cg.brush(TQColorGroup::Button)); p->fillRect(r, cg.brush(TQColorGroup::Button));
p->setPen( cg.mid() ); p->setPen( cg.mid() );
@ -950,8 +950,8 @@ void LightStyleV3::drawControl( TQ_ControlElement control,
if (flags & Style_Active) if (flags & Style_Active)
qDrawShadePanel(p, r, cg, true, 1, qDrawShadePanel(p, r, cg, true, 1,
&cg.brush(TQColorGroup::Midlight)); &cg.brush(TQColorGroup::Midlight));
else if ( widget->erasePixmap() && !widget->erasePixmap()->isNull() ) else if ( !ceData.bgPixmap.isNull() )
p->drawPixmap( r.topLeft(), *widget->erasePixmap(), r ); p->drawPixmap( r.topLeft(), ceData.bgPixmap, r );
else else
p->fillRect(r, cg.brush(TQColorGroup::Button)); p->fillRect(r, cg.brush(TQColorGroup::Button));
@ -1221,7 +1221,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
if ((controls & SC_ComboBoxEditField) && field.isValid()) { if ((controls & SC_ComboBoxEditField) && field.isValid()) {
if (flags & Style_HasFocus) { if (flags & Style_HasFocus) {
if (! combobox->editable()) { if (! (elementFlags & CEF_IsEditable)) {
TQRect fr = TQRect fr =
TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ), TQStyle::visualRect( subRect( SR_ComboBoxFocusRect, ceData, elementFlags, widget ),
ceData, elementFlags ); ceData, elementFlags );
@ -1250,15 +1250,15 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, frame = querySubControlMetrics((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags,
SC_SpinWidgetFrame, data, widget); SC_SpinWidgetFrame, data, widget);
up = spinwidget->upRect(); up = ceData.spinWidgetData.upRect;
down = spinwidget->downRect(); down = ceData.spinWidgetData.downRect;
if ((controls & SC_SpinWidgetFrame) && frame.isValid()) if ((controls & SC_SpinWidgetFrame) && frame.isValid())
drawPrimitive( PE_Panel, p, ceData, elementFlags, frame, cg, flags | Style_Sunken ); drawPrimitive( PE_Panel, p, ceData, elementFlags, frame, cg, flags | Style_Sunken );
if ((controls & SC_SpinWidgetUp) && up.isValid()) { if ((controls & SC_SpinWidgetUp) && up.isValid()) {
TQ_PrimitiveElement pe = PE_SpinWidgetUp; TQ_PrimitiveElement pe = PE_SpinWidgetUp;
if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetPlus; pe = PE_SpinWidgetPlus;
p->setPen( cg.background() ); p->setPen( cg.background() );
@ -1276,7 +1276,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
if ((controls & SC_SpinWidgetDown) && down.isValid()) { if ((controls & SC_SpinWidgetDown) && down.isValid()) {
TQ_PrimitiveElement pe = PE_SpinWidgetDown; TQ_PrimitiveElement pe = PE_SpinWidgetDown;
if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) if ( ceData.spinWidgetData.buttonSymbols == TQSpinWidget::PlusMinus )
pe = PE_SpinWidgetMinus; pe = PE_SpinWidgetMinus;
p->setPen( cg.background() ); p->setPen( cg.background() );
@ -1297,9 +1297,8 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
case CC_ScrollBar: case CC_ScrollBar:
{ {
const TQScrollBar *scrollbar = (const TQScrollBar *) widget;
TQRect addline, subline, subline2, addpage, subpage, slider, first, last; TQRect addline, subline, subline2, addpage, subpage, slider, first, last;
bool maxedOut = (scrollbar->minValue() == scrollbar->maxValue()); bool maxedOut = (ceData.minSteps == ceData.maxSteps);
subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget); subline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine, data, widget);
addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget); addline = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine, data, widget);
@ -1310,7 +1309,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget); last = querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast, data, widget);
subline2 = addline; subline2 = addline;
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
subline2.moveBy(-addline.width(), 0); subline2.moveBy(-addline.width(), 0);
else else
subline2.moveBy(0, -addline.height()); subline2.moveBy(0, -addline.height());
@ -1319,56 +1318,56 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, cg,
Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Enabled | ((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if (subline2.isValid()) if (subline2.isValid())
drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg, drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, cg,
Style_Enabled | ((active == SC_ScrollBarSubLine) ? Style_Enabled | ((active == SC_ScrollBarSubLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
} }
if ((controls & SC_ScrollBarAddLine) && addline.isValid()) if ((controls & SC_ScrollBarAddLine) && addline.isValid())
drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg, drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, cg,
Style_Enabled | ((active == SC_ScrollBarAddLine) ? Style_Enabled | ((active == SC_ScrollBarAddLine) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarSubPage) && subpage.isValid()) if ((controls & SC_ScrollBarSubPage) && subpage.isValid())
drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg, drawPrimitive(PE_ScrollBarSubPage, p, ceData, elementFlags, subpage, cg,
Style_Enabled | ((active == SC_ScrollBarSubPage) ? Style_Enabled | ((active == SC_ScrollBarSubPage) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarAddPage) && addpage.isValid()) if ((controls & SC_ScrollBarAddPage) && addpage.isValid())
drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg, drawPrimitive(PE_ScrollBarAddPage, p, ceData, elementFlags, addpage, cg,
((maxedOut) ? Style_Default : Style_Enabled) | ((maxedOut) ? Style_Default : Style_Enabled) |
((active == SC_ScrollBarAddPage) ? ((active == SC_ScrollBarAddPage) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarFirst) && first.isValid()) if ((controls & SC_ScrollBarFirst) && first.isValid())
drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg,
Style_Enabled | ((active == SC_ScrollBarFirst) ? Style_Enabled | ((active == SC_ScrollBarFirst) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarLast) && last.isValid()) if ((controls & SC_ScrollBarLast) && last.isValid())
drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg,
Style_Enabled | ((active == SC_ScrollBarLast) ? Style_Enabled | ((active == SC_ScrollBarLast) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
if ((controls & SC_ScrollBarSlider) && slider.isValid()) { if ((controls & SC_ScrollBarSlider) && slider.isValid()) {
drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg,
Style_Enabled | ((active == SC_ScrollBarSlider) ? Style_Enabled | ((active == SC_ScrollBarSlider) ?
Style_Down : Style_Default) | Style_Down : Style_Default) |
((scrollbar->orientation() == Qt::Horizontal) ? ((ceData.orientation == TQt::Horizontal) ?
Style_Horizontal : 0)); Style_Horizontal : 0));
// ### perhaps this should not be able to accept focus if maxedOut? // ### perhaps this should not be able to accept focus if maxedOut?
if (scrollbar->hasFocus()) { if (elementFlags & CEF_HasFocus) {
TQRect fr(slider.x() + 2, slider.y() + 2, TQRect fr(slider.x() + 2, slider.y() + 2,
slider.width() - 5, slider.height() - 5); slider.width() - 5, slider.height() - 5);
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default); drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, Style_Default);
@ -1425,7 +1424,7 @@ void LightStyleV3::drawComplexControl( TQ_ComplexControl control,
p->fillRect( handle, sliderColor ); p->fillRect( handle, sliderColor );
p->setPen( cg.midlight() ); p->setPen( cg.midlight() );
if ( slider->orientation() == Qt::Horizontal ) if ( ceData.orientation == TQt::Horizontal )
p->drawLine( handle.left() + handle.width() / 2, p->drawLine( handle.left() + handle.width() / 2,
handle.top() + 1, handle.top() + 1,
handle.left() + handle.width() / 2, handle.left() + handle.width() / 2,
@ -1473,15 +1472,15 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
switch ( sc ) { switch ( sc ) {
case SC_ComboBoxFrame: case SC_ComboBoxFrame:
ret = widget->rect(); ret = ceData.rect;
break; break;
case SC_ComboBoxArrow: case SC_ComboBoxArrow:
ret.setRect( widget->width() - fw - sb, fw, ret.setRect( ceData.rect.width() - fw - sb, fw,
sb, widget->height() - fw*2 ); sb, ceData.rect.height() - fw*2 );
break; break;
case SC_ComboBoxEditField: case SC_ComboBoxEditField:
ret.setRect( fw, fw, widget->width() - fw*2 - sb - 1, ret.setRect( fw, fw, ceData.rect.width() - fw*2 - sb - 1,
widget->height() - fw*2 ); ceData.rect.height() - fw*2 );
break; break;
default: default:
break; break;
@ -1492,18 +1491,17 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
case CC_ScrollBar: case CC_ScrollBar:
{ {
const TQScrollBar *scrollbar = (const TQScrollBar *) widget; int sliderstart = ceData.startStep;
int sliderstart = scrollbar->sliderStart();
int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget); int sbextent = pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget);
int maxlen = ((scrollbar->orientation() == Qt::Horizontal) ? int maxlen = ((ceData.orientation == TQt::Horizontal) ?
scrollbar->width() : scrollbar->height()) - (sbextent * 3); ceData.rect.width() : ceData.rect.height()) - (sbextent * 3);
int sliderlen; int sliderlen;
// calculate slider length // calculate slider length
if (scrollbar->maxValue() != scrollbar->minValue()) { if (ceData.maxSteps != ceData.minSteps) {
uint range = scrollbar->maxValue() - scrollbar->minValue(); uint range = ceData.maxSteps - ceData.minSteps;
sliderlen = (scrollbar->pageStep() * maxlen) / sliderlen = (ceData.pageStep * maxlen) /
(range + scrollbar->pageStep()); (range + ceData.pageStep);
int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget ); int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
if ( sliderlen < slidermin || range > INT_MAX / 2 ) if ( sliderlen < slidermin || range > INT_MAX / 2 )
@ -1521,15 +1519,15 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
case SC_ScrollBarAddLine: case SC_ScrollBarAddLine:
// bottom/right button // bottom/right button
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(scrollbar->width() - sbextent, 0, sbextent, sbextent); ret.setRect(ceData.rect.width() - sbextent, 0, sbextent, sbextent);
else else
ret.setRect(0, scrollbar->height() - sbextent, sbextent, sbextent); ret.setRect(0, ceData.rect.height() - sbextent, sbextent, sbextent);
break; break;
case SC_ScrollBarSubPage: case SC_ScrollBarSubPage:
// between top/left button and slider // between top/left button and slider
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent); ret.setRect(sbextent, 0, sliderstart - sbextent, sbextent);
else else
ret.setRect(0, sbextent, sbextent, sliderstart - sbextent); ret.setRect(0, sbextent, sbextent, sliderstart - sbextent);
@ -1537,7 +1535,7 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
case SC_ScrollBarAddPage: case SC_ScrollBarAddPage:
// between bottom/right button and slider // between bottom/right button and slider
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sliderstart + sliderlen, 0, maxlen - sliderstart - ret.setRect(sliderstart + sliderlen, 0, maxlen - sliderstart -
sliderlen + sbextent, sbextent); sliderlen + sbextent, sbextent);
else else
@ -1546,14 +1544,14 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
break; break;
case SC_ScrollBarGroove: case SC_ScrollBarGroove:
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sbextent, 0, maxlen, sbextent ); ret.setRect(sbextent, 0, maxlen, sbextent );
else else
ret.setRect(0, sbextent, sbextent, maxlen ); ret.setRect(0, sbextent, sbextent, maxlen );
break; break;
case SC_ScrollBarSlider: case SC_ScrollBarSlider:
if (scrollbar->orientation() == Qt::Horizontal) if (ceData.orientation == TQt::Horizontal)
ret.setRect(sliderstart, 0, sliderlen, sbextent); ret.setRect(sliderstart, 0, sliderlen, sbextent);
else else
ret.setRect(0, sliderstart, sbextent, sliderlen); ret.setRect(0, sliderstart, sbextent, sliderlen);
@ -1574,18 +1572,18 @@ TQRect LightStyleV3::querySubControlMetrics( TQ_ComplexControl control,
switch ( sc ) { switch ( sc ) {
case SC_SliderGroove: case SC_SliderGroove:
if ( slider->orientation() == Qt::Horizontal ) if ( ceData.orientation == TQt::Horizontal )
ret.setRect( 0, tickOffset, slider->width(), thickness ); ret.setRect( 0, tickOffset, ceData.rect.width(), thickness );
else else
ret.setRect( tickOffset, 0, thickness, slider->height() ); ret.setRect( tickOffset, 0, thickness, ceData.rect.height() );
break; break;
case SC_SliderHandle: case SC_SliderHandle:
{ {
int pos = slider->sliderStart(); int pos = ceData.startStep;
int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget ); int len = pixelMetric( PM_SliderLength, ceData, elementFlags, widget );
if ( slider->orientation() == Qt::Horizontal ) if ( ceData.orientation == TQt::Horizontal )
ret.setRect( pos + 2, tickOffset + 2, len - 4, thickness - 4 ); ret.setRect( pos + 2, tickOffset + 2, len - 4, thickness - 4 );
else else
ret.setRect( tickOffset + 2, pos + 2, thickness - 4, len - 4 ); ret.setRect( tickOffset + 2, pos + 2, thickness - 4, len - 4 );
@ -1697,10 +1695,9 @@ int LightStyleV3::pixelMetric( PixelMetric metric, TQStyleControlElementData ceD
case PM_SliderControlThickness: case PM_SliderControlThickness:
{ {
const TQSlider * sl = (const TQSlider *) widget; int space = (ceData.orientation == TQt::Horizontal) ? ceData.rect.height()
int space = (sl->orientation() == Qt::Horizontal) ? sl->height() : ceData.rect.width();
: sl->width(); int ticks = ceData.tickMarkSetting;
int ticks = sl->tickmarks();
int n = 0; int n = 0;
if ( ticks & TQSlider::Above ) n++; if ( ticks & TQSlider::Above ) n++;
if ( ticks & TQSlider::Below ) n++; if ( ticks & TQSlider::Below ) n++;
@ -1789,7 +1786,7 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents,
case CT_PopupMenuItem: case CT_PopupMenuItem:
{ {
if (! widget || data.isDefault()) if (data.isDefault())
break; break;
TQMenuItem *mi = data.menuItem(); TQMenuItem *mi = data.menuItem();
@ -1834,22 +1831,20 @@ TQSize LightStyleV3::sizeFromContents( ContentsType contents,
case CT_ProgressBar: case CT_ProgressBar:
{ {
const TQProgressBar* pb = static_cast<const TQProgressBar*>(widget);
//If we have to display the indicator, and we do it on RHS, give some more room //If we have to display the indicator, and we do it on RHS, give some more room
//for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents //for it. This tries to match the logic and the spacing in SR_ProgressBarGroove/Contents
//sizing in TQCommonStyle. //sizing in TQCommonStyle.
if (pb->percentageVisible() && if (ceData.percentageVisible &&
(pb->indicatorFollowsStyle() || ! pb->centerIndicator())) ((elementFlags & CEF_IndicatorFollowsStyle) || ! (elementFlags & CEF_CenterIndicator)))
{ {
int addw = pb->fontMetrics().width("100%") + 6; int addw = TQFontMetrics(ceData.font).width("100%") + 6;
return TQSize(contentsSize.width() + addw, contentsSize.height()); return TQSize(contentsSize.width() + addw, contentsSize.height());
} }
else else
return contentsSize; //Otherwise leave unchanged return contentsSize; //Otherwise leave unchanged
break; break;
} }
default: default:
ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget); ret = TQCommonStyle::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget);

@ -1215,8 +1215,7 @@ void PlastikStyle::drawKStylePrimitive(KStylePrimitive kpe,
// ------ // ------
switch( kpe ) { switch( kpe ) {
case KPE_SliderGroove: { case KPE_SliderGroove: {
const TQSlider* slider = (const TQSlider*)widget; bool horizontal = ceData.orientation == TQt::Horizontal;
bool horizontal = slider->orientation() == Qt::Horizontal;
if (horizontal) { if (horizontal) {
int center = r.y()+r.height()/2; int center = r.y()+r.height()/2;
@ -1233,8 +1232,7 @@ void PlastikStyle::drawKStylePrimitive(KStylePrimitive kpe,
} }
case KPE_SliderHandle: { case KPE_SliderHandle: {
const TQSlider* slider = (const TQSlider*)widget; bool horizontal = ceData.orientation == TQt::Horizontal;
bool horizontal = slider->orientation() == Qt::Horizontal;
const bool pressed = (flags&Style_Active); const bool pressed = (flags&Style_Active);
const WidgetState s = enabled?(pressed?IsPressed:IsEnabled):IsDisabled; const WidgetState s = enabled?(pressed?IsPressed:IsEnabled):IsDisabled;
@ -2214,15 +2212,14 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
} }
case CE_ProgressBarContents: { case CE_ProgressBarContents: {
const TQProgressBar *pb = dynamic_cast<const TQProgressBar*>(widget); int steps = ceData.totalSteps;
int steps = pb->totalSteps();
const TQColor bg = enabled?cg.base():cg.background(); // background const TQColor bg = enabled?cg.base():cg.background(); // background
const TQColor fg = enabled?cg.highlight():TQColor(cg.background().dark(110)); // foreground const TQColor fg = enabled?cg.highlight():TQColor(cg.background().dark(110)); // foreground
if( steps == 0 ) { // Busy indicator if( steps == 0 ) { // Busy indicator
static const int barWidth = 10; static const int barWidth = 10;
int progress = pb->progress() % (2*(r.width()-barWidth)); int progress = ceData.currentStep % (2*(r.width()-barWidth));
if( progress < 0) if( progress < 0)
progress = 0; progress = 0;
if( progress > r.width()-barWidth ) if( progress > r.width()-barWidth )
@ -2239,7 +2236,7 @@ void PlastikStyle::drawControl(TQ_ControlElement element,
Round_UpperRight|Round_BottomRight| Round_UpperRight|Round_BottomRight|
Round_UpperLeft|Round_BottomLeft|Is_Horizontal); Round_UpperLeft|Round_BottomLeft|Is_Horizontal);
} else { } else {
double percent = static_cast<double>(pb->progress()) / static_cast<double>(steps); double percent = static_cast<double>(ceData.currentStep) / static_cast<double>(steps);
int w = static_cast<int>(r.width() * percent); int w = static_cast<int>(r.width() * percent);
// renderContour/renderSurface handle small sizes not very well, so set a minimal // renderContour/renderSurface handle small sizes not very well, so set a minimal
@ -3196,11 +3193,11 @@ TQRect PlastikStyle::subRect(SubRect r, const TQStyleControlElementData ceData,
// Don't use KStyles progressbar subrect // Don't use KStyles progressbar subrect
// TODO: // TODO:
case SR_ProgressBarGroove: { case SR_ProgressBarGroove: {
return TQRect(widget->rect()); return TQRect(ceData.rect);
} }
case SR_ProgressBarContents: case SR_ProgressBarContents:
case SR_ProgressBarLabel: { case SR_ProgressBarLabel: {
TQRect rw = widget->rect(); TQRect rw = ceData.rect;
return TQRect(rw.left()+2, rw.top()+2, rw.width()-4, rw.height()-4 ); return TQRect(rw.left()+2, rw.top()+2, rw.width()-4, rw.height()-4 );
} }

@ -881,11 +881,10 @@ void KStyle::drawControl( TQ_ControlElement element,
case CE_ProgressBarContents: { case CE_ProgressBarContents: {
// ### Take into account totalSteps() for busy indicator // ### Take into account totalSteps() for busy indicator
const TQProgressBar* pb = (const TQProgressBar*)widget;
TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget); TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
double progress = pb->progress(); double progress = ceData.currentStep;
bool reverse = TQApplication::reverseLayout(); bool reverse = TQApplication::reverseLayout();
int steps = pb->totalSteps(); int steps = ceData.totalSteps;
if (!cr.isValid()) if (!cr.isValid())
return; return;
@ -945,11 +944,10 @@ void KStyle::drawControl( TQ_ControlElement element,
} }
case CE_ProgressBarLabel: { case CE_ProgressBarLabel: {
const TQProgressBar* pb = (const TQProgressBar*)widget;
TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget); TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
double progress = pb->progress(); double progress = ceData.currentStep;
bool reverse = TQApplication::reverseLayout(); bool reverse = TQApplication::reverseLayout();
int steps = pb->totalSteps(); int steps = ceData.totalSteps;
if (!cr.isValid()) if (!cr.isValid())
return; return;
@ -969,16 +967,16 @@ void KStyle::drawControl( TQ_ControlElement element,
crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height()); crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height());
p->save(); p->save();
p->setPen(pb->isEnabled() ? (reverse ? cg.text() : cg.highlightedText()) : cg.text()); p->setPen((elementFlags & CEF_IsEnabled) ? (reverse ? cg.text() : cg.highlightedText()) : cg.text());
p->drawText(r, AlignCenter, pb->progressString()); p->drawText(r, AlignCenter, ceData.progressText);
p->setClipRect(crect); p->setClipRect(crect);
p->setPen(reverse ? cg.highlightedText() : cg.text()); p->setPen(reverse ? cg.highlightedText() : cg.text());
p->drawText(r, AlignCenter, pb->progressString()); p->drawText(r, AlignCenter, ceData.progressText);
p->restore(); p->restore();
} else { } else {
p->setPen(cg.text()); p->setPen(cg.text());
p->drawText(r, AlignCenter, pb->progressString()); p->drawText(r, AlignCenter, ceData.progressText);
} }
break; break;

@ -237,8 +237,8 @@ class TDEFX_EXPORT KStyle: public TQCommonStyle
KPE_ListViewBranch KPE_ListViewBranch
}; };
// Old API // Old API
// DEPRECATED // DEPRECATED
virtual void drawKStylePrimitive( KStylePrimitive kpe, virtual void drawKStylePrimitive( KStylePrimitive kpe,
TQPainter* p, TQPainter* p,
const TQWidget* widget, const TQWidget* widget,

Loading…
Cancel
Save