ManaPlus
windowmenu.h
Go to the documentation of this file.
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-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef GUI_WINDOWMENU_H
24 #define GUI_WINDOWMENU_H
25 
27 
28 #include "gui/widgets/container.h"
29 
33 
34 #include "localconsts.h"
35 
36 class Button;
37 class ImageSet;
38 
39 struct ButtonInfo;
40 struct ButtonText;
41 
48 class WindowMenu final : public Container,
49  public ConfigListener,
50  public ActionListener,
51  public SelectionListener,
52  public MouseListener
53 {
54  public:
55  explicit WindowMenu(const Widget2 *const widget);
56 
58 
59  ~WindowMenu() override final;
60 
61  void action(const ActionEvent &event) override final;
62 
63  void mousePressed(MouseEvent &event) override final;
64 
65  void mouseMoved(MouseEvent &event) override final;
66 
67  void mouseExited(MouseEvent& event A_UNUSED) override final;
68 
69  std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
70  { return mButtonNames; }
71 
72  STD_VECTOR <Button*> &getButtons() A_WARN_UNUSED
73  { return mButtons; }
74 
75  STD_VECTOR <ButtonText*> &getButtonTexts() A_WARN_UNUSED
76  { return mButtonTexts; }
77 
78  void showButton(const std::string &name, const Visible visible);
79 
80  void loadButtons();
81 
82  void saveButtons() const;
83 
84  void optionChanged(const std::string &name) override final;
85 
86 #ifdef USE_PROFILER
87  void logicChildren();
88 #endif // USE_PROFILER
89 
90  protected:
91  void drawChildren(Graphics *const graphics) override final
92  A_NONNULL(2);
93 
94  void safeDrawChildren(Graphics *const graphics) override final
95  A_NONNULL(2);
96 
97  private:
98  inline void addButton(const char *const text,
99  const int iconNumber,
100  const std::string &description,
101  int &restrict x, int &restrict h,
102  const InputActionT key,
103  const Visible visible);
104 
105  void updateButtons();
106 
109  int mPadding;
110  int mSpacing;
111  STD_VECTOR <Button*> mButtons;
112  STD_VECTOR <ButtonText*> mButtonTexts;
113  std::map <std::string, ButtonInfo*> mButtonNames;
117 };
118 
119 extern WindowMenu *windowMenu;
120 
121 #endif // GUI_WINDOWMENU_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
WindowMenu(const Widget2 *const widget)
Definition: windowmenu.cpp:52
void updateButtons()
Definition: windowmenu.cpp:458
Definition: skin.h:35
void mousePressed(MouseEvent &event)
Definition: windowmenu.cpp:376
void optionChanged(const std::string &name)
Definition: windowmenu.cpp:577
std::vector< ButtonText * > mButtonTexts
Definition: windowmenu.h:112
bool mSmallWindow
Definition: windowmenu.h:116
std::vector< Button * > & getButtons()
Definition: windowmenu.h:72
void showButton(const std::string &name, const Visible visible)
Definition: windowmenu.cpp:446
int mAutoHide
Definition: windowmenu.h:115
std::vector< ButtonText * > & getButtonTexts()
Definition: windowmenu.h:75
#define A_WARN_UNUSED
Definition: localconsts.h:152
int mSpacing
Definition: windowmenu.h:110
Definition: button.h:96
#define final
Definition: localconsts.h:45
ImageSet * mImageSet
Definition: windowmenu.h:108
#define A_NONNULL(...)
Definition: localconsts.h:159
void saveButtons() const
Definition: windowmenu.cpp:536
void loadButtons()
Definition: windowmenu.cpp:483
void action(const ActionEvent &event)
Definition: windowmenu.cpp:307
void addButton(const char *const text, const int iconNumber, const std::string &description, int &x, int &h, const InputActionT key, const Visible visible)
Definition: windowmenu.cpp:322
virtual void logicChildren()
bool mHaveMouse
Definition: windowmenu.h:114
int mPadding
Definition: windowmenu.h:109
InputAction ::T InputActionT
Definition: inputaction.h:715
void mouseExited(MouseEvent &event)
Definition: windowmenu.cpp:437
#define A_UNUSED
Definition: localconsts.h:151
Skin * mSkin
Definition: windowmenu.h:107
WindowMenu * windowMenu
Definition: windowmenu.cpp:50
#define restrict
Definition: localconsts.h:156
std::map< std::string, ButtonInfo * > & getButtonNames()
Definition: windowmenu.h:69
std::map< std::string, ButtonInfo * > mButtonNames
Definition: windowmenu.h:113
void mouseMoved(MouseEvent &event)
Definition: windowmenu.cpp:398
void safeDrawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:565
std::vector< Button * > mButtons
Definition: windowmenu.h:111
void drawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:553