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 
38 struct ButtonInfo;
39 struct ButtonText;
40 
47 class WindowMenu final : public Container,
48  public ConfigListener,
49  public ActionListener,
50  public SelectionListener,
51  public MouseListener
52 {
53  public:
54  explicit WindowMenu(const Widget2 *const widget);
55 
57 
58  ~WindowMenu() override final;
59 
60  void action(const ActionEvent &event) override final;
61 
62  void mousePressed(MouseEvent &event) override final;
63 
64  void mouseMoved(MouseEvent &event) override final;
65 
66  void mouseExited(MouseEvent& event A_UNUSED) override final;
67 
68  std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
69  { return mButtonNames; }
70 
71  STD_VECTOR <Button*> &getButtons() A_WARN_UNUSED
72  { return mButtons; }
73 
74  STD_VECTOR <ButtonText*> &getButtonTexts() A_WARN_UNUSED
75  { return mButtonTexts; }
76 
77  void showButton(const std::string &name, const Visible visible);
78 
79  void loadButtons();
80 
81  void saveButtons() const;
82 
83  void optionChanged(const std::string &name) override final;
84 
85 #ifdef USE_PROFILER
86  void logicChildren();
87 #endif // USE_PROFILER
88 
89  protected:
90  void drawChildren(Graphics *const graphics) override final
91  A_NONNULL(2);
92 
93  void safeDrawChildren(Graphics *const graphics) override final
94  A_NONNULL(2);
95 
96  private:
97  inline void addButton(const char *const text,
98  const std::string &description,
99  int &restrict x, int &restrict h,
100  const InputActionT key,
101  const Visible visible);
102 
103  void updateButtons();
104 
106  int mPadding;
107  int mSpacing;
108  STD_VECTOR <Button*> mButtons;
109  STD_VECTOR <ButtonText*> mButtonTexts;
110  std::map <std::string, ButtonInfo*> mButtonNames;
114 };
115 
116 extern WindowMenu *windowMenu;
117 
118 #endif // GUI_WINDOWMENU_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
WindowMenu(const Widget2 *const widget)
Definition: windowmenu.cpp:49
void updateButtons()
Definition: windowmenu.cpp:376
Definition: skin.h:35
void mousePressed(MouseEvent &event)
Definition: windowmenu.cpp:294
void optionChanged(const std::string &name)
Definition: windowmenu.cpp:495
std::vector< ButtonText * > mButtonTexts
Definition: windowmenu.h:109
bool mSmallWindow
Definition: windowmenu.h:113
std::vector< Button * > & getButtons()
Definition: windowmenu.h:71
void showButton(const std::string &name, const Visible visible)
Definition: windowmenu.cpp:364
int mAutoHide
Definition: windowmenu.h:112
std::vector< ButtonText * > & getButtonTexts()
Definition: windowmenu.h:74
#define A_WARN_UNUSED
Definition: localconsts.h:172
int mSpacing
Definition: windowmenu.h:107
Definition: button.h:94
#define final
Definition: localconsts.h:45
#define A_NONNULL(...)
Definition: localconsts.h:179
void saveButtons() const
Definition: windowmenu.cpp:454
void loadButtons()
Definition: windowmenu.cpp:401
void action(const ActionEvent &event)
Definition: windowmenu.cpp:258
void addButton(const char *const text, const std::string &description, int &x, int &h, const InputActionT key, const Visible visible)
Definition: windowmenu.cpp:273
virtual void logicChildren()
bool mHaveMouse
Definition: windowmenu.h:111
int mPadding
Definition: windowmenu.h:106
InputAction ::T InputActionT
Definition: inputaction.h:714
void mouseExited(MouseEvent &event)
Definition: windowmenu.cpp:355
#define A_UNUSED
Definition: localconsts.h:171
Skin * mSkin
Definition: windowmenu.h:105
WindowMenu * windowMenu
Definition: windowmenu.cpp:47
#define restrict
Definition: localconsts.h:176
std::map< std::string, ButtonInfo * > & getButtonNames()
Definition: windowmenu.h:68
std::map< std::string, ButtonInfo * > mButtonNames
Definition: windowmenu.h:110
void mouseMoved(MouseEvent &event)
Definition: windowmenu.cpp:316
void safeDrawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:483
std::vector< Button * > mButtons
Definition: windowmenu.h:108
void drawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:471