Crazy Eddies GUI System  0.7.0
CEGUIFalagard_xmlHandler.h
1 /***********************************************************************
2  filename: CEGUIFalagard_xmlHandler.h
3  created: Fri Jun 17 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 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 "../CEGUIXMLHandler.h"
32 #include "../CEGUIcolour.h"
33 #include "CEGUIFalDimensions.h"
34 #include "../CEGUIWindow.h"
35 #include <vector>
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
40  // forward refs
41  class WidgetLookManager;
42  class WidgetLookFeel;
43  class WidgetComponent;
44  class ImagerySection;
45  class StateImagery;
46  class LayerSpecification;
47  class SectionSpecification;
48  class ImageryComponent;
49  class ComponentArea;
50  class Dimension;
51  class TextComponent;
52  class NamedArea;
53  class FrameComponent;
54 
60  {
61  public:
67 
73 
74  /*************************************************************************
75  XMLHandler base class overrides
76  *************************************************************************/
77  void elementStart(const String& element, const XMLAttributes& attributes);
78  void elementEnd(const String& element);
79 
80  private:
81  /*************************************************************************
82  Typedefs
83  *************************************************************************/
85  typedef void (Falagard_xmlHandler::*ElementStartHandler)(const XMLAttributes& attributes);
87  typedef void (Falagard_xmlHandler::*ElementEndHandler)();
89  typedef std::map<String, ElementStartHandler, String::FastLessCompare> ElementStartHandlerMap;
91  typedef std::map<String, ElementEndHandler, String::FastLessCompare> ElementEndHandlerMap;
92 
93  /*************************************************************************
94  Implementation Constants
95  *************************************************************************/
96  // element names
97  static const String FalagardElement;
98  static const String WidgetLookElement;
99  static const String ChildElement;
100  static const String ImagerySectionElement;
101  static const String StateImageryElement;
102  static const String LayerElement;
103  static const String SectionElement;
104  static const String ImageryComponentElement;
105  static const String TextComponentElement;
106  static const String FrameComponentElement;
107  static const String AreaElement;
108  static const String ImageElement;
109  static const String ColoursElement;
110  static const String VertFormatElement;
111  static const String HorzFormatElement;
112  static const String VertAlignmentElement;
113  static const String HorzAlignmentElement;
114  static const String PropertyElement;
115  static const String DimElement;
116  static const String UnifiedDimElement;
117  static const String AbsoluteDimElement;
118  static const String ImageDimElement;
119  static const String WidgetDimElement;
120  static const String FontDimElement;
121  static const String PropertyDimElement;
122  static const String TextElement;
123  static const String ColourPropertyElement;
124  static const String ColourRectPropertyElement;
125  static const String NamedAreaElement;
126  static const String PropertyDefinitionElement;
127  static const String PropertyLinkDefinitionElement;
128  static const String DimOperatorElement;
129  static const String VertFormatPropertyElement;
130  static const String HorzFormatPropertyElement;
131  static const String AreaPropertyElement;
132  static const String ImagePropertyElement;
133  static const String TextPropertyElement;
134  static const String FontPropertyElement;
135  static const String ColourElement;
136  // attribute names
137  static const String TopLeftAttribute;
138  static const String TopRightAttribute;
139  static const String BottomLeftAttribute;
140  static const String BottomRightAttribute;
141  static const String ImagesetAttribute;
142  static const String ImageAttribute;
143  static const String TypeAttribute;
144  static const String NameAttribute;
145  static const String PriorityAttribute;
146  static const String SectionNameAttribute;
147  static const String NameSuffixAttribute;
148  static const String RendererAttribute;
149  static const String LookAttribute;
150  static const String ScaleAttribute;
151  static const String OffsetAttribute;
152  static const String ValueAttribute;
153  static const String DimensionAttribute;
154  static const String WidgetAttribute;
155  static const String StringAttribute;
156  static const String FontAttribute;
157  static const String InitialValueAttribute;
158  static const String ClippedAttribute;
159  static const String OperatorAttribute;
160  static const String PaddingAttribute;
161  static const String LayoutOnWriteAttribute;
162  static const String RedrawOnWriteAttribute;
163  static const String TargetPropertyAttribute;
164  static const String ControlPropertyAttribute;
165  static const String ColourAttribute;
166 
167  /*************************************************************************
168  helper methods
169  **************************************************************************/
170  static argb_t hexStringToARGB(const String& str);
171 
172  /*************************************************************************
173  implementation methods
174  **************************************************************************/
175  void assignAreaDimension(Dimension& dim);
176  void assignColours(const ColourRect& colours);
177 
182  void doBaseDimStart(const BaseDim* dim);
183 
188  void elementFalagardStart(const XMLAttributes& attributes);
189 
194  void elementWidgetLookStart(const XMLAttributes& attributes);
195 
200  void elementChildStart(const XMLAttributes& attributes);
201 
206  void elementImagerySectionStart(const XMLAttributes& attributes);
207 
212  void elementStateImageryStart(const XMLAttributes& attributes);
213 
218  void elementLayerStart(const XMLAttributes& attributes);
219 
224  void elementSectionStart(const XMLAttributes& attributes);
225 
230  void elementImageryComponentStart(const XMLAttributes& attributes);
231 
236  void elementTextComponentStart(const XMLAttributes& attributes);
237 
242  void elementFrameComponentStart(const XMLAttributes& attributes);
243 
248  void elementAreaStart(const XMLAttributes& attributes);
249 
254  void elementImageStart(const XMLAttributes& attributes);
255 
260  void elementColoursStart(const XMLAttributes& attributes);
261 
266  void elementVertFormatStart(const XMLAttributes& attributes);
267 
272  void elementHorzFormatStart(const XMLAttributes& attributes);
273 
278  void elementVertAlignmentStart(const XMLAttributes& attributes);
279 
284  void elementHorzAlignmentStart(const XMLAttributes& attributes);
285 
290  void elementPropertyStart(const XMLAttributes& attributes);
291 
296  void elementDimStart(const XMLAttributes& attributes);
297 
302  void elementUnifiedDimStart(const XMLAttributes& attributes);
303 
308  void elementAbsoluteDimStart(const XMLAttributes& attributes);
309 
314  void elementImageDimStart(const XMLAttributes& attributes);
315 
320  void elementWidgetDimStart(const XMLAttributes& attributes);
321 
326  void elementFontDimStart(const XMLAttributes& attributes);
327 
332  void elementPropertyDimStart(const XMLAttributes& attributes);
333 
338  void elementTextStart(const XMLAttributes& attributes);
339 
344  void elementColourPropertyStart(const XMLAttributes& attributes);
345 
350  void elementColourRectPropertyStart(const XMLAttributes& attributes);
351 
356  void elementNamedAreaStart(const XMLAttributes& attributes);
357 
362  void elementPropertyDefinitionStart(const XMLAttributes& attributes);
363 
368  void elementPropertyLinkDefinitionStart(const XMLAttributes& attributes);
369 
374  void elementDimOperatorStart(const XMLAttributes& attributes);
375 
380  void elementVertFormatPropertyStart(const XMLAttributes& attributes);
381 
386  void elementHorzFormatPropertyStart(const XMLAttributes& attributes);
387 
392  void elementAreaPropertyStart(const XMLAttributes& attributes);
393 
398  void elementImagePropertyStart(const XMLAttributes& attributes);
399 
404  void elementTextPropertyStart(const XMLAttributes& attributes);
405 
410  void elementFontPropertyStart(const XMLAttributes& attributes);
411 
416  void elementColourStart(const XMLAttributes& attributes);
417 
422  void elementFalagardEnd();
423 
428  void elementWidgetLookEnd();
429 
434  void elementChildEnd();
435 
440  void elementImagerySectionEnd();
441 
446  void elementStateImageryEnd();
447 
452  void elementLayerEnd();
453 
458  void elementSectionEnd();
459 
464  void elementImageryComponentEnd();
465 
470  void elementTextComponentEnd();
471 
476  void elementFrameComponentEnd();
477 
482  void elementAreaEnd();
483 
488  void elementNamedAreaEnd();
489 
494  void elementAnyDimEnd();
495 
500  void registerElementStartHandler(const String& element, ElementStartHandler handler);
501 
506  void registerElementEndHandler(const String& element, ElementEndHandler handler);
507 
508  /*************************************************************************
509  Implementation Data
510  *************************************************************************/
511  WidgetLookManager* d_manager;
512 
513  // these are used to implement the handler without using a huge
514  // if / else if /else construct, we just register the element name, and
515  // handler member function, and everything else is done using those
516  // mappings.
517  ElementStartHandlerMap d_startHandlersMap;
518  ElementEndHandlerMap d_endHandlersMap;
519 
520  // these hold pointers to various objects under construction.
521  WidgetLookFeel* d_widgetlook;
522  WidgetComponent* d_childcomponent;
523  ImagerySection* d_imagerysection;
524  StateImagery* d_stateimagery;
525  LayerSpecification* d_layer;
526  SectionSpecification* d_section;
527  ImageryComponent* d_imagerycomponent;
528  ComponentArea* d_area;
529  Dimension d_dimension;
530  TextComponent* d_textcomponent;
531  NamedArea* d_namedArea;
532  FrameComponent* d_framecomponent;
533 
534  std::vector<BaseDim*> d_dimStack;
535  };
536 
537 } // End of CEGUI namespace section
538 
539 
540 #endif // end of guard _CEGUIFalagard_xmlHandler_h_