ScummVM API documentation
floating.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 * Based on the original sources
22 * Faery Tale II -- The Halls of the Dead
23 * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24 */
25
26#ifndef SAGA2_FLOATING_H
27#define SAGA2_FLOATING_H
28
29#include "saga2/fta.h"
30#include "saga2/hresmgr.h"
31#include "saga2/panel.h"
32
33namespace Saga2 {
34
35//DNode
36// gPanel
37// gControl
38class DragControl;
39// gPanelList
40// gWindow
41class DecoratedWindow;
42class BackWindow;
43class FloatingWindow;
44struct WindowDecoration;
45class GameObject;
46
47/* ===================================================================== *
48 WindowDecoration -- defines border imagery for windows
49 * ===================================================================== */
50
51// BackgroundImage -- for windows which are covered with decorative
52// artwork, this class provides a linked list of all the "artwork
53// panels" which cover the borders of the image.
54
56 StaticRect extent;
57 void *image;
58 int16 imageNumber;
59};
60
62 Rect16 extent; // area that image covers
63 void *image; // pointer to image data
64 int16 imageNumber; // image resource number
65
66 // default constructor
68 extent = Rect16(0, 0, 0, 0), image = NULL;
69 imageNumber = 0;
70 }
71
72 WindowDecoration(const Rect16 &r, int16 num) {
73 extent = r;
74 image = NULL;
75 imageNumber = num;
76 }
77
79 extent = s.extent;
80 image = s.image;
81 imageNumber = s.imageNumber;
82 }
83
84 // this sets the decorations ( for use with the default constructor
85 void set(const Rect16 &r, int16 num) {
86 extent = r, image = NULL, imageNumber = num;
87 }
88
89};
90
91
92/* ===================================================================== *
93 DragBar -- a control which allows the user to drag the window
94 * ===================================================================== */
95
96class FloatingWindow;
97
98class DragBar : public gControl {
99
100public:
101 static StaticPoint16 _dragOffset, // mouse offset
102 _dragPos; // new position of window
103 static bool _update; // true = update window pos
104 static FloatingWindow *_dragWindow; // which window to update
105
106 DragBar(gPanelList &, const Rect16 &);
107
108private:
109 bool activate(gEventType);
110 void deactivate();
111 bool pointerHit(gPanelMessage &msg);
112 void pointerDrag(gPanelMessage &msg);
113 void pointerRelease(gPanelMessage &msg);
114};
115
116/* ===================================================================== *
117 gButton class: Your basic pushbutton.
118 * ===================================================================== */
119
120class gButton : public gControl {
121public:
122
123 gButton(gPanelList &list, const Rect16 &box, char *title_, uint16 ident, AppFunc *cmd = NULL) :
124 gControl(list, box, title_, ident, cmd) {}
125 gButton(gPanelList &list, const Rect16 &box, gPixelMap &img, uint16 ident, AppFunc *cmd = NULL) :
126 gControl(list, box, img, ident, cmd) {}
127
128 void draw(); // redraw the panel.
129
130private:
131 bool activate(gEventType why); // activate the control
132 void deactivate();
133 bool pointerHit(gPanelMessage &msg);
134 void pointerDrag(gPanelMessage &msg);
135 void pointerRelease(gPanelMessage &msg);
136};
137
138class gPhantomButton : public gButton {
139public:
140 // Fakes out the gButton into thinking there's no image.
142 const Rect16 &box, uint16 ident, AppFunc *cmd = NULL) :
143 gButton(list, box, NULL, ident, cmd) {};
144 virtual void draw() {}; // Overrides draw() member of parent, since
145 // in this case there's nothing to draw.
146
147};
148
149/* ===================================================================== *
150 gImageButton class: a push button with two images (selected & deselected)
151 * ===================================================================== */
152
153class gImageButton : public gButton {
154protected:
155 gPixelMap *_selImage,
156 *_deselImage;
157
158public:
159 gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, uint16 ident, AppFunc *cmd = NULL) :
160 gButton(list, box, NULL, ident, cmd) {
161 _selImage = &img1;
162 _deselImage = &img2;
163 }
164 gImageButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, char *title_, uint16 ident, AppFunc *cmd = NULL) :
165 gButton(list, box, title_, ident, cmd) {
166 _selImage = &img1;
167 _deselImage = &img2;
168 }
169
170 void drawClipped(gPort &port, const Point16 &offset, const Rect16 &r);
171};
172
173/* ===================================================================== *
174 gToggleButton class: Like a push button, but toggles on/off
175 * ===================================================================== */
176
178public:
179 gToggleButton(gPanelList &list, const Rect16 &box, gPixelMap &img1, gPixelMap &img2, uint16 ident, AppFunc *cmd) :
180 gImageButton(list, box, img1, img2, ident, cmd) {}
181
182private:
183 bool activate(gEventType why); // activate the control
184 bool pointerHit(gPanelMessage &msg);
185};
186
187
188/* ===================================================================== *
189 LabeledButton class: an image button which displays text
190 * ===================================================================== */
191
193public:
195 const Rect16 &box,
196 gPixelMap &img1,
197 gPixelMap &img2,
198 char *buttonLabel,
199 uint16 ident,
200 AppFunc *cmd);
201
202 void drawClipped(gPort &port, const Point16 &offset, const Rect16 &r);
203};
204
205
206/* ===================================================================== *
207 DecoratedWindow -- a window with border decorations
208 * ===================================================================== */
209
210class DecoratedWindow : public gWindow {
211public:
212 WindowDecoration *_decorations;
213 int16 _numDecorations;
214
215 // For a future enhancement where different windows have
216 // different animated areas.
217// Rect16 animatedArea;
218
219 DecoratedWindow(const Rect16 &, uint16, const char saveAs[], AppFunc *cmd = NULL);
221 void draw(); // redraw the window
222
223 // Redraw the window, but only a small clipped section,
224 // and perhaps drawn onto an off-screen map.
225 void drawClipped(
226 gPort &port,
227 const Point16 &offset,
228 const Rect16 &r);
229
230 // Attach a list of decorative panels to the window
231 void setDecorations(WindowDecoration *, int16, hResContext *);
232 void setDecorations(WindowDecoration *, int16, hResContext *, hResID);
233 void setDecorations(WindowDecoration *, int16, hResContext *, char, char, char);
234
235 void setDecorations(const StaticWindow *, int16, hResContext *);
236 void setDecorations(const StaticWindow *, int16, hResContext *, hResID);
237 void setDecorations(const StaticWindow *, int16, hResContext *, char, char, char);
238
239
240 // Free up memory used by decorative panels
241 void removeDecorations();
242
243 virtual bool isBackdrop();
244
245 // Update a region of a window, and all floaters which
246 // might be above that window.
247 void update(const Rect16 &updateRect);
248 void update(const StaticRect &updateRect);
249};
250
251/* ===================================================================== *
252 BackWindow -- the background window behind everything else
253 * ===================================================================== */
254
256
257 // Disable the window-to-front
258 void toFront();
259
260public:
261 BackWindow(const Rect16 &, uint16, AppFunc *cmd = NULL);
262 void invalidate(Rect16 *area);
263 void invalidate(const StaticRect *area);
264
265 virtual bool isBackdrop();
266};
267
268/* ===================================================================== *
269 FloatingWindow -- floats on top of background window
270 * ===================================================================== */
271
273
274 DragBar *_db; // save address of drag bar
275
276 void toFront();
277
278 // original extent before movement
279 Point16 _origPos;
280
281public:
282
283 // decoration position offset
284 Point16 _decOffset;
285
286 FloatingWindow(const Rect16 &, uint16, const char saveas[], AppFunc *cmd = NULL);
287
288
289 // Redraw the window, but only a small clipped section,
290 // and perhaps drawn onto an off-screen map.
291 void drawClipped(
292 gPort &port,
293 const Point16 &offset,
294 const Rect16 &r);
295
296 // set the extent of the entire window ( including decorations )
297 void setExtent(const Rect16 &);
298 const Point16 &getDecOffset() {
299 return _decOffset;
300 }
301
302 bool open();
303 void close();
304};
305
306/* ===================================================================== *
307 Misc functions
308 * ===================================================================== */
309
310// This probably doesn't belong here, but I can't think of a
311// convenient place to put it right now.
312
313void drawCompressedImage(gPort &port, const Point16 pos, void *image);
314void drawCompressedImageGhosted(gPort &port, const Point16 pos, void *image);
315
316} // end of namespace Saga2
317
318#endif
Definition: floating.h:255
Definition: floating.h:210
Definition: floating.h:98
Definition: floating.h:272
Definition: floating.h:192
Definition: rect.h:42
Definition: rect.h:290
Definition: floating.h:120
Definition: panel.h:406
Definition: floating.h:153
Definition: panel.h:255
Definition: panel.h:218
Definition: floating.h:138
Definition: gdraw.h:56
Definition: gdraw.h:178
Definition: floating.h:177
Definition: panel.h:315
Definition: hresmgr.h:98
Definition: rect.h:33
Definition: rect.h:282
Definition: floating.h:55
Definition: floating.h:61