help::help_text_area Class Reference

The area where the content is shown in the help browser. More...

Inheritance diagram for help::help_text_area:

Inheritance graph
[legend]
Collaboration diagram for help::help_text_area:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 help_text_area (CVideo &video, const section &toplevel)
void show_topic (const topic &t)
 Display the topic.
std::string ref_at (const int x, const int y)
 Return the ID that is crossreferenced at the (screen) coordinates x, y.

Protected Member Functions

virtual void scroll (unsigned int pos)
virtual void set_inner_location (const SDL_Rect &rect)

Private Types

enum  ALIGNMENT { LEFT, MIDDLE, RIGHT, HERE }

Private Member Functions

ALIGNMENT str_to_align (const std::string &s)
 Convert a string to an alignment.
void set_items ()
 Update the vector with the items of the shown topic, creating surfaces for everything and putting things where they belong.
void handle_ref_cfg (const config &cfg)
void handle_img_cfg (const config &cfg)
void handle_bold_cfg (const config &cfg)
void handle_italic_cfg (const config &cfg)
void handle_header_cfg (const config &cfg)
void handle_jump_cfg (const config &cfg)
void handle_format_cfg (const config &cfg)
void draw_contents ()
void add_text_item (const std::string text, const std::string ref_dst="", int font_size=-1, bool bold=false, bool italic=false, SDL_Color color=font::NORMAL_COLOUR)
 Add an item with text.
void add_img_item (const std::string path, const std::string alignment, const bool floating, const bool box)
 Add an image item with the specified attributes.
void down_one_line ()
 Move the current input point to the next line.
void adjust_last_row ()
 Adjust the heights of the items in the last row to make it look good .
int get_remaining_width ()
 Return the width that remain on the line the current input point is at.
int get_min_x (const int y, const int height=0)
 Return the least x coordinate at which something of the specified height can be drawn at the specified y coordinate without interfering with floating images.
int get_max_x (const int y, const int height=0)
 Analogous with get_min_x but return the maximum X.
int get_y_for_floating_img (const int width, const int x, const int desired_y)
 Find the lowest y coordinate where a floating img of the specified width and at the specified x coordinate can be placed.
void add_item (const item &itm)
 Add an item to the internal list, update the locations and row height.

Private Attributes

std::list< itemitems_
std::list< item * > last_row_
const sectiontoplevel_
topic const * shown_topic_
const int title_spacing_
std::pair< int, int > curr_loc_
const unsigned min_row_height_
unsigned curr_row_height_
int contents_height_
 The height of all items in total.

Classes

struct  item
 An item that is displayed in the text area. More...
class  item_at
 Function object to find an item at the specified coordinates. More...


Detailed Description

The area where the content is shown in the help browser.

Definition at line 307 of file help.cpp.


Member Enumeration Documentation

Enumerator:
LEFT 
MIDDLE 
RIGHT 
HERE 

Definition at line 324 of file help.cpp.


Constructor & Destructor Documentation

help::help_text_area::help_text_area ( CVideo video,
const section toplevel 
)

Definition at line 1960 of file help.cpp.

References gui::scrollarea::set_scroll_rate().


Member Function Documentation

void help::help_text_area::show_topic ( const topic t  ) 

Display the topic.

Definition at line 1976 of file help.cpp.

References gui::widget::set_dirty(), set_items(), and shown_topic_.

Referenced by help::help_browser::show_topic().

std::string help::help_text_area::ref_at ( const int  x,
const int  y 
)

Return the ID that is crossreferenced at the (screen) coordinates x, y.

If no cross-reference is there, return the empty string.

Definition at line 2480 of file help.cpp.

References gui::scrollarea::get_position(), gui::widget::height(), items_, and gui::widget::location().

Referenced by help::help_browser::handle_event(), and help::help_browser::update_cursor().

void help::help_text_area::scroll ( unsigned int  pos  )  [protected, virtual]

Implements gui::scrollarea.

Definition at line 2468 of file help.cpp.

References gui::widget::set_dirty().

void help::help_text_area::set_inner_location ( const SDL_Rect &  rect  )  [protected, virtual]

Implements gui::scrollarea.

Definition at line 1969 of file help.cpp.

References gui::widget::bg_register(), set_items(), and shown_topic_.

help_text_area::ALIGNMENT help::help_text_area::str_to_align ( const std::string &  s  )  [private]

Convert a string to an alignment.

Throw parse_error if unsuccesful.

Definition at line 2400 of file help.cpp.

References HERE, LEFT, MIDDLE, RIGHT, and help::to_lower().

Referenced by add_img_item().

void help::help_text_area::set_items (  )  [private]

void help::help_text_area::handle_ref_cfg ( const config cfg  )  [private]

Definition at line 2080 of file help.cpp.

References add_text_item(), game_config::debug, help::find_topic(), help::get_bool(), text, toplevel_, and write().

Referenced by set_items().

void help::help_text_area::handle_img_cfg ( const config cfg  )  [private]

Definition at line 2125 of file help.cpp.

References add_img_item(), and help::get_bool().

Referenced by set_items().

void help::help_text_area::handle_bold_cfg ( const config cfg  )  [private]

Definition at line 2140 of file help.cpp.

