#include <textbox.hpp>

Public Member Functions | |
| textbox (CVideo &video, int width, const std::string &text="", bool editable=true, size_t max_size=256, int font_size=font::SIZE_PLUS, double alpha=0.4, double alpha_focus=0.2, const bool auto_join=true) | |
| virtual | ~textbox () |
| const std::string | text () const |
| void | set_text (const std::string &text, const SDL_Color &color=font::NORMAL_COLOR) |
| void | append_text (const std::string &text, bool auto_scroll=false, const SDL_Color &color=font::NORMAL_COLOR) |
| void | clear () |
| void | set_selection (const int selstart, const int selend) |
| void | set_cursor_pos (const int cursor_pos) |
| void | set_editable (bool value) |
| bool | editable () const |
| int | font_size () const |
| void | set_font_size (int fs) |
| void | scroll_to_bottom () |
| void | set_wrap (bool val) |
| void | set_edit_target (textbox *target) |
Public Member Functions inherited from gui::scrollarea | |
| scrollarea (CVideo &video, bool auto_join=true) | |
| Create a zone with automatic handling of scrollbar. More... | |
| virtual void | hide (bool value=true) |
Public Member Functions inherited from gui::widget | |
| SDL_Rect const & | location () const |
| virtual void | set_location (SDL_Rect const &rect) |
| void | set_location (int x, int y) |
| void | set_width (int w) |
| void | set_height (int h) |
| void | set_measurements (int w, int h) |
| int | width () const |
| int | height () const |
| bool | focus (const SDL_Event *event) |
| void | set_focus (bool focus) |
| bool | hidden () const |
| virtual void | enable (bool new_val=true) |
| bool | enabled () const |
| void | set_clip_rect (const SDL_Rect &rect) |
| void | set_volatile (bool val=true) |
| void | set_dirty (bool dirty=true) |
| bool | dirty () const |
| const std::string & | id () const |
| void | set_id (const std::string &id) |
| void | set_help_string (const std::string &str) |
| void | set_tooltip_string (const std::string &str) |
| virtual void | process_help_string (int mousex, int mousey) |
| virtual void | process_tooltip_string (int mousex, int mousey) |
Public Member Functions inherited from events::sdl_handler | |
| virtual void | join () |
| virtual void | join (context &c) |
| virtual void | join_same (sdl_handler *parent) |
| virtual void | leave () |
| virtual void | join_global () |
| virtual void | leave_global () |
Protected Member Functions | |
| virtual void | draw_contents () |
| virtual void | update_location (SDL_Rect const &rect) |
| virtual void | set_inner_location (SDL_Rect const &) |
| virtual void | scroll (unsigned int pos) |
Protected Member Functions inherited from gui::scrollarea | |
| virtual sdl_handler_vector | handler_members () |
| virtual void | process_event () |
| SDL_Rect | inner_location () const |
| unsigned | scrollbar_width () const |
| unsigned | get_position () const |
| unsigned | get_max_position () const |
| void | set_position (unsigned pos) |
| void | adjust_position (unsigned pos) |
| void | move_position (int dep) |
| void | set_shown_size (unsigned h) |
| void | set_full_size (unsigned h) |
| void | set_scroll_rate (unsigned r) |
| bool | has_scrollbar () const |
Protected Member Functions inherited from gui::widget | |
| widget (widget const &o) | |
| widget (CVideo &video, const bool auto_join=true) | |
| virtual | ~widget () |
| void | bg_register (SDL_Rect const &rect) |
| void | bg_restore () const |
| void | bg_restore (SDL_Rect const &rect) const |
| void | bg_update () |
| void | bg_cancel () |
| CVideo & | video () const |
| virtual void | draw () |
| const SDL_Rect * | clip_rect () const |
| virtual sdl_handler_vector | member_handlers () |
| virtual void | handle_window_event (SDL_Event const &event) |
| bool | mouse_locked () const |
| void | aquire_mouse_lock () |
| void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
| sdl_handler (const bool auto_join=true) | |
| virtual | ~sdl_handler () |
Private Member Functions | |
| virtual void | handle_text_changed (const ucs4::string &) |
| void | handle_event (const SDL_Event &event, bool was_forwarded) |
| void | handle_event (const SDL_Event &event) |
| void | pass_event_to_target (const SDL_Event &event) |
| void | draw_cursor (int pos, CVideo &video) const |
| void | update_text_cache (bool reset=false, const SDL_Color &color=font::NORMAL_COLOR) |
| surface | add_text_line (const ucs4::string &text, const SDL_Color &color=font::NORMAL_COLOR) |
| bool | is_selection () |
| void | erase_selection () |
| bool | requires_event_focus (const SDL_Event *event=nullptr) const |
| bool | show_scrollbar () const |
| bool | handle_text_input (const SDL_Event &event) |
| bool | handle_key_down (const SDL_Event &event) |
Private Attributes | |
| size_t | max_size_ |
| int | font_size_ |
| ucs4::string | text_ |
| int | cursor_ |
| int | selstart_ |
| int | selend_ |
| bool | grabmouse_ |
| int | text_pos_ |
| int | cursor_pos_ |
| std::vector< int > | char_x_ |
| std::vector< int > | char_y_ |
| bool | editable_ |
| bool | show_cursor_ |
| int | show_cursor_at_ |
| surface | text_image_ |
| bool | wrap_ |
| size_t | line_height_ |
| size_t | yscroll_ |
| double | alpha_ |
| double | alpha_focus_ |
| textbox * | edit_target_ |
| bool | listening_ |
Additional Inherited Members | |
Protected Attributes inherited from gui::widget | |
| bool | focus_ |
Definition at line 25 of file textbox.hpp.
| gui::textbox::textbox | ( | CVideo & | video, |
| int | width, | ||
| const std::string & | text = "", |
||
| bool | editable = true, |
||
| size_t | max_size = 256, |
||
| int | font_size = font::SIZE_PLUS, |
||
| double | alpha = 0.4, |
||
| double | alpha_focus = 0.2, |
||
| const bool | auto_join = true |
||
| ) |
Definition at line 33 of file textbox.cpp.
References font_size_, font::get_max_height(), gui::widget::set_measurements(), gui::scrollarea::set_scroll_rate(), and update_text_cache().
|
virtual |
Definition at line 50 of file textbox.cpp.
|
private |
Definition at line 292 of file textbox.cpp.
References char_x_, char_y_, font_size_, font::get_max_height(), font::get_rendered_text(), gui::scrollarea::inner_location(), itor, line_height_, font::line_width(), unicode_cast(), and wrap_.
Referenced by append_text(), and update_text_cache().
| void gui::textbox::append_text | ( | const std::string & | text, |
| bool | auto_scroll = false, |
||
| const SDL_Color & | color = font::NORMAL_COLOR |
||
| ) |
Definition at line 88 of file textbox.cpp.
References add_text_line(), surface::assign(), create_compatible_surface(), sdl::create_rect(), surface::get(), gui::scrollarea::get_max_position(), gui::scrollarea::get_position(), handle_text_changed(), utils::isnewline(), scroll_to_bottom(), sdl_blit(), SDL_SetAlpha(), gui::widget::set_dirty(), set_text(), text(), text_, text_image_, unicode_cast(), update_text_cache(), and wrap_.
Referenced by mp::chat::init_textbox(), and mp::chat::update_textbox().
| void gui::textbox::clear | ( | ) |
Definition at line 127 of file textbox.cpp.
References cursor_, cursor_pos_, handle_text_changed(), selend_, selstart_, gui::widget::set_dirty(), text_, text_pos_, and update_text_cache().
Referenced by mp::ui::handle_key_event().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 183 of file textbox.cpp.
References adjust_surface_alpha(), alpha_, alpha_focus_, char_x_, char_y_, sdl::create_rect(), cursor_pos_, draw_cursor(), sdl::draw_solid_tinted_rectangle(), gui::widget::enabled(), sdl::fill_rect_alpha(), gui::widget::focus(), ftofxp, CVideo::getSurface(), gui::scrollarea::inner_location(), int(), is_selection(), line_height_, right, screen_area(), sdl_blit(), selend_, selstart_, surf, text_image_, text_pos_, update_rect(), update_text_cache(), gui::widget::video(), and yscroll_.
Definition at line 170 of file textbox.cpp.
References sdl::create_rect(), editable_, gui::widget::enabled(), sdl::fill_rect(), CVideo::getSurface(), gui::widget::location(), and show_cursor_.
Referenced by draw_contents().
| bool gui::textbox::editable | ( | ) | const |
Definition at line 257 of file textbox.cpp.
References editable_.
Referenced by handle_key_down(), and pass_event_to_target().
|
private |
Definition at line 391 of file textbox.cpp.
References cursor_, is_selection(), itor, selend_, selstart_, and text_.
Referenced by handle_key_down(), and handle_text_input().
| int gui::textbox::font_size | ( | ) | const |
Definition at line 262 of file textbox.cpp.
References font_size_.
|
private |
Definition at line 601 of file textbox.cpp.
References char_x_, char_y_, cursor_, gui::widget::draw(), gui::widget::enabled(), gui::widget::focus(), events::focus_handler(), grabmouse_, gui::scrollarea::handle_event(), handle_key_down(), handle_text_changed(), handle_text_input(), gui::widget::hidden(), i, gui::scrollarea::inner_location(), is_selection(), line_height_, listening_, gui::widget::mouse_locked(), sdl::point_in_rect(), pos, selend_, selstart_, gui::widget::set_dirty(), gui::widget::set_focus(), show_cursor_, show_cursor_at_, text_, text_image_, text_pos_, update_text_cache(), WRN_DP, and yscroll_.
Referenced by handle_event(), and pass_event_to_target().
|
privatevirtual |
Reimplemented from gui::scrollarea.
Definition at line 440 of file textbox.cpp.
References gui::widget::handle_event(), and handle_event().
|
private |
Definition at line 470 of file textbox.cpp.
References desktop::clipboard::copy_from_clipboard(), desktop::clipboard::copy_to_clipboard(), cursor_, editable(), editable_, erase_selection(), is_selection(), utils::isnewline(), listening_, max_size_, pass_event_to_target(), SDL_keysym, SDLMod, selend_, selstart_, text_, and unicode_cast().
Referenced by handle_event().
|
inlineprivatevirtual |
Reimplemented in gui::filter_textbox.
Definition at line 58 of file textbox.hpp.
Referenced by append_text(), clear(), handle_event(), and set_text().
|
private |
Definition at line 446 of file textbox.cpp.
References cursor_, DBG_G, editable_, erase_selection(), is_selection(), max_size_, pass_event_to_target(), text_, and unicode_cast().
Referenced by handle_event().
|
private |
Definition at line 386 of file textbox.cpp.
References selend_, and selstart_.
Referenced by draw_contents(), erase_selection(), handle_event(), handle_key_down(), and handle_text_input().
|
private |
Definition at line 712 of file textbox.cpp.
References edit_target_, editable(), and handle_event().
Referenced by handle_key_down(), and handle_text_input().
|
privatevirtual |
Reimplemented from events::sdl_handler.
Definition at line 412 of file textbox.cpp.
References gui::widget::enabled(), gui::widget::focus_, gui::widget::hidden(), and SDLKey.
Implements gui::scrollarea.
Definition at line 286 of file textbox.cpp.
References pos, gui::widget::set_dirty(), and yscroll_.
| void gui::textbox::scroll_to_bottom | ( | ) |
Definition at line 272 of file textbox.cpp.
References gui::scrollarea::get_max_position(), and gui::scrollarea::set_position().
Referenced by append_text().
Definition at line 155 of file textbox.cpp.
References cursor_, editable_, gui::widget::set_dirty(), text_, update_text_cache(), and WRN_DP.
Referenced by dialogs::file_dialog::set_save_text().
Definition at line 719 of file textbox.cpp.
References edit_target_.
Referenced by mp::ui::set_location().
| void gui::textbox::set_editable | ( | bool | value | ) |
Definition at line 252 of file textbox.cpp.
References editable_.
Definition at line 267 of file textbox.cpp.
References font_size_.
|
protectedvirtual |
Implements gui::scrollarea.
Definition at line 61 of file textbox.cpp.
References gui::widget::bg_register(), surface::null(), text_image_, text_pos_, and update_text_cache().
Definition at line 140 of file textbox.cpp.
References editable_, selend_, selstart_, gui::widget::set_dirty(), text_, and WRN_DP.
Referenced by dialogs::file_dialog::set_save_text().
| void gui::textbox::set_text | ( | const std::string & | text, |
| const SDL_Color & | color = font::NORMAL_COLOR |
||
| ) |
Definition at line 76 of file textbox.cpp.
References cursor_, handle_text_changed(), selend_, selstart_, gui::widget::set_dirty(), text(), text_, text_pos_, unicode_cast(), and update_text_cache().
Referenced by dialogs::file_dialog::action(), append_text(), mp::configure::configure(), gui::filter_textbox::filter_textbox(), mp::ui::handle_key_event(), mp::lobby::lobby(), dialogs::file_dialog::select_file(), mp::create::set_description(), dialogs::file_dialog::set_save_text(), and mp::options::entry_display::set_value().
| void gui::textbox::set_wrap | ( | bool | val | ) |
Definition at line 277 of file textbox.cpp.
References gui::widget::set_dirty(), update_text_cache(), and wrap_.
Referenced by mp::create::layout_children(), mp::ui::set_location(), and gui::dialog::set_textbox().
|
private |
| const std::string gui::textbox::text | ( | ) | const |
Definition at line 69 of file textbox.cpp.
References text_, and unicode_cast().
Referenced by append_text(), mp::configure::get_parameters(), mp::options::entry_display::get_value(), mp::ui::handle_key_event(), gui::dialog::layout(), mp::create::process_event_impl(), mp::configure::process_event_impl(), mp::lobby::process_event_impl(), set_text(), and gui::dialog::textbox_text().
|
protectedvirtual |
Reimplemented from gui::scrollarea.
Definition at line 54 of file textbox.cpp.
References gui::widget::set_dirty(), gui::scrollarea::update_location(), and update_text_cache().
|
private |
Definition at line 362 of file textbox.cpp.
References add_text_line(), surface::assign(), char_x_, char_y_, cursor_, cursor_pos_, gui::widget::location(), surface::null(), gui::scrollarea::set_full_size(), gui::scrollarea::set_shown_size(), text_, text_image_, and text_pos_.
Referenced by append_text(), clear(), draw_contents(), handle_event(), set_cursor_pos(), set_inner_location(), set_text(), set_wrap(), textbox(), and update_location().
|
private |
Definition at line 90 of file textbox.hpp.
Referenced by draw_contents().
|
private |
Definition at line 91 of file textbox.hpp.
Referenced by draw_contents().
|
private |
Definition at line 74 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), handle_event(), and update_text_cache().
|
private |
Definition at line 74 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), handle_event(), and update_text_cache().
|
private |
Definition at line 67 of file textbox.hpp.
Referenced by clear(), erase_selection(), handle_event(), handle_key_down(), handle_text_input(), set_cursor_pos(), set_text(), and update_text_cache().
|
private |
Definition at line 73 of file textbox.hpp.
Referenced by clear(), draw_contents(), and update_text_cache().
|
private |
Definition at line 93 of file textbox.hpp.
Referenced by pass_event_to_target(), and set_edit_target().
|
private |
Definition at line 76 of file textbox.hpp.
Referenced by draw_cursor(), editable(), handle_key_down(), handle_text_input(), set_cursor_pos(), set_editable(), and set_selection().
|
private |
Definition at line 62 of file textbox.hpp.
Referenced by add_text_line(), font_size(), set_font_size(), and textbox().
|
private |
Definition at line 70 of file textbox.hpp.
Referenced by handle_event().
|
private |
Definition at line 88 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), and handle_event().
|
private |
Definition at line 99 of file textbox.hpp.
Referenced by handle_event(), and handle_key_down().
|
private |
Definition at line 60 of file textbox.hpp.
Referenced by handle_key_down(), and handle_text_input().
|
private |
Definition at line 69 of file textbox.hpp.
Referenced by clear(), draw_contents(), erase_selection(), handle_event(), handle_key_down(), is_selection(), set_selection(), and set_text().
|
private |
Definition at line 68 of file textbox.hpp.
Referenced by clear(), draw_contents(), erase_selection(), handle_event(), handle_key_down(), is_selection(), set_selection(), and set_text().
|
private |
Definition at line 78 of file textbox.hpp.
Referenced by draw_cursor(), and handle_event().
|
private |
Definition at line 83 of file textbox.hpp.
Referenced by handle_event().
|
private |
Definition at line 64 of file textbox.hpp.
Referenced by append_text(), clear(), erase_selection(), handle_event(), handle_key_down(), handle_text_input(), set_cursor_pos(), set_selection(), set_text(), text(), and update_text_cache().
|
private |
Definition at line 84 of file textbox.hpp.
Referenced by append_text(), draw_contents(), handle_event(), set_inner_location(), and update_text_cache().
|
private |
Definition at line 72 of file textbox.hpp.
Referenced by clear(), draw_contents(), handle_event(), set_inner_location(), set_text(), and update_text_cache().
|
private |
Definition at line 86 of file textbox.hpp.
Referenced by add_text_line(), append_text(), and set_wrap().
|
private |
Definition at line 88 of file textbox.hpp.
Referenced by draw_contents(), handle_event(), and scroll().
1.8.8