diff options
author | Timothy Pearson <[email protected]> | 2012-11-03 21:42:44 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-11-03 21:42:44 -0500 |
commit | 06d51bc1ec0abbb14c3770e7d86d6777dd66e917 (patch) | |
tree | 197019d1f3506a3ec0ea0473a5871c369cc0cb76 /styles/dotnet | |
parent | f16f8eb6bf27ae9dcebbcac7db0a5dbe673a27c5 (diff) | |
download | tdeartwork-06d51bc1ec0abbb14c3770e7d86d6777dd66e917.tar.gz tdeartwork-06d51bc1ec0abbb14c3770e7d86d6777dd66e917.zip |
Fix style crashes when used with third party toolkits
Diffstat (limited to 'styles/dotnet')
-rw-r--r-- | styles/dotnet/dotnet.cpp | 98 |
1 files changed, 44 insertions, 54 deletions
diff --git a/styles/dotnet/dotnet.cpp b/styles/dotnet/dotnet.cpp index e73d40d8..107f182b 100644 --- a/styles/dotnet/dotnet.cpp +++ b/styles/dotnet/dotnet.cpp @@ -114,17 +114,17 @@ void dotNETstyle::polish(TQStyleControlElementData ceData, ControlElementFlags e if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { 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; - if (widget->isTopLevel()) + if (elementFlags & CEF_IsTopLevel) return; // we can't simply set a palette -- upon color-theme changes, we have // to update the palette again. // 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); updatePalette( (TQComboBox*) widget ); // extraPalette = true; @@ -137,10 +137,10 @@ void dotNETstyle::polish(TQStyleControlElementData ceData, ControlElementFlags e // other bad things (see bug #54569) /* if (!widget->ownPalette()) { - if (widget->inherits(TQTOOLBAR_OBJECT_NAME_STRING)) { + if (ceData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) { updatePalette( (TQToolBar*) widget ); extraPalette = true; - } else if (widget->inherits(TQMENUBAR_OBJECT_NAME_STRING)) { + } else if (ceData.widgetObjectTypes.contains(TQMENUBAR_OBJECT_NAME_STRING)) { updatePalette( (TQMenuBar*) widget ); extraPalette = true; } @@ -156,7 +156,7 @@ void dotNETstyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { 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); } } @@ -390,10 +390,9 @@ void dotNETstyle::drawKStylePrimitive(KStylePrimitive kpe, // ------ switch( kpe ) { case KPE_SliderGroove: { - const TQSlider* slider = (const TQSlider*)widget; int 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; if (horizontal) { @@ -828,11 +827,9 @@ void dotNETstyle::drawControl(TQ_ControlElement element, } case CE_ProgressBarContents: { - const TQProgressBar *pb = (const TQProgressBar *)widget; - - if (pb->totalSteps()) { + if (ceData.totalSteps) { 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); @@ -849,7 +846,7 @@ void dotNETstyle::drawControl(TQ_ControlElement element, p->fillRect(x, y, w, h, cg.highlight()); - if (pb->progress() < pb->totalSteps()) { + if (ceData.currentStep < ceData.totalSteps) { p->setPen(cg.background().dark(115)); if (TQApplication::reverseLayout()) { p->drawLine(x - 1, y, x - 1, h); @@ -1107,7 +1104,6 @@ void dotNETstyle::drawControl(TQ_ControlElement element, } case CE_PushButtonLabel: { - const TQPushButton *pb = (const TQPushButton *)widget; const bool enabled = flags & Style_Enabled; const int text_flags = AlignVCenter | AlignHCenter | ShowPrefix | DontClip | SingleLine; @@ -1118,19 +1114,19 @@ void dotNETstyle::drawControl(TQ_ControlElement element, 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)); } - if (pb->iconSet() && !pb->iconSet()->isNull()) { + if (!ceData.iconSet.isNull()) { 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; 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; 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 { - 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, pixmap); 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()) { - TQRect pr(0, 0, pb->pixmap()->width(), pb->pixmap()->height()); + if ((!ceData.fgPixmap.isNull()) && !ceData.text) { + TQRect pr(0, 0, ceData.fgPixmap.width(), ceData.fgPixmap.height()); 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->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()) { - p->setPen(enabled ? cg.foreground() : pb->palette().disabled().buttonText()); - p->drawText(ur, text_flags, pb->text()); + if (!ceData.text.isEmpty()) { + p->setPen(enabled ? cg.foreground() : ceData.palette.disabled().buttonText()); + p->drawText(ur, text_flags, ceData.text); } if ( flags & Style_HasFocus ) @@ -1484,7 +1480,6 @@ void dotNETstyle::drawComplexControl(ComplexControl control, // -------- case CC_ComboBox: { int x, y, w, h; - const TQComboBox *cb = (const TQComboBox *)widget; r.rect(&x, &y, &w, &h); if (active & Style_Sunken) @@ -1501,13 +1496,13 @@ void dotNETstyle::drawComplexControl(ComplexControl control, TQBitmap downArrow = TQBitmap(7, 4, downarrow_bits, true); 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); p->save(); // Draw the box on the right. - if (cb->listBox() && cb->listBox()->isVisible()) { + if (ceData.comboBoxListBoxFlags & CEF_IsVisible) { p->setPen(cg.highlight()); p->setBrush(cg.highlight().light()); } else if (flags & Style_HasFocus) { @@ -1528,12 +1523,12 @@ void dotNETstyle::drawComplexControl(ComplexControl control, if (TQApplication::reverseLayout()) { rr = visualRect( rr, r ); } if (flags & Style_HasFocus || cg.highlight() == cg.midlight() || - (cb->listBox() && cb->listBox()->isVisible())) { + (ceData.comboBoxListBoxFlags & CEF_IsVisible)) { p->drawRect(rr); } if (pseudo3D && !((active & Style_Sunken) || - (cb->listBox() && cb->listBox()->isVisible()))) { + (ceData.comboBoxListBoxFlags & CEF_IsVisible))) { p->save(); p->setBrush(NoBrush); TQColor test = ((flags & Style_HasFocus) ? cg.highlight() : cg.midlight()); @@ -1564,7 +1559,7 @@ void dotNETstyle::drawComplexControl(ComplexControl control, 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()); } else { p->setPen(cg.text()); @@ -1737,7 +1732,7 @@ TQRect dotNETstyle::subRect(SubRect r, const TQStyleControlElementData ceData, c } 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; rect.addCoords(margin, margin, -margin, -margin); @@ -1762,11 +1757,7 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control, const TQStyleOption &opt, const TQWidget *widget) const { - if (!widget) { - return TQRect(); - } - - TQRect r(widget->rect()); + TQRect r(ceData.rect); switch (control) { case CC_ComboBox: { switch (subcontrol) { @@ -1783,12 +1774,12 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control, case CC_SpinWidget: { int fw = pixelMetric(PM_SpinBoxFrameWidth, ceData, elementFlags, widget); TQSize bs; - bs.setHeight(TQMAX(8, widget->height()/2)); - bs.setWidth(TQMIN(bs.height() * 8 / 5, widget->width() / 4)); + bs.setHeight(TQMAX(8, ceData.rect.height()/2)); + bs.setWidth(TQMIN(bs.height() * 8 / 5, ceData.rect.width() / 4)); int y = fw; int x, lx; - x = widget->width() - y - bs.width(); + x = ceData.rect.width() - y - bs.width(); lx = fw; switch (subcontrol) { @@ -1799,13 +1790,13 @@ TQRect dotNETstyle::querySubControlMetrics(ComplexControl control, return TQRect(x, y + bs.height()-1, bs.width(), bs.height()); } 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: { - 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: { - return TQRect(x, y, bs.width(), widget->height() - 2 * fw); + return TQRect(x, y, bs.width(), ceData.rect.height() - 2 * fw); } default: { } @@ -1885,11 +1876,10 @@ int dotNETstyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, Co if (!pseudo3D) { return 1; } else { - if (widget && - (widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING) || - widget->inherits(TQMENUBAR_OBJECT_NAME_STRING) || - widget->inherits(TQRANGECONTROL_OBJECT_NAME_STRING) || - widget->inherits(TQSCROLLVIEW_OBJECT_NAME_STRING))) { + if (ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING) || + ceData.widgetObjectTypes.contains(TQMENUBAR_OBJECT_NAME_STRING) || + ceData.widgetObjectTypes.contains(TQRANGECONTROL_OBJECT_NAME_STRING) || + ceData.widgetObjectTypes.contains(TQSCROLLVIEW_OBJECT_NAME_STRING)) { return 1; } else { return 2; @@ -1953,7 +1943,7 @@ TQSize dotNETstyle::sizeFromContents(ContentsType t, 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()) { 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; default: - ret = TQCommonStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + ret = KStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); break; } |