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