Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetEditor.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetEditor.h
4 // Created:     25 Apr 2014
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef ModuleBase_WidgetEditor_H
8 #define ModuleBase_WidgetEditor_H
9
10 #include <ModuleBase.h>
11 #include "ModuleBase_WidgetDoubleValue.h"
12
13 #include <QObject>
14 #include <QStringList>
15
16 class ModelAPI_Feature;
17 class QLineEdit;
18
19 /**\class ModuleBase_WidgetEditor
20  * \ingroup GUI
21  * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
22  */
23 class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_WidgetDoubleValue
24 {
25 Q_OBJECT
26  public:
27   /// Constructor
28   /// \param theParent the parent object
29   /// \param theData the widget configuation. The attribute of the model widget is obtained from
30   ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
31   /// Constructor
32   /// \param theParent the parent object
33   /// \param theAttribute The attribute of the model widget
34   ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute);
35
36   /// Destructor
37   virtual ~ModuleBase_WidgetEditor();
38
39   /// Set focus to the first control of the current widget.
40   /// The focus policy of the control is checked.
41   /// If the widget has the NonFocus focus policy, it is skipped.
42   /// \return the state whether the widget can accept the focus
43   virtual bool focusTo();
44
45   /// Shous popup window under cursor for data editing
46   /// \param theSendSignals a flag whether the signals should be sent or the value
47   /// is to be applyed directly
48   /// \return true if the editor value is accepted
49   bool showPopupEditor(const bool theSendSignals = true);
50
51   /// Set current cursor position
52   /// \param theX the X coordinate
53   /// \param theY the Y coordinate
54   void setCursorPosition(const int theX, const int theY);
55
56 private:
57   /// Show editor
58   /// \param theOutValue a result value
59   /// \param theOutText a result text
60   /// \return true if the editor value is accepted
61   bool editedValue(double& theOutValue, QString& theOutText);
62
63  private:
64    ///< the current widget feature
65    FeaturePtr myFeature;
66
67    ///< the kinds of possible features
68    QStringList myFeatureKinds;
69
70    int myXPosition, myYPosition;
71 };
72
73 #endif