1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: ModuleBase_WidgetOptionalBox.h
4 // Created: 13 Dec 2015
5 // Author: Natalia ERMOLAEVA
7 #ifndef ModuleBase_WidgetOptionalBox_H_
8 #define ModuleBase_WidgetOptionalBox_H_
10 #include <ModuleBase.h>
11 #include <ModuleBase_PageBase.h>
12 #include <ModuleBase_ModelWidget.h>
23 * Implements a model widget for switch as a container widget. It can be defined in XML with "toolbox" keyword
25 class MODULEBASE_EXPORT ModuleBase_WidgetOptionalBox : public ModuleBase_ModelWidget,
26 public ModuleBase_PageBase
30 enum OptionType {CheckBox, GroupBox};
33 /// \param theParent the parent object
34 /// \param theData the widget configuration. The attribute of the model widget is obtained from
35 ModuleBase_WidgetOptionalBox(QWidget* theParent, const Config_WidgetAPI* theData);
36 virtual ~ModuleBase_WidgetOptionalBox();
38 /// Defines if it is supported to set the value in this widget
39 /// \return false because this is an info widget
40 virtual bool canAcceptFocus() const { return false; };
42 /// Methods to be redefined from ModuleBase_PageBase: start
43 /// Cast the page to regular QWidget
44 virtual QWidget* pageWidget();
45 /// Methods to be redefined from ModuleBase_PageBase: end
47 /// Methods to be redefined from ModuleBase_ModelWidget: start
48 /// Returns list of widget controls
49 /// \return a control list
50 virtual QList<QWidget*> getControls() const;
51 /// Methods to be redefined from ModuleBase_ModelWidget: end
54 // store value to the model
58 /// Methods to be redefined from ModuleBase_PageBase: start
59 /// Adds the given widget to page's layout
60 virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
61 /// Adds the given page to page's layout
62 virtual void placeWidget(QWidget* theWidget);
63 /// Returns page's layout (QGridLayout)
64 virtual QLayout* pageLayout();
65 /// Adds a stretch to page's layout
66 virtual void addPageStretch();
67 /// Methods to be redefined from ModuleBase_PageBase: end
70 /// Methods to be redefined from ModuleBase_ModelWidget: start
71 /// Saves the internal parameters to the given feature
72 /// \return True in success
73 virtual bool storeValueCustom();
74 /// Restore value from attribute data to the widget's control
75 virtual bool restoreValueCustom();
76 /// Methods to be redefined from ModuleBase_ModelWidget: end
79 /// Sets whether Check box or Group box is used currently
80 /// \param theType a type of the control
81 void setOptionType(const OptionType& theType);
83 /// Returns true if the model widget is set into the check box frame
84 /// \return boolean value
85 bool isCheckBoxFilled() const;
87 /// Creates controls for the given type if it was not perfomed yet
88 /// \param theType a type to create whether check box or group box controls
89 void createControl(const OptionType& theType);
91 /// Returns true if control is checked
92 /// \return boolean value
93 bool getCurrentValue() const;
95 /// Returns true if control is checked
96 /// \param theValue a new value to fill the control state
97 void setCurrentValue(const bool& theValue);
99 /// Makes model widget controls either disabled(for check box mode) or hidden(for group box mode)
100 void updateControlsVisibility();
103 std::string myToolTip; ///< tool tip defined in XML
104 std::string myGroupTitle; ///< a title for group box
106 OptionType myOptionType; ///< current option state
107 QVBoxLayout* myMainLayout; ///< the main layout
108 // controls to fill check box frame
109 QFrame* myCheckBoxFrame; ///< frame with check box, to be hidden when group box is used
110 QCheckBox* myCheckBox; ///< control used if only one model widget is placed inside
111 QHBoxLayout* myCheckBoxLayout; ///< layout of check box frame
112 ModuleBase_ModelWidget* myCheckBoxWidget; /// model widget, placed in the check box frame
113 // controls to fill group box frame
114 QGroupBox* myGroupBox; ///< control used if more than model widget is placed inside
115 QGridLayout* myGroupBoxLayout; ///< page's layout
118 #endif /* ModuleBase_WidgetOptionalBox_H_ */