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