Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[modules/shaper.git] / src / Config / Config_WidgetAPI.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Config_WidgetAPI.h
5  *
6  *  Created on: Apr 1, 2014
7  *      Author: sbh
8  */
9
10 #ifndef CONFIG_WIDGETAPI_H_
11 #define CONFIG_WIDGETAPI_H_
12
13 #include <Config_def.h>
14
15 #include <cstdarg>
16 #include <string>
17
18 //>> Forward declaration of xmlNodePtr.
19 typedef struct _xmlNode xmlNode;
20 typedef xmlNode *xmlNodePtr;
21 struct _xmlNode;
22 //<<
23
24 //>> Forward declaration of xmlDocPtr.
25 typedef struct _xmlDoc xmlDoc;
26 typedef xmlDoc *xmlDocPtr;
27 struct _xmlDoc;
28 //<<
29
30 /*!
31  * \class Config_WidgetAPI
32  * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
33  */
34 class CONFIG_EXPORT Config_WidgetAPI
35 {
36  public:
37   virtual ~Config_WidgetAPI();
38
39   //! Returns name of widget's node (attribute)
40   std::string widgetType() const;
41   //! Returns true if widget has container type, which means it able to contain other widgets
42   bool isContainerWidget() const;
43   //! Returns true if widget has page type;
44   //! Page is container widget with combo box control to switch between pages
45   bool isPagedWidget() const;
46
47   //! Returns id of current widget
48   std::string widgetId() const;
49   //! Returns icon of current widget
50   std::string widgetIcon() const;
51   //! Returns text for label of current widget
52   std::string widgetLabel() const;
53   //! Returns text for tooltip of current widget
54   std::string widgetTooltip() const;
55   //! Returns a custom property of current widget
56   std::string getProperty(const char* thePropName) const;
57
58   /*! Checks if the XML representation of widget has given attribute,
59    *  if yes - returns it's bool value, if no, or if the value can not
60    *  be converted to bool - returns theDefault.
61    *  \param theAttributeName attribute to check
62    *  \param theDefault default value on bad data
63    *  \return the boolean result
64    */
65   bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
66
67  protected:
68   /// These fields are accessible for ModuleBase_WidgetFactory only
69   Config_WidgetAPI(std::string theRawXml);
70   //! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
71   bool toNextWidget();
72   //! Pass into the child node of widget's xml definition. If impossible, returns false
73   bool toChildWidget();
74   //! Pass into the parent node of widget's xml definition. If impossible, returns false
75   bool toParentWidget();
76
77  private:
78   xmlDocPtr myDoc; //!< Pointer to the root of widget's xml definition
79   xmlNodePtr myCurrentNode; //!< Pointer to the current node in the widget's xml definition
80
81   friend class ModuleBase_WidgetFactory;
82 };
83
84 #endif /* CONFIG_WIDGETAPI_H_ */