References add_text_item(), and text.

Referenced by set_items().

void help::help_text_area::handle_italic_cfg ( const config cfg  )  [private]

Definition at line 2149 of file help.cpp.

References add_text_item(), and text.

Referenced by set_items().

void help::help_text_area::handle_header_cfg ( const config cfg  )  [private]

Definition at line 2158 of file help.cpp.

References add_text_item(), and text.

Referenced by set_items().

void help::help_text_area::handle_jump_cfg ( const config cfg  )  [private]

Definition at line 2167 of file help.cpp.

References curr_loc_, curr_row_height_, down_one_line(), get_max_x(), jump_to(), lexical_cast(), and to.

Referenced by set_items().

void help::help_text_area::handle_format_cfg ( const config cfg  )  [private]

Definition at line 2205 of file help.cpp.

References add_text_item(), bold(), font_size, help::get_bool(), lexical_cast(), help::string_to_color(), and text.

Referenced by set_items().

void help::help_text_area::draw_contents (  )  [private, virtual]

void help::help_text_area::add_text_item ( const std::string  text,
const std::string  ref_dst = "",
int  font_size = -1,
bool  bold = false,
bool  italic = false,
SDL_Color  color = font::NORMAL_COLOUR 
) [private]

Add an item with text.

If ref_dst is something else than the empty string, the text item will be underlined to show that it is a cross-reference. The item will also remember what the reference points to. If font_size is below zero, the default will be used.

Definition at line 2225 of file help.cpp.

References add_item(), curr_loc_, curr_row_height_, down_one_line(), font_size, help::get_first_word(), get_min_x(), get_remaining_width(), font::get_rendered_text(), font::line_width(), surface::null(), help::remove_first_space(), help::split_in_width(), and font::YELLOW_COLOUR.

Referenced by handle_bold_cfg(), handle_format_cfg(), handle_header_cfg(), handle_italic_cfg(), handle_ref_cfg(), and set_items().

void help::help_text_area::add_img_item ( const std::string  path,
const std::string  alignment,
const bool  floating,
const bool  box 
) [private]

void help::help_text_area::down_one_line (  )  [private]

Move the current input point to the next line.

Definition at line 2417 of file help.cpp.

References adjust_last_row(), contents_height_, curr_loc_, curr_row_height_, get_min_x(), last_row_, and min_row_height_.

Referenced by add_img_item(), add_text_item(), handle_jump_cfg(), and set_items().

void help::help_text_area::adjust_last_row (  )  [private]

Adjust the heights of the items in the last row to make it look good .

Definition at line 2427 of file help.cpp.

References curr_row_height_, last_row_, and help::help_text_area::item::rect.

Referenced by down_one_line().

int help::help_text_area::get_remaining_width (  )  [private]

Return the width that remain on the line the current input point is at.

Definition at line 2436 of file help.cpp.

References curr_loc_, curr_row_height_, and get_max_x().

Referenced by add_text_item().

int help::help_text_area::get_min_x ( const int  y,
const int  height = 0 
) [private]

Return the least x coordinate at which something of the specified height can be drawn at the specified y coordinate without interfering with floating images.

Definition at line 2349 of file help.cpp.

References help::help_text_area::item::align, help::help_text_area::item::floating, items_, LEFT, and help::help_text_area::item::rect.

Referenced by add_img_item(), add_text_item(), and down_one_line().

int help::help_text_area::get_max_x ( const int  y,
const int  height = 0 
) [private]

int help::help_text_area::get_y_for_floating_img ( const int  width,
const int  x,
const int  desired_y 
) [private]

Find the lowest y coordinate where a floating img of the specified width and at the specified x coordinate can be placed.

Start looking at desired_y and continue downwards. Only check against other floating things, since text and inline images only can be above this place if called correctly.

Definition at line 2334 of file help.cpp.

References help::help_text_area::item::floating, items_, and help::help_text_area::item::rect.

Referenced by add_img_item().

void help::help_text_area::add_item ( const item itm  )  [private]

Add an item to the internal list, update the locations and row height.

Definition at line 2382 of file help.cpp.

References help::help_text_area::item::align, contents_height_, curr_loc_, curr_row_height_, help::help_text_area::item::floating, items_, last_row_, LEFT, and help::help_text_area::item::rect.

Referenced by add_img_item(), add_text_item(), and set_items().


Member Data Documentation

std::list<item> help::help_text_area::items_ [private]

std::list<item *> help::help_text_area::last_row_ [private]

Definition at line 428 of file help.cpp.

Referenced by add_item(), adjust_last_row(), down_one_line(), and set_items().

Definition at line 429 of file help.cpp.

Referenced by handle_ref_cfg().

Definition at line 430 of file help.cpp.

Referenced by set_inner_location(), set_items(), and show_topic().

Definition at line 431 of file help.cpp.

Referenced by set_items().

std::pair<int, int> help::help_text_area::curr_loc_ [private]

const unsigned help::help_text_area::min_row_height_ [private]

Definition at line 434 of file help.cpp.

Referenced by down_one_line(), and set_items().

The height of all items in total.

Definition at line 437 of file help.cpp.

Referenced by add_item(), down_one_line(), and set_items().


The documentation for this class was generated from the following file:

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs