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