Fix style crashes when used with third party toolkits

pull/1/head
Timothy Pearson 12 years ago
parent f16f8eb6bf
commit 06d51bc1ec

@ -114,17 +114,17 @@ void dotNETstyle::polish(TQStyleControlElementData ceData, ControlElementFlags e
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if (!qstrcmp(tqApp->argv()[0], "kicker") || widget->inherits("Kicker")) if (!qstrcmp(tqApp->argv()[0], "kicker") || ceData.widgetObjectTypes.contains("Kicker"))
kickerMode = true; kickerMode = true;
if (widget->isTopLevel()) if (elementFlags & CEF_IsTopLevel)
return; return;
// we can't simply set a palette -- upon color-theme changes, we have // we can't simply set a palette -- upon color-theme changes, we have
// to update the palette again. // to update the palette again.
// bool extraPalette = false; // bool extraPalette = false;
if (widget->inherits(TQCOMBOBOX_OBJECT_NAME_STRING) && !inheritsKHTML(widget)) { if (ceData.widgetObjectTypes.contains(TQCOMBOBOX_OBJECT_NAME_STRING) && !inheritsKHTML(widget)) {
installObjectEventHandler(ceData, elementFlags, ptr, this); installObjectEventHandler(ceData, elementFlags, ptr, this);
updatePalette( (TQComboBox*) widget ); updatePalette( (TQComboBox*) widget );
// extraPalette = true; // extraPalette = true;
@ -137,10 +137,10 @@ void dotNETstyle::polish(TQStyleControlElementData ceData, ControlElementFlags e
// other bad things (see bug #54569) // other bad things (see bug #54569)
/* /*
if (!widget->ownPalette()) { if (!widget->ownPalette()) {
if (widget->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) { if (ceData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) {
updatePalette( (TQToolBar*) widget ); updatePalette( (TQToolBar*) widget );
extraPalette = true; extraPalette = true;
} else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING)) { } else if (ceData.widgetObjectTypes.contains(TQMENUBAR_OBJECT_NAME_STRING)) {
updatePalette( (TQMenuBar*) widget ); updatePalette( (TQMenuBar*) widget );
extraPalette = true; extraPalette = true;
} }
@ -156,7 +156,7 @@ void dotNETstyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if (widget->inherits(TQCOMBOBOX_OBJECT_NAME_STRING) && !inheritsKHTML(widget)) { if (ceData.widgetObjectTypes.contains(TQCOMBOBOX_OBJECT_NAME_STRING) && !inheritsKHTML(widget)) {
removeObjectEventHandler(ceData, elementFlags, ptr, this); removeObjectEventHandler(ceData, elementFlags, ptr, this);
} }
} }
@ -390,10 +390,9 @@ void dotNETstyle::drawKStylePrimitive(KStylePrimitive kpe,
// ------ // ------
switch( kpe ) { switch( kpe ) {
case KPE_SliderGroove: { case KPE_SliderGroove: {
const TQSlider* slider = (const TQSlider*)widget;
int x, y, w, h; int x, y, w, h;
r.rect(&x, &y, &w, &h); r.rect(&x, &y, &w, &h);
bool horizontal = slider->orientation() ==Qt::Horizontal; bool horizontal = ceData.orientation == TQt::Horizontal;
int gcenter = (horizontal ? h : w) / 2; int gcenter = (horizontal ? h : w) / 2;
if (horizontal) { if (horizontal) {
@ -828,11 +827,9 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
} }
case CE_ProgressBarContents: { case CE_ProgressBarContents: {
const TQProgressBar *pb = (const TQProgressBar *)widget; if (ceData.totalSteps) {
if (pb->totalSteps()) {
int x, y, w, h; int x, y, w, h;
double percent = (double)pb->progress() / (double)pb->totalSteps(); double percent = (double)ceData.currentStep / (double)ceData.totalSteps;
r.rect(&x, &y, &w, &h); r.rect(&x, &y, &w, &h);
@ -849,7 +846,7 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
p->fillRect(x, y, w, h, cg.highlight()); p->fillRect(x, y, w, h, cg.highlight());
if (pb->progress() < pb->totalSteps()) { if (ceData.currentStep < ceData.totalSteps) {
p->setPen(cg.background().dark(115)); p->setPen(cg.background().dark(115));
if (TQApplication::reverseLayout()) { if (TQApplication::reverseLayout()) {
p->drawLine(x - 1, y, x - 1, h); p->drawLine(x - 1, y, x - 1, h);
@ -1107,7 +1104,6 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
} }
case CE_PushButtonLabel: { case CE_PushButtonLabel: {
const TQPushButton *pb = (const TQPushButton *)widget;
const bool enabled = flags & Style_Enabled; const bool enabled = flags & Style_Enabled;
const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix | const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix |
DontClip | SingleLine; DontClip | SingleLine;
@ -1118,19 +1114,19 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags)); pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags));
} }
if (!pb->text().isEmpty() && (flags & Style_ButtonDefault)) { if (!ceData.text.isEmpty() && (flags & Style_ButtonDefault)) {
p->setFont(TQFont(p->font().family(), p->font().pointSize(), 75)); p->setFont(TQFont(p->font().family(), p->font().pointSize(), 75));
} }
if (pb->iconSet() && !pb->iconSet()->isNull()) { if (!ceData.iconSet.isNull()) {
TQIconSet::Mode mode = enabled ? TQIconSet::Normal : TQIconSet::Disabled; TQIconSet::Mode mode = enabled ? TQIconSet::Normal : TQIconSet::Disabled;
TQPixmap pixmap = pb->iconSet()->pixmap(TQIconSet::Small, mode); TQPixmap pixmap = ceData.iconSet.pixmap(TQIconSet::Small, mode);
if (!pb->text().isEmpty()) if (!ceData.text.isEmpty())
{ {
const int TextToIconMargin = 3; const int TextToIconMargin = 3;
int length = pixmap.width() + TextToIconMargin int length = pixmap.width() + TextToIconMargin
+ p->fontMetrics().size(ShowPrefix, pb->text()).width(); + p->fontMetrics().size(ShowPrefix, ceData.text).width();
int offset = (r.width() - length)/2; int offset = (r.width() - length)/2;
p->drawPixmap( r.x() + offset, r.y() + r.height() / 2 - pixmap.height() / 2, pixmap ); p->drawPixmap( r.x() + offset, r.y() + r.height() / 2 - pixmap.height() / 2, pixmap );
@ -1138,28 +1134,28 @@ void dotNETstyle::drawControl(TQ_ControlElement element,
} }
else else
{ {
if (!pb->pixmap()) if (ceData.fgPixmap.isNull())
p->drawPixmap(r.x() + r.width()/2 - pixmap.width()/2, r.y() + r.height() / 2 - pixmap.height() / 2, p->drawPixmap(r.x() + r.width()/2 - pixmap.width()/2, r.y() + r.height() / 2 - pixmap.height() / 2,
pixmap); pixmap);
else //icon + pixmap. Ugh. else //icon + pixmap. Ugh.
p->drawPixmap(r.x() + pb->isDefault() ? 8 : 4 , r.y() + r.height() / 2 - pixmap.height() / 2, pixmap); p->drawPixmap(r.x() + (elementFlags & CEF_IsDefault) ? 8 : 4 , r.y() + r.height() / 2 - pixmap.height() / 2, pixmap);
} }
} }
if (pb->pixmap() && !pb->text()) { if ((!ceData.fgPixmap.isNull()) && !ceData.text) {
TQRect pr(0, 0, pb->pixmap()->width(), pb->pixmap()->height()); TQRect pr(0, 0, ceData.fgPixmap.width(), ceData.fgPixmap.height());
pr.moveCenter(r.center()); pr.moveCenter(r.center());
p->drawPixmap(pr.topLeft(), *pb->pixmap()); p->drawPixmap(pr.topLeft(), (ceData.fgPixmap.isNull())?NULL:ceData.fgPixmap);
} }
if (useTextShadows && !pb->text().isEmpty() && enabled) { if (useTextShadows && !ceData.text.isEmpty() && enabled) {
p->setPen((flags & Style_Down ? cg.highlight().dark(135) : cg.background().dark(115))); p->setPen((flags & Style_Down ? cg.highlight().dark(135) : cg.background().dark(115)));
p->drawText(ur.x()+1, ur.y()+1, ur.width(), ur.height(), text_flags, pb->text()); p->drawText(ur.x()+1, ur.y()+1, ur.width(), ur.height(), text_flags, ceData.text);
} }
if (!pb->text().isEmpty()) { if (!ceData.text.isEmpty()) {
p->setPen(enabled ? cg.foreground() : pb->palette().disabled().buttonText()); p->setPen(enabled ? cg.foreground() : ceData.palette.disabled().buttonText());
p->drawText(ur, text_flags, pb->text()); p->drawText(ur, text_flags, ceData.text);
} }
if ( flags & Style_HasFocus ) if ( flags & Style_HasFocus )
@ -1484,7 +1480,6 @@ void dotNETstyle::drawComplexControl(ComplexControl control,
// -------- // --------
case CC_ComboBox: { case CC_ComboBox: {
int x, y, w, h; int x, y, w, h;
const TQComboBox *cb = (const TQComboBox *)widget;
r.rect(&x, &y, &w, &h); r.rect(&x, &y, &w, &h);
if (active & Style_Sunken) if (active & Style_Sunken)
@ -1501,13 +1496,13 @@ void dotNETstyle::drawComplexControl(ComplexControl control,
TQBitmap downArrow = TQBitmap(7, 4, downarrow_bits, true); TQBitmap downArrow = TQBitmap(7, 4, downarrow_bits, true);
downArrow.setMask(downArrow); downArrow.setMask(downArrow);
cb->editable() ? p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.base()) : p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.light()); (elementFlags & CEF_IsEditable) ? p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.base()) : p->fillRect(x + 1, y + 1, w - 2, h - 2, cg.light());
renderPanel(p, r, cg, true, true); renderPanel(p, r, cg, true, true);
p->save(); p->save();
// Draw the box on the right. // Draw the box on the right.
if (cb->listBox() && cb->listBox()->isVisible()) { if (ceData.comboBoxListBoxFlags & CEF_IsVisible) {
p->setPen(cg.highlight()); p->setPen(cg.highlight());
p->setBrush(cg.highlight().light()); p->setBrush(cg.highlight().light());
} else if (flags & Style_HasFocus) { } else if (flags & Style_HasFocus) {
@ -1528,12 +1523,12 @@ void dotNETstyle::drawComplexControl(ComplexControl control,
if (TQApplication::reverseLayout()) { rr = visualRect( rr, r ); } if (TQApplication::reverseLayout()) { rr = visualRect( rr, r ); }
if (flags & Style_HasFocus || cg.highlight() == cg.midlight() || if (flags & Style_HasFocus || cg.highlight() == cg.midlight() ||
(cb->listBox() && cb->listBox()->isVisible())) { (ceData.comboBoxListBoxFlags & CEF_IsVisible)) {
p->drawRect(rr); p->drawRect(rr);
} }
if (pseudo3D && !((active & Style_Sunken) || if (pseudo3D && !((active & Style_Sunken) ||
(cb->listBox() && cb->listBox()->isVisible()))) { (ceData.comboBoxListBoxFlags & CEF_IsVisible))) {
p->save(); p->save();
p->setBrush(NoBrush); p->setBrush(NoBrush);
TQColor test = ((flags & Style_HasFocus) ? cg.highlight() : cg.midlight()); TQColor test = ((flags & Style_HasFocus) ? cg.highlight() : cg.midlight());
@ -1564,7 +1559,7 @@ void dotNETstyle::drawComplexControl(ComplexControl control,
p->drawPoint(hr.bottomLeft()); p->drawPoint(hr.bottomLeft());
} }
if ((active && cb->hasFocus()) || (cb->listBox() && cb->listBox()->isVisible())) { if ((active && (elementFlags & CEF_HasFocus)) || (ceData.comboBoxListBoxFlags & CEF_IsVisible)) {
p->setPen(cg.highlightedText()); p->setPen(cg.highlightedText());
} else { } else {
p->setPen(cg.text()); p->setPen(cg.text());
@ -1737,7 +1732,7 @@ TQRect dotNETstyle::subRect(SubRect r, const TQStyleControlElementData ceData, c
} }
case SR_PushButtonFocusRect: { case SR_PushButtonFocusRect: {
TQRect rect = widget->rect(); TQRect rect = ceData.rect;
int margin = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget) + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) + 2; int margin = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget) + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) + 2;
rect.addCoords(margin, margin, -margin, -margin); rect.addCoords(margin, margin, -margin, -margin);
@ -1762,11 +1757,7 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control,
const TQStyleOption &opt, const TQStyleOption &opt,
const TQWidget *widget) const const TQWidget *widget) const
{ {
if (!widget) { TQRect r(ceData.rect);
return TQRect();
}
TQRect r(widget->rect());
switch (control) { switch (control) {
case CC_ComboBox: { case CC_ComboBox: {
switch (subcontrol) { switch (subcontrol) {
@ -1783,12 +1774,12 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control,
case CC_SpinWidget: { case CC_SpinWidget: {
int fw = pixelMetric(PM_SpinBoxFrameWidth, ceData, elementFlags, widget); int fw = pixelMetric(PM_SpinBoxFrameWidth, ceData, elementFlags, widget);
TQSize bs; TQSize bs;
bs.setHeight(TQMAX(8, widget->height()/2)); bs.setHeight(TQMAX(8, ceData.rect.height()/2));
bs.setWidth(TQMIN(bs.height() * 8 / 5, widget->width() / 4)); bs.setWidth(TQMIN(bs.height() * 8 / 5, ceData.rect.width() / 4));
int y = fw; int y = fw;
int x, lx; int x, lx;
x = widget->width() - y - bs.width(); x = ceData.rect.width() - y - bs.width();
lx = fw; lx = fw;
switch (subcontrol) { switch (subcontrol) {
@ -1799,13 +1790,13 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control,
return TQRect(x, y + bs.height()-1, bs.width(), bs.height()); return TQRect(x, y + bs.height()-1, bs.width(), bs.height());
} }
case SC_SpinWidgetFrame: { case SC_SpinWidgetFrame: {
return TQRect(0, 0, widget->width() - (bs.width() + 2), widget->height()); return TQRect(0, 0, ceData.rect.width() - (bs.width() + 2), ceData.rect.height());
} }
case SC_SpinWidgetEditField: { case SC_SpinWidgetEditField: {
return TQRect(lx, fw, widget->width() - (bs.width() + 4), widget->height() - 2 * fw); return TQRect(lx, fw, ceData.rect.width() - (bs.width() + 4), ceData.rect.height() - 2 * fw);
} }
case SC_SpinWidgetButtonField: { case SC_SpinWidgetButtonField: {
return TQRect(x, y, bs.width(), widget->height() - 2 * fw); return TQRect(x, y, bs.width(), ceData.rect.height() - 2 * fw);
} }
default: { default: {
} }
@ -1885,11 +1876,10 @@ int dotNETstyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, Co
if (!pseudo3D) { if (!pseudo3D) {
return 1; return 1;
} else { } else {
if (widget && if (ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING) ||
(widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains(TQMENUBAR_OBJECT_NAME_STRING) ||
widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains(TQRANGECONTROL_OBJECT_NAME_STRING) ||
widget->inherits(TQRANGECONTROL_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains(TQSCROLLVIEW_OBJECT_NAME_STRING)) {
widget->inherits(TQSCROLLVIEW_OBJECT_NAME_STRING))) {
return 1; return 1;
} else { } else {
return 2; return 2;
@ -1953,7 +1943,7 @@ TQSize dotNETstyle::sizeFromContents(ContentsType t,
h = TQMAX(h, mi->pixmap()->height() + 8); h = TQMAX(h, mi->pixmap()->height() + 8);
} }
h = TQMAX(h, widget->fontMetrics().height() + 10); h = TQMAX(h, TQFontMetrics(ceData.font).height() + 10);
if (mi->iconSet()) { if (mi->iconSet()) {
h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 8); h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height() + 8);
@ -2128,7 +2118,7 @@ int dotNETstyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Contr
} }
break; break;
default: default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break; break;
} }

@ -638,8 +638,8 @@ void PhaseStyle::drawPrimitive(TQ_PrimitiveElement element,
horiz = true; horiz = true;
} }
if ((widget) && ((widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING)) || if ((ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) ||
(widget->inherits("KPopupTitle")))) { (ceData.widgetObjectTypes.contains("KPopupTitle"))) {
// kicker/kdesktop menu titles // kicker/kdesktop menu titles
drawPhaseBevel(painter, x,y,w,h, drawPhaseBevel(painter, x,y,w,h,
group, group.background(), depress, !horiz); group, group.background(), depress, !horiz);
@ -894,12 +894,11 @@ void PhaseStyle::drawPrimitive(TQ_PrimitiveElement element,
widget = dynamic_cast<TQWidget*>(painter->device()); widget = dynamic_cast<TQWidget*>(painter->device());
bool flat = true; bool flat = true;
if (widget && widget->parent() && if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) {
widget->parent()->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) {
TQToolBar *toolbar = ::tqqt_cast<TQToolBar*>(widget->parent()); TQToolBar *toolbar = ::tqqt_cast<TQToolBar*>(widget->parent());
if (toolbar) { if (toolbar) {
// toolbar not floating or in a TQMainWindow // toolbar not floating or in a TQMainWindow
flat = flatToolbar(toolbar); flat = flatToolbar(ceData, elementFlags, toolbar);
} }
} }
@ -1113,15 +1112,12 @@ void PhaseStyle::drawKStylePrimitive(KStylePrimitive element,
break; break;
case KPE_SliderGroove: { case KPE_SliderGroove: {
const TQSlider* slider = ::tqqt_cast<const TQSlider*>(widget); if (ceData.orientation == TQt::Horizontal) {
if (slider) { y = cy - 3;
if (slider->orientation() ==Qt::Horizontal) { h = 7;
y = cy - 3; } else {
h = 7; x = cx - 3;
} else { w = 7;
x = cx - 3;
w = 7;
}
} }
drawPhasePanel(painter, x, y, w, h, group, true, drawPhasePanel(painter, x, y, w, h, group, true,
&group.brush(TQColorGroup::Mid)); &group.brush(TQColorGroup::Mid));
@ -1129,22 +1125,19 @@ void PhaseStyle::drawKStylePrimitive(KStylePrimitive element,
} }
case KPE_SliderHandle: { case KPE_SliderHandle: {
const TQSlider* slider = ::tqqt_cast<const TQSlider*>(widget); TQColor color = (flags & Style_MouseOver)
if (slider) { ? TQColor(group.button().light(contrast))
TQColor color = (flags & Style_MouseOver) : group.button();
? TQColor(group.button().light(contrast)) if (ceData.orientation == TQt::Horizontal) {
: group.button(); drawPhaseBevel(painter, cx-5, y, 6, h, group, color,
if (slider->orientation() ==Qt::Horizontal) { false, false, false);
drawPhaseBevel(painter, cx-5, y, 6, h, group, color, drawPhaseBevel(painter, cx, y, 6, h, group, color,
false, false, false); false, false, false);
drawPhaseBevel(painter, cx, y, 6, h, group, color, } else {
false, false, false); drawPhaseBevel(painter, x, cy-5, w, 6, group, color,
} else { false, true, false);
drawPhaseBevel(painter, x, cy-5, w, 6, group, color, drawPhaseBevel(painter, x, cy, w, 6, group, color,
false, true, false); false, true, false);
drawPhaseBevel(painter, x, cy, w, 6, group, color,
false, true, false);
}
} }
break; break;
} }
@ -1308,7 +1301,7 @@ void PhaseStyle::drawControl(TQ_ControlElement element,
const TQToolBar *tb = ::tqqt_cast<const TQToolBar*>(widget); const TQToolBar *tb = ::tqqt_cast<const TQToolBar*>(widget);
if (tb) { if (tb) {
// toolbar not floating or in a TQMainWindow // toolbar not floating or in a TQMainWindow
if (flatToolbar(tb)) { if (flatToolbar(ceData, elementFlags, tb)) {
if (tb->backgroundMode() == PaletteButton) if (tb->backgroundMode() == PaletteButton)
// force default button color to background color // force default button color to background color
painter->fillRect(rect, group.background()); painter->fillRect(rect, group.background());
@ -1381,9 +1374,8 @@ void PhaseStyle::drawControl(TQ_ControlElement element,
// draw background // draw background
if (active && enabled) { if (active && enabled) {
painter->fillRect(x, y, w, h, group.highlight()); painter->fillRect(x, y, w, h, group.highlight());
} else if (widget->erasePixmap() && } else if (!ceData.bgPixmap.isNull()) {
!widget->erasePixmap()->isNull()) { painter->drawPixmap(x, y, ceData.bgPixmap, x, y, w, h);
painter->drawPixmap(x, y, *widget->erasePixmap(), x, y, w, h);
} else { } else {
painter->fillRect(x, y, w, h, group.background()); painter->fillRect(x, y, w, h, group.background());
} }
@ -1879,7 +1871,7 @@ void PhaseStyle::drawComplexControl(TQ_ComplexControl control,
if (toolbar) { if (toolbar) {
horiz = (toolbar->orientation() == Qt::Horizontal); horiz = (toolbar->orientation() == Qt::Horizontal);
if (normal) { // draw background if (normal) { // draw background
if (flatToolbar(toolbar)) { if (flatToolbar(ceData, elementFlags, toolbar)) {
// toolbar not floating or in a TQMainWindow // toolbar not floating or in a TQMainWindow
painter->fillRect(rect, group.background()); painter->fillRect(rect, group.background());
} else { } else {
@ -2071,7 +2063,7 @@ TQRect PhaseStyle::querySubControlMetrics(TQ_ComplexControl control,
TQRect rect; TQRect rect;
const int fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget); const int fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget);
int w = widget->width(), h = widget->height(); int w = ceData.rect.width(), h = ceData.rect.height();
int xc; int xc;
switch (control) { switch (control) {
@ -2081,7 +2073,7 @@ TQRect PhaseStyle::querySubControlMetrics(TQ_ComplexControl control,
switch (subcontrol) { switch (subcontrol) {
case SC_ComboBoxFrame: // total combobox area case SC_ComboBoxFrame: // total combobox area
rect = widget->rect(); rect = ceData.rect;
break; break;
case SC_ComboBoxArrow: // the right side case SC_ComboBoxArrow: // the right side
@ -2103,10 +2095,7 @@ TQRect PhaseStyle::querySubControlMetrics(TQ_ComplexControl control,
} }
case CC_ScrollBar: { case CC_ScrollBar: {
const TQScrollBar *sb = ::tqqt_cast<const TQScrollBar*>(widget); bool horizontal = (ceData.orientation == TQt::Horizontal);
if (!sb) break;
bool horizontal = (sb->orientation() == Qt::Horizontal);
rect = KStyle::querySubControlMetrics(control, ceData, elementFlags, rect = KStyle::querySubControlMetrics(control, ceData, elementFlags,
subcontrol, option, widget); subcontrol, option, widget);
@ -2119,7 +2108,7 @@ TQRect PhaseStyle::querySubControlMetrics(TQ_ComplexControl control,
} }
case CC_SpinWidget: { case CC_SpinWidget: {
bool odd = widget->height() % 2; bool odd = ceData.rect.height() % 2;
xc = (h * 3 / 4) + odd; // position between edit and arrows xc = (h * 3 / 4) + odd; // position between edit and arrows
switch (subcontrol) { switch (subcontrol) {
@ -2132,7 +2121,7 @@ TQRect PhaseStyle::querySubControlMetrics(TQ_ComplexControl control,
break; break;
case SC_SpinWidgetFrame: case SC_SpinWidgetFrame:
rect = widget->rect(); rect = ceData.rect;
break; break;
case SC_SpinWidgetUp: case SC_SpinWidgetUp:
@ -2254,7 +2243,7 @@ TQSize PhaseStyle::sizeFromContents(ContentsType contents,
// ------------- // -------------
// Is the toolbar "flat" // Is the toolbar "flat"
bool PhaseStyle::flatToolbar(const TQToolBar *toolbar) const bool PhaseStyle::flatToolbar(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQToolBar *toolbar) const
{ {
if (!toolbar) return true; // not on a toolbar if (!toolbar) return true; // not on a toolbar
if (!toolbar->isMovingEnabled()) return true; // immobile toolbars are flat if (!toolbar->isMovingEnabled()) return true; // immobile toolbars are flat
@ -2280,7 +2269,7 @@ int PhaseStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Contro
} }
break; break;
default: default:
ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
break; break;
} }
@ -2316,7 +2305,7 @@ bool PhaseStyle::objectEventHandler( TQStyleControlElementData ceData, ControlEl
if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) { if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) {
if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false; if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
TQWidget *parent = ::tqqt_cast<TQWidget*>(object->parent()); TQWidget *parent = ::tqqt_cast<TQWidget*>(object->parent());
int px = widget->x(), py = widget->y(); int px = ceData.rect.x(), py = ceData.rect.y();
// find the toolbar // find the toolbar
while (parent && parent->parent() while (parent && parent->parent()
&& !::tqqt_cast<TQToolBar*>(parent)) { && !::tqqt_cast<TQToolBar*>(parent)) {
@ -2325,18 +2314,18 @@ bool PhaseStyle::objectEventHandler( TQStyleControlElementData ceData, ControlEl
parent = ::tqqt_cast<TQWidget*>(parent->parent()); parent = ::tqqt_cast<TQWidget*>(parent->parent());
} }
if (!parent) return false; if (!parent) return false;
TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h); TQT_TQRECT_OBJECT(ceData.rect).rect(&x, &y, &w, &h);
TQRect prect = parent->rect(); TQRect prect = parent->rect();
toolbar = ::tqqt_cast<TQToolBar*>(parent); toolbar = ::tqqt_cast<TQToolBar*>(parent);
horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal) horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal)
: (prect.height() < prect.width()); : (prect.height() < prect.width());
TQPainter painter(widget); TQPainter painter(widget);
if (flatToolbar(toolbar)) { if (flatToolbar(ceData, elementFlags, toolbar)) {
painter.fillRect(widget->rect(), painter.fillRect(ceData.rect,
parent->colorGroup().background()); parent->colorGroup().background());
} else { } else {
drawPhaseGradient(&painter, widget->rect(), drawPhaseGradient(&painter, ceData.rect,
parent->colorGroup().background(), parent->colorGroup().background(),
!horiz, px, py, !horiz, px, py,
prect.width(), prect.height(), true); prect.width(), prect.height(), true);
@ -2356,9 +2345,9 @@ bool PhaseStyle::objectEventHandler( TQStyleControlElementData ceData, ControlEl
if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false; if (0 == (widget = ::tqqt_cast<TQWidget*>(object))) return false;
horiz = (toolbar->orientation() == Qt::Horizontal); horiz = (toolbar->orientation() == Qt::Horizontal);
TQPainter painter(widget); TQPainter painter(widget);
TQT_TQRECT_OBJECT(widget->rect()).rect(&x, &y, &w, &h); TQT_TQRECT_OBJECT(ceData.rect).rect(&x, &y, &w, &h);
// draw the extension // draw the extension
drawPhaseGradient(&painter, widget->rect(), drawPhaseGradient(&painter, ceData.rect,
toolbar->colorGroup().background(), toolbar->colorGroup().background(),
!horiz, x, y, w-1, h-1, true); !horiz, x, y, w-1, h-1, true);
if (horiz) { if (horiz) {

@ -187,7 +187,7 @@ class PhaseStyle : public KStyle
int pw=-1, int ph=-1, int pw=-1, int ph=-1,
bool reverse=false) const; bool reverse=false) const;
bool flatToolbar(const TQToolBar *toolbar) const; bool flatToolbar(const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQToolBar *toolbar) const;
bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );

Loading…
Cancel
Save