Salome HOME
Update classes documentation
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetChoice.h
index 99bd281f9505ac5e8a1ee1e4663841551f6832f3..f88a56e7f57690911f73070c5f8a469ab484a7fc 100644 (file)
 class QWidget;
 class QLabel;
 class QComboBox;
+class QButtonGroup;
 
+/**
+* \ingroup GUI
+* Implementation of model widget for choice widget definition (combo box)
+* It can be defined as following:
+* \code
+*   <choice id="bool_type" 
+*     label="Type" 
+*     tooltip="Type of boolean operation"
+*     string_list="Cut Fuse Common Smash"
+*   />
+* \endcode
+* Aditionally can be used: 
+* A key "widget_type". It can have values "combobox" or "radiobuttons".
+* By default it uses "combobox".
+* A key "buttons_dir" which is applicable only for "radiobuttons" mode.
+* It defines direction of radiobuttons layout. it can be "vertical" or "horizontal"
+* Default value is "vertical"
+*/
 class MODULEBASE_EXPORT ModuleBase_WidgetChoice : public ModuleBase_ModelWidget
 {
 Q_OBJECT
  public:
-  ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData, 
-                          const std::string& theParentId);
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from
+  ModuleBase_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData);
 
   virtual ~ModuleBase_WidgetChoice();
-  
-  /// Saves the internal parameters to the given feature
-  /// \param theObject a model feature to be changed
-  virtual bool storeValue() const;
 
-  virtual bool restoreValue();
+  /// Defines if it is supported to set the value in this widget
+  /// It returns false because this is an info widget
+  virtual bool canAcceptFocus() const { return false; };
 
   virtual bool focusTo();
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const
-  {
-    return myContainer;
-  }
-
   /// Returns list of widget controls
-  /// \return a control list
+  /// \return a controls list
   virtual QList<QWidget*> getControls() const;
 
+  /// Returns text value for the property panel title
+  /// \param theIndex a button index
+  /// \return the title value
+  QString getPropertyPanelTitle(int theIndex);
+
+signals:
+  /// Segnal about selected item
+  /// \param theWidget selected widget
+  /// \param theIndex selected index
+  void itemSelected(ModuleBase_ModelWidget* theWidget, int theIndex);
+
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom();
+
+  virtual bool restoreValueCustom();
+
 private slots:
+  /// Slot called on combo box index change
   void onCurrentIndexChanged(int theIndex);
 
 private:
-  QWidget* myContainer;
+  /// The label
   QLabel* myLabel;
+
+  /// The control
   QComboBox* myCombo;
+  QButtonGroup* myButtons;
+
+  // XML definition of titles
+  QStringList myButtonTitles;
 };
 
 #endif