comparison src/frame-msw.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 5aa1854ad537
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
56 56
57 /* Default popup size, in characters */ 57 /* Default popup size, in characters */
58 #define POPUP_WIDTH 30 58 #define POPUP_WIDTH 30
59 #define POPUP_HEIGHT 10 59 #define POPUP_HEIGHT 10
60 60
61 /* Default popup size, in characters */ 61 /* Default regular frame size, in characters */
62 #define DEFAULT_FRAME_WIDTH 80 62 #define DEFAULT_FRAME_WIDTH 80
63 #define DEFAULT_FRAME_HEIGHT 35 63 #define DEFAULT_FRAME_HEIGHT 35
64 64
65 #ifdef HAVE_MENUBARS 65 #ifdef HAVE_MENUBARS
66 #define ADJR_MENUFLAG TRUE 66 #define ADJR_MENUFLAG TRUE
78 Lisp_Object Vmswindows_frame_being_created; 78 Lisp_Object Vmswindows_frame_being_created;
79 79
80 /*---------------------------------------------------------------------*/ 80 /*---------------------------------------------------------------------*/
81 /*----- DISPLAY FRAME -----*/ 81 /*----- DISPLAY FRAME -----*/
82 /*---------------------------------------------------------------------*/ 82 /*---------------------------------------------------------------------*/
83
84 HWND
85 mswindows_get_selected_frame_hwnd (void)
86 {
87 Lisp_Object frame, device;
88
89 device = Ffind_device (Qnil, Qmswindows);
90 if (NILP (device))
91 return NULL;
92 frame = DEVICE_SELECTED_FRAME (XDEVICE (device));
93 if (NILP (frame))
94 return NULL;
95
96 return FRAME_MSWINDOWS_HANDLE (XFRAME (frame));
97 }
83 98
84 static void 99 static void
85 mswindows_init_frame_1 (struct frame *f, Lisp_Object props) 100 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
86 { 101 {
87 Lisp_Object initially_unmapped; 102 Lisp_Object initially_unmapped;
93 HWND hwnd, hwnd_parent; 108 HWND hwnd, hwnd_parent;
94 109
95 /* Pick up relevant properties */ 110 /* Pick up relevant properties */
96 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil); 111 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
97 name = Fplist_get (props, Qname, Qnil); 112 name = Fplist_get (props, Qname, Qnil);
98 113
99 popup = Fplist_get (props, Qpopup, Qnil); 114 popup = Fplist_get (props, Qpopup, Qnil);
100 if (EQ (popup, Qt)) 115 if (EQ (popup, Qt))
101 popup = Fselected_frame (Qnil); 116 popup = Fselected_frame (Qnil);
102 117
103 left = Fplist_get (props, Qleft, Qnil); 118 left = Fplist_get (props, Qleft, Qnil);
119 f->frame_data = xnew_and_zero (struct mswindows_frame); 134 f->frame_data = xnew_and_zero (struct mswindows_frame);
120 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH); 135 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH);
121 136
122 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left)); 137 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left));
123 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top)); 138 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top));
124 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 : 139 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 :
125 abs (XINT (width)); 140 abs (XINT (width));
126 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 : 141 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 :
127 abs (XINT (height)); 142 abs (XINT (height));
128 143
129 /* Misc frame stuff */ 144 /* Misc frame stuff */
130 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
131 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
132 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
133 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
134 FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
135 FRAME_MSWINDOWS_DATA(f)->sizing = 0;
136 FRAME_MSWINDOWS_MENU_HASH_TABLE(f) = Qnil; 145 FRAME_MSWINDOWS_MENU_HASH_TABLE(f) = Qnil;
137 #ifdef HAVE_TOOLBARS 146 #ifdef HAVE_TOOLBARS
138 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f) = 147 FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE(f) =
139 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); 148 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
140 #endif 149 #endif
141 /* hashtable of instantiated glyphs on the frame. */ 150 /* hashtable of instantiated glyphs on the frame. */
142 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f) = 151 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f) =
152 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
153 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f) =
154 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
155 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f) =
143 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL); 156 make_lisp_hash_table (50, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
144 /* Will initialize these in WM_SIZE handler. We cannot do it now, 157 /* Will initialize these in WM_SIZE handler. We cannot do it now,
145 because we do not know what is CW_USEDEFAULT height and width */ 158 because we do not know what is CW_USEDEFAULT height and width */
146 FRAME_WIDTH (f) = 0; 159 FRAME_WIDTH (f) = 0;
147 FRAME_HEIGHT (f) = 0; 160 FRAME_HEIGHT (f) = 0;
173 GetWindowRect (hwnd_parent, &rect); 186 GetWindowRect (hwnd_parent, &rect);
174 rect_default.left = rect.left + POPUP_OFFSET; 187 rect_default.left = rect.left + POPUP_OFFSET;
175 rect_default.top = rect.top + POPUP_OFFSET; 188 rect_default.top = rect.top + POPUP_OFFSET;
176 char_to_real_pixel_size (f, POPUP_WIDTH, POPUP_HEIGHT, 189 char_to_real_pixel_size (f, POPUP_WIDTH, POPUP_HEIGHT,
177 &rect_default.width, &rect_default.height); 190 &rect_default.width, &rect_default.height);
191 FRAME_MSWINDOWS_POPUP (f) = 1;
178 } 192 }
179 193
180 AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle); 194 AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle);
181 195
182 XSETFRAME (frame_obj, f); 196 XSETFRAME (frame_obj, f);
184 Vmswindows_frame_being_created = frame_obj; 198 Vmswindows_frame_being_created = frame_obj;
185 199
186 hwnd = CreateWindowEx (exstyle, 200 hwnd = CreateWindowEx (exstyle,
187 XEMACS_CLASS, 201 XEMACS_CLASS,
188 STRINGP(f->name) ? XSTRING_DATA(f->name) : 202 STRINGP(f->name) ? XSTRING_DATA(f->name) :
189 (STRINGP(name) ? 203 (STRINGP(name) ?
190 (CONST Extbyte*)XSTRING_DATA(name) : 204 (const Extbyte*)XSTRING_DATA(name) :
191 (CONST Extbyte*)XEMACS_CLASS), 205 (const Extbyte*)XEMACS_CLASS),
192 style, 206 style,
193 rect_default.left, rect_default.top, 207 rect_default.left, rect_default.top,
194 rect_default.width, rect_default.height, 208 rect_default.width, rect_default.height,
195 hwnd_parent, NULL, NULL, NULL); 209 hwnd_parent, NULL, NULL, NULL);
196 210
197 Vmswindows_frame_being_created = Qnil; 211 Vmswindows_frame_being_created = Qnil;
198 212
199 if (hwnd == NULL) 213 if (hwnd == NULL)
200 error ("System call to create frame failed"); 214 invalid_operation ("System call to create frame failed",
201 215 STRINGP (f->name) ? f->name :
216 STRINGP (name) ? name :
217 Qunbound);
218
202 FRAME_MSWINDOWS_HANDLE(f) = hwnd; 219 FRAME_MSWINDOWS_HANDLE(f) = hwnd;
203 220
204 SetWindowLong (hwnd, XWL_FRAMEOBJ, (LONG)LISP_TO_VOID(frame_obj)); 221 SetWindowLong (hwnd, XWL_FRAMEOBJ, (LONG)LISP_TO_VOID(frame_obj));
205 FRAME_MSWINDOWS_DC(f) = GetDC (hwnd); 222 FRAME_MSWINDOWS_DC(f) = GetDC (hwnd);
206 FRAME_MSWINDOWS_CDC(f) = CreateCompatibleDC (FRAME_MSWINDOWS_CDC(f));
207 SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP); 223 SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
224
225 if (FRAME_MSWINDOWS_POPUP (f))
226 mswindows_register_popup_frame (frame_obj);
208 } 227 }
209 228
210 static void 229 static void
211 mswindows_init_frame_2 (struct frame *f, Lisp_Object props) 230 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
212 { 231 {
214 { 233 {
215 /* I don't think anything can set the frame size before this 234 /* I don't think anything can set the frame size before this
216 since we don't have X resources. This may change if we look 235 since we don't have X resources. This may change if we look
217 at the registry. Even so these values can get overridden 236 at the registry. Even so these values can get overridden
218 later.*/ 237 later.*/
219 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH, 238 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH,
220 DEFAULT_FRAME_HEIGHT }; 239 DEFAULT_FRAME_HEIGHT };
221 mswindows_size_frame_internal (f, &dest); 240 mswindows_size_frame_internal (f, &dest);
222 } 241 }
223 } 242 }
224 243
226 static void 245 static void
227 mswindows_init_frame_3 (struct frame *f) 246 mswindows_init_frame_3 (struct frame *f)
228 { 247 {
229 /* Don't do this earlier or we get a WM_PAINT before the frame is ready. 248 /* Don't do this earlier or we get a WM_PAINT before the frame is ready.
230 * The SW_x parameter in the first call that an app makes to ShowWindow is 249 * The SW_x parameter in the first call that an app makes to ShowWindow is
231 * ignored, and the parameter specified in the caller's STARTUPINFO is 250 * ignored, and the parameter specified in the caller's STARTUPINFO is
232 * substituted instead. That parameter is SW_HIDE if we were started by 251 * substituted instead. That parameter is SW_HIDE if we were started by
233 * runemacs, so call this twice. #### runemacs is evil */ 252 * runemacs, so call this twice. #### runemacs is evil */
234 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL); 253 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
235 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL); 254 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
236 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f)); 255 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
240 static void 259 static void
241 mswindows_after_init_frame (struct frame *f, int first_on_device, 260 mswindows_after_init_frame (struct frame *f, int first_on_device,
242 int first_on_console) 261 int first_on_console)
243 { 262 {
244 /* Windows, unlike X, is very synchronous. After the initial 263 /* Windows, unlike X, is very synchronous. After the initial
245 frame is created, it will never be displayed, except for 264 frame is created, it will never be displayed, except for
246 hollow border, unless we start pumping messages. Load progress 265 hollow border, unless we start pumping messages. Load progress
247 messages show in the bottom of the hollow frame, which is ugly. 266 messages show in the bottom of the hollow frame, which is ugly.
248 We redisplay the initial frame here, so modeline and root window 267 We redisplay the initial frame here, so modeline and root window
249 background show. 268 background show.
250 */ 269 */
257 { 276 {
258 mark_object (FRAME_MSWINDOWS_MENU_HASH_TABLE (f)); 277 mark_object (FRAME_MSWINDOWS_MENU_HASH_TABLE (f));
259 #ifdef HAVE_TOOLBARS 278 #ifdef HAVE_TOOLBARS
260 mark_object (FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f)); 279 mark_object (FRAME_MSWINDOWS_TOOLBAR_HASH_TABLE (f));
261 #endif 280 #endif
262 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f)); 281 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f));
282 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f));
283 mark_object (FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f));
263 } 284 }
264 285
265 static void 286 static void
266 mswindows_focus_on_frame (struct frame *f) 287 mswindows_focus_on_frame (struct frame *f)
267 { 288 {
271 static void 292 static void
272 mswindows_delete_frame (struct frame *f) 293 mswindows_delete_frame (struct frame *f)
273 { 294 {
274 if (f->frame_data) 295 if (f->frame_data)
275 { 296 {
276 DeleteDC(FRAME_MSWINDOWS_CDC(f)); 297 Lisp_Object frame;
298 XSETFRAME (frame, f);
299 mswindows_unregister_popup_frame (frame);
277 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f)); 300 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
278 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f)); 301 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
279 xfree (f->frame_data); 302 xfree (f->frame_data);
280 } 303 }
281 f->frame_data = 0; 304 f->frame_data = 0;
295 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); 318 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
296 319
297 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE(f))) 320 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
298 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE); 321 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
299 322
300 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL, 323 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
301 0, 0, rect.right-rect.left, rect.bottom-rect.top, 324 0, 0, rect.right-rect.left, rect.bottom-rect.top,
302 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE); 325 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE);
303 } 326 }
304 327
305 static void 328 static void
306 mswindows_set_frame_position (struct frame *f, int xoff, int yoff) 329 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
307 { 330 {
308 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL, 331 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
309 xoff, yoff, 0, 0, 332 xoff, yoff, 0, 0,
310 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE); 333 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE);
311 } 334 }
312 335
313 static void 336 static void
314 mswindows_make_frame_visible (struct frame *f) 337 mswindows_make_frame_visible (struct frame *f)
315 { 338 {
316 if (!FRAME_VISIBLE_P(f)) 339 if (!FRAME_VISIBLE_P(f))
317 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE); 340 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
318 else 341 else
319 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOW); 342 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOW);
320 f->visible = 1; 343 f->visible = 1;
321 f->iconified = 0; 344 f->iconified = 0;
322 } 345 }
323 346
324 static void 347 static void
325 mswindows_make_frame_invisible (struct frame *f) 348 mswindows_make_frame_invisible (struct frame *f)
326 { 349 {
327 if (!FRAME_VISIBLE_P(f)) 350 if (!FRAME_VISIBLE_P(f))
328 return; 351 return;
329 352
330 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE); 353 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE);
346 /* First see if we're off the desktop */ 369 /* First see if we're off the desktop */
347 GetWindowRect (GetDesktopWindow(), &rc_other); 370 GetWindowRect (GetDesktopWindow(), &rc_other);
348 UnionRect(&rc_temp, &rc_me, &rc_other); 371 UnionRect(&rc_temp, &rc_me, &rc_other);
349 if (!EqualRect (&rc_temp, &rc_other)) 372 if (!EqualRect (&rc_temp, &rc_other))
350 return 0; 373 return 0;
351 374
352 /* Then see if any window above us obscures us */ 375 /* Then see if any window above us obscures us */
353 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL) 376 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL)
354 if (IsWindowVisible (hwnd)) 377 if (IsWindowVisible (hwnd))
355 { 378 {
356 GetWindowRect (hwnd, &rc_other); 379 GetWindowRect (hwnd, &rc_other);
389 if (IMAGE_INSTANCEP (f->icon) 412 if (IMAGE_INSTANCEP (f->icon)
390 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon))) 413 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon)))
391 { 414 {
392 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon)) 415 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon))
393 { 416 {
394 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon), 417 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon),
395 FALSE); 418 FALSE);
396 } 419 }
397 420
398 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON, 421 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON,
399 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon)); 422 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon));
400 } 423 }
401 } 424 }
402 425
403 static void 426 static void
479 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, 0, 0, 0, 0, 502 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, 0, 0, 0, 0,
480 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING); 503 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING);
481 } 504 }
482 505
483 static void 506 static void
484 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title) 507 mswindows_enable_frame (struct frame *f)
508 {
509 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), TRUE);
510 }
511
512 static void
513 mswindows_disable_frame (struct frame *f)
514 {
515 EnableWindow (FRAME_MSWINDOWS_HANDLE (f), FALSE);
516 }
517
518 static void
519 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
485 { 520 {
486 unsigned int new_checksum = hash_string (title, strlen (title)); 521 unsigned int new_checksum = hash_string (title, strlen (title));
487 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f)) 522 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f))
488 { 523 {
489 FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum; 524 FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum;
550 { 585 {
551 /* If the value is not a string we silently ignore it. */ 586 /* If the value is not a string we silently ignore it. */
552 if (STRINGP (val)) 587 if (STRINGP (val))
553 { 588 {
554 Lisp_Object frm, font_spec; 589 Lisp_Object frm, font_spec;
555 590
556 XSETFRAME (frm, f); 591 XSETFRAME (frm, f);
557 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil); 592 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
558 593
559 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil); 594 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
560 update_frame_face_values (f); 595 update_frame_face_values (f);
587 } 622 }
588 } 623 }
589 624
590 /* Now we've extracted the properties, apply them. 625 /* Now we've extracted the properties, apply them.
591 Do not apply geometric properties during frame creation. This 626 Do not apply geometric properties during frame creation. This
592 is excessive anyways, and this loses becuase WM_SIZE has not 627 is excessive anyways, and this loses because WM_SIZE has not
593 been sent yet, so frame width and height fields are not initialized. 628 been sent yet, so frame width and height fields are not initialized.
594 629
595 unfortunately WM_SIZE loses as well since the resize is only 630 unfortunately WM_SIZE loses as well since the resize is only
596 applied once and the first time WM_SIZE is applied not everything 631 applied once and the first time WM_SIZE is applied not everything
597 is initialised in the frame (toolbars for instance). enabling 632 is initialised in the frame (toolbars for instance). enabling
598 this always makes no visible difference and fixes a whole host of 633 this always makes no visible difference and fixes a whole host of
599 bugs (and is more consistent with X) so I am going to reenable it. 634 bugs (and is more consistent with X) so I am going to reenable it.
608 } 643 }
609 } 644 }
610 645
611 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest) 646 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest)
612 { 647 {
613 RECT rect; 648 RECT rect, ws_rect;
614 int pixel_width, pixel_height; 649 int pixel_width, pixel_height;
615 int size_p = (dest->width >=0 || dest->height >=0); 650 int size_p = (dest->width >=0 || dest->height >=0);
616 int move_p = (dest->top >=0 || dest->left >=0); 651 int move_p = (dest->top >=0 || dest->left >=0);
617 struct device* d = XDEVICE (FRAME_DEVICE (f));
618 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height); 652 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height);
619 653
620 if (dest->width < 0) 654 if (dest->width < 0)
621 pixel_width = FRAME_PIXWIDTH (f); 655 pixel_width = FRAME_PIXWIDTH (f);
622 if (dest->height < 0) 656 if (dest->height < 0)
623 pixel_height = FRAME_PIXHEIGHT (f); 657 pixel_height = FRAME_PIXHEIGHT (f);
624 658
625 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect); 659 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
626 if (dest->left < 0) 660 if (dest->left < 0)
627 dest->left = rect.left; 661 dest->left = rect.left;
628 if (dest->top < 0) 662 if (dest->top < 0)
629 dest->top = rect.top; 663 dest->top = rect.top;
630 664
631 rect.left = rect.top = 0; 665 rect.left = rect.top = 0;
632 rect.right = pixel_width; 666 rect.right = pixel_width;
633 rect.bottom = pixel_height; 667 rect.bottom = pixel_height;
634 668
635 AdjustWindowRectEx (&rect, 669 AdjustWindowRectEx (&rect,
636 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), 670 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
637 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, 671 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
638 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); 672 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
639 673
640 /* resize and move the window so that it fits on the screen. This is 674 /* resize and move the window so that it fits in the workspace. This is
641 not restrictive since this will happen later anyway in WM_SIZE. We 675 not restrictive since this will happen later anyway in WM_SIZE. We
642 have to do this after adjusting the rect to account for menubar 676 have to do this after adjusting the rect to account for menubar
643 etc. */ 677 etc. */
678 mswindows_get_workspace_coords (&ws_rect);
644 pixel_width = rect.right - rect.left; 679 pixel_width = rect.right - rect.left;
645 pixel_height = rect.bottom - rect.top; 680 pixel_height = rect.bottom - rect.top;
646 if (pixel_width > DEVICE_MSWINDOWS_HORZRES(d)) 681 if (pixel_width > ws_rect.right - ws_rect.left)
647 { 682 {
648 pixel_width = DEVICE_MSWINDOWS_HORZRES(d); 683 pixel_width = ws_rect.right - ws_rect.left;
649 size_p=1; 684 size_p=1;
650 } 685 }
651 if (pixel_height > DEVICE_MSWINDOWS_VERTRES(d)) 686 if (pixel_height > ws_rect.bottom - ws_rect.top)
652 { 687 {
653 pixel_height = DEVICE_MSWINDOWS_VERTRES(d); 688 pixel_height = ws_rect.bottom - ws_rect.top;
654 size_p=1; 689 size_p=1;
655 } 690 }
656 691
657 /* adjust position so window is on screen */ 692 /* adjust position so window is in workspace */
658 if (dest->left + pixel_width > DEVICE_MSWINDOWS_HORZRES(d)) 693 if (dest->left + pixel_width > ws_rect.right)
659 { 694 {
660 dest->left = DEVICE_MSWINDOWS_HORZRES(d) - pixel_width; 695 dest->left = ws_rect.right - pixel_width;
661 move_p=1; 696 move_p=1;
662 } 697 }
663 if (dest->top + pixel_height > DEVICE_MSWINDOWS_VERTRES(d)) 698 if (dest->left < ws_rect.left)
664 { 699 {
665 dest->top = DEVICE_MSWINDOWS_VERTRES(d) - pixel_height; 700 dest->left = ws_rect.left;
666 move_p=1; 701 move_p=1;
667 } 702 }
668 703
669 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) 704 if (dest->top + pixel_height > ws_rect.bottom)
705 {
706 dest->top = ws_rect.bottom - pixel_height;
707 move_p=1;
708 }
709 if (dest->top < ws_rect.top)
710 {
711 dest->top = ws_rect.top;
712 move_p=1;
713 }
714
715 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f))
670 || IsZoomed (FRAME_MSWINDOWS_HANDLE(f))) 716 || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
671 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE); 717 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
672 718
673 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL, 719 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
674 dest->left, dest->top, pixel_width, pixel_height, 720 dest->left, dest->top, pixel_width, pixel_height,
675 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING 721 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
676 | (size_p ? 0 : SWP_NOSIZE) 722 | (size_p ? 0 : SWP_NOSIZE)
677 | (move_p ? 0 : SWP_NOMOVE)); 723 | (move_p ? 0 : SWP_NOMOVE));
678 } 724 }
707 753
708 /*---------------------------------------------------------------------*/ 754 /*---------------------------------------------------------------------*/
709 /*----- PRINTER FRAME -----*/ 755 /*----- PRINTER FRAME -----*/
710 /*---------------------------------------------------------------------*/ 756 /*---------------------------------------------------------------------*/
711 757
712 EXFUN (Fset_frame_properties, 2); 758 /*
759 * With some driver/os combination (I discovered this with HP drivers
760 * under W2K), DC geometry is reset upon StartDoc and EndPage
761 * calls. This is called every time one of these calls is made.
762 */
763 static void
764 apply_dc_geometry (struct frame* f)
765 {
766 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
767 SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
768 SetViewportOrgEx (hdc, FRAME_MSPRINTER_PIXLEFT(f),
769 FRAME_MSPRINTER_PIXTOP(f), NULL);
770 }
771
772 void
773 msprinter_start_page (struct frame *f)
774 {
775 if (!FRAME_MSPRINTER_PAGE_STARTED (f))
776 {
777 FRAME_MSPRINTER_PAGE_STARTED (f) = 1;
778 StartPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
779 apply_dc_geometry (f);
780 }
781 }
713 782
714 static void 783 static void
715 error_frame_unsizable (struct frame *f) 784 error_frame_unsizable (struct frame *f)
716 { 785 {
717 Lisp_Object frame; 786 Lisp_Object frame;
718 XSETFRAME (frame, f); 787 XSETFRAME (frame, f);
719 signal_simple_error ("Cannot resize frame (margins)" 788 invalid_change ("Cannot resize frame (margins) after print job has started.",
720 " after print job has started.", frame); 789 frame);
721 } 790 }
722 791
723 static void 792 static void
724 maybe_error_if_job_active (struct frame *f) 793 maybe_error_if_job_active (struct frame *f)
725 { 794 {
728 } 797 }
729 798
730 static void 799 static void
731 msprinter_init_frame_1 (struct frame *f, Lisp_Object props) 800 msprinter_init_frame_1 (struct frame *f, Lisp_Object props)
732 { 801 {
733 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
734 Lisp_Object frame_obj = Qnil;
735
736 /* Make sure this is the only frame on device. Windows printer can 802 /* Make sure this is the only frame on device. Windows printer can
737 handle only one job at a time. */ 803 handle only one job at a time. */
738 if (!NILP (DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f))))) 804 if (!NILP (DEVICE_FRAME_LIST (XDEVICE (FRAME_DEVICE (f)))))
739 error ("Only one frame (print job) at a time is allowed on " 805 invalid_operation ("Only one frame (print job) at a time is allowed on "
740 "this printer device."); 806 "this printer device", FRAME_DEVICE (f));
741 807
742 f->frame_data = xnew_and_zero (struct msprinter_frame); 808 f->frame_data = xnew_and_zero (struct msprinter_frame);
743 809
744 /* Default margin size is 1" = 1440 twips */ 810 /* Default margin size is 1" = 1440 twips */
745 FRAME_MSPRINTER_TOP_MARGIN(f) = 1440; 811 FRAME_MSPRINTER_TOP_MARGIN(f) = 1440;
748 FRAME_MSPRINTER_RIGHT_MARGIN(f) = 1440; 814 FRAME_MSPRINTER_RIGHT_MARGIN(f) = 1440;
749 815
750 /* Negative for "uinspecified" */ 816 /* Negative for "uinspecified" */
751 FRAME_MSPRINTER_CHARWIDTH(f) = -1; 817 FRAME_MSPRINTER_CHARWIDTH(f) = -1;
752 FRAME_MSPRINTER_CHARHEIGHT(f) = -1; 818 FRAME_MSPRINTER_CHARHEIGHT(f) = -1;
753
754 /* nil is for "system default" for these properties. */
755 FRAME_MSPRINTER_ORIENTATION(f) = Qnil;
756 FRAME_MSPRINTER_DUPLEX(f) = Qnil;
757 } 819 }
758 820
759 static void 821 static void
760 msprinter_init_frame_3 (struct frame *f) 822 msprinter_init_frame_3 (struct frame *f)
761 { 823 {
762 DOCINFO di; 824 DOCINFO di;
763 struct device *device = XDEVICE (FRAME_DEVICE (f)); 825 struct device *device = XDEVICE (FRAME_DEVICE (f));
764 HDC hdc = DEVICE_MSPRINTER_HDC (device); 826 HDC hdc;
765 int frame_left, frame_top, frame_width, frame_height; 827 int frame_left, frame_top, frame_width, frame_height;
766 828
767 /* Change printer parameters */ 829 /* DC might be recreated in msprinter_apply_devmode,
768 { 830 so do not initialize until now */
769 DEVMODE* devmode = msprinter_get_devmode_copy (device); 831 hdc = DEVICE_MSPRINTER_HDC (device);
770 devmode->dmFields = 0;
771
772 if (!NILP (FRAME_MSPRINTER_ORIENTATION(f)))
773 {
774 devmode->dmFields = DM_ORIENTATION;
775 if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qportrait))
776 devmode->dmOrientation = DMORIENT_PORTRAIT;
777 else if (EQ (FRAME_MSPRINTER_ORIENTATION(f), Qlandscape))
778 devmode->dmOrientation = DMORIENT_LANDSCAPE;
779 else
780 abort();
781 }
782
783 if (!NILP (FRAME_MSPRINTER_DUPLEX(f)))
784 {
785 devmode->dmFields = DM_DUPLEX;
786 if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qnone))
787 devmode->dmDuplex = DMDUP_SIMPLEX;
788 if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qvertical))
789 devmode->dmDuplex = DMDUP_VERTICAL;
790 if (EQ (FRAME_MSPRINTER_DUPLEX(f), Qhorizontal))
791 devmode->dmDuplex = DMDUP_HORIZONTAL;
792 else
793 abort();
794 }
795
796 msprinter_apply_devmode (device, devmode);
797 }
798 832
799 /* Compute geometry properties */ 833 /* Compute geometry properties */
800 frame_left = (MulDiv (GetDeviceCaps (hdc, LOGPIXELSX), 834 frame_left = (MulDiv (GetDeviceCaps (hdc, LOGPIXELSX),
801 FRAME_MSPRINTER_LEFT_MARGIN(f), 1440) 835 FRAME_MSPRINTER_LEFT_MARGIN(f), 1440)
802 - GetDeviceCaps (hdc, PHYSICALOFFSETX)); 836 - GetDeviceCaps (hdc, PHYSICALOFFSETX));
803 837
804 if (FRAME_MSPRINTER_CHARWIDTH(f) > 0) 838 if (FRAME_MSPRINTER_CHARWIDTH(f) > 0)
805 { 839 {
806 char_to_real_pixel_size (f, FRAME_MSPRINTER_CHARWIDTH(f), 0, 840 char_to_real_pixel_size (f, FRAME_MSPRINTER_CHARWIDTH(f), 0,
807 &frame_width, NULL); 841 &frame_width, NULL);
808 FRAME_MSPRINTER_RIGHT_MARGIN(f) = 842 FRAME_MSPRINTER_RIGHT_MARGIN(f) =
809 MulDiv (GetDeviceCaps (hdc, PHYSICALWIDTH) 843 MulDiv (GetDeviceCaps (hdc, PHYSICALWIDTH)
810 - (frame_left + frame_width), 1440, 844 - (frame_left + frame_width), 1440,
811 GetDeviceCaps (hdc, LOGPIXELSX)); 845 GetDeviceCaps (hdc, LOGPIXELSX));
812 } 846 }
813 else 847 else
814 frame_width = (GetDeviceCaps (hdc, PHYSICALWIDTH) 848 frame_width = (GetDeviceCaps (hdc, PHYSICALWIDTH)
815 - frame_left 849 - frame_left
816 - MulDiv (GetDeviceCaps (hdc, LOGPIXELSX), 850 - MulDiv (GetDeviceCaps (hdc, LOGPIXELSX),
817 FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440)); 851 FRAME_MSPRINTER_RIGHT_MARGIN(f), 1440));
823 if (FRAME_MSPRINTER_CHARHEIGHT(f) > 0) 857 if (FRAME_MSPRINTER_CHARHEIGHT(f) > 0)
824 { 858 {
825 char_to_real_pixel_size (f, 0, FRAME_MSPRINTER_CHARHEIGHT(f), 859 char_to_real_pixel_size (f, 0, FRAME_MSPRINTER_CHARHEIGHT(f),
826 NULL, &frame_height); 860 NULL, &frame_height);
827 861
828 FRAME_MSPRINTER_BOTTOM_MARGIN(f) = 862 FRAME_MSPRINTER_BOTTOM_MARGIN(f) =
829 MulDiv (GetDeviceCaps (hdc, PHYSICALHEIGHT) 863 MulDiv (GetDeviceCaps (hdc, PHYSICALHEIGHT)
830 - (frame_top + frame_height), 1440, 864 - (frame_top + frame_height), 1440,
831 GetDeviceCaps (hdc, LOGPIXELSY)); 865 GetDeviceCaps (hdc, LOGPIXELSY));
832 } 866 }
833 else 867 else
834 frame_height = (GetDeviceCaps (hdc, PHYSICALHEIGHT) 868 frame_height = (GetDeviceCaps (hdc, PHYSICALHEIGHT)
835 - frame_top 869 - frame_top
836 - MulDiv (GetDeviceCaps (hdc, LOGPIXELSY), 870 - MulDiv (GetDeviceCaps (hdc, LOGPIXELSY),
837 FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440)); 871 FRAME_MSPRINTER_BOTTOM_MARGIN(f), 1440));
838 872
839 /* Geometry sanity checks */ 873 /* Geometry sanity checks */
840 if (!frame_pixsize_valid_p (f, frame_width, frame_height)) 874 if (!frame_pixsize_valid_p (f, frame_width, frame_height))
841 error ("Area inside print margins has shrunk to naught."); 875 invalid_operation ("Area inside print margins has shrunk to naught",
876 STRINGP (f->name) ? f->name : Qunbound);
842 877
843 if (frame_left < 0 878 if (frame_left < 0
844 || frame_top < 0 879 || frame_top < 0
845 || frame_left + frame_width > GetDeviceCaps (hdc, HORZRES) 880 || frame_left + frame_width > GetDeviceCaps (hdc, HORZRES)
846 || frame_top + frame_height > GetDeviceCaps (hdc, VERTRES)) 881 || frame_top + frame_height > GetDeviceCaps (hdc, VERTRES))
847 error ("Print area is ouside of the printer's hardware printable area."); 882 invalid_operation ("Print area is ouside of the printer's "
883 "hardware printable area",
884 STRINGP (f->name) ? f->name : Qunbound);
848 885
849 /* Apply XEmacs frame geometry and layout windows */ 886 /* Apply XEmacs frame geometry and layout windows */
850 { 887 {
851 int rows, columns; 888 int rows, columns;
852 FRAME_PIXWIDTH(f) = frame_width; 889 FRAME_PIXWIDTH(f) = frame_width;
853 FRAME_PIXHEIGHT(f) = frame_height; 890 FRAME_PIXHEIGHT(f) = frame_height;
854 pixel_to_char_size (f, frame_width, frame_height, &columns, &rows); 891 pixel_to_char_size (f, frame_width, frame_height, &columns, &rows);
855 change_frame_size (f, rows, columns, 0); 892 change_frame_size (f, rows, columns, 0);
856 } 893 }
857 894
858 /* Apply DC geometry */ 895 FRAME_MSPRINTER_PIXLEFT(f) = frame_left;
859 SetTextAlign (hdc, TA_BASELINE | TA_LEFT | TA_NOUPDATECP); 896 FRAME_MSPRINTER_PIXTOP(f) = frame_top;
860 SetViewportOrgEx (hdc, frame_left, frame_top, NULL);
861 SetWindowOrgEx (hdc, 0, 0, NULL);
862 897
863 /* Start print job */ 898 /* Start print job */
864 di.cbSize = sizeof (di); 899 di.cbSize = sizeof (di);
865 di.lpszDocName = (STRINGP(f->name) 900 di.lpszDocName = (STRINGP(f->name)
866 ? (char*) XSTRING_DATA(f->name) 901 ? (char*) XSTRING_DATA(f->name)
868 di.lpszOutput = NULL; 903 di.lpszOutput = NULL;
869 di.lpszDatatype = NULL; 904 di.lpszDatatype = NULL;
870 di.fwType = 0; 905 di.fwType = 0;
871 906
872 if (StartDoc (hdc, &di) <= 0) 907 if (StartDoc (hdc, &di) <= 0)
873 error ("Cannot start print job"); 908 invalid_operation ("Cannot start print job",
909 STRINGP (f->name) ? f->name : Qunbound);
910
911 apply_dc_geometry (f);
874 912
875 /* Finish frame setup */ 913 /* Finish frame setup */
876 FRAME_MSPRINTER_CDC(f) = CreateCompatibleDC (hdc);
877 FRAME_MSPRINTER_JOB_STARTED (f) = 1; 914 FRAME_MSPRINTER_JOB_STARTED (f) = 1;
878 FRAME_VISIBLE_P(f) = 0; 915 FRAME_VISIBLE_P(f) = 0;
879 } 916 }
880 917
881 static void 918 static void
882 msprinter_mark_frame (struct frame *f) 919 msprinter_mark_frame (struct frame *f)
883 { 920 {
884 /* NOTE: These need not be marked as long as we allow only c-defined
885 symbols for their values. Although, marking these is safer than
886 expensive. [I know a proof to the theorem postulating that a
887 gator is longer than greener. Ask me. -- kkm] */
888 mark_object (FRAME_MSPRINTER_ORIENTATION (f));
889 mark_object (FRAME_MSPRINTER_DUPLEX (f));
890 } 921 }
891 922
892 static void 923 static void
893 msprinter_delete_frame (struct frame *f) 924 msprinter_delete_frame (struct frame *f)
894 { 925 {
895 if (f->frame_data) 926 if (f->frame_data)
896 { 927 {
928 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)));
929 if (FRAME_MSPRINTER_PAGE_STARTED (f))
930 EndPage (hdc);
897 if (FRAME_MSPRINTER_JOB_STARTED (f)) 931 if (FRAME_MSPRINTER_JOB_STARTED (f))
898 EndDoc (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f)))); 932 EndDoc (hdc);
899 if (FRAME_MSPRINTER_CDC(f))
900 DeleteDC(FRAME_MSPRINTER_CDC(f));
901 xfree (f->frame_data); 933 xfree (f->frame_data);
902 } 934 }
903 935
904 f->frame_data = 0; 936 f->frame_data = 0;
905 } 937 }
913 return make_int (FRAME_MSPRINTER_TOP_MARGIN(f)); 945 return make_int (FRAME_MSPRINTER_TOP_MARGIN(f));
914 if (EQ (Qright_margin, property)) 946 if (EQ (Qright_margin, property))
915 return make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f)); 947 return make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f));
916 else if (EQ (Qbottom_margin, property)) 948 else if (EQ (Qbottom_margin, property))
917 return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f)); 949 return make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f));
918 else if (EQ (Qorientation, property))
919 return FRAME_MSPRINTER_ORIENTATION(f);
920 else if (EQ (Qduplex, property))
921 return FRAME_MSPRINTER_DUPLEX(f);
922 else 950 else
923 return Qunbound; 951 return Qunbound;
924 } 952 }
925 953
926 static int 954 static int
927 msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property) 955 msprinter_internal_frame_property_p (struct frame *f, Lisp_Object property)
928 { 956 {
929 return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) || 957 return (EQ (Qleft_margin, property) || EQ (Qtop_margin, property) ||
930 EQ (Qright_margin, property) || EQ (Qbottom_margin, property) || 958 EQ (Qright_margin, property) || EQ (Qbottom_margin, property));
931 EQ (Qorientation, property) || EQ (Qduplex, property));
932 } 959 }
933 960
934 static Lisp_Object 961 static Lisp_Object
935 msprinter_frame_properties (struct frame *f) 962 msprinter_frame_properties (struct frame *f)
936 { 963 {
937 Lisp_Object props = Qnil; 964 Lisp_Object props = Qnil;
938 props = cons3 (Qorientation, FRAME_MSPRINTER_ORIENTATION(f), props);
939 props = cons3 (Qduplex, FRAME_MSPRINTER_DUPLEX(f), props);
940 props = cons3 (Qbottom_margin, 965 props = cons3 (Qbottom_margin,
941 make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f)), props); 966 make_int (FRAME_MSPRINTER_BOTTOM_MARGIN(f)), props);
942 props = cons3 (Qright_margin, 967 props = cons3 (Qright_margin,
943 make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f)), props); 968 make_int (FRAME_MSPRINTER_RIGHT_MARGIN(f)), props);
944 props = cons3 (Qtop_margin, 969 props = cons3 (Qtop_margin,
949 } 974 }
950 975
951 static void 976 static void
952 msprinter_set_frame_properties (struct frame *f, Lisp_Object plist) 977 msprinter_set_frame_properties (struct frame *f, Lisp_Object plist)
953 { 978 {
954 BOOL size_changed_p = FALSE;
955 Lisp_Object tail; 979 Lisp_Object tail;
956 980
957 /* Extract the properties from plist */ 981 /* Extract the properties from plist */
958 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) 982 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
959 { 983 {
1002 { 1026 {
1003 maybe_error_if_job_active (f); 1027 maybe_error_if_job_active (f);
1004 CHECK_NATNUM (val); 1028 CHECK_NATNUM (val);
1005 FRAME_MSPRINTER_BOTTOM_MARGIN(f) = XINT (val); 1029 FRAME_MSPRINTER_BOTTOM_MARGIN(f) = XINT (val);
1006 } 1030 }
1007 else if (EQ (prop, Qorientation))
1008 {
1009 maybe_error_if_job_active (f);
1010 CHECK_SYMBOL (val);
1011 if (!NILP(val) &&
1012 !EQ (val, Qportrait) &&
1013 !EQ (val, Qlandscape))
1014 signal_simple_error ("Page orientation can only be "
1015 "'portrait or 'landscape", val);
1016 FRAME_MSPRINTER_ORIENTATION(f) = val;
1017 }
1018 else if (EQ (prop, Qduplex))
1019 {
1020 maybe_error_if_job_active (f);
1021 CHECK_SYMBOL (val);
1022 if (!NILP(val) &&
1023 !EQ (val, Qnone) &&
1024 !EQ (val, Qvertical) &&
1025 !EQ (val, Qhorizontal))
1026 signal_simple_error ("Duplex can only be 'none, "
1027 "'vertical or 'horizontal", val);
1028 FRAME_MSPRINTER_DUPLEX(f) = val;
1029 }
1030 } 1031 }
1031 } 1032 }
1032 } 1033 }
1033 1034
1034 static void 1035 static void
1036 { 1037 {
1037 /* We're absolutely unsizeable */ 1038 /* We're absolutely unsizeable */
1038 error_frame_unsizable (f); 1039 error_frame_unsizable (f);
1039 } 1040 }
1040 1041
1042 static void
1043 msprinter_eject_page (struct frame *f)
1044 {
1045 /* #### Should we eject empty pages? */
1046 if (FRAME_MSPRINTER_PAGE_STARTED (f))
1047 {
1048 FRAME_MSPRINTER_PAGE_STARTED (f) = 0;
1049 EndPage (DEVICE_MSPRINTER_HDC (XDEVICE (FRAME_DEVICE (f))));
1050 apply_dc_geometry (f);
1051 }
1052 }
1053
1054
1041 void 1055 void
1042 console_type_create_frame_mswindows (void) 1056 console_type_create_frame_mswindows (void)
1043 { 1057 {
1044 /* Display frames */ 1058 /* Display frames */
1045 CONSOLE_HAS_METHOD (mswindows, init_frame_1); 1059 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
1046 CONSOLE_HAS_METHOD (mswindows, init_frame_2); 1060 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
1047 CONSOLE_HAS_METHOD (mswindows, init_frame_3); 1061 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
1048 CONSOLE_HAS_METHOD (mswindows, after_init_frame); 1062 CONSOLE_HAS_METHOD (mswindows, after_init_frame);
1049 CONSOLE_HAS_METHOD (mswindows, mark_frame); 1063 CONSOLE_HAS_METHOD (mswindows, mark_frame);
1050 CONSOLE_HAS_METHOD (mswindows, focus_on_frame); 1064 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
1051 CONSOLE_HAS_METHOD (mswindows, delete_frame); 1065 CONSOLE_HAS_METHOD (mswindows, delete_frame);
1052 CONSOLE_HAS_METHOD (mswindows, get_mouse_position); 1066 CONSOLE_HAS_METHOD (mswindows, get_mouse_position);
1053 CONSOLE_HAS_METHOD (mswindows, set_mouse_position); 1067 CONSOLE_HAS_METHOD (mswindows, set_mouse_position);
1054 CONSOLE_HAS_METHOD (mswindows, raise_frame); 1068 CONSOLE_HAS_METHOD (mswindows, raise_frame);
1055 CONSOLE_HAS_METHOD (mswindows, lower_frame); 1069 CONSOLE_HAS_METHOD (mswindows, lower_frame);
1070 CONSOLE_HAS_METHOD (mswindows, enable_frame);
1071 CONSOLE_HAS_METHOD (mswindows, disable_frame);
1056 CONSOLE_HAS_METHOD (mswindows, make_frame_visible); 1072 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
1057 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible); 1073 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
1058 CONSOLE_HAS_METHOD (mswindows, iconify_frame); 1074 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
1059 CONSOLE_HAS_METHOD (mswindows, set_frame_size); 1075 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
1060 CONSOLE_HAS_METHOD (mswindows, set_frame_position); 1076 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
1065 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte); 1081 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte);
1066 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */ 1082 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */
1067 CONSOLE_HAS_METHOD (mswindows, frame_visible_p); 1083 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
1068 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p); 1084 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p);
1069 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p); 1085 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
1070 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer); 1086 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer);
1071 CONSOLE_HAS_METHOD (mswindows, set_frame_icon); 1087 CONSOLE_HAS_METHOD (mswindows, set_frame_icon);
1072 CONSOLE_HAS_METHOD (mswindows, get_frame_parent); 1088 CONSOLE_HAS_METHOD (mswindows, get_frame_parent);
1073 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits); 1089 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits);
1074 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p); 1090 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p);
1075 1091
1076 /* Printer frames, aka print jobs */ 1092 /* Printer frames, aka print jobs */
1081 CONSOLE_HAS_METHOD (msprinter, frame_property); 1097 CONSOLE_HAS_METHOD (msprinter, frame_property);
1082 CONSOLE_HAS_METHOD (msprinter, internal_frame_property_p); 1098 CONSOLE_HAS_METHOD (msprinter, internal_frame_property_p);
1083 CONSOLE_HAS_METHOD (msprinter, frame_properties); 1099 CONSOLE_HAS_METHOD (msprinter, frame_properties);
1084 CONSOLE_HAS_METHOD (msprinter, set_frame_properties); 1100 CONSOLE_HAS_METHOD (msprinter, set_frame_properties);
1085 CONSOLE_HAS_METHOD (msprinter, set_frame_size); 1101 CONSOLE_HAS_METHOD (msprinter, set_frame_size);
1102 CONSOLE_HAS_METHOD (msprinter, eject_page);
1086 } 1103 }
1087 1104
1088 void 1105 void
1089 syms_of_frame_mswindows (void) 1106 syms_of_frame_mswindows (void)
1090 { 1107 {
1102 { 1119 {
1103 reinit_vars_of_frame_mswindows (); 1120 reinit_vars_of_frame_mswindows ();
1104 1121
1105 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /* 1122 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /*
1106 Controls whether to use system or XEmacs defaults for frame size. 1123 Controls whether to use system or XEmacs defaults for frame size.
1107 If nil then reasonable defaults are used for intial frame sizes. If t 1124 If nil then reasonable defaults are used for initial frame sizes. If t
1108 then the system will choose default sizes for the frame. 1125 then the system will choose default sizes for the frame.
1109 */ ); 1126 */ );
1110 Vmswindows_use_system_frame_size_defaults = Qnil; 1127 Vmswindows_use_system_frame_size_defaults = Qnil;
1111 1128
1112 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /* 1129 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
1113 Plist of default frame-creation properties for mswindows frames. 1130 Plist of default frame-creation properties for mswindows frames.
1114 These override what is specified in `default-frame-plist', but are 1131 These override what is specified in `default-frame-plist', but are
1115 overridden by the arguments to the particular call to `make-frame'. 1132 overridden by the arguments to the particular call to `make-frame'.
1116 1133
1164 1181
1165 left-margin Margin of the page, in twips. Twip is a 1182 left-margin Margin of the page, in twips. Twip is a
1166 top-margin typographical unit of measurement, 1183 top-margin typographical unit of measurement,
1167 right-margin equal to 1/1440 of an inch, or 1/20 of a 1184 right-margin equal to 1/1440 of an inch, or 1/20 of a
1168 bottom-margin point, and roughly equal to 7/400 of a 1185 bottom-margin point, and roughly equal to 7/400 of a
1169 millimeter. If not specifified, each margin 1186 millimeter. If not specified, each margin
1170 defaults to one inch (25.4 mm). 1187 defaults to one inch (25.4 mm).
1171 1188
1172 MARGINS NOTE. right-margin and bottom-margin are overridden by 1189 MARGINS NOTE. right-margin and bottom-margin are overridden by
1173 the height and width properties. If you want to specify size 1190 the height and width properties. If you want to specify size
1174 of the printable area in character, as with the rest of XEmacs, 1191 of the printable area in character, as with the rest of XEmacs,
1179 plist to nil, as in this example: 1196 plist to nil, as in this example:
1180 1197
1181 (setq default-frame-plist '(height 55 'width 80) 1198 (setq default-frame-plist '(height 55 'width 80)
1182 default-msprinter-frame-plist '(height nil 'width nil)) 1199 default-msprinter-frame-plist '(height nil 'width nil))
1183 1200
1184
1185 orientation Printer page orientation. Can be 'nil,
1186 indicating system default, 'portrait
1187 or 'landscape.
1188
1189 duplex Duplex printing mode, subject to printer
1190 support. Can be 'nil for the device default,
1191 'none for simplex printing, 'vertical or
1192 'horizontal for duplex page bound along
1193 the corresponding page direction.
1194
1195 See also `default-frame-plist', which specifies properties which apply 1201 See also `default-frame-plist', which specifies properties which apply
1196 to all frames, not just mswindows frames. 1202 to all frames, not just mswindows frames.
1197 */ ); 1203 */ );
1198 Vdefault_msprinter_frame_plist = Qnil; 1204 Vdefault_msprinter_frame_plist = Qnil;
1199 1205