Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / ModuleBase / ModuleBase_ToolBox.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF 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, or (at your option) any later version.
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/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_ToolBox_H
22 #define ModuleBase_ToolBox_H
23
24 #include <ModuleBase.h>
25 #include <QFrame>
26
27 class QButtonGroup;
28 class QFrame;
29 class QHBoxLayout;
30 class QStackedWidget;
31 class ModuleBase_ModelWidget;
32
33 /**
34  * \class ModuleBase_ToolBox
35  * \ingroup GUI
36  * \brief An extension of QFrame object
37  */
38 class MODULEBASE_EXPORT ModuleBase_ToolBox : public QFrame
39 {
40   Q_OBJECT
41
42 public:
43   /// Constructor
44   /// \param theParent a parent widget
45   /// \param theUseFrameStyleBox a flag if the tool box should have box covered
46   /// buttons and current page
47   ModuleBase_ToolBox(QWidget* theParent, const bool theUseFrameStyleBox = false);
48   virtual ~ModuleBase_ToolBox();
49
50   ///  Add a new item to the tool box
51   /// \param thePage a widget of the new item
52   /// \param theName a name of the item
53   /// \param theIcon an icon of the item
54   void addItem(QWidget* thePage, const QString& theName, const QPixmap& theIcon);
55
56   /// \return number of items
57   int count() const;
58
59   /// \return index of current widget
60   int currentIndex() const;
61
62   /// Set current item
63   /// \param theIdx an index
64   void setCurrentIndex(const int theIdx);
65
66   /// Found in the controls of the model widget parent in Stacked Widget
67   /// returns whether this controls are in the current widget of the stacked widgets
68   /// \param theWidget a model widget
69   /// \return boolean result
70   static bool isOffToolBoxParent(ModuleBase_ModelWidget* theWidget);
71
72 signals:
73   /// A signal which is emited on current item changed
74   void currentChanged(int);
75
76 private slots:
77   /// A slot called on button press
78   void onButton(int);
79
80 private:
81   QButtonGroup*   myButtonsGroup;
82   QFrame*         myButtonsFrame;
83   QHBoxLayout*    myButtonsLayout;
84   QStackedWidget* myStack;
85 };
86 #endif