17 #ifndef HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_HPP 18 #define HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_HPP 22 #include "control/input_manager.hpp" 23 #include "interface/control.hpp" 32 virtual bool on_mouse_button_up(
const SDL_MouseButtonEvent& button)
override;
33 virtual bool on_mouse_button_down(
const SDL_MouseButtonEvent& button)
override;
34 virtual bool on_mouse_motion(
const SDL_MouseMotionEvent& motion)
override;
35 virtual bool on_key_up(
const SDL_KeyboardEvent& key)
override;
36 virtual bool on_key_down(
const SDL_KeyboardEvent& key)
override;
37 virtual bool event(
const SDL_Event& ev)
override;
39 virtual void update(
float dt_sec)
override;
51 bool fits(
const std::string& text)
const;
81 bool put_text(
const std::string& text);
102 virtual bool parse_value(
bool call_on_change =
true);
162 float m_cursor_timer;
165 bool m_shift_pressed, m_ctrl_pressed;
166 bool m_mouse_pressed;
176 void delete_char_before_caret();
int m_secondary_caret_pos
Used for selections.
Definition: control_textbox.hpp:164
void bind_string(std::string *value)
Binds a string to the textbox.
Definition: control_textbox.hpp:42
bool put_text(const std::string &text)
Puts the given text at the currently selected position, replacing the text that was selected...
Definition: control_textbox.cpp:511
std::string get_truncated_text(const std::string &text) const
Returns the largest string fitting in the box.
Definition: control_textbox.cpp:423
std::string get_first_chars_visible(int amount) const
Returns first "amount" chars that are displayed.
Definition: control_textbox.cpp:404
Definition: control.hpp:28
bool erase_selected_text()
Definition: control_textbox.cpp:532
std::string m_internal_string_backup
Used so that if m_string is not bound, get_string() won't break/segfault.
Definition: control_textbox.hpp:160
void recenter_offset()
Changes m_current_offset so that the caret is visible.
Definition: control_textbox.cpp:441
int m_current_offset
If the string is too long to be contained in the box, use this offset to select which characters will...
Definition: control_textbox.hpp:173
virtual bool parse_value(bool call_on_change=true)
Transfers the string into the binded variable, if any.
Definition: control_textbox.cpp:316
std::string get_contents_visible() const
Returns the part of the string that is actually displayed.
Definition: control_textbox.cpp:389
bool copy() const
Copies the current selected text to the clipboard.
Definition: control_textbox.cpp:457
const std::string & get_string() const
Returns the full string held in m_charlist.
Definition: control_textbox.cpp:358
std::string get_selected_text() const
Definition: control_textbox.cpp:488
Definition: control_textbox.hpp:26
std::string get_first_chars(int amount) const
Returns first "amount" chars held in m_charlist.
Definition: control_textbox.cpp:376
bool paste()
Pastes the text from the clipboard.
Definition: control_textbox.cpp:472
bool(* m_validate_string)(ControlTextbox *, std::string)
Optional, a function to validate the string.
Definition: control_textbox.hpp:140
bool fits(const std::string &text) const
Returns true if the given text would fit inside the box.
Definition: control_textbox.cpp:435
std::string get_contents() const
WARNING : These function returns the status of the string as the user types, and therefore are unsuit...
Definition: control_textbox.cpp:364
std::string * m_string
This is the value that should be looked at by external functions.
Definition: control_textbox.hpp:153
virtual void revert_value()
Reverts the contents of the char vector to the value of the member variable.
Definition: control_textbox.cpp:342
int get_text_position(const Vector &pos) const
Gets at which (absolute) index, in the text, corresponds an on-screen point.
Definition: control_textbox.cpp:410
std::list< char > m_charlist
Holds the list of characters that are in the textbox.
Definition: control_textbox.hpp:146
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42