]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for bug IPAL19450 : QT4 porting: corrupted spinbox in preferences - set color.
authormkr <mkr@opencascade.com>
Fri, 4 Apr 2008 13:49:01 +0000 (13:49 +0000)
committermkr <mkr@opencascade.com>
Fri, 4 Apr 2008 13:49:01 +0000 (13:49 +0000)
src/Style/Style_Salome.cxx
src/Style/Style_Tools.cxx
src/Style/Style_Tools.h

index fa27e9af06a57e57ed8dca66483a1e7c0580b1f5..58b302c2a5bc2ca6a104b12ed3a65813d1306412 100644 (file)
@@ -278,7 +278,7 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp
           pe = (spin->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
                : PE_IndicatorSpinUp);
           copy.rect = aBtnRect;
-          drawPrimitive(PE_IndicatorSpinUp, &copy, p, w);
+          drawPrimitive(pe, &copy, p, w);
         }
         if (spin->subControls & SC_SpinBoxDown) {
           copy.subControls = SC_SpinBoxDown;
@@ -1362,7 +1362,9 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
     case PE_IndicatorArrowUp:
     case PE_IndicatorArrowDown:
     case PE_IndicatorSpinUp:
-    case PE_IndicatorSpinDown: {
+    case PE_IndicatorSpinDown:
+    case PE_IndicatorSpinPlus:
+    case PE_IndicatorSpinMinus: {
       QRect rect = opt->rect;
       QColor pen, brush;
       if ( opt->state & State_Enabled ) {
@@ -1374,7 +1376,10 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
         pen = opt->palette.mid().color();
        brush = pen;
       }
-      Style_Tools::drawArrow( pe, p, rect, pen, brush );
+      if ( pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinMinus )
+       Style_Tools::drawSign( pe, p, rect, pen, brush );
+      else
+       Style_Tools::drawArrow( pe, p, rect, pen, brush );
       break;
     }
     case PE_IndicatorCheckBox: {
index 08e0abe5633124188b3761bb9d0fa918d55824da..390fa1332d05e11ca9c4ed8672e490f2fe871f4e 100644 (file)
@@ -338,6 +338,77 @@ void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const Q
   p->restore();
 }
 
+void Style_Tools::drawSign( QStyle::PrimitiveElement type, QPainter* p, const QRect& r,
+                           const QColor& pen, const QColor& brush )
+{
+  p->save();
+  QPainterPath sign;
+  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 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 );
+  bool correct = false;
+  switch( type ) {
+    case QStyle::PE_IndicatorSpinMinus:
+      correct = true;
+    case QStyle::PE_IndicatorSpinPlus: {
+      aDelta = (int)(deltaY/2);
+      if ( correct ) {
+        aDelta = -aDelta;
+        deltaY = -deltaY;
+      }
+      if ( correct ) 
+       sign.moveTo(  deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3) );
+      else {
+       sign.moveTo(  aDelta/3,   -aDelta/2 );
+       sign.lineTo(  aDelta/3,   -aDelta/2-(deltaY/2-aDelta/3) );
+       sign.lineTo(  deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3) );
+      }
+      
+      sign.lineTo(    deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3)-2*aDelta/3 );
+      
+      if ( !correct ) {
+       sign.lineTo(  aDelta/3,   -aDelta/2-(deltaY/2-aDelta/3)-2*aDelta/3 );
+       sign.lineTo(  aDelta/3,   -aDelta/2-deltaY );
+       sign.lineTo( -aDelta/3,   -aDelta/2-deltaY );
+       sign.lineTo( -aDelta/3,   -aDelta/2-(deltaY/2-aDelta/3)-2*aDelta/3 );
+      }
+      
+      sign.lineTo(   -deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3)-2*aDelta/3 );
+      sign.lineTo(   -deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3) );
+
+      if ( correct ) 
+       sign.lineTo(  deltaY/2,   -aDelta/2-(deltaY/2-aDelta/3) );
+      else {
+       sign.lineTo( -aDelta/3,   -aDelta/2-(deltaY/2-aDelta/3) );
+       sign.lineTo( -aDelta/3,   -aDelta/2 );
+       sign.lineTo(  aDelta/3,   -aDelta/2);
+      }
+
+      if ( correct )
+        deltaX = -deltaX;
+      x11 = -deltaX, y11 = -deltaY, x12 = deltaX, y12 = 0;
+      break;
+    }
+    default:
+      p->restore();
+      return;
+  }
+  p->setPen( pen );
+  p->setBrush( brush );
+
+  QLinearGradient gr( x11, y11, x12, y12 );
+  gr.setColorAt( 0.0, pen );                // grayer
+  gr.setColorAt( 1.0, brush);               // lighter
+  p->fillPath( sign, gr );
+  p->strokePath( sign, QPen( pen, Qt::SolidLine ) );
+
+  p->restore();
+}
+
 QPainterPath Style_Tools::tabRect( QPainter* p, const QRect& r, const int position, const double rad,
                                    const double delta, const QColor& light, const QColor& dark,
                                    const QColor& border_top, const QColor& border_bot,
index 381c5a3d278d0f8a509691cc72efa0848067d3cf..06ddc54b3bae50d8bce88f0aa2aac2cb5d85be34 100644 (file)
@@ -68,6 +68,8 @@ public:
                                 const QColor&, const int = 255 );
   static void         drawArrow( QStyle::PrimitiveElement, QPainter*, const QRect&,
                                  const QColor&, const QColor& );
+  static void         drawSign( QStyle::PrimitiveElement, QPainter*, const QRect&,
+                               const QColor&, const QColor& );
   static QPainterPath tabRect( QPainter*, const QRect&, const int, const double,
                                const double, const QColor&, const QColor&,
                                const QColor&, const QColor&,