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