00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "CEGUIScheme_xmlHandler.h"
00027
00028 #include "CEGUIExceptions.h"
00029 #include "CEGUIImageset.h"
00030 #include "CEGUILogger.h"
00031 #include "CEGUIXMLAttributes.h"
00032 #include "falagard/CEGUIFalWidgetLookManager.h"
00033
00034
00035 namespace CEGUI
00036 {
00037
00038
00039
00040
00041
00042
00043 const String Scheme_xmlHandler::GUISchemeElement( "GUIScheme" );
00044 const String Scheme_xmlHandler::ImagesetElement( "Imageset" );
00045 const String Scheme_xmlHandler::ImagesetFromImageElement( "ImagesetFromImage" );
00046 const String Scheme_xmlHandler::FontElement( "Font" );
00047 const String Scheme_xmlHandler::WindowSetElement( "WindowSet" );
00048 const String Scheme_xmlHandler::WindowFactoryElement( "WindowFactory" );
00049 const String Scheme_xmlHandler::WindowAliasElement( "WindowAlias" );
00050 const String Scheme_xmlHandler::FalagardMappingElement( "FalagardMapping" );
00051 const String Scheme_xmlHandler::LookNFeelElement( "LookNFeel" );
00052 const String Scheme_xmlHandler::NameAttribute( "Name" );
00053 const String Scheme_xmlHandler::FilenameAttribute( "Filename" );
00054 const String Scheme_xmlHandler::AliasAttribute( "Alias" );
00055 const String Scheme_xmlHandler::TargetAttribute( "Target" );
00056 const String Scheme_xmlHandler::ResourceGroupAttribute( "ResourceGroup" );
00057 const String Scheme_xmlHandler::WindowTypeAttribute( "WindowType" );
00058 const String Scheme_xmlHandler::TargetTypeAttribute( "TargetType" );
00059 const String Scheme_xmlHandler::LookNFeelAttribute( "LookNFeel" );
00060
00061
00062
00063
00064 void Scheme_xmlHandler::elementStart(const String& element, const XMLAttributes& attributes)
00065 {
00066
00067 if (element == WindowAliasElement)
00068 {
00069 Scheme::AliasMapping alias;
00070
00071 alias.aliasName = attributes.getValueAsString(AliasAttribute);
00072 alias.targetName = attributes.getValueAsString(TargetAttribute);
00073 d_scheme->d_aliasMappings.push_back(alias);
00074 }
00075
00076 else if (element == ImagesetElement)
00077 {
00078 Scheme::LoadableUIElement imageset;
00079
00080 imageset.name = attributes.getValueAsString(NameAttribute);
00081 imageset.filename = attributes.getValueAsString(FilenameAttribute);
00082 imageset.resourceGroup = attributes.getValueAsString(ResourceGroupAttribute);
00083
00084 d_scheme->d_imagesets.push_back(imageset);
00085 }
00086
00087 else if (element == ImagesetFromImageElement)
00088 {
00089 Scheme::LoadableUIElement imageset;
00090
00091 imageset.name = attributes.getValueAsString(NameAttribute);
00092 imageset.filename = attributes.getValueAsString(FilenameAttribute);
00093 imageset.resourceGroup = attributes.getValueAsString(ResourceGroupAttribute);
00094
00095 d_scheme->d_imagesetsFromImages.push_back(imageset);
00096 }
00097
00098 else if (element == FontElement)
00099 {
00100 Scheme::LoadableUIElement font;
00101
00102 font.name = attributes.getValueAsString(NameAttribute);
00103 font.filename = attributes.getValueAsString(FilenameAttribute);
00104 font.resourceGroup = attributes.getValueAsString(ResourceGroupAttribute);
00105
00106 d_scheme->d_fonts.push_back(font);
00107 }
00108
00109 else if (element == WindowSetElement)
00110 {
00111 Scheme::UIModule module;
00112 module.name = attributes.getValueAsString(FilenameAttribute);
00113 module.module = NULL;
00114
00115 module.factories.clear();
00116 d_scheme->d_widgetModules.push_back(module);
00117 }
00118
00119 else if (element == WindowFactoryElement)
00120 {
00121 Scheme::UIElementFactory factory;
00122
00123 factory.name = attributes.getValueAsString(NameAttribute);
00124
00125 d_scheme->d_widgetModules[d_scheme->d_widgetModules.size() - 1].factories.push_back(factory);
00126 }
00127
00128 else if (element == GUISchemeElement)
00129 {
00130
00131 d_scheme->d_name = attributes.getValueAsString(NameAttribute);
00132
00133 Logger::getSingleton().logEvent("Started creation of Scheme '" + d_scheme->d_name + "' via XML file.", Informative);
00134
00135 if (SchemeManager::getSingleton().isSchemePresent(d_scheme->d_name))
00136 {
00137 throw AlreadyExistsException((utf8*)"A GUI Scheme named '" + d_scheme->d_name + "' is already present in the system.");
00138 }
00139
00140 }
00141 else if (element == FalagardMappingElement)
00142 {
00143 Scheme::FalagardMapping fmap;
00144 fmap.windowName = attributes.getValueAsString(WindowTypeAttribute);
00145 fmap.targetName = attributes.getValueAsString(TargetTypeAttribute);
00146 fmap.lookName = attributes.getValueAsString(LookNFeelAttribute);
00147
00148 d_scheme->d_falagardMappings.push_back(fmap);
00149 }
00150 else if (element == LookNFeelElement)
00151 {
00152 Scheme::LoadableUIElement lnf;
00153 lnf.filename = attributes.getValueAsString(FilenameAttribute);
00154 lnf.resourceGroup = attributes.getValueAsString(ResourceGroupAttribute);
00155
00156 d_scheme->d_looknfeels.push_back(lnf);
00157 }
00158
00159 else
00160 {
00161 throw FileIOException("Scheme::xmlHandler::startElement - Unexpected data was found while parsing the Scheme file: '" + element + "' is unknown.");
00162 }
00163
00164 }
00165
00166 void Scheme_xmlHandler::elementEnd(const String& element)
00167 {
00168 if (element == GUISchemeElement)
00169 {
00170 Logger::getSingleton().logEvent("Finished creation of Scheme '" + d_scheme->d_name + "' via XML file.", Informative);
00171 }
00172
00173 }
00174
00175 }