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-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  * Copyright (C) 2009 Aethyra Development Team
8  *
9  * This file is part of The ManaPlus Client.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef GUI_WIDGETS_POPUP_H
26 #define GUI_WIDGETS_POPUP_H
27 
28 #include "gui/widgets/container.h"
29 
32 
33 class ImageCollection;
34 class Skin;
35 class WindowContainer;
36 
49 class Popup notfinal : public Container,
50  public MouseListener,
51  public WidgetListener
52 {
53  public:
62  Popup(const std::string &name,
63  std::string skin);
64 
66 
67 
70  ~Popup() override;
71 
76 
80  void draw(Graphics *const graphics) override A_NONNULL(2);
81 
82  void safeDraw(Graphics *const graphics) override A_NONNULL(2);
83 
87  void setContentSize(int width, int height);
88 
92  void setLocationRelativeTo(const Widget *const widget);
93 
94  void mouseMoved(MouseEvent &event) override;
95 
99  void setMinWidth(const int width);
100 
102  { return mMinWidth; }
103 
107  void setMinHeight(const int height);
108 
110  { return mMinHeight; }
111 
115  void setMaxWidth(const int width);
116 
118  { return mMaxWidth; }
119 
123  void setMaxHeight(const int height);
124 
126  { return mMaxHeight; }
127 
136  { return mPadding; }
137 
138  void setPadding(int padding) noexcept2
139  { mPadding = padding; }
140 
144  void setPopupName(const std::string &name) noexcept2
145  { mPopupName = name; }
146 
147  const std::string &getPopupName() const noexcept2
148  { return mPopupName; }
149 
154  void scheduleDelete();
155 
156  // Inherited from BasicContainer
157 
158  Rect getChildrenArea() override;
159 
166  void position(const int x, const int y);
167 
168  void hide();
169 
170  void widgetResized(const Event &event) override;
171 
172  void widgetMoved(const Event &event) override final;
173 
175  { return mVisible == Visible_true; }
176 
177  void postInit() override
178  { mInit = true; }
179 
180  protected:
181  int mPadding;
184  private:
185  std::string mPopupName;
187  int mMinWidth;
189  int mMaxWidth;
191  bool mInit;
192 };
193 
194 #endif // GUI_WIDGETS_POPUP_H
Definition: event.h:79
Definition: popup.h:52
const std::string & getPopupName() const
Definition: popup.h:147
Skin * mSkin
Definition: popup.h:182
void setPadding(int padding)
Definition: popup.h:138
void scheduleDelete()
Definition: popup.cpp:230
int getMinWidth() const
Definition: popup.h:101
void setMaxHeight(const int height)
Definition: popup.cpp:225
~Popup()
Definition: popup.cpp:84
void setMaxWidth(const int width)
Definition: popup.cpp:220
void setLocationRelativeTo(const Widget *const widget)
Definition: popup.cpp:174
void setPopupName(const std::string &name)
Definition: popup.h:144
void hide()
Definition: popup.cpp:265
int getMaxWidth() const
Definition: popup.h:117
int mMinHeight
Definition: popup.h:188
void draw(Graphics *const graphics)
Definition: popup.cpp:109
static void setWindowContainer(WindowContainer *const windowContainer)
Definition: popup.cpp:104
void setMinHeight(const int height)
Definition: popup.cpp:207
void widgetMoved(const Event &event)
Definition: popup.cpp:276
Popup(const std::string &name, std::string skin)
Definition: popup.cpp:40
int getPadding() const
Definition: popup.h:135
void setMinWidth(const int width)
Definition: popup.cpp:194
std::string mPopupName
Definition: popup.h:185
void setContentSize(int width, int height)
Definition: popup.cpp:155
void safeDraw(Graphics *const graphics)
Definition: popup.cpp:133
int getMinHeight() const
Definition: popup.h:109
ImageCollection * mVertexes
Definition: popup.h:186
void position(const int x, const int y)
Definition: popup.cpp:235
int mMinWidth
Definition: popup.h:187
Rect getChildrenArea()
Definition: popup.cpp:148
int mMaxWidth
Definition: popup.h:189
bool isPopupVisible() const
Definition: popup.h:174
void widgetResized(const Event &event)
Definition: popup.cpp:271
void mouseMoved(MouseEvent &event)
Definition: popup.cpp:255
int mMaxHeight
Definition: popup.h:190
int mPadding
Definition: popup.h:181
int getMaxHeight() const
Definition: popup.h:125
void postInit()
Definition: popup.h:177
bool mInit
Definition: popup.h:191
Definition: rect.h:74
Definition: skin.h:37
Definition: widget.h:99
Visible mVisible
Definition: widget.h:963
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
const bool Visible_true
Definition: visible.h:30
WindowContainer * windowContainer