Crazy Eddies GUI System
0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIGUILayout_xmlHandler.h 00003 created: 5/7/2004 00004 author: Paul D Turner 00005 00006 purpose: Interface to XML parser for GUILayout files 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIGUILayout_xmlHandler_h_ 00031 #define _CEGUIGUILayout_xmlHandler_h_ 00032 00033 #include "CEGUIWindowManager.h" 00034 #include "CEGUIWindow.h" 00035 #include "CEGUIXMLHandler.h" 00036 00037 #include <vector> 00038 00039 // Start of CEGUI namespace section 00040 namespace CEGUI 00041 { 00046 class GUILayout_xmlHandler : public XMLHandler 00047 { 00048 typedef WindowManager::PropertyCallback PropertyCallback; 00049 public: 00050 /************************************************************************* 00051 Construction & Destruction 00052 *************************************************************************/ 00057 GUILayout_xmlHandler(const String& name_prefix, PropertyCallback* callback = 0, void* userdata = 0) : 00058 d_root(0), 00059 d_namingPrefix(name_prefix), 00060 d_propertyCallback(callback), 00061 d_userData(userdata) 00062 {} 00063 00068 virtual ~GUILayout_xmlHandler(void) {} 00069 00070 /************************************************************************* 00071 SAX2 Handler overrides 00072 *************************************************************************/ 00077 virtual void elementStart(const String& element, const XMLAttributes& attributes); 00078 virtual void elementEnd(const String& element); 00079 virtual void text(const String& text); 00080 00081 /************************************************************************* 00082 Functions used by our implementation 00083 *************************************************************************/ 00088 void cleanupLoadedWindows(void); 00089 00090 00095 Window* getLayoutRootWindow(void) const; 00096 00097 private: 00098 /************************************************************************* 00099 Implementation Constants 00100 *************************************************************************/ 00101 static const String GUILayoutElement; 00102 static const String WindowElement; 00103 static const String AutoWindowElement; 00104 static const String PropertyElement; 00105 static const String LayoutImportElement; 00106 static const String EventElement; 00107 static const String WindowTypeAttribute; 00108 static const String WindowNameAttribute; 00109 static const String AutoWindowNameSuffixAttribute; 00110 static const String PropertyNameAttribute; 00111 static const String PropertyValueAttribute; 00112 static const String LayoutParentAttribute; 00113 static const String LayoutImportFilenameAttribute; 00114 static const String LayoutImportPrefixAttribute; 00115 static const String LayoutImportResourceGroupAttribute; 00116 static const String EventNameAttribute; 00117 static const String EventFunctionAttribute; 00118 00123 void elementGUILayoutStart(const XMLAttributes& attributes); 00124 00129 void elementWindowStart(const XMLAttributes& attributes); 00130 00135 void elementAutoWindowStart(const XMLAttributes& attributes); 00136 00141 void elementPropertyStart(const XMLAttributes& attributes); 00142 00147 void elementLayoutImportStart(const XMLAttributes& attributes); 00148 00153 void elementEventStart(const XMLAttributes& attributes); 00154 00159 void elementGUILayoutEnd(); 00160 00165 void elementWindowEnd(); 00166 00171 void elementAutoWindowEnd(); 00172 00177 void elementPropertyEnd(); 00178 00179 void operator=(const GUILayout_xmlHandler&) {} 00180 00181 /************************************************************************* 00182 Implementation Data 00183 *************************************************************************/ 00184 typedef std::pair<Window*,bool> WindowStackEntry; 00185 typedef std::vector<WindowStackEntry> WindowStack; 00186 Window* d_root; 00187 WindowStack d_stack; 00188 String d_layoutParent; 00189 const String& d_namingPrefix; 00190 PropertyCallback* d_propertyCallback; 00191 void* d_userData; 00192 String d_propertyName; 00193 String d_propertyValue; 00194 }; 00195 00196 00197 } // End of CEGUI namespace section 00198 00199 00200 #endif // end of guard _CEGUIGUILayout_xmlHandler_h_