From c373f2019c7c25c7fa279573ce196f3ed60c29ac Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 8 Aug 2007 05:45:12 +0000 Subject: [PATCH] Corrections for comboBox --- src/Style/Style_Model.cxx | 2 +- src/Style/Style_Salome.cxx | 56 ++++++++++++++++++++++++++++---------- src/Style/Style_Tools.cxx | 9 ++---- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/Style/Style_Model.cxx b/src/Style/Style_Model.cxx index 30195dc08..86764f5b2 100644 --- a/src/Style/Style_Model.cxx +++ b/src/Style/Style_Model.cxx @@ -79,7 +79,7 @@ Style_Model::Style_Model() fillValue( lines_clr, "lines-color", "Color", grp_lines, Color ); // grp_font group - fillValue( font_value, "app-font", "Application font", grp_font, Font ); + fillValue( font_value, "app-font", "App Font", grp_font, Font ); // grp_values group fillValue( all_antialized, "all-antialized", "All borders antialized", grp_value, Bool ); fillValue( auto_raising_wdg, "is-raising-widget", "Auto raising widget", grp_value, Bool ); diff --git a/src/Style/Style_Salome.cxx b/src/Style/Style_Salome.cxx index 1b050fd19..1179dd069 100644 --- a/src/Style/Style_Salome.cxx +++ b/src/Style/Style_Salome.cxx @@ -228,8 +228,7 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp case CC_SpinBox: if (const QStyleOptionSpinBox *spin = qstyleoption_cast(opt)) { bool hover = hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver); - QRect optr = opt->rect, arUp = subControlRect( cc, spin, SC_SpinBoxUp, w ), - arDown = subControlRect( cc, spin, SC_SpinBoxDown, w ); + QRect optr = opt->rect, arUp = subControlRect( cc, spin, SC_SpinBoxUp, w ); optr.setWidth( arUp.x()-optr.x()+1 ); double aRad = getDblValue( Style_Model::edit_rad ); bool antialized = getBoolValue( Style_Model::all_antialized ); @@ -1166,6 +1165,35 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, aBrdBotCol, getBoolValue( Style_Model::all_antialized ), true, aStateOn ); break; } + case CE_ComboBoxLabel: + if (const QStyleOptionComboBox *cb = qstyleoption_cast(opt)) { + QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, w); + p->save(); + p->setClipRect(editRect); + if (!cb->currentIcon.isNull()) { + QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal + : QIcon::Disabled; + QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QRect iconRect(editRect); + iconRect.setWidth(cb->iconSize.width() + 4); + iconRect = alignedRect(QApplication::layoutDirection(), + Qt::AlignLeft | Qt::AlignVCenter, + iconRect.size(), editRect); + // Here's absent filling of pixmap on basic color for editable comboBox + drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); + + if (cb->direction == Qt::RightToLeft) + editRect.translate(-4 - cb->iconSize.width(), 0); + else + editRect.translate(cb->iconSize.width() + 4, 0); + } + if (!cb->currentText.isEmpty() && !cb->editable) { + drawItemText(p, editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, cb->palette, + cb->state & State_Enabled, cb->currentText); + } + p->restore(); + } + break; case CE_ScrollBarSubLine: case CE_ScrollBarAddLine: { bool aStateOn = opt->state & ( State_Sunken | State_On ); @@ -1800,13 +1828,14 @@ QRect Style_Salome::subControlRect( ComplexControl cc, const QStyleOptionComplex case CC_SpinBox: { int x = res.x(), w = res.width(), h = res.height(); if ( sc==SC_SpinBoxUp || sc==SC_SpinBoxDown ) { - res.setX( x-2*h+w ); - res.setWidth( 2*h ); + QRect frame_r = QWindowsStyle::subControlRect( cc, opt, SC_SpinBoxFrame, wid ); + h = frame_r.height(); + res.setX( x+w-h ); + res.setWidth( h ); } else if ( sc==QStyle::SC_SpinBoxEditField ) { - QRect old_r = QWindowsStyle::subControlRect( cc, opt, SC_SpinBoxUp, wid ); - res.setWidth( w-h+old_r.width()-2 ); - res.setTopLeft( QPoint( res.x()+aHalfRect-1, res.y() - SHADOW ) ); + res.setWidth( w-h ); + res.setTopLeft( QPoint( res.x()+aHalfRect, res.y()-SHADOW ) ); } break; } @@ -1815,12 +1844,11 @@ QRect Style_Salome::subControlRect( ComplexControl cc, const QStyleOptionComplex res = cb->rect; int x = res.x(), w = res.width(), h = res.height(); if ( sc==SC_ComboBoxArrow ) { - res.setX( x-h+w ); + res.setX( x+w-h ); res.setWidth( h ); } else if ( sc==QStyle::SC_ComboBoxEditField ) { - QRect old_r = QWindowsStyle::subControlRect( cc, opt, SC_ComboBoxArrow, wid ); - res.setWidth( w - h+old_r.width()-2 ); + res.setWidth( w-h ); res.setTopLeft( QPoint( res.x()+aHalfRect, res.y()-SHADOW ) ); } } @@ -1894,10 +1922,10 @@ QRect Style_Salome::subElementRect( SubElement se, const QStyleOption* opt, case SE_ProgressBarGroove: return opt->rect; } - if( hasHover() ) { - if( qobject_cast(wid) || - qobject_cast(wid) ) - res = res.adjusted(0, 0, 2, 0); + if( qobject_cast(wid) || + qobject_cast(wid) ) { + if( hasHover() ) + res = res.adjusted(0, 0, 2, 0); } return res; } diff --git a/src/Style/Style_Tools.cxx b/src/Style/Style_Tools.cxx index 43d455010..08e0abe56 100644 --- a/src/Style/Style_Tools.cxx +++ b/src/Style/Style_Tools.cxx @@ -260,7 +260,8 @@ void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const Q QPainterPath arrow1; int x = r.x(), y = r.y(), w = r.right()-x, h = r.bottom()-y; int x11 = 0, x12 = 0, y11 = 0, y12 = 0; - int deltaX = (int)(w/4.), deltaY = (int)(h/4.); + int aDelta = qMin( (int)(w/3.5), (int)(h/3.5) ); + int deltaX = aDelta, deltaY = aDelta; QLineF line( 0, 0, 1, 0 ); int xc = r.center().x(), yc = r.center().y(); p->translate( xc, yc ); @@ -269,7 +270,6 @@ void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const Q case QStyle::PE_IndicatorArrowDown: correct = true; case QStyle::PE_IndicatorArrowUp: { - deltaX = (int)(w/3.5), deltaY = (int)(w/3.5); int widthArr2 = (int)(deltaX/3.); if ( correct ) deltaY = -deltaY; // change arrow direction @@ -290,7 +290,6 @@ void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const Q case QStyle::PE_IndicatorArrowLeft: // to change correct = true; case QStyle::PE_IndicatorArrowRight: { - deltaX = (int)(w/3.5), deltaY = (int)(w/3.5); int widthArr2 = (int)(deltaX/3.); if ( correct ) deltaX = -deltaX; // change arrow direction @@ -309,9 +308,7 @@ void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const Q case QStyle::PE_IndicatorSpinDown: correct = true; case QStyle::PE_IndicatorSpinUp: { - deltaY = (int)(w/3.5); - deltaX = (int)(w/3.5); - int aDelta = (int)(deltaY/2); + aDelta = (int)(deltaY/2); if ( correct ) { aDelta = (int)(-aDelta/2); deltaY = -deltaY; -- 2.39.2