Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
falagard/XMLHandler.h
1 /***********************************************************************
2  filename: CEGUIXMLHandler.h
3  created: Fri Jun 17 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIFalagard_xmlHandler_h_
29 #define _CEGUIFalagard_xmlHandler_h_
30 
31 #include "../ChainedXMLHandler.h"
32 #include "./Dimensions.h"
33 #include "../Window.h"
34 #include <vector>
35 
36 // Start of CEGUI namespace section
37 namespace CEGUI
38 {
39  // forward refs
40  class WidgetLookManager;
41  class WidgetLookFeel;
42  class WidgetComponent;
43  class ImagerySection;
44  class StateImagery;
45  class LayerSpecification;
46  class SectionSpecification;
47  class ImageryComponent;
48  class ComponentArea;
49  class Dimension;
50  class TextComponent;
51  class NamedArea;
52  class FrameComponent;
53  class PropertyDefinitionBase;
54  class EventLinkDefinition;
55 
61  {
62  public:
68 
74 
76  static const String NativeVersion;
77 
78  protected:
79  /*************************************************************************
80  ChainedXMLHandler base class overrides
81  *************************************************************************/
82  void elementStartLocal(const String& element,
83  const XMLAttributes& attributes);
84  void elementEndLocal(const String& element);
85 
86  private:
87  /*************************************************************************
88  Typedefs
89  *************************************************************************/
91  typedef void (Falagard_xmlHandler::*ElementStartHandler)(const XMLAttributes& attributes);
93  typedef void (Falagard_xmlHandler::*ElementEndHandler)();
95  typedef std::map<String, ElementStartHandler, StringFastLessCompare> ElementStartHandlerMap;
97  typedef std::map<String, ElementEndHandler, StringFastLessCompare> ElementEndHandlerMap;
98 
99  /*************************************************************************
100  Implementation Constants
101  *************************************************************************/
102  // element names
103  static const String FalagardElement;
104  static const String WidgetLookElement;
105  static const String ChildElement;
106  static const String ImagerySectionElement;
107  static const String StateImageryElement;
108  static const String LayerElement;
109  static const String SectionElement;
110  static const String ImageryComponentElement;
111  static const String TextComponentElement;
112  static const String FrameComponentElement;
113  static const String AreaElement;
114  static const String ImageElement;
115  static const String ColoursElement;
116  static const String VertFormatElement;
117  static const String HorzFormatElement;
118  static const String VertAlignmentElement;
119  static const String HorzAlignmentElement;
120  static const String PropertyElement;
121  static const String DimElement;
122  static const String UnifiedDimElement;
123  static const String AbsoluteDimElement;
124  static const String ImageDimElement;
125  static const String ImagePropertyDimElement;
126  static const String WidgetDimElement;
127  static const String FontDimElement;
128  static const String PropertyDimElement;
129  static const String TextElement;
130  static const String ColourPropertyElement;
131  static const String ColourRectPropertyElement;
132  static const String NamedAreaElement;
133  static const String PropertyDefinitionElement;
134  static const String PropertyLinkDefinitionElement;
135  static const String PropertyLinkTargetElement;
136  static const String OperatorDimElement;
137  static const String VertFormatPropertyElement;
138  static const String HorzFormatPropertyElement;
139  static const String AreaPropertyElement;
140  static const String ImagePropertyElement;
141  static const String TextPropertyElement;
142  static const String FontPropertyElement;
143  static const String ColourElement;
144  static const String EventLinkDefinitionElement;
145  static const String EventLinkTargetElement;
146 
147  static const String NamedAreaSourceElement;
149  static const String EventActionElement;
150  // attribute names
151  static const String TopLeftAttribute;
152  static const String TopRightAttribute;
153  static const String BottomLeftAttribute;
154  static const String BottomRightAttribute;
155  static const String TypeAttribute;
156  static const String NameAttribute;
157  static const String PriorityAttribute;
158  static const String SectionNameAttribute;
159  static const String NameSuffixAttribute;
160  static const String RendererAttribute;
161  static const String LookAttribute;
162  static const String ScaleAttribute;
163  static const String OffsetAttribute;
164  static const String ValueAttribute;
165  static const String DimensionAttribute;
166  static const String WidgetAttribute;
167  static const String StringAttribute;
168  static const String FontAttribute;
169  static const String InitialValueAttribute;
170  static const String ClippedAttribute;
171  static const String OperatorAttribute;
172  static const String PaddingAttribute;
173  static const String LayoutOnWriteAttribute;
174  static const String RedrawOnWriteAttribute;
175  static const String TargetPropertyAttribute;
176  static const String ControlPropertyAttribute;
177  static const String ColourAttribute;
178  static const String PropertyAttribute;
179  static const String ControlValueAttribute;
180  static const String ControlWidgetAttribute;
181 
182  static const String HelpStringAttribute;
184  static const String EventAttribute;
186  static const String InheritsAttribute;
188  static const String AutoWindowAttribute;
190  static const String FireEventAttribute;
192  static const String ActionAttribute;
194  static const String ComponentAttribute;
195 
196  /*************************************************************************
197  helper methods
198  **************************************************************************/
199  static argb_t hexStringToARGB(const String& str);
200 
201  /*************************************************************************
202  implementation methods
203  **************************************************************************/
204  void assignAreaDimension(Dimension& dim);
205  void assignColours(const ColourRect& colours);
206 
211  void doBaseDimStart(const BaseDim* dim);
212 
217  void elementFalagardStart(const XMLAttributes& attributes);
218 
223  void elementWidgetLookStart(const XMLAttributes& attributes);
224 
229  void elementChildStart(const XMLAttributes& attributes);
230 
235  void elementImagerySectionStart(const XMLAttributes& attributes);
236 
241  void elementStateImageryStart(const XMLAttributes& attributes);
242 
247  void elementLayerStart(const XMLAttributes& attributes);
248 
253  void elementSectionStart(const XMLAttributes& attributes);
254 
259  void elementImageryComponentStart(const XMLAttributes& attributes);
260 
265  void elementTextComponentStart(const XMLAttributes& attributes);
266 
271  void elementFrameComponentStart(const XMLAttributes& attributes);
272 
277  void elementAreaStart(const XMLAttributes& attributes);
278 
283  void elementImageStart(const XMLAttributes& attributes);
284 
289  void elementColoursStart(const XMLAttributes& attributes);
290 
295  void elementVertFormatStart(const XMLAttributes& attributes);
296 
301  void elementHorzFormatStart(const XMLAttributes& attributes);
302 
307  void elementVertAlignmentStart(const XMLAttributes& attributes);
308 
313  void elementHorzAlignmentStart(const XMLAttributes& attributes);
314 
319  void elementPropertyStart(const XMLAttributes& attributes);
320 
325  void elementDimStart(const XMLAttributes& attributes);
326 
331  void elementUnifiedDimStart(const XMLAttributes& attributes);
332 
337  void elementAbsoluteDimStart(const XMLAttributes& attributes);
338 
343  void elementImageDimStart(const XMLAttributes& attributes);
344 
349  void elementImagePropertyDimStart(const XMLAttributes& attributes);
350 
355  void elementWidgetDimStart(const XMLAttributes& attributes);
356 
361  void elementFontDimStart(const XMLAttributes& attributes);
362 
367  void elementPropertyDimStart(const XMLAttributes& attributes);
368 
373  void elementTextStart(const XMLAttributes& attributes);
374 
379  void elementColourRectPropertyStart(const XMLAttributes& attributes);
380 
385  void elementNamedAreaStart(const XMLAttributes& attributes);
386 
391  void elementPropertyDefinitionStart(const XMLAttributes& attributes);
392 
397  void elementPropertyLinkDefinitionStart(const XMLAttributes& attributes);
398 
403  void elementOperatorDimStart(const XMLAttributes& attributes);
404 
409  void elementVertFormatPropertyStart(const XMLAttributes& attributes);
410 
415  void elementHorzFormatPropertyStart(const XMLAttributes& attributes);
416 
421  void elementAreaPropertyStart(const XMLAttributes& attributes);
422 
427  void elementImagePropertyStart(const XMLAttributes& attributes);
428 
433  void elementTextPropertyStart(const XMLAttributes& attributes);
434 
439  void elementFontPropertyStart(const XMLAttributes& attributes);
440 
445  void elementColourStart(const XMLAttributes& attributes);
446 
448  void elementPropertyLinkTargetStart(const XMLAttributes& attributes);
449 
451  void elementAnimationDefinitionStart(const XMLAttributes& attributes);
452 
454  void elementEventLinkDefinitionStart(const XMLAttributes& attributes);
455 
457  void elementEventLinkTargetStart(const XMLAttributes& attributes);
458 
460  void elementNamedAreaSourceStart(const XMLAttributes& attributes);
462  void elementEventActionStart(const XMLAttributes& attributes);
463 
468  void elementFalagardEnd();
469 
474  void elementWidgetLookEnd();
475 
480  void elementChildEnd();
481 
486  void elementImagerySectionEnd();
487 
492  void elementStateImageryEnd();
493 
498  void elementLayerEnd();
499 
504  void elementSectionEnd();
505 
510  void elementImageryComponentEnd();
511 
516  void elementTextComponentEnd();
517 
522  void elementFrameComponentEnd();
523 
528  void elementAreaEnd();
529 
534  void elementNamedAreaEnd();
535 
540  void elementAnyDimEnd();
541 
543  void elementPropertyLinkDefinitionEnd();
544 
546  void elementEventLinkDefinitionEnd();
547 
552  void registerElementStartHandler(const String& element, ElementStartHandler handler);
553 
558  void registerElementEndHandler(const String& element, ElementEndHandler handler);
559 
561  void processEventLinkTarget(const String& widget, const String& event);
562 
563  /*************************************************************************
564  Implementation Data
565  *************************************************************************/
566  WidgetLookManager* d_manager;
567 
568  // these are used to implement the handler without using a huge
569  // if / else if /else construct, we just register the element name, and
570  // handler member function, and everything else is done using those
571  // mappings.
572  ElementStartHandlerMap d_startHandlersMap;
573  ElementEndHandlerMap d_endHandlersMap;
574 
575  // these hold pointers to various objects under construction.
576  WidgetLookFeel* d_widgetlook;
577  WidgetComponent* d_childcomponent;
578  ImagerySection* d_imagerysection;
579  StateImagery* d_stateimagery;
580  LayerSpecification* d_layer;
581  SectionSpecification* d_section;
582  ImageryComponent* d_imagerycomponent;
583  ComponentArea* d_area;
584  Dimension d_dimension;
585  TextComponent* d_textcomponent;
586  NamedArea* d_namedArea;
587  FrameComponent* d_framecomponent;
588 
589  std::vector<BaseDim*
590  CEGUI_VECTOR_ALLOC(BaseDim*)> d_dimStack;
591 
592  PropertyDefinitionBase* d_propertyLink;
593  EventLinkDefinition* d_eventLink;
594  };
595 
596 } // End of CEGUI namespace section
597 
598 
599 #endif // end of guard _CEGUIFalagard_xmlHandler_h_
600