Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
GUIEditBox Class Referenceabstract

#include <guiEditBox.h>

+ Inheritance diagram for GUIEditBox:
+ Collaboration diagram for GUIEditBox:

Public Member Functions

 GUIEditBox (IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect< s32 > rectangle, bool border, bool writable)
 
virtual ~GUIEditBox ()
 
virtual void setOverrideFont (IGUIFont *font=0)
 Sets another skin independent font.
 
virtual IGUIFont * getOverrideFont () const
 
virtual IGUIFont * getActiveFont () const
 Get the font which is used right now for drawing.
 
virtual void setOverrideColor (video::SColor color)
 Sets another color for the text.
 
virtual video::SColor getOverrideColor () const
 Gets the override color.
 
virtual void enableOverrideColor (bool enable)
 Sets if the text should use the overide color or the color in the gui skin.
 
virtual bool isOverrideColorEnabled (void) const
 Checks if an override color is enabled.
 
virtual void setWordWrap (bool enable)
 Enables or disables word wrap for using the edit box as multiline text editor.
 
virtual bool isWordWrapEnabled () const
 Checks if word wrap is enabled.
 
virtual void setDrawBorder (bool border)
 Turns the border on or off.
 
virtual bool isDrawBorderEnabled () const
 
virtual void setMultiLine (bool enable)
 Enables or disables newlines.
 
virtual bool isMultiLineEnabled () const
 Checks if multi line editing is enabled.
 
virtual void setAutoScroll (bool enable)
 Enables or disables automatic scrolling with cursor position.
 
virtual bool isAutoScrollEnabled () const
 Checks to see if automatic scrolling is enabled.
 
virtual void setPasswordBox (bool passwordBox, wchar_t passwordChar=L' *')
 Sets whether the edit box is a password box. Setting this to true will.
 
virtual bool isPasswordBox () const
 Returns true if the edit box is currently a password box.
 
virtual void setTextAlignment (EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical)
 Sets text justification.
 
virtual void setText (const wchar_t *text)
 Sets the new caption of this element.
 
virtual void setMax (u32 max)
 Sets the maximum amount of characters which may be entered in the box.
 
virtual u32 getMax () const
 Returns maximum amount of characters, previously set by setMax();.
 
virtual core::dimension2du getTextDimension ()
 Gets the size area of the text in the edit box.
 
virtual void setWritable (bool can_write_text)
 set true if this EditBox is writable
 
virtual bool OnEvent (const SEvent &event)
 called if an event happened.
 
virtual bool acceptsIME ()
 

Protected Member Functions

virtual void breakText ()=0
 
virtual void setTextRect (s32 line)=0
 sets the area of the given line
 
void setTextMarkers (s32 begin, s32 end)
 set text markers
 
void sendGuiEvent (EGUI_EVENT_TYPE type)
 send some gui event to parent
 
virtual void calculateScrollPos ()=0
 calculates the current scroll position
 
virtual s32 getCursorPos (s32 x, s32 y)=0
 
bool processKey (const SEvent &event)
 
virtual void inputString (const core::stringw &str)
 
virtual void inputChar (wchar_t c)
 
s32 getLineFromPos (s32 pos)
 returns the line number that the cursor is on
 
void updateVScrollBar ()
 update the vertical scrollBar (visibilty & position)
 

Protected Attributes

gui::IGUIFont * m_override_font = nullptr
 
bool m_override_color_enabled = false
 
bool m_word_wrap = false
 
bool m_multiline = false
 
bool m_autoscroll = true
 
bool m_border
 
bool m_passwordbox = false
 
wchar_t m_passwordchar = L'*'
 
std::vector< core::stringw > m_broken_text
 
std::vector< s32 > m_broken_text_positions
 
EGUI_ALIGNMENT m_halign = EGUIA_UPPERLEFT
 
EGUI_ALIGNMENT m_valign = EGUIA_CENTER
 
u32 m_blink_start_time = 0
 
s32 m_cursor_pos = 0
 
s32 m_hscroll_pos = 0
 
s32 m_vscroll_pos = 0
 
u32 m_max = 0
 
video::SColor m_override_color = video::SColor(101, 255, 255, 255)
 
core::rect< s32 > m_current_text_rect = core::rect<s32>(0, 0, 1, 1)
 
bool m_writable
 
bool m_mouse_marking = false
 
s32 m_mark_begin = 0
 
s32 m_mark_end = 0
 
gui::IGUIFont * m_last_break_font = nullptr
 
IOSOperator * m_operator = nullptr
 
core::rect< s32 > m_frame_rect
 
u32 m_scrollbar_width = 0
 
GUIScrollBarm_vscrollbar = nullptr
 

Private Member Functions

bool processMouse (const SEvent &event)
 
