Crazy Eddie's GUI System  0.8.7
falagard/XMLHandler.h
1 /***********************************************************************
2  created: Fri Jun 17 2005
3  author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIFalagard_xmlHandler_h_
28 #define _CEGUIFalagard_xmlHandler_h_
29 
30 #include "../ChainedXMLHandler.h"
31 #include "./Dimensions.h"
32 #include "../Window.h"
33 #include <vector>
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
43  // forward refs
44  class WidgetLookManager;
45  class WidgetLookFeel;
46  class WidgetComponent;
47  class ImagerySection;
48  class StateImagery;
49  class LayerSpecification;
50  class SectionSpecification;
51  class ImageryComponent;
52  class ComponentArea;
53  class Dimension;
54  class TextComponent;
55  class NamedArea;
56  class FrameComponent;
57  class PropertyDefinitionBase;
58  class EventLinkDefinition;
59 
64  class CEGUIEXPORT Falagard_xmlHandler : public ChainedXMLHandler
65  {
66  public:
71  Falagard_xmlHandler(WidgetLookManager* mgr);
72 
77  ~Falagard_xmlHandler();
78 
80  static const String NativeVersion;
81 
83  static const String PropertyDefinitionHelpDefaultValue;
84 
86  static const String PropertyLinkDefinitionHelpDefaultValue;
87 
89  static const String GenericDataType;
90 
91 
93  static const String ParentIdentifier;
94 
95  /*************************************************************************
96  XML element and attribute name constants
97  *************************************************************************/
98  // element names
99  static const String FalagardElement;
100  static const String WidgetLookElement;
101  static const String ChildElement;
102  static const String ImagerySectionElement;
103  static const String StateImageryElement;
104  static const String LayerElement;
105  static const String SectionElement;
106  static const String ImageryComponentElement;
107  static const String TextComponentElement;
108  static const String FrameComponentElement;
109  static const String AreaElement;
110  static const String ImageElement;
111  static const String ColoursElement;
112  static const String VertFormatElement;
113  static const String HorzFormatElement;
114  static const String VertAlignmentElement;
115  static const String HorzAlignmentElement;
116  static const String PropertyElement;
117  static const String DimElement;
118  static const String UnifiedDimElement;
119  static const String AbsoluteDimElement;
120  static const String ImageDimElement;
121  static const String ImagePropertyDimElement;
122  static const String WidgetDimElement;
123  static const String FontDimElement;
124  static const String PropertyDimElement;
125  static const String TextElement;
126  static const String ColourPropertyElement;
127  static const String ColourRectPropertyElement;
128  static const String NamedAreaElement;
129  static const String PropertyDefinitionElement;
130  static const String PropertyLinkDefinitionElement;
131  static const String PropertyLinkTargetElement;
132  static const String OperatorDimElement;
133  static const String VertFormatPropertyElement;
134  static const String HorzFormatPropertyElement;
135  static const String AreaPropertyElement;
136  static const String ImagePropertyElement;
137  static const String TextPropertyElement;
138  static const String FontPropertyElement;
139  static const String ColourElement;
140  static const String EventLinkDefinitionElement;
141  static const String EventLinkTargetElement;
142  static const String NamedAreaSourceElement;
145  static const String EventActionElement;
146  // attribute names
147  static const String VersionAttribute;
148  static const String TopLeftAttribute;
149  static const String TopRightAttribute;
150  static const String BottomLeftAttribute;
151  static const String BottomRightAttribute;
152  static const String TypeAttribute;
153  static const String NameAttribute;
154  static const String PriorityAttribute;
155  static const String SectionNameAttribute;
156  static const String NameSuffixAttribute;
157  static const String RendererAttribute;
158  static const String LookAttribute;
159  static const String ScaleAttribute;
160  static const String OffsetAttribute;
161  static const String ValueAttribute;
162  static const String DimensionAttribute;
163  static const String WidgetAttribute;
164  static const String StringAttribute;
165  static const String FontAttribute;
166  static const String InitialValueAttribute;
167  static const String ClippedAttribute;
168  static const String OperatorAttribute;
169  static const String PaddingAttribute;
170  static const String LayoutOnWriteAttribute;
171  static const String RedrawOnWriteAttribute;
172  static const String TargetPropertyAttribute;
173  static const String ControlPropertyAttribute;
174  static const String ColourAttribute;
175  static const String PropertyAttribute;
176  static const String ControlValueAttribute;
177  static const String ControlWidgetAttribute;
178  static const String HelpStringAttribute;
181  static const String EventAttribute;
183  static const String InheritsAttribute;
185  static const String AutoWindowAttribute;
187  static const String FireEventAttribute;
189  static const String ActionAttribute;
191  static const String ComponentAttribute;
192 
193  protected:
194  /*************************************************************************
195  ChainedXMLHandler base class overrides
196  *************************************************************************/
197  void elementStartLocal(const String& element,
198  const XMLAttributes& attributes);
199  void elementEndLocal(const String& element);
200 
201  private:
202  /*************************************************************************
203  Typedefs
204  *************************************************************************/
206  typedef void (Falagard_xmlHandler::*ElementStartHandler)(const XMLAttributes& attributes);
208  typedef void (Falagard_xmlHandler::*ElementEndHandler)();
210  typedef std::map<String, ElementStartHandler, StringFastLessCompare> ElementStartHandlerMap;
212  typedef std::map<String, ElementEndHandler, StringFastLessCompare> ElementEndHandlerMap;
213 
214  /*************************************************************************
215  helper methods
216  **************************************************************************/
217  static argb_t hexStringToARGB(const String& str);
218 
219  /*************************************************************************
220  implementation methods
221  **************************************************************************/
222  void assignAreaDimension(Dimension& dim);
223  void assignColours(const ColourRect& colours);
224 
229  void doBaseDimStart(const BaseDim* dim);
230 
235  void elementFalagardStart(const XMLAttributes& attributes);
236 
241  void elementWidgetLookStart(const XMLAttributes& attributes);
242 
247  void elementChildStart(const XMLAttributes& attributes);
248 
253  void elementImagerySectionStart(const XMLAttributes& attributes);
254 
259  void elementStateImageryStart(const XMLAttributes& attributes);
260 
265  void elementLayerStart(const XMLAttributes& attributes);
266 
271  void elementSectionStart(const XMLAttributes& attributes);
272 
277  void elementImageryComponentStart(const XMLAttributes& attributes);
278 
283  void elementTextComponentStart(const XMLAttributes& attributes);
284 
289  void elementFrameComponentStart(const XMLAttributes& attributes);
290 
295  void elementAreaStart(const XMLAttributes& attributes);
296 
301  void elementImageStart(const XMLAttributes& attributes);
302 
307  void elementColoursStart(const XMLAttributes& attributes);
308 
313  void elementVertFormatStart(const XMLAttributes& attributes);
314 
319  void elementHorzFormatStart(const XMLAttributes& attributes);
320 
325  void elementVertAlignmentStart(const XMLAttributes& attributes);
326 
331  void elementHorzAlignmentStart(const XMLAttributes& attributes);
332 
337  void elementPropertyStart(const XMLAttributes& attributes);
338 
343  void elementDimStart(const XMLAttributes& attributes);
344 
349  void elementUnifiedDimStart(const XMLAttributes& attributes);
350 
355  void elementAbsoluteDimStart(const XMLAttributes& attributes);
356 
361  void elementImageDimStart(const XMLAttributes& attributes);
362 
367  void elementImagePropertyDimStart(const XMLAttributes& attributes);
368 
373  void elementWidgetDimStart(const XMLAttributes& attributes);
374 
379  void elementFontDimStart(const XMLAttributes& attributes);
380 
385  void elementPropertyDimStart(const XMLAttributes& attributes);
386 
391  void elementTextStart(const XMLAttributes& attributes);
392 
397  void elementColourRectPropertyStart(const XMLAttributes& attributes);
398 
403  void elementNamedAreaStart(const XMLAttributes& attributes);
404 
409  void elementPropertyDefinitionStart(const XMLAttributes& attributes);
410 
415  void elementPropertyLinkDefinitionStart(const XMLAttributes& attributes);
416 
421  void elementOperatorDimStart(const XMLAttributes& attributes);
422 
427  void elementVertFormatPropertyStart(const XMLAttributes& attributes);
428 
433  void elementHorzFormatPropertyStart(const XMLAttributes& attributes);
434 
439  void elementAreaPropertyStart(const XMLAttributes& attributes);
440 
445  void elementImagePropertyStart(const XMLAttributes& attributes);
446 
451  void elementTextPropertyStart(const XMLAttributes& attributes);
452 
457  void elementFontPropertyStart(const XMLAttributes& attributes);
458 
463  void elementColourStart(const XMLAttributes& attributes);
464 
466  void elementPropertyLinkTargetStart(const XMLAttributes& attributes);
467 
469  void elementAnimationDefinitionStart(const XMLAttributes& attributes);
470 
472  void elementEventLinkDefinitionStart(const XMLAttributes& attributes);
473 
475  void elementEventLinkTargetStart(const XMLAttributes& attributes);
476 
478  void elementNamedAreaSourceStart(const XMLAttributes& attributes);
480  void elementEventActionStart(const XMLAttributes& attributes);
481 
486  void elementFalagardEnd();
487 
492  void elementWidgetLookEnd();
493 
498  void elementChildEnd();
499 
504  void elementImagerySectionEnd();
505 
510  void elementStateImageryEnd();
511 
516  void elementLayerEnd();
517 
522  void elementSectionEnd();
523 
528  void elementImageryComponentEnd();
529 
534  void elementTextComponentEnd();
535 
540  void elementFrameComponentEnd();
541 
546  void elementAreaEnd();
547 
552  void elementNamedAreaEnd();
553 
558  void elementAnyDimEnd();
559 
561  void elementPropertyLinkDefinitionEnd();
562 
564  void elementEventLinkDefinitionEnd();
565 
570  void registerElementStartHandler(const String& element, ElementStartHandler handler);
571 
576  void registerElementEndHandler(const String& element, ElementEndHandler handler);
577 
579  void processEventLinkTarget(const String& widget, const String& event);
580 
581  /*************************************************************************
582  Implementation Data
583  *************************************************************************/
584  WidgetLookManager* d_manager;
585 
586  // these are used to implement the handler without using a huge
587  // if / else if /else construct, we just register the element name, and
588  // handler member function, and everything else is done using those
589  // mappings.
590  ElementStartHandlerMap d_startHandlersMap;
591  ElementEndHandlerMap d_endHandlersMap;
592 
593  // these hold pointers to various objects under construction.
594  WidgetLookFeel* d_widgetlook;
595  WidgetComponent* d_childcomponent;
596  ImagerySection* d_imagerysection;
597  StateImagery* d_stateimagery;
598  LayerSpecification* d_layer;
599  SectionSpecification* d_section;
600  ImageryComponent* d_imagerycomponent;
601  ComponentArea* d_area;
602  Dimension d_dimension;
603  TextComponent* d_textcomponent;
604  NamedArea* d_namedArea;
605  FrameComponent* d_framecomponent;
606 
607  std::vector<BaseDim*
608  CEGUI_VECTOR_ALLOC(BaseDim*)> d_dimStack;
609 
610  PropertyDefinitionBase* d_propertyLink;
611  EventLinkDefinition* d_eventLink;
612  };
613 
614 } // End of CEGUI namespace section
615 
616 
617 #if defined(_MSC_VER)
618 # pragma warning(pop)
619 #endif
620 
621 #endif // end of guard _CEGUIFalagard_xmlHandler_h_
622 
CEGUI::FrameComponent
Class that encapsulates information for a frame with background (9 images in total)
Definition: FrameComponent.h:75
CEGUI::LayerSpecification
Class that encapsulates a single layer of imagery.
Definition: LayerSpecification.h:69
CEGUI::TextComponent
Class that encapsulates information for a text component.
Definition: TextComponent.h:72
CEGUI::ImageryComponent
Class that encapsulates information for a single image component.
Definition: ImageryComponent.h:70
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::StateImagery
Class the encapsulates imagery for a given widget state.
Definition: StateImagery.h:70
CEGUI::ColourRect
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:70
CEGUI::Falagard_xmlHandler
Handler class used to parse look & feel XML files used by the Falagard system.
Definition: falagard/XMLHandler.h:88
CEGUI::EventLinkDefinition
Definition: EventLinkDefinition.h:67
CEGUI::Dimension
Class representing some kind of dimension.
Definition: Dimensions.h:717
CEGUI::ComponentArea
Class that represents a target area for a widget or imagery component.
Definition: Dimensions.h:804
CEGUI::WidgetLookFeel
Class that encapsulates Look N' Feel information for a widget.
Definition: WidgetLookFeel.h:79
CEGUI::XMLAttributes
Class representing a block of attributes associated with an XML element.
Definition: XMLAttributes.h:70
CEGUI::argb_t
uint32 argb_t
32 bit ARGB representation of a colour.
Definition: Colour.h:65
CEGUI::NamedArea
NamedArea defines an area for a component which may later be obtained and referenced by a name unique...
Definition: NamedArea.h:64
CEGUI::BaseDim
Abstract interface for a generic 'dimension' class.
Definition: Dimensions.h:64
CEGUI::String
String class used within the GUI system.
Definition: String.h:88
CEGUI::PropertyDefinitionBase
common base class used for types representing a new property to be available on all widgets that use ...
Definition: PropertyDefinitionBase.h:66
CEGUI::WidgetLookManager
Manager class that gives top-level access to widget data based "look and feel" specifications loaded ...
Definition: WidgetLookManager.h:73
CEGUI::WidgetComponent
Class that encapsulates information regarding a sub-widget required for a widget.
Definition: WidgetComponent.h:74
CEGUI::ImagerySection
Class that encapsulates a re-usable collection of imagery specifications.
Definition: ImagerySection.h:71
CEGUI::SectionSpecification
Class that represents a simple 'link' to an ImagerySection.
Definition: SectionSpecification.h:71