00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "falagard/CEGUIFalagard_xmlHandler.h"
00025 #include "falagard/CEGUIFalWidgetLookManager.h"
00026 #include "falagard/CEGUIFalWidgetLookFeel.h"
00027 #include "falagard/CEGUIFalWidgetComponent.h"
00028 #include "falagard/CEGUIFalTextComponent.h"
00029 #include "falagard/CEGUIFalFrameComponent.h"
00030 #include "falagard/CEGUIFalNamedArea.h"
00031 #include "falagard/CEGUIFalPropertyDefinition.h"
00032 #include "falagard/CEGUIFalXMLEnumHelper.h"
00033 #include "CEGUIXMLAttributes.h"
00034 #include "CEGUILogger.h"
00035 #include <sstream>
00036
00037
00038 namespace CEGUI
00039 {
00041
00042 const String Falagard_xmlHandler::FalagardElement("Falagard");
00043 const String Falagard_xmlHandler::WidgetLookElement("WidgetLook");
00044 const String Falagard_xmlHandler::ChildElement("Child");
00045 const String Falagard_xmlHandler::ImagerySectionElement("ImagerySection");
00046 const String Falagard_xmlHandler::StateImageryElement("StateImagery");
00047 const String Falagard_xmlHandler::LayerElement("Layer");
00048 const String Falagard_xmlHandler::SectionElement("Section");
00049 const String Falagard_xmlHandler::ImageryComponentElement("ImageryComponent");
00050 const String Falagard_xmlHandler::TextComponentElement("TextComponent");
00051 const String Falagard_xmlHandler::FrameComponentElement("FrameComponent");
00052 const String Falagard_xmlHandler::AreaElement("Area");
00053 const String Falagard_xmlHandler::ImageElement("Image");
00054 const String Falagard_xmlHandler::ColoursElement("Colours");
00055 const String Falagard_xmlHandler::VertFormatElement("VertFormat");
00056 const String Falagard_xmlHandler::HorzFormatElement("HorzFormat");
00057 const String Falagard_xmlHandler::VertAlignmentElement("VertAlignment");
00058 const String Falagard_xmlHandler::HorzAlignmentElement("HorzAlignment");
00059 const String Falagard_xmlHandler::PropertyElement("Property");
00060 const String Falagard_xmlHandler::DimElement("Dim");
00061 const String Falagard_xmlHandler::UnifiedDimElement("UnifiedDim");
00062 const String Falagard_xmlHandler::AbsoluteDimElement("AbsoluteDim");
00063 const String Falagard_xmlHandler::ImageDimElement("ImageDim");
00064 const String Falagard_xmlHandler::WidgetDimElement("WidgetDim");
00065 const String Falagard_xmlHandler::FontDimElement("FontDim");
00066 const String Falagard_xmlHandler::PropertyDimElement("PropertyDim");
00067 const String Falagard_xmlHandler::TextElement("Text");
00068 const String Falagard_xmlHandler::ColourPropertyElement("ColourProperty");
00069 const String Falagard_xmlHandler::ColourRectPropertyElement("ColourRectProperty");
00070 const String Falagard_xmlHandler::NamedAreaElement("NamedArea");
00071 const String Falagard_xmlHandler::PropertyDefinitionElement("PropertyDefinition");
00072 const String Falagard_xmlHandler::DimOperatorElement("DimOperator");
00073 const String Falagard_xmlHandler::VertFormatPropertyElement("VertFormatProperty");
00074 const String Falagard_xmlHandler::HorzFormatPropertyElement("HorzFormatProperty");
00075 const String Falagard_xmlHandler::AreaPropertyElement("AreaProperty");
00076 const String Falagard_xmlHandler::ImagePropertyElement("ImageProperty");
00077
00078 const String Falagard_xmlHandler::TopLeftAttribute("topLeft");
00079 const String Falagard_xmlHandler::TopRightAttribute("topRight");
00080 const String Falagard_xmlHandler::BottomLeftAttribute("bottomLeft");
00081 const String Falagard_xmlHandler::BottomRightAttribute("bottomRight");
00082 const String Falagard_xmlHandler::ImagesetAttribute("imageset");
00083 const String Falagard_xmlHandler::ImageAttribute("image");
00084 const String Falagard_xmlHandler::TypeAttribute("type");
00085 const String Falagard_xmlHandler::NameAttribute("name");
00086 const String Falagard_xmlHandler::PriorityAttribute("priority");
00087 const String Falagard_xmlHandler::SectionNameAttribute("section");
00088 const String Falagard_xmlHandler::NameSuffixAttribute("nameSuffix");
00089 const String Falagard_xmlHandler::LookAttribute("look");
00090 const String Falagard_xmlHandler::ScaleAttribute("scale");
00091 const String Falagard_xmlHandler::OffsetAttribute("offset");
00092 const String Falagard_xmlHandler::ValueAttribute("value");
00093 const String Falagard_xmlHandler::DimensionAttribute("dimension");
00094 const String Falagard_xmlHandler::WidgetAttribute("widget");
00095 const String Falagard_xmlHandler::StringAttribute("string");
00096 const String Falagard_xmlHandler::FontAttribute("font");
00097 const String Falagard_xmlHandler::InitialValueAttribute("initialValue");
00098 const String Falagard_xmlHandler::ClippedAttribute("clipped");
00099 const String Falagard_xmlHandler::OperatorAttribute("op");
00100 const String Falagard_xmlHandler::PaddingAttribute("padding");
00101 const String Falagard_xmlHandler::LayoutOnWriteAttribute("layoutOnWrite");
00102 const String Falagard_xmlHandler::RedrawOnWriteAttribute("redrawOnWrite");
00103
00105
00106
00107 Falagard_xmlHandler::Falagard_xmlHandler(WidgetLookManager* mgr) :
00108 d_manager(mgr),
00109 d_widgetlook(0),
00110 d_childcomponent(0),
00111 d_imagerysection(0),
00112 d_stateimagery(0),
00113 d_layer(0),
00114 d_section(0),
00115 d_imagerycomponent(0),
00116 d_area(0),
00117 d_textcomponent(0),
00118 d_namedArea(0),
00119 d_framecomponent(0)
00120 {
00121 }
00122
00123 Falagard_xmlHandler::~Falagard_xmlHandler()
00124 {}
00125
00126 void Falagard_xmlHandler::elementStart(const String& element, const XMLAttributes& attributes)
00127 {
00128
00129 if (element == FalagardElement)
00130 {
00131 Logger::getSingleton().logEvent("===== Falagard 'root' element: look and feel parsing begins =====");
00132 }
00133
00134 else if (element == WidgetLookElement)
00135 {
00136 assert(d_widgetlook == 0);
00137 d_widgetlook = new WidgetLookFeel(attributes.getValueAsString(NameAttribute));
00138
00139 Logger::getSingleton().logEvent("---> Start of definition for widget look '" + d_widgetlook->getName() + "'.", Informative);
00140 }
00141
00142 else if (element == ChildElement)
00143 {
00144 assert(d_childcomponent == 0);
00145 d_childcomponent = new WidgetComponent(attributes.getValueAsString(TypeAttribute), attributes.getValueAsString(LookAttribute), attributes.getValueAsString(NameSuffixAttribute));
00146
00147 CEGUI_LOGINSANE("-----> Start of definition for child widget. Type: " + d_childcomponent->getBaseWidgetType() + " Suffix: " + d_childcomponent->getWidgetNameSuffix() + " Look: " + d_childcomponent->getWidgetLookName());
00148 }
00149 else if (element == ImagerySectionElement)
00150 {
00151 assert(d_imagerysection == 0);
00152 d_imagerysection = new ImagerySection(attributes.getValueAsString(NameAttribute));
00153
00154 CEGUI_LOGINSANE("-----> Start of definition for imagery section '" + d_imagerysection->getName() + "'.");
00155 }
00156 else if (element == StateImageryElement)
00157 {
00158 assert(d_stateimagery == 0);
00159 d_stateimagery = new StateImagery(attributes.getValueAsString(NameAttribute));
00160 d_stateimagery->setClippedToDisplay(!attributes.getValueAsBool(ClippedAttribute, true));
00161
00162 CEGUI_LOGINSANE("-----> Start of definition for imagery for state '" + d_stateimagery->getName() + "'.");
00163 }
00164 else if (element == LayerElement)
00165 {
00166 assert(d_layer == 0);
00167 d_layer = new LayerSpecification(attributes.getValueAsInteger(PriorityAttribute, 0));
00168
00169 CEGUI_LOGINSANE("-------> Start of definition of new imagery layer, priority: " + attributes.getValueAsString(PriorityAttribute, "0"));
00170 }
00171 else if (element == SectionElement)
00172 {
00173 assert(d_section == 0);
00174 assert(d_widgetlook != 0);
00175 String owner(attributes.getValueAsString(LookAttribute));
00176 d_section = new SectionSpecification(owner.empty() ? d_widgetlook->getName() : owner, attributes.getValueAsString(SectionNameAttribute));
00177
00178 CEGUI_LOGINSANE("---------> Layer references imagery section '" + d_section->getSectionName() + "'.");
00179 }
00180 else if (element == ImageryComponentElement)
00181 {
00182 assert(d_imagerycomponent == 0);
00183 d_imagerycomponent = new ImageryComponent();
00184
00185 CEGUI_LOGINSANE("-------> Image component definition...");
00186 }
00187 else if (element == TextComponentElement)
00188 {
00189 assert(d_textcomponent == 0);
00190 d_textcomponent = new TextComponent();
00191
00192 CEGUI_LOGINSANE("-------> Text component definition...");
00193 }
00194 else if (element == FrameComponentElement)
00195 {
00196 assert(d_framecomponent == 0);
00197 d_framecomponent = new FrameComponent();
00198
00199 CEGUI_LOGINSANE("-------> Frame component definition...");
00200 }
00201 else if (element == AreaElement)
00202 {
00203 assert(d_area == 0);
00204 d_area = new ComponentArea();
00205 }
00206 else if (element == ColoursElement)
00207 {
00208 ColourRect cols(
00209 hexStringToARGB(attributes.getValueAsString(TopLeftAttribute)),
00210 hexStringToARGB(attributes.getValueAsString(TopRightAttribute)),
00211 hexStringToARGB(attributes.getValueAsString(BottomLeftAttribute)),
00212 hexStringToARGB(attributes.getValueAsString(BottomRightAttribute))
00213 );
00214
00215
00216 if (d_framecomponent)
00217 {
00218 d_framecomponent->setColours(cols);
00219 }
00220 else if (d_imagerycomponent)
00221 {
00222 d_imagerycomponent->setColours(cols);
00223 }
00224 else if (d_textcomponent)
00225 {
00226 d_textcomponent->setColours(cols);
00227 }
00228 else if (d_imagerysection)
00229 {
00230 d_imagerysection->setMasterColours(cols);
00231 }
00232 else if (d_section)
00233 {
00234 d_section->setOverrideColours(cols);
00235 d_section->setUsingOverrideColours(true);
00236 }
00237 }
00238 else if ((element == ColourPropertyElement) || (element == ColourRectPropertyElement))
00239 {
00240
00241 if (d_framecomponent)
00242 {
00243 d_framecomponent->setColoursPropertySource(attributes.getValueAsString(NameAttribute));
00244 d_framecomponent->setColoursPropertyIsColourRect(element == ColourRectPropertyElement);
00245 }
00246 else if (d_imagerycomponent)
00247 {
00248 d_imagerycomponent->setColoursPropertySource(attributes.getValueAsString(NameAttribute));
00249 d_imagerycomponent->setColoursPropertyIsColourRect(element == ColourRectPropertyElement);
00250 }
00251 else if (d_textcomponent)
00252 {
00253 d_textcomponent->setColoursPropertySource(attributes.getValueAsString(NameAttribute));
00254 d_textcomponent->setColoursPropertyIsColourRect(element == ColourRectPropertyElement);
00255 }
00256 else if (d_imagerysection)
00257 {
00258 d_imagerysection->setMasterColoursPropertySource(attributes.getValueAsString(NameAttribute));
00259 d_imagerysection->setMasterColoursPropertyIsColourRect(element == ColourRectPropertyElement);
00260 }
00261 else if (d_section)
00262 {
00263 d_section->setOverrideColoursPropertySource(attributes.getValueAsString(NameAttribute));
00264 d_section->setOverrideColoursPropertyIsColourRect(element == ColourRectPropertyElement);
00265 d_section->setUsingOverrideColours(true);
00266 }
00267 }
00268 else if (element == PropertyElement)
00269 {
00270 assert(d_widgetlook != 0);
00271 PropertyInitialiser prop(attributes.getValueAsString(NameAttribute), attributes.getValueAsString(ValueAttribute));
00272
00273 if (d_childcomponent)
00274 {
00275 d_childcomponent->addPropertyInitialiser(prop);
00276 CEGUI_LOGINSANE("-------> Added property initialiser for property: " + prop.getTargetPropertyName() + " with value: " + prop.getInitialiserValue());
00277 }
00278 else
00279 {
00280 d_widgetlook->addPropertyInitialiser(prop);
00281 CEGUI_LOGINSANE("---> Added property initialiser for property: " + prop.getTargetPropertyName() + " with value: " + prop.getInitialiserValue());
00282 }
00283
00284 }
00285 else if (element == VertAlignmentElement)
00286 {
00287 assert(d_childcomponent != 0);
00288 d_childcomponent->setVerticalWidgetAlignment(FalagardXMLHelper::stringToVertAlignment(attributes.getValueAsString(TypeAttribute)));
00289 }
00290 else if (element == HorzAlignmentElement)
00291 {
00292 assert(d_childcomponent != 0);
00293 d_childcomponent->setHorizontalWidgetAlignemnt(FalagardXMLHelper::stringToHorzAlignment(attributes.getValueAsString(TypeAttribute)));
00294 }
00295 else if (element == VertFormatElement)
00296 {
00297 if (d_framecomponent)
00298 {
00299 d_framecomponent->setBackgroundVerticalFormatting(FalagardXMLHelper::stringToVertFormat(attributes.getValueAsString(TypeAttribute)));
00300 }
00301 else if (d_imagerycomponent)
00302 {
00303 d_imagerycomponent->setVerticalFormatting(FalagardXMLHelper::stringToVertFormat(attributes.getValueAsString(TypeAttribute)));
00304 }
00305 else if (d_textcomponent)
00306 {
00307 d_textcomponent->setVerticalFormatting(FalagardXMLHelper::stringToVertTextFormat(attributes.getValueAsString(TypeAttribute)));
00308 }
00309 }
00310 else if (element == HorzFormatElement)
00311 {
00312 if (d_framecomponent)
00313 {
00314 d_framecomponent->setBackgroundHorizontalFormatting(FalagardXMLHelper::stringToHorzFormat(attributes.getValueAsString(TypeAttribute)));
00315 }
00316 else if (d_imagerycomponent)
00317 {
00318 d_imagerycomponent->setHorizontalFormatting(FalagardXMLHelper::stringToHorzFormat(attributes.getValueAsString(TypeAttribute)));
00319 }
00320 else if (d_textcomponent)
00321 {
00322 d_textcomponent->setHorizontalFormatting(FalagardXMLHelper::stringToHorzTextFormat(attributes.getValueAsString(TypeAttribute)));
00323 }
00324 }
00325 else if (element == ImageElement)
00326 {
00327 if (d_imagerycomponent)
00328 {
00329 d_imagerycomponent->setImage(attributes.getValueAsString(ImagesetAttribute), attributes.getValueAsString(ImageAttribute));
00330 CEGUI_LOGINSANE("---------> Using image: " + attributes.getValueAsString(ImageAttribute) + " from imageset: " + attributes.getValueAsString(ImagesetAttribute));
00331 }
00332 else if (d_framecomponent)
00333 {
00334 d_framecomponent->setImage(
00335 FalagardXMLHelper::stringToFrameImageComponent(attributes.getValueAsString(TypeAttribute)),
00336 attributes.getValueAsString(ImagesetAttribute),
00337 attributes.getValueAsString(ImageAttribute));
00338
00339 CEGUI_LOGINSANE("---------> Using image: " +
00340 attributes.getValueAsString(ImageAttribute) + " from imageset: " +
00341 attributes.getValueAsString(ImagesetAttribute) + " for: " +
00342 attributes.getValueAsString(TypeAttribute));
00343 }
00344 }
00345 else if (element == DimElement)
00346 {
00347 d_dimension.setDimensionType(FalagardXMLHelper::stringToDimensionType(attributes.getValueAsString(TypeAttribute)));
00348 }
00349 else if (element == UnifiedDimElement)
00350 {
00351 UnifiedDim base(UDim(attributes.getValueAsFloat(ScaleAttribute, 0.0f), attributes.getValueAsFloat(OffsetAttribute, 0.0f)), FalagardXMLHelper::stringToDimensionType(attributes.getValueAsString(TypeAttribute)));
00352 doBaseDimStart(&base);
00353 }
00354 else if (element == AbsoluteDimElement)
00355 {
00356 AbsoluteDim base(attributes.getValueAsFloat(ValueAttribute, 0.0f));
00357 doBaseDimStart(&base);
00358 }
00359 else if (element == ImageDimElement)
00360 {
00361 ImageDim base(attributes.getValueAsString(ImagesetAttribute), attributes.getValueAsString(ImageAttribute), FalagardXMLHelper::stringToDimensionType(attributes.getValueAsString(DimensionAttribute)));
00362 doBaseDimStart(&base);
00363 }
00364 else if (element == WidgetDimElement)
00365 {
00366 WidgetDim base(attributes.getValueAsString(WidgetAttribute), FalagardXMLHelper::stringToDimensionType(attributes.getValueAsString(DimensionAttribute)));
00367 doBaseDimStart(&base);
00368 }
00369 else if (element == FontDimElement)
00370 {
00371 FontDim base(
00372 attributes.getValueAsString(WidgetAttribute),
00373 attributes.getValueAsString(FontAttribute),
00374 attributes.getValueAsString(StringAttribute),
00375 FalagardXMLHelper::stringToFontMetricType(attributes.getValueAsString(TypeAttribute)),
00376 attributes.getValueAsFloat(PaddingAttribute, 0.0f));
00377
00378 doBaseDimStart(&base);
00379 }
00380 else if (element == PropertyDimElement)
00381 {
00382 PropertyDim base(attributes.getValueAsString(WidgetAttribute), attributes.getValueAsString(NameAttribute));
00383 doBaseDimStart(&base);
00384 }
00385 else if (element == TextElement)
00386 {
00387 assert (d_textcomponent != 0);
00388 d_textcomponent->setText(attributes.getValueAsString(StringAttribute));
00389 d_textcomponent->setFont(attributes.getValueAsString(FontAttribute));
00390 }
00391 else if (element == NamedAreaElement)
00392 {
00393 assert(d_namedArea == 0);
00394 d_namedArea = new NamedArea(attributes.getValueAsString(NameAttribute));
00395
00396 CEGUI_LOGINSANE("-----> Creating named area: " + d_namedArea->getName());
00397 }
00398 else if (element == DimOperatorElement)
00399 {
00400 if (!d_dimStack.empty())
00401 {
00402 d_dimStack.back()->setDimensionOperator(FalagardXMLHelper::stringToDimensionOperator(attributes.getValueAsString(OperatorAttribute)));
00403 }
00404 }
00405 else if (element == PropertyDefinitionElement)
00406 {
00407 assert(d_widgetlook);
00408
00409 PropertyDefinition prop(
00410 attributes.getValueAsString(NameAttribute),
00411 attributes.getValueAsString(InitialValueAttribute),
00412 attributes.getValueAsBool(RedrawOnWriteAttribute, false),
00413 attributes.getValueAsBool(LayoutOnWriteAttribute, false)
00414 );
00415
00416 CEGUI_LOGINSANE("-----> Adding PropertyDefiniton. Name: " + prop.getName() + " Default Value: " + attributes.getValueAsString(InitialValueAttribute));
00417
00418 d_widgetlook->addPropertyDefinition(prop);
00419 }
00420 else if (element == VertFormatPropertyElement)
00421 {
00422 if (d_framecomponent)
00423 d_framecomponent->setVertFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00424 else if (d_imagerycomponent)
00425 d_imagerycomponent->setVertFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00426 else if (d_textcomponent)
00427 d_textcomponent->setVertFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00428 }
00429 else if (element == HorzFormatPropertyElement)
00430 {
00431 if (d_framecomponent)
00432 d_framecomponent->setHorzFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00433 else if (d_imagerycomponent)
00434 d_imagerycomponent->setHorzFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00435 else if (d_textcomponent)
00436 d_textcomponent->setHorzFormattingPropertySource(attributes.getValueAsString(NameAttribute));
00437 }
00438 else if (element == AreaPropertyElement)
00439 {
00440 assert (d_area != 0);
00441
00442 d_area->setAreaPropertySource(attributes.getValueAsString(NameAttribute));
00443 }
00444 else if (element == ImagePropertyElement)
00445 {
00446 assert(d_imagerycomponent != 0);
00447
00448 d_imagerycomponent->setImagePropertySource(attributes.getValueAsString(NameAttribute));
00449 }
00450 else
00451 {
00452 throw FileIOException("Falagard::xmlHandler::elementStart - The unknown XML element '" + element + "' was encountered while processing the look and feel file.");
00453 }
00454 }
00455
00456 void Falagard_xmlHandler::elementEnd(const String& element)
00457 {
00458
00459 if (element == FalagardElement)
00460 {
00461 Logger::getSingleton().logEvent("===== Look and feel parsing completed =====");
00462 }
00463
00464 else if (element == WidgetLookElement)
00465 {
00466 if (d_widgetlook)
00467 {
00468 Logger::getSingleton().logEvent("---< End of definition for widget look '" + d_widgetlook->getName() + "'.", Informative);
00469 d_manager->addWidgetLook(*d_widgetlook);
00470 delete d_widgetlook;
00471 d_widgetlook = 0;
00472 }
00473 }
00474
00475 else if (element == ChildElement)
00476 {
00477 assert(d_widgetlook != 0);
00478
00479 if (d_childcomponent)
00480 {
00481 CEGUI_LOGINSANE("-----< End of definition for child widget. Type: " + d_childcomponent->getBaseWidgetType() + ".");
00482 d_widgetlook->addWidgetComponent(*d_childcomponent);
00483 delete d_childcomponent;
00484 d_childcomponent = 0;
00485 }
00486 }
00487
00488 else if (element == ImagerySectionElement)
00489 {
00490 assert(d_widgetlook != 0);
00491
00492 if (d_imagerysection)
00493 {
00494 CEGUI_LOGINSANE("-----< End of definition for imagery section '" + d_imagerysection->getName() + "'.");
00495 d_widgetlook->addImagerySection(*d_imagerysection);
00496 delete d_imagerysection;
00497 d_imagerysection = 0;
00498 }
00499 }
00500
00501 else if (element == StateImageryElement)
00502 {
00503 assert(d_widgetlook != 0);
00504
00505 if (d_stateimagery)
00506 {
00507 CEGUI_LOGINSANE("-----< End of definition for imagery for state '" + d_stateimagery->getName() + "'.");
00508 d_widgetlook->addStateSpecification(*d_stateimagery);
00509 delete d_stateimagery;
00510 d_stateimagery = 0;
00511 }
00512 }
00513
00514 else if (element == LayerElement)
00515 {
00516 assert(d_stateimagery != 0);
00517
00518 if (d_layer)
00519 {
00520 CEGUI_LOGINSANE("-------< End of definition of imagery layer.");
00521 d_stateimagery->addLayer(*d_layer);
00522 delete d_layer;
00523 d_layer = 0;
00524 }
00525 }
00526
00527 else if (element == SectionElement)
00528 {
00529 assert(d_layer != 0);
00530
00531 if (d_section)
00532 {
00533 d_layer->addSectionSpecification(*d_section);
00534 delete d_section;
00535 d_section = 0;
00536 }
00537 }
00538
00539 else if (element == ImageryComponentElement)
00540 {
00541 assert(d_imagerysection != 0);
00542
00543 if (d_imagerycomponent)
00544 {
00545 d_imagerysection->addImageryComponent(*d_imagerycomponent);
00546 delete d_imagerycomponent;
00547 d_imagerycomponent = 0;
00548 }
00549 }
00550
00551 else if (element == TextComponentElement)
00552 {
00553 assert(d_imagerysection != 0);
00554
00555 if (d_textcomponent)
00556 {
00557 d_imagerysection->addTextComponent(*d_textcomponent);
00558 delete d_textcomponent;
00559 d_textcomponent = 0;
00560 }
00561 }
00562
00563 else if (element == FrameComponentElement)
00564 {
00565 assert(d_imagerysection != 0);
00566
00567 if (d_framecomponent)
00568 {
00569 d_imagerysection->addFrameComponent(*d_framecomponent);
00570 delete d_framecomponent;
00571 d_framecomponent = 0;
00572 }
00573 }
00574
00575 else if (element == AreaElement)
00576 {
00577 assert((d_childcomponent != 0) || (d_imagerycomponent != 0) || (d_textcomponent != 0) || d_namedArea != 0 || d_framecomponent != 0);
00578 assert(d_area != 0);
00579
00580 if (d_childcomponent)
00581 {
00582 d_childcomponent->setComponentArea(*d_area);
00583 }
00584 else if (d_framecomponent)
00585 {
00586 d_framecomponent->setComponentArea(*d_area);
00587 }
00588 else if (d_imagerycomponent)
00589 {
00590 d_imagerycomponent->setComponentArea(*d_area);
00591 }
00592 else if (d_textcomponent)
00593 {
00594 d_textcomponent->setComponentArea(*d_area);
00595 }
00596 else if (d_namedArea)
00597 {
00598 d_namedArea->setArea(*d_area);
00599 }
00600
00601 delete d_area;
00602 d_area = 0;
00603 }
00604
00605 else if (element == NamedAreaElement)
00606 {
00607 assert(d_widgetlook != 0);
00608
00609 if (d_namedArea)
00610 {
00611 d_widgetlook->addNamedArea(*d_namedArea);
00612 delete d_namedArea;
00613 d_namedArea = 0;
00614 }
00615 }
00616
00617 else if ((element == UnifiedDimElement) || (element == AbsoluteDimElement) || (element == ImageDimElement) ||
00618 (element == WidgetDimElement) || (element == FontDimElement) || (element == PropertyDimElement))
00619 {
00620 doBaseDimEnd();
00621 }
00622 }
00623
00624 argb_t Falagard_xmlHandler::hexStringToARGB(const String& str)
00625 {
00626 argb_t val;
00627 std::istringstream s(str.c_str());
00628 s >> std::hex >> val;
00629
00630 return val;
00631 }
00632
00633 void Falagard_xmlHandler::assignAreaDimension(Dimension& dim)
00634 {
00635 if (d_area)
00636 {
00637 switch (dim.getDimensionType())
00638 {
00639 case DT_LEFT_EDGE:
00640 case DT_X_POSITION:
00641 d_area->d_left = dim;
00642 break;
00643 case DT_TOP_EDGE:
00644 case DT_Y_POSITION:
00645 d_area->d_top = dim;
00646 break;
00647 case DT_RIGHT_EDGE:
00648 case DT_WIDTH:
00649 d_area->d_right_or_width = dim;
00650 break;
00651 case DT_BOTTOM_EDGE:
00652 case DT_HEIGHT:
00653 d_area->d_bottom_or_height = dim;
00654 break;
00655 default:
00656 throw InvalidRequestException("Falagard::xmlHandler::assignAreaDimension - Invalid DimensionType specified for area component.");
00657 }
00658 }
00659 }
00660
00661 void Falagard_xmlHandler::doBaseDimStart(const BaseDim* dim)
00662 {
00663 BaseDim* cloned = dim->clone();
00664 d_dimStack.push_back(cloned);
00665 }
00666
00667 void Falagard_xmlHandler::doBaseDimEnd()
00668 {
00669 if (!d_dimStack.empty())
00670 {
00671 BaseDim* currDim = d_dimStack.back();
00672 d_dimStack.pop_back();
00673
00674 if (!d_dimStack.empty())
00675 {
00676 d_dimStack.back()->setOperand(*currDim);
00677 }
00678 else
00679 {
00680 d_dimension.setBaseDimension(*currDim);
00681 assignAreaDimension(d_dimension);
00682 }
00683
00684
00685 delete currDim;
00686 }
00687 }
00688
00689 }