Salome HOME
Update classes documentation
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetChoice.h
4 // Created:     03 Sept 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ModuleBase_WidgetChoice_H
8 #define ModuleBase_WidgetChoice_H
9
10 #include "ModuleBase.h"
11 #include "ModuleBase_ModelWidget.h"
12
13 class QWidget;
14 class QLabel;
15 class QComboBox;
16 class QButtonGroup;
17
18 /**
19 * \ingroup GUI
20 * Implementation of model widget for choice widget definition (combo box)
21 * It can be defined as following:
22 * \code
23 *   <choice id="bool_type" 
24 *     label="Type" 
25 *     tooltip="Type of boolean operation"
26 *     string_list="Cut Fuse Common Smash"
27 *   />
28 * \endcode
29 * Aditionally can be used: 
30 * A key "widget_type". It can have values "combobox" or "radiobuttons".
31 * By default it uses "combobox".
32 * A key "buttons_dir" which is applicable only for "radiobuttons" mode.
33 * It defines direction of radiobuttons layout. it can be "vertical" or "horizontal"
34 * Default value is "vertical"
35 */
36 class MODULEBASE_EXPORT ModuleBase_WidgetChoice : public ModuleBase_ModelWidget
37 {
38 Q_OBJECT
39  public:
40   /// Constructor
41   /// \param theParent the parent object
42   /// \param theData the widget configuation. The attribute of the model widget is obtained from
43   ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData);
44
45   virtual ~ModuleBase_WidgetChoice();
46
47   /// Defines if it is supported to set the value in this widget
48   /// It returns false because this is an info widget
49   virtual bool canAcceptFocus() const { return false; };
50
51   virtual bool focusTo();
52
53   /// Returns list of widget controls
54   /// \return a controls list
55   virtual QList<QWidget*> getControls() const;
56
57   /// Returns text value for the property panel title
58   /// \param theIndex a button index
59   /// \return the title value
60   QString getPropertyPanelTitle(int theIndex);
61
62 signals:
63   /// Segnal about selected item
64   /// \param theWidget selected widget
65   /// \param theIndex selected index
66   void itemSelected(ModuleBase_ModelWidget* theWidget, int theIndex);
67
68 protected:
69   /// Saves the internal parameters to the given feature
70   /// \return True in success
71   virtual bool storeValueCustom();
72
73   virtual bool restoreValueCustom();
74
75 private slots:
76   /// Slot called on combo box index change
77   void onCurrentIndexChanged(int theIndex);
78
79 private:
80   /// The label
81   QLabel* myLabel;
82
83   /// The control
84   QComboBox* myCombo;
85   QButtonGroup* myButtons;
86
87   // XML definition of titles
88   QStringList myButtonTitles;
89 };
90
91 #endif