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