Fix spinbox rendering

r14.0.x
Timothy Pearson 12 years ago
parent a3ae879d7b
commit 2624ef7e33

@ -713,7 +713,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_qt4painter->setClipping( (m_qt4OrigClipping)?true:p[0].ival );
break;
case PdcSetClipRegion:
m_qt4painter->setClipRegion( qt4region.intersected(m_qt4OrigClipRegion), Qt::ReplaceClip );
m_qt4painter->setClipRegion( (m_qt4OrigClipping)?qt4region.intersected(m_qt4OrigClipRegion):qt4region, Qt::ReplaceClip );
break;
default:
#if defined(QT_CHECK_RANGE)

@ -1561,7 +1561,7 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
const QComboBox* qt4combobox_widget = 0;
const QSlider* qt4slider_widget = 0;
const QScrollBar* qt4scrollbar_widget = 0;
const QSpinBox* qt4spinbox_widget = 0;
const QAbstractSpinBox* qt4spinbox_widget = 0;
const QMenuBar* qt4menubar_widget = 0;
const QToolBox* qt4toolbox_widget = 0;
const QToolButton* qt4toolbutton_widget = 0;
@ -1815,10 +1815,11 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
interfaceWidget = 0;
}
break;
#if 0
case TQT3WT_TQSpinBox:
interfaceWidget = m_tqt3spinbox_widget;
// Copy over all widget attributes
qt4spinbox_widget = dynamic_cast<const QSpinBox*>(w);
qt4spinbox_widget = dynamic_cast<const QAbstractSpinBox*>(w);
if (qt4spinbox_widget) {
m_tqt3spinbox_widget->setGeometry(0, 0, qt4spinbox_widget->width(), qt4spinbox_widget->height());
m_tqt3spinbox_widget->setEnabled(qt4spinbox_widget->isEnabled());
@ -1834,18 +1835,16 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
interfaceWidget = 0;
}
break;
#endif
case TQT3WT_TQSpinWidget:
interfaceWidget = m_tqt3spinwidget_widget;
// Copy over all widget attributes
qt4spinbox_widget = dynamic_cast<const QSpinBox*>(w);
qt4spinbox_widget = dynamic_cast<const QAbstractSpinBox*>(w);
if (qt4spinbox_widget) {
m_tqt3spinwidget_widget->setGeometry(0, 0, qt4spinbox_widget->width(), qt4spinbox_widget->height());
m_tqt3spinwidget_widget->setEnabled(qt4spinbox_widget->isEnabled());
// FIXME
// m_tqt3spinwidget_widget->setMinValue(qt4spinbox_widget->minimum());
// m_tqt3spinwidget_widget->setMaxValue(qt4spinbox_widget->maximum());
// m_tqt3spinwidget_widget->setLineStep(qt4spinbox_widget->singleStep());
// m_tqt3spinwidget_widget->setValue(qt4spinbox_widget->value());
m_tqt3spinwidget_widget->setUpEnabled(qt4spinbox_widget->stepEnabled() & QSpinBox::StepUpEnabled);
m_tqt3spinwidget_widget->setDownEnabled(qt4spinbox_widget->stepEnabled() & QSpinBox::StepDownEnabled);
}
else {
if (enable_debug_warnings) {
@ -1971,6 +1970,92 @@ QRect Qt4TDEStyle::subElementRect(SubElement element, const QStyleOption *opt, c
return retRect;
}
QRect Qt4TDEStyle::subControlRect(ComplexControl control, const QStyleOptionComplex* opt, SubControl subControl, const QWidget* w) const
{
TQStyle::SFlags sflags = 0;
bool can_override = true;
TQStyle::ComplexControl tqtCC;
TQStyle::SubControl tqtSC;
TQWidget* interfaceWidget = 0;
TQStyleOption tqt3opt(TQStyleOption::Default);
QRect retRect;
switch (control) {
case CC_SpinBox: {
tqtCC = TQStyle::CC_SpinWidget;
switch (subControl) {
case SC_SpinBoxUp:
tqtSC = TQStyle::SC_SpinWidgetUp;
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w, opt);
if (interfaceWidget == 0) {
can_override = false;
}
break;
case SC_SpinBoxDown:
tqtSC = TQStyle::SC_SpinWidgetDown;
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w, opt);
if (interfaceWidget == 0) {
can_override = false;
}
break;
case SC_SpinBoxEditField:
tqtSC = TQStyle::SC_SpinWidgetEditField;
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w, opt);
if (interfaceWidget == 0) {
can_override = false;
}
break;
case SC_SpinBoxFrame:
tqtSC = TQStyle::SC_SpinWidgetFrame;
interfaceWidget = initializeInterfaceWidget(TQT3WT_TQSpinWidget, w, opt);
if (interfaceWidget == 0) {
can_override = false;
}
break;
default:
if (enable_debug_warnings) {
printf("No rules to obtain Qt4 subcontrol rect %d for control %d\n\r", subControl, control); fflush(stdout);
}
can_override = false;
}
break;
}
default:
if (enable_debug_warnings) {
printf("No rules to obtain Qt4 subcontrol rect %d for control %d\n\r", subControl, control); fflush(stdout);
}
can_override = false;
}
if (can_override) {
// Instruct TQt3 to obtain the subelement rect information
retRect = convertTQt3ToQt4Rect(tqApp->style().querySubControlMetrics(tqtCC, interfaceWidget, tqtSC, tqt3opt));
if ((tqtCC == TQStyle::CC_SpinWidget) && (tqtSC == TQStyle::SC_SpinWidgetEditField)) {
// HACK
// For an unknown reason, Qt4 instantly resizes SpinBoxes to a very small height if TQt3 returns
// an editor height hint that is different (larger?) than the Qt4 editor height hint!
// Work around this problem here...
QRect qt4Rect = BASE_QT4_STYLE_CLASS::subControlRect(control, opt, subControl, w);
retRect.setHeight(qt4Rect.height());
}
if (enable_debug_warnings) {
#ifdef DEBUG_SPEW
printf("Used Qt3 subcontrol rect %d for control %d to handle Qt4 subcontrol rect %d for control %d\n\r", tqtSC, tqtCC, subControl, control); fflush(stdout);
#endif
}
}
else {
// Tell Qt4 to obtain the subelement rect information
retRect = BASE_QT4_STYLE_CLASS::subControlRect(control, opt, subControl, w);
}
return retRect;
}
void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const
{
TQStyle::SFlags sflags = 0;
@ -2048,12 +2133,26 @@ void Qt4TDEStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
if ((sbopt->subControls & QStyle::SC_SpinBoxUp) || (sbopt->subControls & QStyle::SC_SpinBoxDown)) {
subControl = subControl | TQStyle::SC_SpinWidgetButtonField;
}
if (sbopt->subControls & QStyle::SC_SpinBoxUp) {
subControl = subControl | TQStyle::SC_SpinWidgetUp;
}
if (sbopt->subControls & QStyle::SC_SpinBoxDown) {
subControl = subControl | TQStyle::SC_SpinWidgetDown;
}
if (sbopt->subControls & QStyle::SC_SpinBoxEditField) {
subControl = subControl | TQStyle::SC_SpinWidgetFrame;
subControl = subControl | TQStyle::SC_SpinWidgetEditField;
}
if (sbopt->subControls & QStyle::SC_SpinBoxFrame) {
subControl = subControl | TQStyle::SC_SpinWidgetFrame;
}
subControlActive = 0;
if (sbopt->activeSubControls & QStyle::SC_SpinBoxUp) {
subControlActive = subControlActive | TQStyle::SC_SpinWidgetUp;
}
if (sbopt->activeSubControls & QStyle::SC_SpinBoxDown) {
subControlActive = subControlActive | TQStyle::SC_SpinWidgetDown;
}
break;
case CC_TitleBar:
tqtCC = TQStyle::CC_TitleBar;

@ -67,6 +67,7 @@ public:
void drawControl(ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0) const;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget = 0) const;
QRect subElementRect(SubElement element, const QStyleOption * option, const QWidget * widget = 0) const;
QRect subControlRect(ComplexControl control, const QStyleOptionComplex * option, SubControl subControl, const QWidget * widget = 0) const;
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0) const;
int styleHint(StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0) const;

Loading…
Cancel
Save