Renamed wintypes.h to windef.h.
[wine/wine-kai.git] / include / windef.h
blob1b318ca11358df6f013af3869b9438723a180565
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Misc. constants. */
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE 1
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL 0
36 /* Macros to map Winelib names to the correct implementation name */
37 /* depending on __WINE__ and UNICODE macros. */
38 /* Note that Winelib is purely Win32. */
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func) this_is_a_syntax_error this_is_a_syntax_error
42 #else /* __WINE__ */
43 # ifdef UNICODE
44 # define WINELIB_NAME_AW(func) func##W
45 # else
46 # define WINELIB_NAME_AW(func) func##A
47 # endif /* UNICODE */
48 #endif /* __WINE__ */
50 #ifdef __WINE__
51 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
52 #else /* __WINE__ */
53 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
54 #endif /* __WINE__ */
57 /* Calling conventions definitions */
59 #ifdef __i386__
60 # if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
61 # define __stdcall __attribute__((__stdcall__))
62 # define __cdecl __attribute__((__cdecl__))
63 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
64 # else
65 # error You need gcc >= 2.7 to build Wine on a 386
66 # endif /* __GNUC__ */
67 #else /* __i386__ */
68 # define __stdcall
69 # define __cdecl
70 # define __RESTORE_ES
71 #endif /* __i386__ */
73 #define CALLBACK __stdcall
74 #define WINAPI __stdcall
75 #define APIPRIVATE __stdcall
76 #define PASCAL __stdcall
77 #define _pascal __stdcall
78 #define __export __stdcall
79 #define WINAPIV __cdecl
80 #define APIENTRY WINAPI
82 #define CONST const
84 /* Standard data types. These are the same for emulator and library. */
86 typedef void VOID;
87 typedef short INT16;
88 typedef unsigned short UINT16;
89 typedef int INT;
90 typedef unsigned int UINT;
91 typedef unsigned short WORD;
92 typedef unsigned long DWORD;
93 typedef unsigned long ULONG;
94 typedef unsigned char BYTE;
95 typedef long LONG;
96 typedef short SHORT;
97 typedef unsigned short USHORT;
98 typedef char CHAR;
99 typedef unsigned char UCHAR;
100 /* Some systems might have wchar_t, but we really need 16 bit characters */
101 typedef unsigned short WCHAR;
102 typedef unsigned short BOOL16;
103 typedef int BOOL;
104 typedef double DATE;
105 typedef long LONG_PTR;
106 typedef unsigned long ULONG_PTR;
107 typedef double DOUBLE;
108 typedef double LONGLONG;
109 typedef double ULONGLONG;
111 /* Integer types. These are the same for emulator and library. */
113 typedef UINT16 HANDLE16;
114 typedef UINT HANDLE;
115 typedef UINT16 *LPHANDLE16;
116 typedef UINT *LPHANDLE;
117 typedef UINT16 WPARAM16;
118 typedef UINT WPARAM;
119 typedef LONG LPARAM;
120 typedef LONG HRESULT;
121 typedef LONG LRESULT;
122 typedef WORD ATOM;
123 typedef WORD CATCHBUF[9];
124 typedef WORD *LPCATCHBUF;
125 typedef DWORD ACCESS_MASK;
126 typedef ACCESS_MASK REGSAM;
127 typedef HANDLE HHOOK;
128 typedef HANDLE HKEY;
129 typedef HANDLE HMONITOR;
130 typedef DWORD LCID;
131 typedef WORD LANGID;
132 typedef DWORD LCTYPE;
133 typedef float FLOAT;
134 typedef long long __int64;
136 /* Pointers types. These are the same for emulator and library. */
137 /* winnt types */
138 typedef VOID *PVOID;
139 typedef const void *PCVOID;
140 typedef CHAR *PCHAR;
141 typedef UCHAR *PUCHAR;
142 typedef BYTE *PBYTE;
143 typedef ULONG *PULONG;
144 typedef LONG *PLONG;
145 typedef DWORD *PDWORD;
146 /* common win32 types */
147 typedef CHAR *LPSTR;
148 typedef CHAR *PSTR;
149 typedef const CHAR *LPCSTR;
150 typedef const CHAR *PCSTR;
151 typedef WCHAR *LPWSTR;
152 typedef WCHAR *PWSTR;
153 typedef const WCHAR *LPCWSTR;
154 typedef const WCHAR *PCWSTR;
155 typedef BYTE *LPBYTE;
156 typedef WORD *LPWORD;
157 typedef DWORD *LPDWORD;
158 typedef LONG *LPLONG;
159 typedef VOID *LPVOID;
160 typedef const VOID *LPCVOID;
161 typedef INT16 *LPINT16;
162 typedef UINT16 *LPUINT16;
163 typedef INT *PINT;
164 typedef INT *LPINT;
165 typedef UINT *PUINT;
166 typedef UINT *LPUINT;
167 typedef HKEY *LPHKEY;
168 typedef HKEY *PHKEY;
169 typedef FLOAT *PFLOAT;
170 typedef FLOAT *LPFLOAT;
171 typedef BOOL *PBOOL;
172 typedef BOOL *LPBOOL;
174 /* Special case: a segmented pointer is just a pointer in the user's code. */
176 #ifdef __WINE__
177 typedef DWORD SEGPTR;
178 #else
179 typedef void* SEGPTR;
180 #endif /* __WINE__ */
182 /* Handle types that exist both in Win16 and Win32. */
184 #define DECLARE_HANDLE(a) typedef HANDLE16 a##16; typedef HANDLE a
185 DECLARE_HANDLE(HACCEL);
186 DECLARE_HANDLE(HBITMAP);
187 DECLARE_HANDLE(HBRUSH);
188 DECLARE_HANDLE(HCOLORSPACE);
189 DECLARE_HANDLE(HCURSOR);
190 DECLARE_HANDLE(HDC);
191 DECLARE_HANDLE(HDROP);
192 DECLARE_HANDLE(HDRVR);
193 DECLARE_HANDLE(HDWP);
194 DECLARE_HANDLE(HENHMETAFILE);
195 DECLARE_HANDLE(HFILE);
196 DECLARE_HANDLE(HFONT);
197 DECLARE_HANDLE(HGDIOBJ);
198 DECLARE_HANDLE(HGLOBAL);
199 DECLARE_HANDLE(HICON);
200 DECLARE_HANDLE(HINSTANCE);
201 DECLARE_HANDLE(HLOCAL);
202 DECLARE_HANDLE(HMENU);
203 DECLARE_HANDLE(HMETAFILE);
204 DECLARE_HANDLE(HMIDI);
205 DECLARE_HANDLE(HMIDIIN);
206 DECLARE_HANDLE(HMIDIOUT);
207 DECLARE_HANDLE(HMIDISTRM);
208 DECLARE_HANDLE(HMIXER);
209 DECLARE_HANDLE(HMIXEROBJ);
210 DECLARE_HANDLE(HMMIO);
211 DECLARE_HANDLE(HMODULE);
212 DECLARE_HANDLE(HPALETTE);
213 DECLARE_HANDLE(HPEN);
214 DECLARE_HANDLE(HQUEUE);
215 DECLARE_HANDLE(HRGN);
216 DECLARE_HANDLE(HRSRC);
217 DECLARE_HANDLE(HTASK);
218 DECLARE_HANDLE(HWAVE);
219 DECLARE_HANDLE(HWAVEIN);
220 DECLARE_HANDLE(HWAVEOUT);
221 DECLARE_HANDLE(HWINSTA);
222 DECLARE_HANDLE(HDESK);
223 DECLARE_HANDLE(HWND);
224 DECLARE_HANDLE(HKL);
225 DECLARE_HANDLE(HIC);
226 DECLARE_HANDLE(HRASCONN);
227 #undef DECLARE_HANDLE
229 /* Callback function pointers types */
231 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
232 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
233 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
234 typedef BOOL16 (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
235 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
236 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
237 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
238 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
239 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
240 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
241 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
242 typedef LRESULT (CALLBACK *FARPROC16)();
243 typedef LRESULT (CALLBACK *FARPROC)();
244 typedef INT16 (CALLBACK *PROC16)();
245 typedef INT (CALLBACK *PROC)();
246 typedef INT16 (CALLBACK *GOBJENUMPROC16)(SEGPTR,LPARAM);
247 typedef INT (CALLBACK *GOBJENUMPROC)(LPVOID,LPARAM);
248 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
249 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
250 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
251 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
252 typedef VOID (CALLBACK *LINEDDAPROC16)(INT16,INT16,LPARAM);
253 typedef VOID (CALLBACK *LINEDDAPROC)(INT,INT,LPARAM);
254 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
255 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
256 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
257 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
258 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
259 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
260 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
261 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
262 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
263 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
264 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
265 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
266 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
267 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
268 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
269 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
271 /* TCHAR data types definitions for Winelib. */
272 /* These types are _not_ defined for the emulator, because they */
273 /* depend on the UNICODE macro that only exists in user's code. */
275 #ifndef __WINE__
276 # ifdef UNICODE
277 typedef WCHAR TCHAR;
278 typedef LPWSTR LPTSTR;
279 typedef LPCWSTR LPCTSTR;
280 #define __TEXT(string) L##string /*probably wrong */
281 # else /* UNICODE */
282 typedef CHAR TCHAR;
283 typedef LPSTR LPTSTR;
284 typedef LPCSTR LPCTSTR;
285 #define __TEXT(string) string
286 # endif /* UNICODE */
287 #endif /* __WINE__ */
288 #define TEXT(quote) __TEXT(quote)
290 /* Data types specific to the library. These do _not_ exist in the emulator. */
294 /* Define some empty macros for compatibility with Windows code. */
296 #ifndef __WINE__
297 #define NEAR
298 #define FAR
299 #define _far
300 #define _near
301 #define IN
302 #define OUT
303 #define OPTIONAL
304 #endif /* __WINE__ */
306 /* Macro for structure packing. */
308 #ifdef __GNUC__
309 #define WINE_PACKED __attribute__ ((packed))
310 #define WINE_UNUSED __attribute__ ((unused))
311 #else
312 #define WINE_PACKED /* nothing */
313 #define WINE_UNUSED /* nothing */
314 #endif
316 /* Macros to split words and longs. */
318 #define LOBYTE(w) ((BYTE)(WORD)(w))
319 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
321 #define LOWORD(l) ((WORD)(DWORD)(l))
322 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
324 #define SLOWORD(l) ((INT16)(LONG)(l))
325 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
327 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
328 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
329 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
330 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
331 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
332 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
334 #define SELECTOROF(ptr) (HIWORD(ptr))
335 #define OFFSETOF(ptr) (LOWORD(ptr))
337 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
338 /* Note: These macros are semantically broken, at least for wrc. wrc
339 spits out data in the platform's current binary format, *not* in
340 little-endian format. These macros are used throughout the resource
341 code to load and store data to the resources. Since it is unlikely
342 that we'll ever be dealing with little-endian resource data, the
343 byte-swapping nature of these macros has been disabled. Rather than
344 remove the use of these macros from the resource loading code, the
345 macros have simply been disabled. In the future, someone may want
346 to reactivate these macros for other purposes. In that case, the
347 resource code will have to be modified to use different macros. */
349 #if 1
350 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
351 #define GET_WORD(ptr) (*(WORD *)(ptr))
352 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
353 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
354 #else
355 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
356 *((BYTE *)(ptr) + 1) = HIBYTE(w))
357 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
358 (WORD)(*((BYTE *)(ptr)+1) << 8)))
359 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
360 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
361 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
362 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
363 #endif /* 1 */
365 /* MIN and MAX macros */
367 #ifdef MAX
368 #undef MAX
369 #endif
370 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
372 #ifdef MIN
373 #undef MIN
374 #endif
375 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
377 #define __max(a,b) MAX(a,b)
378 #define __min(a,b) MIN(a,b)
379 #define max(a,b) MAX(a,b)
380 #define min(a,b) MIN(a,b)
382 #define _MAX_PATH 260
383 #define MAX_PATH 260
384 #define _MAX_DRIVE 3
385 #define _MAX_DIR 256
386 #define _MAX_FNAME 255
387 #define _MAX_EXT 256
389 #define HFILE_ERROR16 ((HFILE16)-1)
390 #define HFILE_ERROR ((HFILE)-1)
392 /* Winelib run-time flag */
394 #ifdef __WINE__
395 extern int __winelib;
396 #endif /* __WINE__ */
398 /* The SIZE structure */
400 typedef struct
402 INT16 cx;
403 INT16 cy;
404 } SIZE16, *PSIZE16, *LPSIZE16;
406 typedef struct tagSIZE
408 INT cx;
409 INT cy;
410 } SIZE, *PSIZE, *LPSIZE;
413 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
415 #define CONV_SIZE16TO32(s16,s32) \
416 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
417 #define CONV_SIZE32TO16(s32,s16) \
418 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
420 /* The POINT structure */
422 typedef struct
424 INT16 x;
425 INT16 y;
426 } POINT16, *PPOINT16, *LPPOINT16;
428 typedef struct tagPOINT
430 LONG x;
431 LONG y;
432 } POINT, *PPOINT, *LPPOINT;
434 typedef struct _POINTL
436 LONG x;
437 LONG y;
438 } POINTL;
440 #define CONV_POINT16TO32(p16,p32) \
441 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
442 #define CONV_POINT32TO16(p32,p16) \
443 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
445 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
447 /* The POINTS structure */
449 typedef struct tagPOINTS
451 SHORT x;
452 SHORT y;
453 } POINTS, *PPOINTS, *LPPOINTS;
456 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
459 /* The RECT structure */
461 typedef struct
463 INT16 left;
464 INT16 top;
465 INT16 right;
466 INT16 bottom;
467 } RECT16, *LPRECT16;
469 typedef struct tagRECT
471 INT left;
472 INT top;
473 INT right;
474 INT bottom;
475 } RECT, *PRECT, *LPRECT;
476 typedef const RECT *LPCRECT;
479 typedef struct tagRECTL
481 LONG left;
482 LONG top;
483 LONG right;
484 LONG bottom;
485 } RECTL, *PRECTL, *LPRECTL;
487 typedef const RECTL *LPCRECTL;
489 #define CONV_RECT16TO32(r16,r32) \
490 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
491 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
492 #define CONV_RECT32TO16(r32,r16) \
493 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
494 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
496 #ifdef __cplusplus
498 #endif
500 #endif /* __WINE_WINTYPES_H */