Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIBasicRenderedStringParser.h
1 /***********************************************************************
2  filename: CEGUIBasicRenderedStringParser.h
3  created: 28/05/2009
4  author: Paul Turner
5  *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 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 _CEGUIBasicRenderedStringParser_h_
29 #define _CEGUIBasicRenderedStringParser_h_
30 
31 #include "CEGUIRenderedStringParser.h"
32 
33 #include "CEGUIRect.h"
34 #include "CEGUIColourRect.h"
35 #include "CEGUIString.h"
36 #include "falagard/CEGUIFalEnums.h"
37 #include <map>
38 
39 #if defined(_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
66 {
67 public:
68  // Strings for supported tags
69  static const String ColourTagName;
70  static const String FontTagName;
71  static const String ImageTagName;
72  static const String WindowTagName;
73  static const String VertAlignmentTagName;
74  static const String PaddingTagName;
75  static const String TopPaddingTagName;
76  static const String BottomPaddingTagName;
77  static const String LeftPaddingTagName;
78  static const String RightPaddingTagName;
79  static const String AspectLockTagName;
80  static const String ImageSizeTagName;
81  static const String ImageWidthTagName;
82  static const String ImageHeightTagName;
83  static const String TopAlignedValueName;
84  static const String BottomAlignedValueName;
85  static const String CentreAlignedValueName;
86  static const String StretchAlignedValueName;
87 
100  BasicRenderedStringParser(const String& initial_font,
101  const ColourRect& initial_colours);
103  virtual ~BasicRenderedStringParser();
104 
112  void setInitialFontName(const String& font_name);
113 
121  void setInitialColours(const ColourRect& colours);
122 
127  const String& getInitialFontName() const;
128 
133  const ColourRect& getInitialColours() const;
134 
135  // implement required interface from RenderedStringParser
136  RenderedString parse(const String& input_string,
137  Font* initial_font,
138  const ColourRect* initial_colours);
139 
140 protected:
142  virtual void appendRenderedText(RenderedString& rs, const String& text) const;
143 
145  virtual void processControlString(RenderedString& rs, const String& ctrl_str);
146 
148  virtual void initialiseDefaultState();
149 
151  void initialiseTagHandlers();
152 
154  void handleColour(RenderedString& rs, const String& value);
155  void handleFont(RenderedString& rs, const String& value);
156  void handleImage(RenderedString& rs, const String& value);
157  void handleWindow(RenderedString& rs, const String& value);
158  void handleVertAlignment(RenderedString& rs, const String& value);
159  void handlePadding(RenderedString& rs, const String& value);
160  void handleTopPadding(RenderedString& rs, const String& value);
161  void handleBottomPadding(RenderedString& rs, const String& value);
162  void handleLeftPadding(RenderedString& rs, const String& value);
163  void handleRightPadding(RenderedString& rs, const String& value);
164  void handleAspectLock(RenderedString& rs, const String& value);
165  void handleImageSize(RenderedString& rs, const String& value);
166  void handleImageWidth(RenderedString& rs, const String& value);
167  void handleImageHeight(RenderedString& rs, const String& value);
168 
185 
189  typedef void (BasicRenderedStringParser::*TagHandler)(RenderedString&,
190  const String&);
192  typedef std::map<String, TagHandler, String::FastLessCompare> TagHandlerMap;
195 };
196 
197 } // End of CEGUI namespace section
198 
199 #if defined(_MSC_VER)
200 # pragma warning(pop)
201 #endif
202 
203 #endif // end of guard _CEGUIBasicRenderedStringParser_h_