15 #define GETTEXT_DOMAIN "wesnoth-lib"
26 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
27 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
37 , selection_length_(0)
38 , text_changed_callback_()
42 connect_signal<event::MIDDLE_BUTTON_CLICK>(std::bind(
47 connect_signal<event::SDL_KEY_DOWN>(std::bind(
50 connect_signal<event::RECEIVE_KEYBOARD_FOCUS>(std::bind(
52 connect_signal<event::LOSE_KEYBOARD_FOCUS>(
75 if(maximum_length == 0) {
216 set_cursor(offset, (modifier & KMOD_SHIFT) != 0);
228 set_cursor(offset, (modifier & KMOD_SHIFT) != 0);
237 if(modifier & KMOD_CTRL) {
249 if(modifier & KMOD_CTRL) {
289 if(unicode.size() > 1 || unicode[0] != 0) {
321 const unsigned copypaste_modifier = KMOD_CTRL;
351 if(!(modifier & KMOD_CTRL)) {
357 modifier =
static_cast<SDLMod>(modifier & ~KMOD_CTRL);
365 if(!(modifier & KMOD_CTRL)) {
371 modifier =
static_cast<SDLMod>(modifier & ~KMOD_CTRL);
383 if(modifier & KMOD_CTRL) {
395 if(!(modifier & copypaste_modifier)) {
407 if(!(modifier & copypaste_modifier)) {
418 if(!(modifier & copypaste_modifier)) {
Define the common log macros for the gui toolkit.
void set_selection_length(const int selection_length)
virtual void delete_char(const bool before_cursor)=0
Deletes the character.
virtual void delete_selection()=0
Deletes the current selection.
font::ttext text_
The text entered in the widget.
size_t index(const utf8::string &str, const size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
virtual void handle_key_left_arrow(SDLMod modifier, bool &handled)
Left arrow key pressed.
int selection_length_
Length of the selected text.
virtual void handle_key_end(SDLMod modifier, bool &handled)
End key pressed.
std::string copy_from_clipboard(const bool)
Copies text from the clipboard.
const std::string & text() const
virtual void set_active(const bool active) override
See tcontrol::set_active.
ttext & set_maximum_length(const size_t maximum_length)
unsigned insert_text(const unsigned offset, const std::string &text)
Inserts UTF-8 text.
virtual void paste_selection(const bool mouse)
Pastes the current selection.
tstate
Note the order of the states must be the same as defined in settings.hpp.
void signal_handler_lose_keyboard_focus(const event::tevent event)
void signal_handler_sdl_key_down(const event::tevent event, bool &handled, const SDLKey key, SDLMod modifier, const utf8::string &unicode)
tformula< t_string > text_
The text to draw.
virtual void handle_key_right_arrow(SDLMod modifier, bool &handled)
Right arrow key pressed.
virtual void set_value(const std::string &text)
The set_value is virtual for the tpassword_box class.
std::function< void(ttext_ *textbox, const std::string text)> text_changed_callback_
Text changed callback.
A class inherited from ttext_box that displays its input as stars.
virtual void handle_key_backspace(SDLMod modifier, bool &handled)
Backspace key pressed.
void goto_end_of_data(const bool select=false)
Moves the cursor to the end of all text.
virtual void insert_char(const utf8::string &unicode)
Inserts a character at the cursor.
tstate state_
Current state of the widget.
size_t selection_start_
Start of the selected text.
void goto_start_of_data(const bool select=false)
Moves the cursor to the beginning of the data.
bool fire(const tevent event, twidget &target)
Fires an event which has no extra parameters.
virtual void handle_key_clear_line(SDLMod modifier, bool &handled)=0
Clears the current line.
size_t get_length() const
Gets the length of the text in characters.
Send by a widget to notify others its contents or state are modified.
virtual void handle_key_up_arrow(SDLMod modifier, bool &handled)=0
Every key can have several behaviors.
tevent
The event send to the dispatcher.
virtual void handle_key_delete(SDLMod modifier, bool &handled)
Delete key pressed.
virtual unsigned get_state() const override
See tcontrol::get_state.
virtual void handle_key_down_arrow(SDLMod modifier, bool &handled)=0
Down arrow key pressed.
virtual void update_canvas()
Updates the canvas(ses).
virtual void goto_start_of_line(const bool select=false)=0
Moves the cursor to the beginning of the line.
virtual void handle_key_default(bool &handled, SDLKey key, SDLMod modifier, const utf8::string &unicode)
Default key handler if none of the above functions is called.
void signal_handler_receive_keyboard_focus(const event::tevent event)
virtual void handle_key_page_down(SDLMod, bool &)
Page down key.
virtual void handle_key_home(SDLMod modifier, bool &handled)
Home key pressed.
virtual void handle_key_page_up(SDLMod, bool &)
Page up key.
Base class for all visible items.
void set_selection_start(const size_t selection_start)
void signal_handler_middle_button_click(const event::tevent event, bool &handled)
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
void set_maximum_length(const size_t maximum_length)
virtual bool get_active() const override
See tcontrol::get_active.
const std::string & text() const
virtual void goto_end_of_line(const bool select=false)=0
Moves the cursor to the end of the line.
void set_state(const tstate state)
virtual void copy_selection(const bool mouse)
Copies the current selection.
GLsizei const GLcharARB ** string
void set_cursor(const size_t offset, const bool select)
Moves the cursor at the wanted position.