ScummVM API documentation
window.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
22#ifndef BURIED_WINDOW_H
23#define BURIED_WINDOW_H
24
25#include "common/events.h"
26#include "common/rect.h"
27#include "common/list.h"
28
29namespace Common {
30struct KeyState;
31}
32
33namespace Buried {
34
35class BuriedEngine;
36class Message;
37
38class Window {
39public:
40 Window(BuriedEngine *vm, Window *parent, bool visible = false);
41 virtual ~Window();
42
43 // The message types used by Buried in Time's windows
44 virtual bool onEraseBackground() { return false; }
45 virtual void onActionStart(const Common::CustomEventType &action, uint flags) {}
46 virtual void onActionEnd(const Common::CustomEventType &action, uint flags) {}
47 virtual void onKeyUp(const Common::KeyState &key, uint flags) {}
48 virtual void onTimer(uint timer) {}
49 virtual void onKillFocus(Window *newWindow) {}
50 virtual void onSetFocus(Window *oldWindow) {}
51 virtual void onPaint() {}
52 virtual void onLButtonUp(const Common::Point &point, uint flags) {}
53 virtual void onLButtonDown(const Common::Point &point, uint flags) {}
54 virtual void onMouseMove(const Common::Point &point, uint flags) {}
55 virtual void onMButtonUp(const Common::Point &point, uint flags) {}
56 virtual void onRButtonUp(const Common::Point &point, uint flags) {}
57 virtual void onRButtonDown(const Common::Point &point, uint flags) {}
58 virtual bool onSetCursor(uint message);
59 virtual void onEnable(bool enable) {}
60
61 void invalidateRect(const Common::Rect &rect, bool erase = true);
62 void invalidateWindow(bool erase = true) { invalidateRect(_rect, erase); }
63 Window *getParent() const { return _parent; }
64 const Common::Rect &getRect() const { return _rect; }
65 Common::Rect getClientRect() const;
66 Common::Rect getAbsoluteRect() const;
67 void updateWindow();
68 void enableWindow(bool enable);
69 bool isWindowEnabled() const;
70 void setWindowPos(const Window *insertAfter, int x, int y, int width, int height, uint flags);
71
72 // The subset of show modes we'll accept
73 enum WindowShowMode {
74 kWindowShow,
75 kWindowHide,
76 kWindowShowNormal
77 };
78
79 void showWindow(WindowShowMode showMode);
80 bool isWindowVisible() const { return _visible; }
81
82 // The subset of flags we'll accept
83 enum WindowPosFlags {
84 kWindowPosNoFlags = 0,
85
86 kWindowPosNoSize = (1 << 0),
87 kWindowPosNoZOrder = (1 << 1),
88 kWindowPosHideWindow = (1 << 2),
89 kWindowPosShowWindow = (1 << 3),
90 kWindowPosNoMove = (1 << 4),
91 kWindowPosNoActivate = (1 << 5)
92 };
93
94 Window *setFocus();
95 Window *setCapture();
96
97 void sendMessage(Message *message);
98 void postMessage(Message *message);
99
100 Window *childWindowAtPoint(const Common::Point &point);
101
102 // Helper functions
103 Common::Point convertPointToGlobal(const Common::Point &point);
104 Common::Point convertPointToLocal(const Common::Point &point);
105 Common::Point convertPointToWindow(const Common::Point &point, Window *dest);
106
107protected:
108 BuriedEngine *_vm;
109
110 Window *_parent;
111 Common::Rect _rect;
112
113 uint setTimer(uint elapse);
114 bool killTimer(uint timer);
115
116 Common::Rect makeAbsoluteRect(const Common::Rect &rect) const;
117
118private:
119 bool _enabled, _visible;
120
122 WindowList _children, _topMostChildren;
123};
124
125// A subset of the special insert after Window handles
126// (Values declared in window.cpp)
127extern const Window *kWindowPosTop;
128extern const Window *kWindowPosTopMost;
129
130} // End of namespace Buried
131
132#endif
Definition: buried.h:96
Definition: message.h:62
Definition: window.h:38
uint32 CustomEventType
Definition: events.h:212
Definition: algorithm.h:29
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536