]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Porting on Br_Qt4_Dev.
authornds <nds@opencascade.com>
Fri, 25 Apr 2008 13:05:27 +0000 (13:05 +0000)
committernds <nds@opencascade.com>
Fri, 25 Apr 2008 13:05:27 +0000 (13:05 +0000)
src/Style/Style_Salome.cxx
src/Style/Style_Salome.h
src/Style/Style_Tools.cxx
src/Style/Style_Tools.h

index e1ffb6b6b075f5aeb87ab2d4cb0bcfa60c5ed667..576e1778b45e6b27d2576d897808570e84685048 100644 (file)
@@ -163,6 +163,8 @@ static const char* const minimize_xpm[] = {
 Style_Salome::Style_Salome()
   : QWindowsStyle()
 {
+  //Q_INIT_RESOURCE(Style);
+
   myModel = new Style_Model();
   myModel->setDefaults( qApp );
 
@@ -278,7 +280,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;
@@ -1162,9 +1164,6 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt,
           }
         }
       break;
-    case CE_ToolBoxTab:
-      QCommonStyle::drawControl( ce, opt, p, w );
-      break;
     case CE_HeaderSection: {
       bool aStateOn = opt->state & State_On;
       QColor aColor = getColor( Style_Model::header_clr );
@@ -1298,13 +1297,12 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt,
     break;
   }
   default:
-    QWindowsStyle::drawControl( ce, opt, p, w );
-    break;
+      QWindowsStyle::drawControl( ce, opt, p, w );
   }
 }
 
 void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
-                                 QPainter* p, const QWidget* w ) const
+                                 QPainter* p, const QWidget* w ) const
 {
   const QPalette& pal = opt->palette;
   bool doRestore = false;
@@ -1368,7 +1366,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 ) {
@@ -1380,7 +1380,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: {
@@ -1390,7 +1393,7 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
       QBrush fill;
       if (opt->state & State_NoChange)
         fill = QBrush( opt->palette.color( QPalette::Base ), Qt::Dense4Pattern);
-      else if (opt->state & ( State_Sunken | !State_Enabled ) )
+      else if (opt->state & ( State_Sunken | ~State_Enabled ) )
         fill = opt->palette.color( QPalette::Window );
       else if (opt->state & State_Enabled) {
         if (!(opt->state & State_Off) )
@@ -1433,15 +1436,13 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
         p->save();
         doRestore = true;
       }
-      if (pe == PE_Q3CheckListIndicator || pe == PE_IndicatorViewItemCheck) {
-        const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
-        p->setPen(itemViewOpt && itemViewOpt->showDecorationSelected
-                  && opt->state & State_Selected ? opt->palette.highlightedText().color()
-                  : opt->palette.text().color());
-        if (opt->state & State_NoChange)
-          p->setBrush( opt->palette.color( QPalette::Button ) );
-        p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
-      }
+      const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt);
+      p->setPen(itemViewOpt && itemViewOpt->showDecorationSelected
+               && opt->state & State_Selected ? opt->palette.highlightedText().color()
+               : opt->palette.text().color());
+      if (opt->state & State_NoChange)
+       p->setBrush( opt->palette.color( QPalette::Button ) );
+      p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11);
       if (!(opt->state & State_Off)) {
         QLineF lines[11];
         int i, xx, yy;
@@ -1461,7 +1462,7 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
         QColor aColor = getColor( Style_Model::pointer_clr );
         if ( !(opt->state & State_Enabled ) )
           aColor = opt->palette.mid().color();
-        if ( opt->state & State_Selected )
+        if ( opt->state & State_Selected && itemViewOpt && itemViewOpt->showDecorationSelected )
           aColor = opt->palette.highlightedText().color();
 
         p->setPen( QPen( aColor ) );
@@ -1564,15 +1565,12 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
           drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), aRad, Style_Tools::All, true);
         else {
           Style_Tools::shadowRect( p, opt->rect, aRad, LINE_GR_MARGIN, SHADOW,
-                                   Style_Tools::All, opt->palette.color( QPalette::Base ), //, getColor( Style_Model::fld_light_clr ),
+                                   Style_Tools::All, opt->palette.color( QPalette::Base ), // getColor( Style_Model::fld_light_clr ),
                                    getColor( Style_Model::fld_dark_clr ), aBrdTopCol, aBrdBotCol,
                                    getBoolValue( Style_Model::all_antialized ), false );
         }
       }
       else {
-        //drawPrimitive( PE_FrameLineEdit, opt, p, w );
-        // fillRect()'s not correct working with basic color
-        // for ListWidget in edit QListWidgetItem mode
         if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
           QRect rect = panel->rect.adjusted( panel->lineWidth,  panel->lineWidth,
                                              -panel->lineWidth, -panel->lineWidth);
@@ -1718,7 +1716,7 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
         if ( qobject_cast<QTreeView*>(aWdg) ) {
           QTreeView* trView = qobject_cast<QTreeView*>(aWdg);
           QHeaderView* aHeader = trView->header();
-          if ( aHeader ) {
+          if ( aHeader && aHeader->isVisible() ) {
             int aHeight = aHeader->contentsRect().height();
             r = QRect( r.x(), r.y()+aHeight, r.width(), r.height()-aHeight );
           }
@@ -1726,10 +1724,10 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
         QPalette aPal = aWdg->palette();
         double aMarg = LINE_GR_MARGIN;
         QColor base = getColor( Style_Model::pal_base_clr ),
-               light = base,
+              light = base,
                light_alt = base.dark(110),//AlternateBase color
                dark  = getColor( Style_Model::fld_dark_clr );
-        light.setAlpha( 0 );
+        //light.setAlpha( 0 ); // VSR commented: IPAL19262
         QLinearGradient gr_h(r.x(), r.y(), r.right(), r.y());
         gr_h.setColorAt( 0.0, dark );
         gr_h.setColorAt( aMarg / r.width(), light );
@@ -1851,6 +1849,28 @@ QPixmap Style_Salome::standardPixmap(StandardPixmap stPixmap, const QStyleOption
   }
 }
 
+QIcon Style_Salome::standardIconImplementation( StandardPixmap standardIcon, 
+                                               const QStyleOption* opt,
+                                               const QWidget* widget ) const
+{
+  /*
+  switch ( standardIcon )
+  {
+  case SP_MessageBoxInformation:
+    return QPixmap( ":/images/information.png" );
+  case SP_MessageBoxWarning:
+    return QPixmap( ":/images/warning.png" );
+  case SP_MessageBoxCritical:
+    return QPixmap( ":/images/critical.png" );
+  case SP_MessageBoxQuestion:
+    return QPixmap( ":/images/question.png" );
+  default:
+    break;
+  }
+  */
+  return QWindowsStyle::standardIconImplementation( standardIcon, opt, widget );
+}
+
 int Style_Salome::styleHint( StyleHint hint, const QStyleOption* opt, const QWidget* widget,
                             QStyleHintReturn* returnData ) const
 {
index 67e6472eb58dc31e0573c3f1afd3a455e01d1ef5..edcfd1973cc8e26b0f405fd4f3885bc7bae7998e 100644 (file)
@@ -69,6 +69,10 @@ public:
                                  SubControl, const QWidget* = 0 ) const;
   virtual QRect   subElementRect( SubElement, const QStyleOption*, const QWidget* = 0 ) const;
 
+protected slots:
+  QIcon standardIconImplementation( StandardPixmap, const QStyleOption* = 0,
+                                   const QWidget* = 0 ) const;
+
 private:
   void            updatePaletteColors();
   void            updateAllWidgets( QApplication* );
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&,