1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 * Created on: Apr 1, 2014
10 #ifndef CONFIG_WIDGETAPI_H_
11 #define CONFIG_WIDGETAPI_H_
13 #include <Config_def.h>
19 //>> Forward declaration of xmlNodePtr.
20 typedef struct _xmlNode xmlNode;
21 typedef xmlNode *xmlNodePtr;
25 //>> Forward declaration of xmlDocPtr.
26 typedef struct _xmlDoc xmlDoc;
27 typedef xmlDoc *xmlDocPtr;
32 * \class Config_WidgetAPI
34 * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
36 class CONFIG_EXPORT Config_WidgetAPI
39 virtual ~Config_WidgetAPI();
41 //! Returns name of widget's node (attribute)
42 std::string widgetType() const;
43 //! Returns true if widget has container type, which means it able to contain other widgets
44 bool isGroupBoxWidget() const;
45 //! Returns true if widget has page type;
46 //! Page is container widget with combo box control to switch between pages
47 bool isPagedWidget() const;
49 //! Returns id of current widget
50 std::string widgetId() const;
51 //! Returns icon of current widget
52 std::string widgetIcon() const;
53 //! Returns text for label of current widget
54 std::string widgetLabel() const;
55 //! Returns text for tooltip of current widget
56 std::string widgetTooltip() const;
57 //! Returns a custom property of current widget
58 std::string getProperty(const char* thePropName) const;
60 /*! Returns a list of attributes.
61 * If theRole is 0 then returns all attributes.
62 * If theRole is "main" then returns widgetId().
64 std::list<std::string> getAttributes(const std::string& theRole = std::string()) const;
65 //! Returns a custom property of attribute
66 std::string getAttributeProperty(const std::string& theAttribute,
67 const std::string& thePropName) const;
69 /*! Checks if the XML representation of widget has given attribute,
70 * if yes - returns it's bool value, if no, or if the value can not
71 * be converted to bool - returns theDefault.
72 * \param theAttributeName attribute to check
73 * \param theDefault default value on bad data
74 * \return the boolean result
76 bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
79 /// These fields are accessible for ModuleBase_WidgetFactory only
80 Config_WidgetAPI(const std::string& theRawXml);
81 //! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
83 //! Pass into the child node of widget's xml definition. If impossible, returns false
85 //! Pass into the parent node of widget's xml definition. If impossible, returns false
86 bool toParentWidget();
88 std::list<xmlNodePtr> attributes() const;
91 xmlDocPtr myDoc; //!< Pointer to the root of widget's xml definition
92 xmlNodePtr myCurrentNode; //!< Pointer to the current node in the widget's xml definition
94 friend class ModuleBase_WidgetFactory;
97 #endif /* CONFIG_WIDGETAPI_H_ */