Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / Style / SalomeStyle.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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 #ifndef SALOMESTYLE_H
20 #define SALOMESTYLE_H
21
22 #define parent_style qwindowsstyle
23 #define PARENT_STYLE QWindowsStyle
24
25 #define QUOTE(x) #x
26 #define PARENT_INC(x) QUOTE(x.h)
27
28 //#include PARENT_INC(parent_style)
29 #include <qwindowsstyle.h>
30
31 #include <qpixmap.h>
32 #include <qdockwindow.h>
33 #include <qstyleplugin.h>
34
35 #if defined SALOMESTYLE_EXPORTS
36 #if defined WIN32
37 #define SALOMESTYLE_EXPORT _declspec( dllexport )
38 #else
39 #define SALOMESTYLE_EXPORT  
40 #endif
41 #else
42 #if defined WIN32
43 #define SALOMESTYLE_EXPORT _declspec( dllimport )
44 #else
45 #define SALOMESTYLE_EXPORT  
46 #endif
47 #endif
48
49 class QFontMetrics;
50
51 class SALOMESTYLE_EXPORT SalomeStyle : public PARENT_STYLE
52 {
53 public:
54   SalomeStyle();
55   virtual ~SalomeStyle();
56
57   virtual void       polish( QWidget* );
58
59   virtual bool       eventFilter( QObject*, QEvent* );
60
61   static void        mix( const double, QRgb&, const QRgb& );
62   static void        mix( const double, QPixmap&, const QColor& );
63   static void        mix( const double, const QColor&, const QColor&, QColor& );
64
65   static void        toGrayscale( QPixmap&, double = 1.0 );
66
67   virtual void       drawPrimitive( PrimitiveElement, QPainter*, const QRect&,
68                                     const QColorGroup&, SFlags = Style_Default,
69                                     const QStyleOption& = QStyleOption::Default ) const;
70
71   virtual void       drawControl( ControlElement, QPainter*, const QWidget*,
72                                   const QRect&, const QColorGroup&, SFlags = Style_Default,
73                                   const QStyleOption& = QStyleOption::Default ) const; 
74
75   virtual QRect      subRect( SubRect, const QWidget* ) const;
76
77   virtual void       drawComplexControl( ComplexControl, QPainter*, const QWidget*,
78                                          const QRect&, const QColorGroup&, SFlags = Style_Default,
79                                          SCFlags = SC_All, SCFlags = SC_None,
80                                          const QStyleOption& = QStyleOption::Default ) const;
81
82   virtual QPixmap    stylePixmap( StylePixmap, const QWidget* = 0,
83                                   const QStyleOption& = QStyleOption::Default ) const;
84
85   virtual int        pixelMetric( PixelMetric, const QWidget* widget = 0 ) const;
86
87 protected:
88   typedef enum { LeftToRight, RightToLeft, UpToDown, DownToUp } Direction;
89
90   typedef double (*gradient_func)( double );
91
92   void               drawGradient( QPainter*, const QRect&, const QColor&,
93                                    const QColor&, const Direction, gradient_func ) const;
94
95   QString            titleText( const QString&, const int, const int, QFont& f ) const;
96
97 private:
98   QWidget*           myTitleParent;
99 };
100
101 class SalomeStylePlugin : public QStylePlugin
102 {
103 public:
104   SalomeStylePlugin();
105   virtual ~SalomeStylePlugin();
106
107   virtual QStringList keys() const;
108   virtual QStyle* create( const QString& );
109 };
110
111 #endif