1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ModuleBase_WidgetEditor_H
21 #define ModuleBase_WidgetEditor_H
23 #include <ModuleBase.h>
24 #include "ModuleBase_WidgetDoubleValue.h"
27 #include <QStringList>
29 class ModelAPI_Feature;
33 /**\class ModuleBase_WidgetEditor
35 * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
37 class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_WidgetDoubleValue
42 /// \param theParent the parent object
43 /// \param theData the widget configuation. The attribute of the model widget is obtained from
44 ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
46 /// \param theParent the parent object
47 /// \param theAttribute The attribute of the model widget
48 ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute);
51 virtual ~ModuleBase_WidgetEditor();
53 /// Set focus to the first control of the current widget.
54 /// The focus policy of the control is checked.
55 /// If the widget has the NonFocus focus policy, it is skipped.
56 /// \return the state whether the widget can accept the focus
57 virtual bool focusTo();
59 /// Shous popup window under cursor for data editing
60 /// \param theSendSignals a flag whether the signals should be sent or the value
61 /// is to be applyed directly
62 /// \return true if the editor value is accepted
63 bool showPopupEditor(const bool theSendSignals = true);
65 /// Set current cursor position
66 /// \param theX the X coordinate
67 /// \param theY the Y coordinate
68 void setCursorPosition(const int theX, const int theY);
71 /// Returns true if the event is processed.
72 virtual bool processEnter();
74 /// Reject the current editor dialog if it is shown and returns true.
75 virtual bool processEscape();
79 /// \param theSpinMinValue a minimal value of popup menu spin box
80 /// \param theSpinMaxValue a maximum value of popup menu spin box
81 /// \param theOutValue a result value
82 /// \param theOutText a result text
83 /// \return true if the editor value is accepted
84 bool editedValue(double theSpinMinValue, double theSpinMaxValue,
85 double& theOutValue, QString& theOutText);
88 ///< the current widget feature
91 ///< the kinds of possible features
92 QStringList myFeatureKinds;
94 int myXPosition, myYPosition;
96 QDialog* myEditorDialog;