Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Config_xmlHandler.h
1 /***********************************************************************
2  filename: CEGUIConfig_xmlHandler.h
3  created: Sat Jul 25 2009
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIConfig_xmlHandler_h_
29 #define _CEGUIConfig_xmlHandler_h_
30 
31 #include "CEGUI/Base.h"
32 #include "CEGUI/String.h"
33 #include "CEGUI/Logger.h"
34 #include "CEGUI/XMLHandler.h"
35 #include <vector>
36 
37 #if defined (_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
47 {
48 public:
51  // xml tag names
52  static const String CEGUIConfigElement;
53  static const String LoggingElement;
54  static const String AutoLoadElement;
55  static const String ResourceDirectoryElement;
56  static const String DefaultResourceGroupElement;
57  static const String ScriptingElement;
58  static const String XMLParserElement;
59  static const String ImageCodecElement;
60  static const String DefaultFontElement;
61  static const String DefaultMouseCursorElement;
62  static const String DefaultTooltipElement;
63  // xml attribute names
64  static const String FilenameAttribute;
65  static const String LevelAttribute;
66  static const String TypeAttribute;
67  static const String GroupAttribute;
68  static const String PatternAttribute;
69  static const String DirectoryAttribute;
70  static const String InitScriptAttribute;
71  static const String TerminateScriptAttribute;
72  static const String ImageAttribute;
73  static const String NameAttribute;
74 
77 
80 
82  void initialiseXMLParser() const;
84  void initialiseImageCodec() const;
86  void initialiseLogger(const String& default_filename) const;
92  void loadAutoResources() const;
94  void initialiseDefaultFont() const;
96  void initialiseDefaultMouseCursor() const;
98  void initialiseDefaulTooltip() const;
100  void executeInitScript() const;
102  const String& getTerminateScriptName() const;
103 
104  // XMLHandler overrides
105  const String& getSchemaName() const;
106  const String& getDefaultResourceGroup() const;
107 
108  void elementStart(const String& element, const XMLAttributes& attributes);
109  void elementEnd(const String& element);
110 
111 private:
113  enum ResourceType
114  {
115  RT_IMAGESET,
116  RT_FONT,
117  RT_SCHEME,
118  RT_LOOKNFEEL,
119  RT_LAYOUT,
120  RT_SCRIPT,
121  RT_XMLSCHEMA,
122  RT_DEFAULT
123  };
124 
126  struct ResourceDirectory
127  {
128  String group;
129  String directory;
130  };
131 
133  struct DefaultResourceGroup
134  {
135  ResourceType type;
136  String group;
137  };
138 
140  struct AutoLoadResource
141  {
142  String type_string;
143  ResourceType type;
144  String group;
145  String pattern;
146  };
147 
148  // functions to handle the various elements
149  void handleCEGUIConfigElement(const XMLAttributes& attr);
150  void handleLoggingElement(const XMLAttributes& attr);
151  void handleAutoLoadElement(const XMLAttributes& attr);
152  void handleResourceDirectoryElement(const XMLAttributes& attr);
153  void handleDefaultResourceGroupElement(const XMLAttributes& attr);
154  void handleScriptingElement(const XMLAttributes& attr);
155  void handleXMLParserElement(const XMLAttributes& attr);
156  void handleImageCodecElement(const XMLAttributes& attr);
157  void handleDefaultTooltipElement(const XMLAttributes& attr);
158  void handleDefaultFontElement(const XMLAttributes& attr);
159  void handleDefaultMouseCursorElement(const XMLAttributes& attr);
160 
162  ResourceType stringToResourceType(const String& type) const;
164  void autoLoadLookNFeels(const String& pattern, const String& group) const;
166  void autoLoadImagesets(const String& pattern, const String& group) const;
167 
169  typedef std::vector<ResourceDirectory
170  CEGUI_VECTOR_ALLOC(ResourceDirectory)> ResourceDirVector;
172  typedef std::vector<DefaultResourceGroup
173  CEGUI_VECTOR_ALLOC(DefaultResourceGroup)> DefaultGroupVector;
175  typedef std::vector<AutoLoadResource
176  CEGUI_VECTOR_ALLOC(AutoLoadResource)> AutoResourceVector;
178  String d_logFileName;
180  LoggingLevel d_logLevel;
182  String d_xmlParserName;
184  String d_imageCodecName;
186  String d_defaultFont;
188  String d_defaultMouseImage;
190  String d_defaultTooltipType;
192  String d_scriptingInitScript;
194  String d_scriptingTerminateScript;
196  ResourceDirVector d_resourceDirectories;
198  DefaultGroupVector d_defaultResourceGroups;
200  AutoResourceVector d_autoLoadResources;
201 };
202 
203 } // End of CEGUI namespace section
204 
205 #if defined (_MSC_VER)
206 # pragma warning(pop)
207 #endif
208 
209 #endif // end of guard _CEGUIConfig_xmlHandler_h_