ManaPlus
popup.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  * Copyright (C) 2009 Aethyra Development Team
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_WIDGETS_POPUP_H
25 #define GUI_WIDGETS_POPUP_H
26 
27 #include "gui/widgets/container.h"
28 
31 
32 class ImageCollection;
33 class Skin;
34 class WindowContainer;
35 
48 class Popup notfinal : public Container,
49  public MouseListener,
50  public WidgetListener
51 {
52  public:
61  Popup(const std::string &name,
62  std::string skin);
63 
65 
66 
69  ~Popup() override;
70 
75 
79  void draw(Graphics *const graphics) override A_NONNULL(2);
80 
81  void safeDraw(Graphics *const graphics) override A_NONNULL(2);
82 
86  void setContentSize(int width, int height);
87 
91  void setLocationRelativeTo(const Widget *const widget);
92 
93  void mouseMoved(MouseEvent &event) override;
94 
98  void setMinWidth(const int width);
99 
101  { return mMinWidth; }
102 
106  void setMinHeight(const int height);
107 
109  { return mMinHeight; }
110 
114  void setMaxWidth(const int width);
115 
117  { return mMaxWidth; }
118 
122  void setMaxHeight(const int height);
123 
125  { return mMaxHeight; }
126 
135  { return mPadding; }
136 
137  void setPadding(int padding) noexcept2
138  { mPadding = padding; }
139 
143  void setPopupName(const std::string &name) noexcept2
144  { mPopupName = name; }
145 
146  const std::string &getPopupName() const noexcept2
147  { return mPopupName; }
148 
153  void scheduleDelete();
154 
155  // Inherited from BasicContainer
156 
157  Rect getChildrenArea() override;
158 
165  void position(const int x, const int y);
166 
167  void hide();
168 
169  void widgetResized(const Event &event) override;
170 
171  void widgetMoved(const Event &event) override final;
172 
174  { return mVisible == Visible_true; }
175 
176  void postInit() override
177  { mInit = true; }
178 
179  protected:
180  int mPadding;
183  private:
184  std::string mPopupName;
186  int mMinWidth;
188  int mMaxWidth;
190  bool mInit;
191 };
192 
193 #endif // GUI_WIDGETS_POPUP_H
int getMinHeight() const
Definition: popup.h:108
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
void setMaxHeight(const int height)
Definition: popup.cpp:222
int getPadding() const
Definition: popup.h:134
void setContentSize(int width, int height)
Definition: popup.cpp:154
Definition: skin.h:35
void setMinHeight(const int height)
Definition: popup.cpp:204
Popup(const std::string &name, std::string skin)
Definition: popup.cpp:39
#define A_NONNULLPOINTER
Definition: localconsts.h:294
const bool Visible_true
Definition: visible.h:29
int getMinWidth() const
Definition: popup.h:100
WindowContainer * windowContainer
const std::string & getPopupName() const
Definition: popup.h:146
void setPopupName(const std::string &name)
Definition: popup.h:143
Definition: rect.h:72
void postInit()
Definition: popup.h:176
#define A_WARN_UNUSED
Definition: localconsts.h:172
void safeDraw(Graphics *const graphics)
Definition: popup.cpp:132
void setMinWidth(const int width)
Definition: popup.cpp:191
bool isPopupVisible() const
Definition: popup.h:173
int mPadding
Definition: popup.h:180
#define A_NONNULL(...)
Definition: localconsts.h:179
Visible mVisible
Definition: widget.h:962
int mMaxHeight
Definition: popup.h:189
void hide()
Definition: popup.cpp:262
int mMaxWidth
Definition: popup.h:188
void scheduleDelete()
Definition: popup.cpp:227
void mouseMoved(MouseEvent &event)
Definition: popup.cpp:252
int getMaxHeight() const
Definition: popup.h:124
void setLocationRelativeTo(const Widget *const widget)
Definition: popup.cpp:173
void position(const int x, const int y)
Definition: popup.cpp:232
#define notfinal
Definition: localconsts.h:289
int mMinWidth
Definition: popup.h:186
bool mInit
Definition: popup.h:190
int getMaxWidth() const
Definition: popup.h:116
int mMinHeight
Definition: popup.h:187
void draw(Graphics *const graphics)
Definition: popup.cpp:108
std::string mPopupName
Definition: popup.h:184
static void setWindowContainer(WindowContainer *const windowContainer)
Definition: popup.cpp:103
void widgetMoved(const Event &event)
Definition: popup.cpp:273
Definition: widget.h:97
Definition: event.h:77
Rect getChildrenArea()
Definition: popup.cpp:147
ImageCollection * mVertexes
Definition: popup.h:185
Definition: popup.h:48
void widgetResized(const Event &event)
Definition: popup.cpp:268
void setMaxWidth(const int width)
Definition: popup.cpp:217
void setPadding(int padding)
Definition: popup.h:137
#define noexcept2
Definition: localconsts.h:49
Skin * mSkin
Definition: popup.h:181
~Popup()
Definition: popup.cpp:83