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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
23 * Created on: Apr 1, 2014
27 #ifndef CONFIG_WIDGETAPI_H_
28 #define CONFIG_WIDGETAPI_H_
30 #include <Config_def.h>
35 //>> Forward declaration of xmlNodePtr.
36 typedef struct _xmlNode xmlNode;
37 typedef xmlNode *xmlNodePtr;
41 //>> Forward declaration of xmlDocPtr.
42 typedef struct _xmlDoc xmlDoc;
43 typedef xmlDoc *xmlDocPtr;
48 * \class Config_WidgetAPI
50 * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
52 class Config_WidgetAPI
55 CONFIG_EXPORT virtual ~Config_WidgetAPI();
57 //! Returns name of widget's node (attribute)
58 CONFIG_EXPORT std::string widgetType() const;
59 //! Returns true if widget has container type, which means it able to contain other widgets
60 CONFIG_EXPORT bool isGroupBoxWidget() const;
61 //! Returns true if widget has page type;
62 //! Page is container widget with combo box control to switch between pages
63 CONFIG_EXPORT bool isPagedWidget() const;
65 //! Returns id of current feature
66 CONFIG_EXPORT std::string featureId() const;
67 //! Returns id of current widget
68 CONFIG_EXPORT std::string widgetId() const;
69 //! Returns icon of current widget
70 CONFIG_EXPORT std::string widgetIcon() const;
71 //! Returns text for label of current widget
72 CONFIG_EXPORT std::string widgetLabel() const;
73 //! Returns text for tooltip of current widget
74 CONFIG_EXPORT std::string widgetTooltip() const;
75 //! Returns a custom property of current widget
76 CONFIG_EXPORT std::string getProperty(const char* thePropName) const;
78 /*! Checks if the XML representation of widget has given attribute,
79 * if yes - returns it's bool value, if no, or if the value can not
80 * be converted to bool - returns theDefault.
81 * \param theAttributeName attribute to check
82 * \param theDefault default value on bad data
83 * \return the boolean result
85 CONFIG_EXPORT bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
88 /// These fields are accessible for ModuleBase_WidgetFactory only
89 CONFIG_EXPORT Config_WidgetAPI(std::string theRawXml);
90 //! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
91 CONFIG_EXPORT bool toNextWidget();
92 //! Pass into the child node of widget's xml definition. If impossible, returns false
93 CONFIG_EXPORT bool toChildWidget();
94 //! Pass into the parent node of widget's xml definition. If impossible, returns false
95 CONFIG_EXPORT bool toParentWidget();
98 xmlDocPtr myDoc; //!< Pointer to the root of widget's xml definition
99 xmlNodePtr myCurrentNode; //!< Pointer to the current node in the widget's xml definition
100 std::string myFeatureId;
102 friend class ModuleBase_WidgetFactory;
105 #endif /* CONFIG_WIDGETAPI_H_ */