Salome HOME
Copyright update 2022
[modules/gui.git] / src / Style / Style_Salome.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : Style_Salome.h
21 // Author : Natalia Ermolaeva, Open CASCADE S.A.S.
22 //
23 #ifndef STYLE_SALOME_H
24 #define STYLE_SALOME_H
25
26 #include <QtGlobal>
27 #include "Style.h"
28 #include <QCommonStyle>
29 #define BaseStyle QCommonStyle
30
31 class Style_Model;
32
33 class QApplication;
34 class QWidget;
35 class QPainter;
36 class QtxResourceMgr;
37
38 class STYLE_SALOME_EXPORT Style_Salome : public BaseStyle
39 {
40   Q_OBJECT
41
42 private:
43   Style_Salome();
44
45 public:
46   virtual ~Style_Salome();
47
48   static void         initialize( QtxResourceMgr* = 0, const QString& = QString() );
49   static void         apply();
50   static void         restore();
51
52   static bool         isActive();
53
54   static Style_Model* model();
55
56   static void         update();
57
58   virtual void        polish( QApplication* );
59   virtual void        polish( QWidget* );
60   virtual void        unpolish( QWidget* );
61   virtual void        drawComplexControl( ComplexControl, const QStyleOptionComplex*,
62                                           QPainter*, const QWidget* = 0 ) const;
63   
64   virtual void        drawControl( ControlElement, const QStyleOption*, QPainter*, const QWidget* ) const;
65   virtual void        drawPrimitive( PrimitiveElement, const QStyleOption*,
66                                      QPainter*, const QWidget* = 0 ) const;
67   virtual int         pixelMetric( PixelMetric, const QStyleOption* = 0,
68                                    const QWidget* = 0 ) const;
69   virtual QSize       sizeFromContents ( ContentsType, const QStyleOption*,
70                                          const QSize&, const QWidget* = 0 ) const;
71   virtual QPixmap     standardPixmap( StandardPixmap, const QStyleOption*,
72                                       const QWidget* = 0) const;
73   virtual int         styleHint( StyleHint, const QStyleOption* = 0,
74                                  const QWidget* = 0, QStyleHintReturn* = 0 ) const;
75   virtual QRect       subControlRect( ComplexControl, const QStyleOptionComplex*,
76                                       SubControl, const QWidget* = 0 ) const;
77   virtual QRect       subElementRect( SubElement, const QStyleOption*, const QWidget* = 0 ) const;
78
79 protected slots:
80   QIcon               standardIconImplementation( StandardPixmap, const QStyleOption* = 0,
81                                                   const QWidget* = 0 ) const;
82 private:
83   void                updatePaletteColors();
84   void                updateAllWidgets( QApplication* );
85   bool                hasHover() const;
86   void                drawHoverRect( QPainter*, const QRect&, const QColor&, const double,
87                                      const int, const bool ) const;
88   void                drawHandle( QPainter*, const QRect&, bool, bool = true ) const;
89   void                drawBackground( QPainter*, const QRect&, const QColor&, const bool,
90                                       const bool = false, const bool = true ) const;
91   void                drawBorder( QPainter*, const QRect&, bool ) const;
92
93   QString             titleText( const QString&, const int, const int, QFont& ) const;
94
95 private:
96   static Style_Model* myModel;
97 };
98
99 #endif // STYLE_SALOME_H