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