]> SALOME platform Git repositories - modules/yacs.git/blob - src/gui/YACSGui_PlusMinusGrp.h
Salome HOME
merge from branch DEV tag mergeto_trunk_04apr08
[modules/yacs.git] / src / gui / YACSGui_PlusMinusGrp.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #ifndef YACSGui_PlusMinusGrp_H 
22 #define YACSGui_PlusMinusGrp_H 
23  
24 #include "QtxGroupBox.h" 
25 #include <qstringlist.h> 
26  
27 class YACSGui_Table; 
28 class QToolButton; 
29  
30 /*!  
31   Class       : YACSGui_PlusMinusGrp 
32   Description : Group box containing data table and "plus" "minus" "insert" "up" and "down" buttons 
33 */ 
34  
35  
36 class YACSGui_PlusMinusGrp : public QtxGroupBox 
37
38   Q_OBJECT 
39  
40 public: 
41  
42   enum { PlusBtn = 0x1, MinusBtn = 0x2, InsertBtn = 0x4, UpBtn = 0x8, DownBtn = 0x10, SelectBtn = 0x20,
43          AllBtn = PlusBtn | MinusBtn | InsertBtn | UpBtn | DownBtn | SelectBtn }; 
44
45 public: 
46   YACSGui_PlusMinusGrp( QWidget* theParent, const QString& theTitle, const int theBtns = AllBtn ); 
47   virtual ~YACSGui_PlusMinusGrp(); 
48
49   YACSGui_Table*                      Table(); 
50   void                                ShowBtn( const int = AllBtn ); 
51   void                                HideBtn( const int = AllBtn );
52  
53   /*! buttons become enabled or disabled depending on number of rows at a table 
54       and max allowed number of rows for this table
55       parameter: defines which buttons will be enabled/disabled
56    */ 
57   void                                EnableBtn( const int = AllBtn );
58   void                                EnableBtn( const int, bool theEnable );
59
60   /*! Returns the tool button with given id
61       parameter: defines tool buttons' id
62    */ 
63   QToolButton*                        Btn( const int ) const;
64
65   /*! Set min allowed number of rows at the table. 
66       It is 0 by default.
67    */
68   inline void                         SetMinNumRow( const int theMinRow ) { myMinNumRow = theMinRow; };
69
70   /*!
71      returns min allowed number of strings for table or 0
72    */
73   inline int                          MinNumRow() { return myMinNumRow; }
74
75   /*! Set max allowed number of rows at the table. 
76       It is -1 by default. That means that number of rows is not limited
77    */
78   inline void                         SetMaxNumRow( const int theMaxRow ) { myMaxNumRow = theMaxRow; };
79
80   /*!
81      returns max allowed number of strings for table or -1
82    */
83   inline int                          MaxNumRow() { return myMaxNumRow; }
84
85   /*! Set the row number before which a new row will be added in case of "Plus" button
86       or "Insert" button with empty rows selection in the table. 
87       It is -1 by default. That means that row is added to the end of the table
88    */
89   inline void                         SetAddBeforeRowNum( const int theAddBeforeRowNum ) { myAddBeforeRowNum = theAddBeforeRowNum; };
90
91   /*!
92      returns the row number before which a new row will be added or -1
93    */
94   inline int                          AddBeforeRowNum() { return myAddBeforeRowNum; }
95
96   /*!
97      untoggled the selection button
98    */
99   void                                setOffSelect();
100
101 signals:
102   void                                MovedUp( const int theUpRowId );
103   void                                MovedDown( const int theDownRowId );
104   void                                Inserted( const int theInsRowId );
105   void                                initSelection( const int theRowId, const int theColId );
106   void                                Added( const int theRowId );
107   void                                Removed( const int theRowId );
108
109 private slots: 
110  
111   /*! SLOT which called when button Up is pressed.
112       Moves up the selected row by one row.
113    */
114   void                                onUp(); 
115
116   /*! SLOT which called when button Down is pressed.
117       Moves down the selected row by one row.
118    */
119   void                                onDown(); 
120
121   /*! SLOT which called when button Insert is pressed.
122       Adds new row before selected.
123    */
124   void                                onInsert(); 
125
126   /*! SLOT which called when button Select is pressed.
127       Emits the signal to start the selection in the tree.
128       The selected object have to be put into the current cell.
129    */
130   void                                onSelect( bool ); 
131
132   /*! SLOT which called when button Add is pressed.
133       Adds new string at table's bottom.
134    */
135   void                                onAdd();  
136
137   /*! SLOT which called when button Remove is pressed.
138       Removed selected row from table.
139    */
140   void                                onRemove(); 
141
142   /*! SLOT which called whenever a selection in the table changes
143       or the current cell has changed.
144       Apdated the enable/disable states of the tool buttons.
145    */
146   void                                onTableSelectionChanged();
147  
148 private: 
149   int                                 myMinNumRow;
150   int                                 myMaxNumRow;
151   int                                 myAddBeforeRowNum;
152   
153   YACSGui_Table*                      myTable; 
154   QToolButton*                        myAddBtn; 
155   QToolButton*                        myInsertBtn; 
156   QToolButton*                        myRemoveBtn; 
157   QToolButton*                        myUpBtn; 
158   QToolButton*                        myDownBtn; 
159   QToolButton*                        mySelectBtn;
160 }; 
161  
162 #endif