Crazy Eddie's GUI System  0.8.5
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,
101  const ColourRect& initial_colours);
103  virtual ~BasicRenderedStringParser();
104 
112  void setInitialFontName(const String& font_name);
114 
122  void setInitialColours(const ColourRect& colours);
124 
129  const String& getInitialFontName() const;
131 
136  const ColourRect& getInitialColours() const;
138 
139  // implement required interface from RenderedStringParser
140  RenderedString parse(const String& input_string,
141  const Font* active_font,
142  const ColourRect* active_colours);
143 
144 protected:
146  virtual void appendRenderedText(RenderedString& rs, const String& text) const;
147 
149  virtual void processControlString(RenderedString& rs, const String& ctrl_str);
150 
152  virtual void initialiseDefaultState();
153 
155  void initialiseTagHandlers();
156 
158  void handleColour(RenderedString& rs, const String& value);
159  void handleFont(RenderedString& rs, const String& value);
160  void handleImage(RenderedString& rs, const String& value);
161  void handleWindow(RenderedString& rs, const String& value);
162  void handleVertAlignment(RenderedString& rs, const String& value);
163  void handlePadding(RenderedString& rs, const String& value);
164  void handleTopPadding(RenderedString& rs, const String& value);
165  void handleBottomPadding(RenderedString& rs, const String& value);
166  void handleLeftPadding(RenderedString& rs, const String& value);
167  void handleRightPadding(RenderedString& rs, const String& value);
168  void handleAspectLock(RenderedString& rs, const String& value);
169  void handleImageSize(RenderedString& rs, const String& value);
170  void handleImageWidth(RenderedString& rs, const String& value);
171  void handleImageHeight(RenderedString& rs, const String& value);
172 
189 
193  typedef void (BasicRenderedStringParser::*TagHandler)(RenderedString&,
194  const String&);
196  typedef std::map<String, TagHandler, StringFastLessCompare> TagHandlerMap;
198  TagHandlerMap d_tagHandlers;
199 };
200 
201 } // End of CEGUI namespace section
202 
203 #if defined(_MSC_VER)
204 # pragma warning(pop)
205 #endif
206 
207 #endif // end of guard _CEGUIBasicRenderedStringParser_h_
VerticalFormatting d_vertAlignment
active vertical alignment
Definition: BasicRenderedStringParser.h:184
String d_fontName
active font.
Definition: BasicRenderedStringParser.h:182
VerticalFormatting
Enumeration of possible values to indicate the vertical formatting to be used for an image component...
Definition: Enums.h:58
bool d_initialised
true if handlers have been registered
Definition: BasicRenderedStringParser.h:191
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
std::map< String, TagHandler, StringFastLessCompare > TagHandlerMap
definition of type used to despatch tag handler functions
Definition: BasicRenderedStringParser.h:196
ColourRect d_initialColours
Definition: BasicRenderedStringParser.h:176
Class that holds details of colours for the four corners of a rectangle.
Definition: ColourRect.h:43
Class representing a rendered string of entities.
Definition: RenderedString.h:50
Sizef d_imageSize
active image size
Definition: BasicRenderedStringParser.h:186
TagHandlerMap d_tagHandlers
Collection to map tag names to their handler functions.
Definition: BasicRenderedStringParser.h:198
Rectf d_padding
active padding values.
Definition: BasicRenderedStringParser.h:178
Class that encapsulates a typeface.
Definition: Font.h:58
bool d_aspectLock
active 'aspect lock' state
Definition: BasicRenderedStringParser.h:188
Basic RenderedStringParser class that offers support for the following tags:
Definition: BasicRenderedStringParser.h:64
ColourRect d_colours
active colour values.
Definition: BasicRenderedStringParser.h:180
Specifies interface for classes that parse text into RenderedString objects.
Definition: RenderedStringParser.h:37
String d_initialFontName
Definition: BasicRenderedStringParser.h:174
String class used within the GUI system.
Definition: String.h:62