Sync up with r21-4-22.
[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 #ifndef LOCALE_RETURN_NUMBER
184 #define LOCALE_RETURN_NUMBER    0x20000000
185 #endif
186
187 /***************************************************************/
188
189 /* Definitions for Mule under MS Windows */
190
191 #include <wchar.h>
192
193 #if defined (CYGWIN) && (CYGWIN_VERSION_DLL_COMBINED < 190)
194
195 /* All but wcscmp and wcslen left out of Cygwin headers -- but present
196    in /usr/include/mingw32/string.h! */
197 wchar_t* wcscat (wchar_t*, const wchar_t*);
198 wchar_t* wcschr (const wchar_t*, wchar_t);
199 int     wcscoll (const wchar_t*, const wchar_t*);
200 wchar_t* wcscpy (wchar_t*, const wchar_t*);
201 size_t  wcscspn (const wchar_t*, const wchar_t*);
202 /* Note: No wcserror in CRTDLL. */
203 wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t);
204 int     wcsncmp(const wchar_t*, const wchar_t*, size_t);
205 wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
206 wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
207 wchar_t* wcsrchr(const wchar_t*, wchar_t);
208 size_t  wcsspn(const wchar_t*, const wchar_t*);
209 wchar_t* wcsstr(const wchar_t*, const wchar_t*);
210 wchar_t* wcstok(wchar_t*, const wchar_t*);
211 size_t  wcsxfrm(wchar_t*, const wchar_t*, size_t);
212
213 #endif /* CYGWIN */
214
215 // extern int mswindows_windows9x_p;
216 /* #define XEUNICODE_P (!mswindows_windows9x_p) */
217 #define XEUNICODE_P 0
218
219 #define XETCHAR_SIZE (XEUNICODE_P ? sizeof (WCHAR) : sizeof (CHAR))
220 #define MAX_XETCHAR_SIZE sizeof (WCHAR)
221 #define XETEXT1(arg) (XEUNICODE_P ? ((char *) (L##arg)) : (arg))
222 /* We need to do this indirection in case ARG is also a manifest constant.
223    I don't really understand why. --ben */
224 #define XETEXT(arg) XETEXT1(arg)
225 #define XECOPY_TCHAR(ptr, ch) \
226   (XEUNICODE_P ? (* (LPWSTR) (ptr) = L##ch) : (* (LPSTR) (ptr) = (ch)))
227 #define xetcslen(arg) (XEUNICODE_P ? wcslen ((wchar_t *) arg) : strlen (arg))
228 #define xetcscmp(s1, s2) \
229   (XEUNICODE_P ? wcscmp ((wchar_t *) s1, (wchar_t *) s2) \
230    : strcmp (s1, s2))
231 #define xetcscpy(s1, s2) \
232   (XEUNICODE_P ? (char *) wcscpy ((wchar_t *) s1, (wchar_t *) s2) \
233    : strcpy (s1, s2))
234 #define xetcschr(s, ch) \
235   (XEUNICODE_P ? (char *) wcschr ((wchar_t *) s, (WCHAR) ch) \
236    : strchr (s, ch))
237 #define xetcsrchr(s, ch) \
238   (XEUNICODE_P ? (char *) wcsrchr ((wchar_t *) s, (WCHAR) ch) \
239    : strrchr (s, ch))
240
241
242 #define LOCAL_FILE_FORMAT_TO_TSTR(path, out)            \
243 do {                                                    \
244   Bufbyte *lttff;                                       \
245                                                         \
246   LOCAL_TO_WIN32_FILE_FORMAT (path, lttff);             \
247   C_STRING_TO_EXTERNAL (lttff, out, Qmswindows_tstr);   \
248 } while (0)
249
250 Lisp_Object tstr_to_local_file_format (Extbyte *pathout);
251
252 #ifdef CYGWIN
253 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)                       \
254 do {                                                                    \
255   Lisp_Object ltwff1 = (path);                                          \
256   Bufbyte* ltwffp = XSTRING_DATA (ltwff1);                              \
257   if (isalpha (ltwffp[0]) && (IS_DEVICE_SEP (ltwffp[1])))                       \
258     pathout = ltwffp;                                                   \
259   else {                                                                        \
260     int ltwff2 =                                                                \
261       cygwin_posix_to_win32_path_list_buf_size (ltwffp);        \
262     pathout = (Bufbyte *) alloca (ltwff2);                              \
263     cygwin_posix_to_win32_path_list (ltwffp, pathout);  \
264   }                                                                     \
265 } while (0)
266 #else
267 #define LOCAL_TO_WIN32_FILE_FORMAT(path, pathout)       \
268 do {                                                    \
269   (pathout) = XSTRING_DATA (path);                      \
270 } while (0)
271 #endif
272
273 #ifdef CYGWIN
274 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
275 do {                                                    \
276   Bufbyte *wtlff1 = (path);                             \
277   int wtlff2 =                                          \
278     cygwin_win32_to_posix_path_list_buf_size (wtlff1);  \
279   Bufbyte *wtlff3 = (Bufbyte *) alloca (wtlff2);        \
280   cygwin_win32_to_posix_path_list (wtlff1, wtlff3);     \
281   (pathout) = build_string (wtlff3);                    \
282 } while (0)
283 #else
284 #define WIN32_TO_LOCAL_FILE_FORMAT(path, pathout)       \
285 do {                                                    \
286   (pathout) = build_string (path);                      \
287 } while (0)
288 #endif
289
290 extern BOOL (WINAPI *xSwitchToThread) (VOID);
291
292 extern HKL (WINAPI *xGetKeyboardLayout) (DWORD);
293 extern BOOL (WINAPI *xSetMenuDefaultItem) (HMENU, UINT, UINT);
294 extern BOOL (WINAPI *xInsertMenuItemA) (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
295 extern BOOL (WINAPI *xInsertMenuItemW) (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
296 extern HANDLE (WINAPI *xLoadImageA) (HINSTANCE, LPCSTR, UINT, int, int, UINT);
297 extern HANDLE (WINAPI *xLoadImageW) (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
298 extern ATOM (WINAPI *xRegisterClassExA) (CONST WNDCLASSEXA *);
299 extern ATOM (WINAPI *xRegisterClassExW) (CONST WNDCLASSEXW *);
300
301 extern int (WINAPI *xEnumFontFamiliesExA) (HDC, LPLOGFONTA, FONTENUMPROCA,
302                                            LPARAM, DWORD);
303 extern int (WINAPI *xEnumFontFamiliesExW) (HDC, LPLOGFONTW, FONTENUMPROCW,
304                                            LPARAM, DWORD);
305
306 extern DWORD (WINAPI *xSHGetFileInfoA) (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT,
307                                         UINT);
308 extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *,
309                                         UINT, UINT);
310
311 #endif /* INCLUDED_syswindows_h_ */