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