comparison ext/guichan-0.8.1/include/guichan/widgets/window.hpp @ 89:fa33cda75471

* Reverting back to 2543 as requested by sleek
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 19 Jul 2008 11:38:52 +0000
parents 4a0efb7baf70
children
comparison
equal deleted inserted replaced
88:1c2842ebe393 89:fa33cda75471
1 /* _______ __ __ __ ______ __ __ _______ __ __
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8 *
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
10 *
11 *
12 * Per Larsson a.k.a finalman
13 * Olof Naessén a.k.a jansem/yakslem
14 *
15 * Visit: http://guichan.sourceforge.net
16 *
17 * License: (BSD)
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 * 3. Neither the name of Guichan nor the names of its contributors may
28 * be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 #ifndef GCN_WINDOW_HPP
45 #define GCN_WINDOW_HPP
46
47 #include <string>
48
49 #include "guichan/mouselistener.hpp"
50 #include "guichan/platform.hpp"
51 #include "guichan/widgets/container.hpp"
52
53 namespace gcn
54 {
55 /**
56 * An implementation of a movable window that can contain other widgets.
57 */
58 class GCN_CORE_DECLSPEC Window : public Container,
59 public MouseListener
60 {
61 public:
62 /**
63 * Constructor.
64 */
65 Window();
66
67 /**
68 * Constructor. The window will be automatically resized in height
69 * to fit the caption.
70 *
71 * @param caption the caption of the window.
72 */
73 Window(const std::string& caption);
74
75 /**
76 * Destructor.
77 */
78 virtual ~Window();
79
80 /**
81 * Sets the caption of the window.
82 *
83 * @param caption The caption of the window.
84 * @see getCaption
85 */
86 void setCaption(const std::string& caption);
87
88 /**
89 * Gets the caption of the window.
90 *
91 * @return the caption of the window.
92 * @see setCaption
93 */
94 const std::string& getCaption() const;
95
96 /**
97 * Sets the alignment of the caption.
98 *
99 * @param alignment The alignment of the caption.
100 * @see getAlignment, Graphics
101 */
102 void setAlignment(Graphics::Alignment alignment);
103
104 /**
105 * Gets the alignment of the caption.
106 *
107 * @return The alignment of caption.
108 * @see setAlignment, Graphics
109 */
110 Graphics::Alignment getAlignment() const;
111
112 /**
113 * Sets the padding of the window. The padding is the distance between the
114 * window border and the content.
115 *
116 * @param padding The padding of the window.
117 * @see getPadding
118 */
119 void setPadding(unsigned int padding);
120
121 /**
122 * Gets the padding of the window. The padding is the distance between the
123 * window border and the content.
124 *
125 * @return The padding of the window.
126 * @see setPadding
127 */
128 unsigned int getPadding() const;
129
130 /**
131 * Sets the title bar height.
132 *
133 * @param height The title height value.
134 * @see getTitleBarHeight
135 */
136 void setTitleBarHeight(unsigned int height);
137
138 /**
139 * Gets the title bar height.
140 *
141 * @return The title bar height.
142 * @see setTitleBarHeight
143 */
144 unsigned int getTitleBarHeight();
145
146 /**
147 * Sets the window to be moveble or not.
148 *
149 * @param movable True if the window should be movable, false otherwise.
150 * @see isMovable
151 */
152 void setMovable(bool movable);
153
154 /**
155 * Checks if the window is movable.
156 *
157 * @return True if the window is movable, false otherwise.
158 * @see setMovable
159 */
160 bool isMovable() const;
161
162 /**
163 * Sets the window to be opaque or not. An opaque window will draw it's background
164 * and it's content. A non opaque window will only draw it's content.
165 *
166 * @param opaque True if the window should be opaque, false otherwise.
167 * @see isOpaque
168 */
169 void setOpaque(bool opaque);
170
171 /**
172 * Checks if the window is opaque.
173 *
174 * @return True if the window is opaque, false otherwise.
175 * @see setOpaque
176 */
177 bool isOpaque();
178
179 /**
180 * Resizes the window to fit the content.
181 */
182 virtual void resizeToContent();
183
184
185 // Inherited from BasicContainer
186
187 virtual Rectangle getChildrenArea();
188
189
190 // Inherited from Widget
191
192 virtual void draw(Graphics* graphics);
193
194
195 // Inherited from MouseListener
196
197 virtual void mousePressed(MouseEvent& mouseEvent);
198
199 virtual void mouseDragged(MouseEvent& mouseEvent);
200
201 virtual void mouseReleased(MouseEvent& mouseEvent);
202
203 protected:
204 /**
205 * Holds the caption of the window.
206 */
207 std::string mCaption;
208
209 /**
210 * Holds the alignment of the caption.
211 */
212 Graphics::Alignment mAlignment;
213
214 /**
215 * Holds the padding of the window.
216 */
217 unsigned int mPadding;
218
219 /**
220 * Holds the title bar height of the window.
221 */
222 unsigned int mTitleBarHeight;
223
224 /**
225 * True if the window is movable, false otherwise.
226 */
227 bool mMovable;
228
229 /**
230 * True if the window is opaque, false otherwise.
231 */
232 bool mOpaque;
233
234 /**
235 * Holds a drag offset as an x coordinate where the drag of the window
236 * started if the window is being dragged. It's used to move the window
237 * correctly when dragged.
238 */
239 int mDragOffsetX;
240
241 /**
242 * Holds a drag offset as an y coordinate where the drag of the window
243 * started if the window is being dragged. It's used to move the window
244 * correctly when dragged.
245 */
246 int mDragOffsetY;
247
248 /**
249 * True if the window is being moved, false otherwise.
250 */
251 bool mMoved;
252 };
253 }
254
255 #endif // end GCN_WINDOW_HPP