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