]> SALOME platform Git repositories - modules/gui.git/blob - src/Style/Style_Salome.h
Salome HOME
Merge remote branch 'origin/V7_dev'
[modules/gui.git] / src / Style / Style_Salome.h
1 // Copyright (C) 2007-2016  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 "Style.h"
27 #include <QtGlobal>
28 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
29 #include <QWindowsStyle>
30 #else
31 #include <QCommonStyle>
32 #endif
33 class Style_Model;
34
35 class QApplication;
36 class QWidget;
37 class QPainter;
38 class QtxResourceMgr;
39
40 class STYLE_SALOME_EXPORT Style_Salome
41 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
42 : public QWindowsStyle
43 #else
44 : public QCommonStyle
45 #endif
46 {
47   Q_OBJECT
48
49 private:
50   Style_Salome();
51
52 public:
53   virtual ~Style_Salome();
54
55   static void         initialize( QtxResourceMgr* = 0, const QString& = QString() );
56   static void         apply();
57   static void         restore();
58
59   static bool         isActive();
60
61   static Style_Model* model();
62
63   static void         update();
64
65   virtual void        polish( QApplication* );
66   virtual void        polish( QWidget* );
67   virtual void        unpolish( QWidget* );
68   virtual void        drawComplexControl( ComplexControl, const QStyleOptionComplex*,
69                                           QPainter*, const QWidget* = 0 ) const;
70   
71   virtual void        drawControl( ControlElement, const QStyleOption*, QPainter*, const QWidget* ) const;
72   virtual void        drawPrimitive( PrimitiveElement, const QStyleOption*,
73                                      QPainter*, const QWidget* = 0 ) const;
74   virtual int         pixelMetric( PixelMetric, const QStyleOption* = 0,
75                                    const QWidget* = 0 ) const;
76   virtual QSize       sizeFromContents ( ContentsType, const QStyleOption*,
77                                          const QSize&, const QWidget* = 0 ) const;
78   virtual QPixmap     standardPixmap( StandardPixmap, const QStyleOption*,
79                                       const QWidget* = 0) const;
80   virtual int         styleHint( StyleHint, const QStyleOption* = 0,
81                                  const QWidget* = 0, QStyleHintReturn* = 0 ) const;
82   virtual QRect       subControlRect( ComplexControl, const QStyleOptionComplex*,
83                                       SubControl, const QWidget* = 0 ) const;
84   virtual QRect       subElementRect( SubElement, const QStyleOption*, const QWidget* = 0 ) const;
85
86 protected slots:
87   QIcon               standardIconImplementation( StandardPixmap, const QStyleOption* = 0,
88                                                   const QWidget* = 0 ) const;
89 private:
90   void                updatePaletteColors();
91   void                updateAllWidgets( QApplication* );
92   bool                hasHover() const;
93   void                drawHoverRect( QPainter*, const QRect&, const QColor&, const double,
94                                      const int, const bool ) const;
95   void                drawHandle( QPainter*, const QRect&, bool, bool = true ) const;
96   void                drawBackground( QPainter*, const QRect&, const QColor&, const bool,
97                                       const bool = false, const bool = true ) const;
98   void                drawBorder( QPainter*, const QRect&, bool ) const;
99
100   QString             titleText( const QString&, const int, const int, QFont& ) const;
101
102 private:
103   static Style_Model* myModel;
104 };
105
106 #endif // STYLE_SALOME_H