1 | /************************************************************************
|
---|
2 | filename: CEGUIGUILayout_xmlHandler.h
|
---|
3 | created: 5/7/2004
|
---|
4 | author: Paul D Turner
|
---|
5 |
|
---|
6 | purpose: Interface to XML parser for GUILayout files
|
---|
7 | *************************************************************************/
|
---|
8 | /*************************************************************************
|
---|
9 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
10 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
11 |
|
---|
12 | This library is free software; you can redistribute it and/or
|
---|
13 | modify it under the terms of the GNU Lesser General Public
|
---|
14 | License as published by the Free Software Foundation; either
|
---|
15 | version 2.1 of the License, or (at your option) any later version.
|
---|
16 |
|
---|
17 | This library is distributed in the hope that it will be useful,
|
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | Lesser General Public License for more details.
|
---|
21 |
|
---|
22 | You should have received a copy of the GNU Lesser General Public
|
---|
23 | License along with this library; if not, write to the Free Software
|
---|
24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *************************************************************************/
|
---|
26 | #ifndef _CEGUIGUILayout_xmlHandler_h_
|
---|
27 | #define _CEGUIGUILayout_xmlHandler_h_
|
---|
28 |
|
---|
29 | #include "CEGUIWindowManager.h"
|
---|
30 | #include "CEGUIWindow.h"
|
---|
31 | #include "CEGUIXMLHandler.h"
|
---|
32 |
|
---|
33 | #include <vector>
|
---|
34 |
|
---|
35 | // Start of CEGUI namespace section
|
---|
36 | namespace CEGUI
|
---|
37 | {
|
---|
38 | /*!
|
---|
39 | \brief
|
---|
40 | Handler class used to parse the GUILayout XML files using SAX2
|
---|
41 | */
|
---|
42 | class GUILayout_xmlHandler : public XMLHandler
|
---|
43 | {
|
---|
44 | typedef WindowManager::PropertyCallback PropertyCallback;
|
---|
45 | public:
|
---|
46 | /*************************************************************************
|
---|
47 | Construction & Destruction
|
---|
48 | *************************************************************************/
|
---|
49 | /*!
|
---|
50 | \brief
|
---|
51 | Constructor for GUILayout_xmlHandler objects
|
---|
52 | */
|
---|
53 | GUILayout_xmlHandler(const String& name_prefix, PropertyCallback* callback = NULL, void* userdata = NULL) :
|
---|
54 | d_root(NULL),
|
---|
55 | d_namingPrefix(name_prefix),
|
---|
56 | d_propertyCallback(callback),
|
---|
57 | d_userData(userdata)
|
---|
58 | {}
|
---|
59 |
|
---|
60 | /*!
|
---|
61 | \brief
|
---|
62 | Destructor for GUILayout_xmlHandler objects
|
---|
63 | */
|
---|
64 | virtual ~GUILayout_xmlHandler(void) {}
|
---|
65 |
|
---|
66 | /*************************************************************************
|
---|
67 | SAX2 Handler overrides
|
---|
68 | *************************************************************************/
|
---|
69 | /*!
|
---|
70 | \brief
|
---|
71 | document processing (only care about elements, schema validates format)
|
---|
72 | */
|
---|
73 | virtual void elementStart(const String& element, const XMLAttributes& attributes);
|
---|
74 | virtual void elementEnd(const String& element);
|
---|
75 |
|
---|
76 | /*************************************************************************
|
---|
77 | Functions used by our implementation
|
---|
78 | *************************************************************************/
|
---|
79 | /*!
|
---|
80 | \brief
|
---|
81 | Destroy all windows created so far.
|
---|
82 | */
|
---|
83 | void cleanupLoadedWindows(void);
|
---|
84 |
|
---|
85 |
|
---|
86 | /*!
|
---|
87 | \brief
|
---|
88 | Return a pointer to the 'root' window created.
|
---|
89 | */
|
---|
90 | Window* getLayoutRootWindow(void) const;
|
---|
91 |
|
---|
92 | private:
|
---|
93 | /*************************************************************************
|
---|
94 | Implementation Constants
|
---|
95 | *************************************************************************/
|
---|
96 | static const String GUILayoutElement; //!< Tag name for GUILayout elements.
|
---|
97 | static const String WindowElement; //!< Tag name for Window elements.
|
---|
98 | static const String PropertyElement; //!< Tag name for Property elements.
|
---|
99 | static const String LayoutImportElement; //!< Tag name for LayoutImport elements.
|
---|
100 | static const String EventElement; //!< Tag name for Event elements.
|
---|
101 | static const char WindowTypeAttribute[]; //!< Attribute name that stores the type of Window to create.
|
---|
102 | static const char WindowNameAttribute[]; //!< Attribute name that stores the name of the window to create.
|
---|
103 | static const char PropertyNameAttribute[]; //!< Attribute name that stores the name of the property to set.
|
---|
104 | static const char PropertyValueAttribute[]; //!< Attribute name that stores the value to pass to the property.
|
---|
105 | static const char LayoutParentAttribute[]; //!< Attribute name that stores the name of the window to attach the layout to.
|
---|
106 | static const char LayoutImportFilenameAttribute[];//!< Attribute name that stores the file name of the layout to import.
|
---|
107 | static const char LayoutImportPrefixAttribute[]; //!< Attribute name that stores the prefix to use when loading the imported layout.
|
---|
108 | static const char LayoutImportResourceGroupAttribute[]; //!< Attribute name that stores the resource group identifier used when loading imported file.
|
---|
109 | static const char EventNameAttribute[]; //!< Attribute name that stores the event name to be subscribed.
|
---|
110 | static const char EventFunctionAttribute[]; //!< Attribute name that stores the name of the scripted function to be bound.
|
---|
111 |
|
---|
112 |
|
---|
113 | /*************************************************************************
|
---|
114 | Implementation Data
|
---|
115 | *************************************************************************/
|
---|
116 | typedef std::vector<Window*> WindowStack;
|
---|
117 | Window* d_root; //!< Will point to first window created.
|
---|
118 | WindowStack d_stack; //!< Stack used to keep track of what we're doing to which window.
|
---|
119 | String d_layoutParent; //!< Name of the parent window to attach the loaded layout to.
|
---|
120 | const String& d_namingPrefix; //!< Prefix that is to prepend all names of created windows.
|
---|
121 | PropertyCallback* d_propertyCallback; //!< Callback for every property loaded
|
---|
122 | void* d_userData; //!< User data for the property callback
|
---|
123 | };
|
---|
124 |
|
---|
125 |
|
---|
126 | } // End of CEGUI namespace section
|
---|
127 |
|
---|
128 |
|
---|
129 | #endif // end of guard _CEGUIGUILayout_xmlHandler_h_
|
---|