40 #ifndef _uieditbox_cpp
41 #define _uieditbox_cpp
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"
50 #include "UI/screen.h"
54 #include "stringtool.h"
73 EditHighlightTarget(-1,-1),
75 EditHighlightOrigin(-1),
81 EditHighlightTarget(-1,-1),
83 EditHighlightOrigin(-1),
89 EditHighlightTarget(-1,-1),
91 EditHighlightOrigin(-1),
96 Widget(RendName,RendRect,Parent),
97 EditHighlightTarget(-1,-1),
99 EditHighlightOrigin(-1),
104 Widget(RendName,RendRect,Parent),
105 EditHighlightTarget(-1,-1),
107 EditHighlightOrigin(-1),
113 EditHighlightTarget(-1,-1),
115 EditHighlightOrigin(-1),
134 if( Code.
GetCode() == Input::OSTEXTINPUT &&
138 if( HighlightStart > -1 && HighlightEnd > -1 ) {
149 if( HighlightStart > -1 && HighlightEnd > -1 ) {
159 if( HighlightStart > -1 && HighlightEnd > -1 ) {
168 if( HighlightStart > -1 && HighlightEnd > -1 ) {
176 if( HighlightStart > -1 && HighlightEnd > -1 ) {
186 }
else if( this->
IsDragged() && ( Code.
GetCode() == Input::MOUSEABSOLUTEHORIZONTAL || Code.
GetCode() == Input::MOUSEABSOLUTEVERTICAL ) ) {
188 if( Code.
GetCode() == Input::MOUSEABSOLUTEHORIZONTAL ) {
190 }
else if( Code.
GetCode() == Input::MOUSEABSOLUTEVERTICAL ) {
202 if( IndexMax == Result.second && IndexMin != Result.second ) {
207 if( IndexMin != HighlightStart || IndexMax != HighlightEnd ) {
222 this->
AddEvent(EditBox::EventTextUpdated);
245 if( EditLayer != NULL ) {
264 if( EditLayer != NULL ) {
274 if( EditLayer != NULL ) {
283 if( EditLayer != NULL ) {
315 if( UncastedLayer != NULL && UncastedLayer->
IsTextLayer() ) {
316 return static_cast<TextLayer*
>(UncastedLayer);
346 if( !PropertiesNode.
Empty() ) {
348 CurrAttrib = PropertiesNode.
GetAttribute(
"EditingEnabled");
349 if( !CurrAttrib.
Empty() )
376 if( EditLayer != NULL ) {
414 {
return new EditBox(RendName,EditLayerType,EditFont,Parent); }
417 {
return new EditBox(RendName,EditLayerType,EditFontName,Parent); }
420 {
return new EditBox(RendName,RendRect,EditLayerType,EditFont,Parent); }
423 {
return new EditBox(RendName,RendRect,EditLayerType,EditFontName,Parent); }
426 {
return new EditBox(XMLNode,Parent); }
429 {
return new EditBox(Parent); }
436 NameValuePairMap::const_iterator ParamIt;
437 ParamIt = Params.find(
"EditFontName");
438 if( ParamIt != Params.end() )
439 EditFontName = (*ParamIt).second;
441 ParamIt = Params.find(
"EditLayerType");
442 if( ParamIt != Params.end() )
445 return this->
CreateEditBox(RendName,EditLayerType,EditFontName,Parent);
453 NameValuePairMap::const_iterator ParamIt;
454 ParamIt = Params.find(
"EditFontName");
455 if( ParamIt != Params.end() )
456 EditFontName = (*ParamIt).second;
458 ParamIt = Params.find(
"EditLayerType");
459 if( ParamIt != Params.end() )
462 return this->
CreateEditBox(RendName,RendRect,EditLayerType,EditFontName,Parent);
469 {
delete static_cast<EditBox*
>( ToBeDestroyed ); }
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.
Vector2 EditHighlightTarget
Stores the screen position where the mouse is located during editing. Used to find the end index for ...
A light-weight handle for manipulating attributes in DOM tree.
virtual void _OnFocusLost()
Self logic to be executed when focus is removed from this widget.
virtual void SetEditingEnabled(Boole Enable)
Sets wether or not this EditBox will consume inputs to generate text.
bool Boole
Generally acts a single bit, true or false.
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.
virtual const String & GetTypeName() const
Gets the type of widget this is.
virtual Boole IsCurrentlyEditing() const
Checks to see if this EditBox is currently Editing.
virtual void InsertCharacterAtCursor(const UInt32 GlyphID)
Creates a character from a Glyph ID and inserts it at the cursor position.
Thrown when the requested identity could not be found.
virtual void MoveCursorLeft()
Decrements this cursors index position, moving it to the left.
EditBox(Screen *Parent)
Blank constructor.
virtual void _OnMouseDragEnd()
Self logic to be executed when the mouse cursor stops dragging across the bounds of this widget...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
int Integer
A datatype used to represent any integer close to.
A simple reference counting pointer.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Value representing a SingleLineTextLayer.
virtual String GetWidgetTypeName() const
Gets the name of the Widget that is created by this factory.
virtual void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
virtual void MoveCursorRight()
Increments this cursors index position, moving it to the right.
virtual void SetText(const String &Text)
Sets the text in the edit layer of this EditBox.
FontData * GetFont(const String &FontName, const String &Atlas) const
Gets the specified FontData from an Atlas.
virtual String GetText() const
Gets the text in the edit layer of this EditBox.
virtual void SetInputFilter(FilterCallback *Callback)
Sets the filter that will be used by this EditBox to determine if an input will be consumed...
bool Empty() const
Is this storing anything at all?
This implements the exception hiearchy for Mezzanine.
virtual void SetCursorEnabled(Boole Enable)
Enables (or disables) the cursor for use in this layer.
virtual void _OnMouseDragStart()
Self logic to be executed when the mouse cursor starts dragging across the bounds of this widget...
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.
virtual Widget * CreateWidget(Screen *Parent)
Creates a Widget of the type represented by this factory.
The interface for serialization.
Integer EditHighlightOrigin
Stores the index of the character initially highlighted while editing.
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...
virtual FilterCallback * GetIntputFilter() const
Gets the filter that is being used by this EditBox to determine if an input will be consumed...
Real Y
Coordinate on the Y vector.
virtual Integer GetHighlightEnd() const
Gets the index of this last character that is highlighted in this layer.
virtual void RemoveLeftCharacter()
Removes the character to the left (and decrements the index position) of this cursor.
virtual CharIndexPair GetIndexAtOffset(const Vector2 &Offset)
Gets the index of the character at the specified offset position.
A light-weight handle for manipulating nodes in DOM tree.
virtual Boole GetEditingEnabled() const
Gets wether or not this EditBox will consume inputs to generate text.
Real X
Coordinate on the X vector.
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".
bool Empty() const
Is this storing anything at all?
virtual void Highlight()
Highlights all characters in this layer.
Class for encapsulating the functionality of the text cursor/carat navigation in text layers...
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.
virtual TextLayer * GetEditLayer() const
Gets the layer that consumed inputs will be inserted into.
virtual void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
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.
String Name
The unique name of this Renderable.
virtual void ConstructEditBox(const RenderLayerType EditLayerType, FontData *EditFont)
Contains all the common necessary startup initializations for this class.
void FireEvent(EventArgumentsPtr Args)
Fires an event.
virtual String GetText() const
Gets the text displayed within this layer.
virtual void ClearHighlights()
Clears all the highlights in this layer.
virtual void DestroyWidget(Widget *ToBeDestroyed)
Destroys a Widget created by this factory.
Thrown when parameters are checked at runtime and found invalid.
virtual Boole IsTextLayer() const
Gets whether or not this is a TextLayer.
virtual void _OnTextUpdated()
Self logic to be executed when this EditBox updates its text.
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
virtual ~EditBox()
Class destructor.
virtual void SetCursorIndex(const Integer &Index)
Sets the index position of this cursor.
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...
static const String EventTextUpdated
Event name for when the text in this widget has been updated.
The bulk of the engine components go in this namspace.
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&).
virtual Boole HandleInputImpl(const Input::MetaCode &Code)
Consumes input for this widget's use.
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.
virtual EditBox * CreateEditBox(const String &RendName, const RenderLayerType EditLayerType, FontData *EditFont, Screen *Parent)
Creates a new EditBox.
virtual TextCursor * GetCursor() const
Gets the TextCursor in use by this layer.
SingleLineTextLayer * CreateSingleLineTextLayer()
Creats a SingleLineTextLayer for this renderable.
Vector2 Position
Vector2 representing the top-left position of the rect.
virtual void SetDefaultFont(FontData *NewFont)
Sets the default font to be used with this layer.
virtual void SetText(const String &Text)
Sets the text displayed within this layer.
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.
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...
virtual void UpdateEditMode()
Convenience method that will check the configuration of this EditBox to determine if inputs will be c...
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
std::string String
A datatype used to a series of characters.
This is a base class for render layers that render text.
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. ...
virtual void _OnFocusGained()
Self logic to be executed when focus is given to this widget.
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.
Widget for handling the input and manipulation of text.