Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
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
44namespace CEGUI
45{
65{
66public:
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
101 const ColourRect& initial_colours);
104
113 void setInitialFontName(const String& font_name);
114
123 void setInitialColours(const ColourRect& colours);
124
131
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
144protected:
146 virtual void appendRenderedText(RenderedString& rs, const String& text) const;
147
149 virtual void processControlString(RenderedString& rs, const String& ctrl_str);
150
153
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
197 CEGUI_MAP_ALLOC(String, TagHandler)> TagHandlerMap;
200};
201
202} // End of CEGUI namespace section
203
204#if defined(_MSC_VER)
205# pragma warning(pop)
206#endif
207
208#endif // end of guard _CEGUIBasicRenderedStringParser_h_
Basic RenderedStringParser class that offers support for the following tags:
Definition BasicRenderedStringParser.h:65
String d_fontName
active font.
Definition BasicRenderedStringParser.h:182
const ColourRect & getInitialColours() const
Return a ColourRect describing the initial colours used in each parse.
void setInitialFontName(const String &font_name)
set the initial font name to be used on subsequent calls to parse.
Rectf d_padding
active padding values.
Definition BasicRenderedStringParser.h:178
virtual ~BasicRenderedStringParser()
Destructor.
ColourRect d_colours
active colour values.
Definition BasicRenderedStringParser.h:180
virtual void appendRenderedText(RenderedString &rs, const String &text) const
append the text string text to the RenderedString rs.
std::map< String, TagHandler, StringFastLessCompare CEGUI_MAP_ALLOC(String, TagHandler)> TagHandlerMap
definition of type used to despatch tag handler functions
Definition BasicRenderedStringParser.h:197
void setInitialColours(const ColourRect &colours)
Set the initial colours to be used on subsequent calls to parse.
bool d_aspectLock
active 'aspect lock' state
Definition BasicRenderedStringParser.h:188
virtual void processControlString(RenderedString &rs, const String &ctrl_str)
Process the control string ctrl_str.
virtual void initialiseDefaultState()
initialise the default state
void initialiseTagHandlers()
initialise tag handlers
void handleColour(RenderedString &rs, const String &value)
handlers for the various tags supported
ColourRect d_initialColours
Definition BasicRenderedStringParser.h:176
const String & getInitialFontName() const
Return the name of the initial font used in each parse.
RenderedString parse(const String &input_string, const Font *active_font, const ColourRect *active_colours)
parse a text string and return a RenderedString representation.
BasicRenderedStringParser(const String &initial_font, const ColourRect &initial_colours)
Initialising constructor.
VerticalFormatting d_vertAlignment
active vertical alignment
Definition BasicRenderedStringParser.h:184
bool d_initialised
true if handlers have been registered
Definition BasicRenderedStringParser.h:191
TagHandlerMap d_tagHandlers
Collection to map tag names to their handler functions.
Definition BasicRenderedStringParser.h:199
Sizef d_imageSize
active image size
Definition BasicRenderedStringParser.h:186
String d_initialFontName
Definition BasicRenderedStringParser.h:174
Class that holds details of colours for the four corners of a rectangle.
Definition ColourRect.h:45
Class that encapsulates a typeface.
Definition Font.h:62
Specifies interface for classes that parse text into RenderedString objects.
Definition RenderedStringParser.h:39
Class representing a rendered string of entities.
Definition RenderedString.h:52
String class used within the GUI system.
Definition String.h:64
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1
VerticalFormatting
Enumeration of possible values to indicate the vertical formatting to be used for an image component.
Definition Enums.h:59
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition String.h:5580