1 /* 2 * The ManaPlus Client 3 * Copyright (C) 2004-2009 The Mana World Development Team 4 * Copyright (C) 2009-2010 The Mana Developers 5 * Copyright (C) 2011-2019 The ManaPlus Developers 6 * Copyright (C) 2019-2021 Andrei Karas 7 * 8 * This file is part of The ManaPlus Client. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef GUI_WINDOWS_HELPWINDOW_H 25 #define GUI_WINDOWS_HELPWINDOW_H 26 27 #include "gui/widgets/linkhandler.h" 28 #include "gui/widgets/window.h" 29 30 #include "listeners/actionlistener.h" 31 32 #include "localconsts.h" 33 34 class Button; 35 class ScrollArea; 36 class StaticBrowserBox; 37 38 typedef std::set<std::string> HelpNames; 39 typedef HelpNames::const_iterator HelpNamesCIter; 40 typedef std::map<std::string, HelpNames> HelpTagsMap; 41 42 /** 43 * The help window. 44 */ 45 class HelpWindow final : public Window, 46 public LinkHandler, 47 public ActionListener 48 { 49 public: 50 /** 51 * Constructor. 52 */ 53 HelpWindow(); 54 55 A_DELETE_COPY(HelpWindow) 56 57 /** 58 * Called when receiving actions from the widgets. 59 */ 60 void action(const ActionEvent &event) override final; 61 62 /** 63 * Handles link action. 64 */ 65 void handleLink(const std::string &link, 66 MouseEvent *const event A_UNUSED) override final; 67 68 /** 69 * Loads help in the dialog. 70 */ 71 void loadHelp(const std::string &helpFile); 72 73 void loadHelpSimple(const std::string &helpFile); 74 75 /** 76 * Seach for given text in tags. 77 */ 78 void search(const std::string &text); 79 80 private: 81 void loadTags(); 82 83 void loadFile(std::string file); 84 85 Button *mDYKButton A_NONNULLPOINTER; 86 StaticBrowserBox *mBrowserBox A_NONNULLPOINTER; 87 ScrollArea *mScrollArea A_NONNULLPOINTER; 88 HelpTagsMap mTagFileMap; 89 }; 90 91 extern HelpWindow *helpWindow; 92 93 #endif // GUI_WINDOWS_HELPWINDOW_H 94