Spinning Topp Logo BlackTopp Studios
inc
editbox.cpp
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 #ifndef _uieditbox_cpp
41 #define _uieditbox_cpp
42 
43 #include "UI/editbox.h"
44 #include "UI/textlayer.h"
45 #include "UI/singlelinetextlayer.h"
46 #include "UI/multilinetextlayer.h"
47 #include "UI/renderlayergroup.h"
48 #include "UI/textcursor.h"
49 #include "UI/font.h"
50 #include "UI/screen.h"
51 
52 #include "serialization.h"
53 #include "exception.h"
54 #include "stringtool.h"
55 
56 #include <algorithm>
57 
58 namespace Mezzanine
59 {
60  namespace UI
61  {
62  ///////////////////////////////////////////////////////////////////////////////
63  // EditBox Static Members
64 
65  const String EditBox::TypeName = "EditBox";
66  const String EditBox::EventTextUpdated = "TextUpdated";
67 
68  ///////////////////////////////////////////////////////////////////////////////
69  // EditBox Methods
70 
72  Widget(Parent),
73  EditHighlightTarget(-1,-1),
74  InputFilter(NULL),
75  EditHighlightOrigin(-1),
76  EditingEnabled(true)
77  { }
78 
79  EditBox::EditBox(const String& RendName, const RenderLayerType EditLayerType, FontData* EditFont, Screen* Parent) :
80  Widget(RendName,Parent),
81  EditHighlightTarget(-1,-1),
82  InputFilter(NULL),
83  EditHighlightOrigin(-1),
84  EditingEnabled(true)
85  { this->ConstructEditBox(EditLayerType,EditFont); }
86 
87  EditBox::EditBox(const String& RendName, const RenderLayerType EditLayerType, const String& EditFontName, Screen* Parent) :
88  Widget(RendName,Parent),
89  EditHighlightTarget(-1,-1),
90  InputFilter(NULL),
91  EditHighlightOrigin(-1),
92  EditingEnabled(true)
93  { this->ConstructEditBox(EditLayerType,this->ParentScreen->GetFont(EditFontName,this->ParentScreen->GetPrimaryAtlas())); }
94 
95  EditBox::EditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, FontData* EditFont, Screen* Parent) :
96  Widget(RendName,RendRect,Parent),
97  EditHighlightTarget(-1,-1),
98  InputFilter(NULL),
99  EditHighlightOrigin(-1),
100  EditingEnabled(true)
101  { this->ConstructEditBox(EditLayerType,EditFont); }
102 
103  EditBox::EditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, const String& EditFontName, Screen* Parent) :
104  Widget(RendName,RendRect,Parent),
105  EditHighlightTarget(-1,-1),
106  InputFilter(NULL),
107  EditHighlightOrigin(-1),
108  EditingEnabled(true)
109  { this->ConstructEditBox(EditLayerType,this->ParentScreen->GetFont(EditFontName,this->ParentScreen->GetPrimaryAtlas())); }
110 
111  EditBox::EditBox(const XML::Node& XMLNode, Screen* Parent) :
112  Widget(Parent),
113  EditHighlightTarget(-1,-1),
114  InputFilter(NULL),
115  EditHighlightOrigin(-1),
116  EditingEnabled(true)
117  { this->ProtoDeSerialize(XMLNode); }
118 
120  { }
121 
123  {
124  // Verify we can consume inputs.
125  if( this->IsCurrentlyEditing() ) {
126  // Get the layer and get the cursor.
127  TextLayer* EditLayer = this->GetEditLayer();
128  TextCursor* EditCursor = EditLayer->GetCursor();
129  // Get our highlight indexes.
130  const Integer HighlightStart = EditLayer->GetHighlightStart();
131  const Integer HighlightEnd = EditLayer->GetHighlightEnd();
132 
133  // Start our actual checks.
134  if( Code.GetCode() == Input::OSTEXTINPUT &&
135  ( this->InputFilter != NULL ? this->InputFilter( Code.GetMetaValue() ) : true ) )
136  {
137  // If there is a selection range we need to clear it before inserting.
138  if( HighlightStart > -1 && HighlightEnd > -1 ) {
139  // Set our post erase position.
140  EditCursor->SetCursorIndex(HighlightStart);
141  EditLayer->RemoveCharacterRange(HighlightStart,HighlightEnd);
142  }
143  // Finally perform our insert.
144  EditLayer->GetCursor()->InsertCharacterAtCursor( Code.GetMetaValue() );
145  this->_OnTextUpdated();
146  return true;
147  }else if( Code.GetCode() == Input::KEY_BACKSPACE && Code.GetMetaValue() == Input::BUTTON_PRESSING ) {
148  /// @todo Enable repeat backspace somehow.
149  if( HighlightStart > -1 && HighlightEnd > -1 ) {
150  EditCursor->SetCursorIndex(HighlightStart);
151  EditLayer->RemoveCharacterRange(HighlightStart,HighlightEnd);
152  }else{
153  EditCursor->RemoveLeftCharacter();
154  }
155  this->_OnTextUpdated();
156  return true;
157  }else if( Code.GetCode() == Input::KEY_LEFT && Code.GetMetaValue() == Input::BUTTON_PRESSING ) {
158  /// @todo Enable repeat move somehow.
159  if( HighlightStart > -1 && HighlightEnd > -1 ) {
160  EditCursor->SetCursorIndex(HighlightStart);
161  EditLayer->ClearHighlights();
162  }else{
163  EditCursor->MoveCursorLeft();
164  }
165  return true;
166  }else if( Code.GetCode() == Input::KEY_RIGHT && Code.GetMetaValue() == Input::BUTTON_PRESSING ) {
167  /// @todo Enable repeat move somehow.
168  if( HighlightStart > -1 && HighlightEnd > -1 ) {
169  EditCursor->SetCursorIndex(HighlightEnd);
170  EditLayer->ClearHighlights();
171  }else{
172  EditCursor->MoveCursorRight();
173  }
174  return true;
175  }else if( !this->IsDragged() && Code.GetCode() == Input::MOUSEBUTTON_1 && Code.GetMetaValue() == Input::BUTTON_PRESSING ) {
176  if( HighlightStart > -1 && HighlightEnd > -1 ) {
177  EditLayer->ClearHighlights();
178  }
179  // Find the offset position of the mouse and use that to update our cursor position.
181  if( !Result.first )
182  return false;
183  // Perform the update.
184  EditCursor->SetCursorIndex( Result.second );
185  return true;
186  }else if( this->IsDragged() && ( Code.GetCode() == Input::MOUSEABSOLUTEHORIZONTAL || Code.GetCode() == Input::MOUSEABSOLUTEVERTICAL ) ) {
187  // Assign the horizontal or vertical value to the target, then check if we have a complete target.
188  if( Code.GetCode() == Input::MOUSEABSOLUTEHORIZONTAL ) {
189  this->EditHighlightTarget.X = Code.GetMetaValue();
190  }else if( Code.GetCode() == Input::MOUSEABSOLUTEVERTICAL ) {
191  this->EditHighlightTarget.Y = Code.GetMetaValue();
192  }
193  if( this->EditHighlightTarget.X > -1 && this->EditHighlightTarget.Y > -1 ) {
194  // When the mouse is updated, the absolute position for both axes is send out regardless of change.
195  // So we'd only get to this point if we've processed both events. Convert our target to a usable index.
197  if( !Result.first )
198  return false;
199  // The mouse can move to earlier characters in the squence, so sort out which index is the actual start in this set.
200  Integer IndexMin = std::min(this->EditHighlightOrigin,Result.second);
201  Integer IndexMax = std::max(this->EditHighlightOrigin,Result.second);
202  if( IndexMax == Result.second && IndexMin != Result.second ) {
203  // If we're dragging to the right, we want the mouse cursor to be on the edge of the highlights, so reduce the index to be used for highlighting.
204  --IndexMax;
205  }
206  // If there was a change, update it.
207  if( IndexMin != HighlightStart || IndexMax != HighlightEnd ) {
208  EditLayer->Highlight(IndexMin,IndexMax);
209  }
210  // Update our cursor position
211  EditCursor->SetCursorIndex(Result.second);
212  }
213  return true;
214  }
215  }
216  return false;
217  }
218 
219  void EditBox::ConstructEditBox(const RenderLayerType EditLayerType, FontData* EditFont)
220  {
221  // Create our events.
222  this->AddEvent(EditBox::EventTextUpdated);
223 
224  // Create our edit layer.
225  TextLayer* EditLayer = NULL;
226  if( EditLayerType == UI::RLT_SingleLineText ) {
227  EditLayer = this->CreateSingleLineTextLayer();
228  }else if( EditLayerType == UI::RLT_MultiLineText ) {
229  EditLayer = this->CreateMultiLineTextLayer();
230  }else{
231  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Invalid RenderLayer type passed in to EditBox constructor.");
232  }
233 
234  // Set the font separately since setting the font on construction can only be done via string. todo?
235  EditLayer->SetDefaultFont(EditFont);
236 
237  // Add the edit layer to the default groups.
238  this->AddLayerToGroup(EditLayer,5,Widget::WG_Normal);
239  this->AddLayerToGroup(EditLayer,5,Widget::WG_Hovered);
240  }
241 
243  {
244  TextLayer* EditLayer = this->GetEditLayer();
245  if( EditLayer != NULL ) {
246  if( this->EditingEnabled && this->HasFocus() ) {
247  EditLayer->SetCursorEnabled(true);
248  }else{
249  EditLayer->ClearHighlights();
250  EditLayer->SetCursorEnabled(false);
251  }
252  }
253  }
254 
255  ///////////////////////////////////////////////////////////////////////////////
256  // Utility Methods
257 
259  { return EditBox::TypeName; }
260 
262  {
263  TextLayer* EditLayer = this->GetEditLayer();
264  if( EditLayer != NULL ) {
265  TextCursor* EditCursor = EditLayer->GetCursor();
266  return ( ( EditCursor != NULL ) && this->HasFocus() && this->EditingEnabled );
267  }
268  return false;
269  }
270 
271  void EditBox::SetText(const String& Text)
272  {
273  TextLayer* EditLayer = this->GetEditLayer();
274  if( EditLayer != NULL ) {
275  EditLayer->SetText(Text);
276  this->_OnTextUpdated();
277  }
278  }
279 
281  {
282  TextLayer* EditLayer = this->GetEditLayer();
283  if( EditLayer != NULL ) {
284  return EditLayer->GetText();
285  }
286  return "";
287  }
288 
289  ///////////////////////////////////////////////////////////////////////////////
290  // EditBox Properties
291 
293  {
294  if( this->EditingEnabled != Enable ) {
295  this->EditingEnabled = Enable;
296  this->UpdateEditMode();
297  }
298  }
299 
301  { return this->EditingEnabled; }
302 
303  ///////////////////////////////////////////////////////////////////////////////
304  // EditBox Configuration
305 
307  { this->InputFilter = Callback; }
308 
310  { return this->InputFilter; }
311 
313  {
314  RenderLayer* UncastedLayer = this->ActiveGroup->GetLayerByZOrder(5);
315  if( UncastedLayer != NULL && UncastedLayer->IsTextLayer() ) {
316  return static_cast<TextLayer*>(UncastedLayer);
317  }
318  return NULL;
319  }
320 
321  ///////////////////////////////////////////////////////////////////////////////
322  // Serialization
323 
325  {
326  this->Widget::ProtoSerializeProperties(SelfRoot);
327 
328  XML::Node PropertiesNode = SelfRoot.AppendChild( EditBox::GetSerializableName() + "Properties" );
329 
330  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
331  PropertiesNode.AppendAttribute("EditingEnabled").SetValue( this->EditingEnabled ) )
332  {
333  return;
334  }else{
335  SerializeError("Create XML Attribute Values",EditBox::GetSerializableName() + "Properties",true);
336  }
337  }
338 
340  {
341  this->Widget::ProtoDeSerializeProperties(SelfRoot);
342 
343  XML::Attribute CurrAttrib;
344  XML::Node PropertiesNode = SelfRoot.GetChild( EditBox::GetSerializableName() + "Properties" );
345 
346  if( !PropertiesNode.Empty() ) {
347  if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
348  CurrAttrib = PropertiesNode.GetAttribute("EditingEnabled");
349  if( !CurrAttrib.Empty() )
350  this->SetEditingEnabled( CurrAttrib.AsBool() );
351  }else{
352  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (EditBox::GetSerializableName() + "Properties") + ": Not Version 1.");
353  }
354  }else{
355  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,EditBox::GetSerializableName() + "Properties" + " was not found in the provided XML node, which was expected.");
356  }
357  }
358 
360  {
361  return EditBox::TypeName;
362  }
363 
364  ///////////////////////////////////////////////////////////////////////////////
365  // Internal Event Methods
366 
368  {
369  WidgetEventArgumentsPtr Args( new WidgetEventArguments(EditBox::EventTextUpdated,this->Name) );
370  this->FireEvent(Args);
371  }
372 
374  {
375  TextLayer* EditLayer = this->GetEditLayer();
376  if( EditLayer != NULL ) {
378  if( Result.first ) {
379  this->EditHighlightOrigin = Result.second;
380  }
381  }
383  }
384 
386  {
387  this->EditHighlightTarget.SetValues(-1,-1);
388  this->EditHighlightOrigin = -1;
389  this->Widget::_OnMouseDragEnd();
390  }
391 
393  {
394  this->Widget::_OnFocusGained();
395  this->UpdateEditMode();
396  }
397 
399  {
400  this->Widget::_OnFocusLost();
401  this->UpdateEditMode();
402  }
403 
404  ///////////////////////////////////////////////////////////////////////////////
405  // Internal Methods
406 
407  ///////////////////////////////////////////////////////////////////////////////
408  // EditBoxFactory Methods
409 
411  { return EditBox::TypeName; }
412 
413  EditBox* EditBoxFactory::CreateEditBox(const String& RendName, const RenderLayerType EditLayerType, FontData* EditFont, Screen* Parent)
414  { return new EditBox(RendName,EditLayerType,EditFont,Parent); }
415 
416  EditBox* EditBoxFactory::CreateEditBox(const String& RendName, const RenderLayerType EditLayerType, const String& EditFontName, Screen* Parent)
417  { return new EditBox(RendName,EditLayerType,EditFontName,Parent); }
418 
419  EditBox* EditBoxFactory::CreateEditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, FontData* EditFont, Screen* Parent)
420  { return new EditBox(RendName,RendRect,EditLayerType,EditFont,Parent); }
421 
422  EditBox* EditBoxFactory::CreateEditBox(const String& RendName, const UnifiedRect& RendRect, const RenderLayerType EditLayerType, const String& EditFontName, Screen* Parent)
423  { return new EditBox(RendName,RendRect,EditLayerType,EditFontName,Parent); }
424 
426  { return new EditBox(XMLNode,Parent); }
427 
429  { return new EditBox(Parent); }
430 
431  Widget* EditBoxFactory::CreateWidget(const String& RendName, const NameValuePairMap& Params, Screen* Parent)
432  {
433  String EditFontName;
435 
436  NameValuePairMap::const_iterator ParamIt;
437  ParamIt = Params.find("EditFontName");
438  if( ParamIt != Params.end() )
439  EditFontName = (*ParamIt).second;
440 
441  ParamIt = Params.find("EditLayerType");
442  if( ParamIt != Params.end() )
443  EditLayerType = static_cast<UI::RenderLayerType>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
444 
445  return this->CreateEditBox(RendName,EditLayerType,EditFontName,Parent);
446  }
447 
448  Widget* EditBoxFactory::CreateWidget(const String& RendName, const UnifiedRect& RendRect, const NameValuePairMap& Params, Screen* Parent)
449  {
450  String EditFontName;
452 
453  NameValuePairMap::const_iterator ParamIt;
454  ParamIt = Params.find("EditFontName");
455  if( ParamIt != Params.end() )
456  EditFontName = (*ParamIt).second;
457 
458  ParamIt = Params.find("EditLayerType");
459  if( ParamIt != Params.end() )
460  EditLayerType = static_cast<UI::RenderLayerType>( StringTools::ConvertToUInt32( (*ParamIt).second ) );
461 
462  return this->CreateEditBox(RendName,RendRect,EditLayerType,EditFontName,Parent);
463  }
464 
466  { return this->CreateEditBox(XMLNode,Parent); }
467 
469  { delete static_cast<EditBox*>( ToBeDestroyed ); }
470  }//UI
471 }//Mezzanine
472 
473 #endif
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
This class represents a collection of Glyphs in a common visual style.
Definition: font.h:55
Vector2 EditHighlightTarget
Stores the screen position where the mouse is located during editing. Used to find the end index for ...
Definition: editbox.h:72
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
virtual void _OnFocusLost()
Self logic to be executed when focus is removed from this widget.
Definition: editbox.cpp:398
UInt32 ConvertToUInt32(const String &ToConvert)
Converts a string into a UInt32.
Definition: stringtool.cpp:456
virtual void _OnFocusLost()
Self logic to be executed when focus is removed from this widget.
Definition: widget.cpp:496
virtual void SetEditingEnabled(Boole Enable)
Sets wether or not this EditBox will consume inputs to generate text.
Definition: editbox.cpp:292
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
RenderLayerGroup * ActiveGroup
This is a pointer to the group of RenderLayers currently being used for rendering.
bool AsBool(bool def=false) const
Attempts to convert the value of the attribute to a float and returns the results.
Boole( FilterCallback)(const Int32 Glyph)
Callback type for input filtering.
Definition: editbox.h:68
virtual const String & GetTypeName() const
Gets the type of widget this is.
Definition: editbox.cpp:258
virtual Boole IsCurrentlyEditing() const
Checks to see if this EditBox is currently Editing.
Definition: editbox.cpp:261
virtual void InsertCharacterAtCursor(const UInt32 GlyphID)
Creates a character from a Glyph ID and inserts it at the cursor position.
Definition: textcursor.cpp:186
Thrown when the requested identity could not be found.
Definition: exception.h:94
virtual void MoveCursorLeft()
Decrements this cursors index position, moving it to the left.
Definition: textcursor.cpp:165
EditBox(Screen *Parent)
Blank constructor.
Definition: editbox.cpp:71
virtual void _OnMouseDragEnd()
Self logic to be executed when the mouse cursor stops dragging across the bounds of this widget...
Definition: editbox.cpp:385
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
A simple reference counting pointer.
Definition: countedptr.h:70
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: widget.cpp:278
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
Value representing a SingleLineTextLayer.
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
Definition: editbox.cpp:410
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: editbox.cpp:339
virtual void MoveCursorRight()
Increments this cursors index position, moving it to the right.
Definition: textcursor.cpp:177
virtual void SetText(const String &Text)
Sets the text in the edit layer of this EditBox.
Definition: editbox.cpp:271
FontData * GetFont(const String &FontName, const String &Atlas) const
Gets the specified FontData from an Atlas.
Definition: screen.cpp:889
virtual String GetText() const
Gets the text in the edit layer of this EditBox.
Definition: editbox.cpp:280
virtual void SetInputFilter(FilterCallback *Callback)
Sets the filter that will be used by this EditBox to determine if an input will be consumed...
Definition: editbox.cpp:306
bool Empty() const
Is this storing anything at all?
This implements the exception hiearchy for Mezzanine.
Int32 GetMetaValue() const
This Returns the MetaValue.
Definition: metacode.cpp:250
virtual void SetCursorEnabled(Boole Enable)
Enables (or disables) the cursor for use in this layer.
Definition: textlayer.cpp:632
virtual void _OnMouseDragStart()
Self logic to be executed when the mouse cursor starts dragging across the bounds of this widget...
Definition: editbox.cpp:373
Rect ActDims
The actual (pixel) position and size of this Quad on the screen it belongs to.
RenderLayer * GetLayerByZOrder(const UInt16 ZOrder) const
Gets a RenderLayer in this group by it's ZOrder.
Value representing a MultiLineTextLayer.
std::pair< Boole, Integer > CharIndexPair
An std::pair type used as a return for index-offset conversions.
Definition: textlayer.h:86
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
Definition: editbox.cpp:428
The interface for serialization.
Integer EditHighlightOrigin
Stores the index of the character initially highlighted while editing.
Definition: editbox.h:78
bool SetValue(const Char8 *rhs)
Set the value of this.
This class represents a 2D rect which can express the size and position of a renderable on screen...
Definition: unifieddim.h:661
virtual FilterCallback * GetIntputFilter() const
Gets the filter that is being used by this EditBox to determine if an input will be consumed...
Definition: editbox.cpp:309
Real Y
Coordinate on the Y vector.
Definition: vector2.h:69
virtual Integer GetHighlightEnd() const
Gets the index of this last character that is highlighted in this layer.
Definition: textlayer.cpp:585
virtual void RemoveLeftCharacter()
Removes the character to the left (and decrements the index position) of this cursor.
Definition: textcursor.cpp:210
virtual CharIndexPair GetIndexAtOffset(const Vector2 &Offset)
Gets the index of the character at the specified offset position.
Definition: textlayer.cpp:393
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
virtual Boole GetEditingEnabled() const
Gets wether or not this EditBox will consume inputs to generate text.
Definition: editbox.cpp:300
Real X
Coordinate on the X vector.
Definition: vector2.h:67
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
static const String TypeName
String containing the type name for this class: "EditBox".
Definition: editbox.h:64
bool Empty() const
Is this storing anything at all?
virtual void _OnFocusGained()
Self logic to be executed when focus is given to this widget.
Definition: widget.cpp:485
This is the base class for all widgets.
Definition: widget.h:126
virtual void Highlight()
Highlights all characters in this layer.
Definition: textlayer.cpp:545
Most commonly left click.
Class for encapsulating the functionality of the text cursor/carat navigation in text layers...
Definition: textcursor.h:59
Event * AddEvent(const String &EventName)
Creates a new event this Publisher can fire.
virtual Integer GetHighlightStart() const
Gets the index of the first character that is highlighted in this layer.
Definition: textlayer.cpp:580
virtual TextLayer * GetEditLayer() const
Gets the layer that consumed inputs will be inserted into.
Definition: editbox.cpp:312
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: editbox.cpp:324
void AddLayerToGroup(RenderLayer *Layer, const UInt16 LayerZOrder, const UInt16 GroupID)
Adds a RenderLayer to the specified group.
void SetValues(const Real &x, const Real &y)
Sets the X and Y values of this vector2.
Definition: vector2.cpp:105
String Name
The unique name of this Renderable.
Definition: renderable.h:81
virtual void ConstructEditBox(const RenderLayerType EditLayerType, FontData *EditFont)
Contains all the common necessary startup initializations for this class.
Definition: editbox.cpp:219
void FireEvent(EventArgumentsPtr Args)
Fires an event.
virtual String GetText() const
Gets the text displayed within this layer.
Definition: textlayer.cpp:434
Input::InputCode GetCode() const
This Returns the Inputcode.
Definition: metacode.cpp:244
virtual void ClearHighlights()
Clears all the highlights in this layer.
Definition: textlayer.cpp:590
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
Definition: editbox.cpp:468
Thrown when parameters are checked at runtime and found invalid.
Definition: exception.h:108
virtual Boole IsTextLayer() const
Gets whether or not this is a TextLayer.
This Determines the kind of user input.
Definition: metacode.h:93
virtual void _OnTextUpdated()
Self logic to be executed when this EditBox updates its text.
Definition: editbox.cpp:367
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Definition: editbox.cpp:359
virtual ~EditBox()
Class destructor.
Definition: editbox.cpp:119
virtual void SetCursorIndex(const Integer &Index)
Sets the index position of this cursor.
Definition: textcursor.cpp:83
RenderLayerType
This enum describes the type of RenderLayer this is for use in casting.
FilterCallback * InputFilter
A pointer to the method that will filter any input before adding it as text to this EditBox...
Definition: editbox.h:75
static const String EventTextUpdated
Event name for when the text in this widget has been updated.
Definition: editbox.h:66
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
MultiLineTextLayer * CreateMultiLineTextLayer()
Creats a MultiLineTextLayer for this renderable.
virtual const Vector2 & GetMouseHitPosition() const
Gets the mouse position from the last call to "FindHoveredQuad(const Vector2&).
Definition: screen.cpp:434
virtual Boole HandleInputImpl(const Input::MetaCode &Code)
Consumes input for this widget's use.
Definition: editbox.cpp:122
virtual void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
virtual Integer RemoveCharacterRange(const Integer First, const Integer Last)
Removes a range of characters from the text in this layer.
Definition: textlayer.cpp:895
virtual EditBox * CreateEditBox(const String &RendName, const RenderLayerType EditLayerType, FontData *EditFont, Screen *Parent)
Creates a new EditBox.
Definition: editbox.cpp:413
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: widget.cpp:337
virtual Boole HasFocus() const
Gets whether or not this widget currently has focus.
Definition: widget.cpp:162
virtual Boole IsDragged() const
Gets whether or not the system mouse is being dragged over this widget.
Definition: widget.cpp:165
virtual TextCursor * GetCursor() const
Gets the TextCursor in use by this layer.
Definition: textlayer.cpp:654
virtual void _OnMouseDragStart()
Self logic to be executed when the mouse cursor starts dragging across the bounds of this widget...
Definition: widget.cpp:463
SingleLineTextLayer * CreateSingleLineTextLayer()
Creats a SingleLineTextLayer for this renderable.
Vector2 Position
Vector2 representing the top-left position of the rect.
Definition: rect.h:69
virtual void SetDefaultFont(FontData *NewFont)
Sets the default font to be used with this layer.
Definition: textlayer.cpp:489
virtual void SetText(const String &Text)
Sets the text displayed within this layer.
Definition: textlayer.cpp:411
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Boole EditingEnabled
Stores whether or not inputs into this widget will alter it's underlying text.
Definition: editbox.h:81
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::map< String, String > NameValuePairMap
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:209
virtual void UpdateEditMode()
Convenience method that will check the configuration of this EditBox to determine if inputs will be c...
Definition: editbox.cpp:242
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
virtual void _OnMouseDragEnd()
Self logic to be executed when the mouse cursor stops dragging across the bounds of this widget...
Definition: widget.cpp:474
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
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
This is the base class for the types of layers that can be added to a renderable. ...
Definition: renderlayer.h:58
virtual void _OnFocusGained()
Self logic to be executed when focus is given to this widget.
Definition: editbox.cpp:392
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
Screen * ParentScreen
A pointer to the Screen that created this Renderable.
Definition: renderable.h:72
This is the base class for widget specific event arguments.
Definition: widget.h:60
Widget for handling the input and manipulation of text.
Definition: editbox.h:60