Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.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_WidgetChoice_H
22 #define ModuleBase_WidgetChoice_H
23
24 #include "ModuleBase.h"
25 #include "ModuleBase_ModelWidget.h"
26
27 class QWidget;
28 class ModuleBase_ChoiceCtrl;
29
30 /**
31 * \ingroup GUI
32 * Implementation of model widget for choice widget definition (combo box)
33 * It can be defined as following:
34 * \code
35 *   <choice id="bool_type" 
36 *     label="Type" 
37 *     tooltip="Type of boolean operation"
38 *     string_list="Cut Fuse Common Smash"
39 *   />
40 * \endcode
41 * Aditionally can be used: 
42 * A key "widget_type". It can have values "combobox" or "radiobuttons".
43 * By default it uses "combobox".
44 * A key "buttons_dir" which is applicable only for "radiobuttons" mode.
45 * It defines direction of radiobuttons layout. it can be "vertical" or "horizontal"
46 * Default value is "vertical"
47 */
48 class MODULEBASE_EXPORT ModuleBase_WidgetChoice : public ModuleBase_ModelWidget
49 {
50 Q_OBJECT
51  public:
52   /// Constructor
53   /// \param theParent the parent object
54   /// \param theData the widget configuation. The attribute of the model widget is obtained from
55   ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData);
56
57   virtual ~ModuleBase_WidgetChoice();
58
59   /// Defines if it is supported to set the value in this widget
60   /// It returns false because this is an info widget
61   virtual bool canAcceptFocus() const { return false; };
62
63   virtual bool focusTo();
64
65   /// Returns list of widget controls
66   /// \return a controls list
67   virtual QList<QWidget*> getControls() const;
68
69   /// Returns text value for the property panel title
70   /// \param theIndex a button index
71   /// \return the title value
72   QString getPropertyPanelTitle(int theIndex);
73
74 signals:
75   /// Segnal about selected item
76   /// \param theWidget selected widget
77   /// \param theIndex selected index
78   void itemSelected(ModuleBase_ModelWidget* theWidget, int theIndex);
79
80 protected:
81   /// Saves the internal parameters to the given feature
82   /// \return True in success
83   virtual bool storeValueCustom();
84
85   virtual bool restoreValueCustom();
86
87 private slots:
88   /// Slot called on combo box index change
89   void onCurrentIndexChanged(int theIndex);
90
91 private:
92   /// The label
93   //QLabel* myLabel;
94
95   /// The control
96   //QComboBox* myCombo;
97   //QButtonGroup* myButtons;
98   ModuleBase_ChoiceCtrl* myChoiceCtrl;
99
100   // XML definition of titles
101   QStringList myButtonTitles;
102   std::string myStringListAttribute;
103 };
104
105 #endif