X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetChoice.h;h=742a4cea08e33dbe0f70eca151984339f704ffe5;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=15a95054eb8662cc2ef192c7a2b3ee867ab99a31;hpb=ba737434252ae41c4bee1b792a0f0bb098ffae87;p=modules%2Fshaper.git
diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.h b/src/ModuleBase/ModuleBase_WidgetChoice.h
index 15a95054e..742a4cea0 100644
--- a/src/ModuleBase/ModuleBase_WidgetChoice.h
+++ b/src/ModuleBase/ModuleBase_WidgetChoice.h
@@ -1,6 +1,21 @@
-// File: ModuleBase_WidgetChoice.h
-// Created: 03 Sept 2014
-// Author: Vitaly Smetannikov
+// Copyright (C) 2014-2023 CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#ifndef ModuleBase_WidgetChoice_H
#define ModuleBase_WidgetChoice_H
@@ -9,44 +24,82 @@
#include "ModuleBase_ModelWidget.h"
class QWidget;
-class QLabel;
-class QComboBox;
+class ModuleBase_ChoiceCtrl;
+/**
+* \ingroup GUI
+* Implementation of model widget for choice widget definition (combo box)
+* It can be defined as following:
+* \code
+*
+* \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 getControls() const;
+ /// Returns text value for the property panel title
+ /// \param theIndex a button index
+ /// \return the title value
+ QString getPropertyPanelTitle(int theIndex);
+
+ /// The slot is called when user press Ok or OkPlus buttons in the parent property panel
+ virtual void onFeatureAccepted();
+
+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;
- QLabel* myLabel;
- QComboBox* myCombo;
+ ModuleBase_ChoiceCtrl* myChoiceCtrl;
+
+ // XML definition of titles
+ QStringList myButtonTitles;
+ std::string myStringListAttribute;
+
+ bool myIsFirst;
+ int myDefValue;
+ bool myHasValue;
};
#endif