#include <textbox.hpp>
Public Member Functions | |
textbox (CVideo &video, int width, const std::string &text="", bool editable=true, size_t max_size=256, 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) |
void | append_text (const std::string &text, bool auto_scroll=false) |
void | clear () |
void | process () |
void | set_editable (bool value) |
bool | editable () const |
void | scroll_to_bottom () |
void | set_wrap (bool val) |
void | set_location (const SDL_Rect &rect) |
void | set_location (int x, int y) |
Protected Member Functions | |
virtual void | draw_contents () |
virtual void | set_inner_location (SDL_Rect const &) |
virtual void | scroll (unsigned int pos) |
Private Member Functions | |
virtual void | handle_text_changed (const wide_string &) |
void | handle_event (const SDL_Event &event) |
void | draw_cursor (int pos, CVideo &video) const |
void | update_text_cache (bool reset=false) |
surface | add_text_line (const wide_string &text) |
bool | is_selection () |
void | erase_selection () |
bool | requires_event_focus (const SDL_Event *event=NULL) const |
bool | show_scrollbar () const |
Private Attributes | |
size_t | max_size_ |
wide_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_ |
Definition at line 27 of file textbox.hpp.
gui::textbox::textbox | ( | CVideo & | video, | |
int | width, | |||
const std::string & | text = "" , |
|||
bool | editable = true , |
|||
size_t | max_size = 256 , |
|||
double | alpha = 0.4 , |
|||
double | alpha_focus = 0.2 , |
|||
const bool | auto_join = true | |||
) |
Definition at line 44 of file textbox.cpp.
References gui::font_size, font::get_max_height(), gui::widget::set_measurements(), gui::scrollarea::set_scroll_rate(), and update_text_cache().
gui::textbox::~textbox | ( | ) | [virtual] |
Definition at line 59 of file textbox.cpp.
const std::string gui::textbox::text | ( | ) | const |
Definition at line 68 of file textbox.cpp.
References text_, and utils::wstring_to_string().
Referenced by mp::create::get_parameters(), mp::ui::handle_key_event(), gui::dialog::layout(), mp::create::process_event(), and gui::dialog::textbox_text().
void gui::textbox::set_text | ( | const std::string & | text | ) |
Definition at line 75 of file textbox.cpp.
References cursor_, handle_text_changed(), selend_, selstart_, gui::widget::set_dirty(), utils::string_to_wstring(), text_, text_pos_, and update_text_cache().
Referenced by append_text(), mp::create::create(), mp::ui::handle_key_event(), and mp::chat::init_textbox().
void gui::textbox::append_text | ( | const std::string & | text, | |
bool | auto_scroll = false | |||
) |
Definition at line 87 of file textbox.cpp.
References add_text_line(), surface::assign(), create_compatible_surface(), surface::get(), gui::scrollarea::get_max_position(), gui::scrollarea::get_position(), handle_text_changed(), utils::isnewline(), scroll_to_bottom(), gui::widget::set_dirty(), set_text(), utils::string_to_wstring(), text_, text_image_, update_text_cache(), and wrap_.
Referenced by mp::chat::update_textbox().
void gui::textbox::clear | ( | void | ) |
Definition at line 122 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().
void gui::textbox::process | ( | ) |
Definition at line 202 of file textbox.cpp.
References gui::widget::draw(), editable_, gui::widget::focus(), gui::widget::set_dirty(), show_cursor_, and show_cursor_at_.
void gui::textbox::set_editable | ( | bool | value | ) |
bool gui::textbox::editable | ( | ) | const |
void gui::textbox::scroll_to_bottom | ( | ) |
Definition at line 231 of file textbox.cpp.
References gui::scrollarea::get_max_position(), and gui::scrollarea::set_position().
Referenced by append_text(), and mp::chat::init_textbox().
void gui::textbox::set_wrap | ( | bool | val | ) |
Definition at line 236 of file textbox.cpp.
References gui::widget::set_dirty(), update_text_cache(), and wrap_.
Referenced by mp::ui::set_location(), and gui::dialog::set_textbox().
void gui::textbox::set_location | ( | const SDL_Rect & | rect | ) | [virtual] |
Reimplemented from gui::widget.
Definition at line 245 of file textbox.cpp.
References gui::widget::location(), gui::scrollarea::set_shown_size(), and text_pos_.
Referenced by mp::ui::layout_children(), mp::create::layout_children(), and gui::dialog::update_widget_positions().
void gui::textbox::set_location | ( | int | x, | |
int | y | |||
) | [inline] |
void gui::textbox::draw_contents | ( | ) | [protected, virtual] |
Reimplemented from gui::widget.
Definition at line 144 of file textbox.cpp.
References alpha_, alpha_focus_, char_x_, char_y_, cursor_pos_, draw_cursor(), draw_solid_tinted_rectangle(), boost::foreach_detail_::end(), fill_rect_alpha(), gui::widget::focus(), CVideo::getSurface(), gui::scrollarea::inner_location(), is_selection(), line_height_, loc, rect, screen_area(), selend_, selstart_, text_image_, text_pos_, update_rect(), update_text_cache(), gui::widget::video(), and yscroll_.
void gui::textbox::set_inner_location | ( | SDL_Rect const & | rect | ) | [protected, virtual] |
Implements gui::scrollarea.
Definition at line 63 of file textbox.cpp.
References gui::widget::bg_register().
void gui::textbox::scroll | ( | unsigned int | pos | ) | [protected, virtual] |
Implements gui::scrollarea.
Definition at line 253 of file textbox.cpp.
References gui::widget::set_dirty(), and yscroll_.
virtual void gui::textbox::handle_text_changed | ( | const wide_string & | ) | [inline, private, virtual] |
Definition at line 58 of file textbox.hpp.
Referenced by append_text(), clear(), handle_event(), and set_text().
void gui::textbox::handle_event | ( | const SDL_Event & | event | ) | [private, virtual] |
Reimplemented from gui::scrollarea.
Definition at line 403 of file textbox.cpp.
References char_x_, char_y_, copy_from_clipboard(), copy_to_clipboard(), gui::copypaste_modifier, cursor_, DBG_G, gui::widget::draw(), editable_, boost::foreach_detail_::end(), erase_selection(), gui::widget::focus(), events::focus_handler(), grabmouse_, map_editor::handle_event(), handle_text_changed(), gui::widget::hidden(), gui::scrollarea::inner_location(), is_selection(), utils::isnewline(), line_height_, loc, max_size_, point_in_rect(), pos, selend_, selstart_, gui::widget::set_dirty(), gui::widget::set_focus(), show_cursor_, show_cursor_at_, utils::string_to_wstring(), text_, text_image_, text_pos_, update_text_cache(), WRN_DISPLAY, utils::wstring_to_string(), and yscroll_.
void gui::textbox::draw_cursor | ( | int | pos, | |
CVideo & | video | |||
) | const [private] |
Definition at line 135 of file textbox.cpp.
References editable_, CVideo::getSurface(), gui::widget::location(), rect, and show_cursor_.
Referenced by draw_contents().
void gui::textbox::update_text_cache | ( | bool | reset = false |
) | [private] |
Definition at line 325 of file textbox.cpp.
References add_text_line(), surface::assign(), char_x_, char_y_, cursor_, cursor_pos_, cursor_x, 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_text(), set_wrap(), and textbox().
surface gui::textbox::add_text_line | ( | const wide_string & | text | ) | [private] |
Definition at line 259 of file textbox.cpp.
References backup, char_x_, char_y_, gui::font_size, font::get_max_height(), font::get_rendered_text(), gui::scrollarea::inner_location(), line_height_, font::line_width(), font::NORMAL_COLOUR, utils::wchar_to_string(), wrap_, and utils::wstring_to_string().
Referenced by append_text(), and update_text_cache().
bool gui::textbox::is_selection | ( | ) | [private] |
Definition at line 349 of file textbox.cpp.
References selend_, and selstart_.
Referenced by draw_contents(), erase_selection(), and handle_event().
void gui::textbox::erase_selection | ( | ) | [private] |
Definition at line 354 of file textbox.cpp.
References cursor_, is_selection(), minimum(), selend_, selstart_, and text_.
Referenced by handle_event().
bool gui::textbox::requires_event_focus | ( | const SDL_Event * | event = NULL |
) | const [private, virtual] |
Reimplemented from events::handler.
Definition at line 375 of file textbox.cpp.
References editable_, gui::widget::focus_, and gui::widget::hidden().
bool gui::textbox::show_scrollbar | ( | ) | const [private] |
size_t gui::textbox::max_size_ [private] |
wide_string gui::textbox::text_ [private] |
Definition at line 62 of file textbox.hpp.
Referenced by append_text(), clear(), erase_selection(), handle_event(), set_text(), text(), and update_text_cache().
int gui::textbox::cursor_ [private] |
Definition at line 65 of file textbox.hpp.
Referenced by clear(), erase_selection(), handle_event(), set_text(), and update_text_cache().
int gui::textbox::selstart_ [private] |
Definition at line 66 of file textbox.hpp.
Referenced by clear(), draw_contents(), erase_selection(), handle_event(), is_selection(), and set_text().
int gui::textbox::selend_ [private] |
Definition at line 67 of file textbox.hpp.
Referenced by clear(), draw_contents(), erase_selection(), handle_event(), is_selection(), and set_text().
bool gui::textbox::grabmouse_ [private] |
int gui::textbox::text_pos_ [private] |
Definition at line 70 of file textbox.hpp.
Referenced by clear(), draw_contents(), handle_event(), set_location(), set_text(), and update_text_cache().
int gui::textbox::cursor_pos_ [private] |
Definition at line 71 of file textbox.hpp.
Referenced by clear(), draw_contents(), and update_text_cache().
std::vector<int> gui::textbox::char_x_ [private] |
Definition at line 72 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), handle_event(), and update_text_cache().
std::vector<int> gui::textbox::char_y_ [private] |
Definition at line 72 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), handle_event(), and update_text_cache().
bool gui::textbox::editable_ [private] |
Definition at line 74 of file textbox.hpp.
Referenced by draw_cursor(), editable(), handle_event(), process(), requires_event_focus(), and set_editable().
bool gui::textbox::show_cursor_ [private] |
Definition at line 76 of file textbox.hpp.
Referenced by draw_cursor(), handle_event(), and process().
int gui::textbox::show_cursor_at_ [private] |
surface gui::textbox::text_image_ [private] |
Definition at line 82 of file textbox.hpp.
Referenced by append_text(), draw_contents(), handle_event(), and update_text_cache().
bool gui::textbox::wrap_ [private] |
Definition at line 84 of file textbox.hpp.
Referenced by add_text_line(), append_text(), and set_wrap().
size_t gui::textbox::line_height_ [private] |
Definition at line 86 of file textbox.hpp.
Referenced by add_text_line(), draw_contents(), and handle_event().
size_t gui::textbox::yscroll_ [private] |
Definition at line 86 of file textbox.hpp.
Referenced by draw_contents(), handle_event(), and scroll().
double gui::textbox::alpha_ [private] |
double gui::textbox::alpha_focus_ [private] |
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |