Crazy Eddies GUI System 0.7.6
CEGUIFalagard_xmlHandler.h
00001 /***********************************************************************
00002     filename:   CEGUIFalagard_xmlHandler.h
00003     created:    Fri Jun 17 2005
00004     author:     Paul D Turner <paul@cegui.org.uk>
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIFalagard_xmlHandler_h_
00029 #define _CEGUIFalagard_xmlHandler_h_
00030 
00031 #include "../CEGUIChainedXMLHandler.h"
00032 #include "../CEGUIcolour.h"
00033 #include "CEGUIFalDimensions.h"
00034 #include "../CEGUIWindow.h"
00035 #include <vector>
00036 
00037 // Start of CEGUI namespace section
00038 namespace CEGUI
00039 {
00040     // forward refs
00041     class WidgetLookManager;
00042     class WidgetLookFeel;
00043     class WidgetComponent;
00044     class ImagerySection;
00045     class StateImagery;
00046     class LayerSpecification;
00047     class SectionSpecification;
00048     class ImageryComponent;
00049     class ComponentArea;
00050     class Dimension;
00051     class TextComponent;
00052     class NamedArea;
00053     class FrameComponent;
00054     class PropertyLinkDefinition;
00055 
00060     class Falagard_xmlHandler : public ChainedXMLHandler
00061     {
00062     public:
00067         Falagard_xmlHandler(WidgetLookManager* mgr);
00068 
00073         ~Falagard_xmlHandler();
00074 
00075     protected:
00076         /*************************************************************************
00077             ChainedXMLHandler base class overrides
00078         *************************************************************************/
00079         void elementStartLocal(const String& element,
00080                                const XMLAttributes& attributes);
00081         void elementEndLocal(const String& element);
00082 
00083     private:
00084         /*************************************************************************
00085             Typedefs
00086         *************************************************************************/
00088         typedef void (Falagard_xmlHandler::*ElementStartHandler)(const XMLAttributes& attributes);
00090         typedef void (Falagard_xmlHandler::*ElementEndHandler)();
00092         typedef std::map<String, ElementStartHandler, String::FastLessCompare> ElementStartHandlerMap;
00094         typedef std::map<String, ElementEndHandler, String::FastLessCompare> ElementEndHandlerMap;
00095 
00096         /*************************************************************************
00097             Implementation Constants
00098         *************************************************************************/
00099         // element names
00100         static const String FalagardElement;            
00101         static const String WidgetLookElement;          
00102         static const String ChildElement;               
00103         static const String ImagerySectionElement;      
00104         static const String StateImageryElement;        
00105         static const String LayerElement;               
00106         static const String SectionElement;             
00107         static const String ImageryComponentElement;    
00108         static const String TextComponentElement;       
00109         static const String FrameComponentElement;      
00110         static const String AreaElement;                
00111         static const String ImageElement;               
00112         static const String ColoursElement;             
00113         static const String VertFormatElement;          
00114         static const String HorzFormatElement;          
00115         static const String VertAlignmentElement;       
00116         static const String HorzAlignmentElement;       
00117         static const String PropertyElement;            
00118                 static const String DimElement;                 
00119                 static const String UnifiedDimElement;          
00120         static const String AbsoluteDimElement;         
00121         static const String ImageDimElement;            
00122         static const String WidgetDimElement;           
00123         static const String FontDimElement;             
00124         static const String PropertyDimElement;         
00125         static const String TextElement;                
00126         static const String ColourPropertyElement;      
00127         static const String ColourRectPropertyElement;  
00128         static const String NamedAreaElement;           
00129         static const String PropertyDefinitionElement;  
00130         static const String PropertyLinkDefinitionElement;  
00131         static const String PropertyLinkTargetElement;  
00132         static const String DimOperatorElement;         
00133         static const String VertFormatPropertyElement;  
00134         static const String HorzFormatPropertyElement;  
00135         static const String AreaPropertyElement;        
00136         static const String ImagePropertyElement;       
00137         static const String TextPropertyElement;        
00138         static const String FontPropertyElement;        
00139         static const String ColourElement;              
00140         // attribute names
00141         static const String TopLeftAttribute;           
00142         static const String TopRightAttribute;          
00143         static const String BottomLeftAttribute;        
00144         static const String BottomRightAttribute;       
00145         static const String ImagesetAttribute;          
00146         static const String ImageAttribute;             
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;
00175 
00176         /*************************************************************************
00177             helper methods
00178         **************************************************************************/
00179         static argb_t hexStringToARGB(const String& str);
00180 
00181         /*************************************************************************
00182             implementation methods
00183         **************************************************************************/
00184         void assignAreaDimension(Dimension& dim);
00185         void assignColours(const ColourRect& colours);
00186 
00191         void doBaseDimStart(const BaseDim* dim);
00192 
00197         void elementFalagardStart(const XMLAttributes& attributes);
00198 
00203         void elementWidgetLookStart(const XMLAttributes& attributes);
00204 
00209         void elementChildStart(const XMLAttributes& attributes);
00210 
00215         void elementImagerySectionStart(const XMLAttributes& attributes);
00216 
00221         void elementStateImageryStart(const XMLAttributes& attributes);
00222 
00227         void elementLayerStart(const XMLAttributes& attributes);
00228 
00233         void elementSectionStart(const XMLAttributes& attributes);
00234 
00239         void elementImageryComponentStart(const XMLAttributes& attributes);
00240 
00245         void elementTextComponentStart(const XMLAttributes& attributes);
00246 
00251         void elementFrameComponentStart(const XMLAttributes& attributes);
00252 
00257         void elementAreaStart(const XMLAttributes& attributes);
00258 
00263         void elementImageStart(const XMLAttributes& attributes);
00264 
00269         void elementColoursStart(const XMLAttributes& attributes);
00270 
00275         void elementVertFormatStart(const XMLAttributes& attributes);
00276 
00281         void elementHorzFormatStart(const XMLAttributes& attributes);
00282 
00287         void elementVertAlignmentStart(const XMLAttributes& attributes);
00288 
00293         void elementHorzAlignmentStart(const XMLAttributes& attributes);
00294 
00299         void elementPropertyStart(const XMLAttributes& attributes);
00300 
00305         void elementDimStart(const XMLAttributes& attributes);
00306 
00311         void elementUnifiedDimStart(const XMLAttributes& attributes);
00312 
00317         void elementAbsoluteDimStart(const XMLAttributes& attributes);
00318 
00323         void elementImageDimStart(const XMLAttributes& attributes);
00324 
00329         void elementWidgetDimStart(const XMLAttributes& attributes);
00330 
00335         void elementFontDimStart(const XMLAttributes& attributes);
00336 
00341         void elementPropertyDimStart(const XMLAttributes& attributes);
00342 
00347         void elementTextStart(const XMLAttributes& attributes);
00348 
00353         void elementColourPropertyStart(const XMLAttributes& attributes);
00354 
00359         void elementColourRectPropertyStart(const XMLAttributes& attributes);
00360 
00365         void elementNamedAreaStart(const XMLAttributes& attributes);
00366 
00371         void elementPropertyDefinitionStart(const XMLAttributes& attributes);
00372 
00377         void elementPropertyLinkDefinitionStart(const XMLAttributes& attributes);
00378 
00383         void elementDimOperatorStart(const XMLAttributes& attributes);
00384 
00389         void elementVertFormatPropertyStart(const XMLAttributes& attributes);
00390 
00395         void elementHorzFormatPropertyStart(const XMLAttributes& attributes);
00396 
00401         void elementAreaPropertyStart(const XMLAttributes& attributes);
00402 
00407         void elementImagePropertyStart(const XMLAttributes& attributes);
00408 
00413         void elementTextPropertyStart(const XMLAttributes& attributes);
00414 
00419         void elementFontPropertyStart(const XMLAttributes& attributes);
00420 
00425         void elementColourStart(const XMLAttributes& attributes);
00426 
00428         void elementPropertyLinkTargetStart(const XMLAttributes& attributes);
00429         
00431         void elementAnimationDefinitionStart(const XMLAttributes& attributes);
00432 
00437         void elementFalagardEnd();
00438 
00443         void elementWidgetLookEnd();
00444 
00449         void elementChildEnd();
00450 
00455         void elementImagerySectionEnd();
00456 
00461         void elementStateImageryEnd();
00462 
00467         void elementLayerEnd();
00468 
00473         void elementSectionEnd();
00474 
00479         void elementImageryComponentEnd();
00480 
00485         void elementTextComponentEnd();
00486 
00491         void elementFrameComponentEnd();
00492 
00497         void elementAreaEnd();
00498 
00503         void elementNamedAreaEnd();
00504 
00509         void elementAnyDimEnd();
00510 
00512         void elementPropertyLinkDefinitionEnd();
00513 
00518         void registerElementStartHandler(const String& element, ElementStartHandler handler);
00519 
00524         void registerElementEndHandler(const String& element, ElementEndHandler handler);
00525 
00526         /*************************************************************************
00527             Implementation Data
00528         *************************************************************************/
00529         WidgetLookManager* d_manager;
00530 
00531         // these are used to implement the handler without using a huge
00532         // if / else if /else construct, we just register the element name, and
00533         // handler member function, and everything else is done using those
00534         // mappings.
00535         ElementStartHandlerMap  d_startHandlersMap;
00536         ElementEndHandlerMap    d_endHandlersMap;
00537 
00538         // these hold pointers to various objects under construction.
00539         WidgetLookFeel*     d_widgetlook;
00540         WidgetComponent*    d_childcomponent;
00541         ImagerySection*     d_imagerysection;
00542         StateImagery*       d_stateimagery;
00543         LayerSpecification* d_layer;
00544         SectionSpecification* d_section;
00545         ImageryComponent*   d_imagerycomponent;
00546         ComponentArea*   d_area;
00547         Dimension       d_dimension;
00548         TextComponent*  d_textcomponent;
00549         NamedArea*      d_namedArea;
00550         FrameComponent*  d_framecomponent;
00551 
00552         std::vector<BaseDim*>    d_dimStack;
00553 
00554         PropertyLinkDefinition* d_propertyLink;
00555     };
00556 
00557 } // End of  CEGUI namespace section
00558 
00559 
00560 #endif  // end of guard _CEGUIFalagard_xmlHandler_h_
00561