Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom 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  * \ingroup Config
33  * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
34  */
35 class CONFIG_EXPORT Config_WidgetAPI
36 {
37  public:
38   virtual ~Config_WidgetAPI();
39
40   //! Returns name of widget's node (attribute)
41   std::string widgetType() const;
42   //! Returns true if widget has container type, which means it able to contain other widgets
43   bool isContainerWidget() const;
44   //! Returns true if widget has page type;
45   //! Page is container widget with combo box control to switch between pages
46   bool isPagedWidget() const;
47
48   //! Returns id of current widget
49   std::string widgetId() const;
50   //! Returns icon of current widget
51   std::string widgetIcon() const;
52   //! Returns text for label of current widget
53   std::string widgetLabel() const;
54   //! Returns text for tooltip of current widget
55   std::string widgetTooltip() const;
56   //! Returns a custom property of current widget
57   std::string getProperty(const char* thePropName) const;
58
59   /*! Checks if the XML representation of widget has given attribute,
60    *  if yes - returns it's bool value, if no, or if the value can not
61    *  be converted to bool - returns theDefault.
62    *  \param theAttributeName attribute to check
63    *  \param theDefault default value on bad data
64    *  \return the boolean result
65    */
66   bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
67
68  protected:
69   /// These fields are accessible for ModuleBase_WidgetFactory only
70   Config_WidgetAPI(std::string theRawXml);
71   //! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
72   bool toNextWidget();
73   //! Pass into the child node of widget's xml definition. If impossible, returns false
74   bool toChildWidget();
75   //! Pass into the parent node of widget's xml definition. If impossible, returns false
76   bool toParentWidget();
77
78  private:
79   xmlDocPtr myDoc; //!< Pointer to the root of widget's xml definition
80   xmlNodePtr myCurrentNode; //!< Pointer to the current node in the widget's xml definition
81
82   friend class ModuleBase_WidgetFactory;
83 };
84
85 #endif /* CONFIG_WIDGETAPI_H_ */