Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Style_Model.h
Go to the documentation of this file.
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_Model.h
21 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
22 //
23 #ifndef STYLE_MODEL_H
24 #define STYLE_MODEL_H
25 
26 #include "Style.h"
27 
28 #include <QMap>
29 #include <QString>
30 #include <QPalette>
31 #include <QFont>
32 
33 class QStyle;
34 class QtxResourceMgr;
35 
36 //
37 // This class is private for Style package.
38 // Normally it should not be exported.
39 //
41 {
42 public:
44  typedef enum {
45  WindowText = QPalette::WindowText,
46  Button = QPalette::Button,
47  Light = QPalette::Light,
48  Midlight = QPalette::Midlight,
49  Dark = QPalette::Dark,
50  Mid = QPalette::Mid,
51  Text = QPalette::Text,
52  BrightText = QPalette::BrightText,
53  ButtonText = QPalette::ButtonText,
54  Base = QPalette::Base,
56  Shadow = QPalette::Shadow,
57  Highlight = QPalette::Highlight,
58  HighlightedText = QPalette::HighlightedText,
59  Link = QPalette::Link,
60  LinkVisited = QPalette::LinkVisited,
61  AlternateBase = QPalette::AlternateBase,
62  NoRole = QPalette::NoRole,
63  ToolTipBase = QPalette::ToolTipBase,
64  ToolTipText = QPalette::ToolTipText,
65  NColorRoles = QPalette::NColorRoles,
66  BorderTop = NColorRoles,
81  LastColor
82  } ColorRole;
83 
85  typedef enum {
89  } LineType;
90 
92  typedef enum {
97  } WidgetRounding;
98 
100  typedef enum {
103  AutoRaiseEffect
104  } WidgetEffect;
105 
106  Style_Model();
107  virtual ~Style_Model();
108 
109  void fromApplication( bool = false );
110  void fromResources( QtxResourceMgr*, const QString& = QString() );
111 
112  void save( QtxResourceMgr* = 0, const QString& = QString() );
113  void update();
114  void restore();
115 
116  QtxResourceMgr* resourceMgr() const;
117  QString resourceSection() const;
118 
119 
120  QColor color( ColorRole, QPalette::ColorGroup = QPalette::Active ) const;
121  void setColor( ColorRole, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
122  void setColor( ColorRole, QPalette::ColorGroup, const QColor& );
123 
124  bool isAutoPalette() const;
125  void setAutoPalette( bool );
126 
127  LineType linesType() const;
128  void setLinesType( LineType );
129 
130  int linesTransparency() const;
131  void setLinesTransparency( int );
132 
133  QFont applicationFont() const;
134  void setApplicationFont( const QFont& );
135 
136  double widgetRounding( WidgetRounding ) const;
137  void setWidgetRounding( WidgetRounding, double );
138 
139  bool antialiasing() const;
140  void setAntialiasing( bool );
141 
142  WidgetEffect widgetEffect() const;
143  void setWidgetEffect( WidgetEffect );
144 
145  int handleDelta( Qt::Orientation ) const;
146  void setHandleDelta( Qt::Orientation, int );
147 
148  int splitHandleLength() const;
149  void setSplitHandleLength( int );
150 
151  int sliderSize() const;
152  void setSliderSize( int );
153 
154 private:
155  void initDefaults();
156  void readColorValue( ColorRole, const QString& );
157  void writeColorValue( ColorRole, const QString&, QtxResourceMgr*, const QString& ) const;
158 
159 private:
160  typedef QMap<ColorRole, QColor> ColorMap;
161  typedef QMap<QPalette::ColorGroup, ColorMap> ColorGroupMap;
162  typedef QMap<WidgetRounding, double> RoundMap;
163  typedef QMap<Qt::Orientation, int> DeltaMap;
164 
167 
172  QFont myFont;
179 
180  struct AppData {
181  QStyle* myStyle;
182  QPalette myPalette;
183  QFont myFont;
184  };
185 
187 };
188 
189 #endif // STYLE_MODEL_H