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