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