The Battle for Wesnoth  1.19.7+dev
help_browser.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
3  by Charles Dang <exodia339@gmail.com>
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 
19 #include "help/help_impl.hpp"
20 #include <map>
21 #include <vector>
22 
23 class config;
24 class game_config_view;
25 
26 namespace help {
27  struct section;
28 }
29 
30 namespace gui2
31 {
32 class tree_view_node;
33 
34 namespace dialogs
35 {
36 
37 /** Help browser dialog. */
38 class help_browser : public modal_dialog
39 {
40 public:
41  help_browser(const help::section& toplevel, const std::string& initial = "");
42 
44 
45 private:
46  std::string initial_topic_;
48 
49  std::map<std::string, int> parsed_pages_;
50 
51  std::vector<std::string> history_;
52  unsigned history_pos_;
53 
54  virtual const std::string& window_id() const override;
55 
56  virtual void pre_show() override;
57 
58  void on_topic_select();
59  void on_history_navigate(bool backwards);
60 
61  void add_topics_for_section(const help::section& parent_section, tree_view_node& parent_node);
62  tree_view_node& add_topic(const std::string& topic_id, const std::string& topic_title,
63  bool expands, tree_view_node& parent);
64  void show_topic(std::string topic_id, bool add_to_history = true);
65 };
66 
67 } // namespace dialogs
68 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Help browser dialog.
const help::section & toplevel_
void show_topic(std::string topic_id, bool add_to_history=true)
std::map< std::string, int > parsed_pages_
virtual void pre_show() override
Actions to be taken before showing the window.
void on_history_navigate(bool backwards)
tree_view_node & add_topic(const std::string &topic_id, const std::string &topic_title, bool expands, tree_view_node &parent)
virtual const std::string & window_id() const override
The ID of the window to build.
help_browser(const help::section &toplevel, const std::string &initial="")
std::vector< std::string > history_
void add_topics_for_section(const help::section &parent_section, tree_view_node &parent_node)
Abstract base class for all modal dialogs.
widget * parent()
Definition: widget.cpp:170
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
Various uncategorised dialogs.
Generic file dialog.
A section contains topics and sections along with title and ID.
Definition: help_impl.hpp:148