Salome HOME
no message
[modules/gui.git] / src / Style / SalomeStyle.h
1 #ifndef SALOMESTYLE_H
2 #define SALOMESTYLE_H
3
4 #define parent_style qwindowsstyle
5 #define PARENT_STYLE QWindowsStyle
6
7 #define QUOTE(x) #x
8 #define PARENT_INC(x) QUOTE(x.h)
9
10 //#include PARENT_INC(parent_style)
11 #include <qwindowsstyle.h>
12
13 #include <qpixmap.h>
14 #include <qdockwindow.h>
15 #include <qstyleplugin.h>
16
17 #if defined SALOMESTYLE_EXPORTS
18 #if defined WIN32
19 #define SALOMESTYLE_EXPORT _declspec( dllexport )
20 #else
21 #define SALOMESTYLE_EXPORT  
22 #endif
23 #else
24 #if defined WIN32
25 #define SALOMESTYLE_EXPORT _declspec( dllimport )
26 #else
27 #define SALOMESTYLE_EXPORT  
28 #endif
29 #endif
30
31 class QFontMetrics;
32
33 class SALOMESTYLE_EXPORT SalomeStyle : public PARENT_STYLE
34 {
35 public:
36   SalomeStyle();
37   virtual ~SalomeStyle();
38
39   virtual void       polish( QWidget* );
40
41   virtual bool       eventFilter( QObject*, QEvent* );
42
43   static void        mix( const double, QRgb&, const QRgb& );
44   static void        mix( const double, QPixmap&, const QColor& );
45   static void        mix( const double, const QColor&, const QColor&, QColor& );
46
47   static void        toGrayscale( QPixmap&, double = 1.0 );
48
49   virtual void       drawPrimitive( PrimitiveElement, QPainter*, const QRect&,
50                                     const QColorGroup&, SFlags = Style_Default,
51                                     const QStyleOption& = QStyleOption::Default ) const;
52
53   virtual void       drawControl( ControlElement, QPainter*, const QWidget*,
54                                   const QRect&, const QColorGroup&, SFlags = Style_Default,
55                                   const QStyleOption& = QStyleOption::Default ) const; 
56
57   virtual QRect      subRect( SubRect, const QWidget* ) const;
58
59   virtual void       drawComplexControl( ComplexControl, QPainter*, const QWidget*,
60                                          const QRect&, const QColorGroup&, SFlags = Style_Default,
61                                          SCFlags = SC_All, SCFlags = SC_None,
62                                          const QStyleOption& = QStyleOption::Default ) const;
63
64   virtual QPixmap    stylePixmap( StylePixmap, const QWidget* = 0,
65                                   const QStyleOption& = QStyleOption::Default ) const;
66
67   virtual int        pixelMetric( PixelMetric, const QWidget* widget = 0 ) const;
68
69 protected:
70   typedef enum { LeftToRight, RightToLeft, UpToDown, DownToUp } Direction;
71
72   typedef double (*gradient_func)( double );
73
74   void               drawGradient( QPainter*, const QRect&, const QColor&,
75                                    const QColor&, const Direction, gradient_func ) const;
76
77   QString            titleText( const QString&, const int, const QFontMetrics& ) const;
78
79 private:
80   QWidget*           myTitleParent;
81 };
82
83 class SalomeStylePlugin : public QStylePlugin
84 {
85 public:
86   SalomeStylePlugin();
87   virtual ~SalomeStylePlugin();
88
89   virtual QStringList keys() const;
90   virtual QStyle* create( const QString& );
91 };
92
93 #endif