SHAPER  9.12.0
ModuleBase_WidgetOptionalBox.h
1 // Copyright (C) 2014-2023 CEA, EDF
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_WidgetOptionalBox_H_
21 #define ModuleBase_WidgetOptionalBox_H_
22 
23 #include <ModuleBase.h>
24 #include <ModuleBase_PageBase.h>
25 #include <ModuleBase_ModelWidget.h>
26 
27 class QGroupBox;
28 class QFrame;
29 class QCheckBox;
30 class QVBoxLayout;
31 class QHBoxLayout;
32 class QGridLayout;
33 
38 class MODULEBASE_EXPORT ModuleBase_WidgetOptionalBox : public ModuleBase_ModelWidget,
39  public ModuleBase_PageBase
40 {
41  Q_OBJECT
42 
43  enum OptionType {CheckBox, GroupBox};
44 public:
48  ModuleBase_WidgetOptionalBox(QWidget* theParent, const Config_WidgetAPI* theData);
50 
53  virtual bool canAcceptFocus() const { return false; };
54 
57  virtual QWidget* pageWidget();
59 
63  virtual QList<QWidget*> getControls() const;
65 
66 protected slots:
67  // store value to the model
68  void onPageClicked();
69 
70 protected:
73  virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
75  virtual void placeWidget(QWidget* theWidget);
77  virtual QLayout* pageLayout();
79  virtual void addPageStretch();
81 
82 
86  virtual bool storeValueCustom();
88  virtual bool restoreValueCustom();
90 
91 private:
94  void setOptionType(const OptionType& theType);
95 
98  bool isCheckBoxFilled() const;
99 
102  void createControl(const OptionType& theType);
103 
106  bool getCurrentValue() const;
107 
110  void setCurrentValue(const bool& theValue);
111 
113  void updateControlsVisibility();
114 
115  bool toEnableWidgets() const;
116 
117 private:
118  std::string myToolTip;
119  std::string myGroupTitle;
120 
121  OptionType myOptionType;
122  QVBoxLayout* myMainLayout;
123  // controls to fill check box frame
124  QWidget* myCheckBoxFrame;
125  QCheckBox* myCheckBox;
126  QHBoxLayout* myCheckBoxLayout;
127  ModuleBase_ModelWidget* myCheckBoxWidget;
128  // controls to fill group box frame
129  QGroupBox* myGroupBox;
130  QGridLayout* myGroupBoxLayout;
131 
132  QWidget* myCheckGroup;
133  QCheckBox* myCheckGroupBtn;
134  QWidget* myCheckContent;
135  QVBoxLayout* myCheckGroupLayout;
136 
137  bool myHaveFrame;
138  bool myEnableOnCheck;
139  bool myAlwaysShowTitle;
140 };
141 
142 #endif /* ModuleBase_WidgetOptionalBox_H_ */
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
virtual QList< QWidget * > getControls() const =0
Returns list of widget controls.
virtual bool storeValueCustom()=0
Saves the internal parameters to the given feature.
virtual bool restoreValueCustom()=0
Restore value from attribute data to the widget's control.
Definition: ModuleBase_PageBase.h:35
virtual void placeModelWidget(ModuleBase_ModelWidget *theWidget)=0
Pure Virtual. Allows to derived class to lay out the widget properly;.
virtual void addPageStretch()=0
Pure Virtual. Allows to derived class to insert page stretch properly.
virtual QLayout * pageLayout()=0
Pure Virtual. Returns layout of the page.
QWidget * pageWidget()
Cast the page to regular QWidget.
Definition: ModuleBase_PageBase.cpp:37
virtual void placeWidget(QWidget *theWidget)=0
Pure Virtual. Allows to derived class to lay out the page properly;.
Implements a model widget for switch as a container widget.
Definition: ModuleBase_WidgetOptionalBox.h:40
virtual bool canAcceptFocus() const
Defines if it is supported to set the value in this widget.
Definition: ModuleBase_WidgetOptionalBox.h:53