Salome HOME
Updated copyright comment
[modules/gui.git] / src / Qtx / QtxBackgroundTool.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:      QtxBackgroundTool.h
21 // Author:    Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22
23 #ifndef QTXBACKGROUNDTOOL_H
24 #define QTXBACKGROUNDTOOL_H
25
26 #include "Qtx.h"
27 #include "QtxDialog.h"
28
29 #include <QWidget>
30 #include <QMap>
31
32 class QCheckBox;
33 class QComboBox;
34 class QStackedWidget;
35 class QLineEdit;
36 class QPushButton;
37 class QtxColorButton;
38
39 class QTX_EXPORT QtxBackgroundTool : public QWidget
40 {
41   enum { Color, Gradient };
42   enum { TypeRole = Qt::UserRole, IdRole };
43
44   Q_OBJECT
45
46 public:
47   QtxBackgroundTool( QWidget* = 0 );
48   QtxBackgroundTool( Qt::Orientation, QWidget* = 0 );
49   virtual ~QtxBackgroundTool();
50
51   Qtx::BackgroundData data() const;
52   void                setData( const Qtx::BackgroundData& );
53
54   void                gradients( QStringList&, QIntList& ) const;
55   void                setGradients( const QStringList&, const QIntList& = QIntList() );
56
57   bool                isModeAllowed( Qtx::BackgroundMode ) const;
58   void                setModeAllowed( Qtx::BackgroundMode, bool = true );
59
60   bool                isTextureModeAllowed( Qtx::TextureMode ) const;
61   void                setTextureModeAllowed( Qtx::TextureMode, bool = true );
62
63   bool                isTextureAllowed() const;
64   void                setTextureAllowed( bool = true );
65
66   QString             imageFormats() const;
67   void                setImageFormats( const QString& );
68
69   Qt::Orientation     orientation() const;
70   void                setOrientation( Qt::Orientation );
71
72 private:
73   void                init( Qt::Orientation );
74   void                internalUpdate();
75
76 private slots:
77   void                updateState();
78   void                browse();
79   
80 private:
81   QComboBox*          myModeCombo;
82   QStackedWidget*     myCContainer;
83   QWidget*            myTContainer;
84   QCheckBox*          myTextureCheck;
85   QLineEdit*          myFileName;
86   QPushButton*        myBrowseBtn;
87   QComboBox*          myTextureMode;
88   QtxColorButton*     myFirstColor;
89   QtxColorButton*     mySecondColor;
90   QStringList         myGradients;
91   QIntList            myGradientsIds;
92   bool                myTextureAllowed;
93   QMap<int, bool>     myTypesAllowed;
94   QMap<int, bool>     myTextureTypesAllowed;
95   QString             myImageFormats;
96   int                 myLastGradient;
97 };
98
99 class QTX_EXPORT QtxBackgroundDialog : public QtxDialog
100 {
101   Q_OBJECT
102
103 public:
104   QtxBackgroundDialog( QWidget* = 0 );
105   QtxBackgroundDialog( const Qtx::BackgroundData&, QWidget* = 0 );
106   virtual ~QtxBackgroundDialog();
107
108   void                       setData( const Qtx::BackgroundData& );
109   Qtx::BackgroundData        data() const;
110
111   static Qtx::BackgroundData getBackground( const Qtx::BackgroundData& = Qtx::BackgroundData(),
112                                             QWidget* = 0,
113                                             bool = true, bool = true, bool = true, bool = true,
114                                             const QStringList& = QStringList(),
115                                             const QIntList& = QIntList(),
116                                             const QString& = QString() );
117   static Qtx::BackgroundData getBackground( const Qtx::BackgroundData&,
118                                             QWidget*,
119                                             const QIntList&,
120                                             bool = true, bool = true, bool = true, bool = true,
121                                             const QStringList& = QStringList(),
122                                             const QIntList& = QIntList(),
123                                             const QString& = QString() );
124
125
126   void                       setGradients( const QStringList&, const QIntList& = QIntList() );
127   void                       setModeAllowed( Qtx::BackgroundMode, bool = true );
128   void                       setTextureAllowed( bool = true );
129   void                       setTextureModeAllowed( Qtx::TextureMode, bool = true );
130   void                       setImageFormats( const QString& );
131
132 private:
133   void                       init();
134
135 private:
136   QtxBackgroundTool*         myTool;
137 };
138
139 #endif // QTXBACKGROUNDTOOL_H