Crazy Eddies GUI System  0.7.2
CEGUIGUILayout_xmlHandler.h
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  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIGUILayout_xmlHandler_h_
31 #define _CEGUIGUILayout_xmlHandler_h_
32 
33 #include "CEGUIWindowManager.h"
34 #include "CEGUIWindow.h"
35 #include "CEGUIXMLHandler.h"
36 
37 #include <vector>
38 
39 // Start of CEGUI namespace section
40 namespace CEGUI
41 {
47 {
48  typedef WindowManager::PropertyCallback PropertyCallback;
49 public:
50  /*************************************************************************
51  Construction & Destruction
52  *************************************************************************/
57  GUILayout_xmlHandler(const String& name_prefix, PropertyCallback* callback = 0, void* userdata = 0) :
58  d_root(0),
59  d_namingPrefix(name_prefix),
60  d_propertyCallback(callback),
61  d_userData(userdata)
62  {}
63 
68  virtual ~GUILayout_xmlHandler(void) {}
69 
70  /*************************************************************************
71  SAX2 Handler overrides
72  *************************************************************************/
77  virtual void elementStart(const String& element, const XMLAttributes& attributes);
78  virtual void elementEnd(const String& element);
79  virtual void text(const String& text);
80 
81  /*************************************************************************
82  Functions used by our implementation
83  *************************************************************************/
88  void cleanupLoadedWindows(void);
89 
90 
95  Window* getLayoutRootWindow(void) const;
96 
97 private:
98  /*************************************************************************
99  Implementation Constants
100  *************************************************************************/
101  static const String GUILayoutElement;
102  static const String WindowElement;
103  static const String AutoWindowElement;
104  static const String PropertyElement;
105  static const String LayoutImportElement;
106  static const String EventElement;
107  static const String WindowTypeAttribute;
108  static const String WindowNameAttribute;
109  static const String AutoWindowNameSuffixAttribute;
110  static const String PropertyNameAttribute;
111  static const String PropertyValueAttribute;
112  static const String LayoutParentAttribute;
113  static const String LayoutImportFilenameAttribute;
114  static const String LayoutImportPrefixAttribute;
115  static const String LayoutImportResourceGroupAttribute;
116  static const String EventNameAttribute;
117  static const String EventFunctionAttribute;
118 
123  void elementGUILayoutStart(const XMLAttributes& attributes);
124 
129  void elementWindowStart(const XMLAttributes& attributes);
130 
135  void elementAutoWindowStart(const XMLAttributes& attributes);
136 
141  void elementPropertyStart(const XMLAttributes& attributes);
142 
147  void elementLayoutImportStart(const XMLAttributes& attributes);
148 
153  void elementEventStart(const XMLAttributes& attributes);
154 
159  void elementGUILayoutEnd();
160 
165  void elementWindowEnd();
166 
171  void elementAutoWindowEnd();
172 
177  void elementPropertyEnd();
178 
179  void operator=(const GUILayout_xmlHandler&) {}
180 
181  /*************************************************************************
182  Implementation Data
183  *************************************************************************/
184  typedef std::pair<Window*,bool> WindowStackEntry;
185  typedef std::vector<WindowStackEntry> WindowStack;
186  Window* d_root;
187  WindowStack d_stack;
188  String d_layoutParent;
189  const String& d_namingPrefix;
190  PropertyCallback* d_propertyCallback;
191  void* d_userData;
192  String d_propertyName;
193  String d_propertyValue;
194 };
195 
196 
197 } // End of CEGUI namespace section
198 
199 
200 #endif // end of guard _CEGUIGUILayout_xmlHandler_h_