Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModuleBase / ModuleBase_IPropertyPanel.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_PROPERTYPANEL_H_
22 #define ModuleBase_PROPERTYPANEL_H_
23
24 #include "ModuleBase.h"
25
26 #include <QDockWidget>
27 #include <QKeyEvent>
28
29 class ModuleBase_ModelWidget;
30
31 /**
32 * \ingroup GUI
33 * A class for Property panel object definition
34 */
35 class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
36 {
37 Q_OBJECT
38 public:
39   /// Constructor
40   /// \param theParent is a parent of the property panel
41   ModuleBase_IPropertyPanel(QWidget* theParent);
42
43   /// Returns header widget
44   virtual QWidget* headerWidget() const = 0;
45
46   /// Returns currently active widget
47   virtual ModuleBase_ModelWidget* activeWidget() const = 0;
48
49   /// Returns all property panel's widget created by WidgetFactory
50   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
51
52   /// Returns widget, that has the given attribute index
53   /// \param theAttributeId an attribute from XML
54   virtual ModuleBase_ModelWidget* modelWidget(const std::string& theAttributeId) const;
55
56   /// Removes all widgets in the widget area of the property panel
57   virtual void cleanContent() = 0;
58
59   /// Editing mode depends on mode of current operation. This value is defined by it.
60   /// \param isEditing state of editing mode flag
61   virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
62
63   /// \return State of editing mode flag
64   bool isEditingMode() const { return myIsEditing; }
65
66   /// Set focus on the Ok button
67   virtual void setFocusOnOkButton() = 0;
68
69   /// Set Enable/Disable state of Cancel button
70   /// \param theEnabled Enable/Disable state of Cancel button
71   virtual void setCancelEnabled(bool theEnabled) = 0;
72
73   /// \return Enable/Disable state of Cancel button
74   virtual bool isCancelEnabled() const = 0;
75
76   /// Returns widget processed by preselection
77   virtual ModuleBase_ModelWidget* preselectionWidget() const = 0;
78
79   /// Sets widget processed by preselection
80   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget) = 0;
81
82   /// Returns the first widget, where canAcceptFocus returns true
83   /// \return a widget or null
84   ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
85
86   /// Returns the first widget, where canAcceptFocus returns true
87   /// \return a widget or null
88   static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
89                           const QList<ModuleBase_ModelWidget*>& theWidgets);
90
91 signals:
92   /// The signal about key release on the control, that corresponds to the attribute
93   /// \param theObject a sender of the event
94   /// \param theEvent key release event
95   void keyReleased(QObject* theObject, QKeyEvent* theEvent);
96
97   /// The signal about the widget activation
98   /// \param theWidget the activated widget
99   void beforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
100
101   /// The signal about the widget activation
102   /// \param theWidget the activated widget
103   void widgetActivated(ModuleBase_ModelWidget* theWidget);
104
105   /// Emited when there is no next widget
106   /// \param thePreviousAttributeID an attribute key of the previous active widget
107   void noMoreWidgets(const std::string& thePreviousAttributeID);
108
109 public slots:
110   /// Activate the next widget in the property panel
111   /// \param theWidget a widget. The next widget should be activated
112   virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget) = 0;
113
114   /// Activate the next from current widget in the property panel
115   virtual void activateNextWidget() = 0;
116
117   /**
118   * Makes the given widget active, highlights it and removes
119   * highlighting from the previous active widget
120   * emits widgetActivated(theWidget) signal
121   * \param theWidget which has to be activated
122   * \param theEmitSignal a flag to prohibit signal emit
123   */
124   virtual void activateWidget(ModuleBase_ModelWidget* theWidget,
125                               const bool theEmitSignal = true) = 0;
126
127 protected:
128
129   /// Flag which shows that current operation is in editing mode
130   bool myIsEditing;
131 };
132
133 #endif