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