The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
help::help_browser Class Reference

A help browser widget. More...

#include <help_browser.hpp>

Inheritance diagram for help::help_browser:
Inheritance graph

Public Member Functions

 help_browser (CVideo &video, const section &toplevel)
 
void adjust_layout ()
 
void show_topic (const std::string &topic_id)
 Display the topic with the specified identifier. More...
 
- Public Member Functions inherited from gui::widget
const SDL_Rect & location () const
 
virtual void set_location (const SDL_Rect &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)
 
virtual void hide (bool value=true)
 
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)
 
virtual void draw ()
 
- 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 ()
 
virtual bool has_joined ()
 
virtual bool has_joined_global ()
 
sdl_handleroperator= (sdl_handler &&)=delete
 Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More...
 
 sdl_handler (sdl_handler &&)=delete
 

Protected Member Functions

virtual void update_location (const SDL_Rect &rect)
 
virtual void process_event ()
 
virtual void handle_event (const SDL_Event &event)
 
- Protected Member Functions inherited from gui::widget
 widget (CVideo &video, const bool auto_join=true)
 
virtual ~widget ()
 
void bg_register (const SDL_Rect &rect)
 
void bg_restore () const
 
void bg_restore (const SDL_Rect &rect) const
 
void bg_update ()
 
void bg_cancel ()
 
CVideovideo () const
 
virtual void draw_contents ()
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_window_event (const SDL_Event &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)
 
 sdl_handler (const sdl_handler &)
 
sdl_handleroperator= (const sdl_handler &)
 
virtual ~sdl_handler ()
 
virtual std::vector< sdl_handler * > handler_members ()
 

Private Member Functions

void update_cursor ()
 Update the current cursor, set it to the reference cursor if mousex, mousey is over a cross-reference, otherwise, set it to the normal cursor. More...
 
void show_topic (const topic &t, bool save_in_history=true)
 
void move_in_history (std::deque< const topic *> &from, std::deque< const topic *> &to)
 Move in the topic history. More...
 

Private Attributes

help_menu menu_
 
help_text_area text_area_
 
const sectiontoplevel_
 
bool ref_cursor_
 
std::deque< const topic * > back_topics_
 
std::deque< const topic * > forward_topics_
 
gui::button back_button_
 
gui::button forward_button_
 
topic const * shown_topic_
 

Additional Inherited Members

- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

A help browser widget.

Definition at line 30 of file help_browser.hpp.

Constructor & Destructor Documentation

◆ help_browser()

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

Member Function Documentation

◆ adjust_layout()

void help::help_browser::adjust_layout ( )

◆ handle_event()

void help::help_browser::handle_event ( const SDL_Event &  event)
protectedvirtual

◆ move_in_history()

void help::help_browser::move_in_history ( std::deque< const topic *> &  from,
std::deque< const topic *> &  to 
)
private

Move in the topic history.

Pop an element from from and insert it in to. Pop at the fronts if the maximum number of elements is exceeded.

Definition at line 120 of file help_browser.cpp.

References help::max_history, show_topic(), and shown_topic_.

Referenced by handle_event(), and process_event().

◆ process_event()

void help::help_browser::process_event ( )
protectedvirtual

Fake focus functionality for the menu, only process it if it has focus.

A new topic has been chosen in the menu, display it.

Reimplemented from events::sdl_handler.

Definition at line 95 of file help_browser.cpp.

References back_button_, back_topics_, help::help_menu::chosen_topic(), forward_button_, forward_topics_, gui::widget::hide(), gui::widget::location(), menu_, move_in_history(), sdl::point_in_rect(), gui::button::pressed(), help::help_menu::process(), show_topic(), and shown_topic_.

◆ show_topic() [1/2]

void help::help_browser::show_topic ( const std::string &  topic_id)

Display the topic with the specified identifier.

Open the menu on the right location and display the topic in the text area.

Definition at line 207 of file help_browser.cpp.

References help::find_topic(), help::hidden_symbol(), t, toplevel_, help::unit_prefix, and help::unknown_unit_topic.

Referenced by handle_event(), move_in_history(), process_event(), and help::show_help().

◆ show_topic() [2/2]

void help::help_browser::show_topic ( const topic t,
bool  save_in_history = true 
)
private

◆ update_cursor()

void help::help_browser::update_cursor ( )
private

Update the current cursor, set it to the reference cursor if mousex, mousey is over a cross-reference, otherwise, set it to the normal cursor.

Definition at line 192 of file help_browser.cpp.

References cursor::HYPERLINK, cursor::NORMAL, help::help_text_area::ref_at(), ref_cursor_, cursor::set(), and text_area_.

Referenced by handle_event(), and show_topic().

◆ update_location()

void help::help_browser::update_location ( const SDL_Rect &  rect)
protectedvirtual

Reimplemented from gui::widget.

Definition at line 90 of file help_browser.cpp.

References adjust_layout().

Member Data Documentation

◆ back_button_

gui::button help::help_browser::back_button_
private

Definition at line 61 of file help_browser.hpp.

Referenced by adjust_layout(), handle_event(), help_browser(), and process_event().

◆ back_topics_

std::deque<const topic *> help::help_browser::back_topics_
private

Definition at line 60 of file help_browser.hpp.

Referenced by handle_event(), process_event(), and show_topic().

◆ forward_button_

gui::button help::help_browser::forward_button_
private

Definition at line 61 of file help_browser.hpp.

Referenced by adjust_layout(), handle_event(), help_browser(), and process_event().

◆ forward_topics_

std::deque<const topic *> help::help_browser::forward_topics_
private

Definition at line 60 of file help_browser.hpp.

Referenced by handle_event(), process_event(), and show_topic().

◆ menu_

help_menu help::help_browser::menu_
private

Definition at line 56 of file help_browser.hpp.

Referenced by adjust_layout(), process_event(), and show_topic().

◆ ref_cursor_

bool help::help_browser::ref_cursor_
private

Definition at line 59 of file help_browser.hpp.

Referenced by update_cursor().

◆ shown_topic_

topic const* help::help_browser::shown_topic_
private

Definition at line 62 of file help_browser.hpp.

Referenced by move_in_history(), process_event(), and show_topic().

◆ text_area_

help_text_area help::help_browser::text_area_
private

Definition at line 57 of file help_browser.hpp.

Referenced by adjust_layout(), handle_event(), show_topic(), and update_cursor().

◆ toplevel_

const section& help::help_browser::toplevel_
private

Definition at line 58 of file help_browser.hpp.

Referenced by handle_event(), and show_topic().


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