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

Protected Member Functions

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

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

◆ breakText()

virtual void GUIEditBox::breakText ( )
protectedpure virtual

Implemented in irr::gui::intlGUIEditBox, and GUIEditBoxWithScrollBar.

Referenced by inputChar(), 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 irr::gui::intlGUIEditBox, and GUIEditBoxWithScrollBar.

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

+ Here is the caller graph for this function:

◆ deserializeAttributes()

void GUIEditBox::deserializeAttributes ( io::IAttributes *  in,
io::SAttributeReadWriteOptions *  options = 0 
)
virtual

Reads attributes of the element.

Reimplemented in GUIEditBoxWithScrollBar.

References enableOverrideColor(), setAutoScroll(), setMax(), setMultiLine(), setOverrideColor(), setPasswordBox(), setTextAlignment(), setWordWrap(), and setWritable().

Referenced by GUIEditBoxWithScrollBar::deserializeAttributes().

+ Here is the call graph for this function:
+ 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.

Referenced by deserializeAttributes().

+ Here is the caller graph for this function:

◆ 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(), irr::gui::intlGUIEditBox::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 irr::gui::intlGUIEditBox, and 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(), irr::gui::intlGUIEditBox::calculateScrollPos(), GUIEditBoxWithScrollBar::draw(), irr::gui::intlGUIEditBox::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();.

◆ getOverrideColor()

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

Gets the override color.

References m_override_color.

◆ getOverrideFont()

virtual IGUIFont* GUIEditBox::getOverrideFont ( ) const
inlinevirtual

◆ 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 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 processKey().

+ 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

◆ isDrawBorderEnabled()

virtual bool GUIEditBox::isDrawBorderEnabled ( ) const
inlinevirtual

Reimplemented in GUIEditBoxWithScrollBar.

◆ isMultiLineEnabled()

virtual bool GUIEditBox::isMultiLineEnabled ( ) const
inlinevirtual

Checks if multi line editing is enabled.

Returns
true if mult-line is enabled, false otherwise

◆ 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

◆ isPasswordBox()

virtual bool GUIEditBox::isPasswordBox ( ) const
inlinevirtual

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

◆ isWordWrapEnabled()

virtual bool GUIEditBox::isWordWrapEnabled ( ) const
inlinevirtual

Checks if word wrap is enabled.

Returns
true if word wrap is enabled, false otherwise

◆ OnEvent()

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

called if an event happened.

References 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, and m_mark_end.

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, 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, 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, and m_mark_end.

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, m_writable, 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::getPos(), GUIScrollBar::getSmallStep(), porting::getTimeMs(), m_blink_start_time, m_cursor_pos, m_mark_begin, m_mouse_marking, m_vscrollbar, GUIScrollBar::setPos(), 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 inputChar(), processKey(), and setTextMarkers().

+ Here is the caller graph for this function:

◆ serializeAttributes()

void GUIEditBox::serializeAttributes ( io::IAttributes *  out,
io::SAttributeReadWriteOptions *  options = 0 
) const
virtual

Writes attributes of the element.

Reimplemented in GUIEditBoxWithScrollBar.

References m_autoscroll, m_halign, m_max, m_multiline, m_override_color, m_override_color_enabled, m_passwordbox, m_passwordchar, m_valign, m_word_wrap, and m_writable.

Referenced by GUIEditBoxWithScrollBar::serializeAttributes().

+ 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.

Referenced by deserializeAttributes().

+ Here is the caller graph for this function:

◆ setDrawBorder()

void GUIEditBox::setDrawBorder ( bool  border)
virtual

Turns the border on or off.

References m_border.

Referenced by GUIEditBoxWithScrollBar::deserializeAttributes().

+ Here is the caller graph for this function:

◆ 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.

Referenced by deserializeAttributes().

+ Here is the caller graph for this function:

◆ 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 deserializeAttributes(), and 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.

Referenced by deserializeAttributes().

+ Here is the caller graph for this function:

◆ 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().

Referenced by deserializeAttributes().

+ Here is the call graph for this function:
+ Here is the caller 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.

Referenced by deserializeAttributes().

+ Here is the caller graph for this function:

◆ setTextMarkers()

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

set text markers

References m_mark_begin, m_mark_end, and sendGuiEvent().

Referenced by inputChar(), 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 irr::gui::intlGUIEditBox, and 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 deserializeAttributes(), and 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(), irr::gui::intlGUIEditBox::intlGUIEditBox(), and deserializeAttributes().

+ 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(), and irr::gui::intlGUIEditBox::draw().

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

Member Data Documentation

◆ m_autoscroll

◆ m_blink_start_time

◆ 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

◆ 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

◆ m_passwordchar

wchar_t GUIEditBox::m_passwordchar = L'*'
protected

◆ m_scrollbar_width

◆ m_valign

◆ m_vscroll_pos

◆ m_vscrollbar

◆ m_word_wrap

◆ m_writable


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