1 /* Definitions and headers for communication on the Microsoft Windows API.
2 Copyright (C) 1995, 2001-2023 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
18
19 #ifndef EMACS_W32GUI_H
20 #define EMACS_W32GUI_H
21 #include <windows.h>
22
23 #include "systime.h" /* for Time */
24
25 /* FIXME: old local memory management for menus. */
26 #define local_heap (GetProcessHeap ())
27 #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
28 #define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
29
30 typedef HBITMAP Emacs_Pixmap;
31
32 typedef HWND Window;
33 typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
34 typedef HCURSOR Emacs_Cursor;
35
36 /* Windows equivalent of XImage. */
37 typedef struct _XImage
38 {
39 unsigned char * data;
40 BITMAPINFO info;
41 /* Optional RGBQUAD array for palette follows (see BITMAPINFO docs). */
42 } XImage;
43
44 struct image;
45 extern int w32_load_image (struct frame *f, struct image *img,
46 Lisp_Object spec_file, Lisp_Object spec_data);
47 extern bool w32_can_use_native_image_api (Lisp_Object);
48 extern void w32_gdiplus_shutdown (void);
49 extern size_t w32_image_size (Emacs_Pixmap);
50
51 #define FACE_DEFAULT (~0)
52
53 extern HINSTANCE hinst;
54
55 /* Bit Gravity */
56
57 #define ForgetGravity 0
58 #define NorthWestGravity 1
59 #define NorthGravity 2
60 #define NorthEastGravity 3
61 #define WestGravity 4
62 #define CenterGravity 5
63 #define EastGravity 6
64 #define SouthWestGravity 7
65 #define SouthGravity 8
66 #define SouthEastGravity 9
67 #define StaticGravity 10
68
69 #define NoValue 0x0000
70 #define XValue 0x0001
71 #define YValue 0x0002
72 #define WidthValue 0x0004
73 #define HeightValue 0x0008
74 #define AllValues 0x000F
75 #define XNegative 0x0010
76 #define YNegative 0x0020
77
78 #define USPosition (1L << 0) /* user specified x, y */
79 #define USSize (1L << 1) /* user specified width, height */
80
81 #define PPosition (1L << 2) /* program specified position */
82 #define PSize (1L << 3) /* program specified size */
83 #define PMinSize (1L << 4) /* program specified minimum size */
84 #define PMaxSize (1L << 5) /* program specified maximum size */
85 #define PResizeInc (1L << 6) /* program specified resize increments */
86 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
87 #define PBaseSize (1L << 8) /* program specified base for incrementing */
88 #define PWinGravity (1L << 9) /* program specified window gravity */
89
90 #define NativeRectangle RECT
91
92 #define CONVERT_TO_EMACS_RECT(xr,nr) \
93 ((xr).x = (nr).left, \
94 (xr).y = (nr).top, \
95 (xr).width = ((nr).right - (nr).left), \
96 (xr).height = ((nr).bottom - (nr).top))
97
98 #define CONVERT_FROM_EMACS_RECT(xr,nr) \
99 ((nr).left = (xr).x, \
100 (nr).top = (xr).y, \
101 (nr).right = ((xr).x + (xr).width), \
102 (nr).bottom = ((xr).y + (xr).height))
103
104 #define STORE_NATIVE_RECT(nr,x,y,width,height) \
105 ((nr).left = (x), \
106 (nr).top = (y), \
107 (nr).right = ((nr).left + (width)), \
108 (nr).bottom = ((nr).top + (height)))
109
110
111 #endif /* EMACS_W32GUI_H */