Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 28/05/2009 00003 author: Paul Turner 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIBasicRenderedStringParser_h_ 00028 #define _CEGUIBasicRenderedStringParser_h_ 00029 00030 #include "CEGUI/RenderedStringParser.h" 00031 00032 #include "CEGUI/Rect.h" 00033 #include "CEGUI/ColourRect.h" 00034 #include "CEGUI/String.h" 00035 #include "CEGUI/falagard/Enums.h" 00036 #include <map> 00037 00038 #if defined(_MSC_VER) 00039 # pragma warning(push) 00040 # pragma warning(disable : 4251) 00041 #endif 00042 00043 // Start of CEGUI namespace section 00044 namespace CEGUI 00045 { 00064 class CEGUIEXPORT BasicRenderedStringParser : public RenderedStringParser 00065 { 00066 public: 00067 // Strings for supported tags 00068 static const String ColourTagName; 00069 static const String FontTagName; 00070 static const String ImageTagName; 00071 static const String WindowTagName; 00072 static const String VertAlignmentTagName; 00073 static const String PaddingTagName; 00074 static const String TopPaddingTagName; 00075 static const String BottomPaddingTagName; 00076 static const String LeftPaddingTagName; 00077 static const String RightPaddingTagName; 00078 static const String AspectLockTagName; 00079 static const String ImageSizeTagName; 00080 static const String ImageWidthTagName; 00081 static const String ImageHeightTagName; 00082 static const String TopAlignedValueName; 00083 static const String BottomAlignedValueName; 00084 static const String CentreAlignedValueName; 00085 static const String StretchAlignedValueName; 00086 00088 BasicRenderedStringParser(); 00099 BasicRenderedStringParser(const String& initial_font, 00100 const ColourRect& initial_colours); 00102 virtual ~BasicRenderedStringParser(); 00103 00111 void setInitialFontName(const String& font_name); 00112 00120 void setInitialColours(const ColourRect& colours); 00121 00126 const String& getInitialFontName() const; 00127 00132 const ColourRect& getInitialColours() const; 00133 00134 // implement required interface from RenderedStringParser 00135 RenderedString parse(const String& input_string, 00136 const Font* initial_font, 00137 const ColourRect* initial_colours); 00138 00139 protected: 00141 virtual void appendRenderedText(RenderedString& rs, const String& text) const; 00142 00144 virtual void processControlString(RenderedString& rs, const String& ctrl_str); 00145 00147 virtual void initialiseDefaultState(); 00148 00150 void initialiseTagHandlers(); 00151 00153 void handleColour(RenderedString& rs, const String& value); 00154 void handleFont(RenderedString& rs, const String& value); 00155 void handleImage(RenderedString& rs, const String& value); 00156 void handleWindow(RenderedString& rs, const String& value); 00157 void handleVertAlignment(RenderedString& rs, const String& value); 00158 void handlePadding(RenderedString& rs, const String& value); 00159 void handleTopPadding(RenderedString& rs, const String& value); 00160 void handleBottomPadding(RenderedString& rs, const String& value); 00161 void handleLeftPadding(RenderedString& rs, const String& value); 00162 void handleRightPadding(RenderedString& rs, const String& value); 00163 void handleAspectLock(RenderedString& rs, const String& value); 00164 void handleImageSize(RenderedString& rs, const String& value); 00165 void handleImageWidth(RenderedString& rs, const String& value); 00166 void handleImageHeight(RenderedString& rs, const String& value); 00167 00169 String d_initialFontName; 00171 ColourRect d_initialColours; 00173 Rectf d_padding; 00175 ColourRect d_colours; 00177 String d_fontName; 00179 VerticalFormatting d_vertAlignment; 00181 Sizef d_imageSize; 00183 bool d_aspectLock; 00184 00186 bool d_initialised; 00188 typedef void (BasicRenderedStringParser::*TagHandler)(RenderedString&, 00189 const String&); 00191 typedef std::map<String, TagHandler, StringFastLessCompare> TagHandlerMap; 00193 TagHandlerMap d_tagHandlers; 00194 }; 00195 00196 } // End of CEGUI namespace section 00197 00198 #if defined(_MSC_VER) 00199 # pragma warning(pop) 00200 #endif 00201 00202 #endif // end of guard _CEGUIBasicRenderedStringParser_h_