00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef STYLE_MODEL_H
00024 #define STYLE_MODEL_H
00025
00026 #include "Style.h"
00027
00028 #include <QMap>
00029 #include <QString>
00030 #include <QPalette>
00031 #include <QFont>
00032
00033 class QStyle;
00034 class QtxResourceMgr;
00035
00036
00037
00038
00039
00040 class STYLE_SALOME_EXPORT Style_Model
00041 {
00042 public:
00044 typedef enum {
00045 WindowText = QPalette::WindowText,
00046 Button = QPalette::Button,
00047 Light = QPalette::Light,
00048 Midlight = QPalette::Midlight,
00049 Dark = QPalette::Dark,
00050 Mid = QPalette::Mid,
00051 Text = QPalette::Text,
00052 BrightText = QPalette::BrightText,
00053 ButtonText = QPalette::ButtonText,
00054 Base = QPalette::Base,
00055 Window = QPalette::Window,
00056 Shadow = QPalette::Shadow,
00057 Highlight = QPalette::Highlight,
00058 HighlightedText = QPalette::HighlightedText,
00059 Link = QPalette::Link,
00060 LinkVisited = QPalette::LinkVisited,
00061 AlternateBase = QPalette::AlternateBase,
00062 NoRole = QPalette::NoRole,
00063 ToolTipBase = QPalette::ToolTipBase,
00064 ToolTipText = QPalette::ToolTipText,
00065 NColorRoles = QPalette::NColorRoles,
00066 BorderTop = NColorRoles,
00067 BorderBottom,
00068 TabBorderTop,
00069 TabBorderBottom,
00070 FieldLight,
00071 FieldDark,
00072 Slider,
00073 Lines,
00074 HighlightWidget,
00075 HighlightBorder,
00076 Header,
00077 ProgressBar,
00078 Pointer,
00079 Checked,
00080 GridLine,
00081 LastColor
00082 } ColorRole;
00083
00085 typedef enum {
00086 NoLines,
00087 Horizontal,
00088 Inclined,
00089 } LineType;
00090
00092 typedef enum {
00093 ButtonRadius,
00094 EditRadius,
00095 FrameRadius,
00096 SliderRadius,
00097 } WidgetRounding;
00098
00100 typedef enum {
00101 NoEffect,
00102 HighlightEffect,
00103 AutoRaiseEffect
00104 } WidgetEffect;
00105
00106 Style_Model();
00107 virtual ~Style_Model();
00108
00109 void fromApplication( bool = false );
00110 void fromResources( QtxResourceMgr*, const QString& = QString() );
00111
00112 void save( QtxResourceMgr* = 0, const QString& = QString() );
00113 void update();
00114 void restore();
00115
00116 QtxResourceMgr* resourceMgr() const;
00117 QString resourceSection() const;
00118
00119
00120 QColor color( ColorRole, QPalette::ColorGroup = QPalette::Active ) const;
00121 void setColor( ColorRole, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
00122 void setColor( ColorRole, QPalette::ColorGroup, const QColor& );
00123
00124 bool isAutoPalette() const;
00125 void setAutoPalette( bool );
00126
00127 LineType linesType() const;
00128 void setLinesType( LineType );
00129
00130 int linesTransparency() const;
00131 void setLinesTransparency( int );
00132
00133 QFont applicationFont() const;
00134 void setApplicationFont( const QFont& );
00135
00136 double widgetRounding( WidgetRounding ) const;
00137 void setWidgetRounding( WidgetRounding, double );
00138
00139 bool antialiasing() const;
00140 void setAntialiasing( bool );
00141
00142 WidgetEffect widgetEffect() const;
00143 void setWidgetEffect( WidgetEffect );
00144
00145 int handleDelta( Qt::Orientation ) const;
00146 void setHandleDelta( Qt::Orientation, int );
00147
00148 int splitHandleLength() const;
00149 void setSplitHandleLength( int );
00150
00151 int sliderSize() const;
00152 void setSliderSize( int );
00153
00154 private:
00155 void initDefaults();
00156 void readColorValue( ColorRole, const QString& );
00157 void writeColorValue( ColorRole, const QString&, QtxResourceMgr*, const QString& ) const;
00158
00159 private:
00160 typedef QMap<ColorRole, QColor> ColorMap;
00161 typedef QMap<QPalette::ColorGroup, ColorMap> ColorGroupMap;
00162 typedef QMap<WidgetRounding, double> RoundMap;
00163 typedef QMap<Qt::Orientation, int> DeltaMap;
00164
00165 QtxResourceMgr* myResourceMgr;
00166 QString myResourceSection;
00167
00168 ColorGroupMap myColors;
00169 bool myAutoPalette;
00170 RoundMap myWidgetRounding;
00171 DeltaMap myHandleDelta;
00172 QFont myFont;
00173 LineType myLinesType;
00174 WidgetEffect myWidgetEffect;
00175 bool myAntiAliasing;
00176 int myLinesTransparency;
00177 int mySplitHandleLength;
00178 int mySliderSize;
00179
00180 struct AppData {
00181 QStyle* myStyle;
00182 QPalette myPalette;
00183 QFont myFont;
00184 };
00185
00186 static AppData* myAppData;
00187 };
00188
00189 #endif // STYLE_MODEL_H