Lysa UI  0.0
Lysa UI —UI components for the Lysa Engine
TextEdit Class Reference

Detailed Description

An editable single line of text widget.

+ Inheritance diagram for TextEdit:

Public Member Functions

 TextEdit (const std::string &text="")
 
auto isReadOnly () const
 
void setReadOnly (const bool state)
 
void setText (const std::string &text)
 
void setSelStart (uint32 start)
 
auto getText () const
 
auto getSelStart () const
 
auto getFirstDisplayedChar () const
 
auto getDisplayedText () const
 
auto getTextBox () const
 
void setResources (const std::string &resource)
 
- Public Member Functions inherited from Widget
 Widget (Type type=WIDGET)
 
virtual ~Widget () = default
 
Type getType () const
 
bool isVisible () const
 
void show (bool show=true)
 
bool isEnabled () const
 
void enable (bool isEnabled=true)
 
void setPos (float x, float y)
 
float getWidth () const
 
float getHeight () const
 
virtual void setSize (float width, float height)
 
const Rect & getRect () const
 
void setRect (float x, float y, float width, float height)
 
void setRect (const Rect &rect)
 
Alignment getAlignment () const
 
void setAlignment (Alignment alignment)
 
std::shared_ptr< Font > getFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontScale () const
 
virtual void setFontScale (float fontScale)
 
bool isFocused () const
 
Widget * getParent () const
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const std::string &resource, const Alignment alignment, Args &&...args)
 
template<typename T , typename... Args>
std::shared_ptr< T > create (const Alignment alignment, Args &&...args)
 
template<typename T >
std::shared_ptr< T > add (std::shared_ptr< T > child, const Alignment alignment, const std::string &resource="", const bool overlap=false)
 
virtual void remove (const std::shared_ptr< Widget > &child)
 
virtual void removeAll ()
 
void setPadding (float padding)
 
float getPadding () const
 
float getVBorder () const
 
float getHBorder () const
 
void setVBorder (float size)
 
void setHBorder (float size)
 
bool isDrawBackground () const
 
void setDrawBackground (bool drawBackground)
 
bool isPushed () const
 
bool isPointed () const
 
bool isFreezed () const
 
bool isRedrawOnMouseEvent () const
 
bool isOverlapping () const
 
Rect getChildrenRect () const
 
void setFreezed (const bool f)
 
void setPushed (const bool p)
 
void refresh () const
 
void setResource (std::shared_ptr< UIResource > resource)
 
uint32 getGroupIndex () const
 
void setGroupIndex (int32 index)
 
void * getUserData () const
 
void setUserData (void *data)
 
float getTransparency () const
 
void setTransparency (float alpha)
 
void resizeChildren ()
 
std::shared_ptr< Widget > setFocus (bool=true)
 
virtual void eventCreate ()
 
virtual void eventDestroy ()
 
virtual void eventShow ()
 
virtual void eventHide ()
 
virtual void eventEnable ()
 
virtual void eventDisable ()
 
virtual void eventMove (float x, float y)
 
virtual void eventResize ()
 
virtual bool eventKeyUp (Key key)
 
virtual bool eventMouseDown (MouseButton button, float x, float y)
 
virtual bool eventMouseUp (MouseButton button, float x, float y)
 
virtual bool eventMouseMove (uint32, float x, float y)
 
virtual void eventGotFocus ()
 
virtual void eventLostFocus ()
 

Protected Member Functions

bool eventKeyDown (Key key) override
 
bool eventTextInput (const std::string &newText) override
 
void computeNDispChar ()
 

Protected Attributes

std::string text
 
bool readonly {false}
 
uint32 selStart {0}
 
uint32 selLen {0}
 
uint32 startPos {0}
 
uint32 nDispChar {0}
 
std::shared_ptr< Boxbox
 
std::shared_ptr< TexttextBox
 
- Protected Attributes inherited from Widget
const Type type
 
Rect rect
 
Rect defaultRect
 
float hborder {0}
 
float vborder {0}
 
float padding {0}
 
bool overlap {false}
 
bool focused {false}
 
bool allowFocus {false}
 
bool allowChildren {true}
 
bool drawBackground {true}
 
bool moveChildrenOnPush {false}
 
bool redrawOnMouseEvent {false}
 
bool redrawOnMouseMove {false}
 
float transparency {1.0f}
 
Widget * parent {nullptr}
 
Alignment alignment {Alignment::NONE}
 
std::shared_ptr< UIResourceresource
 
std::list< std::shared_ptr< Widget > > children
 
void * window {nullptr}
 
void * style {nullptr}
 
bool mouseMoveOnFocus {false}
 
float fontScale {0.0f}
 

Additional Inherited Members

- Public Types inherited from Widget
enum  Type {
  WIDGET, PANEL, BOX, LINE,
  FRAME, BUTTON, TOGGLEBUTTON, TEXT,
  TEXTEDIT, SCROLLBAR, TREEVIEW, IMAGE
}
 

Constructor & Destructor Documentation

TextEdit ( const std::string &  text = "")

Constructor.

Parameters
ctxThe engine context.
textInitial text.

Member Function Documentation

void computeNDispChar ( )
protected
bool eventKeyDown ( Key  key)
overrideprotectedvirtual
bool eventTextInput ( const std::string &  newText)
overrideprotectedvirtual
auto getDisplayedText ( ) const
inline

Returns the text currently being displayed in the text box.

auto getFirstDisplayedChar ( ) const
inline

Returns the index of the first displayed character.

auto getSelStart ( ) const
inline

Returns the selection start position.

auto getText ( ) const
inline

Returns the text.

auto getTextBox ( ) const
inline

Returns the internal text widget.

auto isReadOnly ( ) const
inline

Returns true if the widget is read-only.

void setReadOnly ( const bool  state)
inline

Sets whether the widget is read-only.

void setResources ( const std::string &  resource)

Sets the UI resources for the text edit.

void setSelStart ( uint32  start)

Sets the selection start position.

void setText ( const std::string &  text)

Sets the text.

Member Data Documentation

std::shared_ptr<Box> box
protected
uint32 nDispChar {0}
protected
bool readonly {false}
protected
uint32 selLen {0}
protected
uint32 selStart {0}
protected
uint32 startPos {0}
protected
std::string text
protected
std::shared_ptr<Text> textBox
protected