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