Salome HOME
Place TableDlg into a separate unit GUITOOLS to make available using it in VISU_I
[modules/visu.git] / src / GUITOOLS / VisuGUI_TableDlg.h
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : VisuGUI_TableDlg.h
8 //  Author : Vadim SANDLER
9 //  Module : VISU
10
11 #ifndef VisuGUI_TABLE_DLG_H
12 #define VisuGUI_TABLE_DLG_H
13
14 #include <qdialog.h>
15 #include <qlineedit.h>
16 #include <qpushbutton.h>
17
18 class VisuGUI_Table;
19 class VisuGUI_TableWidget;
20
21 #include <SALOMEDSClient_SObject.hxx>
22
23 class VisuGUI_TableDlg : public QDialog
24
25   Q_OBJECT
26
27 public:
28
29   enum { ttNone, ttInt, ttReal, ttBoth, ttAuto };
30
31   VisuGUI_TableDlg( QWidget* parent, 
32                     _PTR(SObject) obj, 
33                     bool edit = false,
34                     int which = ttAuto, 
35                     Orientation orient = Horizontal,
36                     bool showColumnTitles = true );
37   ~VisuGUI_TableDlg();
38
39 public slots:
40   void onOK();
41
42 private:
43   void initDlg();
44
45 private:
46   VisuGUI_TableWidget*   myIntTable;
47   VisuGUI_TableWidget*   myRealTable;
48   QPushButton*           myOKBtn;
49   QPushButton*           myCancelBtn;
50
51   _PTR(SObject) myObject;
52 };
53  
54 class VisuGUI_TableWidget : public QWidget
55 {
56   Q_OBJECT
57 public:
58   VisuGUI_TableWidget( QWidget* parent = 0, 
59                        const char* name = 0, 
60                        bool edit = false, 
61                        Orientation orient = Horizontal,
62                        bool showColumnTitles = true );
63   ~VisuGUI_TableWidget();
64
65   void    setTableTitle( const QString& title );
66   QString getTableTitle();
67   void    setNumRows( const int num );
68   int     getNumRows();
69   void    setNumCols( const int num );
70   int     getNumCols();
71   void    setRowTitles( QStringList& tlts );
72   void    getRowTitles( QStringList& tlts );
73   void    setColTitles( QStringList& tlts );
74   void    getColTitles( QStringList& tlts );
75   void    setUnitsTitle( const QString& tlt );
76   void    setUnits( QStringList& units );
77   void    getUnits( QStringList& units );
78   void    setRowData( int row, QStringList& data );
79   void    getRowData( int row, QStringList& data );
80
81   VisuGUI_Table*   getTable()     { return myTable; } 
82   QLineEdit*       getTitleEdit() { return myTitleEdit; }
83
84   bool    eventFilter( QObject* o, QEvent* e);
85
86 public slots:
87   void updateButtonsState();
88   void addRow();
89   void addCol();
90   void delRow();
91   void delCol();
92   void adjustTable();
93   void selectAll();
94   void clearTable();
95
96 private:
97   QLineEdit*       myTitleEdit;
98   VisuGUI_Table*   myTable;
99   QPushButton*     myAddRowBtn;
100   QPushButton*     myAddColBtn;
101   QPushButton*     myDelRowBtn;
102   QPushButton*     myDelColBtn;
103   QPushButton*     myAdjustBtn;
104   QPushButton*     mySelectAllBtn;
105   QPushButton*     myClearBtn;
106   Orientation      myOrientation;
107 };
108
109 #endif // VisuGUI_TABLE_DLG_H
110