Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / Config / Config_WidgetAPI.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef CONFIG_WIDGETAPI_H_
22 #define CONFIG_WIDGETAPI_H_
23
24 #include <Config_def.h>
25
26 #include <cstdarg>
27 #include <string>
28
29 //>> Forward declaration of xmlNodePtr.
30 typedef struct _xmlNode xmlNode;
31 typedef xmlNode *xmlNodePtr;
32 struct _xmlNode;
33 //<<
34
35 //>> Forward declaration of xmlDocPtr.
36 typedef struct _xmlDoc xmlDoc;
37 typedef xmlDoc *xmlDocPtr;
38 struct _xmlDoc;
39 //<<
40
41 /*!
42  * \class Config_WidgetAPI
43  * \ingroup Config
44  * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
45  */
46 class Config_WidgetAPI
47 {
48  public:
49   CONFIG_EXPORT virtual ~Config_WidgetAPI();
50
51   //! Returns name of widget's node (attribute)
52   CONFIG_EXPORT std::string widgetType() const;
53   //! Returns true if widget has container type, which means it able to contain other widgets
54   CONFIG_EXPORT bool isGroupBoxWidget() const;
55   //! Returns true if widget has page type;
56   //! Page is container widget with combo box control to switch between pages
57   CONFIG_EXPORT bool isPagedWidget() const;
58
59   //! Returns id of current feature
60   CONFIG_EXPORT std::string featureId() const;
61   //! Returns id of current widget
62   CONFIG_EXPORT std::string widgetId() const;
63   //! Returns icon of current widget
64   CONFIG_EXPORT std::string widgetIcon() const;
65   //! Returns text for label of current widget
66   CONFIG_EXPORT std::string widgetLabel() const;
67   //! Returns text for tooltip of current widget
68   CONFIG_EXPORT std::string widgetTooltip() const;
69   //! Returns a custom property of current widget
70   CONFIG_EXPORT std::string getProperty(const char* thePropName) const;
71
72   /*! Checks if the XML representation of widget has given attribute,
73    *  if yes - returns it's bool value, if no, or if the value can not
74    *  be converted to bool - returns theDefault.
75    *  \param theAttributeName attribute to check
76    *  \param theDefault default value on bad data
77    *  \return the boolean result
78    */
79   CONFIG_EXPORT bool getBooleanAttribute(const char* theAttributeName, bool theDefault) const;
80
81  protected:
82   /// These fields are accessible for ModuleBase_WidgetFactory only
83   CONFIG_EXPORT Config_WidgetAPI(std::string theRawXml);
84   //! Pass to the next (sibling) node of widget's xml definition. If impossible, returns false
85   CONFIG_EXPORT bool toNextWidget();
86   //! Pass into the child node of widget's xml definition. If impossible, returns false
87   CONFIG_EXPORT bool toChildWidget();
88   //! Pass into the parent node of widget's xml definition. If impossible, returns false
89   CONFIG_EXPORT bool toParentWidget();
90
91  private:
92   xmlDocPtr myDoc; //!< Pointer to the root of widget's xml definition
93   xmlNodePtr myCurrentNode; //!< Pointer to the current node in the widget's xml definition
94   std::string myFeatureId;
95
96   friend class ModuleBase_WidgetFactory;
97 };
98
99 #endif /* CONFIG_WIDGETAPI_H_ */