XEmacs 21.4.4 "Artificial Intelligence".
[chise/xemacs-chise.git.1] / src / syswindows.h
1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2    Copyright (C) 2000 Ben Wing.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Synched up with: Not in FSF. */
22
23 /* Authorship:
24
25    Created May 2000 by Andy Piper.
26    Windows-Mule stuff added by Ben Wing.
27 */
28
29 #ifndef INCLUDED_syswindows_h_
30 #define INCLUDED_syswindows_h_
31
32 /* Note that there are currently FOUR different general
33    Windows-related include files in src!
34
35    Uses are approximately:
36
37    syswindows.h: Mostly a wrapper around <windows.h>, including missing
38    defines as necessary.  Also includes stuff needed on both Cygwin and
39    native Windows, regardless of window system chosen.
40
41    console-msw.h: Used on both Cygwin and native Windows, but only when
42    native window system (as opposed to X) chosen.
43
44    nt.h: [will be renamed to win32.h] Used only on native Windows, and
45    regardless of window system chosen -- but used on both purely native
46    Windows (s/windowsnt.h) and MinGW (s/mingw32.h).
47
48    ntheap.h: Used only on native Windows and only when standard dumping
49    mechanism (unexnt.c) used.
50
51    All of the last three files include the first.
52 */
53
54 #ifndef WIN32_LEAN_AND_MEAN
55 #define WIN32_LEAN_AND_MEAN
56 #endif
57
58 #include <windows.h>
59
60 #if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21
61 extern BOOL WINAPI DdeFreeStringHandle(DWORD,HSZ);
62 extern BOOL WINAPI PlaySound(LPCSTR,HMODULE,DWORD);
63 #define stricmp strcasecmp
64 #define FONTENUMPROC FONTENUMEXPROC
65 #define ntmTm ntmentm
66 #elif defined (WIN32_LEAN_AND_MEAN)
67 #ifdef HAVE_X_WINDOWS
68 /* Christ almighty.  The problems you get when combining two large code bases,
69    neither with any respect for namespace purity. */
70 #undef Status
71 #endif
72 #include <winspool.h>
73 #ifdef HAVE_X_WINDOWS
74 #define Status int
75 #endif
76 #include <mmsystem.h>
77 #include <shellapi.h>
78 #include <ddeml.h>
79 #endif
80
81 /* mmsystem.h defines. */
82 #ifndef SND_ASYNC
83 #define SND_ASYNC               1
84 #endif
85 #ifndef SND_NODEFAULT
86 #define SND_NODEFAULT           2
87 #endif
88 #ifndef SND_MEMORY
89 #define SND_MEMORY              4
90 #endif
91 #ifndef SND_FILENAME
92 #define SND_FILENAME            0x2000L
93 #endif
94
95 /* winspool.h defines. */
96 #ifndef PHYSICALWIDTH
97 #define PHYSICALWIDTH 110
98 #endif
99 #ifndef PHYSICALHEIGHT
100 #define PHYSICALHEIGHT 111
101 #endif
102 #ifndef PHYSICALOFFSETX
103 #define PHYSICALOFFSETX 112
104 #endif
105 #ifndef PHYSICALOFFSETY
106 #define PHYSICALOFFSETY 113
107 #endif
108
109 /* windows.h defines. */
110 #if defined (CYGWIN) && (CYGWIN_VERSION_DLL_MAJOR < 20)
111 typedef NMHDR *LPNMHDR;
112 #endif
113
114 #ifndef SPI_GETWHEELSCROLLLINES
115 #define SPI_GETWHEELSCROLLLINES 104
116 #endif
117 #ifndef WHEEL_PAGESCROLL
118 #define WHEEL_PAGESCROLL (UINT_MAX)
119 #endif
120 #ifndef WHEEL_DELTA
121 #define WHEEL_DELTA 120
122 #endif
123 #ifndef WM_MOUSEWHEEL
124 #define WM_MOUSEWHEEL 0x20A
125 #endif
126 #ifndef VK_APPS
127 #define VK_APPS                 0x5D
128 #endif
129 #ifndef SIF_TRACKPOS
130 #define SIF_TRACKPOS            0x0010
131 #endif
132 #ifndef FW_BLACK
133 #define FW_BLACK        FW_HEAVY
134 #endif
135 #ifndef FW_ULTRABOLD
136 #define FW_ULTRABOLD    FW_EXTRABOLD
137 #endif
138 #ifndef FW_DEMIBOLD
139 #define FW_DEMIBOLD     FW_SEMIBOLD
140 #endif
141 #ifndef FW_ULTRALIGHT
142 #define FW_ULTRALIGHT   FW_EXTRALIGHT
143 #endif
144 #ifndef APPCMD_FILTERINITS
145 #define APPCMD_FILTERINITS      0x20L
146 #endif
147 #ifndef CBF_FAIL_SELFCONNECTIONS
148 #define CBF_FAIL_SELFCONNECTIONS 0x1000
149 #endif
150 #ifndef CBF_SKIP_ALLNOTIFICATIONS
151 #define CBF_SKIP_ALLNOTIFICATIONS       0x3C0000
152 #endif
153 #ifndef CBF_FAIL_ADVISES
154 #define CBF_FAIL_ADVISES        0x4000
155 #endif
156 #ifndef CBF_FAIL_POKES
157 #define CBF_FAIL_POKES          0x10000
158 #endif
159 #ifndef CBF_FAIL_REQUESTS
160 #define CBF_FAIL_REQUESTS       0x20000
161 #endif
162 #ifndef SZDDESYS_TOPIC
163 #define SZDDESYS_TOPIC          "System"
164 #endif
165 #ifndef JOHAB_CHARSET
166 #define JOHAB_CHARSET           130
167 #endif
168 #ifndef MAC_CHARSET
169 #define MAC_CHARSET             77
170 #endif
171
172 /***************************************************************/
173
174 /* Definitions for Mule under MS Windows */
175
176 #include <wchar.h>
177
178 #ifdef CYGWIN
179
180 /* All but wcscmp and wcslen left out of Cygwin headers -- but present
181    in /usr/include/mingw32/string.h! */
182 wchar_t* wcscat (wchar_t*, const wchar_t*);
183 wchar_t* wcschr (const wchar_t*, wchar_t);
184 int     wcscoll (const wchar_t*, const wchar_t*);
185 wchar_t* wcscpy (wchar_t*, const wchar_t*);
186 size_t  wcscspn (const wchar_t*, const wchar_t*);
187 /* Note: No wcserror in CRTDLL. */
188 wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t);
189 int     wcsncmp(const wchar_t*, const wchar_t*, size_t);
190 wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
191 wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
192 wchar_t* wcsrchr(const wchar_t*, wchar_t);
193 size_t  wcsspn(const wchar_t*, const wchar_t*);
194 wchar_t* wcsstr(const wchar_t*, const wchar_t*);
195 wchar_t* wcstok(wchar_t*, const wchar_t*);
196 size_t  wcsxfrm(wchar_t*, const wchar_t*, size_t);
197
198 #endif /* CYGWIN */
199
200 // extern int mswindows_windows9x_p;
201 /* #define XEUNICODE_P (!mswindows_windows9x_p) */
202 #define XEUNICODE_P 0
203
204 #define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR))
205 #define MAX_XETCHAR_SIZE sizeof (WCHAR)
206 #define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg))
207 /* We need to do this indirection in case ARG is also a manifest constant.
208    I don't really understand why. --ben */
209 #define XETEXT(arg) XETEXT1(arg)
210 #define XECOPY_TCHAR(ptr, ch) \
211   (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch)))
212 #define xetcslen(arg) (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg))
213 #define xetcscmp(s1, s2) \
214   (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \
215    : strcmp (s1, s2))
216 #define xetcscpy(s1, s2) \
217   (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \
218    : strcpy (s1, s2))
219 #define xetcschr(s, ch) \
220   (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \
221    : strchr (s, ch))
222 #define xetcsrchr(s, ch) \
223   (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \
224    : strrchr (s, ch))
225
226
227 #define LOCAL_FILE_FORMAT_TO_TSTR(path, out)            \
228 do {                                                    \
229   Bufbyte *lttff;                                       \
230                                                         \
231   LOCAL_TO_WIN32_FILE_FORMAT (path, lttff);             \
232   C_STRING_TO_EXTERNAL (lttff, out, Qmswindows_tstr);   \
233 } while (0)
234
235 Lisp_Object tstr_to_local_file_format (Extbyte *pathout);
236
237 #ifdef CYGWIN
238 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)                       \
239 do {                                                                    \
240   Lisp_Object ltwff1 = (path);                                          \
241   int ltwff2 =                                                          \
242     cygwin_posix_to_win32_path_list_buf_size (XSTRING_DATA (ltwff1));   \
243   pathout = (Bufbyte *) alloca (ltwff2);                                \
244   cygwin_posix_to_win32_path_list (XSTRING_DATA (ltwff1), pathout);     \
245 } while (0)
246 #else
247 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)       \
248 do {                                                    \
249   (pathout) = XSTRING_DATA (path);                      \
250 } while (0)
251 #endif
252
253 #ifdef CYGWIN
254 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
255 do {                                                    \
256   Bufbyte *wtlff1 = (path);                             \
257   int wtlff2 =                                          \
258     cygwin_win32_to_posix_path_list_buf_size (wtlff1);  \
259   Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);        \
260   cygwin_win32_to_posix_path_list (wtlff1, wtlff3);     \
261   (pathout) = build_string (wtlff3);                    \
262 } while (0)
263 #else
264 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
265 do {                                                    \
266   (pathout) = build_string (path);                      \
267 } while (0)
268 #endif
269
270 extern BOOL (WINAPI *xSwitchToThread) (VOID);
271
272 extern HKL (WINAPI *xGetKeyboardLayout) (DWORD);
273 extern BOOL (WINAPI *xSetMenuDefaultItem) (HMENU, UINT, UINT);
274 extern BOOL (WINAPI *xInsertMenuItemA) (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
275 extern BOOL (WINAPI *xInsertMenuItemW) (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
276 extern HANDLE (WINAPI *xLoadImageA) (HINSTANCE, LPCSTR, UINT, int, int, UINT);
277 extern HANDLE (WINAPI *xLoadImageW) (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
278 extern ATOM (WINAPI *xRegisterClassExA) (CONST WNDCLASSEXA *);
279 extern ATOM (WINAPI *xRegisterClassExW) (CONST WNDCLASSEXW *);
280
281 extern int (WINAPI *xEnumFontFamiliesExA) (HDC, LPLOGFONTA, FONTENUMPROCA,
282                                            LPARAM, DWORD);
283 extern int (WINAPI *xEnumFontFamiliesExW) (HDC, LPLOGFONTW, FONTENUMPROCW,
284                                            LPARAM, DWORD);
285
286 extern DWORD (WINAPI *xSHGetFileInfoA) (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT,
287                                         UINT);
288 extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *,
289                                         UINT, UINT);
290
291 #endif /* INCLUDED_syswindows_h_ */