]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxComboBox.h
Salome HOME
9315c674eb35b872dc79595bb1c6bf7bf6f78b46
[modules/gui.git] / src / Qtx / QtxComboBox.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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/
18 //
19 // File:      QtxComboBox.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTXCOMBOBOX_H
23 #define QTXCOMBOBOX_H
24
25 #include "Qtx.h"
26
27 #include <qmap.h>
28 #include <qcombobox.h>
29
30 #ifdef WIN32
31 #pragma warning( disable:4251 )
32 #endif
33
34 class QTX_EXPORT QtxComboBox : public QComboBox
35 {
36     Q_OBJECT
37
38     typedef QMap<int, int> IndexIdMap;
39
40 public:
41     QtxComboBox( QWidget* = 0, const char* = 0 );
42     QtxComboBox( bool, QWidget* = 0, const char* = 0 );
43     virtual ~QtxComboBox();
44
45     bool         isCleared() const;
46     void         setCleared( const bool );
47
48     virtual void setCurrentItem( int );
49     virtual void setCurrentText( const QString& );
50
51     int          currentId() const;
52     void         setCurrentId( int );
53
54 signals:
55     void         activatedId( int );
56     void         highlightedId( int );
57
58 private slots:
59     void         onActivated( int );
60     void         onActivated( const QString& );
61
62 protected:
63     virtual void paintEvent( QPaintEvent* );
64
65 private:
66     int          id( const int ) const;
67     int          index( const int ) const;
68
69     void         resetClear();
70     void         paintClear( QPaintEvent* );
71
72 private:
73     bool         myCleared;
74     IndexIdMap   myIndexId;
75 };
76
77 #ifdef WIN32
78 #pragma warning( default:4251 )
79 #endif
80
81 #endif