The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
help::help_menu Class Reference

The menu to the left in the help browser, where topics can be navigated through and chosen. More...

#include <help_menu.hpp>

Inheritance diagram for help::help_menu:
Inheritance graph

Classes

struct  visible_item
 Information about an item that is visible in the menu. More...
 

Public Member Functions

 help_menu (CVideo &video, const section &toplevel, int max_height=-1)
 
int process ()
 
void select_topic (const topic &t)
 Make the topic the currently selected one, and expand all sections that need to be expanded to show it. More...
 
const topicchosen_topic ()
 If a topic has been chosen, return that topic, otherwise nullptr. More...
 
- Public Member Functions inherited from gui::menu
 menu (CVideo &video, const std::vector< std::string > &items, bool click_selects=false, int max_height=-1, int max_width=-1, const sorter *sorter_obj=nullptr, style *menu_style=nullptr, const bool auto_join=true)
 
 ~menu ()
 Default implementation, but defined out-of-line for efficiency reasons. More...
 
int selection () const
 
void move_selection (size_t id)
 
void move_selection_keeping_viewport (size_t id)
 
void reset_selection ()
 
const itemget_item (int index) const
 
const itemget_selected_item () const
 
void change_item (int pos1, int pos2, const std::string &str)
 
virtual void erase_item (size_t index)
 
void set_heading (const std::vector< std::string > &heading)
 
virtual void set_items (const std::vector< std::string > &items, bool strip_spaces=true, bool keep_viewport=false)
 Set new items to show and redraw/recalculate everything. More...
 
void set_max_height (const int new_max_height)
 Set a new max height for this menu. More...
 
void set_max_width (const int new_max_width)
 
int get_max_height ()
 
int get_max_width ()
 
size_t number_of_items () const
 
int process ()
 
bool double_clicked ()
 
void set_click_selects (bool value)
 
void set_numeric_keypress_selection (bool value)
 
void scroll (unsigned int pos)
 
void set_sorter (sorter *s)
 
void sort_by (int column)
 
int get_sort_by ()
 
bool get_sort_reversed ()
 
- 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::stringid () 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_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 ()
 

Private Member Functions

void update_visible_items (const section &top_level, unsigned starting_level=0)
 Regenerate what items are visible by checking what sections are expanded. More...
 
bool expanded (const section &sec)
 Return true if the section is expanded. More...
 
void expand (const section &sec)
 Mark a section as expanded. More...
 
void contract (const section &sec)
 Contract (close) a section. More...
 
std::string indent_list (const std::string &icon, const unsigned level)
 Return the string to use as the prefix for the icon part of the menu-string at the specified level. More...
 
std::string get_string_to_show (const section &sec, const unsigned level)
 Return the string to use as the menu-string for sections at the specified level. More...
 
std::string get_string_to_show (const topic &topic, const unsigned level)
 Return the string to use as the menu-string for topics at the specified level. More...
 
void display_visible_items ()
 Draw the currently visible items. More...
 
bool select_topic_internal (const topic &t, const section &sec)
 Internal recursive thingie. More...
 

Private Attributes

std::vector< visible_itemvisible_items_
 
const sectiontoplevel_
 
std::set< const section * > expanded_
 
surface_restorer restorer_
 
topic const * chosen_topic_
 
visible_item selected_item_
 

Additional Inherited Members

- Public Types inherited from gui::menu
enum  ROW_TYPE { NORMAL_ROW, SELECTED_ROW, HEADING_ROW }
 
- Static Public Attributes inherited from gui::menu
static styledefault_style = menu::bluebg_style
 
static style simple_style
 
static imgsel_style bluebg_style
 
- Protected Member Functions inherited from gui::menu
bool item_ends_with_image (const std::string &item) const
 
virtual void handle_event (const SDL_Event &event)
 
void set_inner_location (const SDL_Rect &rect)
 
bool requires_event_focus (const SDL_Event *event=nullptr) const
 
const std::vector< int > & column_widths () const
 
virtual void draw_row (const size_t row_index, const SDL_Rect &rect, ROW_TYPE type)
 
int hit (int x, int y) const
 
std::pair< int, inthit_cell (int x, int y) const
 
int hit_column (int x) const
 
int hit_heading (int x, int y) const
 
void invalidate_row (size_t id)
 
void invalidate_row_pos (size_t pos)
 
void invalidate_heading ()
 
- Protected Member Functions inherited from gui::scrollarea
virtual sdl_handler_vector handler_members ()
 
virtual void update_location (SDL_Rect const &rect)
 
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 ()
 
CVideovideo () const
 
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 ()
 
