Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetSwitch.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModuleBase_WidgetSwitch.h
5  *
6  *  Created on: Apr 16, 2014
7  *      Author: sbh
8  */
9
10 #ifndef ModuleBase_WidgetSwitch_H_
11 #define ModuleBase_WidgetSwitch_H_
12
13 #include <ModuleBase.h>
14 #include <QFrame>
15
16 class QComboBox;
17 class QVBoxLayout;
18
19 /**
20 * \ingroup GUI
21 * Implements a model widget for swithch as a container widget. It can be defined in XML with "switch" keyword
22 */
23 class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public QFrame
24 {
25 Q_OBJECT
26  public:
27    /// Constructor
28    /// \param parent a parent widget
29   ModuleBase_WidgetSwitch(QWidget* parent = NULL);
30   virtual ~ModuleBase_WidgetSwitch();
31
32   /// Add a page to the widget
33   /// \param theWidget a page widget
34   /// \param theName a name of page
35   int addPage(QWidget * theWidget, const QString & theName);
36
37   /// Returns count of pages
38   int count() const;
39
40   /// Returns index of current page
41   int currentIndex() const;
42
43   /// Returns current widget (page)
44   QWidget * currentWidget() const;
45
46   /// Returns index of widget (page)
47   /// \param theWidget a widget page
48   int indexOf(QWidget * theWidget) const;
49
50   /// Insert page
51   /// \param index an index (position) to insert 
52   /// \param theWidget a page widget
53   /// \param theName a name of the page
54   int insertPage(int index, QWidget * theWidget, const QString & theName);
55
56   /// Returns True if a page by given index is enabled
57   /// \param index index of the page
58   bool isPageEnabled(int index) const;
59
60   /// Returns text of the page by its id
61   /// \param index index of the page
62   QString pageText(int index) const;
63
64   /// Returns tooltip of the page by its id
65   /// \param index index of the page
66   QString pageToolTip(int index) const;
67
68   /// Remove page by its id
69   /// \param index index of the page
70   void removePage(int index);
71
72   /// Enale/disable a page by its Id
73   /// \param index index of the page
74   /// \param enabled an enable flag
75   void setPageEnabled(int index, bool enabled);
76
77   /// Set page name
78   /// \param index index of the page
79   /// \param text a name of the page
80   void setPageName(int index, const QString & text);
81
82   /// Set page tooltip
83   /// \param index index of the page
84   /// \param toolTip a tooltip of the page
85   void setPageToolTip(int index, const QString & toolTip);
86
87  public slots:
88    /// Set current page by index
89   /// \param index index of the page
90   void setCurrentIndex(int index);
91
92 signals:
93   /// Emitted on current page change
94   void currentPageChanged(int);
95
96  protected:
97   /// Update widget
98   void refresh();
99
100  private:
101    /// Layout
102   QVBoxLayout* myMainLay;
103
104   /// Combo box
105   QComboBox* myCombo;
106
107   /// List of pages
108   QWidgetList myCases;
109 };
110
111 #endif /* ModuleBase_WidgetSwitch_H_ */