MezzanineEngine
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Mezzanine
src
UI
textcursor.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 _uitextcursor_h
41
#define _uitextcursor_h
42
43
#include "colourvalue.h"
44
#include "UI/rect.h"
45
#include "UI/textlayer.h"
46
47
namespace
Mezzanine
48
{
49
namespace
UI
50
{
51
class
TextLayer;
52
class
Glyph;
53
class
Sprite;
54
///////////////////////////////////////////////////////////////////////////////
55
/// @brief Class for encapsulating the functionality of the text cursor/carat navigation in text layers.
56
/// @details
57
///////////////////////////////////////
58
class
TextCursor
59
{
60
protected
:
61
/// @internal
62
/// @brief The colour to be given to the TextCursor.
63
ColourValue
CursorColour
;
64
/// @internal
65
/// @brief The index of the character this TextCursor is to the left of.
66
Integer
IndexPosition
;
67
/// @internal
68
/// @brief The layer this TextCursor belongs to.
69
TextLayer
*
Layer
;
70
/// @internal
71
/// @brief Stores the cursors current visibility state.
72
Boolean
Visibility
;
73
public
:
74
/// @brief Class constructor.
75
/// @param Creator The layer that this TextCursor belongs to.
76
TextCursor
(
TextLayer
* Creator);
77
/// @brief Class destructor.
78
virtual
~TextCursor
();
79
80
///////////////////////////////////////////////////////////////////////////////
81
// Utility Methods
82
83
/// @brief Sets the visibility of this cursor.
84
/// @param Visible True to enable rendering of this cursor, false otherwise.
85
virtual
void
SetVisible
(Boolean Visible);
86
/// @brief Gets the visibility of this cursor.
87
/// @return Returns true if this cursor is being rendered along with it's parent TextLayer, false otherwise.
88
virtual
Boolean
GetVisible
()
const
;
89
90
/// @brief Sets the index position of this cursor.
91
/// @param Index The index indicating the position of this cursor among the characters in the parent layer.
92
virtual
void
SetCursorIndex
(
const
Integer
& Index);
93
/// @brief Gets the index position of this cursor.
94
/// @return Returns an Integer representing the index position of this cursor.
95
virtual
Integer
GetCursorIndex
()
const
;
96
97
/// @brief Sets the offset position of this cursor to the nearest appropriate point.
98
/// @param Offset The position from the top left corner of the parent layer where the bottom left corner of this cursor is to be placed.
99
virtual
void
SetOffsetPosition
(
const
Vector2
& Offset);
100
/// @brief Gets the current offset position of this cursor.
101
/// @return Returns a Vector2 containing the position of this cursor relative to the parent layer.
102
virtual
TextLayer::CharOffsetPair
GetOffsetPosition
()
const
;
103
/// @brief Gets a rect representing this cursors dimentions.
104
/// @return Returns a Rect containing the position and size of this TextCursor.
105
virtual
Rect
GetCursorRect
()
const
;
106
107
/// @brief Sets the colour that the Text Cursor should be rendered as.
108
/// @param Colour The colour to use when rendering the Text Cursor.
109
virtual
void
SetColour
(
const
ColourValue
& Colour);
110
/// @brief Gets the colour that the Text Cursor will be rendered as.
111
/// @return Returns a const ColourValue reference of the Text Cursors colour.
112
virtual
const
ColourValue
&
GetColour
()
const
;
113
114
///////////////////////////////////////////////////////////////////////////////
115
// Left and Right Methods
116
117
/// @brief Decrements this cursors index position, moving it to the left.
118
virtual
void
MoveCursorLeft
();
119
/// @brief Increments this cursors index position, moving it to the right.
120
virtual
void
MoveCursorRight
();
121
122
/// @brief Creates a character from a Glyph ID and inserts it at the cursor position.
123
/// @param GlyphID The ID of the Glyph to be inserted.
124
virtual
void
InsertCharacterAtCursor
(
const
UInt32
GlyphID);
125
/// @brief Creates a series of characters from a UTF-8 encoded string to be inserted at the cursor position.
126
/// @param Characters An array of Char8's encoded in UTF-8 to be inserted.
127
/// @param BufSize The size of the array of Char8's passed in.
128
virtual
void
InsertCharactersAtCursor
(
const
Char8
* Characters,
const
UInt32
BufSize);
129
/// @brief Creates a series of characters from a UTF-32 encoded string to be inserted at the cursor position.
130
/// @param Characters An array of UInt32's encoded in UTF-32 to be inserted.
131
/// @param BufSize The size of the array of Char8's passed in.
132
virtual
void
InsertCharactersAtCursor
(
const
UInt32
* Characters,
const
UInt32
BufSize);
133
/// @brief Removes the character to the left (and decrements the index position) of this cursor.
134
virtual
void
RemoveLeftCharacter
();
135
/// @brief Removes the character to the right of this cursor.
136
virtual
void
RemoveRightCharacter
();
137
138
///////////////////////////////////////////////////////////////////////////////
139
// Serialization
140
141
/// @brief Convert this class to an XML::Node ready for serialization.
142
/// @param ParentNode The point in the XML hierarchy that this renderable should be appended to.
143
virtual
void
ProtoSerialize
(
XML::Node
& ParentNode)
const
;
144
/// @brief Take the data stored in an XML Node and overwrite this object with it.
145
/// @param SelfRoot An XML::Node containing the data to populate this class with.
146
virtual
void
ProtoDeSerialize
(
const
XML::Node
& SelfRoot);
147
148
/// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
149
/// @return A string containing the name of this class.
150
static
String
GetSerializableName
();
151
};
//TextCursor
152
}
//UI
153
}
//Mezzanine
154
155
#endif
Generated on Mon Jan 6 2014 20:58:06 for MezzanineEngine by
1.8.4