]> SALOME platform Git repositories - modules/gui.git/blob - src/Style/Style_PrefDlg.h
Salome HOME
d96a4f0838c0ca74a783c19f98b947fce4d12190
[modules/gui.git] / src / Style / Style_PrefDlg.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : Style_PrefDlg.h
23 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
24 //
25 #ifndef STYLE_PREFDLG_H
26 #define STYLE_PREFDLG_H
27
28 #include "Style.h"
29
30 #include <QtxDialog.h>
31 #include <QFrame>
32 #include <QMap>
33
34 class QCheckBox;
35 class QComboBox;
36 class QLabel;
37 class QListWidget;
38 class QListWidgetItem;
39 class QPushButton;
40 class QRadioButton;
41 class QSlider;
42 class QSpinBox;
43 class QTabWidget;
44 class QtxColorButton;
45 class QtxDoubleSpinBox;
46 class QtxFontEdit;
47 class Style_ResourceMgr;
48 class Style_Model;
49
50 class STYLE_SALOME_EXPORT Style_PrefDlg : public QtxDialog
51 {
52   Q_OBJECT
53
54   class PaletteEditor;
55   enum { Current, Default, Global, User };
56   enum { TypeRole = Qt::UserRole + 123, NameRole  };
57
58 public:
59   Style_PrefDlg( QWidget* = 0 );
60   ~Style_PrefDlg();
61
62   void               accept();
63
64 protected:
65   void               keyPressEvent( QKeyEvent* );
66
67 private:
68   Style_ResourceMgr* resourceMgr();
69   void               fromModel( Style_Model* );
70   void               toModel( Style_Model* ) const;
71   
72   QString            findUniqueName( const QString&, QListWidgetItem* = 0, bool = false );
73
74 signals:
75   void               styleChanged();
76
77 private slots:
78   void               onApply();
79   void               onHelp();
80
81   void               onStyleChanged();
82   void               onLinesType();
83   void               onChanged();
84   void               onItemChanged( QListWidgetItem* );
85   void               onEffectChanged( QAbstractButton* );
86
87 private:
88   Style_ResourceMgr* myResMgr;
89   QCheckBox*         myStyleCheck;
90   QListWidget*       myStylesList;
91   QTabWidget*        myStylesTab;
92
93   PaletteEditor*     myPaletteEditor;
94   QtxFontEdit*       myFontEdit;
95   QComboBox*         myLinesCombo;
96   QSlider*           myLinesTransparency;
97   QtxDoubleSpinBox*  myEditRound;
98   QtxDoubleSpinBox*  myButtonRound;
99   QtxDoubleSpinBox*  myFrameRound;
100   QtxDoubleSpinBox*  mySliderRound;
101   QCheckBox*         myAntiAliasing;
102   QSpinBox*          myHorHandleDelta;
103   QSpinBox*          myVerHandleDelta;
104   QSpinBox*          mySplitterLength;
105   QSpinBox*          mySliderSize;
106   QRadioButton*      myEffectNone;
107   QRadioButton*      myEffectHighlight;
108   QRadioButton*      myEffectAutoRaise;
109
110   QRadioButton*      myCurrentEffect;
111 };
112
113 class Style_PrefDlg::PaletteEditor : public QFrame
114 {
115   Q_OBJECT
116
117 public:
118   PaletteEditor( QWidget* = 0 );
119   ~PaletteEditor();
120  
121   void               addColumn( const QString& );
122   void               addItem( int );
123   QList<int>         items() const;
124
125   void               setColor( int, QPalette::ColorGroup, const QColor& );
126   void               setColor( int, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
127   QColor             color( int, QPalette::ColorGroup ) const;
128
129   bool               isAuto() const;
130   void               setAuto( bool );
131
132   void               fromColor( const QColor& );
133
134 private:
135   static QString     idToName( int );
136   QWidget*           line();
137
138 private slots:
139   void               onQuick();
140   void               onAuto();
141
142 signals:
143   void               changed();
144
145 private:
146   typedef QMap<QPalette::ColorGroup, QtxColorButton*> Btns;
147
148   QFrame*            myContainer;
149   QPushButton*       myQuickButton;
150   QCheckBox*         myAutoCheck;
151   QLabel*            myActiveLab;
152   QLabel*            myInactiveLab;
153   QLabel*            myDisabledLab;
154
155   QMap<int, Btns>    myButtons;
156   int                myCurrentRow;
157   int                myCurrentColumn;
158
159   friend class Style_PrefDlg;
160 };
161
162 #endif // STYLE_PREFDLG_H