Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Fri Jun 17 2005 00003 author: Paul D Turner <paul@cegui.org.uk> 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIFalagard_xmlHandler_h_ 00028 #define _CEGUIFalagard_xmlHandler_h_ 00029 00030 #include "../ChainedXMLHandler.h" 00031 #include "./Dimensions.h" 00032 #include "../Window.h" 00033 #include <vector> 00034 00035 // Start of CEGUI namespace section 00036 namespace CEGUI 00037 { 00038 // forward refs 00039 class WidgetLookManager; 00040 class WidgetLookFeel; 00041 class WidgetComponent; 00042 class ImagerySection; 00043 class StateImagery; 00044 class LayerSpecification; 00045 class SectionSpecification; 00046 class ImageryComponent; 00047 class ComponentArea; 00048 class Dimension; 00049 class TextComponent; 00050 class NamedArea; 00051 class FrameComponent; 00052 class PropertyDefinitionBase; 00053 class EventLinkDefinition; 00054 00059 class Falagard_xmlHandler : public ChainedXMLHandler 00060 { 00061 public: 00066 Falagard_xmlHandler(WidgetLookManager* mgr); 00067 00072 ~Falagard_xmlHandler(); 00073 00075 static const String NativeVersion; 00076 00078 static const String PropertyDefinitionHelpDefaultValue; 00079 00081 static const String PropertyLinkDefinitionHelpDefaultValue; 00082 00084 static const String GenericDataType; 00085 00086 00088 static const String ParentIdentifier; 00089 00090 /************************************************************************* 00091 XML element and attribute name constants 00092 *************************************************************************/ 00093 // element names 00094 static const String FalagardElement; 00095 static const String WidgetLookElement; 00096 static const String ChildElement; 00097 static const String ImagerySectionElement; 00098 static const String StateImageryElement; 00099 static const String LayerElement; 00100 static const String SectionElement; 00101 static const String ImageryComponentElement; 00102 static const String TextComponentElement; 00103 static const String FrameComponentElement; 00104 static const String AreaElement; 00105 static const String ImageElement; 00106 static const String ColoursElement; 00107 static const String VertFormatElement; 00108 static const String HorzFormatElement; 00109 static const String VertAlignmentElement; 00110 static const String HorzAlignmentElement; 00111 static const String PropertyElement; 00112 static const String DimElement; 00113 static const String UnifiedDimElement; 00114 static const String AbsoluteDimElement; 00115 static const String ImageDimElement; 00116 static const String ImagePropertyDimElement; 00117 static const String WidgetDimElement; 00118 static const String FontDimElement; 00119 static const String PropertyDimElement; 00120 static const String TextElement; 00121 static const String ColourPropertyElement; 00122 static const String ColourRectPropertyElement; 00123 static const String NamedAreaElement; 00124 static const String PropertyDefinitionElement; 00125 static const String PropertyLinkDefinitionElement; 00126 static const String PropertyLinkTargetElement; 00127 static const String OperatorDimElement; 00128 static const String VertFormatPropertyElement; 00129 static const String HorzFormatPropertyElement; 00130 static const String AreaPropertyElement; 00131 static const String ImagePropertyElement; 00132 static const String TextPropertyElement; 00133 static const String FontPropertyElement; 00134 static const String ColourElement; 00135 static const String EventLinkDefinitionElement; 00136 static const String EventLinkTargetElement; 00137 00138 static const String NamedAreaSourceElement; 00140 static const String EventActionElement; 00141 // attribute names 00142 static const String VersionAttribute; 00143 static const String TopLeftAttribute; 00144 static const String TopRightAttribute; 00145 static const String BottomLeftAttribute; 00146 static const String BottomRightAttribute; 00147 static const String TypeAttribute; 00148 static const String NameAttribute; 00149 static const String PriorityAttribute; 00150 static const String SectionNameAttribute; 00151 static const String NameSuffixAttribute; 00152 static const String RendererAttribute; 00153 static const String LookAttribute; 00154 static const String ScaleAttribute; 00155 static const String OffsetAttribute; 00156 static const String ValueAttribute; 00157 static const String DimensionAttribute; 00158 static const String WidgetAttribute; 00159 static const String StringAttribute; 00160 static const String FontAttribute; 00161 static const String InitialValueAttribute; 00162 static const String ClippedAttribute; 00163 static const String OperatorAttribute; 00164 static const String PaddingAttribute; 00165 static const String LayoutOnWriteAttribute; 00166 static const String RedrawOnWriteAttribute; 00167 static const String TargetPropertyAttribute; 00168 static const String ControlPropertyAttribute; 00169 static const String ColourAttribute; 00170 static const String PropertyAttribute; 00171 static const String ControlValueAttribute; 00172 static const String ControlWidgetAttribute; 00173 00174 static const String HelpStringAttribute; 00176 static const String EventAttribute; 00178 static const String InheritsAttribute; 00180 static const String AutoWindowAttribute; 00182 static const String FireEventAttribute; 00184 static const String ActionAttribute; 00186 static const String ComponentAttribute; 00187 00188 protected: 00189 /************************************************************************* 00190 ChainedXMLHandler base class overrides 00191 *************************************************************************/ 00192 void elementStartLocal(const String& element, 00193 const XMLAttributes& attributes); 00194 void elementEndLocal(const String& element); 00195 00196 private: 00197 /************************************************************************* 00198 Typedefs 00199 *************************************************************************/ 00201 typedef void (Falagard_xmlHandler::*ElementStartHandler)(const XMLAttributes& attributes); 00203 typedef void (Falagard_xmlHandler::*ElementEndHandler)(); 00205 typedef std::map<String, ElementStartHandler, StringFastLessCompare> ElementStartHandlerMap; 00207 typedef std::map<String, ElementEndHandler, StringFastLessCompare> ElementEndHandlerMap; 00208 00209 /************************************************************************* 00210 helper methods 00211 **************************************************************************/ 00212 static argb_t hexStringToARGB(const String& str); 00213 00214 /************************************************************************* 00215 implementation methods 00216 **************************************************************************/ 00217 void assignAreaDimension(Dimension& dim); 00218 void assignColours(const ColourRect& colours); 00219 00224 void doBaseDimStart(const BaseDim* dim); 00225 00230 void elementFalagardStart(const XMLAttributes& attributes); 00231 00236 void elementWidgetLookStart(const XMLAttributes& attributes); 00237 00242 void elementChildStart(const XMLAttributes& attributes); 00243 00248 void elementImagerySectionStart(const XMLAttributes& attributes); 00249 00254 void elementStateImageryStart(const XMLAttributes& attributes); 00255 00260 void elementLayerStart(const XMLAttributes& attributes); 00261 00266 void elementSectionStart(const XMLAttributes& attributes); 00267 00272 void elementImageryComponentStart(const XMLAttributes& attributes); 00273 00278 void elementTextComponentStart(const XMLAttributes& attributes); 00279 00284 void elementFrameComponentStart(const XMLAttributes& attributes); 00285 00290 void elementAreaStart(const XMLAttributes& attributes); 00291 00296 void elementImageStart(const XMLAttributes& attributes); 00297 00302 void elementColoursStart(const XMLAttributes& attributes); 00303 00308 void elementVertFormatStart(const XMLAttributes& attributes); 00309 00314 void elementHorzFormatStart(const XMLAttributes& attributes); 00315 00320 void elementVertAlignmentStart(const XMLAttributes& attributes); 00321 00326 void elementHorzAlignmentStart(const XMLAttributes& attributes); 00327 00332 void elementPropertyStart(const XMLAttributes& attributes); 00333 00338 void elementDimStart(const XMLAttributes& attributes); 00339 00344 void elementUnifiedDimStart(const XMLAttributes& attributes); 00345 00350 void elementAbsoluteDimStart(const XMLAttributes& attributes); 00351 00356 void elementImageDimStart(const XMLAttributes& attributes); 00357 00362 void elementImagePropertyDimStart(const XMLAttributes& attributes); 00363 00368 void elementWidgetDimStart(const XMLAttributes& attributes); 00369 00374 void elementFontDimStart(const XMLAttributes& attributes); 00375 00380 void elementPropertyDimStart(const XMLAttributes& attributes); 00381 00386 void elementTextStart(const XMLAttributes& attributes); 00387 00392 void elementColourRectPropertyStart(const XMLAttributes& attributes); 00393 00398 void elementNamedAreaStart(const XMLAttributes& attributes); 00399 00404 void elementPropertyDefinitionStart(const XMLAttributes& attributes); 00405 00410 void elementPropertyLinkDefinitionStart(const XMLAttributes& attributes); 00411 00416 void elementOperatorDimStart(const XMLAttributes& attributes); 00417 00422 void elementVertFormatPropertyStart(const XMLAttributes& attributes); 00423 00428 void elementHorzFormatPropertyStart(const XMLAttributes& attributes); 00429 00434 void elementAreaPropertyStart(const XMLAttributes& attributes); 00435 00440 void elementImagePropertyStart(const XMLAttributes& attributes); 00441 00446 void elementTextPropertyStart(const XMLAttributes& attributes); 00447 00452 void elementFontPropertyStart(const XMLAttributes& attributes); 00453 00458 void elementColourStart(const XMLAttributes& attributes); 00459 00461 void elementPropertyLinkTargetStart(const XMLAttributes& attributes); 00462 00464 void elementAnimationDefinitionStart(const XMLAttributes& attributes); 00465 00467 void elementEventLinkDefinitionStart(const XMLAttributes& attributes); 00468 00470 void elementEventLinkTargetStart(const XMLAttributes& attributes); 00471 00473 void elementNamedAreaSourceStart(const XMLAttributes& attributes); 00475 void elementEventActionStart(const XMLAttributes& attributes); 00476 00481 void elementFalagardEnd(); 00482 00487 void elementWidgetLookEnd(); 00488 00493 void elementChildEnd(); 00494 00499 void elementImagerySectionEnd(); 00500 00505 void elementStateImageryEnd(); 00506 00511 void elementLayerEnd(); 00512 00517 void elementSectionEnd(); 00518 00523 void elementImageryComponentEnd(); 00524 00529 void elementTextComponentEnd(); 00530 00535 void elementFrameComponentEnd(); 00536 00541 void elementAreaEnd(); 00542 00547 void elementNamedAreaEnd(); 00548 00553 void elementAnyDimEnd(); 00554 00556 void elementPropertyLinkDefinitionEnd(); 00557 00559 void elementEventLinkDefinitionEnd(); 00560 00565 void registerElementStartHandler(const String& element, ElementStartHandler handler); 00566 00571 void registerElementEndHandler(const String& element, ElementEndHandler handler); 00572 00574 void processEventLinkTarget(const String& widget, const String& event); 00575 00576 /************************************************************************* 00577 Implementation Data 00578 *************************************************************************/ 00579 WidgetLookManager* d_manager; 00580 00581 // these are used to implement the handler without using a huge 00582 // if / else if /else construct, we just register the element name, and 00583 // handler member function, and everything else is done using those 00584 // mappings. 00585 ElementStartHandlerMap d_startHandlersMap; 00586 ElementEndHandlerMap d_endHandlersMap; 00587 00588 // these hold pointers to various objects under construction. 00589 WidgetLookFeel* d_widgetlook; 00590 WidgetComponent* d_childcomponent; 00591 ImagerySection* d_imagerysection; 00592 StateImagery* d_stateimagery; 00593 LayerSpecification* d_layer; 00594 SectionSpecification* d_section; 00595 ImageryComponent* d_imagerycomponent; 00596 ComponentArea* d_area; 00597 Dimension d_dimension; 00598 TextComponent* d_textcomponent; 00599 NamedArea* d_namedArea; 00600 FrameComponent* d_framecomponent; 00601 00602 std::vector<BaseDim* 00603 CEGUI_VECTOR_ALLOC(BaseDim*)> d_dimStack; 00604 00605 PropertyDefinitionBase* d_propertyLink; 00606 EventLinkDefinition* d_eventLink; 00607 }; 00608 00609 } // End of CEGUI namespace section 00610 00611 00612 #endif // end of guard _CEGUIFalagard_xmlHandler_h_ 00613