5#ifndef __C_GUI_EDIT_BOX_H_INCLUDED__
6#define __C_GUI_EDIT_BOX_H_INCLUDED__
8#include "IrrCompileConfig.h"
9#include "IGUIEditBox.h"
11#include "IOSOperator.h"
12#include "utils/leak_check.hpp"
14#include "GlyphLayout.h"
19#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
20#include "SDL_events.h"
28 enum TextBoxType: int;
38 CGUIEditBox(
const wchar_t* text,
bool border, IGUIEnvironment* environment,
39 IGUIElement* parent, s32
id,
const core::rect<s32>& rectangle);
93 virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
96 virtual bool OnEvent(
const SEvent& event);
102 virtual void setText(
const core::stringw& text);
107 virtual void setMax(u32 max);
110 virtual u32
getMax()
const;
116 virtual void setPasswordBox(
bool passwordBox,
wchar_t passwordChar = L
'*');
125 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options)
const;
130 virtual irr::gui::IGUIFont* getOverrideFont()
const {
return NULL; }
131 virtual irr::gui::IGUIFont* getActiveFont()
const {
return NULL; }
132 virtual void setDrawBackground(
bool) { }
134 void fromAndroidEditText(
const std::u32string& text,
int start,
int end,
135 int composing_start,
int composing_end);
136 void openScreenKeyboard();
137 s32 getCursorPosInBox()
const {
return m_cursor_pos; }
138 s32 getTextCount()
const {
return (s32)m_edit_text.size(); }
139 void setTextBoxType(GUIEngine::TextBoxType t) { m_type = t; }
140 virtual void setComposingText(
const std::u32string& ct) { m_composing_text = ct; }
141 virtual void clearComposingText() { m_composing_text.clear(); }
142 virtual const core::position2di& getICPos()
const {
return m_ic_pos; }
154 void updateCursorDistance();
155 bool processKey(
const SEvent& event);
156 bool processMouse(
const SEvent& event);
157 s32 getCursorPos(s32 x, s32 y);
158 void updateGlyphLayouts();
162 bool OverrideColorEnabled;
166 GUIEngine::TextBoxType m_type;
168 video::SColor OverrideColor;
169 gui::IGUIFont *OverrideFont, *LastBreakFont;
170 IOSOperator* Operator;
172 uint64_t m_force_show_cursor_time;
175 s32 m_cursor_distance;
178 bool AutoScroll, PasswordBox;
179 char32_t PasswordChar;
180 EGUI_ALIGNMENT HAlign, VAlign;
182 core::rect<s32> CurrentTextRect, FrameRect;
184 s32 m_composing_start;
189 std::u32string m_edit_text;
191 std::u32string m_composing_text;
192 std::vector<GlyphLayout> m_glyph_layouts;
194 std::vector<wchar_t> m_surrogate_chars;
196 core::position2di m_ic_pos;
197 void correctCursor(s32& cursor_pos,
bool left);
198 void updateSurrogatePairText();
Definition: CGUIEditBox.hpp:32
virtual bool isMultiLineEnabled() const
Checks if multi line editing is enabled.
Definition: CGUIEditBox.hpp:78
virtual void setWordWrap(bool enable)
Enables or disables word wrap for using the edit box as multiline text editor.
Definition: CGUIEditBox.hpp:65
virtual void deserializeAttributes(io::IAttributes *in, io::SAttributeReadWriteOptions *options)
Reads attributes of the element.
Definition: CGUIEditBox.cpp:1464
virtual bool isWordWrapEnabled() const
Checks if word wrap is enabled.
Definition: CGUIEditBox.hpp:69
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical)
Sets text justification.
Definition: CGUIEditBox.cpp:331
virtual bool isPasswordBox() const
Returns true if the edit box is currently a password box.
Definition: CGUIEditBox.cpp:323
virtual void inputChar(char32_t c)
adds a letter to the edit box
Definition: CGUIEditBox.cpp:1272
virtual void setMultiLine(bool enable)
Enables or disables newlines.
Definition: CGUIEditBox.hpp:74
virtual bool isAutoScrollEnabled() const
Checks to see if automatic scrolling is enabled.
Definition: CGUIEditBox.cpp:1061
virtual video::SColor getOverrideColor() const
Gets the override color.
Definition: CGUIEditBox.cpp:281
virtual void setDrawBorder(bool border)
Turns the border on or off.
Definition: CGUIEditBox.cpp:288
virtual void setAutoScroll(bool enable)
Enables or disables automatic scrolling with cursor position.
Definition: CGUIEditBox.cpp:1053
virtual void serializeAttributes(io::IAttributes *out, io::SAttributeReadWriteOptions *options) const
Writes attributes of the element.
Definition: CGUIEditBox.cpp:1443
virtual void draw()
draws the element and its children
Definition: CGUIEditBox.cpp:889
void calculateScrollPos()
calculates the current scroll position
Definition: CGUIEditBox.cpp:1353
virtual ~CGUIEditBox()
destructor
Definition: CGUIEditBox.cpp:236
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar=L' *')
Sets whether the edit box is a password box. Setting this to true will.
Definition: CGUIEditBox.cpp:313
virtual void enableOverrideColor(bool enable)
Sets if the text should use the overide color or the color in the gui skin.
Definition: CGUIEditBox.cpp:295
virtual void setText(const core::stringw &text)
Sets the new caption of this element.
Definition: CGUIEditBox.cpp:1034
virtual void setOverrideFont(IGUIFont *font=0)
Sets another skin independent font.
Definition: CGUIEditBox.cpp:257
virtual void updateAbsolutePosition()
Updates the absolute position, splits text if required.
Definition: CGUIEditBox.cpp:307
void setTextMarkers(s32 begin, s32 end)
send some gui event to parent set text markers
Definition: CGUIEditBox.cpp:1404
virtual void setMax(u32 max)
Sets the maximum amount of characters which may be entered in the box.
Definition: CGUIEditBox.cpp:1091
virtual bool OnEvent(const SEvent &event)
called if an event happened.
Definition: CGUIEditBox.cpp:339
virtual void setOverrideColor(video::SColor color)
Sets another color for the text.
Definition: CGUIEditBox.cpp:274
void sendGuiEvent(EGUI_EVENT_TYPE type)
send some gui event to parent
Definition: CGUIEditBox.cpp:1428
virtual bool isOverrideColorEnabled(void) const
Checks if an override color is enabled.
Definition: CGUIEditBox.cpp:300
void setTextRect(s32 line)
sets the area of the given line
Definition: CGUIEditBox.cpp:1209
virtual u32 getMax() const
Returns maximum amount of characters, previously set by setMax();.
Definition: CGUIEditBox.cpp:1100
virtual core::dimension2du getTextDimension()
Gets the size area of the text in the edit box.
Definition: CGUIEditBox.cpp:1070
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33