Crazy Eddies GUI System: CEGUIBasicRenderedStringParser.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIBasicRenderedStringParser.h

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