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