Spinning Topp Logo BlackTopp Studios
inc
textlayer.h
1 // © Copyright 2010 - 2016 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 
41 #ifndef _uitextlayer_h
42 #define _uitextlayer_h
43 
44 #include "UI/renderlayer.h"
45 #include "UI/character.h"
46 
47 namespace Mezzanine
48 {
49  namespace UI
50  {
51  class TextLine;
52  class TextCursor;
53  class FontData;
54  class Glyph;
55  class Sprite;
56  class Character;
57  class MarkupParser;
58  class TextToken;
59  class TokenString;
60  ///////////////////////////////////////////////////////////////////////////////
61  /// @brief This is a base class for render layers that render text.
62  /// @details
63  ///////////////////////////////////////
65  {
66  public:
67  /// @brief Basic container type for the storage of @ref Character instances by this class.
68  typedef std::list<Character*> CharacterContainer;
69  /// @brief Iterator type for @ref Character instances stored by this class.
70  typedef CharacterContainer::iterator CharacterIterator;
71  /// @brief Const Iterator type for @ref Character instances stored by this class.
72  typedef CharacterContainer::const_iterator ConstCharacterIterator;
73  /// @brief Reverse Iterator type for @ref Character instances stored by this class.
74  typedef CharacterContainer::reverse_iterator ReverseCharacterIterator;
75  /// @brief Const Reverse Iterator type for @ref Character instances stored by this class.
76  typedef CharacterContainer::const_reverse_iterator ConstReverseCharacterIterator;
77  /// @brief An std::pair type storing two character iterators, usually used to express a range.
78  typedef std::pair<CharacterIterator,CharacterIterator> CharacterIteratorPair;
79  /// @brief Basic container type for the storate of @ref TextLine instances by this class.
80  typedef std::vector<TextLine*> TextLineContainer;
81  /// @brief Iterator type for @ref TextLine instances stored by this class.
82  typedef TextLineContainer::iterator TextLineIterator;
83  /// @brief Const Iterator type for @ref TextLine instances stored by this class.
84  typedef TextLineContainer::const_iterator ConstTextLineIterator;
85  /// @brief An std::pair type used as a return for index-offset conversions.
86  typedef std::pair<Boole,Integer> CharIndexPair;
87  /// @brief An std::pair type used as a return for index-offset conversions.
88  typedef std::pair<Boole,Vector2> CharOffsetPair;
89 
90  /// @brief An enum used to describe how the text generated by this layer will be automatically scaled.
92  {
93  SM_NoAutoScaling = 0, ///< There is no auto-scaling applied to text in this layer. Any scaling has to be done explicitly.
94  SM_ScreenRelative = 1, ///< The provided scaler will be treated as relative to the Screen Y size.
95  SM_ParentRelative = 2, ///< The provided scaler will be treated as relative to the parent widget Y size.
96  SM_LayerRelative = 3 ///< The provided scaler will be treated as relative to this layers Y size after layer scaling.
97  };
98  protected:
99  /// @internal
100  /// @brief Container with all this layers TextLines.
101  TextLineContainer TextLines;
102  /// @internal
103  /// @brief Container with all this layers Characters.
104  CharacterContainer Characters;
105  /// @internal
106  /// @brief Default set of traits all characters generated inside this layer are to have.
108  /// @internal
109  /// @brief The colour of the highlight when this layer belongs to a focused widget.
111  /// @internal
112  /// @brief The colour of the highlight when this layer belongs to a widget not being focused.
114  /// @internal
115  /// @brief The scaling to apply to all characters in this layer.
117  /// @internal
118  /// @brief The parser to use when converting raw strings to renderable characters.
120  /// @internal
121  /// @brief The cursor to be used for insert and manipulation operations.
123  /// @internal
124  /// @brief The actual text parsed into tokens used for generating characters.
126  /// @internal
127  /// @brief The index of the character at the start of the highlight sequence.
129  /// @internal
130  /// @brief The index of the character at the end of the highlight sequence.
132  /// @internal
133  /// @brief The maximum width of textlines generated by this layer in pixels.
135  /// @internal
136  /// @brief The auto-scaling height the text is to be in relative units.
138  /// @internal
139  /// @brief The auto-scaling mode that is to be used on text generated by this textlayer.
141  /// @internal
142  /// @brief The order text will have in TextLines.
144  /// @internal
145  /// @brief The alignment TextLines will have.
147 
148  /// @copydoc SimpleRenderer::RedrawImpl(Boole Force)
149  virtual void RedrawImpl(Boole Force);
150  /// @internal
151  /// @brief Recalculates the offset for every text line in this layer.
152  virtual void RecalculateOffsets();
153  /// @internal
154  /// @brief Clears and then places characters belonging to this layer in the appropriate text lines.
155  /// @param MaxWidth The maximum line width to assume for all text lines that are to be populated.
156  virtual void PopulateTextLinesImpl(const Real MaxWidth) = 0;
157  /// @internal
158  /// @brief Gets the index of the character at the specified offset position.
159  /// @param Position The position (in screen space) of the character to retrieve if one exists.
160  /// @return Returns an std::pair with the first member being whether or not a character was found, and the second member being it's index. Index will be zero if first is false.
161  virtual CharIndexPair GetIndexAtOffsetImpl(const Vector2& Position) = 0;
162  /// @internal
163  /// @brief Gets the position of the character at the specified index.
164  /// @param Index The character index to get the position offset of.
165  /// @return Returns an std::pair with the first member being whether or not the index was valid, and the second member being the top-left corner of the character specified.
166  virtual CharOffsetPair GetOffsetAtIndexImpl(const Integer Index) = 0;
167  //public:
168  /// @brief No-Font constructor.
169  /// @param ParentRenderable The renderable that created this layer.
170  TextLayer(QuadRenderable* ParentRenderable);
171  /// @brief Class constructor.
172  /// @param FontName The name of the font to use for this layer.
173  /// @param ParentRenderable The renderable that created this layer.
174  TextLayer(const String& FontName, QuadRenderable* ParentRenderable);
175  /// @brief Text-Scaling constructor.
176  /// @note This constructor defaults to Screen Relative text, but this can be altered after construction.
177  /// @param LineHeight The relative scalar to be used when determining the size of characters generated by this text layer.
178  /// @param ParentRenderable The renderable that created this layer.
179  TextLayer(const Real& LineHeight, QuadRenderable* ParentRenderable);
180  /// @brief Class destructor.
181  virtual ~TextLayer();
182  public:
183  ///////////////////////////////////////////////////////////////////////////////
184  // Parser Methods
185 
186  /// @brief Sets the MarkupParser to be used by this TextLayer.
187  /// @note Passing in NULL will be ignored.
188  /// @param Parser A pointer to the MarkupParser to be used by this TextLayer.
189  /// @return Returns true if the new MarkupParser was successfully set, false otherwise.
190  virtual Boole SetMarkupParser(MarkupParser* Parser);
191  /// @brief Sets the MarkupParser to be used by this TextLayer via it's registered name.
192  /// @remarks This method will check the UIManager to see if the named MarkupParser exists. If it does not then it will set NULL.
193  /// @param ParserName The name of the registered parser to retrieve and set for this TextLayer.
194  /// @return Returns true if the new MarkupParser was successfully set, false otherwise.
195  virtual Boole SetMarkupParser(const String& ParserName);
196  /// @brief Gets the MarkupParser being used by this TextLayer.
197  /// @return Returns a pointer to the MarkupParser currently being used by this TextLayer.
198  virtual MarkupParser* GetMarkupParser() const;
199 
200  ///////////////////////////////////////////////////////////////////////////////
201  // Utility
202 
203  /// @brief Gets the combined height of all the text lines in this layer.
204  /// @return Returns a Real representing the pixel height of all the textlines in this layer.
205  virtual Real GetTotalHeight() const;
206 
207  /// @brief Gets the maximum width of text lines in this layer.
208  /// @return Returns a Real representing the maximum pixel width of text lines generated in this layer.
209  virtual Real GetMaxLineWidth() const;
210  /// @brief Gets the height in pixels this layer is configured to render it's text.
211  /// @return Returns a Real representing the pixel height of text lines in this layer that is desired.
212  virtual Real GetDesiredLineHeight() const;
213 
214  ///////////////////////////////////////////////////////////////////////////////
215  // Offset - Index Conversion Methods
216 
217  /// @brief Gets the index of the character at the specified offset position.
218  /// @param Offset The offset position of the character to get the index of.
219  /// @return Returns a CharIndexPair where the first value is a Boole which will be false if
220  /// the position is invalid for whatever reason. The second value will be in the index. If
221  /// the second value is -1 then the position is to the right of the last character.
222  virtual CharIndexPair GetIndexAtOffset(const Vector2& Offset);
223  /// @brief Gets the offset position of the character at the provided index.
224  /// @param Index The index of the character position to retrieve.
225  /// @return Returns a CharOffsetPair where the first value is a Boole which will be false if the
226  /// index is invalid for any reason, and the second value is the offset position of the
227  /// character at the specified index if the first value is true.
228  virtual CharOffsetPair GetOffsetAtIndex(const Integer Index);
229 
230  ///////////////////////////////////////////////////////////////////////////////
231  // Text Methods
232 
233  /// @brief Sets the text displayed within this layer.
234  /// @param Text The text to be displayed.
235  virtual void SetText(const String& Text);
236  /// @brief Gets the text displayed within this layer.
237  /// @return Returns the text being displayed.
238  virtual String GetText() const;
239  /// @brief Sets the default colour of the text being rendered by this layer.
240  /// @param Colour The colour to apply to the text of this layer.
241  virtual void SetTextColour(const ColourValue& Colour);
242  /// @brief Gets the default colour of the tect being rendered by this layer.
243  /// @return Returns a const ColourValue reference containing the colour used to render this layer's text.
244  virtual const ColourValue& GetTextColour() const;
245 
246  /// @brief Sets the scaling to be applied to the text being rendered.
247  /// @remarks Manual scaling is applied after any autoscaling settings are applied.
248  /// @param Scale A Vector2 representing the scale on both dimensions to be applied. <1.0 means smaller, >1.0 means larger.
249  virtual void SetManualTextScale(const Vector2& Scale);
250  /// @brief Gets the scaling currently being applied to the rendered text.
251  /// @return Returns a Vector2 representing the scale applied to the text in this layer. <1.0 means smaller, >1.0 means larger.
252  virtual const Vector2& GetManualTextScale() const;
253  /// @brief Sets the mode and scaler of auto-scaling applied to the text generated by this textlayer.
254  /// @remarks There are a lot of considerations to be made with auto-scaling. Auto-scaling will adjust the size of the provided font
255  /// automatically based on the scaling mode that is set, which really decides what the relative scalar provided for auto-scaling is
256  /// relative to. If auto-scaling is relative to the screen, then the text will only change in size when the screen does. Parent and
257  /// layer relative scaling are very similiar since layers get their dimensions from the parent widget they belong to. The difference
258  /// comes from scaling applied to the layer itself. Parent relative scaling ignores the layer scaling, while layer relative factors
259  /// it in. @n @n
260  /// In addition to the relative component to the scaling, manual scaling will also be applied after the auto-scaling is. Auto-scaling
261  /// will be completely ignored if the custom size on a character is set.
262  /// @param Mode A ScalingMode enum value describing what the provided scaler will be relative to.
263  /// @param Scalar The relative value that will be used to determine the needed scaling to be applied to text in this layer.
264  virtual void SetAutoTextScale(const TextLayer::ScalingMode Mode, const Real Scalar);
265  /// @brief Gets the automatic scaling mode being used by this textlayer.
266  /// @return Returns a ScalingMode enum value describing what the relative scaler is relative to, if auto-scaling is enabled at all.
267  virtual TextLayer::ScalingMode GetAutoTextScalingMode() const;
268  /// @brief Gets the relative scalar being used to automatically scale text generated by this layer.
269  /// @return Returns a Real representing the relative Y size to use when detmining how to uniformly scale text in this layer.
270  virtual Real GetAutoTextScalar() const;
271 
272  ///////////////////////////////////////////////////////////////////////////////
273  // Font Methods
274 
275  /// @brief Sets the default font to be used with this layer.
276  /// @param NewFont The default font to use for this layer.
277  virtual void SetDefaultFont(FontData* NewFont);
278  /// @brief Sets the default font to be used with this layer.
279  /// @details The font name is defined in your mta file. This class can change which
280  /// glyph is uses with it's markup language. This simply defines which to use when one isn't
281  /// specified.
282  /// @param FontName The name of the font to use for this layer.
283  virtual void SetDefaultFont(const String& FontName);
284  /// @brief Sets the default font to be used with this layer.
285  /// @details The font is defined in your mta file. This class can change which
286  /// glyph is uses with it's markup language. This simply defines which to use when one isn't
287  /// specified.
288  /// @param FontName The name of the font to use for this layer.
289  /// @param Atlas The different atlas to get the glyphdata from.
290  virtual void SetDefaultFont(const String& FontName, const String& Atlas);
291  /// @brief Gets the default font in use by this layer.
292  /// @details The font is defined in your mta file.
293  /// @return Returns a pointer to the font in use by this layer.
294  virtual FontData* GetDefaultFont();
295 
296  ///////////////////////////////////////////////////////////////////////////////
297  // Highlight Methods
298 
299  /// @brief Sets the colour of the highlight when the quad is being focused.
300  /// @note Being focused is a property of Widgets, which the parent quad may not be.
301  /// In general highlighting in a non-Widget is likely or recommended.
302  /// @param Colour The highlight colour while being focused.
303  virtual void SetActiveHighlightBackgroundColour(const ColourValue& Colour);
304  /// @brief Gets the colour of the highlight when the quad is being focused.
305  /// @return Returns a const ColourValue reference containing the colour used to render highlights while the parent quad is focused.
306  virtual const ColourValue& GetActiveHighlightBackgroundColour() const;
307  /// @brief Sets the colour of the highlight when the quad is not focused.
308  /// @note Being focused is a property of Widgets, which the parent quad may not be.
309  /// In general highlighting in a non-Widget is likely or recommended.
310  /// @param Colour The highlight colour while
311  virtual void SetInactiveHighlightBackgroundColour(const ColourValue& Colour);
312  /// @brief Gets the colour of the highlight when the quad is being focused.
313  /// @return Returns a const ColourValue reference containing the colour used to render highlights while the parent quad is not focused.
314  virtual const ColourValue& GetInactiveHighlightBackgroundColour() const;
315 
316  /// @brief Highlights all characters in this layer.
317  virtual void Highlight();
318  /// @brief Highlights the character at the specified index.
319  /// @param Index The index of the character to highlight.
320  virtual void Highlight(const Integer Index);
321  /// @brief Highlights all characters in a provided range.
322  /// @param StartIndex The index of the first character in the range to highlight.
323  /// @param EndIndex The index of the last character in the range to highlight.
324  virtual void Highlight(const Integer StartIndex, const Integer EndIndex);
325  /// @brief Gets the index of the first character that is highlighted in this layer.
326  /// @return Returns the index of the first character in the highlighted range, or -1 if nothing is highlighted.
327  virtual Integer GetHighlightStart() const;
328  /// @brief Gets the index of this last character that is highlighted in this layer.
329  /// @return Returns the index of the last character in the highlighted range, or -1 if nothing is highlighted.
330  virtual Integer GetHighlightEnd() const;
331  /// @brief Clears all the highlights in this layer.
332  virtual void ClearHighlights();
333 
334  ///////////////////////////////////////////////////////////////////////////////
335  // Ordering Methods
336 
337  /// @brief Sets the ordering for characters in this layer.
338  /// @remarks The Text Line Order determines if characters are ordered left to right, or right to left.
339  /// @param Order The direction of advancement for characters on the horizontal axis.
340  virtual void SetTextOrder(const UI::TextOrdering Order);
341  /// @brief Gets the currently set direction of advancement for characters on the horizontal axis created by this layer.
342  /// @return Returns the direction of advancement for characters on the horizontal axis.
343  virtual UI::TextOrdering GetTextOrder() const;
344 
345  ///////////////////////////////////////////////////////////////////////////////
346  // Cursor Methods
347 
348  /// @brief Enables (or disables) the cursor for use in this layer.
349  /// @note The default state for the Text Cursor is disabled.
350  /// @param Enable True to enable the cursor and make it available for manipulation/rendering, false to disable it.
351  virtual void SetCursorEnabled(Boole Enable);
352  /// @brief Gets whether or not the Text Cursor is enabled.
353  /// @return Returns true if the cursor is being rendered, false otherwise.
354  virtual Boole GetCursorEnabled() const;
355  /// @brief Gets the TextCursor in use by this layer.
356  /// @return Returns a pointer to this layers TextCursor, or NULL if it is disabled.
357  virtual TextCursor* GetCursor() const;
358 
359  ///////////////////////////////////////////////////////////////////////////////
360  // TextLine Methods
361 
362  /// @brief Creates a new TextLine.
363  /// @note One textline will be auto-created when a text layer is constructed. It's default horizontal alignment
364  /// will be to the left. Additional text lines will be given the alignment of the last text line in the layers
365  /// text line container.
366  /// @return Returns a pointer to the created TextLine.
367  virtual TextLine* CreateTextLine();
368  /// @brief Gets the TextLine at the specified offset position.
369  /// @param Offset The offset from the top edge of the parent layer.
370  /// @return Returns a pointer to the TextLine at the requested offset, or NULL if none exists.
371  virtual TextLine* GetTextLineAtOffset(const Real& Offset);
372  /// @brief Gets the number of TextLines this layer contains.
373  /// @return Returns a Whole representing the number of lines of text this layer has.
374  virtual Whole GetNumTextLines() const;
375 
376  /// @brief Populates text lines in this layer with parsed characters.
377  /// @param MaxWidth The maximum line width to assume for all text lines that are to be populated.
378  virtual void PopulateTextLines(const Real MaxWidth);
379  /// @brief Removes all characters from all TextLines belonging to this layer.
380  virtual void ClearAllTextLines();
381  /// @brief Destroys all TextLines in this layer.
382  virtual void DestroyAllTextLines();
383 
384  /// @brief Sets the horizontal alignment of every textline in this layer.
385  /// @param Align A LinearAlignment enum value indicating how each text line in this layer should align it's text.
386  virtual void SetTextLineHorizontalAlignment(const UI::LinearAlignment Align);
387  /// @brief Sets the alignment used to determine the start position of the textlines in this layer.
388  /// @note TextLines can easily run out of room in a given layer. If the combined vertical height of the TextLines
389  /// in this layer exceed the size given for rendering then this setting is ignored, and text will render from the top.
390  /// @param Align The alignment to use.
391  virtual void SetTextLineVerticalAlignment(const UI::LinearAlignment Align);
392  /// @brief Gets the current set alignment for positioning textlines in this layer.
393  /// @return Returns the current TextLine position alignment.
394  virtual UI::LinearAlignment GetTextLineVerticalAlignment() const;
395 
396  /// @brief Gets an iterator to the first TextLine.
397  /// @return Returns an iterator to the first TextLine being stored by this TextLayer.
398  virtual TextLineIterator BeginTextLine();
399  /// @brief Gets an iterator to one passed the last TextLine.
400  /// @return Returns an iterator to one passed the last TextLine being stored by this TextLayer.
401  virtual TextLineIterator EndTextLine();
402  /// @brief Gets a const iterator to the first TextLine.
403  /// @return Returns a const iterator to the first TextLine being stored by this TextLayer.
404  virtual ConstTextLineIterator BeginTextLine() const;
405  /// @brief Gets a const iterator to one passed the last TextLine.
406  /// @return Returns a const iterator to one passed the last TextLine being stored by this TextLayer.
407  virtual ConstTextLineIterator EndTextLine() const;
408 
409  ///////////////////////////////////////////////////////////////////////////////
410  // Character Methods
411 
412  /// @brief Gets a Character by index.
413  /// @note The index is counted from the left to the right, regardless of text order.
414  /// @param Index The index of the Character to retrieve.
415  /// @return Returns a pointer to the requested Character.
416  virtual Character* GetCharacterAtIndex(const Integer Index) const;
417  /// @brief Gets a Character by offset position.
418  /// @warning Depending on what has been updated there is a chance this may not get the proper character
419  /// for the current configuration until after the next frame is drawn. In most cases this will be safe,
420  /// but may not always be.
421  /// @param Offset The position relative to the top-left corner of this layer.
422  /// @return Returns a pointer to the character under the provided position, or NULL if the position is invalid.
423  virtual Character* GetCharacterAtOffset(const Vector2& Offset) const;
424  /// @brief Gets an iterator to the character at the specified index.
425  /// @param Index The index of the Character to retrieve.
426  /// @return Returns an iterator to the requested Character.
427  virtual CharacterIterator GetCharacterIteratorAtIndex(const Integer Index);
428  /// @brief Gets a const iterator to the character at the specified index.
429  /// @param Index The index of the Character to retrieve.
430  /// @return Returns a const iterator to the requested Character.
431  virtual ConstCharacterIterator GetCharacterIteratorAtIndex(const Integer Index) const;
432  /// @brief Gets the number of characters being rendered by this TextLayer.
433  /// @return Returns a Whole representing the number of rendered characters being rendered by this TextLayer.
434  virtual Whole GetNumCharacters() const;
435 
436  /// @brief Creates a character from a Glyph ID and inserts it into the layer at the specified index.
437  /// @param Index The index at which the character should be inserted.
438  /// @param GlyphID The ID of the Glyph to be inserted.
439  /// @return Returns the number of render characters successfully added to this layer. Negative number means the operation removed render characters.
440  virtual Integer InsertCharacterAtIndex(const Integer Index, const UInt32 GlyphID);
441  /// @brief Creates a series of characters from a UTF-8 encoded string to be inserted into this layer.
442  /// @param Index The index at which the characters will be inserted.
443  /// @param Characters An array of Char8's encoded in UTF-8 to be inserted.
444  /// @param BufSize The size of the array of Char8's passed in.
445  /// @return Returns the number of render characters successfully added to this layer. Negative number means the operation removed render characters.
446  virtual Integer InsertCharactersAtIndex(const Integer Index, const Char8* Characters, const UInt32 BufSize);
447  /// @brief Creates a series of characters from a UTF-32 encoded string to be inserted into this layer.
448  /// @param Index The index at which the characters will be inserted.
449  /// @param Characters An array of UInt32's encoded in UTF-32 to be inserted.
450  /// @param BufSize The size of the array of Char8's passed in.
451  /// @return Returns the number of render characters successfully added to this layer. Negative number means the operation removed render characters.
452  virtual Integer InsertCharactersAtIndex(const Integer Index, const UInt32* Characters, const UInt32 BufSize);
453  /// @brief Removes a character from the layer at the specified index.
454  /// @param Index The index of the character to be removed.
455  /// @return Returns the number of render characters successfully removed from this layer. Negative number means the operation added render characters.
456  virtual Integer RemoveCharacterAtIndex(const Integer Index);
457  /// @brief Removes a length of characters from this layer at the specified index.
458  /// @param Index The index of the start of the range of characters to be removed.
459  /// @param Length The number of characters being removed.
460  /// @return Returns the number of render characters successfully removed from this layer. Negative number means the operation added render characters.
461  virtual Integer RemoveCharactersAtIndex(const Integer Index, const UInt32 Length);
462  /// @brief Removes a range of characters from the text in this layer.
463  /// @param First The first character in the range to be removed.
464  /// @param Last The last character in the range to be removed.
465  /// @return Returns the number of render characters successfully removed from this layer. Negative number means the operation added render characters.
466  virtual Integer RemoveCharacterRange(const Integer First, const Integer Last);
467  /// @brief Destroy's all characters in this TextLayer
468  /// @return Returns the number of render characters successfully removed from this layer. Negative number means the operation added render characters. This should never happen.
469  virtual Integer DestroyAllCharacters();
470 
471  /// @brief Gets an iterator to the first Character.
472  /// @return Returns an iterator to the first Character being stored by this TextLine.
473  CharacterIterator BeginCharacter();
474  /// @brief Gets an iterator to one passed the last Character.
475  /// @return Returns an iterator to one passed the last Character being stored by this TextLine.
476  CharacterIterator EndCharacter();
477  /// @brief Gets a const iterator to the first Character.
478  /// @return Returns a const iterator to the first Character being stored by this TextLine.
479  ConstCharacterIterator BeginCharacter() const;
480  /// @brief Gets an iterator to one passed the last Character.
481  /// @return Returns an iterator to one passed the last Character being stored by this TextLine.
482  ConstCharacterIterator EndCharacter() const;
483 
484  ///////////////////////////////////////////////////////////////////////////////
485  // Serialization
486 
487  /// @copydoc SimpleRenderer::ProtoSerialize(XML::Node& ParentNode) const
488  virtual void ProtoSerialize(XML::Node& ParentNode) const;
489  /// @copydoc SimpleRenderer::ProtoSerializeProperties(XML::Node&) const
490  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
491  /// @brief Convert the TextCursor of this class to an XML::Node ready for seriailization.
492  /// @param SelfRoot The root node containing all the serialized data for this instance.
493  virtual void ProtoSerializeCursor(XML::Node& SelfRoot) const;
494  /// @brief Convert the Text of this class to an XML::Node ready for serialization.
495  /// @param SelfRoot The root node containing all the serialized data for this instance.
496  virtual void ProtoSerializeText(XML::Node& SelfRoot) const;
497 
498  /// @copydoc SimpleRenderer::ProtoDeSerialize(const XML::Node& SelfRoot)
499  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
500  /// @copydoc SimpleRenderer::ProtoDeSerializeProperties(const XML::Node&)
501  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
502  /// @brief Take the data stored in an XML Node and overwrite the TextCursor of this object with it.
503  /// @param SelfRoot An XML::Node containing the data to populate this class with.
504  virtual void ProtoDeSerializeCursor(const XML::Node& SelfRoot);
505  /// @brief Take the data stored in an XML Node and overwrite the Text of this object with it.
506  /// @param SelfRoot An XML::Node containing the data to populate this class with.
507  virtual void ProtoDeSerializeText(const XML::Node& SelfRoot);
508 
509  /// @copydoc SimpleRenderer::GetDerivedSerializableName() const
510  virtual String GetDerivedSerializableName() const;
511  /// @copydoc SimpleRenderer::GetSerializableName()
512  static String GetSerializableName();
513  };//TextLayer
514  }//UI
515 }//Mezzanine
516 
517 #endif
UI::LinearAlignment VerticalAlign
The alignment TextLines will have.
Definition: textlayer.h:146
std::pair< Boole, Vector2 > CharOffsetPair
An std::pair type used as a return for index-offset conversions.
Definition: textlayer.h:88
This class represents a collection of Glyphs in a common visual style.
Definition: font.h:55
This is a helper class that facilitates operations with collections of tokens generated from Markup P...
Definition: texttoken.h:282
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
CharacterContainer Characters
Container with all this layers Characters.
Definition: textlayer.h:104
MarkupParser * MUParser
The parser to use when converting raw strings to renderable characters.
Definition: textlayer.h:119
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
TextOrdering
This enum describes the direction of advancing characters or lines along the X axis.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
Real MaxLineWidth
The maximum width of textlines generated by this layer in pixels.
Definition: textlayer.h:134
TextLineContainer::iterator TextLineIterator
Iterator type for TextLine instances stored by this class.
Definition: textlayer.h:82
Integer HighlightStart
The index of the character at the start of the highlight sequence.
Definition: textlayer.h:128
This class stores common data for determining the look of a Character.
ColourValue ActiveHLColour
The colour of the highlight when this layer belongs to a focused widget.
Definition: textlayer.h:110
This represents a single line of text to be rendered by a TextLayer.
Definition: textline.h:59
Integer HighlightEnd
The index of the character at the end of the highlight sequence.
Definition: textlayer.h:131
Real AutoCharScaling
The auto-scaling height the text is to be in relative units.
Definition: textlayer.h:137
CharacterContainer::const_reverse_iterator ConstReverseCharacterIterator
Const Reverse Iterator type for Character instances stored by this class.
Definition: textlayer.h:76
std::pair< Boole, Integer > CharIndexPair
An std::pair type used as a return for index-offset conversions.
Definition: textlayer.h:86
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
LinearAlignment
Used by various UI classes to determine the alignment of their child objects, such as text in text li...
char Char8
A datatype to represent one character.
Definition: datatypes.h:169
CharacterContainer::reverse_iterator ReverseCharacterIterator
Reverse Iterator type for Character instances stored by this class.
Definition: textlayer.h:74
ScalingMode
An enum used to describe how the text generated by this layer will be automatically scaled...
Definition: textlayer.h:91
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This class creates and encapsultes a character that can be used in text renders.
Definition: character.h:59
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
CharacterTraits DefaultCharTraits
Default set of traits all characters generated inside this layer are to have.
Definition: textlayer.h:107
Class for encapsulating the functionality of the text cursor/carat navigation in text layers...
Definition: textcursor.h:59
std::vector< TextLine * > TextLineContainer
Basic container type for the storate of TextLine instances by this class.
Definition: textlayer.h:80
CharacterContainer::const_iterator ConstCharacterIterator
Const Iterator type for Character instances stored by this class.
Definition: textlayer.h:72
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Vector2 ManualCharScaling
The scaling to apply to all characters in this layer.
Definition: textlayer.h:116
TextLineContainer TextLines
Container with all this layers TextLines.
Definition: textlayer.h:101
This is a base class for the parsing of markup texts contained in text layers.
Definition: markupparser.h:126
This represents a nestable quad for an object in a GUI layout.
ScalingMode AutoCharScalingMode
The auto-scaling mode that is to be used on text generated by this textlayer.
Definition: textlayer.h:140
std::pair< CharacterIterator, CharacterIterator > CharacterIteratorPair
An std::pair type storing two character iterators, usually used to express a range.
Definition: textlayer.h:78
UI::TextOrdering HorizontalOrder
The order text will have in TextLines.
Definition: textlayer.h:143
TextLineContainer::const_iterator ConstTextLineIterator
Const Iterator type for TextLine instances stored by this class.
Definition: textlayer.h:84
TextCursor * Cursor
The cursor to be used for insert and manipulation operations.
Definition: textlayer.h:122
TokenString * TextTokens
The actual text parsed into tokens used for generating characters.
Definition: textlayer.h:125
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This is a base class for render layers that render text.
Definition: textlayer.h:64
ColourValue InactiveHLColour
The colour of the highlight when this layer belongs to a widget not being focused.
Definition: textlayer.h:113
This is the base class for the types of layers that can be added to a renderable. ...
Definition: renderlayer.h:58
std::list< Character * > CharacterContainer
Basic container type for the storage of Character instances by this class.
Definition: textlayer.h:68
CharacterContainer::iterator CharacterIterator
Iterator type for Character instances stored by this class.
Definition: textlayer.h:70