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 XGUI_PROPERTYPANEL_H_
22 #define XGUI_PROPERTYPANEL_H_
26 #include <ModuleBase_ModelWidget.h>
27 #include <ModuleBase_IPropertyPanel.h>
31 class XGUI_ActionsMgr;
35 class ModuleBase_PageBase;
36 class ModuleBase_PageWidget;
37 class XGUI_OperationMgr;
39 /// Internal name of property panel widget
40 const static char* PROP_PANEL = "property_panel_dock";
42 /// Internal name of Ok button
43 const static char* PROP_PANEL_OK = "property_panel_ok";
45 /// Internal name of Ok button
46 const static char* PROP_PANEL_OK_PLUS = "property_panel_ok_plus";
48 /// Internal name of Cancel button
49 const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
51 /// Internal name of Help button
52 const static char* PROP_PANEL_HELP = "property_panel_help";
54 /// Internal name of Preview button
55 const static char* PROP_PANEL_PREVIEW = "property_panel_preview";
59 * Realization of Property panel object.
61 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
67 /// \param theParent is a parent of the property panel
68 /// \param theMgr operation manager
69 XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr);
71 virtual ~XGUI_PropertyPanel();
73 /// Returns header widget
74 virtual QWidget* headerWidget() const { return myHeaderWidget; }
76 /// Returns main widget of the property panel, which children will be created
77 /// by WidgetFactory using the XML definition
78 ModuleBase_PageBase* contentWidget();
80 /// Brings back all widget created by widget factory for signal/slot
81 /// connections and further processing
82 void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
84 /// Returns all property panel's widget created by WidgetFactory
85 virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
87 /// Removes all widgets in the widget area of the property panel
88 virtual void cleanContent();
90 /// Returns currently active widget. This is a widget from internal container of widgets
91 /// (myWidgets) activated/deactivated by focus in property panel. If parameter is true,
92 /// the method finds firstly the custom widget, after the direct active widget.
93 /// \param isUseCustomWidget boolean state if the custom widget might be a result
94 virtual ModuleBase_ModelWidget* activeWidget(const bool isUseCustomWidget = false) const;
96 /// Activate the next widget in the property panel
97 /// \param theWidget a widget. The next widget should be activated
98 virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
100 /// Activate the next from current widget in the property panel
101 virtual void activateNextWidget();
103 /// Set focus on the Ok button
104 virtual void setFocusOnOkButton();
106 /// Set Enable/Disable state of Cancel button
107 /// \param theEnabled Enable/Disable state of Cancel button
108 virtual void setCancelEnabled(bool theEnabled);
110 /// \return Enable/Disable state of Cancel button
111 virtual bool isCancelEnabled() const;
113 /// Editing mode depends on mode of current operation. This value is defined by it.
114 /// \param isEditing state of editing mode flag
115 virtual void setEditingMode(bool isEditing);
117 //! Allows to set predefined actions for the property panel fetched from the ActionsMgr
118 void setupActions(XGUI_ActionsMgr* theMgr);
120 /// Returns widget processed by preselection
121 virtual ModuleBase_ModelWidget* preselectionWidget() const;
123 /// Sets widget processed by preselection
124 virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget);
126 /// Returns operation manager
127 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
129 /// Find under the panel a child button with the parameter name
130 /// \param theInternalName a button object name
131 /// \return button instance or NULL
132 QToolButton* findButton(const char* theInternalName) const;
134 /// Possibility to process focus by method, for example when Tab or SHIF+Tab is pressed
135 /// but property panel is not active widget
136 /// \param theIsNext true, if Tab(to the next widget) or false(moving to the previous)
137 bool setFocusNextPrevChild(bool theIsNext);
139 /// The method is called on accepting of operation
140 virtual void onAcceptData();
142 /// Set internal active widget, that can be returned as active widget and participate in active
143 /// selection filters/modes in application. It emits signal about property panel activation or
144 /// deactivation and updates selection filters/modes accordingly.
145 /// \param theWidget a widget control to store as internal active widget
146 void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget);
149 /// \brief Update all widgets in property panel with values from the given feature
150 /// \param theFeature a Feature to update values in widgets
151 void updateContentWidget(FeaturePtr theFeature);
153 /// \brief If the XML definition of the feature contains information about specific
154 /// content of the property panel, it creates the panel and allow filling it by the given feature
155 /// \param theFeature a Feature to fill property panel
156 void createContentPanel(FeaturePtr theFeature);
159 * Makes the given widget active, highlights it and removes
160 * highlighting from the previous active widget
161 * \param theWidget which has to be activated
162 * \param theEmitSignal a flag to prohibit signal emit
164 virtual void activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal = true);
166 /// Activates the parameter widget if it can accept focus
167 /// \param theWidget a widget where focus in event happened
168 void onFocusInWidget(ModuleBase_ModelWidget* theWidget);
171 /// Activate next widget
172 /// \param theWidget the current widget
173 void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
176 /// The signal is emitted if the enter is clicked in the control of the widget
177 /// \param theObject a sender of the event
178 void enterClicked(QObject* theObject);
180 /// Emits on deactivating property panel (e.g. by clearContent)
181 void propertyPanelDeactivated();
182 /// Emits on widget activating
183 void propertyPanelActivated();
186 /// Makes the widget active, deactivate the previous, activate and hightlight the given one
187 /// \param theWidget a widget
188 /// \param isEmitSignal flag whether panel signals should be emitted
189 bool setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal);
190 /// The parent method that processes the "Tab"/"SHIF + Tab" keyboard events
191 /// Emits a signal about focus change
192 /// If theIsNext is true, this function searches forward, if next is false, it searches backward.
193 virtual bool focusNextPrevChild(bool theIsNext);
194 /// Activate the next widget in the property panel
195 /// \param theWidget a widget. The next widget should be activated
196 /// \param isCheckVisibility flag whether the next widget visibility is checked
197 void activateNextWidget(ModuleBase_ModelWidget* theWidget,
198 const bool isCheckVisibility);
201 /// A method called on the property panel closed
202 /// \param theEvent a close event
203 void closeEvent(QCloseEvent* theEvent);
206 QWidget* myHeaderWidget; ///< A header widget
208 ModuleBase_PageWidget* myPanelPage;
209 QList<ModuleBase_ModelWidget*> myWidgets;
211 /// Currently active widget
212 ModuleBase_ModelWidget* myActiveWidget;
213 /// Currently widget processed by preselection
214 ModuleBase_ModelWidget* myPreselectionWidget;
215 /// Some custom widget set from outside
216 ModuleBase_ModelWidget* myInternalActiveWidget;
218 XGUI_OperationMgr* myOperationMgr;
221 #endif /* XGUI_PROPERTYPANEL_H_ */