1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/*
* Aethyra
* Copyright (C) 2009 Aethyra Development Team
*
* This file is part of Aethyra based on original code
* from The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef POPUP_H
#define POPUP_H
#include <guichan/widgets/container.hpp>
#include "../graphics.h"
#include "../guichanfwd.h"
class Skin;
class SkinLoader;
class Window;
class WindowContainer;
/**
* A rather reduced down version of the Window class that is particularly suited
* for
*
* \ingroup GUI
*/
class Popup : public gcn::Container
{
public:
/**
* Constructor. Initializes the title to the given text and hooks
* itself into the popup container.
*
* @param name A human readable name for the popup. Only useful for
* debugging purposes.
* @param parent The parent Window. This is the Window standing above
* this one in the Window hiearchy. When reordering,
* a Popup will never go below its parent Window.
* @param skin The location where the Popup's skin XML can be found.
*/
Popup(const std::string& name = "", Window *parent = NULL,
const std::string &skin = "graphics/gui/gui.xml");
/**
* Destructor. Deletes all the added widgets.
*/
~Popup();
/**
* Sets the window container to be used by new popups.
*/
static void setWindowContainer(WindowContainer *windowContainer);
/**
* Changes the popup's skin to use the skin defined in the saved
* configuration file.
*/
void loadPopupConfiguration();
/**
* Currently only saves the skin used by the popup so that when the
* client is reloaded, it can use the saved skin.
*/
void savePopupConfiguration();
/**
* Draws the popup.
*/
void draw(gcn::Graphics *graphics);
/**
* Sets the size of this popup.
*/
void setContentSize(int width, int height);
/**
* Sets the location relative to the given widget.
*/
void setLocationRelativeTo(gcn::Widget *widget);
/**
* Sets the minimum width of the popup.
*/
void setMinWidth(unsigned int width);
/**
* Sets the minimum height of the popup.
*/
void setMinHeight(unsigned int height);
/**
* Sets the maximum width of the popup.
*/
void setMaxWidth(unsigned int width);
/**
* Sets the minimum height of the popup.
*/
void setMaxHeight(unsigned int height);
/**
* Gets the minimum width of the popup.
*/
int getMinWidth() { return mMinWidth; }
/**
* Gets the minimum height of the popup.
*/
int getMinHeight() { return mMinHeight; }
/**
* Gets the maximum width of the popup.
*/
int getMaxWidth() { return mMaxWidth; }
/**
* Gets the minimum height of the popup.
*/
int getMaxHeight() { return mMaxHeight; }
/**
* Gets the padding of the popup. The padding is the distance between
* the popup border and the content.
*
* @return The padding of the popup.
* @see setPadding
*/
unsigned int getPadding() const { return mPadding; }
/**
* Sets the padding of the popup. The padding is the distance between the
* popup border and the content.
*
* @param padding The padding of the popup.
* @see getPadding
*/
void setPadding(unsigned int padding) { mPadding = padding; }
/**
* Returns the parent Window.
*
* @return The parent Window or <code>NULL</code> if there is none.
*/
Window* getParentWindow() { return mParent; }
/**
* Sets the name of the popup. This is only useful for debug purposes.
*/
void setPopupName(const std::string &name) { mPopupName = name; }
/**
* Returns the name of the popup. This is only useful for debug purposes.
*/
const std::string& getPopupName() { return mPopupName; }
/**
* Schedule this popup for deletion. It will be deleted at the start
* of the next logic update.
*/
void scheduleDelete();
// Inherited from BasicContainer
virtual gcn::Rectangle getChildrenArea();
private:
Window *mParent; /**< The parent Window (if there is one) */
std::string mPopupName; /**< Name of the popup */
std::string mDefaultSkinPath; /**< Default skin path for this popup */
int mMinWidth; /**< Minimum popup width */
int mMinHeight; /**< Minimum popup height */
int mMaxWidth; /**< Maximum popup width */
int mMaxHeight; /**< Maximum popup height */
unsigned int mPadding; /**< Holds the padding of the popup. */
static int instances; /**< Number of popup instances */
Skin* mSkin; /**< Skin in use by this popup */
};
#endif
|