Salome HOME
Updated copyright comment
[modules/gui.git] / src / Style / Style_PrefDlg.h
1 // Copyright (C) 2007-2024  CEA, EDF, 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_PrefDlg.h
21 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
22 //
23 #ifndef STYLE_PREFDLG_H
24 #define STYLE_PREFDLG_H
25
26 #include "Style.h"
27
28 #include <QtxDialog.h>
29 #include <QFrame>
30 #include <QMap>
31
32 class QCheckBox;
33 class QComboBox;
34 class QLabel;
35 class QListWidget;
36 class QListWidgetItem;
37 class QPushButton;
38 class QRadioButton;
39 class QSlider;
40 class QSpinBox;
41 class QTabWidget;
42 class QtxColorButton;
43 class QtxDoubleSpinBox;
44 class QtxFontEdit;
45 class Style_ResourceMgr;
46 class Style_Model;
47
48 class STYLE_SALOME_EXPORT Style_PrefDlg : public QtxDialog
49 {
50   Q_OBJECT
51
52   class PaletteEditor;
53   enum { Current, Default, Global, User };
54   enum { TypeRole = Qt::UserRole + 123, NameRole  };
55
56 public:
57   Style_PrefDlg( QWidget* = 0 );
58   ~Style_PrefDlg();
59
60   void               accept();
61   bool               eventFilter( QObject*, QEvent* );
62
63 private:
64   Style_ResourceMgr* resourceMgr();
65   void               fromModel( Style_Model* );
66   void               toModel( Style_Model* ) const;
67   
68   QString            findUniqueName( const QString&, QListWidgetItem* = 0, bool = false );
69
70 signals:
71   void               styleChanged();
72
73 private slots:
74   void               onApply();
75   void               onHelp();
76
77   void               onStyleChanged();
78   void               onLinesType();
79   void               onChanged();
80   void               onItemChanged( QListWidgetItem* );
81   void               onEffectChanged( QAbstractButton* );
82
83 private:
84   Style_ResourceMgr* myResMgr;
85   QCheckBox*         myStyleCheck;
86   QListWidget*       myStylesList;
87   QTabWidget*        myStylesTab;
88
89   PaletteEditor*     myPaletteEditor;
90   QtxFontEdit*       myFontEdit;
91   QComboBox*         myLinesCombo;
92   QSlider*           myLinesTransparency;
93   QtxDoubleSpinBox*  myEditRound;
94   QtxDoubleSpinBox*  myButtonRound;
95   QtxDoubleSpinBox*  myFrameRound;
96   QtxDoubleSpinBox*  mySliderRound;
97   QCheckBox*         myAntiAliasing;
98   QSpinBox*          myHorHandleDelta;
99   QSpinBox*          myVerHandleDelta;
100   QSpinBox*          mySplitterLength;
101   QSpinBox*          mySliderSize;
102   QRadioButton*      myEffectNone;
103   QRadioButton*      myEffectHighlight;
104   QRadioButton*      myEffectAutoRaise;
105
106   QRadioButton*      myCurrentEffect;
107 };
108
109 class Style_PrefDlg::PaletteEditor : public QFrame
110 {
111   Q_OBJECT
112
113 public:
114   PaletteEditor( QWidget* = 0 );
115   ~PaletteEditor();
116  
117   void               addColumn( const QString& );
118   void               addItem( int );
119   QList<int>         items() const;
120
121   void               setColor( int, QPalette::ColorGroup, const QColor& );
122   void               setColor( int, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
123   QColor             color( int, QPalette::ColorGroup ) const;
124
125   bool               isAuto() const;
126   void               setAuto( bool );
127
128   void               fromColor( const QColor& );
129
130 private:
131   static QString     idToName( int );
132   QWidget*           line();
133
134 private slots:
135   void               onQuick();
136   void               onAuto();
137
138 signals:
139   void               changed();
140
141 private:
142   typedef QMap<QPalette::ColorGroup, QtxColorButton*> Btns;
143
144   QFrame*            myContainer;
145   QPushButton*       myQuickButton;
146   QCheckBox*         myAutoCheck;
147   QLabel*            myActiveLab;
148   QLabel*            myInactiveLab;
149   QLabel*            myDisabledLab;
150
151   QMap<int, Btns>    myButtons;
152   int                myCurrentRow;
153   int                myCurrentColumn;
154
155   friend class Style_PrefDlg;
156 };
157
158 #endif // STYLE_PREFDLG_H