ScummVM API documentation
messages.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 ULTIMA_SHARED_ENGINE_MESSAGES_H
23 #define ULTIMA_SHARED_ENGINE_MESSAGES_H
24 
25 #include "common/keyboard.h"
26 #include "common/events.h"
27 #include "ultima/shared/core/rect.h"
28 #include "ultima/shared/core/base_object.h"
29 #include "ultima/shared/core/tree_item.h"
30 
31 namespace Ultima {
32 namespace Shared {
33 
34 enum MessageFlag {
35  MSGFLAG_SCAN = 1,
36  MSGFLAG_BREAK_IF_HANDLED = 2,
37  MSGFLAG_CLASS_DEF = 4
38 };
39 
40 class CMessage;
41 namespace Gfx {
42 class VisualItem;
43 class TextInput;
44 class Popup;
45 }
46 
47 #define MESSAGEDEF(theClass) \
48  static ClassDef type() { return ClassDef(#theClass, &CMessage::type); } \
49  virtual ClassDef getType() const { return type(); }
50 #define MESSAGEDEFP(theClass, baseClass) \
51  static ClassDef type() { return ClassDef(#theClass, &baseClass::type); } \
52  virtual ClassDef getType() const { return type(); }
53 
54 #define MESSAGE0(NAME) \
55  class NAME: public CMessage { \
56  public: NAME() : CMessage() {} \
57  MESSAGEDEF(NAME); \
58  }
59 #define MESSAGE1(NAME, F1, N1, V1) \
60  class NAME: public CMessage { \
61  public: F1 _##N1; \
62  NAME(F1 N1 = V1) : CMessage(), _##N1(N1) {} \
63  MESSAGEDEF(NAME); \
64  }
65 #define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) \
66  class NAME: public CMessage { \
67  public: F1 _##N1; F2 _##N2; \
68  NAME(F1 N1 = V1, F2 N2 = V2) : CMessage(), _##N1(N1), _##N2(N2) {} \
69  MESSAGEDEF(NAME); \
70  }
71 #define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) \
72  class NAME: public CMessage { \
73  public: F1 _##N1; F2 _##N2; F3 _##N3; \
74  NAME(F1 N1 = V1, F2 N2 = V2, F3 N3 = V3) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3) {} \
75  MESSAGEDEF(NAME); \
76  }
77 #define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) \
78  class NAME: public CMessage { \
79  public: F1 _##N1; F2 _##N2; F3 _##N3; F4 _##N4; \
80  NAME(F1 N1 = V1, F2 N2 = V2, F3 N3 = V3, F4 N4 = V4) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3), _##N4(N4) {} \
81  MESSAGEDEF(NAME); \
82  }
83 
87 class CMessage : public BaseObject {
88 private:
92  static const MSGMAP_ENTRY *findMapEntry(const TreeItem *treeItem, const ClassDef &classDef);
93 public:
94  MESSAGEDEFP(CMessage, BaseObject);
95  CMessage();
96 
101  bool execute(TreeItem *target, const ClassDef *classDef = nullptr,
102  int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
103 
108  bool execute(const Common::String &target, const ClassDef *classDef = nullptr,
109  int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
110 
114  virtual bool perform(TreeItem *treeItem);
115 
119  static bool supports(const TreeItem *treeItem, const ClassDef &classDef);
120 
121  virtual bool isMouseMsg() const;
122  virtual bool isButtonDownMsg() const;
123  virtual bool isButtonUpMsg() const;
124  virtual bool isMouseMoveMsg() const;
125  virtual bool isDoubleClickMsg() const;
126 };
127 
128 
129 enum CMouseButton {
130  MB_LEFT = 1, MB_MIDDLE = 2, MB_RIGHT = 4
131 };
132 
136 class CMouseMsg : public CMessage {
137 public:
138  int _buttons;
139  Point _mousePos;
140 public:
141  MESSAGEDEF(CMouseMsg);
142 
143  CMouseMsg() : _buttons(0) {}
144  CMouseMsg(const Point &pt, int buttons) :
145  _mousePos(pt), _buttons(buttons) {}
146 };
147 
152 class CMouseMoveMsg : public CMouseMsg {
153 public:
154  MESSAGEDEFP(CMouseMoveMsg, CMouseMsg);
155  CMouseMoveMsg() : CMouseMsg() {}
156  CMouseMoveMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {}
157 };
158 
162 class CMouseDragMsg : public CMouseMoveMsg {
163 public:
164  MESSAGEDEFP(CMouseDragMsg, CMouseMoveMsg);
166  CMouseDragMsg(const Point &pt, int buttons) : CMouseMoveMsg(pt, buttons) {}
167 };
168 
172 class CMouseButtonMsg : public CMouseMsg {
173 public:
174  MESSAGEDEFP(CMouseButtonMsg, CMouseMsg);
175  CMouseButtonMsg() : CMouseMsg() {}
176  CMouseButtonMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {}
177 };
178 
183 public:
184  MESSAGEDEFP(CMouseButtonDownMsg, CMouseButtonMsg);
186  CMouseButtonDownMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
187 };
188 
193 public:
194  MESSAGEDEFP(CMouseButtonUpMsg, CMouseButtonMsg);
196  CMouseButtonUpMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
197 };
198 
202 class CMouseWheelMsg : public CMouseMsg {
203 public:
204  bool _wheelUp;
205 public:
206  MESSAGEDEFP(CMouseWheelMsg, CMouseMsg);
207  CMouseWheelMsg() : CMouseMsg(), _wheelUp(false) {}
208  CMouseWheelMsg(const Point &pt, bool wheelUp) :
209  CMouseMsg(pt, 0), _wheelUp(wheelUp) {}
210 };
211 
216 public:
217  MESSAGEDEFP(CMouseDuobleClickMsg, CMouseButtonMsg);
219  CMouseDoubleClickMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
220 };
221 
225 MESSAGE1(CFrameMsg, uint, ticks, 0);
226 
230 MESSAGE2(CHideMsg, Gfx::VisualItem *, view, (Gfx::VisualItem *)nullptr, bool, fadeOut, false);
231 
235 MESSAGE1(CInfoGetCommandKeypress, TreeItem *, responder, (TreeItem *)nullptr);
236 
240 MESSAGE1(CInfoGetKeypress, TreeItem *, responder, (TreeItem *)nullptr);
241 
245 MESSAGE3(CInfoGetInput, TreeItem *, responder, (TreeItem *)nullptr, bool, isNumeric, false, size_t, maxCharacters, 10);
246 
250 MESSAGE3(CInfoMsg, Common::String, text, "", bool, newLine, true, bool, replaceLine, false);
251 
255 MESSAGE0(CHuhMsg);
256 
260 MESSAGE1(CKeyCharMsg, int, key, 32);
261 
266 
270 MESSAGE1(CPopupShownMsg, Gfx::Popup *, view, (Gfx::Popup *)nullptr);
271 
275 MESSAGE1(CPopupHiddenMsg, Gfx::Popup *, view, (Gfx::Popup *)nullptr);
276 
280 MESSAGE2(CShowMsg, Gfx::VisualItem *, view, (Gfx::VisualItem *)nullptr, bool, fadeIn, false);
281 
285 MESSAGE2(CTextInputMsg, Common::String, text, "", bool, escaped, false);
286 
291 
292 /*-------------------------------------------------------------------*/
293 
297 MESSAGE1(CMoveMsg, int, direction, 0);
298 
302 MESSAGE1(CAttackMsg, int, direction, 0);
303 
307 MESSAGE0(CBoardMsg);
308 
312 MESSAGE0(CCastMsg);
313 
317 MESSAGE0(CClimbMsg);
318 
322 MESSAGE0(CDropMsg);
323 
327 MESSAGE0(CEnterMsg);
328 
333 
337 MESSAGE0(CFireMsg);
338 
342 MESSAGE0(CGetMsg);
343 
347 MESSAGE0(CHyperJumpMsg);
348 
352 MESSAGE0(CInformMsg);
353 
357 MESSAGE0(COpenMsg);
358 
362 MESSAGE0(CPassMsg);
363 
367 MESSAGE0(CQuitMsg);
368 
372 MESSAGE0(CReadyMsg);
373 
377 MESSAGE0(CStatsMsg);
378 
382 MESSAGE0(CStealMsg);
383 
387 MESSAGE0(CTransactMsg);
388 
392 MESSAGE0(CUnlockMsg);
393 
397 MESSAGE0(CViewChangeMsg);
398 
402 MESSAGE0(CEndOfTurnMsg);
403 
404 } // End of namespace Shared
405 } // End of namespace Ultima
406 
407 #endif
Definition: str.h:59
Definition: messages.h:302
Definition: messages.h:265
Definition: messages.h:87
Definition: messages.h:250
Definition: messages.h:260
Definition: messages.h:225
Definition: messages.h:255
Definition: messages.h:397
Definition: messages.h:297
Definition: tree_item.h:50
Definition: messages.h:357
Definition: messages.h:377
Definition: messages.h:382
Definition: messages.h:290
Definition: messages.h:162
Definition: visual_item.h:39
Definition: messages.h:192
Definition: message_target.h:35
Definition: messages.h:332
Definition: messages.h:152
Definition: detection.h:27
Definition: messages.h:392
Definition: messages.h:402
Definition: messages.h:215
Definition: messages.h:342
Definition: messages.h:352
Definition: messages.h:327
Definition: messages.h:202
Definition: messages.h:270
Definition: messages.h:317
Definition: messages.h:275
Definition: messages.h:172
Definition: messages.h:347
Definition: messages.h:322
Definition: rect.h:45
Definition: messages.h:387
Definition: messages.h:280
Definition: messages.h:240
Definition: messages.h:307
Definition: messages.h:235
Definition: messages.h:372
Definition: messages.h:245
Definition: messages.h:367
Definition: messages.h:362
Definition: messages.h:285
Definition: keyboard.h:294
Definition: messages.h:312
Definition: base_object.h:43
Definition: messages.h:337
Definition: messages.h:136
Definition: base_object.h:71
Definition: popup.h:38
Definition: messages.h:182
Definition: messages.h:230