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
|
1318
|
344 /* This can call Lisp, because it runs the window procedure, which can
|
|
345 call redisplay() */
|
428
|
346 AdjustWindowRectEx (&rect,
|
771
|
347 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_STYLE),
|
|
348 GetMenu (FRAME_MSWINDOWS_HANDLE (f)) != NULL,
|
|
349 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_EXSTYLE));
|
428
|
350
|
771
|
351 if (IsIconic (FRAME_MSWINDOWS_HANDLE (f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE (f)))
|
|
352 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
353
|
771
|
354 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
355 0, 0, rect.right-rect.left, rect.bottom-rect.top,
|
|
356 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE);
|
|
357 }
|
|
358
|
|
359 static void
|
|
360 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
361 {
|
771
|
362 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
363 xoff, yoff, 0, 0,
|
|
364 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE);
|
|
365 }
|
|
366
|
|
367 static void
|
442
|
368 mswindows_make_frame_visible (struct frame *f)
|
428
|
369 {
|
771
|
370 if (!FRAME_VISIBLE_P (f))
|
|
371 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
372 else
|
771
|
373 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_SHOW);
|
|
374 SetActiveWindow (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
375 f->visible = 1;
|
|
376 f->iconified = 0;
|
|
377 }
|
|
378
|
|
379 static void
|
442
|
380 mswindows_make_frame_invisible (struct frame *f)
|
428
|
381 {
|
771
|
382 if (!FRAME_VISIBLE_P (f))
|
428
|
383 return;
|
|
384
|
771
|
385 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_HIDE);
|
428
|
386 f->visible = 0;
|
|
387 }
|
|
388
|
|
389 static int
|
|
390 mswindows_frame_totally_visible_p (struct frame *f)
|
|
391 {
|
|
392 RECT rc_me, rc_other, rc_temp;
|
771
|
393 HWND hwnd = FRAME_MSWINDOWS_HANDLE (f);
|
428
|
394
|
|
395 /* We test against not a whole window rectangle, only against its
|
|
396 client part. So, if non-client are is covered and client area is
|
|
397 not, we return true. */
|
|
398 GetClientRect (hwnd, &rc_me);
|
|
399 MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rc_me, 2);
|
|
400
|
|
401 /* First see if we're off the desktop */
|
771
|
402 GetWindowRect (GetDesktopWindow (), &rc_other);
|
|
403 UnionRect (&rc_temp, &rc_me, &rc_other);
|
428
|
404 if (!EqualRect (&rc_temp, &rc_other))
|
|
405 return 0;
|
442
|
406
|
428
|
407 /* Then see if any window above us obscures us */
|
|
408 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL)
|
|
409 if (IsWindowVisible (hwnd))
|
|
410 {
|
|
411 GetWindowRect (hwnd, &rc_other);
|
771
|
412 if (IntersectRect (&rc_temp, &rc_me, &rc_other))
|
428
|
413 return 0;
|
|
414 }
|
|
415
|
|
416 return 1;
|
|
417 }
|
|
418
|
|
419 static int
|
|
420 mswindows_frame_visible_p (struct frame *f)
|
|
421 {
|
771
|
422 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE (f))
|
|
423 && !IsIconic (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
424 }
|
|
425
|
|
426
|
|
427 static void
|
|
428 mswindows_iconify_frame (struct frame *f)
|
|
429 {
|
771
|
430 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_MINIMIZE);
|
428
|
431 f->visible = 0;
|
|
432 f->iconified = 1;
|
|
433 }
|
|
434
|
|
435 static int
|
|
436 mswindows_frame_iconified_p (struct frame *f)
|
|
437 {
|
771
|
438 return IsIconic (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
439 }
|
|
440
|
|
441 static void
|
|
442 mswindows_set_frame_icon (struct frame *f)
|
|
443 {
|
|
444 if (IMAGE_INSTANCEP (f->icon)
|
|
445 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon)))
|
|
446 {
|
|
447 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon))
|
|
448 {
|
442
|
449 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon),
|
428
|
450 FALSE);
|
|
451 }
|
442
|
452
|
771
|
453 qxeSetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON,
|
|
454 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon));
|
428
|
455 }
|
|
456 }
|
|
457
|
|
458 static void
|
|
459 mswindows_set_frame_pointer (struct frame *f)
|
|
460 {
|
|
461 if (IMAGE_INSTANCEP (f->pointer)
|
|
462 && IMAGE_INSTANCE_TYPE (XIMAGE_INSTANCE (f->pointer)) == IMAGE_POINTER)
|
|
463 {
|
771
|
464 qxeSetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HCURSOR,
|
|
465 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
428
|
466 /* we only have to do this because GC doesn't cause a mouse
|
|
467 event and doesn't give time to event processing even if it
|
|
468 did. */
|
|
469 SetCursor (XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
|
470 }
|
|
471 }
|
|
472
|
|
473 static void
|
|
474 mswindows_set_mouse_position (struct window *w, int x, int y)
|
|
475 {
|
|
476 struct frame *f = XFRAME (w->frame);
|
|
477 POINT pt;
|
|
478
|
|
479 pt.x = w->pixel_left + x;
|
|
480 pt.y = w->pixel_top + y;
|
771
|
481 ClientToScreen (FRAME_MSWINDOWS_HANDLE (f), &pt);
|
428
|
482 SetCursorPos (pt.x, pt.y);
|
|
483 }
|
|
484
|
|
485 static int
|
|
486 mswindows_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
487 {
|
|
488 POINT pt;
|
|
489 HWND hwnd;
|
|
490
|
|
491 GetCursorPos (&pt);
|
|
492
|
|
493 /* What's under cursor? */
|
|
494 hwnd = WindowFromPoint (pt);
|
|
495 if (hwnd == NULL)
|
|
496 return 0;
|
|
497
|
|
498 /* Get grandest parent of the window */
|
|
499 {
|
|
500 HWND hwnd_parent;
|
|
501 while ((hwnd_parent = GetParent (hwnd)) != NULL)
|
|
502 hwnd = hwnd_parent;
|
|
503 }
|
|
504
|
|
505 /* Make sure it belongs to us */
|
|
506 if (GetWindowThreadProcessId (hwnd, NULL) != GetCurrentThreadId ())
|
|
507 return 0;
|
|
508
|
|
509 /* And that the window is an XEmacs frame */
|
771
|
510 if (!mswindows_window_is_xemacs (hwnd))
|
|
511 return 0;
|
428
|
512
|
|
513 /* Yippie! */
|
|
514 ScreenToClient (hwnd, &pt);
|
826
|
515 *frame = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, XWL_FRAMEOBJ));
|
428
|
516 *x = pt.x;
|
|
517 *y = pt.y;
|
|
518 return 1;
|
|
519 }
|
|
520
|
|
521 static void
|
|
522 mswindows_raise_frame (struct frame *f)
|
|
523 {
|
771
|
524 BringWindowToTop (FRAME_MSWINDOWS_HANDLE (f));
|
428
|
525 }
|
|
526
|
|
527 static void
|
|
528 mswindows_lower_frame (struct frame *f)
|
|
529 {
|
771
|
530 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), HWND_BOTTOM, 0, 0, 0, 0,
|
428
|
531 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING);
|
|
532 }
|
|
533
|
|
534 static void
|
442
|
535 mswindows_enable_frame (struct frame *f)
|
|
536 {
|
|
537 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), TRUE);
|
|
538 }
|
|
539
|
|
540 static void
|
|
541 mswindows_disable_frame (struct frame *f)
|
|
542 {
|
|
543 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), FALSE);
|
|
544 }
|
|
545
|
|
546 static void
|
867
|
547 mswindows_set_title_from_ibyte (struct frame *f, Ibyte *title)
|
428
|
548 {
|
771
|
549 unsigned int new_checksum = hash_string (title, qxestrlen (title));
|
593
|
550 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM (f))
|
428
|
551 {
|
593
|
552 Extbyte *title_ext;
|
|
553
|
|
554 FRAME_MSWINDOWS_TITLE_CHECKSUM (f) = new_checksum;
|
771
|
555 C_STRING_TO_TSTR (title, title_ext);
|
|
556 qxeSetWindowText (FRAME_MSWINDOWS_HANDLE (f), title_ext);
|
428
|
557 }
|
|
558 }
|
|
559
|
|
560 static Lisp_Object
|
|
561 mswindows_frame_property (struct frame *f, Lisp_Object property)
|
|
562 {
|
|
563 if (EQ (Qleft, property) || EQ (Qtop, property))
|
|
564 {
|
|
565 RECT rc;
|
771
|
566 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
428
|
567 return make_int (EQ (Qtop, property) ? rc.top : rc.left);
|
|
568 }
|
|
569 return Qunbound;
|
|
570 }
|
|
571
|
|
572 static int
|
|
573 mswindows_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
574 {
|
|
575 return EQ (property, Qleft)
|
|
576 || EQ (property, Qtop);
|
|
577 /* #### frame-x.c has also this. Why?
|
|
578 || STRINGP (property);
|
|
579 */
|
|
580 }
|
|
581
|
|
582 static Lisp_Object
|
|
583 mswindows_frame_properties (struct frame *f)
|
|
584 {
|
|
585 Lisp_Object props = Qnil;
|
|
586 RECT rc;
|
771
|
587 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rc);
|
428
|
588
|
|
589 props = cons3 (Qtop, make_int (rc.top), props);
|
|
590 props = cons3 (Qleft, make_int (rc.left), props);
|
|
591
|
|
592 return props;
|
|
593 }
|
|
594
|
|
595 static void
|
|
596 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
597 {
|
|
598 int x=-1, y=-1;
|
|
599 int width = -1, height = -1;
|
|
600 BOOL width_specified_p = FALSE;
|
|
601 BOOL height_specified_p = FALSE;
|
|
602 BOOL x_specified_p = FALSE;
|
|
603 BOOL y_specified_p = FALSE;
|
|
604 Lisp_Object tail;
|
|
605
|
|
606 /* Extract the properties from plist */
|
|
607 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
608 {
|
|
609 Lisp_Object prop = Fcar (tail);
|
|
610 Lisp_Object val = Fcar (Fcdr (tail));
|
|
611
|
|
612 if (SYMBOLP (prop))
|
|
613 {
|
|
614 /* Kludge to handle the font property. */
|
|
615 if (EQ (prop, Qfont))
|
|
616 {
|
|
617 /* If the value is not a string we silently ignore it. */
|
|
618 if (STRINGP (val))
|
|
619 {
|
|
620 Lisp_Object frm, font_spec;
|
442
|
621
|
793
|
622 frm = wrap_frame (f);
|
428
|
623 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
624
|
|
625 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
626 update_frame_face_values (f);
|
|
627 }
|
|
628 }
|
|
629 else if (EQ (prop, Qwidth))
|
|
630 {
|
|
631 CHECK_INT (val);
|
|
632 width = XINT (val);
|
|
633 width_specified_p = TRUE;
|
|
634 }
|
|
635 else if (EQ (prop, Qheight))
|
|
636 {
|
|
637 CHECK_INT (val);
|
|
638 height = XINT (val);
|
|
639 height_specified_p = TRUE;
|
|
640 }
|
|
641 else if (EQ (prop, Qleft))
|
|
642 {
|
|
643 CHECK_INT (val);
|
|
644 x = XINT (val);
|
|
645 x_specified_p = TRUE;
|
|
646 }
|
|
647 else if (EQ (prop, Qtop))
|
|
648 {
|
|
649 CHECK_INT (val);
|
|
650 y = XINT (val);
|
|
651 y_specified_p = TRUE;
|
|
652 }
|
|
653 }
|
|
654 }
|
|
655
|
|
656 /* Now we've extracted the properties, apply them.
|
|
657 Do not apply geometric properties during frame creation. This
|
442
|
658 is excessive anyways, and this loses because WM_SIZE has not
|
428
|
659 been sent yet, so frame width and height fields are not initialized.
|
442
|
660
|
428
|
661 unfortunately WM_SIZE loses as well since the resize is only
|
|
662 applied once and the first time WM_SIZE is applied not everything
|
|
663 is initialised in the frame (toolbars for instance). enabling
|
|
664 this always makes no visible difference and fixes a whole host of
|
|
665 bugs (and is more consistent with X) so I am going to reenable it.
|
|
666 --andyp */
|
|
667 if ( FRAME_PIXWIDTH (f) && FRAME_PIXHEIGHT (f)
|
440
|
668 && (width_specified_p || height_specified_p
|
|
669 || x_specified_p || y_specified_p))
|
428
|
670 {
|
|
671 XEMACS_RECT_WH dest = { x, y, width, height };
|
|
672
|
|
673 mswindows_size_frame_internal (f, &dest);
|
|
674 }
|
|
675 }
|
|
676
|
506
|
677 void
|
771
|
678 mswindows_size_frame_internal (struct frame *f, XEMACS_RECT_WH *dest)
|
428
|
679 {
|
442
|
680 RECT rect, ws_rect;
|
428
|
681 int pixel_width, pixel_height;
|
|
682 int size_p = (dest->width >=0 || dest->height >=0);
|
|
683 int move_p = (dest->top >=0 || dest->left >=0);
|
506
|
684 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width,
|
|
685 &pixel_height);
|
442
|
686
|
428
|
687 if (dest->width < 0)
|
|
688 pixel_width = FRAME_PIXWIDTH (f);
|
|
689 if (dest->height < 0)
|
|
690 pixel_height = FRAME_PIXHEIGHT (f);
|
|
691
|
771
|
692 GetWindowRect (FRAME_MSWINDOWS_HANDLE (f), &rect);
|
428
|
693 if (dest->left < 0)
|
|
694 dest->left = rect.left;
|
|
695 if (dest->top < 0)
|
|
696 dest->top = rect.top;
|
442
|
697
|
428
|
698 rect.left = rect.top = 0;
|
|
699 rect.right = pixel_width;
|
|
700 rect.bottom = pixel_height;
|
|
701
|
|
702 AdjustWindowRectEx (&rect,
|
771
|
703 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_STYLE),
|
|
704 GetMenu (FRAME_MSWINDOWS_HANDLE (f)) != NULL,
|
|
705 qxeGetWindowLong (FRAME_MSWINDOWS_HANDLE (f), GWL_EXSTYLE));
|
428
|
706
|
442
|
707 /* resize and move the window so that it fits in the workspace. This is
|
428
|
708 not restrictive since this will happen later anyway in WM_SIZE. We
|
|
709 have to do this after adjusting the rect to account for menubar
|
|
710 etc. */
|
442
|
711 mswindows_get_workspace_coords (&ws_rect);
|
428
|
712 pixel_width = rect.right - rect.left;
|
|
713 pixel_height = rect.bottom - rect.top;
|
442
|
714 if (pixel_width > ws_rect.right - ws_rect.left)
|
428
|
715 {
|
442
|
716 pixel_width = ws_rect.right - ws_rect.left;
|
428
|
717 size_p=1;
|
|
718 }
|
442
|
719 if (pixel_height > ws_rect.bottom - ws_rect.top)
|
428
|
720 {
|
442
|
721 pixel_height = ws_rect.bottom - ws_rect.top;
|
428
|
722 size_p=1;
|
|
723 }
|
|
724
|
442
|
725 /* adjust position so window is in workspace */
|
|
726 if (dest->left + pixel_width > ws_rect.right)
|
428
|
727 {
|
442
|
728 dest->left = ws_rect.right - pixel_width;
|
428
|
729 move_p=1;
|
|
730 }
|
442
|
731 if (dest->left < ws_rect.left)
|
428
|
732 {
|
442
|
733 dest->left = ws_rect.left;
|
428
|
734 move_p=1;
|
|
735 }
|
|
736
|
442
|
737 if (dest->top + pixel_height > ws_rect.bottom)
|
|
738 {
|
|
739 dest->top = ws_rect.bottom - pixel_height;
|
|
740 move_p=1;
|
|
741 }
|
|
742 if (dest->top < ws_rect.top)
|
|
743 {
|
|
744 dest->top = ws_rect.top;
|
|
745 move_p=1;
|
|
746 }
|
|
747
|
771
|
748 if (IsIconic (FRAME_MSWINDOWS_HANDLE (f))
|
|
749 || IsZoomed (FRAME_MSWINDOWS_HANDLE (f)))
|
|
750 ShowWindow (FRAME_MSWINDOWS_HANDLE (f), SW_RESTORE);
|
428
|
751
|
771
|
752 SetWindowPos (FRAME_MSWINDOWS_HANDLE (f), NULL,
|
428
|
753 dest->left, dest->top, pixel_width, pixel_height,
|
|
754 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
|
|
755 | (size_p ? 0 : SWP_NOSIZE)
|
|
756 | (move_p ? 0 : SWP_NOMOVE));
|
|
757 }
|
|
758
|
|
759 static Lisp_Object
|
|
760 mswindows_get_frame_parent (struct frame *f)
|
|
761 {
|
771
|
762 HWND hwnd = FRAME_MSWINDOWS_HANDLE (f);
|
428
|
763 hwnd = GetParent (hwnd);
|
|
764 if (hwnd)
|
|
765 {
|
|
766 Lisp_Object parent;
|
826
|
767 parent = VOID_TO_LISP ((void *) qxeGetWindowLong (hwnd, XWL_FRAMEOBJ));
|
428
|
768 assert (FRAME_MSWINDOWS_P (XFRAME (parent)));
|
|
769 return parent;
|
|
770 }
|
|
771 else
|
|
772 return Qnil;
|
|
773 }
|
|
774
|
|
775 static void
|
771
|
776 mswindows_update_frame_external_traits (struct frame *frm, Lisp_Object name)
|
428
|
777 {
|
|
778 }
|
|
779
|
|
780 static int
|
|
781 mswindows_frame_size_fixed_p (struct frame *f)
|
|
782 {
|
|
783 /* Frame size cannot change if the frame is maximized */
|
|
784 return IsZoomed (FRAME_MSWINDOWS_HANDLE (f));
|
|
785 }
|
|
786
|
440
|
787 /*---------------------------------------------------------------------*/
|
|
788 /*----- PRINTER FRAME -----*/
|
|
789 /*---------------------------------------------------------------------*/
|
|
790
|
442
|
791 /*
|
|
792 * With some driver/os combination (I discovered this with HP drivers
|
|
793 * under W2K), DC geometry is reset upon StartDoc and EndPage
|
|
794 * calls. This is called every time one of these calls is made.
|
|
795 */
|
|
796 static void
|
|
797 apply_dc_geometry (struct frame* f)
|
|
798 {
|
|
799 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
|
|
800 SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
|
|
801 SetViewportOrgEx (hdc, FRAME_MSPRINTER_PIXLEFT(f),
|
|
802 FRAME_MSPRINTER_PIXTOP(f), NULL);
|
|
803 }
|
|
804
|
|
805 void
|
|
806 msprinter_start_page (struct frame *f)
|
|
807 {
|
|
808 if (!FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
809 {
|
|
810 FRAME_MSPRINTER_PAGE_STARTED (f) = 1;
|
|
811 StartPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
|
|
812 apply_dc_geometry (f);
|
|
813 }
|
|
814 }
|
440
|
815
|
|
816 static void
|
|
817 error_frame_unsizable (struct frame *f)
|
|
818 {
|
793
|
819 Lisp_Object frame = wrap_frame (f);
|
|
820
|
442
|
821 invalid_change ("Cannot resize frame (margins) after print job has started.",
|
|
822 frame);
|
440
|
823 }
|
|
824
|
|
825 static void
|
|
826 maybe_error_if_job_active (struct frame *f)
|
|
827 {
|
|
828 if (FRAME_MSPRINTER_JOB_STARTED (f))
|
|
829 error_frame_unsizable (f);
|
|
830 }
|
|
831
|
|
832 static void
|
771
|
833 msprinter_init_frame_1 (struct frame *f, Lisp_Object props,
|
|
834 int frame_name_is_defaulted)
|
440
|
835 {
|
|
836 /* Make sure this is the only frame on device. Windows printer can
|
|
837 handle only one job at a time. */
|
|
838 if (!NILP (DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)))))
|
442
|
839 invalid_operation ("Only one frame (print job) at a time is allowed on "
|
|
840 "this printer device", FRAME_DEVICE (f));
|
440
|
841
|
|
842 f->frame_data = xnew_and_zero (struct msprinter_frame);
|
|
843
|
506
|
844 FRAME_MSPRINTER_TOP_MARGIN (f) =
|
|
845 mswindows_get_default_margin (Qtop_margin);
|
|
846 FRAME_MSPRINTER_BOTTOM_MARGIN (f) =
|
|
847 mswindows_get_default_margin (Qbottom_margin);
|
|
848 FRAME_MSPRINTER_LEFT_MARGIN (f) =
|
|
849 mswindows_get_default_margin (Qleft_margin);
|
|
850 FRAME_MSPRINTER_RIGHT_MARGIN (f) =
|
|
851 mswindows_get_default_margin (Qright_margin);
|
440
|
852
|
|
853 /* Negative for "uinspecified" */
|
506
|
854 FRAME_MSPRINTER_CHARWIDTH (f) = -1;
|
|
855 FRAME_MSPRINTER_CHARHEIGHT (f) = -1;
|
440
|
856 }
|
|
857
|
|
858 static void
|
|
859 msprinter_init_frame_3 (struct frame *f)
|
|
860 {
|
771
|
861 DOCINFOW di;
|
440
|
862 struct device *device = XDEVICE (FRAME_DEVICE (f));
|
|
863 int frame_left, frame_top, frame_width, frame_height;
|
903
|
864
|
442
|
865 /* DC might be recreated in msprinter_apply_devmode,
|
|
866 so do not initialize until now */
|
903
|
867 HDC hdc = DEVICE_MSPRINTER_HDC (device);
|
|
868 int logpixelsx = GetDeviceCaps (hdc, LOGPIXELSX);
|
|
869 int logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
|
|
870 int physicaloffsetx = GetDeviceCaps (hdc, PHYSICALOFFSETX);
|
|
871 int physicaloffsety = GetDeviceCaps (hdc, PHYSICALOFFSETY);
|
|
872 int physicalheight = GetDeviceCaps (hdc, PHYSICALHEIGHT);
|
|
873 int physicalwidth = GetDeviceCaps (hdc, PHYSICALWIDTH);
|
440
|
874
|
903
|
875 /* Compute geometry properties.
|
|
876 Conversion is from TWIPS -> inches -> pixels. */
|
|
877 frame_left = MulDiv (logpixelsx, FRAME_MSPRINTER_LEFT_MARGIN(f), 1440)
|
|
878 - physicaloffsetx;
|
|
879
|
771
|
880 if (FRAME_MSPRINTER_CHARWIDTH (f) > 0)
|
440
|
881 {
|
771
|
882 char_to_real_pixel_size (f, FRAME_MSPRINTER_CHARWIDTH (f), 0,
|
440
|
883 &frame_width, NULL);
|
903
|
884 FRAME_MSPRINTER_RIGHT_MARGIN(f) =
|
|
885 MulDiv (physicalwidth - (frame_left + frame_width), 1440,
|
|
886 logpixelsx);
|
442
|
887 }
|
440
|
888 else
|
903
|
889 frame_width = physicalwidth - frame_left
|
|
890 - MulDiv (logpixelsx, FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440)
|
|
891 - physicaloffsetx;
|
440
|
892
|
903
|
893 frame_top = MulDiv (logpixelsy, FRAME_MSPRINTER_TOP_MARGIN(f), 1440)
|
|
894 - physicaloffsety;
|
440
|
895
|
771
|
896 if (FRAME_MSPRINTER_CHARHEIGHT (f) > 0)
|
440
|
897 {
|
771
|
898 char_to_real_pixel_size (f, 0, FRAME_MSPRINTER_CHARHEIGHT (f),
|
440
|
899 NULL, &frame_height);
|
|
900
|
903
|
901 FRAME_MSPRINTER_BOTTOM_MARGIN(f) =
|
|
902 MulDiv (physicalheight - (frame_top + frame_height), 1440,
|
|
903 logpixelsy);
|
442
|
904 }
|
440
|
905 else
|
903
|
906 frame_height = physicalheight - frame_top
|
|
907 - MulDiv (logpixelsy, FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440)
|
|
908 - physicaloffsety;
|
440
|
909
|
|
910 /* Geometry sanity checks */
|
|
911 if (!frame_pixsize_valid_p (f, frame_width, frame_height))
|
442
|
912 invalid_operation ("Area inside print margins has shrunk to naught",
|
|
913 STRINGP (f->name) ? f->name : Qunbound);
|
440
|
914
|
|
915 if (frame_left < 0
|
|
916 || frame_top < 0
|
|
917 || frame_left + frame_width > GetDeviceCaps (hdc, HORZRES)
|
|
918 || frame_top + frame_height > GetDeviceCaps (hdc, VERTRES))
|
546
|
919 invalid_operation ("Print area is outside of the printer's "
|
442
|
920 "hardware printable area",
|
|
921 STRINGP (f->name) ? f->name : Qunbound);
|
440
|
922
|
|
923 /* Apply XEmacs frame geometry and layout windows */
|
|
924 {
|
|
925 int rows, columns;
|
771
|
926 FRAME_PIXWIDTH (f) = frame_width;
|
|
927 FRAME_PIXHEIGHT (f) = frame_height;
|
440
|
928 pixel_to_char_size (f, frame_width, frame_height, &columns, &rows);
|
|
929 change_frame_size (f, rows, columns, 0);
|
|
930 }
|
|
931
|
442
|
932 FRAME_MSPRINTER_PIXLEFT(f) = frame_left;
|
|
933 FRAME_MSPRINTER_PIXTOP(f) = frame_top;
|
440
|
934
|
|
935 /* Start print job */
|
|
936 di.cbSize = sizeof (di);
|
771
|
937 {
|
|
938 const Extbyte *nameext;
|
|
939
|
|
940 if (STRINGP (f->name))
|
|
941 LISP_STRING_TO_TSTR (f->name, nameext);
|
|
942 else
|
|
943 nameext = XETEXT ("XEmacs print document");
|
|
944 di.lpszDocName = (XELPTSTR) nameext;
|
|
945 }
|
440
|
946 di.lpszOutput = NULL;
|
|
947 di.lpszDatatype = NULL;
|
|
948 di.fwType = 0;
|
|
949
|
771
|
950 if (qxeStartDoc (hdc, &di) <= 0)
|
442
|
951 invalid_operation ("Cannot start print job",
|
|
952 STRINGP (f->name) ? f->name : Qunbound);
|
|
953
|
|
954 apply_dc_geometry (f);
|
440
|
955
|
|
956 /* Finish frame setup */
|
|
957 FRAME_MSPRINTER_JOB_STARTED (f) = 1;
|
771
|
958 FRAME_VISIBLE_P (f) = 0;
|
440
|
959 }
|
|
960
|
|
961 static void
|
|
962 msprinter_mark_frame (struct frame *f)
|
|
963 {
|
|
964 }
|
|
965
|
|
966 static void
|
|
967 msprinter_delete_frame (struct frame *f)
|
|
968 {
|
|
969 if (f->frame_data)
|
|
970 {
|
442
|
971 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
|
|
972 if (FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
973 EndPage (hdc);
|
440
|
974 if (FRAME_MSPRINTER_JOB_STARTED (f))
|
442
|
975 EndDoc (hdc);
|
440
|
976 xfree (f->frame_data);
|
|
977 }
|
|
978
|
|
979 f->frame_data = 0;
|
|
980 }
|
|
981
|
|
982 static Lisp_Object
|
|
983 msprinter_frame_property (struct frame *f, Lisp_Object property)
|
|
984 {
|
|
985 if (EQ (Qleft_margin, property))
|
771
|
986 return make_int (FRAME_MSPRINTER_LEFT_MARGIN (f));
|
440
|
987 else if (EQ (Qtop_margin, property))
|
771
|
988 return make_int (FRAME_MSPRINTER_TOP_MARGIN (f));
|
440
|
989 if (EQ (Qright_margin, property))
|
771
|
990 return make_int (FRAME_MSPRINTER_RIGHT_MARGIN (f));
|
440
|
991 else if (EQ (Qbottom_margin, property))
|
771
|
992 return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN (f));
|
440
|
993 else
|
|
994 return Qunbound;
|
|
995 }
|
|
996
|
|
997 static int
|
|
998 msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
999 {
|
|
1000 return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) ||
|
442
|
1001 EQ (Qright_margin, property) || EQ (Qbottom_margin, property));
|
440
|
1002 }
|
|
1003
|
|
1004 static Lisp_Object
|
|
1005 msprinter_frame_properties (struct frame *f)
|
|
1006 {
|
|
1007 Lisp_Object props = Qnil;
|
|
1008 props = cons3 (Qbottom_margin,
|
771
|
1009 make_int (FRAME_MSPRINTER_BOTTOM_MARGIN (f)), props);
|
440
|
1010 props = cons3 (Qright_margin,
|
771
|
1011 make_int (FRAME_MSPRINTER_RIGHT_MARGIN (f)), props);
|
440
|
1012 props = cons3 (Qtop_margin,
|
771
|
1013 make_int (FRAME_MSPRINTER_TOP_MARGIN (f)), props);
|
440
|
1014 props = cons3 (Qleft_margin,
|
771
|
1015 make_int (FRAME_MSPRINTER_LEFT_MARGIN (f)), props);
|
440
|
1016 return props;
|
|
1017 }
|
|
1018
|
|
1019 static void
|
|
1020 msprinter_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
1021 {
|
|
1022 Lisp_Object tail;
|
|
1023
|
|
1024 /* Extract the properties from plist */
|
|
1025 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
1026 {
|
|
1027 Lisp_Object prop = Fcar (tail);
|
|
1028 Lisp_Object val = Fcar (Fcdr (tail));
|
|
1029
|
|
1030 if (SYMBOLP (prop))
|
|
1031 {
|
|
1032 if (EQ (prop, Qwidth))
|
|
1033 {
|
|
1034 maybe_error_if_job_active (f);
|
|
1035 if (!NILP (val))
|
|
1036 {
|
|
1037 CHECK_NATNUM (val);
|
771
|
1038 FRAME_MSPRINTER_CHARWIDTH (f) = XINT (val);
|
440
|
1039 }
|
|
1040 }
|
|
1041 if (EQ (prop, Qheight))
|
|
1042 {
|
|
1043 maybe_error_if_job_active (f);
|
|
1044 if (!NILP (val))
|
|
1045 {
|
|
1046 CHECK_NATNUM (val);
|
771
|
1047 FRAME_MSPRINTER_CHARHEIGHT (f) = XINT (val);
|
440
|
1048 }
|
|
1049 }
|
|
1050 else if (EQ (prop, Qleft_margin))
|
|
1051 {
|
|
1052 maybe_error_if_job_active (f);
|
|
1053 CHECK_NATNUM (val);
|
771
|
1054 FRAME_MSPRINTER_LEFT_MARGIN (f) = XINT (val);
|
440
|
1055 }
|
|
1056 else if (EQ (prop, Qtop_margin))
|
|
1057 {
|
|
1058 maybe_error_if_job_active (f);
|
|
1059 CHECK_NATNUM (val);
|
771
|
1060 FRAME_MSPRINTER_TOP_MARGIN (f) = XINT (val);
|
440
|
1061 }
|
|
1062 else if (EQ (prop, Qright_margin))
|
|
1063 {
|
|
1064 maybe_error_if_job_active (f);
|
|
1065 CHECK_NATNUM (val);
|
771
|
1066 FRAME_MSPRINTER_RIGHT_MARGIN (f) = XINT (val);
|
440
|
1067 }
|
|
1068 else if (EQ (prop, Qbottom_margin))
|
|
1069 {
|
|
1070 maybe_error_if_job_active (f);
|
|
1071 CHECK_NATNUM (val);
|
771
|
1072 FRAME_MSPRINTER_BOTTOM_MARGIN (f) = XINT (val);
|
440
|
1073 }
|
|
1074 }
|
|
1075 }
|
|
1076 }
|
|
1077
|
|
1078 static void
|
|
1079 msprinter_set_frame_size (struct frame *f, int width, int height)
|
|
1080 {
|
|
1081 /* We're absolutely unsizeable */
|
|
1082 error_frame_unsizable (f);
|
|
1083 }
|
|
1084
|
442
|
1085 static void
|
|
1086 msprinter_eject_page (struct frame *f)
|
|
1087 {
|
|
1088 /* #### Should we eject empty pages? */
|
|
1089 if (FRAME_MSPRINTER_PAGE_STARTED (f))
|
|
1090 {
|
|
1091 FRAME_MSPRINTER_PAGE_STARTED (f) = 0;
|
|
1092 EndPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
|
|
1093 apply_dc_geometry (f);
|
|
1094 }
|
|
1095 }
|
|
1096
|
|
1097
|
428
|
1098 void
|
|
1099 console_type_create_frame_mswindows (void)
|
|
1100 {
|
440
|
1101 /* Display frames */
|
428
|
1102 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
442
|
1103 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
428
|
1104 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
|
1105 CONSOLE_HAS_METHOD (mswindows, after_init_frame);
|
|
1106 CONSOLE_HAS_METHOD (mswindows, mark_frame);
|
|
1107 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
|
1108 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
|
1109 CONSOLE_HAS_METHOD (mswindows, get_mouse_position);
|
|
1110 CONSOLE_HAS_METHOD (mswindows, set_mouse_position);
|
|
1111 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
1112 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
442
|
1113 CONSOLE_HAS_METHOD (mswindows, enable_frame);
|
|
1114 CONSOLE_HAS_METHOD (mswindows, disable_frame);
|
428
|
1115 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
1116 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
1117 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
|
1118 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
1119 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
|
1120 CONSOLE_HAS_METHOD (mswindows, frame_property);
|
|
1121 CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p);
|
|
1122 CONSOLE_HAS_METHOD (mswindows, frame_properties);
|
|
1123 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
867
|
1124 CONSOLE_HAS_METHOD (mswindows, set_title_from_ibyte);
|
|
1125 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_ibyte); */
|
428
|
1126 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
|
1127 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p);
|
|
1128 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
442
|
1129 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer);
|
|
1130 CONSOLE_HAS_METHOD (mswindows, set_frame_icon);
|
428
|
1131 CONSOLE_HAS_METHOD (mswindows, get_frame_parent);
|
|
1132 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits);
|
|
1133 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p);
|
440
|
1134
|
|
1135 /* Printer frames, aka print jobs */
|
|
1136 CONSOLE_HAS_METHOD (msprinter, init_frame_1);
|
|
1137 CONSOLE_HAS_METHOD (msprinter, init_frame_3);
|
|
1138 CONSOLE_HAS_METHOD (msprinter, mark_frame);
|
|
1139 CONSOLE_HAS_METHOD (msprinter, delete_frame);
|
|
1140 CONSOLE_HAS_METHOD (msprinter, frame_property);
|
|
1141 CONSOLE_HAS_METHOD (msprinter, internal_frame_property_p);
|
|
1142 CONSOLE_HAS_METHOD (msprinter, frame_properties);
|
|
1143 CONSOLE_HAS_METHOD (msprinter, set_frame_properties);
|
|
1144 CONSOLE_HAS_METHOD (msprinter, set_frame_size);
|
442
|
1145 CONSOLE_HAS_METHOD (msprinter, eject_page);
|
428
|
1146 }
|
|
1147
|
|
1148 void
|
|
1149 syms_of_frame_mswindows (void)
|
|
1150 {
|
|
1151 }
|
|
1152
|
|
1153 void
|
|
1154 reinit_vars_of_frame_mswindows (void)
|
|
1155 {
|
|
1156 /* Needn't staticpro -- see comment above. */
|
|
1157 Vmswindows_frame_being_created = Qnil;
|
|
1158 }
|
|
1159
|
|
1160 void
|
|
1161 vars_of_frame_mswindows (void)
|
|
1162 {
|
|
1163 reinit_vars_of_frame_mswindows ();
|
|
1164
|
|
1165 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /*
|
|
1166 Controls whether to use system or XEmacs defaults for frame size.
|
442
|
1167 If nil then reasonable defaults are used for initial frame sizes. If t
|
428
|
1168 then the system will choose default sizes for the frame.
|
|
1169 */ );
|
|
1170 Vmswindows_use_system_frame_size_defaults = Qnil;
|
442
|
1171
|
428
|
1172 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
1173 Plist of default frame-creation properties for mswindows frames.
|
|
1174 These override what is specified in `default-frame-plist', but are
|
|
1175 overridden by the arguments to the particular call to `make-frame'.
|
|
1176
|
|
1177 Note: In many cases, properties of a frame are available as specifiers
|
|
1178 instead of through the frame-properties mechanism.
|
|
1179
|
|
1180 Here is a list of recognized frame properties, other than those
|
|
1181 documented in `set-frame-properties' (they can be queried and
|
|
1182 set at any time, except as otherwise noted):
|
|
1183
|
|
1184 initially-unmapped If non-nil, the frame will not be visible
|
|
1185 when it is created. In this case, you
|
|
1186 need to call `make-frame-visible' to make
|
|
1187 the frame appear.
|
|
1188 popup If non-nil, it should be a frame, and this
|
|
1189 frame will be created as a "popup" frame
|
|
1190 whose parent is the given frame. This
|
|
1191 will make the window manager treat the
|
|
1192 frame as a dialog box, which may entail
|
|
1193 doing different things (e.g. not asking
|
|
1194 for positioning, and not iconifying
|
|
1195 separate from its parent).
|
|
1196 top Y position (in pixels) of the upper-left
|
|
1197 outermost corner of the frame (i.e. the
|
|
1198 upper-left of the window-manager
|
|
1199 decorations).
|
|
1200 left X position (in pixels) of the upper-left
|
|
1201 outermost corner of the frame (i.e. the
|
|
1202 upper-left of the window-manager
|
|
1203 decorations).
|
|
1204
|
|
1205 See also `default-frame-plist', which specifies properties which apply
|
|
1206 to all frames, not just mswindows frames.
|
|
1207 */ );
|
|
1208 Vdefault_mswindows_frame_plist = Qnil;
|
|
1209
|
|
1210 mswindows_console_methods->device_specific_frame_props =
|
|
1211 &Vdefault_mswindows_frame_plist;
|
440
|
1212
|
|
1213 DEFVAR_LISP ("default-msprinter-frame-plist", &Vdefault_msprinter_frame_plist /*
|
|
1214 Plist of default frame-creation properties for msprinter print job frames.
|
|
1215 These override what is specified in `default-frame-plist', but are
|
|
1216 overridden by the arguments to the particular call to `make-frame'.
|
|
1217
|
|
1218 Note: In many cases, properties of a frame are available as specifiers
|
|
1219 instead of through the frame-properties mechanism.
|
|
1220
|
|
1221 Here is a list of recognized frame properties, other than those
|
|
1222 documented in `set-frame-properties' (they can be queried and
|
|
1223 set at any time, except as otherwise noted):
|
|
1224
|
|
1225 left-margin Margin of the page, in twips. Twip is a
|
|
1226 top-margin typographical unit of measurement,
|
|
1227 right-margin equal to 1/1440 of an inch, or 1/20 of a
|
|
1228 bottom-margin point, and roughly equal to 7/400 of a
|
506
|
1229 millimeter. If not specified, the left
|
|
1230 and right margins default to 1 inch
|
|
1231 (25.4 mm) and the top and bottom margins
|
|
1232 to 0.5 inch (12.7 mm).
|
440
|
1233
|
|
1234 MARGINS NOTE. right-margin and bottom-margin are overridden by
|
|
1235 the height and width properties. If you want to specify size
|
|
1236 of the printable area in character, as with the rest of XEmacs,
|
|
1237 use these properties. If height and/or width are nil, then
|
|
1238 corresponding margin setting is taken into account. If you
|
|
1239 specify height and/or width in `default-frame-plist', but still
|
|
1240 want to specify right/bottom margins, set height/width in this
|
|
1241 plist to nil, as in this example:
|
|
1242
|
506
|
1243 (setq default-frame-plist '(height 55 width 80)
|
|
1244 default-msprinter-frame-plist '(height nil width nil))
|
440
|
1245
|
|
1246 See also `default-frame-plist', which specifies properties which apply
|
|
1247 to all frames, not just mswindows frames.
|
|
1248 */ );
|
|
1249 Vdefault_msprinter_frame_plist = Qnil;
|
|
1250
|
|
1251 msprinter_console_methods->device_specific_frame_props =
|
|
1252 &Vdefault_msprinter_frame_plist;
|
428
|
1253 }
|