XEmacs 21.4.6 "Common Lisp".
[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 <shlobj.h>
78 #include <shellapi.h>
79 #include <ddeml.h>
80 #endif
81
82 /* mmsystem.h defines. */
83 #ifndef SND_ASYNC
84 #define SND_ASYNC               1
85 #endif
86 #ifndef SND_NODEFAULT
87 #define SND_NODEFAULT           2
88 #endif
89 #ifndef SND_MEMORY
90 #define SND_MEMORY              4
91 #endif
92 #ifndef SND_FILENAME
93 #define SND_FILENAME            0x2000L
94 #endif
95
96 /* winspool.h defines. */
97 #ifndef PHYSICALWIDTH
98 #define PHYSICALWIDTH 110
99 #endif
100 #ifndef PHYSICALHEIGHT
101 #define PHYSICALHEIGHT 111
102 #endif
103 #ifndef PHYSICALOFFSETX
104 #define PHYSICALOFFSETX 112
105 #endif
106 #ifndef PHYSICALOFFSETY
107 #define PHYSICALOFFSETY 113
108 #endif
109
110 /* shlobj.h defines. */
111 #ifndef BIF_EDITBOX
112 #define BIF_EDITBOX 0x10
113 #endif
114 #ifndef BIF_VALIDATE
115 #define BIF_VALIDATE 0x20
116 #endif
117 #ifndef BFFM_VALIDATEFAILED
118 #define BFFM_VALIDATEFAILED 3
119 #endif
120
121 /* windows.h defines. */
122 #if defined (CYGWIN) && (CYGWIN_VERSION_DLL_MAJOR < 20)
123 typedef NMHDR *LPNMHDR;
124 #endif
125
126 #ifndef SPI_GETWHEELSCROLLLINES
127 #define SPI_GETWHEELSCROLLLINES 104
128 #endif
129 #ifndef WHEEL_PAGESCROLL
130 #define WHEEL_PAGESCROLL (UINT_MAX)
131 #endif
132 #ifndef WHEEL_DELTA
133 #define WHEEL_DELTA 120
134 #endif
135 #ifndef WM_MOUSEWHEEL
136 #define WM_MOUSEWHEEL 0x20A
137 #endif
138 #ifndef VK_APPS
139 #define VK_APPS                 0x5D
140 #endif
141 #ifndef SIF_TRACKPOS
142 #define SIF_TRACKPOS            0x0010
143 #endif
144 #ifndef FW_BLACK
145 #define FW_BLACK        FW_HEAVY
146 #endif
147 #ifndef FW_ULTRABOLD
148 #define FW_ULTRABOLD    FW_EXTRABOLD
149 #endif
150 #ifndef FW_DEMIBOLD
151 #define FW_DEMIBOLD     FW_SEMIBOLD
152 #endif
153 #ifndef FW_ULTRALIGHT
154 #define FW_ULTRALIGHT   FW_EXTRALIGHT
155 #endif
156 #ifndef APPCMD_FILTERINITS
157 #define APPCMD_FILTERINITS      0x20L
158 #endif
159 #ifndef CBF_FAIL_SELFCONNECTIONS
160 #define CBF_FAIL_SELFCONNECTIONS 0x1000
161 #endif
162 #ifndef CBF_SKIP_ALLNOTIFICATIONS
163 #define CBF_SKIP_ALLNOTIFICATIONS       0x3C0000
164 #endif
165 #ifndef CBF_FAIL_ADVISES
166 #define CBF_FAIL_ADVISES        0x4000
167 #endif
168 #ifndef CBF_FAIL_POKES
169 #define CBF_FAIL_POKES          0x10000
170 #endif
171 #ifndef CBF_FAIL_REQUESTS
172 #define CBF_FAIL_REQUESTS       0x20000
173 #endif
174 #ifndef SZDDESYS_TOPIC
175 #define SZDDESYS_TOPIC          "System"
176 #endif
177 #ifndef JOHAB_CHARSET
178 #define JOHAB_CHARSET           130
179 #endif
180 #ifndef MAC_CHARSET
181 #define MAC_CHARSET             77
182 #endif
183
184 /***************************************************************/
185
186 /* Definitions for Mule under MS Windows */
187
188 #include <wchar.h>
189
190 #ifdef CYGWIN
191
192 /* All but wcscmp and wcslen left out of Cygwin headers -- but present
193    in /usr/include/mingw32/string.h! */
194 wchar_t* wcscat (wchar_t*, const wchar_t*);
195 wchar_t* wcschr (const wchar_t*, wchar_t);
196 int     wcscoll (const wchar_t*, const wchar_t*);
197 wchar_t* wcscpy (wchar_t*, const wchar_t*);
198 size_t  wcscspn (const wchar_t*, const wchar_t*);
199 /* Note: No wcserror in CRTDLL. */
200 wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t);
201 int     wcsncmp(const wchar_t*, const wchar_t*, size_t);
202 wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
203 wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
204 wchar_t* wcsrchr(const wchar_t*, wchar_t);
205 size_t  wcsspn(const wchar_t*, const wchar_t*);
206 wchar_t* wcsstr(const wchar_t*, const wchar_t*);
207 wchar_t* wcstok(wchar_t*, const wchar_t*);
208 size_t  wcsxfrm(wchar_t*, const wchar_t*, size_t);
209
210 #endif /* CYGWIN */
211
212 // extern int mswindows_windows9x_p;
213 /* #define XEUNICODE_P (!mswindows_windows9x_p) */
214 #define XEUNICODE_P 0
215
216 #define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR))
217 #define MAX_XETCHAR_SIZE sizeof (WCHAR)
218 #define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg))
219 /* We need to do this indirection in case ARG is also a manifest constant.
220    I don't really understand why. --ben */
221 #define XETEXT(arg) XETEXT1(arg)
222 #define XECOPY_TCHAR(ptr, ch) \
223   (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch)))
224 #define xetcslen(arg) (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg))
225 #define xetcscmp(s1, s2) \
226   (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \
227    : strcmp (s1, s2))
228 #define xetcscpy(s1, s2) \
229   (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \
230    : strcpy (s1, s2))
231 #define xetcschr(s, ch) \
232   (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \
233    : strchr (s, ch))
234 #define xetcsrchr(s, ch) \
235   (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \
236    : strrchr (s, ch))
237
238
239 #define LOCAL_FILE_FORMAT_TO_TSTR(path, out)            \
240 do {                                                    \
241   Bufbyte *lttff;                                       \
242                                                         \
243   LOCAL_TO_WIN32_FILE_FORMAT (path, lttff);             \
244   C_STRING_TO_EXTERNAL (lttff, out, Qmswindows_tstr);   \
245 } while (0)
246
247 Lisp_Object tstr_to_local_file_format (Extbyte *pathout);
248
249 #ifdef CYGWIN
250 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)                       \
251 do {                                                                    \
252   Lisp_Object ltwff1 = (path);                                          \
253   Bufbyte* ltwffp = XSTRING_DATA (ltwff1);                              \
254   if (isalpha (ltwffp[0]) && (IS_DEVICE_SEP (ltwffp[1])))                       \
255     pathout = ltwffp;                                                   \
256   else {                                                                        \
257     int ltwff2 =                                                                \
258       cygwin_posix_to_win32_path_list_buf_size (ltwffp);        \
259     pathout = (Bufbyte *) alloca (ltwff2);                              \
260     cygwin_posix_to_win32_path_list (ltwffp, pathout);  \
261   }                                                                     \
262 } while (0)
263 #else
264 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)       \
265 do {                                                    \
266   (pathout) = XSTRING_DATA (path);                      \
267 } while (0)
268 #endif
269
270 #ifdef CYGWIN
271 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
272 do {                                                    \
273   Bufbyte *wtlff1 = (path);                             \
274   int wtlff2 =                                          \
275     cygwin_win32_to_posix_path_list_buf_size (wtlff1);  \
276   Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);        \
277   cygwin_win32_to_posix_path_list (wtlff1, wtlff3);     \
278   (pathout) = build_string (wtlff3);                    \
279 } while (0)
280 #else
281 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
282 do {                                                    \
283   (pathout) = build_string (path);                      \
284 } while (0)
285 #endif
286
287 extern BOOL (WINAPI *xSwitchToThread) (VOID);
288
289 extern HKL (WINAPI *xGetKeyboardLayout) (DWORD);
290 extern BOOL (WINAPI *xSetMenuDefaultItem) (HMENU, UINT, UINT);
291 extern BOOL (WINAPI *xInsertMenuItemA) (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
292 extern BOOL (WINAPI *xInsertMenuItemW) (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
293 extern HANDLE (WINAPI *xLoadImageA) (HINSTANCE, LPCSTR, UINT, int, int, UINT);
294 extern HANDLE (WINAPI *xLoadImageW) (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
295 extern ATOM (WINAPI *xRegisterClassExA) (CONST WNDCLASSEXA *);
296 extern ATOM (WINAPI *xRegisterClassExW) (CONST WNDCLASSEXW *);
297
298 extern int (WINAPI *xEnumFontFamiliesExA) (HDC, LPLOGFONTA, FONTENUMPROCA,
299                                            LPARAM, DWORD);
300 extern int (WINAPI *xEnumFontFamiliesExW) (HDC, LPLOGFONTW, FONTENUMPROCW,
301                                            LPARAM, DWORD);
302
303 extern DWORD (WINAPI *xSHGetFileInfoA) (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT,
304                                         UINT);
305 extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *,
306                                         UINT, UINT);
307
308 #endif /* INCLUDED_syswindows_h_ */