428
|
1 /* Functions for the mswindows window system.
|
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
771
|
3 Copyright (C) 1995, 1996, 2001, 2002 Ben Wing.
|
428
|
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 synched with FSF. */
|
|
23
|
771
|
24 /* This file Mule-ized, 8-14-2000. */
|
|
25
|
428
|
26 /* Authorship:
|
|
27
|
|
28 Ultimately based on FSF.
|
|
29 Substantially rewritten for XEmacs by Ben Wing.
|
|
30 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
|
31 Graphics features added and frame resizing fiddled with by Andy Piper.
|
|
32 */
|
|
33
|
|
34 #include <config.h>
|
|
35 #include "lisp.h"
|
|
36
|
|
37 #include "buffer.h"
|
872
|
38 #include "device-impl.h"
|
428
|
39 #include "elhash.h"
|
|
40 #include "events.h"
|
|
41 #include "faces.h"
|
872
|
42 #include "frame-impl.h"
|
428
|
43 #include "redisplay.h"
|
|
44 #include "window.h"
|
|
45
|
872
|
46 #include "console-msw-impl.h"
|
800
|
47 #include "glyphs-msw.h"
|
|
48
|
428
|
49 #define MSWINDOWS_FRAME_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW)
|
|
50 #define MSWINDOWS_POPUP_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP \
|
|
51 | WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX)
|
|
52
|
|
53 #define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
|
54 #define MSWINDOWS_POPUP_EXSTYLE WS_EX_PALETTEWINDOW
|
|
55
|
|
56 /* Default popup left top corner offset from the same
|
|
57 corner of the parent frame, in pixel */
|
|
58 #define POPUP_OFFSET 30
|
|
59
|
|
60 /* Default popup size, in characters */
|
|
61 #define POPUP_WIDTH 30
|
|
62 #define POPUP_HEIGHT 10
|
|
63
|
793
|
64 /* Default regular frame size, in characters; if too big, it will get
|
|
65 shrunk to the workspace size */
|
428
|
66 #define DEFAULT_FRAME_WIDTH 80
|
793
|
67 #define DEFAULT_FRAME_HEIGHT 50
|
428
|
68
|
|
69 #ifdef HAVE_MENUBARS
|
|
70 #define ADJR_MENUFLAG TRUE
|
|
71 #else
|
|
72 #define ADJR_MENUFLAG FALSE
|
|
73 #endif
|
|
74
|
|
75 /* Default properties to use when creating frames. */
|
|
76 Lisp_Object Vdefault_mswindows_frame_plist;
|
440
|
77 Lisp_Object Vdefault_msprinter_frame_plist;
|
428
|
78 Lisp_Object Vmswindows_use_system_frame_size_defaults;
|
|
79
|
|
80 /* This does not need to be GC protected, as it holds a
|
|
81 frame Lisp_Object already protected by Fmake_frame */
|
|
82 Lisp_Object Vmswindows_frame_being_created;
|
|
83
|
1204
|
84 static const struct memory_description mswindows_frame_data_description_1 [] = {
|
|
85 #ifdef HAVE_TOOLBARS
|
|
86 { XD_LISP_OBJECT, offsetof (struct mswindows_frame, toolbar_hash_table) },
|
|
87 #endif
|
|
88 { XD_LISP_OBJECT, offsetof (struct mswindows_frame, menu_hash_table) },
|
|
89 { XD_LISP_OBJECT, offsetof (struct mswindows_frame, widget_hash_table1) },
|
|
90 { XD_LISP_OBJECT, offsetof (struct mswindows_frame, widget_hash_table2) },
|
|
91 { XD_LISP_OBJECT, offsetof (struct mswindows_frame, widget_hash_table3) },
|
|
92 { XD_END }
|
|
93 };
|
|
94
|
|
95 extern const struct sized_memory_description mswindows_frame_data_description;
|
|
96
|
|
97 const struct sized_memory_description mswindows_frame_data_description = {
|
|
98 sizeof (struct mswindows_frame), mswindows_frame_data_description_1
|
|
99 };
|
|
100
|
440
|
101 /*---------------------------------------------------------------------*/
|
|
102 /*----- DISPLAY FRAME -----*/
|
|
103 /*---------------------------------------------------------------------*/
|
|
104
|
442
|
105 HWND
|
|
106 mswindows_get_selected_frame_hwnd (void)
|
|
107 {
|
|
108 Lisp_Object frame, device;
|
|
109
|
|
110 device = Ffind_device (Qnil, Qmswindows);
|
|
111 if (NILP (device))
|
|
112 return NULL;
|
|
113 frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
|
|
114 if (NILP (frame))
|
|
115 return NULL;
|
|
116
|
|
117 return FRAME_MSWINDOWS_HANDLE (XFRAME (frame));
|
|
118 }
|
|
119
|
428
|
120 static void
|
771
|
121 mswindows_init_frame_1 (struct frame *f, Lisp_Object props,
|
|
122 int frame_name_is_defaulted)
|
428
|
123 {
|
|
124 Lisp_Object initially_unmapped;
|
|
125 Lisp_Object name, height, width, popup, top, left;
|
|
126 Lisp_Object frame_obj = Qnil;
|
|
127 RECT rect;
|
|
128 XEMACS_RECT_WH rect_default;
|
|
129 DWORD style, exstyle;
|
|
130 HWND hwnd, hwnd_parent;
|
|
131
|
|
132 /* Pick up relevant properties */
|
|
133 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
|
|
134 name = Fplist_get (props, Qname, Qnil);
|
442
|
135
|
428
|
136 popup = Fplist_get (props, Qpopup, Qnil);
|
|
137 if (EQ (popup, Qt))
|
|
138 popup = Fselected_frame (Qnil);
|
|
139
|
|
140 left = Fplist_get (props, Qleft, Qnil);
|
|
141 if (!NILP (left))
|
|
142 CHECK_INT (left);
|
|
143
|
|
144 top = Fplist_get (props, Qtop, Qnil);
|
|
145 if (!NILP (top))
|
|
146 CHECK_INT (top);
|
|
147
|
|
148 width = Fplist_get (props, Qwidth, Qnil);
|
|
149 if (!NILP (width))
|
|
150 CHECK_INT (width);
|
|
151
|
|
152 height = Fplist_get (props, Qheight, Qnil);
|
|
153 if (!NILP (height))
|
|
154 CHECK_INT (height);
|
|
155
|
|
156 f->frame_data = xnew_and_zero (struct mswindows_frame);
|
|
157 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH);
|
|
158
|
|
159 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left));
|
|
160 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top));
|
442
|
161 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 :
|
428
|
162 abs (XINT (width));
|
442
|
163 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 :
|
428
|
164 abs (XINT (height));
|
442
|
165
|
428
|
166 /* Misc frame stuff */
|
771
|
167 FRAME_MSWINDOWS_MENU_HASH_TABLE (f) = Qnil;
|
428
|
168 #ifdef HAVE_TOOLBARS
|
1130
|
169 /* EQ not EQUAL or we will get QUIT crashes, see below. */
|
771
|
170 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f) =
|
1130
|
171 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
428
|
172 #endif
|
1123
|
173 /* hashtable of instantiated glyphs on the frame. Make them EQ because
|
|
174 we only use ints as keys. Otherwise we run into stickiness in
|
|
175 redisplay because internal_equal() can QUIT. See
|
|
176 enter_redisplay_critical_section(). */
|
442
|
177 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f) =
|
853
|
178 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
|
442
|
179 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f) =
|
853
|
180 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
|
442
|
181 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f) =
|
853
|
182 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQ);
|
428
|
183 /* Will initialize these in WM_SIZE handler. We cannot do it now,
|
|
184 because we do not know what is CW_USEDEFAULT height and width */
|
|
185 FRAME_WIDTH (f) = 0;
|
|
186 FRAME_HEIGHT (f) = 0;
|
|
187 FRAME_PIXWIDTH (f) = 0;
|
|
188 FRAME_PIXHEIGHT (f) = 0;
|
|
189
|
|
190 if (NILP (popup))
|
|
191 {
|
|
192 style = MSWINDOWS_FRAME_STYLE;
|
|
193 exstyle = MSWINDOWS_FRAME_EXSTYLE;
|
|
194 hwnd_parent = NULL;
|
|
195
|
|
196 rect_default.left = rect_default.top = CW_USEDEFAULT;
|
|
197 rect_default.width = rect_default.height = CW_USEDEFAULT;
|
|
198 }
|
|
199 else
|
|
200 {
|
|
201 style = MSWINDOWS_POPUP_STYLE;
|
|
202 exstyle = MSWINDOWS_POPUP_EXSTYLE;
|
|
203
|
|
204 CHECK_MSWINDOWS_FRAME (popup);
|
|
205 hwnd_parent = FRAME_MSWINDOWS_HANDLE (XFRAME (popup));
|
|
206 assert (IsWindow (hwnd_parent));
|
|
207
|
|
208 /* We cannot use CW_USEDEFAULT when creating a popup window.
|
|
209 So by default, we offset the new popup 30 pixels right
|
|
210 and down from its parent, and give it size of 30x10 characters.
|
|
211 These dimensions look adequate on both high and low res monitors */
|
|
212 GetWindowRect (hwnd_parent, &rect);
|
|
213 rect_default.left = rect.left + POPUP_OFFSET;
|
|
214 rect_default.top = rect.top + POPUP_OFFSET;
|
|
215 char_to_real_pixel_size (f, POPUP_WIDTH, POPUP_HEIGHT,
|
|
216 &rect_default.width, &rect_default.height);
|
442
|
217 FRAME_MSWINDOWS_POPUP (f) = 1;
|
428
|
218 }
|
|
219
|
771
|
220 AdjustWindowRectEx (&rect, style, ADJR_MENUFLAG, exstyle);
|
428
|
221
|
793
|
222 frame_obj = wrap_frame (f);
|
428
|
223
|
|
224 Vmswindows_frame_being_created = frame_obj;
|
771
|
225 {
|
|
226 const Extbyte *nameext = 0;
|
428
|
227
|
771
|
228 if (STRINGP (f->name))
|
|
229 LISP_STRING_TO_TSTR (f->name, nameext);
|
|
230 else if (STRINGP (name))
|
|
231 LISP_STRING_TO_TSTR (name, nameext);
|
|
232 else
|
|
233 nameext = XETEXT (XEMACS_CLASS);
|
|
234 hwnd = qxeCreateWindowEx (exstyle,
|
|
235 XETEXT (XEMACS_CLASS),
|
|
236 nameext,
|
|
237 style,
|
|
238 rect_default.left, rect_default.top,
|
|
239 rect_default.width, rect_default.height,
|
|
240 hwnd_parent, NULL, NULL, NULL);
|
|
241 }
|
428
|
242
|
|
243 Vmswindows_frame_being_created = Qnil;
|
|
244
|
|
245 if (hwnd == NULL)
|
442
|
246 invalid_operation ("System call to create frame failed",
|
|
247 STRINGP (f->name) ? f->name :
|
|
248 STRINGP (name) ? name :
|
|
249 Qunbound);
|
771
|
250
|
|
251 FRAME_MSWINDOWS_HANDLE (f) = hwnd;
|
428
|
252
|
771
|
253 qxeSetWindowLong (hwnd, XWL_FRAMEOBJ, (LONG)LISP_TO_VOID (frame_obj));
|
|
254 FRAME_MSWINDOWS_DC (f) = GetDC (hwnd);
|
|
255 SetTextAlign (FRAME_MSWINDOWS_DC (f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
|
442
|
256
|
771
|
257 #ifdef HAVE_DIALOGS
|
442
|
258 if (FRAME_MSWINDOWS_POPUP (f))
|
|
259 mswindows_register_popup_frame (frame_obj);
|
771
|
260 #endif /* HAVE_DIALOGS */
|
428
|
261 }
|
|
262
|
|
263 static void
|
|
264 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
|
|
265 {
|
|
266 if (NILP (Vmswindows_use_system_frame_size_defaults))
|
|
267 {
|
|
268 /* I don't think anything can set the frame size before this
|
|
269 since we don't have X resources. This may change if we look
|
|
270 at the registry. Even so these values can get overridden
|
|
271 later.*/
|
442
|
272 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH,
|
428
|
273 DEFAULT_FRAME_HEIGHT };
|
|
274 mswindows_size_frame_internal (f, &dest);
|
|
275 }
|
|
276 }
|
|
277
|
|
278 /* Called after frame's properties are set */
|
|
279 static void
|
|
280 mswindows_init_frame_3 (struct frame *f)
|
|
281 {
|
827
|
282 /* Don't do this earlier or we get a WM_PAINT before the frame is ready */
|
771
|
283 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_SHOWNORMAL);
|
|
284 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE (f));
|
|
285 DragAcceptFiles (FRAME_MSWINDOWS_HANDLE (f), TRUE);
|
428
|
286 }
|
|
287
|
|
288 static void
|
|
289 mswindows_after_init_frame (struct frame *f, int first_on_device,
|
|
290 int first_on_console)
|
|
291 {
|
|
292 /* Windows, unlike X, is very synchronous. After the initial
|
442
|
293 frame is created, it will never be displayed, except for
|
428
|
294 hollow border, unless we start pumping messages. Load progress
|
|
295 messages show in the bottom of the hollow frame, which is ugly.
|
|
296 We redisplay the initial frame here, so modeline and root window
|
|
297 background show.
|
|
298 */
|
|
299 if (first_on_console)
|
|
300 redisplay ();
|
|
301 }
|
|
302
|
|
303 static void
|
|
304 mswindows_mark_frame (struct frame *f)
|
|
305 {
|
|
306 mark_object (FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
|
|
307 #ifdef HAVE_TOOLBARS
|
|
308 mark_object (FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
|
|
309 #endif
|
442
|
310 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f));
|
|
311 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f));
|
|
312 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f));
|
428
|
313 }
|
|
314
|
|
315 static void
|
|
316 mswindows_focus_on_frame (struct frame *f)
|
|
317 {
|
771
|
318 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
319 }
|
|
320
|
|
321 static void
|
|
322 mswindows_delete_frame (struct frame *f)
|
|
323 {
|
|
324 if (f->frame_data)
|
|
325 {
|
771
|
326 #ifdef HAVE_DIALOGS
|
|
327 mswindows_unregister_popup_frame (wrap_frame (f));
|
|
328 #endif
|
|
329 ReleaseDC (FRAME_MSWINDOWS_HANDLE (f), FRAME_MSWINDOWS_DC (f));
|
|
330 DestroyWindow (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
331 xfree (f->frame_data);
|
|
332 }
|
|
333 f->frame_data = 0;
|
|
334 }
|
|
335
|
|
336 static void
|
|
337 mswindows_set_frame_size (struct frame *f, int width, int height)
|
|
338 {
|
|
339 RECT rect;
|
|
340 rect.left = rect.top = 0;
|
|
341 rect.right = width;
|
|
342 rect.bottom = height;
|
|
343
|
|
344 AdjustWindowRectEx (&rect,
|
771
|
345 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_STYLE),
|
|
346 GetMenu (FRAME_MSWINDOWS_HANDLE (f)) != NULL,
|
|
347 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_EXSTYLE));
|
428
|
348
|
771
|
349 if (IsIconic (FRAME_MSWINDOWS_HANDLE (f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE (f)))
|
|
350 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
351
|
771
|
352 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
353 0, 0, rect.right-rect.left, rect.bottom-rect.top,
|
|
354 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE);
|
|
355 }
|
|
356
|
|
357 static void
|
|
358 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
359 {
|
771
|
360 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
361 xoff, yoff, 0, 0,
|
|
362 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE);
|
|
363 }
|
|
364
|
|
365 static void
|
442
|
366 mswindows_make_frame_visible (struct frame *f)
|
428
|
367 {
|
771
|
368 if (!FRAME_VISIBLE_P (f))
|
|
369 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
370 else
|
771
|
371 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_SHOW);
|
|
372 SetActiveWindow (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
373 f->visible = 1;
|
|
374 f->iconified = 0;
|
|
375 }
|
|
376
|
|
377 static void
|
442
|
378 mswindows_make_frame_invisible (struct frame *f)
|
428
|
379 {
|
771
|
380 if (!FRAME_VISIBLE_P (f))
|
428
|
381 return;
|
|
382
|
771
|
383 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_HIDE);
|
428
|
384 f->visible = 0;
|
|
385 }
|
|
386
|
|
387 static int
|
|
388 mswindows_frame_totally_visible_p (struct frame *f)
|
|
389 {
|
|
390 RECT rc_me, rc_other, rc_temp;
|
771
|
391 HWND hwnd = FRAME_MSWINDOWS_HANDLE (f);
|
428
|
392
|
|
393 /* We test against not a whole window rectangle, only against its
|
|
394 client part. So, if non-client are is covered and client area is
|
|
395 not, we return true. */
|
|
396 GetClientRect (hwnd, &rc_me);
|
|
397 MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rc_me, 2);
|
|
398
|
|
399 /* First see if we're off the desktop */
|
771
|
400 GetWindowRect (GetDesktopWindow (), &rc_other);
|
|
401 UnionRect (&rc_temp, &rc_me, &rc_other);
|
428
|
402 if (!EqualRect (&rc_temp, &rc_other))
|
|
403 return 0;
|
442
|
404
|
428
|
405 /* Then see if any window above us obscures us */
|
|
406 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL)
|
|
407 if (IsWindowVisible (hwnd))
|
|
408 {
|
|
409 GetWindowRect (hwnd, &rc_other);
|
771
|
410 if (IntersectRect (&rc_temp, &rc_me, &rc_other))
|
428
|
411 return 0;
|
|
412 }
|
|
413
|
|
414 return 1;
|
|
415 }
|
|
416
|
|
417 static int
|
|
418 mswindows_frame_visible_p (struct frame *f)
|
|
419 {
|
771
|
420 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE (f))
|
|
421 && !IsIconic (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
422 }
|
|
423
|
|
424
|
|
425 static void
|
|
426 mswindows_iconify_frame (struct frame *f)
|
|
427 {
|
771
|
428 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_MINIMIZE);
|
428
|
429 f->visible = 0;
|
|
430 f->iconified = 1;
|
|
431 }
|
|
432
|
|
433 static int
|
|
434 mswindows_frame_iconified_p (struct frame *f)
|
|
435 {
|
771
|
436 return IsIconic (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
437 }
|
|
438
|
|
439 static void
|
|
440 mswindows_set_frame_icon (struct frame *f)
|
|
441 {
|
|
442 if (IMAGE_INSTANCEP (f->icon)
|
|
443 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon)))
|
|
444 {
|
|
445 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon))
|
|
446 {
|
442
|
447 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon),
|
428
|
448 FALSE);
|
|
449 }
|
442
|
450
|
771
|
451 qxeSetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON,
|
|
452 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon));
|
428
|
453 }
|
|
454 }
|
|
455
|
|
456 static void
|
|
457 mswindows_set_frame_pointer (struct frame *f)
|
|
458 {
|
|
459 if (IMAGE_INSTANCEP (f->pointer)
|
|
460 && IMAGE_INSTANCE_TYPE (XIMAGE_INSTANCE (f->pointer)) == IMAGE_POINTER)
|
|
461 {
|
771
|
462 qxeSetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HCURSOR,
|
|
463 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
428
|
464 /* we only have to do this because GC doesn't cause a mouse
|
|
465 event and doesn't give time to event processing even if it
|
|
466 did. */
|
|
467 SetCursor (XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
|
468 }
|
|
469 }
|
|
470
|
|
471 static void
|
|
472 mswindows_set_mouse_position (struct window *w, int x, int y)
|
|
473 {
|
|
474 struct frame *f = XFRAME (w->frame);
|
|
475 POINT pt;
|
|
476
|
|
477 pt.x = w->pixel_left + x;
|
|
478 pt.y = w->pixel_top + y;
|
771
|
479 ClientToScreen (FRAME_MSWINDOWS_HANDLE (f), &pt);
|
428
|
480 SetCursorPos (pt.x, pt.y);
|
|
481 }
|
|
482
|
|
483 static int
|
|
484 mswindows_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
485 {
|
|
486 POINT pt;
|
|
487 HWND hwnd;
|
|
488
|
|
489 GetCursorPos (&pt);
|
|
490
|
|
491 /* What's under cursor? */
|
|
492 hwnd = WindowFromPoint (pt);
|
|
493 if (hwnd == NULL)
|
|
494 return 0;
|
|
495
|
|
496 /* Get grandest parent of the window */
|
|
497 {
|
|
498 HWND hwnd_parent;
|
|
499 while ((hwnd_parent = GetParent (hwnd)) != NULL)
|
|
500 hwnd = hwnd_parent;
|
|
501 }
|
|
502
|
|
503 /* Make sure it belongs to us */
|
|
504 if (GetWindowThreadProcessId (hwnd, NULL) != GetCurrentThreadId ())
|
|
505 return 0;
|
|
506
|
|
507 /* And that the window is an XEmacs frame */
|
771
|
508 if (!mswindows_window_is_xemacs (hwnd))
|
|
509 return 0;
|
428
|
510
|
|
511 /* Yippie! */
|
|
512 ScreenToClient (hwnd, &pt);
|
826
|
513 *frame = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, XWL_FRAMEOBJ));
|
428
|
514 *x = pt.x;
|
|
515 *y = pt.y;
|
|
516 return 1;
|
|
517 }
|
|
518
|
|
519 static void
|
|
520 mswindows_raise_frame (struct frame *f)
|
|
521 {
|
771
|
522 BringWindowToTop (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
523 }
|
|
524
|
|
525 static void
|
|
526 mswindows_lower_frame (struct frame *f)
|
|
527 {
|
771
|
528 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), HWND_BOTTOM, 0, 0, 0, 0,
|
428
|
529 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING);
|
|
530 }
|
|
531
|
|
532 static void
|
442
|
533 mswindows_enable_frame (struct frame *f)
|
|
534 {
|
|
535 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), TRUE);
|
|
536 }
|
|
537
|
|
538 static void
|
|
539 mswindows_disable_frame (struct frame *f)
|
|
540 {
|
|
541 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), FALSE);
|
|
542 }
|
|
543
|
|
544 static void
|
867
|
545 mswindows_set_title_from_ibyte (struct frame *f, Ibyte *title)
|
428
|
546 {
|
771
|
547 unsigned int new_checksum = hash_string (title, qxestrlen (title));
|
593
|
548 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM (f))
|
428
|
549 {
|
593
|
550 Extbyte *title_ext;
|
|
551
|
|
552 FRAME_MSWINDOWS_TITLE_CHECKSUM (f) = new_checksum;
|
771
|
553 C_STRING_TO_TSTR (title, title_ext);
|
|
554 qxeSetWindowText (FRAME_MSWINDOWS_HANDLE (f), title_ext);
|
428
|
555 }
|
|
556 }
|
|
557
|
|
558 static Lisp_Object
|
|
559 mswindows_frame_property (struct frame *f, Lisp_Object property)
|
|
560 {
|
|
561 if (EQ (Qleft, property) || EQ (Qtop, property))
|
|
562 {
|
|
563 RECT rc;
|
771
|
564 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
428
|
565 return make_int (EQ (Qtop, property) ? rc.top : rc.left);
|
|
566 }
|
|
567 return Qunbound;
|
|
568 }
|
|
569
|
|
570 static int
|
|
571 mswindows_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
572 {
|
|
573 return EQ (property, Qleft)
|
|
574 || EQ (property, Qtop);
|
|
575 /* #### frame-x.c has also this. Why?
|
|
576 || STRINGP (property);
|
|
577 */
|
|
578 }
|
|
579
|
|
580 static Lisp_Object
|
|
581 mswindows_frame_properties (struct frame *f)
|
|
582 {
|
|
583 Lisp_Object props = Qnil;
|
|
584 RECT rc;
|
771
|
585 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
428
|
586
|
|
587 props = cons3 (Qtop, make_int (rc.top), props);
|
|
588 props = cons3 (Qleft, make_int (rc.left), props);
|
|
589
|
|
590 return props;
|
|
591 }
|
|
592
|
|
593 static void
|
|
594 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
595 {
|
|
596 int x=-1, y=-1;
|
|
597 int width = -1, height = -1;
|
|
598 BOOL width_specified_p = FALSE;
|
|
599 BOOL height_specified_p = FALSE;
|
|
600 BOOL x_specified_p = FALSE;
|
|
601 BOOL y_specified_p = FALSE;
|
|
602 Lisp_Object tail;
|
|
603
|
|
604 /* Extract the properties from plist */
|
|
605 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
606 {
|
|
607 Lisp_Object prop = Fcar (tail);
|
|
608 Lisp_Object val = Fcar (Fcdr (tail));
|
|
609
|
|
610 if (SYMBOLP (prop))
|
|
611 {
|
|
612 /* Kludge to handle the font property. */
|
|
613 if (EQ (prop, Qfont))
|
|
614 {
|
|
615 /* If the value is not a string we silently ignore it. */
|
|
616 if (STRINGP (val))
|
|
617 {
|
|
618 Lisp_Object frm, font_spec;
|
442
|
619
|
793
|
620 frm = wrap_frame (f);
|
428
|
621 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
622
|
|
623 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
624 update_frame_face_values (f);
|
|
625 }
|
|
626 }
|
|
627 else if (EQ (prop, Qwidth))
|
|
628 {
|
|
629 CHECK_INT (val);
|
|
630 width = XINT (val);
|
|
631 width_specified_p = TRUE;
|
|
632 }
|
|
633 else if (EQ (prop, Qheight))
|
|
634 {
|
|
635 CHECK_INT (val);
|
|
636 height = XINT (val);
|
|
637 height_specified_p = TRUE;
|
|
638 }
|
|
639 else if (EQ (prop, Qleft))
|
|
640 {
|
|
641 CHECK_INT (val);
|
|
642 x = XINT (val);
|
|
643 x_specified_p = TRUE;
|
|
644 }
|
|
645 else if (EQ (prop, Qtop))
|
|
646 {
|
|
647 CHECK_INT (val);
|
|
648 y = XINT (val);
|
|
649 y_specified_p = TRUE;
|
|
650 }
|
|
651 }
|
|
652 }
|
|
653
|
|
654 /* Now we've extracted the properties, apply them.
|
|
655 Do not apply geometric properties during frame creation. This
|
442
|
656 is excessive anyways, and this loses because WM_SIZE has not
|
428
|
657 been sent yet, so frame width and height fields are not initialized.
|
442
|
658
|
428
|
659 unfortunately WM_SIZE loses as well since the resize is only
|
|
660 applied once and the first time WM_SIZE is applied not everything
|
|
661 is initialised in the frame (toolbars for instance). enabling
|
|
662 this always makes no visible difference and fixes a whole host of
|
|
663 bugs (and is more consistent with X) so I am going to reenable it.
|
|
664 --andyp */
|
|
665 if ( FRAME_PIXWIDTH (f) && FRAME_PIXHEIGHT (f)
|
440
|
666 && (width_specified_p || height_specified_p
|
|
667 || x_specified_p || y_specified_p))
|
428
|
668 {
|
|
669 XEMACS_RECT_WH dest = { x, y, width, height };
|
|
670
|
|
671 mswindows_size_frame_internal (f, &dest);
|
|
672 }
|
|
673 }
|
|
674
|
506
|
675 void
|
771
|
676 mswindows_size_frame_internal (struct frame *f, XEMACS_RECT_WH *dest)
|
428
|
677 {
|
442
|
678 RECT rect, ws_rect;
|
428
|
679 int pixel_width, pixel_height;
|
|
680 int size_p = (dest->width >=0 || dest->height >=0);
|
|
681 int move_p = (dest->top >=0 || dest->left >=0);
|
506
|
682 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width,
|
|
683 &pixel_height);
|
442
|
684
|
428
|
685 if (dest->width < 0)
|
|
686 pixel_width = FRAME_PIXWIDTH (f);
|
|
687 if (dest->height < 0)
|
|
688 pixel_height = FRAME_PIXHEIGHT (f);
|
|
689
|
771
|
690 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rect);
|
428
|
691 if (dest->left < 0)
|
|
692 dest->left = rect.left;
|
|
693 if (dest->top < 0)
|
|
694 dest->top = rect.top;
|
442
|
695
|
428
|
696 rect.left = rect.top = 0;
|
|
697 rect.right = pixel_width;
|
|
698 rect.bottom = pixel_height;
|
|
699
|
|
700 AdjustWindowRectEx (&rect,
|
771
|
701 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_STYLE),
|
|
702 GetMenu (FRAME_MSWINDOWS_HANDLE (f)) != NULL,
|
|
703 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_EXSTYLE));
|
428
|
704
|
442
|
705 /* resize and move the window so that it fits in the workspace. This is
|
428
|
706 not restrictive since this will happen later anyway in WM_SIZE. We
|
|
707 have to do this after adjusting the rect to account for menubar
|
|
708 etc. */
|
442
|
709 mswindows_get_workspace_coords (&ws_rect);
|
428
|
710 pixel_width = rect.right - rect.left;
|
|
711 pixel_height = rect.bottom - rect.top;
|
442
|
712 if (pixel_width > ws_rect.right - ws_rect.left)
|
428
|
713 {
|
442
|
714 pixel_width = ws_rect.right - ws_rect.left;
|
428
|
715 size_p=1;
|
|
716 }
|
442
|
717 if (pixel_height > ws_rect.bottom - ws_rect.top)
|
428
|
718 {
|
442
|
719 pixel_height = ws_rect.bottom - ws_rect.top;
|
428
|
720 size_p=1;
|
|
721 }
|
|
722
|
442
|
723 /* adjust position so window is in workspace */
|
|
724 if (dest->left + pixel_width > ws_rect.right)
|
428
|
725 {
|
442
|
726 dest->left = ws_rect.right - pixel_width;
|
428
|
727 move_p=1;
|
|
728 }
|
442
|
729 if (dest->left < ws_rect.left)
|
428
|
730 {
|
442
|
731 dest->left = ws_rect.left;
|
428
|
732 move_p=1;
|
|
733 }
|
|
734
|
442
|
735 if (dest->top + pixel_height > ws_rect.bottom)
|
|
736 {
|
|
737 dest->top = ws_rect.bottom - pixel_height;
|
|
738 move_p=1;
|
|
739 }
|
|
740 if (dest->top < ws_rect.top)
|
|
741 {
|
|
742 dest->top = ws_rect.top;
|
|
743 move_p=1;
|
|
744 }
|
|
745
|
771
|
746 if (IsIconic (FRAME_MSWINDOWS_HANDLE (f))
|
|
747 || IsZoomed (FRAME_MSWINDOWS_HANDLE (f)))
|
|
748 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
749
|
771
|
750 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
751 dest->left, dest->top, pixel_width, pixel_height,
|
|
752 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
|
|
753 | (size_p ? 0 : SWP_NOSIZE)
|
|
754 | (move_p ? 0 : SWP_NOMOVE));
|
|
755 }
|
|
756
|
|
757 static Lisp_Object
|
|
758 mswindows_get_frame_parent (struct frame *f)
|
|
759 {
|
771
|
760 HWND hwnd = FRAME_MSWINDOWS_HANDLE (f);
|
428
|
761 hwnd = GetParent (hwnd);
|
|
762 if (hwnd)
|
|
763 {
|
|
764 Lisp_Object parent;
|
826
|
765 parent = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, XWL_FRAMEOBJ));
|
428
|
766 assert (FRAME_MSWINDOWS_P (XFRAME (parent)));
|
|
767 return parent;
|
|
768 }
|
|
769 else
|
|
770 return Qnil;
|
|
771 }
|
|
772
|
|
773 static void
|
771
|
774 mswindows_update_frame_external_traits (struct frame *frm, Lisp_Object name)
|
428
|
775 {
|
|
776 }
|
|
777
|
|
778 static int
|
|
779 mswindows_frame_size_fixed_p (struct frame *f)
|
|
780 {
|
|
781 /* Frame size cannot change if the frame is maximized */
|
|
782 return IsZoomed (FRAME_MSWINDOWS_HANDLE (f));
|
|
783 }
|
|
784
|
440
|
785 /*---------------------------------------------------------------------*/
|
|
786 /*----- PRINTER FRAME -----*/
|
|
787 /*---------------------------------------------------------------------*/
|
|
788
|
442
|
789 /*
|
|
790 * With some driver/os combination (I discovered this with HP drivers
|
|
791 * under W2K), DC geometry is reset upon StartDoc and EndPage
|
|
792 * calls. This is called every time one of these calls is made.
|
|
793 */
|
|
794 static void
|
|
795 apply_dc_geometry (struct frame* f)
|
|
796 {
|
|
797 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
|
|
798 SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
|
|
799 SetViewportOrgEx (hdc, FRAME_MSPRINTER_PIXLEFT(f),
|
|
800 FRAME_MSPRINTER_PIXTOP(f), NULL);
|
|
801 }
|
|
802
|
|
803 void
|
|
804 msprinter_start_page (struct frame *f)
|
|
805 {
|
|
806 if (!FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
807 {
|
|
808 FRAME_MSPRINTER_PAGE_STARTED (f) = 1;
|
|
809 StartPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
|
|
810 apply_dc_geometry (f);
|
|
811 }
|
|
812 }
|
440
|
813
|
|
814 static void
|
|
815 error_frame_unsizable (struct frame *f)
|
|
816 {
|
793
|
817 Lisp_Object frame = wrap_frame (f);
|
|
818
|
442
|
819 invalid_change ("Cannot resize frame (margins) after print job has started.",
|
|
820 frame);
|
440
|
821 }
|
|
822
|
|
823 static void
|
|
824 maybe_error_if_job_active (struct frame *f)
|
|
825 {
|
|
826 if (FRAME_MSPRINTER_JOB_STARTED (f))
|
|
827 error_frame_unsizable (f);
|
|
828 }
|
|
829
|
|
830 static void
|
771
|
831 msprinter_init_frame_1 (struct frame *f, Lisp_Object props,
|
|
832 int frame_name_is_defaulted)
|
440
|
833 {
|
|
834 /* Make sure this is the only frame on device. Windows printer can
|
|
835 handle only one job at a time. */
|
|
836 if (!NILP (DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)))))
|
442
|
837 invalid_operation ("Only one frame (print job) at a time is allowed on "
|
|
838 "this printer device", FRAME_DEVICE (f));
|
440
|
839
|
|
840 f->frame_data = xnew_and_zero (struct msprinter_frame);
|
|
841
|
506
|
842 FRAME_MSPRINTER_TOP_MARGIN (f) =
|
|
843 mswindows_get_default_margin (Qtop_margin);
|
|
844 FRAME_MSPRINTER_BOTTOM_MARGIN (f) =
|
|
845 mswindows_get_default_margin (Qbottom_margin);
|
|
846 FRAME_MSPRINTER_LEFT_MARGIN (f) =
|
|
847 mswindows_get_default_margin (Qleft_margin);
|
|
848 FRAME_MSPRINTER_RIGHT_MARGIN (f) =
|
|
849 mswindows_get_default_margin (Qright_margin);
|
440
|
850
|
|
851 /* Negative for "uinspecified" */
|
506
|
852 FRAME_MSPRINTER_CHARWIDTH (f) = -1;
|
|
853 FRAME_MSPRINTER_CHARHEIGHT (f) = -1;
|
440
|
854 }
|
|
855
|
|
856 static void
|
|
857 msprinter_init_frame_3 (struct frame *f)
|
|
858 {
|
771
|
859 DOCINFOW di;
|
440
|
860 struct device *device = XDEVICE (FRAME_DEVICE (f));
|
|
861 int frame_left, frame_top, frame_width, frame_height;
|
903
|
862
|
442
|
863 /* DC might be recreated in msprinter_apply_devmode,
|
|
864 so do not initialize until now */
|
903
|
865 HDC hdc = DEVICE_MSPRINTER_HDC (device);
|
|
866 int logpixelsx = GetDeviceCaps (hdc, LOGPIXELSX);
|
|
867 int logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
|
|
868 int physicaloffsetx = GetDeviceCaps (hdc, PHYSICALOFFSETX);
|
|
869 int physicaloffsety = GetDeviceCaps (hdc, PHYSICALOFFSETY);
|
|
870 int physicalheight = GetDeviceCaps (hdc, PHYSICALHEIGHT);
|
|
871 int physicalwidth = GetDeviceCaps (hdc, PHYSICALWIDTH);
|
440
|
872
|
903
|
873 /* Compute geometry properties.
|
|
874 Conversion is from TWIPS -> inches -> pixels. */
|
|
875 frame_left = MulDiv (logpixelsx, FRAME_MSPRINTER_LEFT_MARGIN(f), 1440)
|
|
876 - physicaloffsetx;
|
|
877
|
771
|
878 if (FRAME_MSPRINTER_CHARWIDTH (f) > 0)
|
440
|
879 {
|
771
|
880 char_to_real_pixel_size (f, FRAME_MSPRINTER_CHARWIDTH (f), 0,
|
440
|
881 &frame_width, NULL);
|
903
|
882 FRAME_MSPRINTER_RIGHT_MARGIN(f) =
|
|
883 MulDiv (physicalwidth - (frame_left + frame_width), 1440,
|
|
884 logpixelsx);
|
442
|
885 }
|
440
|
886 else
|
903
|
887 frame_width = physicalwidth - frame_left
|
|
888 - MulDiv (logpixelsx, FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440)
|
|
889 - physicaloffsetx;
|
440
|
890
|
903
|
891 frame_top = MulDiv (logpixelsy, FRAME_MSPRINTER_TOP_MARGIN(f), 1440)
|
|
892 - physicaloffsety;
|
440
|
893
|
771
|
894 if (FRAME_MSPRINTER_CHARHEIGHT (f) > 0)
|
440
|
895 {
|
771
|
896 char_to_real_pixel_size (f, 0, FRAME_MSPRINTER_CHARHEIGHT (f),
|
440
|
897 NULL, &frame_height);
|
|
898
|
903
|
899 FRAME_MSPRINTER_BOTTOM_MARGIN(f) =
|
|
900 MulDiv (physicalheight - (frame_top + frame_height), 1440,
|
|
901 logpixelsy);
|
442
|
902 }
|
440
|
903 else
|
903
|
904 frame_height = physicalheight - frame_top
|
|
905 - MulDiv (logpixelsy, FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440)
|
|
906 - physicaloffsety;
|
440
|
907
|
|
908 /* Geometry sanity checks */
|
|
909 if (!frame_pixsize_valid_p (f, frame_width, frame_height))
|
442
|
910 invalid_operation ("Area inside print margins has shrunk to naught",
|
|
911 STRINGP (f->name) ? f->name : Qunbound);
|
440
|
912
|
|
913 if (frame_left < 0
|
|
914 || frame_top < 0
|
|
915 || frame_left + frame_width > GetDeviceCaps (hdc, HORZRES)
|
|
916 || frame_top + frame_height > GetDeviceCaps (hdc, VERTRES))
|
546
|
917 invalid_operation ("Print area is outside of the printer's "
|
442
|
918 "hardware printable area",
|
|
919 STRINGP (f->name) ? f->name : Qunbound);
|
440
|
920
|
|
921 /* Apply XEmacs frame geometry and layout windows */
|
|
922 {
|
|
923 int rows, columns;
|
771
|
924 FRAME_PIXWIDTH (f) = frame_width;
|
|
925 FRAME_PIXHEIGHT (f) = frame_height;
|
440
|
926 pixel_to_char_size (f, frame_width, frame_height, &columns, &rows);
|
|
927 change_frame_size (f, rows, columns, 0);
|
|
928 }
|
|
929
|
442
|
930 FRAME_MSPRINTER_PIXLEFT(f) = frame_left;
|
|
931 FRAME_MSPRINTER_PIXTOP(f) = frame_top;
|
440
|
932
|
|
933 /* Start print job */
|
|
934 di.cbSize = sizeof (di);
|
771
|
935 {
|
|
936 const Extbyte *nameext;
|
|
937
|
|
938 if (STRINGP (f->name))
|
|
939 LISP_STRING_TO_TSTR (f->name, nameext);
|
|
940 else
|
|
941 nameext = XETEXT ("XEmacs print document");
|
|
942 di.lpszDocName = (XELPTSTR) nameext;
|
|
943 }
|
440
|
944 di.lpszOutput = NULL;
|
|
945 di.lpszDatatype = NULL;
|
|
946 di.fwType = 0;
|
|
947
|
771
|
948 if (qxeStartDoc (hdc, &di) <= 0)
|
442
|
949 invalid_operation ("Cannot start print job",
|
|
950 STRINGP (f->name) ? f->name : Qunbound);
|
|
951
|
|
952 apply_dc_geometry (f);
|
440
|
953
|
|
954 /* Finish frame setup */
|
|
955 FRAME_MSPRINTER_JOB_STARTED (f) = 1;
|
771
|
956 FRAME_VISIBLE_P (f) = 0;
|
440
|
957 }
|
|
958
|
|
959 static void
|
|
960 msprinter_mark_frame (struct frame *f)
|
|
961 {
|
|
962 }
|
|
963
|
|
964 static void
|
|
965 msprinter_delete_frame (struct frame *f)
|
|
966 {
|
|
967 if (f->frame_data)
|
|
968 {
|
442
|
969 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
|
|
970 if (FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
971 EndPage (hdc);
|
440
|
972 if (FRAME_MSPRINTER_JOB_STARTED (f))
|
442
|
973 EndDoc (hdc);
|
440
|
974 xfree (f->frame_data);
|
|
975 }
|
|
976
|
|
977 f->frame_data = 0;
|
|
978 }
|
|
979
|
|
980 static Lisp_Object
|
|
981 msprinter_frame_property (struct frame *f, Lisp_Object property)
|
|
982 {
|
|
983 if (EQ (Qleft_margin, property))
|
771
|
984 return make_int (FRAME_MSPRINTER_LEFT_MARGIN (f));
|
440
|
985 else if (EQ (Qtop_margin, property))
|
771
|
986 return make_int (FRAME_MSPRINTER_TOP_MARGIN (f));
|
440
|
987 if (EQ (Qright_margin, property))
|
771
|
988 return make_int (FRAME_MSPRINTER_RIGHT_MARGIN (f));
|
440
|
989 else if (EQ (Qbottom_margin, property))
|
771
|
990 return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN (f));
|
440
|
991 else
|
|
992 return Qunbound;
|
|
993 }
|
|
994
|
|
995 static int
|
|
996 msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
997 {
|
|
998 return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) ||
|
442
|
999 EQ (Qright_margin, property) || EQ (Qbottom_margin, property));
|
440
|
1000 }
|
|
1001
|
|
1002 static Lisp_Object
|
|
1003 msprinter_frame_properties (struct frame *f)
|
|
1004 {
|
|
1005 Lisp_Object props = Qnil;
|
|
1006 props = cons3 (Qbottom_margin,
|
771
|
1007 make_int (FRAME_MSPRINTER_BOTTOM_MARGIN (f)), props);
|
440
|
1008 props = cons3 (Qright_margin,
|
771
|
1009 make_int (FRAME_MSPRINTER_RIGHT_MARGIN (f)), props);
|
440
|
1010 props = cons3 (Qtop_margin,
|
771
|
1011 make_int (FRAME_MSPRINTER_TOP_MARGIN (f)), props);
|
440
|
1012 props = cons3 (Qleft_margin,
|
771
|
1013 make_int (FRAME_MSPRINTER_LEFT_MARGIN (f)), props);
|
440
|
1014 return props;
|
|
1015 }
|
|
1016
|
|
1017 static void
|
|
1018 msprinter_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
1019 {
|
|
1020 Lisp_Object tail;
|
|
1021
|
|
1022 /* Extract the properties from plist */
|
|
1023 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
1024 {
|
|
1025 Lisp_Object prop = Fcar (tail);
|
|
1026 Lisp_Object val = Fcar (Fcdr (tail));
|
|
1027
|
|
1028 if (SYMBOLP (prop))
|
|
1029 {
|
|
1030 if (EQ (prop, Qwidth))
|
|
1031 {
|
|
1032 maybe_error_if_job_active (f);
|
|
1033 if (!NILP (val))
|
|
1034 {
|
|
1035 CHECK_NATNUM (val);
|
771
|
1036 FRAME_MSPRINTER_CHARWIDTH (f) = XINT (val);
|
440
|
1037 }
|
|
1038 }
|
|
1039 if (EQ (prop, Qheight))
|
|
1040 {
|
|
1041 maybe_error_if_job_active (f);
|
|
1042 if (!NILP (val))
|
|
1043 {
|
|
1044 CHECK_NATNUM (val);
|
771
|
1045 FRAME_MSPRINTER_CHARHEIGHT (f) = XINT (val);
|
440
|
1046 }
|
|
1047 }
|
|
1048 else if (EQ (prop, Qleft_margin))
|
|
1049 {
|
|
1050 maybe_error_if_job_active (f);
|
|
1051 CHECK_NATNUM (val);
|
771
|
1052 FRAME_MSPRINTER_LEFT_MARGIN (f) = XINT (val);
|
440
|
1053 }
|
|
1054 else if (EQ (prop, Qtop_margin))
|
|
1055 {
|
|
1056 maybe_error_if_job_active (f);
|
|
1057 CHECK_NATNUM (val);
|
771
|
1058 FRAME_MSPRINTER_TOP_MARGIN (f) = XINT (val);
|
440
|
1059 }
|
|
1060 else if (EQ (prop, Qright_margin))
|
|
1061 {
|
|
1062 maybe_error_if_job_active (f);
|
|
1063 CHECK_NATNUM (val);
|
771
|
1064 FRAME_MSPRINTER_RIGHT_MARGIN (f) = XINT (val);
|
440
|
1065 }
|
|
1066 else if (EQ (prop, Qbottom_margin))
|
|
1067 {
|
|
1068 maybe_error_if_job_active (f);
|
|
1069 CHECK_NATNUM (val);
|
771
|
1070 FRAME_MSPRINTER_BOTTOM_MARGIN (f) = XINT (val);
|
440
|
1071 }
|
|
1072 }
|
|
1073 }
|
|
1074 }
|
|
1075
|
|
1076 static void
|
|
1077 msprinter_set_frame_size (struct frame *f, int width, int height)
|
|
1078 {
|
|
1079 /* We're absolutely unsizeable */
|
|
1080 error_frame_unsizable (f);
|
|
1081 }
|
|
1082
|
442
|
1083 static void
|
|
1084 msprinter_eject_page (struct frame *f)
|
|
1085 {
|
|
1086 /* #### Should we eject empty pages? */
|
|
1087 if (FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
1088 {
|
|
1089 FRAME_MSPRINTER_PAGE_STARTED (f) = 0;
|
|
1090 EndPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
|
|
1091 apply_dc_geometry (f);
|
|
1092 }
|
|
1093 }
|
|
1094
|
|
1095
|
428
|
1096 void
|
|
1097 console_type_create_frame_mswindows (void)
|
|
1098 {
|
440
|
1099 /* Display frames */
|
428
|
1100 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
442
|
1101 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
428
|
1102 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
|
1103 CONSOLE_HAS_METHOD (mswindows, after_init_frame);
|
|
1104 CONSOLE_HAS_METHOD (mswindows, mark_frame);
|
|
1105 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
|
1106 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
|
1107 CONSOLE_HAS_METHOD (mswindows, get_mouse_position);
|
|
1108 CONSOLE_HAS_METHOD (mswindows, set_mouse_position);
|
|
1109 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
1110 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
442
|
1111 CONSOLE_HAS_METHOD (mswindows, enable_frame);
|
|
1112 CONSOLE_HAS_METHOD (mswindows, disable_frame);
|
428
|
1113 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
1114 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
1115 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
|
1116 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
1117 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
|
1118 CONSOLE_HAS_METHOD (mswindows, frame_property);
|
|
1119 CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p);
|
|
1120 CONSOLE_HAS_METHOD (mswindows, frame_properties);
|
|
1121 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
867
|
1122 CONSOLE_HAS_METHOD (mswindows, set_title_from_ibyte);
|
|
1123 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_ibyte); */
|
428
|
1124 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
|
1125 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p);
|
|
1126 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
442
|
1127 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer);
|
|
1128 CONSOLE_HAS_METHOD (mswindows, set_frame_icon);
|
428
|
1129 CONSOLE_HAS_METHOD (mswindows, get_frame_parent);
|
|
1130 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits);
|
|
1131 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p);
|
440
|
1132
|
|
1133 /* Printer frames, aka print jobs */
|
|
1134 CONSOLE_HAS_METHOD (msprinter, init_frame_1);
|
|
1135 CONSOLE_HAS_METHOD (msprinter, init_frame_3);
|
|
1136 CONSOLE_HAS_METHOD (msprinter, mark_frame);
|
|
1137 CONSOLE_HAS_METHOD (msprinter, delete_frame);
|
|
1138 CONSOLE_HAS_METHOD (msprinter, frame_property);
|
|
1139 CONSOLE_HAS_METHOD (msprinter, internal_frame_property_p);
|
|
1140 CONSOLE_HAS_METHOD (msprinter, frame_properties);
|
|
1141 CONSOLE_HAS_METHOD (msprinter, set_frame_properties);
|
|
1142 CONSOLE_HAS_METHOD (msprinter, set_frame_size);
|
442
|
1143 CONSOLE_HAS_METHOD (msprinter, eject_page);
|
428
|
1144 }
|
|
1145
|
|
1146 void
|
|
1147 syms_of_frame_mswindows (void)
|
|
1148 {
|
|
1149 }
|
|
1150
|
|
1151 void
|
|
1152 reinit_vars_of_frame_mswindows (void)
|
|
1153 {
|
|
1154 /* Needn't staticpro -- see comment above. */
|
|
1155 Vmswindows_frame_being_created = Qnil;
|
|
1156 }
|
|
1157
|
|
1158 void
|
|
1159 vars_of_frame_mswindows (void)
|
|
1160 {
|
|
1161 reinit_vars_of_frame_mswindows ();
|
|
1162
|
|
1163 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /*
|
|
1164 Controls whether to use system or XEmacs defaults for frame size.
|
442
|
1165 If nil then reasonable defaults are used for initial frame sizes. If t
|
428
|
1166 then the system will choose default sizes for the frame.
|
|
1167 */ );
|
|
1168 Vmswindows_use_system_frame_size_defaults = Qnil;
|
442
|
1169
|
428
|
1170 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
1171 Plist of default frame-creation properties for mswindows frames.
|
|
1172 These override what is specified in `default-frame-plist', but are
|
|
1173 overridden by the arguments to the particular call to `make-frame'.
|
|
1174
|
|
1175 Note: In many cases, properties of a frame are available as specifiers
|
|
1176 instead of through the frame-properties mechanism.
|
|
1177
|
|
1178 Here is a list of recognized frame properties, other than those
|
|
1179 documented in `set-frame-properties' (they can be queried and
|
|
1180 set at any time, except as otherwise noted):
|
|
1181
|
|
1182 initially-unmapped If non-nil, the frame will not be visible
|
|
1183 when it is created. In this case, you
|
|
1184 need to call `make-frame-visible' to make
|
|
1185 the frame appear.
|
|
1186 popup If non-nil, it should be a frame, and this
|
|
1187 frame will be created as a "popup" frame
|
|
1188 whose parent is the given frame. This
|
|
1189 will make the window manager treat the
|
|
1190 frame as a dialog box, which may entail
|
|
1191 doing different things (e.g. not asking
|
|
1192 for positioning, and not iconifying
|
|
1193 separate from its parent).
|
|
1194 top Y position (in pixels) of the upper-left
|
|
1195 outermost corner of the frame (i.e. the
|
|
1196 upper-left of the window-manager
|
|
1197 decorations).
|
|
1198 left X position (in pixels) of the upper-left
|
|
1199 outermost corner of the frame (i.e. the
|
|
1200 upper-left of the window-manager
|
|
1201 decorations).
|
|
1202
|
|
1203 See also `default-frame-plist', which specifies properties which apply
|
|
1204 to all frames, not just mswindows frames.
|
|
1205 */ );
|
|
1206 Vdefault_mswindows_frame_plist = Qnil;
|
|
1207
|
|
1208 mswindows_console_methods->device_specific_frame_props =
|
|
1209 &Vdefault_mswindows_frame_plist;
|
440
|
1210
|
|
1211 DEFVAR_LISP ("default-msprinter-frame-plist", &Vdefault_msprinter_frame_plist /*
|
|
1212 Plist of default frame-creation properties for msprinter print job frames.
|
|
1213 These override what is specified in `default-frame-plist', but are
|
|
1214 overridden by the arguments to the particular call to `make-frame'.
|
|
1215
|
|
1216 Note: In many cases, properties of a frame are available as specifiers
|
|
1217 instead of through the frame-properties mechanism.
|
|
1218
|
|
1219 Here is a list of recognized frame properties, other than those
|
|
1220 documented in `set-frame-properties' (they can be queried and
|
|
1221 set at any time, except as otherwise noted):
|
|
1222
|
|
1223 left-margin Margin of the page, in twips. Twip is a
|
|
1224 top-margin typographical unit of measurement,
|
|
1225 right-margin equal to 1/1440 of an inch, or 1/20 of a
|
|
1226 bottom-margin point, and roughly equal to 7/400 of a
|
506
|
1227 millimeter. If not specified, the left
|
|
1228 and right margins default to 1 inch
|
|
1229 (25.4 mm) and the top and bottom margins
|
|
1230 to 0.5 inch (12.7 mm).
|
440
|
1231
|
|
1232 MARGINS NOTE. right-margin and bottom-margin are overridden by
|
|
1233 the height and width properties. If you want to specify size
|
|
1234 of the printable area in character, as with the rest of XEmacs,
|
|
1235 use these properties. If height and/or width are nil, then
|
|
1236 corresponding margin setting is taken into account. If you
|
|
1237 specify height and/or width in `default-frame-plist', but still
|
|
1238 want to specify right/bottom margins, set height/width in this
|
|
1239 plist to nil, as in this example:
|
|
1240
|
506
|
1241 (setq default-frame-plist '(height 55 width 80)
|
|
1242 default-msprinter-frame-plist '(height nil width nil))
|
440
|
1243
|
|
1244 See also `default-frame-plist', which specifies properties which apply
|
|
1245 to all frames, not just mswindows frames.
|
|
1246 */ );
|
|
1247 Vdefault_msprinter_frame_plist = Qnil;
|
|
1248
|
|
1249 msprinter_console_methods->device_specific_frame_props =
|
|
1250 &Vdefault_msprinter_frame_plist;
|
428
|
1251 }
|