Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

gui::textbox Class Reference

#include <textbox.hpp>

Inheritance diagram for gui::textbox:
Inheritance graph
[legend]
Collaboration diagram for gui::textbox:
Collaboration graph
[legend]

List of all members.

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, 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_editable (bool value)
bool editable () const
void scroll_to_bottom ()
void set_wrap (bool val)

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, const SDL_Color &color=font::NORMAL_COLOR)
surface add_text_line (const wide_string &text, const SDL_Color &color=font::NORMAL_COLOR)
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_

Detailed Description

Definition at line 26 of file textbox.hpp.


Constructor & Destructor Documentation

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 33 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().

Here is the call graph for this function:

gui::textbox::~textbox (  )  [virtual]

Definition at line 48 of file textbox.cpp.


Member Function Documentation

surface gui::textbox::add_text_line ( const wide_string text,
const SDL_Color &  color = font::NORMAL_COLOR 
) [private]

Definition at line 235 of file textbox.cpp.

References char_x_, char_y_, gui::font_size, font::get_max_height(), font::get_rendered_text(), gui::scrollarea::inner_location(), line_height_, font::line_width(), w, utils::wchar_to_string(), wrap_, and utils::wstring_to_string().

Referenced by append_text(), and update_text_cache().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::append_text ( const std::string &  text,
bool  auto_scroll = false,
const SDL_Color &  color = font::NORMAL_COLOR 
)
void gui::textbox::clear (  ) 

Definition at line 118 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::draw_contents (  )  [protected, virtual]
void gui::textbox::draw_cursor ( int  pos,
CVideo video 
) const [private]

Definition at line 131 of file textbox.cpp.

References gui2::create_rect(), editable_, CVideo::getSurface(), h, gui::widget::location(), sdl_fill_rect(), and show_cursor_.

Referenced by draw_contents().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui::textbox::editable (  )  const

Definition at line 210 of file textbox.cpp.

References editable_.

void gui::textbox::erase_selection (  )  [private]

Definition at line 330 of file textbox.cpp.

References cursor_, is_selection(), selend_, selstart_, and text_.

Referenced by handle_event().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::handle_event ( const SDL_Event &  event  )  [private, virtual]
virtual void gui::textbox::handle_text_changed ( const wide_string  )  [inline, private, virtual]

Reimplemented in gui::filter_textbox.

Definition at line 50 of file textbox.hpp.

Referenced by append_text(), clear(), handle_event(), and set_text().

Here is the caller graph for this function:

bool gui::textbox::is_selection (  )  [private]

Definition at line 325 of file textbox.cpp.

References selend_, and selstart_.

Referenced by draw_contents(), erase_selection(), and handle_event().

Here is the caller graph for this function:

bool gui::textbox::requires_event_focus ( const SDL_Event *  event = NULL  )  const [private, virtual]

Reimplemented from events::handler.

Definition at line 351 of file textbox.cpp.

References editable_, gui::widget::focus_, and gui::widget::hidden().

Here is the call graph for this function:

void gui::textbox::scroll ( unsigned int  pos  )  [protected, virtual]

Implements gui::scrollarea.

Definition at line 229 of file textbox.cpp.

References gui::widget::set_dirty(), and yscroll_.

Here is the call graph for this function:

void gui::textbox::scroll_to_bottom (  ) 

Definition at line 215 of file textbox.cpp.

References gui::scrollarea::get_max_position(), and gui::scrollarea::set_position().

Referenced by append_text().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::set_editable ( bool  value  ) 

Definition at line 205 of file textbox.cpp.

References editable_.

Referenced by mp::lobby::lobby(), and mp::lobby::process_event().

Here is the caller graph for this function:

void gui::textbox::set_inner_location ( SDL_Rect const &  rect  )  [protected, virtual]

Implements gui::scrollarea.

Definition at line 52 of file textbox.cpp.

References gui::widget::bg_register(), surface::null(), text_image_, text_pos_, and update_text_cache().

Here is the call graph for this function:

void gui::textbox::set_text ( const std::string &  text,
const SDL_Color &  color = font::NORMAL_COLOR 
)

Definition at line 67 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(), gui::filter_textbox::filter_textbox(), mp::ui::handle_key_event(), and mp::lobby::lobby().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::set_wrap ( bool  val  ) 

Definition at line 220 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().

Here is the call graph for this function:

Here is the caller graph for this function:

bool gui::textbox::show_scrollbar (  )  const [private]
const std::string gui::textbox::text (  )  const

Definition at line 60 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::lobby::process_event(), mp::create::process_event(), and gui::dialog::textbox_text().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui::textbox::update_text_cache ( bool  reset = false,
const SDL_Color &  color = font::NORMAL_COLOR 
) [private]

Member Data Documentation

double gui::textbox::alpha_ [private]

Definition at line 80 of file textbox.hpp.

Referenced by draw_contents().

double gui::textbox::alpha_focus_ [private]

Definition at line 81 of file textbox.hpp.

Referenced by draw_contents().

std::vector<int> gui::textbox::char_x_ [private]

Definition at line 64 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 64 of file textbox.hpp.

Referenced by add_text_line(), draw_contents(), handle_event(), and update_text_cache().

int gui::textbox::cursor_ [private]

Definition at line 57 of file textbox.hpp.

Referenced by clear(), erase_selection(), handle_event(), set_text(), and update_text_cache().

Definition at line 63 of file textbox.hpp.

Referenced by clear(), draw_contents(), and update_text_cache().

bool gui::textbox::editable_ [private]

Definition at line 66 of file textbox.hpp.

Referenced by draw_cursor(), editable(), handle_event(), requires_event_focus(), and set_editable().

bool gui::textbox::grabmouse_ [private]

Definition at line 60 of file textbox.hpp.

Referenced by handle_event().

size_t gui::textbox::line_height_ [private]

Definition at line 78 of file textbox.hpp.

Referenced by add_text_line(), draw_contents(), and handle_event().

size_t gui::textbox::max_size_ [private]

Definition at line 52 of file textbox.hpp.

Referenced by handle_event().

int gui::textbox::selend_ [private]

Definition at line 59 of file textbox.hpp.

Referenced by clear(), draw_contents(), erase_selection(), handle_event(), is_selection(), and set_text().

int gui::textbox::selstart_ [private]

Definition at line 58 of file textbox.hpp.

Referenced by clear(), draw_contents(), erase_selection(), handle_event(), is_selection(), and set_text().

Definition at line 68 of file textbox.hpp.

Referenced by draw_cursor(), and handle_event().

Definition at line 73 of file textbox.hpp.

Referenced by handle_event().

int gui::textbox::text_pos_ [private]
bool gui::textbox::wrap_ [private]

Definition at line 76 of file textbox.hpp.

Referenced by add_text_line(), append_text(), and set_wrap().

size_t gui::textbox::yscroll_ [private]

Definition at line 78 of file textbox.hpp.

Referenced by draw_contents(), handle_event(), and scroll().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:21:40 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs