1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModuleBase_WidgetEditor_H
22 #define ModuleBase_WidgetEditor_H
24 #include <ModuleBase.h>
25 #include "ModuleBase_WidgetDoubleValue.h"
28 #include <QStringList>
30 class ModelAPI_Feature;
34 /**\class ModuleBase_WidgetEditor
36 * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
38 class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_WidgetDoubleValue
43 /// \param theParent the parent object
44 /// \param theData the widget configuation. The attribute of the model widget is obtained from
45 ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
47 /// \param theParent the parent object
48 /// \param theAttribute The attribute of the model widget
49 ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute);
52 virtual ~ModuleBase_WidgetEditor();
54 /// Set focus to the first control of the current widget.
55 /// The focus policy of the control is checked.
56 /// If the widget has the NonFocus focus policy, it is skipped.
57 /// \return the state whether the widget can accept the focus
58 virtual bool focusTo();
60 /// Shous popup window under cursor for data editing
61 /// \param theSendSignals a flag whether the signals should be sent or the value
62 /// is to be applyed directly
63 /// \return true if the editor value is accepted
64 bool showPopupEditor(const bool theSendSignals = true);
66 /// Set current cursor position
67 /// \param theX the X coordinate
68 /// \param theY the Y coordinate
69 void setCursorPosition(const int theX, const int theY);
72 /// Returns true if the event is processed.
73 virtual bool processEnter();
75 /// Reject the current editor dialog if it is shown and returns true.
76 virtual bool processEscape();
80 /// \param theSpinMinValue a minimal value of popup menu spin box
81 /// \param theSpinMaxValue a maximum value of popup menu spin box
82 /// \param theOutValue a result value
83 /// \param theOutText a result text
84 /// \return true if the editor value is accepted
85 bool editedValue(double theSpinMinValue, double theSpinMaxValue,
86 double& theOutValue, QString& theOutText);
89 ///< the current widget feature
92 ///< the kinds of possible features
93 QStringList myFeatureKinds;
95 int myXPosition, myYPosition;
97 QDialog* myEditorDialog;