supertux
|
Public Member Functions | |
virtual void | update (float dt_sec) override |
float | get_value () const |
void | set_value (float value) |
void | bind_value (float *value) |
Binds a float to this textbox. More... | |
![]() | |
virtual void | draw (DrawingContext &context) override |
virtual bool | on_mouse_button_up (const SDL_MouseButtonEvent &button) override |
virtual bool | on_mouse_button_down (const SDL_MouseButtonEvent &button) override |
virtual bool | on_mouse_motion (const SDL_MouseMotionEvent &motion) override |
virtual bool | on_key_up (const SDL_KeyboardEvent &key) override |
virtual bool | on_key_down (const SDL_KeyboardEvent &key) override |
virtual bool | event (const SDL_Event &ev) override |
void | bind_string (std::string *value) |
Binds a string to the textbox. | |
const std::string & | get_string () const |
Returns the full string held in m_charlist. | |
int | get_text_position (const Vector &pos) const |
Gets at which (absolute) index, in the text, corresponds an on-screen point. | |
bool | fits (const std::string &text) const |
Returns true if the given text would fit inside the box. | |
bool | copy () const |
Copies the current selected text to the clipboard. More... | |
bool | paste () |
Pastes the text from the clipboard. More... | |
std::string | get_selected_text () const |
bool | erase_selected_text () |
bool | put_text (const std::string &text) |
Puts the given text at the currently selected position, replacing the text that was selected, if any. More... | |
![]() | |
void | set_focus (bool focus) |
bool | has_focus () const |
void | set_rect (const Rectf &rect) |
Rectf | get_rect () const |
![]() | |
virtual void | setup () |
virtual void | resize () |
virtual bool | on_mouse_wheel (const SDL_MouseWheelEvent &wheel) |
Public Attributes | |
bool(* | m_validate_float )(ControlTextboxFloat *, float) |
Optional, a function to validate the float. More... | |
![]() | |
bool(* | m_validate_string )(ControlTextbox *, std::string) |
Optional, a function to validate the string. More... | |
![]() | |
std::function< void()> | m_on_change |
Optional; a function that will be called each time the bound value is modified. | |
std::unique_ptr< InterfaceLabel > | m_label |
Optional; the label associated with the control. | |
Protected Member Functions | |
virtual bool | parse_value (bool call_on_change=true) override |
Transfers the string into the binded variable, if any. More... | |
virtual void | revert_value () override |
Reverts the contents of the char vector to the value of the member variable. More... | |
![]() | |
std::string | get_contents () const |
WARNING : These function returns the status of the string as the user types, and therefore are unsuited for callers expecting a validated value. More... | |
std::string | get_first_chars (int amount) const |
Returns first "amount" chars held in m_charlist. | |
std::string | get_contents_visible () const |
Returns the part of the string that is actually displayed. | |
std::string | get_first_chars_visible (int amount) const |
Returns first "amount" chars that are displayed. | |
void | delete_char_before_caret () |
std::string | get_truncated_text (const std::string &text) const |
Returns the largest string fitting in the box. More... | |
void | recenter_offset () |
Changes m_current_offset so that the caret is visible. | |
Additional Inherited Members | |
![]() | |
std::list< char > | m_charlist |
Holds the list of characters that are in the textbox. More... | |
std::string * | m_string |
This is the value that should be looked at by external functions. More... | |
std::string | m_internal_string_backup |
Used so that if m_string is not bound, get_string() won't break/segfault. More... | |
float | m_cursor_timer |
int | m_caret_pos |
int | m_secondary_caret_pos |
Used for selections. | |
bool | m_shift_pressed |
bool | m_ctrl_pressed |
bool | m_mouse_pressed |
int | m_current_offset |
If the string is too long to be contained in the box, use this offset to select which characters will be displayed on the screen. | |
![]() | |
bool | m_has_focus |
Whether or not the user has this InterfaceControl as focused. | |
Rectf | m_rect |
The rectangle where the InterfaceControl should be rendered. | |
InterfaceControl * | m_parent |
A pointer to the parent container, or null if not in any container. More... | |
|
inline |
Binds a float to this textbox.
Set m_validate_float(float) if you want custom validation. (You may also use m_validate_string(string), though it's not recommended)
value | A pointer to the value to be bound. MUST NOT BE NULL (FIXME) |
|
overrideprotectedvirtual |
Transfers the string into the binded variable, if any.
Can be overridden by children if they use different value members (like float, int, etc). parse_value MUST make the validation, and MUST use get_contents() to fetch the string to parse, as get_string() will return the precedent valid string.
call_on_change | Whether calling this function should also call m_on_change(). Children classes that implement another m_value member (float, int, etc.) should call ControlTextbox::parse_value(false) to parse the string without calling m_on_change immediately; the child class should call m_on_change() by itself when and only when they have parsed their value. |
Reimplemented from ControlTextbox.
|
overrideprotectedvirtual |
Reverts the contents of the char vector to the value of the member variable.
Can be overridden by children, as parse_value() does.
Reimplemented from ControlTextbox.
bool(* ControlTextboxFloat::m_validate_float) (ControlTextboxFloat *, float) |
Optional, a function to validate the float.
If nullptr, then all values are assumed to be valid.
ControlTextboxFloat* | A pointer to the original control. |
float | The float that is about to be applied to the textbox. |