213
|
1 /* Device functions for mswindows.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
|
24 /* Authorship:
|
|
25
|
|
26 Original authors: Jamie Zawinski and the FSF
|
|
27 Rewritten by Ben Wing and Chuck Thompson.
|
272
|
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
213
|
29 */
|
|
30
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
|
34
|
|
35 #include "console-msw.h"
|
|
36 #include "console-stream.h"
|
|
37 #include "events.h"
|
|
38 #include "faces.h"
|
|
39 #include "frame.h"
|
249
|
40 #include "sysdep.h"
|
|
41
|
|
42 /* win32 DDE management library globals */
|
|
43 DWORD mswindows_dde_mlid;
|
|
44 HSZ mswindows_dde_service;
|
|
45 HSZ mswindows_dde_topic_system;
|
|
46 HSZ mswindows_dde_item_open;
|
213
|
47
|
278
|
48 #ifdef __CYGWIN32__
|
|
49 typedef struct tagINITCOMMONCONTROLSEX
|
|
50 {
|
|
51 DWORD dwSize;
|
|
52 DWORD dwICC;
|
|
53 } INITCOMMONCONTROLSEX;
|
|
54 WINAPI BOOL InitCommonControlsEx (INITCOMMONCONTROLSEX*);
|
|
55 #else
|
|
56 #include <commctrl.h>
|
|
57 #endif
|
263
|
58
|
|
59 /* Control conversion of upper case file names to lower case.
|
|
60 nil means no, t means yes. */
|
|
61 Lisp_Object Vmswindows_downcase_file_names;
|
|
62
|
|
63 /* Control whether stat() attempts to determine file type and link count
|
|
64 exactly, at the expense of slower operation. Since true hard links
|
|
65 are supported on NTFS volumes, this is only relevant on NT. */
|
|
66 Lisp_Object Vmswindows_get_true_file_attributes;
|
|
67
|
213
|
68 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
|
|
69
|
|
70 static void
|
|
71 mswindows_init_device (struct device *d, Lisp_Object props)
|
|
72 {
|
249
|
73 WNDCLASSEX wc;
|
213
|
74 HWND desktop;
|
|
75 HDC hdc;
|
278
|
76 #ifdef HAVE_TOOLBARS
|
|
77 INITCOMMONCONTROLSEX iccex;
|
|
78 xzero(iccex);
|
|
79 #endif
|
213
|
80
|
|
81 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
|
|
82 init_baud_rate (d);
|
|
83 init_one_device (d);
|
|
84
|
|
85 d->device_data = xnew_and_zero (struct mswindows_device);
|
|
86
|
|
87 desktop = GetDesktopWindow();
|
|
88 hdc = GetDC(desktop);
|
|
89 DEVICE_MSWINDOWS_LOGPIXELSX(d) = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
90 DEVICE_MSWINDOWS_LOGPIXELSY(d) = GetDeviceCaps(hdc, LOGPIXELSY);
|
|
91 DEVICE_MSWINDOWS_PLANES(d) = GetDeviceCaps(hdc, PLANES);
|
|
92 /* FIXME: Only valid if RC_PALETTE bit set in RASTERCAPS,
|
|
93 what should we return for a non-palette-based device? */
|
|
94 DEVICE_MSWINDOWS_CELLS(d) = GetDeviceCaps(hdc, SIZEPALETTE);
|
|
95 DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES);
|
|
96 DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES);
|
|
97 DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE);
|
|
98 DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE);
|
267
|
99 DEVICE_MSWINDOWS_BITSPIXEL(d) = GetDeviceCaps(hdc, BITSPIXEL);
|
213
|
100 ReleaseDC(desktop, hdc);
|
|
101
|
217
|
102 DEVICE_CLASS(d) = Qcolor;
|
223
|
103
|
|
104 /* Register the main window class */
|
249
|
105 wc.cbSize = sizeof (WNDCLASSEX);
|
223
|
106 wc.style = CS_OWNDC; /* One DC per window */
|
|
107 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
|
|
108 wc.cbClsExtra = 0;
|
|
109 wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
|
|
110 wc.hInstance = NULL; /* ? */
|
227
|
111 wc.hIcon = LoadIcon (GetModuleHandle(NULL), XEMACS_CLASS);
|
223
|
112 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
|
113 /* Background brush is only used during sizing, when XEmacs cannot
|
|
114 take over */
|
|
115 wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
|
|
116 wc.lpszMenuName = NULL;
|
|
117 wc.lpszClassName = XEMACS_CLASS;
|
249
|
118 wc.hIconSm = LoadImage (GetModuleHandle (NULL), XEMACS_CLASS,
|
|
119 IMAGE_ICON, 16, 16, 0);
|
|
120 RegisterClassEx (&wc);
|
278
|
121 #ifdef HAVE_TOOLBARS
|
|
122 iccex.dwSize = sizeof (iccex);
|
|
123 iccex.dwICC = ICC_BAR_CLASSES;
|
|
124 #ifdef __CYGWIN32__
|
|
125 InitCommonControls ();
|
|
126 #else
|
|
127 InitCommonControlsEx (&iccex);
|
|
128 #endif
|
|
129 #endif
|
249
|
130 }
|
|
131
|
|
132 static void
|
|
133 mswindows_finish_init_device (struct device *d, Lisp_Object props)
|
|
134 {
|
|
135 /* Initialise DDE management library and our related globals */
|
|
136 mswindows_dde_mlid = 0;
|
278
|
137 DdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
|
249
|
138 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES|
|
|
139 CBF_FAIL_POKES|CBF_FAIL_REQUESTS|CBF_SKIP_ALLNOTIFICATIONS, 0);
|
|
140
|
|
141 mswindows_dde_service = DdeCreateStringHandle (mswindows_dde_mlid, XEMACS_CLASS, 0);
|
|
142 mswindows_dde_topic_system = DdeCreateStringHandle (mswindows_dde_mlid, SZDDESYS_TOPIC, 0);
|
|
143 mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid,
|
|
144 TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0);
|
|
145 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
|
|
146 }
|
|
147
|
|
148 static void
|
|
149 mswindows_delete_device (struct device *d)
|
|
150 {
|
|
151 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER);
|
|
152 DdeUninitialize (mswindows_dde_mlid);
|
213
|
153 }
|
|
154
|
|
155 static int
|
|
156 mswindows_device_pixel_width (struct device *d)
|
|
157 {
|
|
158 return(DEVICE_MSWINDOWS_HORZRES(d));
|
|
159 }
|
|
160
|
|
161 static int
|
|
162 mswindows_device_pixel_height (struct device *d)
|
|
163 {
|
|
164 return(DEVICE_MSWINDOWS_VERTRES(d));
|
|
165 }
|
|
166
|
|
167 static int
|
|
168 mswindows_device_mm_width (struct device *d)
|
|
169 {
|
|
170 return(DEVICE_MSWINDOWS_HORZSIZE(d));
|
|
171 }
|
|
172
|
|
173 static int
|
|
174 mswindows_device_mm_height (struct device *d)
|
|
175 {
|
|
176 return(DEVICE_MSWINDOWS_VERTSIZE(d));
|
|
177 }
|
|
178
|
|
179 static int
|
|
180 mswindows_device_bitplanes (struct device *d)
|
|
181 {
|
|
182 return(DEVICE_MSWINDOWS_PLANES(d));
|
|
183 }
|
|
184
|
|
185 static int
|
|
186 mswindows_device_color_cells (struct device *d)
|
|
187 {
|
|
188 return(DEVICE_MSWINDOWS_CELLS(d));
|
|
189 }
|
|
190
|
269
|
191 static unsigned int
|
|
192 mswindows_device_implementation_flags (void)
|
|
193 {
|
|
194 return XDEVIMPF_PIXEL_GEOMETRY;
|
|
195 }
|
213
|
196
|
|
197 /************************************************************************/
|
|
198 /* initialization */
|
|
199 /************************************************************************/
|
|
200
|
|
201 void
|
|
202 syms_of_device_mswindows (void)
|
|
203 {
|
|
204 defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win");
|
|
205 defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win");
|
263
|
206
|
|
207 DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /*
|
|
208 Non-nil means convert all-upper case file names to lower case.
|
|
209 This applies when performing completions and file name expansion.*/ );
|
|
210 Vmswindows_downcase_file_names = Qnil;
|
|
211
|
|
212 DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /*
|
|
213 "Non-nil means determine accurate link count in file-attributes.
|
|
214 This option slows down file-attributes noticeably, so is disabled by
|
|
215 default. Note that it is only useful for files on NTFS volumes,
|
|
216 where hard links are supported.
|
|
217 */ );
|
|
218 Vmswindows_get_true_file_attributes = Qnil;
|
213
|
219 }
|
|
220
|
|
221 void
|
|
222 console_type_create_device_mswindows (void)
|
|
223 {
|
|
224 CONSOLE_HAS_METHOD (mswindows, init_device);
|
249
|
225 CONSOLE_HAS_METHOD (mswindows, finish_init_device);
|
213
|
226 /* CONSOLE_HAS_METHOD (mswindows, mark_device); */
|
249
|
227 CONSOLE_HAS_METHOD (mswindows, delete_device);
|
213
|
228 CONSOLE_HAS_METHOD (mswindows, device_pixel_width);
|
|
229 CONSOLE_HAS_METHOD (mswindows, device_pixel_height);
|
|
230 CONSOLE_HAS_METHOD (mswindows, device_mm_width);
|
|
231 CONSOLE_HAS_METHOD (mswindows, device_mm_height);
|
|
232 CONSOLE_HAS_METHOD (mswindows, device_bitplanes);
|
|
233 CONSOLE_HAS_METHOD (mswindows, device_color_cells);
|
269
|
234 CONSOLE_HAS_METHOD (mswindows, device_implementation_flags);
|
213
|
235 }
|
|
236
|
|
237 void
|
|
238 vars_of_device_mswindows (void)
|
|
239 {
|
|
240 }
|