The Battle for Wesnoth  1.17.0-dev
help_browser.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2021
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <deque> // for deque
19 #include <string> // for string
20 #include <SDL2/SDL_events.h> // for SDL_Event
21 #include "help_menu.hpp" // for help_menu
22 #include "help_text_area.hpp" // for help_text_area
23 #include "widgets/button.hpp" // for button
24 #include "widgets/widget.hpp" // for widget
25 class CVideo; // lines 18-18
26 struct SDL_Rect;
27 
28 namespace help {
29 
30 /** A help browser widget. */
31 class help_browser : public gui::widget
32 {
33 public:
34  help_browser(CVideo& video, const section &toplevel);
35 
36  void adjust_layout();
37 
38  /**
39  * Display the topic with the specified identifier. Open the menu
40  * on the right location and display the topic in the text area.
41  */
42  void show_topic(const std::string &topic_id);
43 
44 protected:
45  virtual void update_location(const SDL_Rect& rect);
46  virtual void process_event();
47  virtual void handle_event(const SDL_Event &event);
48 
49 private:
50  /**
51  * Update the current cursor, set it to the reference cursor if
52  * mousex, mousey is over a cross-reference, otherwise, set it to
53  * the normal cursor.
54  */
55  void update_cursor();
56  void show_topic(const topic &t, bool save_in_history=true);
57  /**
58  * Move in the topic history. Pop an element from from and insert
59  * it in to. Pop at the fronts if the maximum number of elements is
60  * exceeded.
61  */
62  void move_in_history(std::deque<const topic *> &from, std::deque<const topic *> &to);
66  bool ref_cursor_; // If the cursor currently is the hyperlink cursor.
67  std::deque<const topic *> back_topics_, forward_topics_;
70 };
71 
72 } // end namespace help
void update_cursor()
Update the current cursor, set it to the reference cursor if mousex, mousey is over a cross-reference...
virtual void update_location(const SDL_Rect &rect)
gui::button forward_button_
A section contains topics and sections along with title and ID.
Definition: help_impl.hpp:146
topic const * shown_topic_
Definition: video.hpp:32
virtual void handle_event(const SDL_Event &event)
help_browser(CVideo &video, const section &toplevel)
std::deque< const topic * > forward_topics_
const section & toplevel_
std::deque< const topic * > back_topics_
The area where the content is shown in the help browser.
gui::button back_button_
void move_in_history(std::deque< const topic *> &from, std::deque< const topic *> &to)
Move in the topic history.
A button is a control that can be pushed to start an action or close a dialog.
Definition: button.hpp:50
void show_topic(const std::string &topic_id)
Display the topic with the specified identifier.
virtual void process_event()
CVideo & video() const
Definition: widget.hpp:84
double t
Definition: astarsearch.cpp:65
The menu to the left in the help browser, where topics can be navigated through and chosen...
Definition: help_menu.hpp:35
A topic contains a title, an id and some text.
Definition: help_impl.hpp:112
Definition: help.cpp:57
A help browser widget.
help_text_area text_area_