#include <text.hpp>
Public Member Functions | |
ttext_ () | |
void | set_active (const bool) |
Sets the control in the active state, when inactive a control can't be used and doesn't react to events. | |
bool | get_active () const |
Gets the active state of the control. | |
unsigned | get_state () const |
Returns the id of the state, which is also the index for the canvas. | |
void | mouse_move (tevent_handler &) |
void | mouse_left_button_down (tevent_handler &event) |
void | mouse_left_button_up (tevent_handler &) |
void | mouse_left_button_double_click (tevent_handler &) |
void | mouse_middle_button_click (tevent_handler &) |
void | key_press (tevent_handler &event, bool &handled, SDLKey key, SDLMod modifier, Uint16 unicode) |
Handled, if there's a keyboard focus it will get the change to handle the key first, if not done it's send to the window. | |
void | set_text (const std::string &text) |
std::string | get_text () const |
const std::string & | text () const |
Protected Member Functions | |
virtual void | goto_end_of_line (const bool select=false)=0 |
void | goto_end_of_data (const bool select=false) |
virtual void | goto_start_of_line (const bool select=false)=0 |
void | goto_start_of_data (const bool select=false) |
void | select_all () |
void | set_cursor (const size_t offset, const bool select) |
size_t | get_sel_start () const |
void | set_sel_start (const size_t sel_start) |
size_t | get_sel_len () const |
void | set_sel_len (const unsigned sel_len) |
virtual void | insert_char (Uint16 unicode)=0 |
Inserts a character at the cursor. | |
virtual void | delete_char (const bool before_cursor)=0 |
Deletes the character. | |
virtual void | delete_selection ()=0 |
Deletes the current selection. | |
virtual void | copy_selection (const bool mouse) |
Copies the current selection. | |
virtual void | paste_selection (const bool mouse) |
Pastes the current selection. | |
std::string & | text () |
size_t & | sel_start () |
int & | sel_len () |
Private Types | |
enum | tstate { ENABLED, DISABLED, FOCUSSED, COUNT } |
Note the order of the states must be the same as defined in settings.hpp. More... | |
Private Member Functions | |
void | set_state (tstate state) |
virtual void | calculate_char_offset ()=0 |
Calculates the offsets of all chars. | |
virtual void | handle_key_up_arrow (SDLMod modifier, bool &handled)=0 |
virtual void | handle_key_down_arrow (SDLMod modifier, bool &handled)=0 |
virtual void | handle_key_clear_line (SDLMod modifier, bool &handled)=0 |
virtual void | handle_key_left_arrow (SDLMod modifier, bool &handled) |
virtual void | handle_key_right_arrow (SDLMod modifier, bool &handled) |
virtual void | handle_key_home (SDLMod modifier, bool &handled) |
virtual void | handle_key_end (SDLMod modifier, bool &handled) |
virtual void | handle_key_backspace (SDLMod modifier, bool &handled) |
virtual void | handle_key_delete (SDLMod modifier, bool &handled) |
virtual void | handle_key_default (bool &handled, SDLKey key, SDLMod modifier, Uint16 unicode) |
virtual void | handle_key_page_up (SDLMod, bool &) |
virtual void | handle_key_page_down (SDLMod, bool &) |
Private Attributes | |
tstate | state_ |
std::string | text_ |
The text in the widget. | |
size_t | sel_start_ |
int | sel_len_ |
positive sel_len_ means selection to the right. | |
size_t | max_length_ |
bool | dragging_ |
Is the mouse in dragging mode, this affects selection in mouse movee. |
Definition at line 27 of file text.hpp.
enum gui2::ttext_::tstate [private] |
void gui2::ttext_::set_active | ( | const | active | ) | [inline, virtual] |
Sets the control in the active state, when inactive a control can't be used and doesn't react to events.
(Note read-only for a ttext_ is a different state.)
Implements gui2::tcontrol.
bool gui2::ttext_::get_active | ( | ) | const [inline, virtual] |
unsigned gui2::ttext_::get_state | ( | ) | const [inline, virtual] |
Returns the id of the state, which is also the index for the canvas.
Implements gui2::tcontrol.
Definition at line 44 of file text.hpp.
References state_.
void gui2::ttext_::mouse_move | ( | tevent_handler & | ) | [virtual] |
Reimplemented from gui2::tevent_executor.
Reimplemented in gui2::ttext_box.
Definition at line 71 of file text.cpp.
References DBG_G_E.
void gui2::ttext_::mouse_left_button_down | ( | tevent_handler & | event | ) | [virtual] |
Reimplemented from gui2::tevent_executor.
Reimplemented in gui2::ttext_box.
Definition at line 78 of file text.cpp.
References DBG_G_E.
void gui2::ttext_::mouse_left_button_up | ( | tevent_handler & | ) | [virtual] |
Reimplemented from gui2::tevent_executor.
Reimplemented in gui2::ttext_box.
Definition at line 86 of file text.cpp.
References DBG_G_E.
void gui2::ttext_::mouse_left_button_double_click | ( | tevent_handler & | ) | [virtual] |
Reimplemented from gui2::tevent_executor.
Reimplemented in gui2::ttext_box.
Definition at line 92 of file text.cpp.
References DBG_G_E, sel_len_, sel_start_, and text_.
void gui2::ttext_::mouse_middle_button_click | ( | tevent_handler & | ) | [virtual] |
Reimplemented from gui2::tevent_executor.
Definition at line 101 of file text.cpp.
References DBG_G_E, and paste_selection().
void gui2::ttext_::key_press | ( | tevent_handler & | , | |
bool & | , | |||
SDLKey | , | |||
SDLMod | , | |||
Uint16 | ||||
) | [virtual] |
Handled, if there's a keyboard focus it will get the change to handle the key first, if not done it's send to the window.
SDLKey the sdl key code needed for special keys SDLMod the keyboard modifiers at moment of pressing Unit16 the unicode for the pressed key
Reimplemented from gui2::tevent_executor.
Definition at line 111 of file text.cpp.
References copy_selection(), gui::copypaste_modifier, DBG_G_E, delete_selection(), handle_key_backspace(), handle_key_clear_line(), handle_key_default(), 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(), and paste_selection().
void gui2::ttext_::set_text | ( | const std::string & | text | ) |
Definition at line 234 of file text.cpp.
References calculate_char_offset(), sel_len_, sel_start_, gui2::tcontrol::set_canvas_text(), gui2::twidget::set_dirty(), and text_.
Referenced by gui2::tbuilder_text_box::build(), gui2::ttext_box::delete_selection(), gui2::ttext_box::handle_key_clear_line(), gui2::ttext_box::handle_key_down_arrow(), gui2::ttext_box::handle_key_up_arrow(), gui2::tmp_method_selection::show(), and gui2::taddon_connect::show().
std::string gui2::ttext_::get_text | ( | ) | const [inline] |
Definition at line 58 of file text.hpp.
References text_.
Referenced by gui2::tmp_method_selection::show(), and gui2::taddon_connect::show().
const std::string& gui2::ttext_::text | ( | ) | const [inline] |
Definition at line 59 of file text.hpp.
References text_.
Referenced by gui2::ttext_box::calculate_char_offset(), copy_selection(), gui2::ttext_box::delete_selection(), gui2::ttext_box::get_character_offset_at(), gui2::ttext_box::handle_key_down_arrow(), gui2::ttext_box::handle_key_up_arrow(), gui2::ttext_box::insert_char(), paste_selection(), gui2::ttext_box::save_to_history(), and gui2::ttext_box::set_canvas_text().
virtual void gui2::ttext_::goto_end_of_line | ( | const bool | select = false |
) | [protected, pure virtual] |
void gui2::ttext_::goto_end_of_data | ( | const bool | select = false |
) | [inline, protected] |
Definition at line 64 of file text.hpp.
References set_cursor(), and text_.
Referenced by gui2::ttext_box::goto_end_of_line(), handle_key_end(), and select_all().
virtual void gui2::ttext_::goto_start_of_line | ( | const bool | select = false |
) | [protected, pure virtual] |
void gui2::ttext_::goto_start_of_data | ( | const bool | select = false |
) | [inline, protected] |
Definition at line 67 of file text.hpp.
References set_cursor().
Referenced by gui2::ttext_box::goto_start_of_line(), and handle_key_home().
void gui2::ttext_::select_all | ( | ) | [inline, protected] |
Definition at line 69 of file text.hpp.
References goto_end_of_data(), and sel_start_.
Referenced by gui2::ttext_box::mouse_left_button_double_click().
void gui2::ttext_::set_cursor | ( | const size_t | offset, | |
const bool | select | |||
) | [protected] |
Definition at line 44 of file text.cpp.
References copy_selection(), sel_len_, sel_start_, gui2::tcontrol::set_canvas_text(), gui2::twidget::set_dirty(), and text_.
Referenced by gui2::ttext_box::delete_char(), gui2::ttext_box::delete_selection(), goto_end_of_data(), goto_start_of_data(), handle_key_left_arrow(), handle_key_right_arrow(), gui2::ttext_box::handle_mouse_selection(), and gui2::ttext_box::insert_char().
size_t gui2::ttext_::get_sel_start | ( | ) | const [inline, protected] |
void gui2::ttext_::set_sel_start | ( | const size_t | sel_start | ) | [inline, protected] |
size_t gui2::ttext_::get_sel_len | ( | ) | const [inline, protected] |
void gui2::ttext_::set_sel_len | ( | const unsigned | sel_len | ) | [inline, protected] |
virtual void gui2::ttext_::insert_char | ( | Uint16 | unicode | ) | [protected, pure virtual] |
Inserts a character at the cursor.
Implemented in gui2::ttext_box.
Referenced by handle_key_default().
virtual void gui2::ttext_::delete_char | ( | const bool | before_cursor | ) | [protected, pure virtual] |
Deletes the character.
Implemented in gui2::ttext_box.
Referenced by handle_key_backspace(), and handle_key_delete().
virtual void gui2::ttext_::delete_selection | ( | ) | [protected, pure virtual] |
Deletes the current selection.
Implemented in gui2::ttext_box.
Referenced by handle_key_delete(), key_press(), and paste_selection().
void gui2::ttext_::copy_selection | ( | const bool | mouse | ) | [protected, virtual] |
Copies the current selection.
Definition at line 257 of file text.cpp.
References copy_to_clipboard(), sel_len(), sel_start(), utils::string_to_wstring(), text(), text_, and utils::wstring_to_string().
Referenced by key_press(), and set_cursor().
void gui2::ttext_::paste_selection | ( | const bool | mouse | ) | [protected, virtual] |
Pastes the current selection.
Definition at line 273 of file text.cpp.
References calculate_char_offset(), copy_from_clipboard(), delete_selection(), sel_start_, gui2::tcontrol::set_canvas_text(), gui2::twidget::set_dirty(), utils::string_to_wstring(), text(), and text_.
Referenced by key_press(), and mouse_middle_button_click().
std::string& gui2::ttext_::text | ( | ) | [inline, protected] |
size_t& gui2::ttext_::sel_start | ( | ) | [inline, protected] |
Definition at line 98 of file text.hpp.
References sel_start_.
Referenced by copy_selection(), gui2::ttext_box::delete_char(), gui2::ttext_box::delete_selection(), gui2::ttext_box::insert_char(), and gui2::ttext_box::set_canvas_text().
int& gui2::ttext_::sel_len | ( | ) | [inline, protected] |
Definition at line 100 of file text.hpp.
References sel_len_.
Referenced by copy_selection(), gui2::ttext_box::delete_char(), gui2::ttext_box::delete_selection(), and gui2::ttext_box::set_canvas_text().
void gui2::ttext_::set_state | ( | tstate | state | ) | [private] |
virtual void gui2::ttext_::calculate_char_offset | ( | ) | [private, pure virtual] |
Calculates the offsets of all chars.
Implemented in gui2::ttext_box.
Referenced by paste_selection(), and set_text().
virtual void gui2::ttext_::handle_key_up_arrow | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, pure virtual] |
virtual void gui2::ttext_::handle_key_down_arrow | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, pure virtual] |
virtual void gui2::ttext_::handle_key_clear_line | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, pure virtual] |
void gui2::ttext_::handle_key_left_arrow | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 294 of file text.cpp.
References DBG_G_E, sel_len_, sel_start_, and set_cursor().
Referenced by key_press().
void gui2::ttext_::handle_key_right_arrow | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 307 of file text.cpp.
References DBG_G_E, sel_len_, sel_start_, set_cursor(), and text_.
Referenced by key_press().
void gui2::ttext_::handle_key_home | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 320 of file text.cpp.
References DBG_G_E, goto_start_of_data(), and goto_start_of_line().
Referenced by key_press().
void gui2::ttext_::handle_key_end | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 335 of file text.cpp.
References DBG_G_E, goto_end_of_data(), and goto_end_of_line().
Referenced by key_press().
void gui2::ttext_::handle_key_backspace | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 348 of file text.cpp.
References DBG_G_E, delete_char(), and sel_start_.
Referenced by key_press().
void gui2::ttext_::handle_key_delete | ( | SDLMod | modifier, | |
bool & | handled | |||
) | [private, virtual] |
Definition at line 360 of file text.cpp.
References DBG_G_E, delete_char(), delete_selection(), sel_len_, sel_start_, and text_.
Referenced by key_press().
void gui2::ttext_::handle_key_default | ( | bool & | handled, | |
SDLKey | key, | |||
SDLMod | modifier, | |||
Uint16 | unicode | |||
) | [private, virtual] |
Definition at line 372 of file text.cpp.
References DBG_G_E, and insert_char().
Referenced by key_press().
virtual void gui2::ttext_::handle_key_page_up | ( | SDLMod | , | |
bool & | ||||
) | [inline, private, virtual] |
virtual void gui2::ttext_::handle_key_page_down | ( | SDLMod | , | |
bool & | ||||
) | [inline, private, virtual] |
tstate gui2::ttext_::state_ [private] |
std::string gui2::ttext_::text_ [private] |
The text in the widget.
Definition at line 111 of file text.hpp.
Referenced by copy_selection(), get_text(), goto_end_of_data(), handle_key_delete(), handle_key_right_arrow(), mouse_left_button_double_click(), paste_selection(), set_cursor(), set_text(), and text().
size_t gui2::ttext_::sel_start_ [private] |
Definition at line 116 of file text.hpp.
Referenced by get_sel_start(), handle_key_backspace(), handle_key_delete(), handle_key_left_arrow(), handle_key_right_arrow(), mouse_left_button_double_click(), paste_selection(), sel_start(), select_all(), set_cursor(), set_sel_start(), and set_text().
int gui2::ttext_::sel_len_ [private] |
positive sel_len_ means selection to the right.
negative sel_len_ means selection to the left. sel_len_ == 0 means no selection.
Definition at line 120 of file text.hpp.
Referenced by get_sel_len(), handle_key_delete(), handle_key_left_arrow(), handle_key_right_arrow(), mouse_left_button_double_click(), sel_len(), set_cursor(), set_sel_len(), and set_text().
size_t gui2::ttext_::max_length_ [private] |
bool gui2::ttext_::dragging_ [private] |
Is the mouse in dragging mode, this affects selection in mouse movee.
Reimplemented in gui2::ttext_box.
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |