Back to index

salome-gui  6.5.0
Style_Model.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : Style_Model.h
00021 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
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 // This class is private for Style package.
00038 // Normally it should not be exported.
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