ScummVM API documentation
minwindef.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 BAGEL_MFC_MINWINDEF_H
23 #define BAGEL_MFC_MINWINDEF_H
24 
25 #include "common/scummsys.h"
26 #include "common/algorithm.h"
27 #include "common/rect.h"
28 #include "bagel/mfc/winnt.h"
29 
30 namespace Bagel {
31 namespace MFC {
32 
33 #define ASSERT assert
34 
35 #undef FAR
36 #undef NEAR
37 #define FAR
38 #define NEAR
39 #ifndef CONST
40  #define CONST const
41 #endif
42 
43 #define CALLBACK
44 #define WINAPI
45 #define WINAPIV
46 #define APIENTRY WINAPI
47 #define APIPRIVATE
48 #define PASCAL
49 #define AFXAPI
50 #define AFX_DATA
51 #define AFX_NOVTABLE
52 #define BASED_CODE
53 #define AFX_CDECL
54 
55 // We're temporary disabling virtual Create functions
56 // for ScummVM due to the warnings it generates
57 #define CVIRTUAL
58 
59 #ifndef _In_
60  #define _In_
61 #endif
62 #ifndef _Out_
63  #define _Out_
64 #endif
65 #ifndef _In_z_
66  #define _In_z_
67 #endif
68 #ifndef _Inout_
69  #define _Inout_
70 #endif
71 
72 // Dummy try/catch implementation
73 #define TRY if (1) {
74 #define END_TRY }
75 #define CATCH(KLASS, VAL) KLASS *VAL = nullptr; if (0)
76 #define END_CATCH }
77 
78 DECLARE_HANDLE(HACCEL);
79 DECLARE_HANDLE(HCURSOR);
80 DECLARE_HANDLE(HDROP);
81 DECLARE_HANDLE(HHOOK);
82 DECLARE_HANDLE(HICON);
83 DECLARE_HANDLE(HMENU);
84 DECLARE_HANDLE(HRAWINPUT);
85 
87  virtual ~CGdiObjectImpl() {};
88 };
89 typedef CGdiObjectImpl *HGDIOBJ;
90 typedef HGDIOBJ HBITMAP;
91 typedef HGDIOBJ HBRUSH;
92 typedef HGDIOBJ HFONT;
93 typedef HGDIOBJ HPALETTE;
94 typedef HGDIOBJ HPEN;
95 typedef HGDIOBJ HRGN;
96 typedef HGDIOBJ HENHMETAFILE;
97 
98 typedef void *HDC;
99 class CWnd;
100 typedef CWnd *HWND;
101 
102 
103 /* Types use for passing & returning polymorphic values */
104 typedef uintptr WPARAM;
105 typedef intptr LPARAM;
106 typedef intptr LRESULT;
107 
108 typedef LRESULT(CALLBACK *HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
109 typedef LRESULT(CALLBACK *WNDPROC)(HWND, unsigned int, WPARAM, LPARAM);
110 typedef intptr(FAR WINAPI *FARPROC)();
111 typedef intptr(NEAR WINAPI *NEARPROC)();
112 typedef intptr(WINAPI *PROC)();
113 typedef intptr(CALLBACK *DLGPROC)(HWND, unsigned int, WPARAM, LPARAM);
114 
115 #ifndef max
116  #define max(a,b) (((a) > (b)) ? (a) : (b))
117 #endif
118 
119 #ifndef min
120  #define min(a,b) (((a) < (b)) ? (a) : (b))
121 #endif
122 
123 #define MAKEWORD(a, b) ((uint16)(((byte)(((uintptr)(a)) & 0xff)) | ((uint16)((byte)(((uintptr)(b)) & 0xff))) << 8))
124 #define MAKELONG(a, b) ((long)(((uint16)(((uintptr)(a)) & 0xffff)) | ((uint32)((uint16)(((uintptr)(b)) & 0xffff))) << 16))
125 #define LOWORD(l) ((uint16)(((uintptr)(l)) & 0xffff))
126 #define HIWORD(l) ((((uintptr)(l)) >> 16))
127 #define LOBYTE(w) ((byte)(((uintptr)(w)) & 0xff))
128 #define HIBYTE(w) ((byte)((((uintptr)(w)) >> 8) & 0xff))
129 
130 #define POINTTOPOINTS(pt) (MAKELONG((short)((pt).x), (short)((pt).y)))
131 #define MAKEWPARAM(l, h) ((WPARAM)(uint32)MAKELONG(l, h))
132 #define MAKELPARAM(l, h) ((LPARAM)(uint32)MAKELONG(l, h))
133 #define MAKELRESULT(l, h) ((LRESULT)(uint32)MAKELONG(l, h))
134 
135 typedef void *HANDLE;
136 typedef HANDLE NEAR *SPHANDLE;
137 typedef HANDLE FAR *LPHANDLE;
138 typedef HANDLE HGLOBAL;
139 typedef HANDLE HLOCAL;
140 typedef HANDLE GLOBALHANDLE;
141 typedef HANDLE LOCALHANDLE;
142 
143 #define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name
144 
145 typedef uint16 ATOM; //BUGBUG - might want to remove this from minwin
146 
147 DECLARE_HANDLE(HKEY);
148 typedef HKEY *PHKEY;
149 DECLARE_HANDLE(HMETAFILE);
150 DECLARE_HANDLE(HINSTANCE);
151 typedef HINSTANCE HMODULE; /* HMODULEs can be used in place of HINSTANCEs */
152 DECLARE_HANDLE(HRSRC);
153 DECLARE_HANDLE(HSPRITE);
154 DECLARE_HANDLE(HLSURF);
155 DECLARE_HANDLE(HSTR);
156 DECLARE_HANDLE(HTASK);
157 DECLARE_HANDLE(HWINSTA);
158 DECLARE_HANDLE(HKL);
159 
160 typedef struct tagPOINT {
161  int x;
162  int y;
163 } POINT, *PPOINT, NEAR *NPPOINT, FAR *LPPOINT;
164 
165 typedef struct tagSIZE {
166  int cx;
167  int cy;
168 } SIZE, *PSIZE, *LPSIZE;
169 
170 typedef SIZE SIZEL;
171 typedef SIZE *PSIZEL, *LPSIZEL;
172 
173 typedef struct tagPOINTS {
174  SHORT x;
175  SHORT y;
176 } POINTS, *PPOINTS, *LPPOINTS;
177 
178 typedef struct tagRECT {
179  int left;
180  int top;
181  int right;
182  int bottom;
183 
184  operator Common::Rect() const {
185  return Common::Rect(left, top, right, bottom);
186  }
187  bool contains(int x, int y) const {
188  Common::Rect r = *this;
189  return r.contains(x, y);
190  }
191  bool contains(const POINT &pt) const {
192  Common::Rect r = *this;
193  return r.contains(pt.x, pt.y);
194  }
195 } RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
196 typedef const RECT FAR *LPCRECT;
197 
198 inline Common::Rect RECTtoRect(const RECT &src) {
199  return src;
200 }
201 inline RECT RectToRECT(const Common::Rect &src) {
202  RECT dest;
203  dest.left = src.left;
204  dest.top = src.top;
205  dest.right = src.right;
206  dest.bottom = src.bottom;
207  return dest;
208 }
209 inline RECT RectToRECT(int x1, int y1, int x2, int y2) {
210  RECT dest;
211  dest.left = x1;
212  dest.top = y1;
213  dest.right = x2;
214  dest.bottom = y2;
215  return dest;
216 }
217 
218 inline bool RectsIntersect(const RECT &r1, const RECT &r2) {
219  return RECTtoRect(r1).intersects(RECTtoRect(r2));
220 }
221 
222 typedef struct _FILETIME {
223  uint32 dwLowDateTime;
224  uint32 dwHighDateTime;
226 
227 typedef struct _SYSTEMTIME {
228  uint16 wYear;
229  uint16 wMonth;
230  uint16 wDayOfWeek;
231  uint16 wDay;
232  uint16 wHour;
233  uint16 wMinute;
234  uint16 wSecond;
235  uint16 wMilliseconds;
237 
238 typedef struct tagPAINTSTRUCT {
239  HDC hdc;
240  bool fErase;
241  RECT rcPaint;
242  bool fRestore;
243  bool fIncUpdate;
244  byte rgbReserved[32];
246 
247 /*
248  * Message structure
249  */
250 typedef struct tagMSG {
251  HWND hwnd = 0;
252  unsigned int message = 0;
253  WPARAM wParam = 0;
254  LPARAM lParam = 0;
255  uint32 time = 0;
256  POINT pt;
257 
258  // Extra fields for TranslateMessage convenience
259  byte _kbdFlags = 0;
260  char _ascii = 0;
261 
262  tagMSG() {
263  pt.x = pt.y = 0;
264  }
265  tagMSG(HWND hwnd_, unsigned int message_, WPARAM wParam_ = 0,
266  LPARAM lParam_ = 0) :
267  hwnd(hwnd_), message(message_), wParam(wParam_),
268  lParam(lParam_) {
269  pt.x = pt.y = 0;
270  }
271 } MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;
272 
273 inline bool PtInRect(const RECT *lprc, const POINT &pt) {
274  return pt.x >= lprc->left && pt.x < lprc->right &&
275  pt.y >= lprc->top && pt.y < lprc->bottom;
276 }
277 
278 typedef struct tagWNDCLASS {
279  unsigned int style;
280  WNDPROC lpfnWndProc;
281  int cbClsExtra;
282  int cbWndExtra;
283  HINSTANCE hInstance;
284  HICON hIcon;
285  HCURSOR hCursor;
286  HBRUSH hbrBackground;
287  const char * lpszMenuName;
288  const char * lpszClassName;
290 
292  bool m_bSaveAndValidate;
293 };
294 
295 } // namespace MFC
296 } // namespace Bagel
297 
298 #endif
Definition: minwindef.h:165
T left
Definition: rect.h:170
Definition: afxwin.h:1125
Definition: rect.h:524
bool intersects(const ConcreteRect &r) const
Definition: rect.h:291
Definition: minwindef.h:86
Definition: minwindef.h:160
Definition: minwindef.h:222
Definition: minwindef.h:157
Definition: minwindef.h:156
T right
Definition: rect.h:171
Definition: minwindef.h:152
Definition: minwindef.h:238
Definition: minwindef.h:149
Definition: minwindef.h:150
Definition: minwindef.h:155
Definition: minwindef.h:173
Definition: minwindef.h:153
Definition: minwindef.h:158
Definition: minwindef.h:178
Definition: minwindef.h:291
bool contains(T x, T y) const
Definition: rect.h:246
Definition: minwindef.h:227
Definition: minwindef.h:278
Definition: afxwin.h:27
Definition: minwindef.h:154
Definition: minwindef.h:147
Definition: minwindef.h:250