Salome HOME
345881b325350650496d3f2556808cd5568aa3be
[modules/gui.git] / src / Qtx / QtxComboBox.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:      QtxComboBox.h
23 // Author:    Sergey TELKOV
24 //
25 #ifndef QTXCOMBOBOX_H
26 #define QTXCOMBOBOX_H
27
28 #include "Qtx.h"
29
30 #include <QMap>
31 #include <QComboBox>
32
33 #ifdef WIN32
34 #pragma warning( disable:4251 )
35 #endif
36
37 class QTX_EXPORT QtxComboBox : public QComboBox
38 {
39   Q_OBJECT
40
41   class Model;
42   class ClearEvent;
43
44 public:
45   QtxComboBox( QWidget* = 0 );
46   virtual ~QtxComboBox();
47
48   bool         isCleared() const;
49   void         setCleared( const bool );
50
51   int          currentId() const;
52   void         setCurrentId( int );
53
54   int          id( const int ) const;
55   int          index( const int ) const;
56
57   bool         hasId( const int ) const;
58   void         setId( const int, const int );
59
60 signals:
61   void         activatedId( int );
62
63 private slots:
64   void         onActivated( int );
65   void         onCurrentChanged( int );
66
67 protected:
68   virtual void paintEvent( QPaintEvent* );
69   virtual void childEvent( QChildEvent* );
70   virtual void customEvent( QEvent* );
71
72 private:
73   void         resetClear();
74
75 private:
76   enum { IdRole = Qt::UserRole + 10 };
77
78 private:
79   bool         myCleared;     //!< "cleared" state
80 };
81
82 #ifdef WIN32
83 #pragma warning( default:4251 )
84 #endif
85
86 #endif