MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
defaultmarkupparser.h
1 //© Copyright 2010 - 2012 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uidefaultmarkupparser_h
41 #define _uidefaultmarkupparser_h
42 
43 #include "UI/markupparser.h"
44 
45 namespace Mezzanine
46 {
47  namespace UI
48  {
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief This class implements a character colour changing tag.
51  /// @details This tag supports both short and long notation. For example:
52  /// "[Colour=FFFFFFFF]" is valid and equivalent to "[Colour Value=FFFFFFFF]". "Value" is the only
53  /// parameter name supported by this class/tag. The actual value of "Value" is a colour expressed in
54  /// Hexadecimal. Each two characters are one colour, in the following order: Red, Green, Blue, and
55  /// Alpha. The alpha portion does not need to be defined and in it's absence an alpha value of 1.0 will
56  /// be filled in. If the parameter is less than 6 characters long this will fail and "Process" will
57  /// return false.
58  ///////////////////////////////////////
60  {
61  public:
62  /// @brief Class constructor.
64  /// @brief Class destructor.
65  virtual ~DefaultColourTag() {}
66 
67  ///////////////////////////////////////////////////////////////////////////////
68  // Public Data Members
69 
70  /// @brief The name of this tag as it should appear in markup.
71  static const String TagName;
72 
73  ///////////////////////////////////////////////////////////////////////////////
74  // Utility
75 
76  /// @copydoc MarkupTag::GetName() const
77  virtual const String& GetName() const
78  { return DefaultColourTag::TagName; }
79  /// @copydoc MarkupTag::IsRangeTag() const
80  virtual Boolean IsRangeTag() const
81  { return true; }
82 
83  /// @copydoc MarkupTag::Process(NameValuePairMap&, CharacterTraits&, TextLayer*) const
84  virtual ProcessResult Process(NameValuePairMap& Params, CharacterTraits& Traits, TextLayer* Layer) const;
85  };//DefaultColourTag
86 
87  ///////////////////////////////////////////////////////////////////////////////
88  /// @brief This class implements a character font changing tag.
89  /// @details This tag only supports long notation. Example: "[Font Name=Ubuntu]". A size can also be specified
90  /// such as in this example: "[Font Name=Ubuntu Size=12]". The name is the same name as specified in the texture
91  /// atlas the calling layer has set as it's primary. The size is the vertical height in pixels (before scaling)
92  /// the glyphs should be rendered as. Glyphs with their height set have their aspect ratio's preserved. @n @n
93  /// Currently the size parameter is not implemented.
94  ///////////////////////////////////////
96  {
97  public:
98  /// @brief Class constructor.
100  /// @brief Class destructor.
101  virtual ~DefaultFontTag() {}
102 
103  ///////////////////////////////////////////////////////////////////////////////
104  // Public Data Members
105 
106  /// @brief The name of this tag as it should appear in markup.
107  static const String TagName;
108 
109  ///////////////////////////////////////////////////////////////////////////////
110  // Utility
111 
112  /// @copydoc MarkupTag::GetName() const
113  virtual const String& GetName() const
114  { return DefaultFontTag::TagName; }
115  /// @copydoc MarkupTag::IsRangeTag() const
116  virtual Boolean IsRangeTag() const
117  { return true; }
118 
119  /// @copydoc MarkupTag::Process(NameValuePairMap&, CharacterTraits&, TextLayer*) const
120  virtual ProcessResult Process(NameValuePairMap& Params, CharacterTraits& Traits, TextLayer* Layer) const;
121  };//DefaultFontTag
122 
123  ///////////////////////////////////////////////////////////////////////////////
124  /// @brief This class implements a sprite inserting tag.
125  /// @details This tag only supports long notation. Example: "[Sprite Name=Background]". A size can also be specified
126  /// such as in this example: "[Sprite Name=Background Size=12x12]". The name is the same name as specified in the texture
127  /// atlas the calling layer has set as it's primary. The size is the actual dimensions to have set (before scaling) for
128  /// the character that will be generated using the named sprite.
129  ///////////////////////////////////////
131  {
132  public:
133  /// @brief Class constructor.
135  /// @brief Class destructor.
136  virtual ~DefaultSpriteTag() {}
137 
138  ///////////////////////////////////////////////////////////////////////////////
139  // Public Data Members
140 
141  /// @brief The name of this tag as it should appear in markup.
142  static const String TagName;
143 
144  ///////////////////////////////////////////////////////////////////////////////
145  // Utility
146 
147  /// @copydoc MarkupTag::GetName() const
148  virtual const String& GetName() const
149  { return DefaultSpriteTag::TagName; }
150  /// @copydoc MarkupTag::IsRangeTag() const
151  virtual Boolean IsRangeTag() const
152  { return false; }
153 
154  /// @copydoc MarkupTag::Process(NameValuePairMap&, CharacterTraits&, TextLayer*) const
155  virtual ProcessResult Process(NameValuePairMap& Params, CharacterTraits& Traits, TextLayer* Layer) const;
156  };//DefaultSpriteTag
157 
158  ///////////////////////////////////////////////////////////////////////////////
159  /// @brief This class implements the default set of tags used by the UI markup system.
160  /// @details
161  ///////////////////////////////////////
163  {
164  protected:
165  /// @copydoc MarkupParser::Initialize()
166  virtual void Initialize();
167  public:
168  /// @brief Class constructor.
170  /// @brief Class destructor.
171  virtual ~DefaultMarkupParser();
172 
173  ///////////////////////////////////////////////////////////////////////////////
174  // Utility
175 
176  /// @copydoc MarkupParser::GetName() const
177  virtual String GetName() const;
178  /// @copydoc MarkupParser::GetMarkupTagStart() const
179  virtual Char8 GetMarkupTagStart() const;
180  /// @copydoc MarkupParser::GetMarkupTagEnd() const
181  virtual Char8 GetMarkupTagEnd() const;
182  };//DefaultMarkupParser
183  }//UI
184 }//Mezzanine
185 
186 #endif