Salome HOME
a773d2aa97a8cea6835b8cb31166fbbf72e14444
[modules/gui.git] / src / QDS / QDS_RadioBox.h
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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
23 #ifndef QDS_RADIOBOX_H
24 #define QDS_RADIOBOX_H
25
26 #include "QDS_Datum.h"
27
28 #include <Qtx.h>
29
30 #include <QMap>
31 #include <QStringList>
32
33 #ifdef WIN32
34 #pragma warning( disable:4251 )
35 #endif
36
37 class QButtonGroup;
38 class QGroupBox;
39 class QRadioButton;
40
41 class QDS_EXPORT QDS_RadioBox : public QDS_Datum
42 {
43   Q_OBJECT
44
45 public:
46   QDS_RadioBox( const QString&, QWidget* = 0, const int = Control, const QString& = QString() );
47   virtual ~QDS_RadioBox();
48
49   int                        count( bool = false ) const;
50   void                       values( QList<int>&, bool = false ) const;
51
52   int                        columns() const;
53   void                       setColumns( const int );
54
55   bool                       state( const int ) const;
56   void                       setState( const bool, const int, const bool = true );
57   void                       setState( const bool, const QList<int>&, const bool = true );
58   void                       setValues( const QList<int>&, const QStringList& );
59   void                       setValues( const QStringList& );
60
61   virtual QString            getString() const;
62
63 signals:
64   void                       activated( int );
65
66 protected slots:
67   virtual void               onToggled( bool );
68
69 protected:
70   QButtonGroup*              buttonGroup() const;
71   QGroupBox*                 groupBox() const;
72   virtual QWidget*           createControl( QWidget* );
73   void                       buttons( QList<QRadioButton*>& ) const;
74
75   virtual void               setString( const QString& );
76
77   virtual void               unitSystemChanged( const QString& );
78
79 private:
80   void                       updateRadioBox();
81
82 private:
83   typedef QMap<int, QString> IdValueMap;
84   typedef QMap<int, bool>    IdStateMap;
85
86 private:
87   IdValueMap                 myValue;
88   IdStateMap                 myState;
89
90   QIntList                   myDataIds;
91   QIntList                   myUserIds;
92   QStringList                myUserNames;
93
94   QButtonGroup*              myButtonGroup;
95 };
96
97 #ifdef WIN32
98 #pragma warning( default:4251 )
99 #endif
100
101 #endif