]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxListBox.h
Salome HOME
166831734748f95e8a8311bc4618b579b7c8c178
[modules/gui.git] / src / Qtx / QtxListBox.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:      QtxListBox.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTXLISTBOX_H
23 #define QTXLISTBOX_H
24
25 #include "Qtx.h"
26
27 #include <qlistbox.h>
28
29 #ifdef WIN32
30 #pragma warning( disable:4251 )
31 #endif
32
33 class QLineEdit;
34 class QValidator;
35
36 class QTX_EXPORT QtxListBox : public QListBox
37 {
38     Q_OBJECT
39
40 public:
41     QtxListBox( QWidget* = 0, const char* = 0, WFlags = 0 );
42     virtual ~QtxListBox();
43
44     bool              isEditEnabled() const;
45     bool              defaultEditAction() const;
46     bool              isModificationEnabled() const;
47
48     QListBoxItem*     editedItem() const;
49     int               editedIndex() const;
50
51     void              startEdition( const int );
52     void              startEdition( const QListBoxItem* );
53     void              endEdition( const bool );
54
55     void              ensureItemVisible( const int );
56     void              ensureItemVisible( const QListBoxItem* );
57
58     virtual bool      eventFilter( QObject*, QEvent* );
59
60     const QValidator* validator() const;
61
62     void              moveItemToTop( const int );
63     void              moveItemToBottom( const int );
64     void              moveItem( const int, const int );
65
66     void              createItem( const int = -1 );
67     void              deleteItem( const int = -1 );
68
69 signals:
70     void              itemEdited( int );
71     void              itemEdited( QListBoxItem* );
72     void              itemMoved( int, int );
73
74 public slots:
75     virtual void      setEditEnabled( bool );
76     virtual void      setDefaultEditAction( bool );
77     virtual void      setModificationEnabled( bool );
78
79     virtual void      clearValidator();
80     virtual void      setValidator( const QValidator* );
81     virtual void      setContentsPos( int, int );
82
83 private slots:
84     void              onContentsMoving( int, int );
85
86 protected:
87     virtual void      keyPressEvent( QKeyEvent* );
88     virtual void      viewportResizeEvent( QResizeEvent* );
89     virtual void      mouseDoubleClickEvent( QMouseEvent* );
90
91 private:
92     QLineEdit*        editor() const;
93     void              createEditor();
94     void              updateEditor();
95
96 private:
97     QLineEdit*        myEditor;
98     int               myEditIndex;
99     bool              myEditState;
100     bool              myEditDefault;
101     bool              myModifEnabled;
102 };
103
104 #ifdef WIN32
105 #pragma warning( default:4251 )
106 #endif
107
108 #endif