- Protected Attributes inherited from gui::menu
stylestyle_
 
bool silent_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

The menu to the left in the help browser, where topics can be navigated through and chosen.

Definition at line 31 of file help_menu.hpp.

Constructor & Destructor Documentation

help::help_menu::help_menu ( CVideo video,
const section toplevel,
int  max_height = -1 
)

Member Function Documentation

const topic * help::help_menu::chosen_topic ( )

If a topic has been chosen, return that topic, otherwise nullptr.

If one topic is returned, it will not be returned again, if it is not re-chosen.

Definition at line 197 of file help_menu.cpp.

References chosen_topic_.

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

void help::help_menu::contract ( const section sec)
private

Contract (close) a section.

That is, mark it as not expanded, visible items are not updated.

Definition at line 60 of file help_menu.cpp.

References expanded_, game_config::sounds::menu_contract, and sound::play_UI_sound().

Referenced by process().

void help::help_menu::display_visible_items ( )
private

Draw the currently visible items.

Definition at line 204 of file help_menu.cpp.

References selected_item_, gui::menu::set_items(), and visible_items_.

Referenced by help_menu(), process(), and select_topic().

void help::help_menu::expand ( const section sec)
private

Mark a section as expanded.

Do not update the visible items or anything.

Definition at line 53 of file help_menu.cpp.

References expanded_, help::section::id, game_config::sounds::menu_expand, and sound::play_UI_sound().

Referenced by process(), and select_topic_internal().

bool help::help_menu::expanded ( const section sec)
private

Return true if the section is expanded.

Definition at line 48 of file help_menu.cpp.

References expanded_.

Referenced by get_string_to_show(), process(), and update_visible_items().

std::string help::help_menu::get_string_to_show ( const section sec,
const unsigned  level 
)
private

Return the string to use as the menu-string for sections at the specified level.

Definition at line 102 of file help_menu.cpp.

References help::closed_section_img, expanded(), IMG_TEXT_SEPARATOR, indent_list(), help::open_section_img, and help::section::title.

Referenced by update_visible_items().

std::string help::help_menu::get_string_to_show ( const topic topic,
const unsigned  level 
)
private

Return the string to use as the menu-string for topics at the specified level.

Definition at line 110 of file help_menu.cpp.

References IMG_TEXT_SEPARATOR, indent_list(), help::topic::title, and help::topic_img.

std::string help::help_menu::indent_list ( const std::string icon,
const unsigned  level 
)
private

Return the string to use as the prefix for the icon part of the menu-string at the specified level.

Definition at line 92 of file help_menu.cpp.

References i, IMAGE_PREFIX, and IMG_TEXT_SEPARATOR.

Referenced by get_string_to_show(), and process().

int help::help_menu::process ( )
void help::help_menu::select_topic ( const topic t)

Make the topic the currently selected one, and expand all sections that need to be expanded to show it.

Definition at line 139 of file help_menu.cpp.

References display_visible_items(), select_topic_internal(), selected_item_, toplevel_, update_visible_items(), and visible_items_.

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

bool help::help_menu::select_topic_internal ( const topic t,
const section sec 
)
private

Internal recursive thingie.

did_expand will be true if any section was expanded, otherwise untouched.

Definition at line 118 of file help_menu.cpp.

References expand(), gui2::event::find(), help::topic::id, help::section::sections, and help::section::topics.

Referenced by select_topic().

void help::help_menu::update_visible_items ( const section top_level,
unsigned  starting_level = 0 
)
private

Regenerate what items are visible by checking what sections are expanded.

Definition at line 67 of file help_menu.cpp.

References expanded(), get_string_to_show(), help::is_visible_id(), help::section::sections, help::section::topics, and visible_items_.

Referenced by help_menu(), process(), and select_topic().

Member Data Documentation

topic const* help::help_menu::chosen_topic_
private

Definition at line 97 of file help_menu.hpp.

Referenced by chosen_topic(), and process().

std::set<const section*> help::help_menu::expanded_
private

Definition at line 95 of file help_menu.hpp.

Referenced by contract(), expand(), and expanded().

surface_restorer help::help_menu::restorer_
private

Definition at line 96 of file help_menu.hpp.

visible_item help::help_menu::selected_item_
private

Definition at line 98 of file help_menu.hpp.

Referenced by display_visible_items(), help_menu(), process(), and select_topic().

const section& help::help_menu::toplevel_
private

Definition at line 94 of file help_menu.hpp.

Referenced by help_menu(), process(), and select_topic().

std::vector<visible_item> help::help_menu::visible_items_
private

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