bool onKeyUp (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 
bool onKeyDown (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 
void onKeyControlC (const SEvent &event)
 
bool onKeyControlX (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 
bool onKeyControlV (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 
bool onKeyBack (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 
bool onKeyDelete (const SEvent &event, s32 &mark_begin, s32 &mark_end)
 

Constructor & Destructor Documentation

◆ GUIEditBox()

GUIEditBox::GUIEditBox ( IGUIEnvironment * environment,
IGUIElement * parent,
s32 id,
core::rect< s32 > rectangle,
bool border,
bool writable )
inline

◆ ~GUIEditBox()

GUIEditBox::~GUIEditBox ( )
virtual

Member Function Documentation

◆ acceptsIME()

virtual bool GUIEditBox::acceptsIME ( )
inlinevirtual

References m_writable.

◆ breakText()

virtual void GUIEditBox::breakText ( )
protectedpure virtual

Implemented in GUIEditBoxWithScrollBar.

Referenced by inputString(), processKey(), setOverrideFont(), setText(), and setWordWrap().

+ Here is the caller graph for this function:

◆ calculateScrollPos()

virtual void GUIEditBox::calculateScrollPos ( )
protectedpure virtual

calculates the current scroll position

Implemented in GUIEditBoxWithScrollBar.

Referenced by inputString(), processKey(), processMouse(), and updateVScrollBar().

+ Here is the caller graph for this function:

◆ enableOverrideColor()

void GUIEditBox::enableOverrideColor ( bool enable)
virtual

Sets if the text should use the overide color or the color in the gui skin.

References m_override_color_enabled.

◆ getActiveFont()

IGUIFont * GUIEditBox::getActiveFont ( ) const
virtual

Get the font which is used right now for drawing.

Currently this is the override font when one is set and the font of the active skin otherwise

References m_override_font.

Referenced by GUIEditBoxWithScrollBar::breakText(), GUIEditBoxWithScrollBar::calculateScrollPos(), GUIEditBoxWithScrollBar::draw(), GUIEditBoxWithScrollBar::getCursorPos(), and GUIEditBoxWithScrollBar::setTextRect().

+ Here is the caller graph for this function:

◆ getCursorPos()

virtual s32 GUIEditBox::getCursorPos ( s32 x,
s32 y )
protectedpure virtual

Implemented in GUIEditBoxWithScrollBar.

Referenced by processMouse().

+ Here is the caller graph for this function:

◆ getLineFromPos()

s32 GUIEditBox::getLineFromPos ( s32 pos)
protected

returns the line number that the cursor is on

References m_broken_text_positions, m_multiline, and m_word_wrap.

Referenced by GUIEditBoxWithScrollBar::calculateScrollPos(), GUIEditBoxWithScrollBar::draw(), onKeyDown(), onKeyUp(), and processKey().

+ Here is the caller graph for this function:

◆ getMax()

virtual u32 GUIEditBox::getMax ( ) const
inlinevirtual

Returns maximum amount of characters, previously set by setMax();.

References m_max.

◆ getOverrideColor()

video::SColor GUIEditBox::getOverrideColor ( ) const
virtual

Gets the override color.

References m_override_color.

◆ getOverrideFont()

virtual IGUIFont * GUIEditBox::getOverrideFont ( ) const
inlinevirtual

References m_override_font.

◆ getTextDimension()

core::dimension2du GUIEditBox::getTextDimension ( )
virtual

Gets the size area of the text in the edit box.

Gets the area of the text in the edit box.

Returns
Returns the size in pixels of the text

References m_broken_text, m_current_text_rect, and setTextRect().

Referenced by updateVScrollBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inputChar()

void GUIEditBox::inputChar ( wchar_t c)
protectedvirtual

References inputString().

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inputString()

void GUIEditBox::inputString ( const core::stringw & str)
protectedvirtual

References breakText(), calculateScrollPos(), porting::getTimeMs(), m_blink_start_time, m_cursor_pos, m_mark_begin, m_mark_end, m_max, m_writable, sendGuiEvent(), and setTextMarkers().

Referenced by inputChar(), OnEvent(), and processMouse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAutoScrollEnabled()

virtual bool GUIEditBox::isAutoScrollEnabled ( ) const
inlinevirtual

Checks to see if automatic scrolling is enabled.

Returns
true if automatic scrolling is enabled, false if not

References m_autoscroll.

◆ isDrawBorderEnabled()

virtual bool GUIEditBox::isDrawBorderEnabled ( ) const
inlinevirtual

Reimplemented in GUIEditBoxWithScrollBar.

References m_border.

◆ isMultiLineEnabled()

virtual bool GUIEditBox::isMultiLineEnabled ( ) const
inlinevirtual

Checks if multi line editing is enabled.

Returns
true if mult-line is enabled, false otherwise

References m_multiline.

◆ isOverrideColorEnabled()

virtual bool GUIEditBox::isOverrideColorEnabled ( void ) const
inlinevirtual

Checks if an override color is enabled.

Returns
true if the override color is enabled, false otherwise

References m_override_color_enabled.

◆ isPasswordBox()

virtual bool GUIEditBox::isPasswordBox ( ) const
inlinevirtual

Returns true if the edit box is currently a password box.

References m_passwordbox.

◆ isWordWrapEnabled()

virtual bool GUIEditBox::isWordWrapEnabled ( ) const
inlinevirtual

Checks if word wrap is enabled.

Returns
true if word wrap is enabled, false otherwise

References m_word_wrap.

◆ OnEvent()

bool GUIEditBox::OnEvent ( const SEvent & event)
virtual

called if an event happened.

References inputString(), m_mouse_marking, processKey(), processMouse(), and setTextMarkers().

+ Here is the call graph for this function:

◆ onKeyBack()

bool GUIEditBox::onKeyBack ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References porting::getTimeMs(), m_blink_start_time, m_cursor_pos, m_mark_begin, m_mark_end, and m_writable.

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onKeyControlC()

void GUIEditBox::onKeyControlC ( const SEvent & event)
private

References m_mark_begin, m_mark_end, m_operator, and m_passwordbox.

Referenced by onKeyControlX(), and processKey().

+ Here is the caller graph for this function:

◆ onKeyControlV()

bool GUIEditBox::onKeyControlV ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References m_cursor_pos, m_mark_begin, m_mark_end, m_max, m_operator, m_writable, and p().

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onKeyControlX()

bool GUIEditBox::onKeyControlX ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References m_cursor_pos, m_mark_begin, m_mark_end, m_operator, m_passwordbox, m_writable, and onKeyControlC().

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onKeyDelete()

bool GUIEditBox::onKeyDelete ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References porting::getTimeMs(), m_blink_start_time, m_cursor_pos, m_mark_begin, m_mark_end, and m_writable.

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onKeyDown()

bool GUIEditBox::onKeyDown ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References getLineFromPos(), m_broken_text, m_broken_text_positions, m_cursor_pos, m_mark_begin, m_mark_end, m_multiline, and m_word_wrap.

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onKeyUp()

bool GUIEditBox::onKeyUp ( const SEvent & event,
s32 & mark_begin,
s32 & mark_end )
private

References getLineFromPos(), m_broken_text, m_broken_text_positions, m_cursor_pos, m_mark_begin, m_mark_end, m_multiline, and m_word_wrap.

Referenced by processKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processKey()

bool GUIEditBox::processKey ( const SEvent & event)
protected

References breakText(), calculateScrollPos(), getLineFromPos(), porting::getTimeMs(), inputChar(), m_blink_start_time, m_broken_text, m_broken_text_positions, m_cursor_pos, m_mark_begin, m_mark_end, m_multiline, m_word_wrap, onKeyBack(), onKeyControlC(), onKeyControlV(), onKeyControlX(), onKeyDelete(), onKeyDown(), onKeyUp(), p(), sendGuiEvent(), and setTextMarkers().

Referenced by OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processMouse()

bool GUIEditBox::processMouse ( const SEvent & event)
private

References calculateScrollPos(), getCursorPos(), GUIScrollBar::getSmallStep(), GUIScrollBar::getTargetPos(), porting::getTimeMs(), inputString(), m_blink_start_time, m_cursor_pos, m_mark_begin, m_mouse_marking, m_operator, m_vscrollbar, GUIScrollBar::setPosInterpolated(), and setTextMarkers().

Referenced by OnEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendGuiEvent()

void GUIEditBox::sendGuiEvent ( EGUI_EVENT_TYPE type)
protected

send some gui event to parent

Referenced by inputString(), processKey(), and setTextMarkers().

+ Here is the caller graph for this function:

◆ setAutoScroll()

void GUIEditBox::setAutoScroll ( bool enable)
virtual

Enables or disables automatic scrolling with cursor position.

Parameters
enableIf set to true, the text will move around with the cursor position

References m_autoscroll.

◆ setDrawBorder()

void GUIEditBox::setDrawBorder ( bool border)
virtual

Turns the border on or off.

References m_border.

◆ setMax()

void GUIEditBox::setMax ( u32 max)
virtual

Sets the maximum amount of characters which may be entered in the box.

Parameters
maxMaximum amount of characters. If 0, the character amount is infinity.

References m_max.

◆ setMultiLine()

void GUIEditBox::setMultiLine ( bool enable)
virtual

Enables or disables newlines.

Parameters
enableIf set to true, the EGET_EDITBOX_ENTER event will not be fired, instead a newline character will be inserted.

References m_multiline.

Referenced by setPasswordBox().

+ Here is the caller graph for this function:

◆ setOverrideColor()

void GUIEditBox::setOverrideColor ( video::SColor color)
virtual

Sets another color for the text.

References m_override_color, and m_override_color_enabled.

◆ setOverrideFont()

void GUIEditBox::setOverrideFont ( IGUIFont * font = 0)
virtual

Sets another skin independent font.

References breakText(), and m_override_font.

+ Here is the call graph for this function:

◆ setPasswordBox()

void GUIEditBox::setPasswordBox ( bool passwordBox,
wchar_t passwordChar = L'*' )
virtual

Sets whether the edit box is a password box. Setting this to true will.

disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x

Parameters
passwordBoxtrue to enable password, false to disable
passwordCharthe character that is displayed instead of letters

References m_broken_text, m_passwordbox, m_passwordchar, setMultiLine(), and setWordWrap().

+ Here is the call graph for this function:

◆ setText()

void GUIEditBox::setText ( const wchar_t * text)
virtual

Sets the new caption of this element.

References breakText(), m_cursor_pos, and m_hscroll_pos.

+ Here is the call graph for this function:

◆ setTextAlignment()

void GUIEditBox::setTextAlignment ( EGUI_ALIGNMENT horizontal,
EGUI_ALIGNMENT vertical )
virtual

Sets text justification.

References m_halign, and m_valign.

◆ setTextMarkers()

void GUIEditBox::setTextMarkers ( s32 begin,
s32 end )
protected

set text markers

References m_mark_begin, m_mark_end, m_operator, m_passwordbox, and sendGuiEvent().

Referenced by inputString(), OnEvent(), processKey(), and processMouse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTextRect()

virtual void GUIEditBox::setTextRect ( s32 line)
protectedpure virtual

sets the area of the given line

Implemented in GUIEditBoxWithScrollBar.

Referenced by getTextDimension().

+ Here is the caller graph for this function:

◆ setWordWrap()

void GUIEditBox::setWordWrap ( bool enable)
virtual

Enables or disables word wrap for using the edit box as multiline text editor.

Enables or disables word wrap.

References breakText(), and m_word_wrap.

Referenced by setPasswordBox().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setWritable()

void GUIEditBox::setWritable ( bool can_write_text)
virtual

set true if this EditBox is writable

References m_writable.

Referenced by GUIEditBoxWithScrollBar::GUIEditBoxWithScrollBar().

+ Here is the caller graph for this function:

◆ updateVScrollBar()

void GUIEditBox::updateVScrollBar ( )
protected

update the vertical scrollBar (visibilty & position)

References calculateScrollPos(), GUIScrollBar::getMax(), GUIScrollBar::getPos(), getTextDimension(), m_current_text_rect, m_frame_rect, m_scrollbar_width, m_vscroll_pos, m_vscrollbar, GUIScrollBar::setMax(), GUIScrollBar::setPageSize(), and GUIScrollBar::setPos().

Referenced by GUIEditBoxWithScrollBar::calculateFrameRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_autoscroll

bool GUIEditBox::m_autoscroll = true
protected

◆ m_blink_start_time

u32 GUIEditBox::m_blink_start_time = 0
protected

◆ m_border

◆ m_broken_text

◆ m_broken_text_positions

◆ m_current_text_rect

◆ m_cursor_pos

◆ m_frame_rect

◆ m_halign

EGUI_ALIGNMENT GUIEditBox::m_halign = EGUIA_UPPERLEFT
protected

◆ m_hscroll_pos

s32 GUIEditBox::m_hscroll_pos = 0
protected

◆ m_last_break_font

gui::IGUIFont* GUIEditBox::m_last_break_font = nullptr
protected

◆ m_mark_begin

◆ m_mark_end

◆ m_max

u32 GUIEditBox::m_max = 0
protected

◆ m_mouse_marking

bool GUIEditBox::m_mouse_marking = false
protected

Referenced by OnEvent(), and processMouse().

◆ m_multiline

◆ m_operator

◆ m_override_color

video::SColor GUIEditBox::m_override_color = video::SColor(101, 255, 255, 255)
protected

◆ m_override_color_enabled

bool GUIEditBox::m_override_color_enabled = false
protected

◆ m_override_font

◆ m_passwordbox

bool GUIEditBox::m_passwordbox = false
protected

◆ m_passwordchar

wchar_t GUIEditBox::m_passwordchar = L'*'
protected

◆ m_scrollbar_width

u32 GUIEditBox::m_scrollbar_width = 0
protected

◆ m_valign

EGUI_ALIGNMENT GUIEditBox::m_valign = EGUIA_CENTER
protected

◆ m_vscroll_pos

s32 GUIEditBox::m_vscroll_pos = 0
protected

◆ m_vscrollbar

◆ m_word_wrap

◆ m_writable


The documentation for this class was generated from the following files: