Abstract base class for text items. More...
#include <text_box_base.hpp>
Public Types | |
enum | state_t { ENABLED , DISABLED , FOCUSED , HOVERED } |
Note the order of the states must be the same as defined in settings.hpp. More... | |
![]() | |
enum class | visibility { visible , hidden , invisible } |
Visibility settings done by the user. More... | |
enum class | redraw_action { full , partly , none } |
Visibility set by the engine. More... | |
enum class | debug_border { none , outline , fill } |
![]() | |
enum | event_queue_type { pre = 1 , child = 2 , post = 4 } |
enum | queue_position { front_pre_child , back_pre_child , front_child , back_child , front_post_child , back_post_child } |
The position where to add a new callback in the signal handler. More... | |
enum class | mouse_behavior { all , hit , none } |
The behavior of the mouse events. More... | |
Public Member Functions | |
text_box_base (const implementation::builder_styled_widget &builder, const std::string &control_type) | |
~text_box_base () | |
virtual void | set_active (const bool active) override |
See styled_widget::set_active. More... | |
virtual bool | get_active () const override |
See styled_widget::get_active. More... | |
virtual unsigned | get_state () const override |
See styled_widget::get_state. More... | |
void | set_maximum_length (const std::size_t maximum_length) |
std::size_t | get_length () const |
virtual void | set_value (const std::string &text) |
The set_value is virtual for the password_box class. More... | |
std::string | get_value () const |
const std::string & | text () const |
void | set_text_changed_callback (std::function< void(text_box_base *textbox, const std::string text)> cb) |
Set the text_changed callback. More... | |
void | set_selection (std::size_t start, int length) |
Sets or clears the text selection. More... | |
bool | is_composing () const |
void | interrupt_composition () |
![]() | |
styled_widget (const implementation::builder_styled_widget &builder, const std::string &control_type) | |
Constructor. More... | |
virtual void | set_members (const widget_item &data) |
Sets the members of the styled_widget. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
point | get_config_minimum_size () const |
Gets the minimum size as defined in the config. More... | |
point | get_config_default_size () const |
Gets the default size as defined in the config. More... | |
point | get_config_maximum_size () const |
Gets the best size as defined in the config. More... | |
virtual unsigned | get_characters_per_line () const |
Returns the number of characters per line. More... | |
virtual bool | get_link_aware () const |
Returns whether the label should be link_aware, in in rendering and in searching for links with get_link. More... | |
virtual color_t | get_link_color () const |
Returns the color string to be used with links. More... | |
virtual void | layout_initialize (const bool full_initialization) override |
See widget::layout_initialize. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See widget::request_reduce_height. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) override |
See widget::find_at. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const override |
See widget::find_at. More... | |
widget * | find (const std::string &id, const bool must_be_active) override |
See widget::find. More... | |
const widget * | find (const std::string &id, const bool must_be_active) const override |
See widget::find. More... | |
bool | get_use_tooltip_on_label_overflow () const |
void | set_use_tooltip_on_label_overflow (const bool use_tooltip=true) |
const t_string & | get_label () const |
virtual void | set_label (const t_string &label) |
virtual void | set_use_markup (bool use_markup) |
bool | get_use_markup () const |
const t_string & | tooltip () const |
void | set_tooltip (const t_string &tooltip) |
const t_string & | help_message () const |
void | set_help_message (const t_string &help_message) |
std::vector< canvas > & | get_canvases () |
canvas & | get_canvas (const unsigned index) |
virtual void | set_text_alignment (const PangoAlignment text_alignment) |
PangoAlignment | get_text_alignment () const |
void | set_text_ellipse_mode (const PangoEllipsizeMode ellipse_mode) |
PangoEllipsizeMode | get_text_ellipse_mode () const |
Get the text's ellipsize mode. More... | |
virtual const std::string & | get_control_type () const =0 |
Returns the type of this styled_widget. More... | |
![]() | |
widget (const widget &)=delete | |
widget & | operator= (const widget &)=delete |
widget () | |
widget (const builder_widget &builder) | |
Constructor. More... | |
virtual | ~widget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
window * | get_window () |
Get the parent window. More... | |
const window * | get_window () const |
The constant version of get_window. More... | |
grid * | get_parent_grid () |
Get the parent grid. More... | |
void | set_parent (widget *parent) |
widget * | parent () |
virtual void | demand_reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a widget. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
point | get_best_size () const |
Gets the best size for the widget. More... | |
virtual bool | can_mouse_focus () const |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual bool | can_wrap () const |
Can the widget wrap. More... | |
virtual void | set_origin (const point &origin) |
Sets the origin of the widget. More... | |
virtual void | set_size (const point &size) |
Sets the size of the widget. More... | |
virtual void | move (const int x_offset, const int y_offset) |
Moves a widget. More... | |
virtual void | set_horizontal_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | set_vertical_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | layout_children () |
Allows a widget to update its children. More... | |
point | get_origin () const |
Returns the screen origin of the widget. More... | |
point | get_size () const |
Returns the size of the widget. More... | |
rect | get_rectangle () const |
Gets the bounding rectangle of the widget on the screen. More... | |
int | get_x () const |
int | get_y () const |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_linked_group (const std::string &linked_group) |
SDL_Rect | calculate_blitting_rectangle () const |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle () const |
Calculates the clipping rectangle of the widget. More... | |
bool | draw_background () |
Draws the background of a widget. More... | |
void | draw_children () |
Draws the children of a widget. More... | |
bool | draw_foreground () |
Draws the foreground of the widget. More... | |
SDL_Rect | get_dirty_rectangle () const |
Gets the dirty rectangle of the widget. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) |
Sets the visible rectangle for a widget. More... | |
void | queue_redraw () |
Indicates that this widget should be redrawn. More... | |
void | queue_redraw (const rect ®ion) |
Indicate that specific region of the screen should be redrawn. More... | |
void | set_visible (const visibility visible) |
visibility | get_visible () const |
redraw_action | get_drawing_action () const |
void | set_debug_border_mode (const debug_border debug_border_mode) |
void | set_debug_border_color (const color_t debug_border_color) |
virtual bool | has_widget (const widget &widget) const |
Does the widget contain the widget. More... | |
![]() | |
event_executor () | |
virtual | ~event_executor () |
void | set_wants_mouse_hover (const bool hover=true) |
bool | wants_mouse_hover () const |
void | set_wants_mouse_left_double_click (const bool click=true) |
bool | wants_mouse_left_double_click () const |
void | set_wants_mouse_middle_double_click (const bool click=true) |
bool | wants_mouse_middle_double_click () const |
event_executor & | set_wants_mouse_right_double_click (const bool click=true) |
bool | wants_mouse_right_double_click () const |
![]() | |
dispatcher () | |
virtual | ~dispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
void | disconnect () |
Disconnects the dispatcher from the event handler. More... | |
bool | is_connected () const |
Return whether the dispatcher is currently connected. More... | |
bool | has_event (const ui_event event, const event_queue_type event_type) |
bool | fire (const ui_event event, widget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const std::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &pos, const point &distance) |
Fires an event which takes touch-motion parameters. More... | |
bool | fire (const ui_event event, widget &target, const point ¢er, float dTheta, float dDist, uint8_t numFingers) |
Fires an event which takes touch-gesture parameters. More... | |
bool | fire (const ui_event event, widget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const ui_event event, widget &target, const message &msg) |
Fires an event which takes message parameters. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Event &sdlevent) |
Fires an event that's a raw SDL event. More... | |
bool | fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len) |
Fires an event which takes text input parameters. More... | |
template<ui_event E, typename F > | |
void | connect_signal (const F &func, const queue_position position=back_child) |
Adds a callback to the appropriate queue based on event type. More... | |
template<ui_event E, typename F > | |
void | disconnect_signal (const F &func, const queue_position position=back_child) |
Removes a callback from the appropriate queue based on event type. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const mouse_behavior mouse_behavior) |
mouse_behavior | get_mouse_behavior () const |
void | set_want_keyboard_input (const bool want_keyboard_input) |
bool | get_want_keyboard_input () const |
void | register_hotkey (const hotkey::HOTKEY_COMMAND id, const hotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
![]() | |
enable_lua_ptr (widget *tp) | |
Protected Member Functions | |
size_t | get_composition_length () const |
Get length of composition text by IME. More... | |
virtual void | goto_end_of_line (const bool select=false)=0 |
Moves the cursor to the end of the line. More... | |
void | goto_end_of_data (const bool select=false) |
Moves the cursor to the end of all text. More... | |
virtual void | goto_start_of_line (const bool select=false)=0 |
Moves the cursor to the beginning of the line. More... | |
void | goto_start_of_data (const bool select=false) |
Moves the cursor to the beginning of the data. More... | |
void | select_all () |
Selects all text. More... | |
void | set_cursor (const std::size_t offset, const bool select) |
Moves the cursor at the wanted position. More... | |
virtual void | insert_char (const std::string &unicode) |
Inserts a character at the cursor. More... | |
virtual void | delete_char (const bool before_cursor)=0 |
Deletes the character. More... | |
virtual void | delete_selection ()=0 |
Deletes the current selection. More... | |
virtual void | copy_selection (const bool mouse) |
Copies the current selection. More... | |
virtual void | paste_selection (const bool mouse) |
Pastes the current selection. More... | |
point | get_cursor_position (const unsigned column, const unsigned line=0) const |
point | get_column_line (const point &position) const |
void | set_font_size (const unsigned font_size) |
void | set_font_style (const font::pango_text::FONT_STYLE font_style) |
void | set_maximum_width (const int width) |
void | set_maximum_height (const int height, const bool multiline) |
void | set_ellipse_mode (const PangoEllipsizeMode ellipse_mode) |
std::size_t | get_selection_start () const |
void | set_selection_start (const std::size_t selection_start) |
std::size_t | get_selection_length () const |
void | set_selection_length (const int selection_length) |
std::size_t | get_composition_start () const |
virtual void | handle_commit (bool &handled, const std::string &unicode) |
virtual void | handle_editing (bool &handled, const std::string &unicode, int32_t start, int32_t length) |
SDL_TEXTEDITING handler. More... | |
![]() | |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
resolution_definition_ptr | get_config () |
resolution_definition_const_ptr | get_config () const |
template<typename T > | |
std::shared_ptr< const typename T::resolution > | cast_config_to () const |
Casts the current resolution definition config to the respective type of a derived widget. More... | |
void | set_config (resolution_definition_ptr config) |
virtual void | update_canvas () |
Updates the canvas(ses). More... | |
unsigned int | get_text_font_size () const |
Resolves and returns the text_font_size. More... | |
int | get_text_maximum_width () const |
Returns the maximum width available for the text. More... | |
int | get_text_maximum_height () const |
Returns the maximum height available for the text. More... | |
virtual bool | impl_draw_background () override |
See widget::impl_draw_background. More... | |
virtual bool | impl_draw_foreground () override |
See widget::impl_draw_foreground. More... | |
std::string | get_label_token (const point &position, const char *delimiters=" \n\r\t") const |
Exposes font::pango_text::get_token, for the text label of this styled_widget. More... | |
std::string | get_label_link (const point &position) const |
![]() | |
void | set_layout_size (const point &size) |
const point & | layout_size () const |
void | clear_layout_size () |
Throws away layout_size_. More... | |
Private Member Functions | |
void | set_state (const state_t state) |
virtual void | toggle_cursor_timer (bool enable) |
virtual void | cursor_timer_callback () |
Implements blinking cursor functionality. More... | |
virtual void | reset_cursor_state () |
void | update_mouse_cursor (bool enable) |
virtual void | handle_key_up_arrow (SDL_Keymod modifier, bool &handled)=0 |
Every key can have several behaviors. More... | |
virtual void | handle_key_down_arrow (SDL_Keymod modifier, bool &handled)=0 |
Down arrow key pressed. More... | |
virtual void | handle_key_clear_line (SDL_Keymod modifier, bool &handled)=0 |
Clears the current line. More... | |
virtual void | handle_key_left_arrow (SDL_Keymod modifier, bool &handled) |
Left arrow key pressed. More... | |
virtual void | handle_key_right_arrow (SDL_Keymod modifier, bool &handled) |
Right arrow key pressed. More... | |
virtual void | handle_key_home (SDL_Keymod modifier, bool &handled) |
Home key pressed. More... | |
virtual void | handle_key_end (SDL_Keymod modifier, bool &handled) |
End key pressed. More... | |
virtual void | handle_key_backspace (SDL_Keymod modifier, bool &handled) |
Backspace key pressed. More... | |
virtual void | handle_key_delete (SDL_Keymod modifier, bool &handled) |
Delete key pressed. More... | |
virtual void | handle_key_page_up (SDL_Keymod, bool &) |
Page up key. More... | |
virtual void | handle_key_page_down (SDL_Keymod, bool &) |
Page down key. More... | |
virtual void | handle_key_tab (SDL_Keymod, bool &) |
Tab key. More... | |
void | signal_handler_middle_button_click (const event::ui_event event, bool &handled) |
void | signal_handler_sdl_key_down (const event::ui_event event, bool &handled, const SDL_Keycode key, SDL_Keymod modifier) |
void | signal_handler_sdl_text_input (const event::ui_event event, bool &handled, const std::string &unicode, int32_t start, int32_t len) |
void | signal_handler_receive_keyboard_focus (const event::ui_event event) |
void | signal_handler_lose_keyboard_focus (const event::ui_event event) |
void | signal_handler_mouse_enter (const event::ui_event event, bool &handled) |
void | signal_handler_mouse_leave (const event::ui_event event, bool &handled) |
Private Attributes | |
state_t | state_ |
Current state of the widget. More... | |
font::pango_text | text_ |
The text entered in the widget. More... | |
std::string | text_cached_ |
Cached version of the text without any pending IME modifications. More... | |
std::size_t | selection_start_ |
Start of the selected text. More... | |
int | selection_length_ |
Length of the selected text. More... | |
bool | ime_composing_ |
int | ime_start_point_ |
std::size_t | cursor_timer_ |
unsigned short | cursor_alpha_ |
unsigned short | cursor_blink_rate_ms_ |
std::function< void(text_box_base *textbox, const std::string text)> | text_changed_callback_ |
Text changed callback. More... | |
Abstract base class for text items.
All other text classes should inherit from this base class.
The NOTIFY_MODIFIED event is send when the text is modified.
Common signal handlers:
Definition at line 47 of file text_box_base.hpp.
Note the order of the states must be the same as defined in settings.hpp.
Enumerator | |
---|---|
ENABLED | |
DISABLED | |
FOCUSED | |
HOVERED |
Definition at line 276 of file text_box_base.hpp.
gui2::text_box_base::text_box_base | ( | const implementation::builder_styled_widget & | builder, |
const std::string & | control_type | ||
) |
Definition at line 37 of file text_box_base.cpp.
References gui2::implementation::builder_styled_widget::definition, gui2::get_control(), handle_commit(), handle_editing(), font::pango_text::set_family_class(), signal_handler_lose_keyboard_focus(), signal_handler_middle_button_click(), signal_handler_mouse_enter(), signal_handler_mouse_leave(), signal_handler_receive_keyboard_focus(), signal_handler_sdl_key_down(), text_, and toggle_cursor_timer().
gui2::text_box_base::~text_box_base | ( | ) |
Definition at line 78 of file text_box_base.cpp.
References toggle_cursor_timer(), and update_mouse_cursor().
|
protectedvirtual |
Copies the current selection.
Definition at line 201 of file text_box_base.cpp.
References desktop::clipboard::copy_to_clipboard(), utf8::index(), selection_length_, selection_start_, editor::start(), font::pango_text::text(), and text_.
Referenced by set_cursor(), and signal_handler_sdl_key_down().
|
privatevirtual |
Implements blinking cursor functionality.
Definition at line 308 of file text_box_base.cpp.
References cursor_alpha_, DISABLED, ENABLED, gui2::styled_widget::get_canvases(), gui2::widget::get_window(), gui2::open_window_stack, gui2::widget::queue_redraw(), and state_.
Referenced by toggle_cursor_timer().
|
protectedpure virtual |
Deletes the character.
before_cursor | If true it deletes the character before the cursor (backspace) else the character after the cursor (delete). |
Implemented in gui2::text_box.
Referenced by handle_key_backspace(), and handle_key_delete().
|
protectedpure virtual |
Deletes the current selection.
Implemented in gui2::text_box, and gui2::password_box.
Referenced by handle_editing(), handle_key_backspace(), handle_key_delete(), insert_char(), paste_selection(), and signal_handler_sdl_key_down().
|
overridevirtual |
See styled_widget::get_active.
Implements gui2::styled_widget.
Definition at line 91 of file text_box_base.cpp.
References DISABLED, and state_.
Referenced by set_active().
Definition at line 217 of file text_box_base.hpp.
References font::pango_text::get_column_line(), and text_.
Referenced by gui2::text_box::handle_mouse_selection().
|
protected |
Get length of composition text by IME.
Definition at line 178 of file text_box_base.cpp.
References is_composing(), utf8::size(), font::pango_text::text(), text_, and text_cached_.
Referenced by handle_commit(), handle_key_backspace(), handle_key_delete(), and gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 261 of file text_box_base.hpp.
References ime_start_point_.
Referenced by gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 211 of file text_box_base.hpp.
References font::pango_text::get_cursor_position(), draw::line(), and text_.
Referenced by handle_editing(), and gui2::text_box::update_canvas().
|
inline |
Definition at line 68 of file text_box_base.hpp.
References font::pango_text::get_length(), and text_.
Referenced by gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 255 of file text_box_base.hpp.
References selection_length_.
Referenced by gui2::password_box::delete_selection(), gui2::text_box::delete_selection(), gui2::password_box::insert_char(), and gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 249 of file text_box_base.hpp.
References selection_start_.
Referenced by gui2::text_box::delete_char(), gui2::password_box::delete_selection(), gui2::text_box::delete_selection(), gui2::password_box::insert_char(), and gui2::text_box::update_canvas().
|
overridevirtual |
|
inline |
Definition at line 82 of file text_box_base.hpp.
References font::pango_text::text(), and text_.
Referenced by gui2::chatbox::chat_input_keypress_callback(), gui2::text_box::delete_selection(), gui2::dialogs::lobby_player_info::do_kick_ban(), gui2::dialogs::lobby_player_info::do_stopgame(), gui2::dialogs::mp_lobby::game_filter_init(), gui2::dialogs::addon_manager::get_name_filter_visibility(), gui2::text_box::history_down(), gui2::text_box::history_up(), gui2::dialogs::preferences_dialog::hotkey_filter_callback(), gui2::dialogs::mp_match_history::new_search(), gui2::dialogs::mp_connect::on_server_add(), gui2::dialogs::edit_text::on_text_change(), gui2::dialogs::mp_method_selection::post_show(), gui2::dialogs::mp_report::post_show(), gui2::dialogs::file_dialog::process_textbox_submit(), gui2::dialogs::screenshot_notification::save_screenshot(), gui2::text_box::save_to_history(), gui2::dialogs::mp_connect::select_first_match(), gui2::dialogs::chat_log::model::stream_log(), and gui2::text_box::update_canvas().
|
inlineprotected |
Moves the cursor to the end of all text.
For a single line text this is the same as goto_end_of_line().
select | Select the text from the original cursor position till the end of the data? |
Definition at line 141 of file text_box_base.hpp.
References font::pango_text::get_length(), set_cursor(), and text_.
Referenced by gui2::text_box::goto_end_of_line(), handle_key_end(), and select_all().
|
protectedpure virtual |
Moves the cursor to the end of the line.
select | Select the text from the original cursor position till the end of the line? |
Implemented in gui2::text_box.
Referenced by handle_key_end().
|
inlineprotected |
Moves the cursor to the beginning of the data.
select | Select the text from the original cursor position till the beginning of the data? |
Definition at line 160 of file text_box_base.hpp.
References set_cursor().
Referenced by gui2::text_box::goto_start_of_line(), and handle_key_home().
|
protectedpure virtual |
Moves the cursor to the beginning of the line.
select | Select the text from the original cursor position till the beginning of the line? |
Implemented in gui2::text_box.
Referenced by handle_key_home().
|
protectedvirtual |
Definition at line 438 of file text_box_base.cpp.
References DBG_GUI_E, gui2::event::dispatcher::fire(), get_composition_length(), ime_composing_, ime_start_point_, insert_char(), is_composing(), LOG_SCOPE_HEADER, gui2::event::NOTIFY_MODIFIED, set_selection(), text(), and text_changed_callback_.
Referenced by text_box_base().
|
protectedvirtual |
SDL_TEXTEDITING handler.
See example at https://wiki.libsdl.org/Tutorials/TextInput
Definition at line 460 of file text_box_base.cpp.
References delete_selection(), get_cursor_position(), font::pango_text::get_length(), gui2::widget::get_rectangle(), ime_composing_, ime_start_point_, utf8::insert(), font::pango_text::insert_text(), is_composing(), gui2::widget::queue_redraw(), selection_start_, set_cursor(), font::pango_text::set_text(), utf8::size(), editor::start(), font::pango_text::text(), text_, text_cached_, and gui2::styled_widget::update_canvas().
Referenced by text_box_base().
|
privatevirtual |
Backspace key pressed.
Unmodified Deletes the character before the cursor, ignored if at the beginning of the data. Control Ignored. Shift Ignored. Alt Ignored.
Definition at line 402 of file text_box_base.cpp.
References DBG_GUI_E, delete_char(), delete_selection(), gui2::event::dispatcher::fire(), get_composition_length(), ime_composing_, is_composing(), LOG_SCOPE_HEADER, gui2::event::NOTIFY_MODIFIED, selection_length_, and selection_start_.
Referenced by signal_handler_sdl_key_down().
|
privatepure virtual |
Clears the current line.
Unmodified Clears the current line. Control Ignored. Shift Ignored. Alt Ignored.
Implemented in gui2::text_box.
Referenced by signal_handler_sdl_key_down().
|
privatevirtual |
Delete key pressed.
Unmodified If there is a selection that's deleted. Else if not at the end of the data the character after the cursor is deleted. Else the key is ignored. ignored if at the beginning of the data. Control Ignored. Shift Ignored. Alt Ignored.
Definition at line 420 of file text_box_base.cpp.
References DBG_GUI_E, delete_char(), delete_selection(), gui2::event::dispatcher::fire(), get_composition_length(), font::pango_text::get_length(), ime_composing_, is_composing(), LOG_SCOPE_HEADER, gui2::event::NOTIFY_MODIFIED, selection_length_, selection_start_, and text_.
Referenced by signal_handler_sdl_key_down().
|
privatepure virtual |
Down arrow key pressed.
The behavior is implementation defined.
Implemented in gui2::text_box.
Referenced by signal_handler_sdl_key_down().
|
privatevirtual |
End key pressed.
Unmodified Moves the cursor a to the end of the line. Control Like unmodified but to the end of the data. Shift Selects the text while moving. Alt Ignored.
Definition at line 390 of file text_box_base.cpp.
References DBG_GUI_E, goto_end_of_data(), goto_end_of_line(), and LOG_SCOPE_HEADER.
Referenced by signal_handler_sdl_key_down().
|
privatevirtual |
Home key pressed.
Unmodified Moves the cursor a to the beginning of the line. Control Like unmodified but to the beginning of the data. Shift Selects the text while moving. Alt Ignored.
Definition at line 378 of file text_box_base.cpp.
References DBG_GUI_E, goto_start_of_data(), goto_start_of_line(), and LOG_SCOPE_HEADER.
Referenced by signal_handler_sdl_key_down().
|
privatevirtual |
Left arrow key pressed.
Unmodified Moves the cursor a character to the left. Control Like unmodified but a word instead of a letter at the time. Shift Selects the text while moving. Alt Ignored.
Definition at line 354 of file text_box_base.cpp.
References DBG_GUI_E, LOG_SCOPE_HEADER, selection_length_, selection_start_, and set_cursor().
Referenced by signal_handler_sdl_key_down().
|
inlineprivatevirtual |
Page down key.
Unmodified Unhandled. Control Ignored. Shift Ignored. Alt Ignored.
Definition at line 470 of file text_box_base.hpp.
Referenced by signal_handler_sdl_key_down().
|
inlineprivatevirtual |
Page up key.
Unmodified Unhandled. Control Ignored. Shift Ignored. Alt Ignored.
Definition at line 458 of file text_box_base.hpp.
Referenced by signal_handler_sdl_key_down().
|
privatevirtual |
Right arrow key pressed.
Unmodified Moves the cursor a character to the right. Control Like unmodified but a word instead of a letter at the time. Shift Selects the text while moving. Alt Ignored.
Definition at line 366 of file text_box_base.cpp.
References DBG_GUI_E, font::pango_text::get_length(), LOG_SCOPE_HEADER, selection_length_, selection_start_, set_cursor(), and text_.
Referenced by signal_handler_sdl_key_down().
|
inlineprivatevirtual |
Tab key.
Unmodified Implementation defined. Control Implementation defined. Shift Implementation defined. Alt Implementation defined.
Reimplemented in gui2::text_box.
Definition at line 482 of file text_box_base.hpp.
|
privatepure virtual |
Every key can have several behaviors.
Unmodified No modifier is pressed. Control The control key is pressed. Shift The shift key is pressed. Alt The alt key is pressed.
If modifiers together do something else as the sum of the modifiers it's listed separately eg.
Control Moves 10 steps at the time. Shift Selects the text. Control + Shift Inserts 42 in the text.
There are some predefined actions for results. Unhandled The key/modifier is ignored and also reported unhandled. Ignored The key/modifier is ignored and it's expected the inherited classes do the same. Implementation defined The key/modifier is ignored and it's expected the inherited classes will define some meaning to it. Up arrow key pressed.
The behavior is implementation defined.
Implemented in gui2::text_box.
Referenced by signal_handler_sdl_key_down().
|
protectedvirtual |
Inserts a character at the cursor.
This function is preferred over set_text since it's optimized for updating the internal bookkeeping.
unicode | The unicode value of the character to insert. |
Reimplemented in gui2::password_box.
Definition at line 165 of file text_box_base.cpp.
References delete_selection(), font::pango_text::insert_text(), gui2::widget::queue_redraw(), selection_start_, set_cursor(), utf8::size(), text_, and gui2::styled_widget::update_canvas().
Referenced by handle_commit(), and gui2::password_box::insert_char().
void gui2::text_box_base::interrupt_composition | ( | ) |
Definition at line 193 of file text_box_base.cpp.
References ime_composing_.
Referenced by signal_handler_sdl_key_down().
|
inline |
Definition at line 267 of file text_box_base.hpp.
References ime_composing_.
Referenced by gui2::chatbox::chat_input_keypress_callback(), get_composition_length(), handle_commit(), handle_editing(), handle_key_backspace(), handle_key_delete(), and signal_handler_sdl_key_down().
|
protectedvirtual |
Pastes the current selection.
Reimplemented in gui2::password_box.
Definition at line 221 of file text_box_base.cpp.
References desktop::clipboard::copy_from_clipboard(), delete_selection(), gui2::event::dispatcher::fire(), font::pango_text::insert_text(), gui2::event::NOTIFY_MODIFIED, gui2::widget::queue_redraw(), selection_start_, text(), text_, and gui2::styled_widget::update_canvas().
Referenced by signal_handler_middle_button_click(), and signal_handler_sdl_key_down().
|
privatevirtual |
Definition at line 338 of file text_box_base.cpp.
References cursor_alpha_, cursor_blink_rate_ms_, gui2::styled_widget::get_canvases(), and toggle_cursor_timer().
Referenced by set_cursor().
|
inlineprotected |
Selects all text.
Definition at line 166 of file text_box_base.hpp.
References goto_end_of_data(), and selection_start_.
Referenced by gui2::text_box::signal_handler_left_button_double_click(), and signal_handler_sdl_key_down().
|
overridevirtual |
See styled_widget::set_active.
Implements gui2::styled_widget.
Definition at line 84 of file text_box_base.cpp.
References DISABLED, ENABLED, get_active(), and set_state().
Referenced by gui2::dialogs::game_cache_options::pre_show(), gui2::dialogs::game_version::pre_show(), and gui2::dialogs::screenshot_notification::save_screenshot().
|
protected |
Moves the cursor at the wanted position.
offset | The wanted new cursor position. |
select | Select the text from the original cursor position till the new position? |
Definition at line 136 of file text_box_base.cpp.
References copy_selection(), font::pango_text::get_length(), gui2::widget::queue_redraw(), reset_cursor_state(), selection_length_, selection_start_, text_, and gui2::styled_widget::update_canvas().
Referenced by gui2::text_box::delete_char(), gui2::password_box::delete_selection(), gui2::text_box::delete_selection(), goto_end_of_data(), goto_start_of_data(), handle_editing(), handle_key_left_arrow(), handle_key_right_arrow(), gui2::text_box::handle_mouse_selection(), insert_char(), and set_selection().
|
inlineprotected |
Definition at line 242 of file text_box_base.hpp.
References font::pango_text::set_ellipse_mode(), and text_.
Referenced by gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 222 of file text_box_base.hpp.
References font::pango_text::set_font_size(), and text_.
Referenced by gui2::text_box::text_box().
|
inlineprotected |
Definition at line 227 of file text_box_base.hpp.
References font::pango_text::set_font_style(), and text_.
Referenced by gui2::text_box::text_box().
|
inlineprotected |
Definition at line 237 of file text_box_base.hpp.
References font::pango_text::set_maximum_height(), and text_.
Referenced by gui2::text_box::place().
void gui2::text_box_base::set_maximum_length | ( | const std::size_t | maximum_length | ) |
Definition at line 101 of file text_box_base.cpp.
References font::pango_text::get_length(), gui2::widget::queue_redraw(), selection_length_, selection_start_, font::pango_text::set_maximum_length(), text_, and gui2::styled_widget::update_canvas().
Referenced by gui2::text_box::place(), gui2::dialogs::mp_method_selection::pre_show(), gui2::dialogs::wml_message_base::pre_show(), and gui2::text_box::update_canvas().
|
inlineprotected |
Definition at line 232 of file text_box_base.hpp.
References font::pango_text::set_maximum_width(), and text_.
Referenced by gui2::text_box::place().
void gui2::text_box_base::set_selection | ( | std::size_t | start, |
int | length | ||
) |
Sets or clears the text selection.
Setting the selection range will re-position the cursor depending on the selection direction, specified by the length's sign. Selecting beyond the start or end of the text is safe; the final selection will be limited accordingly.
start | Start offset, in characters. |
length | Selection length, in characters. If zero, the current selection is canceled. If negative, the selection extends towards the start of the text and the cursor will be re-positioned in that direction as well; otherwise the selection and cursor extend towards the end. |
Definition at line 253 of file text_box_base.cpp.
References font::pango_text::get_length(), set_cursor(), set_selection_length(), set_selection_start(), editor::start(), text_, and gui2::styled_widget::update_canvas().
Referenced by handle_commit(), and gui2::dialogs::screenshot_notification::pre_show().
|
protected |
Definition at line 245 of file text_box_base.cpp.
References gui2::widget::queue_redraw(), and selection_length_.
Referenced by gui2::text_box::delete_char(), and set_selection().
|
protected |
Definition at line 237 of file text_box_base.cpp.
References gui2::widget::queue_redraw(), and selection_start_.
Referenced by set_selection().
|
private |
Definition at line 285 of file text_box_base.cpp.
References gui2::widget::queue_redraw(), and state_.
Referenced by set_active(), signal_handler_lose_keyboard_focus(), signal_handler_mouse_enter(), signal_handler_mouse_leave(), and signal_handler_receive_keyboard_focus().
|
inline |
Set the text_changed callback.
Definition at line 93 of file text_box_base.hpp.
References text_changed_callback_.
Referenced by gui2::dialogs::chat_log::view::bind(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::mp_report::pre_show(), gui2::dialogs::unit_create::pre_show(), gui2::dialogs::unit_recall::pre_show(), and gui2::dialogs::unit_recruit::pre_show().
|
virtual |
The set_value is virtual for the password_box class.
That class overrides the set_value function to replace it with asterisk. There might be more generic way to do it when more classes are needed.
Reimplemented in gui2::password_box.
Definition at line 123 of file text_box_base.cpp.
References font::pango_text::get_length(), gui2::widget::queue_redraw(), selection_length_, selection_start_, font::pango_text::set_text(), font::pango_text::text(), text(), text_, and gui2::styled_widget::update_canvas().
Referenced by gui2::chatbox::chat_input_keypress_callback(), gui2::text_box::clear(), gui2::text_box::delete_selection(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::text_box::handle_key_clear_line(), gui2::text_box::history_down(), gui2::text_box::history_up(), gui2::dialogs::mp_login::load_password(), gui2::dialogs::preferences_dialog::on_friends_list_select(), gui2::dialogs::mp_connect::on_server_select(), gui2::dialogs::addon_auth::pre_show(), gui2::dialogs::editor_edit_pbl::pre_show(), gui2::dialogs::game_cache_options::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::mp_match_history::pre_show(), gui2::dialogs::mp_method_selection::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::wml_message_base::pre_show(), and gui2::password_box::set_value().
|
private |
Definition at line 665 of file text_box_base.cpp.
References DBG_GUI_E, ENABLED, LOG_HEADER, and set_state().
Referenced by text_box_base().
|
private |
Definition at line 509 of file text_box_base.cpp.
References DBG_GUI_E, LOG_HEADER, and paste_selection().
Referenced by text_box_base().
|
private |
Definition at line 672 of file text_box_base.cpp.
References DBG_GUI_E, FOCUSED, HOVERED, LOG_HEADER, set_state(), state_, and update_mouse_cursor().
Referenced by text_box_base().
|
private |
Definition at line 686 of file text_box_base.cpp.
References DBG_GUI_E, ENABLED, FOCUSED, LOG_HEADER, set_state(), state_, and update_mouse_cursor().
Referenced by text_box_base().
|
private |
Definition at line 658 of file text_box_base.cpp.
References DBG_GUI_E, FOCUSED, LOG_HEADER, and set_state().
Referenced by text_box_base().
|
private |
Definition at line 519 of file text_box_base.cpp.
References copy_selection(), DBG_GUI_E, delete_selection(), handle_key_backspace(), handle_key_clear_line(), handle_key_delete(), handle_key_down_arrow(), handle_key_end(), handle_key_home(), handle_key_left_arrow(), handle_key_page_down(), handle_key_page_up(), handle_key_right_arrow(), handle_key_up_arrow(), interrupt_composition(), is_composing(), LOG_HEADER, paste_selection(), select_all(), text(), and text_changed_callback_.
Referenced by text_box_base().
|
private |
|
inline |
Definition at line 87 of file text_box_base.hpp.
References font::pango_text::text(), and text_.
Referenced by gui2::dialogs::preferences_dialog::add_friend_list_entry(), handle_commit(), paste_selection(), gui2::password_box::paste_selection(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::preferences_dialog::remove_friend_list_entry(), gui2::text_box::set_hint_data(), set_value(), gui2::password_box::set_value(), and signal_handler_sdl_key_down().
|
privatevirtual |
Definition at line 293 of file text_box_base.cpp.
References gui2::add_timer(), cursor_blink_rate_ms_, cursor_timer_, cursor_timer_callback(), and gui2::remove_timer().
Referenced by reset_cursor_state(), text_box_base(), and ~text_box_base().
|
private |
Definition at line 700 of file text_box_base.cpp.
References cursor::get(), cursor::IBEAM, cursor::NORMAL, and cursor::set().
Referenced by signal_handler_mouse_enter(), signal_handler_mouse_leave(), and ~text_box_base().
|
private |
Definition at line 327 of file text_box_base.hpp.
Referenced by cursor_timer_callback(), and reset_cursor_state().
|
private |
Definition at line 328 of file text_box_base.hpp.
Referenced by reset_cursor_state(), and toggle_cursor_timer().
|
private |
Definition at line 325 of file text_box_base.hpp.
Referenced by toggle_cursor_timer().
|
private |
Definition at line 322 of file text_box_base.hpp.
Referenced by handle_commit(), handle_editing(), handle_key_backspace(), handle_key_delete(), interrupt_composition(), and is_composing().
|
private |
Definition at line 323 of file text_box_base.hpp.
Referenced by get_composition_start(), handle_commit(), and handle_editing().
|
private |
Length of the selected text.
Definition at line 319 of file text_box_base.hpp.
Referenced by copy_selection(), get_selection_length(), handle_key_backspace(), handle_key_delete(), handle_key_left_arrow(), handle_key_right_arrow(), set_cursor(), set_maximum_length(), set_selection_length(), and set_value().
|
private |
Start of the selected text.
Definition at line 310 of file text_box_base.hpp.
Referenced by copy_selection(), get_selection_start(), handle_editing(), handle_key_backspace(), handle_key_delete(), handle_key_left_arrow(), handle_key_right_arrow(), insert_char(), paste_selection(), select_all(), set_cursor(), set_maximum_length(), set_selection_start(), and set_value().
|
private |
Current state of the widget.
The state of the widget determines what to render and how the widget reacts to certain 'events'.
Definition at line 301 of file text_box_base.hpp.
Referenced by cursor_timer_callback(), get_active(), get_state(), set_state(), signal_handler_mouse_enter(), and signal_handler_mouse_leave().
|
private |
The text entered in the widget.
Definition at line 304 of file text_box_base.hpp.
Referenced by copy_selection(), get_column_line(), get_composition_length(), get_cursor_position(), get_length(), get_value(), goto_end_of_data(), handle_editing(), handle_key_delete(), handle_key_right_arrow(), insert_char(), paste_selection(), set_cursor(), set_ellipse_mode(), set_font_size(), set_font_style(), set_maximum_height(), set_maximum_length(), set_maximum_width(), set_selection(), set_value(), text(), and text_box_base().
|
private |
Cached version of the text without any pending IME modifications.
Definition at line 307 of file text_box_base.hpp.
Referenced by get_composition_length(), and handle_editing().
|
private |
Text changed callback.
This callback is called in key_press after the key_press event has been handled by the styled_widget. The parameters to the function are:
Definition at line 504 of file text_box_base.hpp.
Referenced by handle_commit(), set_text_changed_callback(), and signal_handler_sdl_key_down().