The area where the content is shown in the help browser. More...
#include <help_text_area.hpp>
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... | |
Public Member Functions | |
help_text_area (CVideo &video, const section &toplevel) | |
void | show_topic (const topic &t) |
Display the topic. More... | |
std::string | ref_at (const int x, const int y) |
Return the ID that is cross-referenced at the (screen) coordinates x, y. More... | |
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 bool | requires_event_focus (const SDL_Event *=nullptr) const |
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 | scroll (unsigned int pos) |
virtual void | set_inner_location (const SDL_Rect &rect) |
Protected Member Functions inherited from gui::scrollarea | |
virtual sdl_handler_vector | handler_members () |
virtual void | update_location (SDL_Rect const &rect) |
virtual void | handle_event (const SDL_Event &event) |
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 Types | |
enum | ALIGNMENT { LEFT, MIDDLE, RIGHT, HERE } |
Private Member Functions | |
ALIGNMENT | str_to_align (const std::string &s) |
Convert a string to an alignment. More... | |
void | set_items () |
Update the vector with the items of the shown topic, creating surfaces for everything and putting things where they belong. More... | |
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="", bool broken_link=false, int font_size=-1, bool bold=false, bool italic=false, SDL_Color color=font::NORMAL_COLOR) |
Add an item with text. More... | |
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. More... | |
void | down_one_line () |
Move the current input point to the next line. More... | |
void | adjust_last_row () |
Adjust the heights of the items in the last row to make it look good . More... | |
int | get_remaining_width () |
Return the width that remain on the line the current input point is at. More... | |
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. More... | |
int | get_max_x (const int y, const int height=0) |
Analogous with get_min_x but return the maximum X. More... | |
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. More... | |
void | add_item (const item &itm) |
Add an item to the internal list, update the locations and row height. More... | |
Private Attributes | |
std::list< item > | items_ |
std::list< item * > | last_row_ |
const section & | toplevel_ |
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. More... | |
Additional Inherited Members | |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
The area where the content is shown in the help browser.
Definition at line 34 of file help_text_area.hpp.
|
private |
Enumerator | |
---|---|
LEFT | |
MIDDLE | |
RIGHT | |
HERE |
Definition at line 51 of file help_text_area.hpp.
Definition at line 37 of file help_text_area.cpp.
References gui::scrollarea::set_scroll_rate().
|
private |
Add an image item with the specified attributes.
Definition at line 366 of file help_text_area.cpp.
References add_item(), help::box_width, curr_loc_, curr_row_height_, down_one_line(), image::get_image(), get_min_x(), get_y_for_floating_img(), HERE, gui::scrollarea::inner_location(), LEFT, MIDDLE, surface::null(), RIGHT, str_to_align(), surf, and WRN_DP.
Referenced by handle_img_cfg().
Add an item to the internal list, update the locations and row height.
Definition at line 460 of file help_text_area.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().
|
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 294 of file help_text_area.cpp.
References add_item(), font::BAD_COLOR, curr_loc_, curr_row_height_, down_one_line(), gui::font_size, help::get_first_word(), get_min_x(), get_remaining_width(), font::get_rendered_text(), font::line_width(), help::normal_font_size, surface::null(), help::remove_first_space(), help::split_in_width(), surf, and font::YELLOW_COLOR.
Referenced by handle_bold_cfg(), handle_format_cfg(), handle_header_cfg(), handle_italic_cfg(), handle_ref_cfg(), and set_items().
|
private |
Adjust the heights of the items in the last row to make it look good .
Definition at line 504 of file help_text_area.cpp.
References curr_row_height_, last_row_, and help::help_text_area::item::rect.
Referenced by down_one_line().
|
private |
Move the current input point to the next line.
Definition at line 494 of file help_text_area.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().
|
privatevirtual |
Reimplemented from gui::widget.
Definition at line 519 of file help_text_area.cpp.
References gui::widget::bg_restore(), help::box_width, sdl::draw_rectangle(), gui::scrollarea::get_position(), CVideo::getSurface(), i, gui::scrollarea::inner_location(), items_, resources::screen, sdl_blit(), update_rect(), and gui::widget::video().
Analogous with get_min_x but return the maximum X.
Definition at line 441 of file help_text_area.cpp.
References help::help_text_area::item::align, help::help_text_area::item::floating, gui::scrollarea::inner_location(), items_, MIDDLE, help::help_text_area::item::rect, and RIGHT.
Referenced by get_remaining_width(), and handle_jump_cfg().
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 427 of file help_text_area.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().
|
private |
Return the width that remain on the line the current input point is at.
Definition at line 513 of file help_text_area.cpp.
References curr_loc_, curr_row_height_, and get_max_x().
Referenced by add_text_item().
|
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 412 of file help_text_area.cpp.
References help::help_text_area::item::floating, items_, help::help_text_area::item::rect, and gui::widget::width().
Referenced by add_img_item().
Definition at line 216 of file help_text_area.cpp.
References add_text_item().
Definition at line 281 of file help_text_area.cpp.
References add_text_item(), help::bold(), gui::font_size, help::normal_font_size, and help::string_to_color().
Definition at line 234 of file help_text_area.cpp.
References add_text_item(), and help::title2_size.
Definition at line 204 of file help_text_area.cpp.
References add_img_item().
Definition at line 225 of file help_text_area.cpp.
References add_text_item().
Definition at line 243 of file help_text_area.cpp.
References amount, curr_loc_, curr_row_height_, down_one_line(), get_max_x(), help::jump_to(), and lexical_cast().
Definition at line 160 of file help_text_area.cpp.
References add_text_item(), game_config::debug, help::find_topic(), game_logic::msg(), toplevel_, and write().
std::string help::help_text_area::ref_at | ( | const int | x, |
const int | y | ||
) |
Return the ID that is cross-referenced at the (screen) coordinates x, y.
If no cross-reference is there, return the empty string.
Definition at line 557 of file help_text_area.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().
Implements gui::scrollarea.
Definition at line 545 of file help_text_area.cpp.
References gui::widget::set_dirty().
|
protectedvirtual |
Implements gui::scrollarea.
Definition at line 52 of file help_text_area.cpp.
References gui::widget::bg_register(), set_items(), and shown_topic_.
|
private |
Update the vector with the items of the shown topic, creating surfaces for everything and putting things where they belong.
Definition at line 98 of file help_text_area.cpp.
References add_item(), add_text_item(), help::bold(), contents_height_, curr_loc_, curr_row_height_, down_one_line(), e, font::get_rendered_text(), gui::widget::height(), gui::scrollarea::inner_location(), items_, help::jump(), last_row_, font::make_text_ellipsis(), game::error::message, min_row_height_, game_logic::msg(), font::NORMAL_COLOR, help::topic_text::parsed_text(), read(), gui::scrollarea::set_full_size(), gui::scrollarea::set_position(), gui::scrollarea::set_shown_size(), shown_topic_, surf, help::topic::text, help::topic::title, help::title_size, title_spacing_, and TRY.
Referenced by set_inner_location(), and show_topic().
Display the topic.
Definition at line 59 of file help_text_area.cpp.
References gui::widget::set_dirty(), set_items(), and shown_topic_.
Referenced by help::help_browser::show_topic().
|
private |
Convert a string to an alignment.
Throw parse_error if unsuccessful.
Definition at line 478 of file help_text_area.cpp.
References HERE, LEFT, MIDDLE, game_logic::msg(), and RIGHT.
Referenced by add_img_item().
|
private |
The height of all items in total.
Definition at line 165 of file help_text_area.hpp.
Referenced by add_item(), down_one_line(), and set_items().
Definition at line 161 of file help_text_area.hpp.
Referenced by add_img_item(), add_item(), add_text_item(), down_one_line(), get_remaining_width(), handle_jump_cfg(), and set_items().
|
private |
Definition at line 163 of file help_text_area.hpp.
Referenced by add_img_item(), add_item(), add_text_item(), adjust_last_row(), down_one_line(), get_remaining_width(), handle_jump_cfg(), and set_items().
|
private |
Definition at line 155 of file help_text_area.hpp.
Referenced by add_item(), draw_contents(), get_max_x(), get_min_x(), get_y_for_floating_img(), ref_at(), and set_items().
|
private |
Definition at line 156 of file help_text_area.hpp.
Referenced by add_item(), adjust_last_row(), down_one_line(), and set_items().
|
private |
Definition at line 162 of file help_text_area.hpp.
Referenced by down_one_line(), and set_items().
|
private |
Definition at line 158 of file help_text_area.hpp.
Referenced by set_inner_location(), set_items(), and show_topic().
|
private |
Definition at line 159 of file help_text_area.hpp.
Referenced by set_items().
|
private |
Definition at line 157 of file help_text_area.hpp.
Referenced by handle_ref_cfg().