Mana
Loading...
Searching...
No Matches
popup.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 * Copyright (C) 2009 Aethyra Development Team
6 *
7 * This file is part of The Mana 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#pragma once
24
25#include "guichanfwd.h"
26
28#include "resources/theme.h"
29
30#include <guichan/mouselistener.hpp>
31
32class Skin;
33class WindowContainer;
34
47class Popup : public Container, public gcn::MouseListener
48{
49 public:
58 explicit Popup(const std::string &name = std::string(),
59 SkinType skinType = SkinType::Popup);
60
64 ~Popup() override;
65
70
71 // Container interface
72 void add(gcn::Widget *widget) override;
73 void add(gcn::Widget *widget, int x, int y) override;
74
78 void draw(gcn::Graphics *graphics) override;
79
83 void drawFrame(gcn::Graphics *graphics) override;
84
88 void setContentSize(int width, int height);
89
93 void setLocationRelativeTo(gcn::Widget *widget);
94
95 void mouseMoved(gcn::MouseEvent &event) override;
96
100 void setMinWidth(int width);
101
102 int getMinWidth() const { return mMinWidth; }
103
107 void setMinHeight(int height);
108
109 int getMinHeight() const { return mMinHeight; }
110
114 void setMaxWidth(int width);
115
116 int getMaxWidth() const { return mMaxWidth; }
117
121 void setMaxHeight(int height);
122
123 int getMaxHeight() const { return mMaxHeight; }
124
132 int getPadding() const { return mPadding; }
133
134 void setPadding(int padding) { mPadding = padding; }
135
139 void setPopupName(const std::string &name)
140 { mPopupName = name; }
141
142 const std::string &getPopupName() const
143 { return mPopupName; }
144
149 void scheduleDelete();
150
151 // Inherited from BasicContainer
152
153 gcn::Rectangle getChildrenArea() override;
154
161 void position(int x, int y);
162
166 const Skin &getSkin() const;
167
168 private:
169 void widgetAdded(gcn::Widget *widget) const;
170
171 std::string mPopupName;
172 int mMinWidth = 100;
173 int mMinHeight = 40;
179};
A widget container.
Definition container.h:41
A light version of the Window class.
Definition popup.h:48
SkinType mSkinType
The skin type used when drawing the popup widget.
Definition popup.h:178
const Skin & getSkin() const
Returns the Skin used by this popup.
Definition popup.cpp:200
static void setWindowContainer(WindowContainer *windowContainer)
Sets the window container to be used by new popups.
Definition popup.cpp:64
void setPadding(int padding)
Definition popup.h:134
void scheduleDelete()
Schedule this popup for deletion.
Definition popup.cpp:178
int getMinWidth() const
Definition popup.h:102
void setMinHeight(int height)
Sets the minimum height of the popup.
Definition popup.cpp:163
void add(gcn::Widget *widget) override
Definition popup.cpp:69
void mouseMoved(gcn::MouseEvent &event) override
Definition popup.cpp:205
void setPopupName(const std::string &name)
Sets the name of the popup.
Definition popup.h:139
void setMinWidth(int width)
Sets the minimum width of the popup.
Definition popup.cpp:158
int getMaxWidth() const
Definition popup.h:116
int mMinHeight
Minimum popup height.
Definition popup.h:173
void drawFrame(gcn::Graphics *graphics) override
Draws the popup frame.
Definition popup.cpp:112
int getPadding() const
Gets the padding of the popup.
Definition popup.h:132
void draw(gcn::Graphics *graphics) override
Draws the popup.
Definition popup.cpp:104
std::string mPopupName
Name of the popup.
Definition popup.h:171
void setContentSize(int width, int height)
Sets the size of this popup.
Definition popup.cpp:127
~Popup() override
Destructor.
Definition popup.cpp:59
int getMinHeight() const
Definition popup.h:109
int mMinWidth
Minimum popup width.
Definition popup.h:172
void setMaxWidth(int width)
Sets the maximum width of the popup.
Definition popup.cpp:168
const std::string & getPopupName() const
Definition popup.h:142
int mMaxWidth
Maximum popup width.
Definition popup.h:174
void setMaxHeight(int height)
Sets the minimum height of the popup.
Definition popup.cpp:173
void widgetAdded(gcn::Widget *widget) const
Definition popup.cpp:81
void position(int x, int y)
Sets the location to display the popup.
Definition popup.cpp:183
gcn::Rectangle getChildrenArea() override
Definition popup.cpp:120
int mMaxHeight
Maximum popup height.
Definition popup.h:175
int mPadding
Holds the padding of the popup.
Definition popup.h:176
int getMaxHeight() const
Definition popup.h:123
void setLocationRelativeTo(gcn::Widget *widget)
Sets the location relative to the given widget.
Definition popup.cpp:144
Definition theme.h:154
A window container.
Graphics * graphics
Definition client.cpp:104
SkinType
Definition theme.h:69
WindowContainer * windowContainer