annotate src/device-msw.c @ 611:38db05db9cb5

[xemacs-hg @ 2001-06-08 12:21:09 by ben] ------ gc-in-window-procedure fixes ------ alloc.c: Create "post-gc actions", to avoid those dreaded "GC during window procedure" problems. event-msw.c: Abort, clean and simple, when GC in window procedure. We want to flush these puppies out. glyphs-msw.c: Use a post-gc action when destroying subwindows. lisp.h: Declare register_post_gc_action(). scrollbar-msw.c: Use a post-gc action when unshowing scrollbar windows, if in gc. redisplay.c: Add comment about the utter evilness of what's going down here. ------ cygwin setitimer fixes ------ Makefile.in.in: Compile profile.c only when HAVE_SETITIMER. nt.c: Style fixes. nt.c: Move setitimer() emulation to win32.c, because Cygwin needs it too. profile.c: Make sure we don't compile if no setitimer(). Use qxe_setitimer() instead of just plain setitimer(). signal.c: Define qxe_setitimer() as an encapsulation around setitimer() -- call setitimer() directly unless Cygwin or MS Win, in which case we use our simulated version in win32.c. systime.h: Prototype mswindows_setitimer() and qxe_setitimer(). Long comment about "qxe" and the policy regarding encapsulation. win32.c: Move setitimer() emulation here, so Cygwin can use it. Rename a couple of functions and variables to be longer and more descriptive. In setitimer_helper_proc(), send the signal using either mswindows_raise() or (on Cygwin) kill(). If for some reason we are still getting lockups, we'll change the kill() to directly invoke the signal handlers. ------ windows shell fixes ------ callproc.c, ntproc.c: Comments about how these two files must die. callproc.c: On MS Windows, init shell-file-name from SHELL, then COMSPEC, not just COMSPEC. (more correct and closer to FSF.) Don't force a value for SHELL into the environment. (Comments added to explain why not.) nt.c: Don't shove a fabricated SHELL into the environment. See above. ------ misc fixes ------ glyphs-shared.c: Style correction. xemacs-faq.texi: Merge in the rest of Hrvoje's Windows FAQ. Redo section 7 to update current reality and add condensed versions of new changes for 21.1 and 21.4. (Not quite done for 21.4.) Lots more Windows updates. process.el: Need to quote a null argument, too. From Dan Holmsand. startup.el: startup.el: Call MS Windows init function. win32-native.el: Correct comments at top. Correctly handle passing arguments to Cygwin programs and to bash. Fix quoting of zero-length arguments (from Dan Holmsand). Set shell-command-switch based on shell-file-name, which in turn comes from env var SHELL.
author ben
date Fri, 08 Jun 2001 12:21:27 +0000
parents 5fd7ba8b56e7
children b39c14581166
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* device functions for mswindows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 Original authors: Jamie Zawinski and the FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 Rewritten by Ben Wing and Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
29 Print support added by Kirill Katsnelson, July 2000.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "console-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "console-stream.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
38 #include "objects-msw.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "events.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "sysdep.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
44 #include <commdlg.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
45
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46 #if !(defined (CYGWIN) || defined(MINGW))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 #include <objbase.h> /* For CoInitialize */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 #endif
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
49
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* win32 DDE management library globals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #ifdef HAVE_DRAGNDROP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 DWORD mswindows_dde_mlid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 HSZ mswindows_dde_service;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 HSZ mswindows_dde_topic_system;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 HSZ mswindows_dde_item_open;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 /* Control conversion of upper case file names to lower case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 nil means no, t means yes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 Lisp_Object Vmswindows_downcase_file_names;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
62 /* Control whether xemacs_stat() attempts to determine file type and link count
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 exactly, at the expense of slower operation. Since true hard links
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 are supported on NTFS volumes, this is only relevant on NT. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Lisp_Object Vmswindows_get_true_file_attributes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 Lisp_Object Qdevmodep;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
70 static Lisp_Object Q_allow_selection;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
71 static Lisp_Object Q_allow_pages;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
72 static Lisp_Object Q_selected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
73 static Lisp_Object Qselected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
74
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75 static Lisp_Object allocate_devmode (DEVMODE* src_devmode, int do_copy,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 char* src_name, struct device *d);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /* helpers */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
83 build_syscolor_string (int idx)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
85 return (idx < 0 ? Qnil : mswindows_color_to_string (GetSysColor (idx)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 build_syscolor_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 Lisp_Object color1, color2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 GCPRO1 (color1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 color1 = build_syscolor_string (index1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 color2 = build_syscolor_string (index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 RETURN_UNGCPRO (Fcons (color1, color2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 build_sysmetrics_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 return Fcons (index1 < 0 ? Qnil : make_int (GetSystemMetrics (index1)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 index2 < 0 ? Qnil : make_int (GetSystemMetrics (index2)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
106 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
107 build_devicecaps_cons (HDC hdc, int index1, int index2)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
108 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
109 return Fcons (index1 < 0 ? Qnil : make_int (GetDeviceCaps (hdc, index1)),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
110 index2 < 0 ? Qnil : make_int (GetDeviceCaps (hdc, index2)));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
111 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
112
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 /************************************************************************/
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
115 /* display methods */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 mswindows_init_device (struct device *d, Lisp_Object props)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 WNDCLASSEX wc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 HDC hdc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 DEVICE_CLASS (d) = Qcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 init_baud_rate (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 init_one_device (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 d->device_data = xnew_and_zero (struct mswindows_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 hdc = CreateCompatibleDC (NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 assert (hdc!=NULL);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 DEVICE_MSWINDOWS_HCDC(d) = hdc;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
133 DEVICE_MSWINDOWS_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134 DEVICE_MSWINDOWS_UPDATE_TICK (d) = GetTickCount ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 /* Register the main window class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 wc.cbSize = sizeof (WNDCLASSEX);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 wc.style = CS_OWNDC; /* One DC per window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 wc.cbClsExtra = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 /* This must match whatever is passed to CreateWIndowEx, NULL is ok
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 for this. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 wc.hInstance = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 wc.hIcon = LoadIcon (GetModuleHandle(NULL), XEMACS_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 /* Background brush is only used during sizing, when XEmacs cannot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 take over */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 wc.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 wc.lpszMenuName = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 wc.lpszClassName = XEMACS_CLASS;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 if (xLoadImageA) /* not in NT 3.5 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154 wc.hIconSm = (HICON) xLoadImageA (GetModuleHandle (NULL), XEMACS_CLASS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 IMAGE_ICON, 16, 16, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 wc.hIconSm = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 if (xRegisterClassExA) /* not in NT 3.5 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 xRegisterClassExA (&wc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
161 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 RegisterClassA ((WNDCLASS *) &wc.style);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 #ifdef HAVE_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 xzero (wc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 /* Register the main window class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 wc.cbSize = sizeof (WNDCLASSEX);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 wc.lpfnWndProc = (WNDPROC) mswindows_control_wnd_proc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 wc.lpszClassName = XEMACS_CONTROL_CLASS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 wc.hInstance = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 if (xRegisterClassExA) /* not in NT 3.5 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 xRegisterClassExA (&wc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 RegisterClassA ((WNDCLASS *) &wc.style);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
177 #if defined (HAVE_TOOLBARS) || defined (HAVE_WIDGETS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 InitCommonControls ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 mswindows_finish_init_device (struct device *d, Lisp_Object props)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 /* Initialize DDE management library and our related globals. We execute a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 * dde Open("file") by simulating a drop, so this depends on dnd support. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 #ifdef HAVE_DRAGNDROP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 # if !(defined(CYGWIN) || defined(MINGW))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 CoInitialize (NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 # endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
191
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 mswindows_dde_mlid = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 DdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES|
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 CBF_FAIL_POKES|CBF_FAIL_REQUESTS|CBF_SKIP_ALLNOTIFICATIONS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
196 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
198 mswindows_dde_service = DdeCreateStringHandle (mswindows_dde_mlid,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199 XEMACS_CLASS, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
200 mswindows_dde_topic_system = DdeCreateStringHandle (mswindows_dde_mlid,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
201 SZDDESYS_TOPIC, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 mswindows_delete_device (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 #ifdef HAVE_DRAGNDROP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
212 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_UNREGISTER);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
213 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_open);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
214 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_system);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
215 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_service);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 DdeUninitialize (mswindows_dde_mlid);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
217
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
218 # if !(defined(CYGWIN) || defined(MINGW))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
219 CoUninitialize ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
220 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
223 DeleteDC (DEVICE_MSWINDOWS_HCDC(d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
224 xfree (d->device_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
225 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
227 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
228 mswindows_get_workspace_coords (RECT *rc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
229 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
230 SystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
233 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
234 mswindows_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
235 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
236 mark_object (DEVICE_MSWINDOWS_FONTLIST (d));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
237 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
238
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 mswindows_device_system_metrics (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 enum device_metrics m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
243 const HDC hdc = DEVICE_MSWINDOWS_HCDC(d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
244
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 switch (m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 case DM_size_device:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
248 return Fcons (make_int (GetDeviceCaps (hdc, HORZRES)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
249 make_int (GetDeviceCaps (hdc, VERTRES)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 break;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
251 case DM_device_dpi:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252 return Fcons (make_int (GetDeviceCaps (hdc, LOGPIXELSX)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
253 make_int (GetDeviceCaps (hdc, LOGPIXELSY)));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
254 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 case DM_size_device_mm:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
256 return Fcons (make_int (GetDeviceCaps (hdc, HORZSIZE)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 make_int (GetDeviceCaps (hdc, VERTSIZE)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 case DM_num_bit_planes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 /* this is what X means by bitplanes therefore we ought to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 consistent. num planes is always 1 under mswindows and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 therefore useless */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
263 return make_int (GetDeviceCaps (hdc, BITSPIXEL));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 case DM_num_color_cells:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
266 /* #### SIZEPALETTE only valid if RC_PALETTE bit set in RASTERCAPS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 what should we return for a non-palette-based device? */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 return make_int (GetDeviceCaps (hdc, SIZEPALETTE));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 /*** Colors ***/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 #define FROB(met, fore, back) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 case DM_##met: \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274 return build_syscolor_cons (fore, back);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
275
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
276 FROB (color_default, COLOR_WINDOWTEXT, COLOR_WINDOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
277 FROB (color_select, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
278 FROB (color_balloon, COLOR_INFOTEXT, COLOR_INFOBK);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
279 FROB (color_3d_face, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
280 FROB (color_3d_light, COLOR_3DHILIGHT, COLOR_3DLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
281 FROB (color_3d_dark, COLOR_3DDKSHADOW, COLOR_3DSHADOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
282 FROB (color_menu, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
283 FROB (color_menu_highlight, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
284 FROB (color_menu_button, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
285 FROB (color_menu_disabled, COLOR_GRAYTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
286 FROB (color_toolbar, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
287 FROB (color_scrollbar, COLOR_CAPTIONTEXT, COLOR_SCROLLBAR);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 FROB (color_desktop, -1, COLOR_DESKTOP);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 FROB (color_workspace, -1, COLOR_APPWORKSPACE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 /*** Sizes ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 #define FROB(met, index1, index2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 case DM_##met: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 return build_sysmetrics_cons (index1, index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 FROB (size_cursor, SM_CXCURSOR, SM_CYCURSOR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 FROB (size_scrollbar, SM_CXVSCROLL, SM_CYHSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 FROB (size_menu, -1, SM_CYMENU);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 FROB (size_icon, SM_CXICON, SM_CYICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 FROB (size_icon_small, SM_CXSMICON, SM_CYSMICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 case DM_size_workspace:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 RECT rc;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 mswindows_get_workspace_coords (&rc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 return Fcons (make_int (rc.right - rc.left),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 make_int (rc.bottom - rc.top));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 case DM_offset_workspace:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 RECT rc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 mswindows_get_workspace_coords (&rc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 return Fcons (make_int (rc.left), make_int (rc.top));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
317 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 case DM_size_toolbar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 case DM_size_toolbar_button:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 case DM_size_toolbar_border:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 /*** Features ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 #define FROB(met, index) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 case DM_##met: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 return make_int (GetSystemMetrics (index));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 FROB (mouse_buttons, SM_CMOUSEBUTTONS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 FROB (swap_buttons, SM_SWAPBUTTON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 FROB (show_sounds, SM_SHOWSOUNDS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 FROB (slow_device, SM_SLOWMACHINE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 FROB (security, SM_SECURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 /* Do not know such property */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
345 /* printer helpers */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
346 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
347
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
348 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
349 signal_open_printer_error (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
350 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
351 invalid_operation ("Failed to open printer", DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
353
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
354
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355 /* Helper function */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357 msprinter_init_device_internal (struct device *d, char* printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359 DEVICE_MSPRINTER_NAME(d) = xstrdup (printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 if (!OpenPrinter (printer_name, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 DEVICE_MSPRINTER_HPRINTER (d) = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 DEVICE_MSPRINTER_HDC (d) = CreateDC ("WINSPOOL", printer_name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
368 NULL, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
369 if (DEVICE_MSPRINTER_HDC (d) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
370 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372 DEVICE_MSPRINTER_HCDC(d) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
373 CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
374
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
375 DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377 > 1) ? Qcolor : Qmono;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
378 return 1;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
379 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
380
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
381 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382 msprinter_delete_device_internal (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 if (DEVICE_MSPRINTER_HPRINTER (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
386 if (DEVICE_MSPRINTER_HDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
387 DeleteDC (DEVICE_MSPRINTER_HDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
388 if (DEVICE_MSPRINTER_HCDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 DeleteDC (DEVICE_MSPRINTER_HCDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390 if (DEVICE_MSPRINTER_NAME (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 xfree (DEVICE_MSPRINTER_NAME (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
394 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
397 msprinter_reinit_device (struct device *d, char* devname)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
398 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
399 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
400 return msprinter_init_device_internal (d, devname);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
403 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
404 msprinter_default_printer (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
406 Extbyte name[666];
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 576
diff changeset
407 Bufbyte *nameint;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
408
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
409 if (GetProfileString (XETEXT ("windows"), XETEXT ("device"), NULL, name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
410 sizeof (name) / XETCHAR_SIZE) <= 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 EXTERNAL_TO_C_STRING (name, nameint, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
413
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
414 if (name[0] == '\0')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
415 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
416 strtok (name, ",");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
417
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
418 return build_string (name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
419 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
420
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
421
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
422 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
423 /* printer methods */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
424 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
425
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
426 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
427 msprinter_init_device (struct device *d, Lisp_Object props)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
428 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
429 char* printer_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 DEVMODE *pdm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431 size_t dm_size;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
432
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
433 d->device_data = xnew_and_zero (struct msprinter_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
434
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
435 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 DEVICE_MSPRINTER_DEVMODE(d) = Qnil;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
437
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
438 /* We do not use printer fon list as we do with the display
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
439 device. Rather, we allow GDI to pick the closest match to the
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
440 display font. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
441 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
442
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 CHECK_STRING (DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
444
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446 C_STRING_ALLOCA, printer_name,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 if (!msprinter_init_device_internal (d, printer_name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 /* Determine DEVMODE size and store the default DEVMODE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 dm_size = DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 printer_name, NULL, NULL, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 if (dm_size <= 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 pdm = (DEVMODE*) xmalloc (dm_size);
552
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
459 if (DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
460 printer_name, pdm,
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
461 NULL, DM_OUT_BUFFER) < 0)
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
462 signal_open_printer_error (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 assert (DEVMODE_SIZE (pdm) <= dm_size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
465
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 DEVICE_MSPRINTER_DEVMODE(d) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 allocate_devmode (pdm, 0, printer_name, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 msprinter_delete_device (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 if (d->device_data)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 /* Disassociate the selected devmode with the device */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 if (!NILP (DEVICE_MSPRINTER_DEVMODE (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d))->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 xfree (d->device_data);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
487 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
488
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
489 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
490 msprinter_device_system_metrics (struct device *d,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
491 enum device_metrics m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
492 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
493 switch (m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
494 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
495 /* Device sizes - pixel and mm */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
496 #define FROB(met, index1, index2) \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
497 case DM_##met: \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
498 return build_devicecaps_cons \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
499 (DEVICE_MSPRINTER_HDC(d), index1, index2);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
500
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
501 FROB (size_device, PHYSICALWIDTH, PHYSICALHEIGHT);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
502 FROB (size_device_mm, HORZSIZE, VERTSIZE);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
503 FROB (size_workspace, HORZRES, VERTRES);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
504 FROB (offset_workspace, PHYSICALOFFSETX, PHYSICALOFFSETY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
505 FROB (device_dpi, LOGPIXELSX, LOGPIXELSY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
506 #undef FROB
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
507
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
508 case DM_num_bit_planes:
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
509 /* this is what X means by bitplanes therefore we ought to be
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
510 consistent. num planes is always 1 under mswindows and
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
511 therefore useless */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
512 return make_int (GetDeviceCaps (DEVICE_MSPRINTER_HDC(d), BITSPIXEL));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
513
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514 case DM_num_color_cells: /* Printers are non-palette devices */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
515 case DM_slow_device: /* Animation would be a really bad idea */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
516 case DM_security: /* Not provided by windows */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
517 return Qzero;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
518 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
519
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
520 /* Do not know such property */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
521 return Qunbound;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
522 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
523
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
524 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
525 msprinter_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
526 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
527 mark_object (DEVICE_MSPRINTER_FONTLIST (d));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 mark_object (DEVICE_MSPRINTER_DEVMODE (d));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
529 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
530
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
531
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
532 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533 /* printer Lisp subroutines */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
534 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
535
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 global_free_2_maybe (HGLOBAL hg1, HGLOBAL hg2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 if (hg1 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 GlobalFree (hg1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 if (hg2 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 GlobalFree (hg2);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 static HGLOBAL
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546 devmode_to_hglobal (Lisp_Devmode *ldm)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
547 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548 HGLOBAL hg = GlobalAlloc (GHND, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 memcpy (GlobalLock (hg), ldm->devmode, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 GlobalUnlock (hg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
551 return hg;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554 /* Returns 0 if the printer has been deleted due to a fatal I/O error,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
555 1 otherwise. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 sync_printer_with_devmode (struct device* d, DEVMODE* devmode_in,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
558 DEVMODE* devmode_out, char* devname)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
559 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 /* Change connection if the device changed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
561 if (devname != NULL
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 && stricmp (devname, DEVICE_MSPRINTER_NAME(d)) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 Lisp_Object new_connection = build_ext_string (devname, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 GCPRO1 (new_connection);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 DEVICE_CONNECTION (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 if (!NILP (Ffind_device (new_connection, Qmsprinter)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 /* We are in trouble - second msprinter for the same device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 Nothing wrong on the Windows side, just forge a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 connection name. Use the memory address of d as a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 suffix. */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
575 Extbyte *new_connext = (Extbyte *) alloca (strlen (devname + 11));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
576 sprintf (new_connext, "%s:%X", devname, d->header.uid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 new_connection = build_ext_string (devname, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 DEVICE_CONNECTION (d) = new_connection;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 /* Reinitialize printer. The device can pop off in process */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583 if (!msprinter_reinit_device (d, devname))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 /* Kaboom! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
586 delete_device_internal (d, 1, 0, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
587 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
588 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
590
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
591 /* Apply the new devmode to the printer */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
592 DocumentProperties (NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
593 DEVICE_MSPRINTER_HPRINTER(d),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 DEVICE_MSPRINTER_NAME(d),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
595 devmode_out, devmode_in,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
596 DM_IN_BUFFER | DM_OUT_BUFFER);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
597
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
598 /* #### ResetDC fails sometimes, Bill only knows why.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
599 The solution below looks more like a workaround to me,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
600 although it might be fine. --kkm */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
601 if (ResetDC (DEVICE_MSPRINTER_HDC (d), devmode_out) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
602 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
603 DeleteDC (DEVICE_MSPRINTER_HDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604 DEVICE_MSPRINTER_HDC (d) =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 CreateDC ("WINSPOOL", DEVICE_MSPRINTER_NAME(d), NULL, devmode_out);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
606 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
607
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
608 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
609 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
610
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
611 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
612 handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
613 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
614 DEVNAMES* devnames = (DEVNAMES*) GlobalLock (hDevNames);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
615 char *new_name = devnames ? (char*)devnames + devnames->wDeviceOffset : NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616 DEVMODE* devmode = (DEVMODE*) GlobalLock (hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618 /* Size and name may have changed */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
619 ldm->devmode = (DEVMODE *) xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620 if (new_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 if (ldm->printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
623 xfree (ldm->printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 ldm->printer_name = xstrdup (new_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
626
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
627 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629 /* Apply the new devmode to the printer and get a compete one back */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 struct device *d = XDEVICE (ldm->device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 if (!sync_printer_with_devmode (d, devmode, ldm->devmode, new_name))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 global_free_2_maybe (hDevNames, hDevMode);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
634 signal_error (Qio_error, "Printer device initialization I/O error, device deleted", Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639 /* Just copy the devmode structure */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
640 memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
642 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
643
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645 ensure_not_printing (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
647 if (!NILP (DEVICE_FRAME_LIST (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
648 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
649 Lisp_Object device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
650 XSETDEVICE (device, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 invalid_operation ("Cannot change settings while print job is active",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
653 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656 static Lisp_Devmode *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657 decode_devmode (Lisp_Object dev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 if (DEVMODEP (dev))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 return XDEVMODE (dev);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663 ensure_not_printing (XDEVICE (dev));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (XDEVICE (dev)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
666 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
667
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
668 /*
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 * DEV can be either a printer or devmode
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
670 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671 static Lisp_Object
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
672 print_dialog_worker (Lisp_Object dev, DWORD flags)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 Lisp_Devmode *ldm = decode_devmode (dev);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 PRINTDLG pd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 pd.hDevMode = devmode_to_hglobal (ldm);
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
681 pd.Flags = flags | PD_USEDEVMODECOPIESANDCOLLATE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 pd.nMinPage = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 pd.nMaxPage = 0xFFFF;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 if (!PrintDlg (&pd))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
688 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 GCPRO1 (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699 /* Do consing in reverse order.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700 Number of copies */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
701 result = Fcons (Qcopies, Fcons (make_int (pd.nCopies), result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 /* Page range */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
704 if (pd.Flags & PD_PAGENUMS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 result = Fcons (Qto_page, Fcons (make_int (pd.nToPage), result));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 result = Fcons (Qfrom_page, Fcons (make_int (pd.nFromPage), result));
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
708 result = Fcons (Qselected_page_button, Fcons (Qpages, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
710 else if (pd.Flags & PD_SELECTION)
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
711 result = Fcons (Qselected_page_button, Fcons (Qselection, result));
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
712 else
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
713 result = Fcons (Qselected_page_button, Fcons (Qall, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
715 /* Device name */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
716 result = Fcons (Qname, Fcons (build_ext_string (ldm->printer_name,
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
717 Qmswindows_tstr),
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
718 result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
722 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
723 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 Lisp_Object
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
727 mswindows_handle_print_dialog_box (struct frame *f, Lisp_Object keys)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
729 Lisp_Object device = Qunbound, settings = Qunbound;
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
730 DWORD flags = PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
734 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
735 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
736 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
737 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
738 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
739 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
740 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
741 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
742 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
745 else if (EQ (key, Q_allow_pages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
746 {
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
747 if (NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
748 flags |= PD_NOPAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
749 }
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
750 else if (EQ (key, Q_allow_selection))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
751 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
752 if (!NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
753 flags &= ~PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
755 else if (EQ (key, Q_selected_page_button))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
756 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
757 if (EQ (value, Qselection))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
758 flags |= PD_SELECTION;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
759 else if (EQ (value, Qpages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
760 flags |= PD_PAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
761 else if (!EQ (value, Qall))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
762 invalid_constant ("for :selected-page-button", value);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
763 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
764 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
765 invalid_constant ("Unrecognized print-dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
766 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
767 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
768
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
769 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
770 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
771 sferror ("Exactly one of :device and :printer-settings must be given",
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772 keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
773
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
774 return print_dialog_worker (!UNBOUNDP (device) ? device : settings, flags);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
775 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
776
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
777 int
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
778 mswindows_get_default_margin (Lisp_Object prop)
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
779 {
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
780 if (EQ (prop, Qleft_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
781 if (EQ (prop, Qright_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
782 if (EQ (prop, Qtop_margin)) return 720;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
783 if (EQ (prop, Qbottom_margin)) return 720;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
784 abort ();
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
785 return 0;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
786 }
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
787
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
788 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 plist_get_margin (Lisp_Object plist, Lisp_Object prop)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 {
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
791 Lisp_Object val =
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
792 Fplist_get (plist, prop, make_int (mswindows_get_default_margin (prop)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
793 if (!INTP (val))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794 invalid_argument ("Margin value must be an integer", val);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796 return MulDiv (XINT (val), 100, 144);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
797 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
798
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
799 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
800 plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
801 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
802 Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 2450 : 100));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
803 return Fcons (prop, Fcons (val, plist));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
804 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
805
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
806 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
807 mswindows_handle_page_setup_dialog_box (struct frame *f, Lisp_Object keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
808 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
809 Lisp_Object device = Qunbound, settings = Qunbound;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
810 Lisp_Object plist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
811
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
812 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
813 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
815 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
818 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
821 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
822 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
823 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
824 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825 else if (EQ (key, Q_properties))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
826 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
827 CHECK_LIST (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 plist = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
830 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
831 invalid_constant ("Unrecognized page-setup dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
832 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
833 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
834
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
835 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
836 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
837 sferror ("Exactly one of :device and :printer-settings must be given",
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
838 keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
839
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
840 if (UNBOUNDP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
841 device = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
842
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
843 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
844 Lisp_Devmode *ldm = decode_devmode (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
845 PAGESETUPDLG pd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
846
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
847 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
848 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
849 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
850 pd.Flags = PSD_MARGINS;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
851 pd.rtMargin.left = plist_get_margin (plist, Qleft_margin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
852 pd.rtMargin.top = plist_get_margin (plist, Qtop_margin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
853 pd.rtMargin.right = plist_get_margin (plist, Qright_margin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
854 pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
855 pd.hDevMode = devmode_to_hglobal (ldm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
856
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
857 if (!PageSetupDlg (&pd))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
858 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
859 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
860 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
861 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
862
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
863 if (pd.hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
864 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
865
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
866 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
868 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
870 result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
871 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
872 result = plist_set_margin (result, Qright_margin, pd.rtMargin.right,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
874 result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
875 result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
877 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
878 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
880
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
881 DEFUN ("msprinter-get-settings", Fmsprinter_get_settings, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
882 Return the settings object currently used by DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
883 The object returned is not a copy, but rather a pointer to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
884 original one. Use `msprinter-settings-copy' to create a copy of it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
885 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
886 (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
887 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889 XSETDEVICE (device, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
890 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
891 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
892 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
894 DEFUN ("msprinter-select-settings", Fmsprinter_select_settings, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
895 Select SETTINGS object into a DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
896 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
897 printer, possibly changing even the target printer itself, and all
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
898 future changes are applied synchronously to the printer device and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
899 selected printer object, until a different settings object is selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
900 into the same printer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
901
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
902 A settings object can be selected to no more than one printer at a time.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
903
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 If the supplied settings object is not specialized, it is specialized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
905 for the printer immediately upon selection. The object can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
906 despecialized after it is unselected by calling the function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
907 `msprinter-settings-despecialize'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909 Return value is the previously selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
911 (device, settings))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
912 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
913 Lisp_Devmode *ldm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
914 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
916 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
917 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
918
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
919 XSETDEVICE (device, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
920 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
925 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
926 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
927
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
928 /* If the object being selected is de-specialized, then its
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
929 size is perhaps not enough to receive the new devmode. We can ask
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
930 for printer's devmode size here, because despecialized settings
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
931 cannot force switching to a different printer, as they supply no
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
932 printer name at all. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
933 if (ldm->printer_name == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
934 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
935 size_t dm_size =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
936 DocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
937 DEVICE_MSPRINTER_NAME(d), NULL, NULL, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
938 if (dm_size <= 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
939 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
940 "Unable to specialize settings, printer error",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
941 device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
942
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
943 assert (XDEVMODE_SIZE (ldm) <= dm_size);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
944 ldm->devmode = (DEVMODE *) xrealloc (ldm->devmode, dm_size);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
945 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
946
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
947 /* If we bail out on signal here, no damage is done, except that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
948 the storage for the DEVMODE structure might be reallocated to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
949 hold a larger one - not a big deal */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
950 if (!sync_printer_with_devmode (d, ldm->devmode, ldm->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
951 ldm->printer_name))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
952 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
953 "Printer device initialization I/O error, device deleted",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
954 Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
955
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
956 if (ldm->printer_name == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
957 ldm->printer_name = xstrdup (DEVICE_MSPRINTER_NAME(d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
958
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
960 Lisp_Object old_mode = DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
961 ldm->device = device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
962 XDEVMODE (old_mode)->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
963 DEVICE_MSPRINTER_DEVMODE (d) = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
964 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
965 return old_mode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
966 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
967 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
968
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
969 DEFUN ("msprinter-apply-settings", Fmsprinter_apply_settings, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
970 Apply settings from a SETTINGS object to a 'msprinter DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
971 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
972 printer, possibly changing even the target printer itself. The SETTING
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
973 object is not modified, unlike `msprinter-select-settings', and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
974 supplied object is not changed. The changes are immediately recorded
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
975 into the settings object which is currently selected into the printer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
976 device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
977
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
978 Return value is the currently selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
979 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
980 (device, settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
981 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
982 Lisp_Devmode *ldm_current, *ldm_new;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
984
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
985 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
986 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
987
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
988 XSETDEVICE (device, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
989 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
990 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
991 ldm_new = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
992 ldm_current = XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
993
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
994 /* If the supplied devmode is not specialized, then the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
995 devmode size will always be sufficient, as the printer does
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
996 not change. If it is specialized, we must reallocate the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
997 devmode storage to match with the supplied one, as it has the right
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
998 size for the new printer, if it is going to change. The correct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
999 way is to use the largest of the two though, to keep the old
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1000 contents unchanged in case of preliminary exit.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1001 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1002 if (ldm_new->printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1003 ldm_current->devmode =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1004 (DEVMODE*) xrealloc (ldm_current->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1005 max (XDEVMODE_SIZE (ldm_new),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1006 XDEVMODE_SIZE (ldm_current)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1007
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1008 if (!sync_printer_with_devmode (d, ldm_new->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1009 ldm_current->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1010 ldm_new->printer_name))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1011 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1012 "Printer device initialization I/O error, device deleted",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1013 Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1014
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1015 if (ldm_new->printer_name != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1016 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1017 xfree (ldm_current->printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1018 ldm_current->printer_name = xstrdup (ldm_new->printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1019 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1020
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1021 UNGCPRO;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1022 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1023 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1024
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1025 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1026 /* devmode */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1027 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1028
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1029 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1030 print_devmode (Lisp_Object obj, Lisp_Object printcharfun,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1031 int escapeflag)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 char buf[100];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1035 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1036 printing_unreadable_object ("#<msprinter-settings 0x%x>",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1037 dm->header.uid);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1038 write_c_string ("#<msprinter-settings", printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1039 if (dm->printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1040 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1041 write_c_string (" for \"", printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1042 write_c_string (dm->printer_name, printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1043 write_c_string ("\"", printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1044 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1045 if (!NILP (dm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1047 write_c_string (" (currently on ", printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1048 print_internal (dm->device, printcharfun, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1049 write_c_string (")", printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1050 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1051 sprintf (buf, " 0x%x>", dm->header.uid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1052 write_c_string (buf, printcharfun);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1053 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1054
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1055 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1056 finalize_devmode (void *header, int for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1057 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1058 Lisp_Devmode *dm = (Lisp_Devmode *) header;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1059
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1060 if (for_disksave)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1061 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1062 Lisp_Object devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1063 XSETDEVMODE (devmode, dm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1064 invalid_operation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1065 ("Cannot dump XEmacs containing an msprinter-settings object",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1066 devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1067 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1068
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1069 assert (NILP (dm->device));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1070
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1071 if (dm->printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1072 xfree (dm->printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1073 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1074
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1075 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1076 equal_devmode (Lisp_Object obj1, Lisp_Object obj2, int depth)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1077 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1078 Lisp_Devmode *dm1 = XDEVMODE (obj1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1079 Lisp_Devmode *dm2 = XDEVMODE (obj2);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1080
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1081 if ((dm1->devmode != NULL) != (dm1->devmode != NULL))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1082 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1083 if (dm1->devmode == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1084 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1085 if (memcmp (dm1->devmode, dm2->devmode, XDEVMODE_SIZE (dm1)) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1087 if (dm1->printer_name == NULL || dm2->printer_name == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1088 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1089 return stricmp (dm1->printer_name, dm2->printer_name) == 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1090 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1091
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1092 static unsigned long
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1093 hash_devmode (Lisp_Object obj, int depth)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1094 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1095 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1096
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1097 return HASH3 (XDEVMODE_SIZE (dm),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1098 dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1099 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1100 dm->printer_name ? string_hash (dm->printer_name) : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1101 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1102
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1103 DEFINE_LRECORD_IMPLEMENTATION ("msprinter-settings", devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1104 0/*mark*/, print_devmode, finalize_devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1105 equal_devmode, hash_devmode, 0/*description*/,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1106 Lisp_Devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1107 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1108 allocate_devmode (DEVMODE* src_devmode, int do_copy,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1109 char* src_name, struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1110 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1111 Lisp_Devmode *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1112 Lisp_Object ob;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1114 dm = alloc_lcrecord_type (Lisp_Devmode, &lrecord_devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1115
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1116 if (d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1117 XSETDEVICE (dm->device, d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1118 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1119 dm->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1120
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1121 dm->printer_name = src_name ? xstrdup (src_name) : NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1122
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1123 if (src_devmode != NULL && do_copy)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1124 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1125 dm->devmode = (DEVMODE*) xmalloc (DEVMODE_SIZE (src_devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1126 memcpy (dm->devmode, src_devmode, DEVMODE_SIZE (src_devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1127 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1128 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1129 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1130 dm->devmode = src_devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1131 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1132
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1133 XSETDEVMODE (ob, dm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1134 return ob;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1135 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1136
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1137 DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1138 Create and returns an exact copy of a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1139 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1140 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1141 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1142 Lisp_Devmode *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1143
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1144 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1145 dm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1146
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1147 return allocate_devmode (dm->devmode, 1, dm->printer_name, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1148 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1149
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1150 DEFUN ("msprinter-settings-despecialize", Fmsprinter_settings_despecialize, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1151 Erase printer-specific settings from a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1152 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1153 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1154 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1155 Lisp_Devmode *ldm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1156 DEVMODE *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1157
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1158 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1159 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1160
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1161 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1162 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1163 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1164
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1165 dm = ldm->devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1166
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1167 /* #### TODO. Either remove references to device specific bins,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1168 paper sizes etc, or signal an error of they are present. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1169
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1170 dm->dmDriverExtra = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1171 dm->dmDeviceName[0] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1172
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1173 if (ldm->printer_name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1174 xfree (ldm->printer_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1175
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1176 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1177 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1179 DEFUN ("mswindows-get-default-printer", Fmswindows_get_default_printer, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1180 Return name of the default printer, as string, on nil if there is no default.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1181 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1182 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1183 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1184 return msprinter_default_printer ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1185 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1186
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1187 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1188 signal_enum_printer_error (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1189 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1190 invalid_operation ("Error enumerating printers", make_int (GetLastError ()));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1191 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1192
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1193 DEFUN ("mswindows-printer-list", Fmswindows_printer_list, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1194 Return a list of string names of installed printers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1195 If there is a default printer, it is returned as the first element of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1196 the list. If there is no default printer, the first element of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1197 list will be nil. The rest of elements are guaranteed to have string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1198 values. Return value is nil if there are no printers installed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1199 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1200 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1201 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1202 int have_nt, ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1203 BYTE *data_buf, dummy_byte;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1204 size_t enum_entry_size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1205 DWORD enum_flags, enum_level, bytes_needed, num_printers;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1206 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1207 Lisp_Object result = Qnil, def_printer = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1208
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1209 /* Determine OS flavor, to use the fastest enumeration method available */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1210 have_nt = !mswindows_windows9x_p ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1211 enum_flags = PRINTER_ENUM_LOCAL | (have_nt ? PRINTER_ENUM_CONNECTIONS : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1212 enum_level = have_nt ? 4 : 5;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1213 enum_entry_size = have_nt ? sizeof (PRINTER_INFO_4) : sizeof (PRINTER_INFO_5);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1214
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1215 /* Allocate memory for printer enum structure */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1216 ok = EnumPrinters (enum_flags, NULL, enum_level, &dummy_byte, 1,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1217 &bytes_needed, &num_printers);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1218 if (ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1219 /* No printers, if just 1 byte is enough */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1220 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1221
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1222 if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1223 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1224
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
1225 data_buf = (BYTE *) alloca (bytes_needed);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1226 ok = EnumPrinters (enum_flags, NULL, enum_level, data_buf, bytes_needed,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1227 &bytes_needed, &num_printers);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1228 if (!ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1229 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1230
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1231 if (num_printers == 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1232 /* Strange but... */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1233 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1235 GCPRO2 (result, def_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1236
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1237 while (num_printers--)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1238 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1239 LPCTSTR printer_name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1240 if (have_nt)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1241 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1242 PRINTER_INFO_4 *info = (PRINTER_INFO_4*) data_buf;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1243 printer_name = info->pPrinterName;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1244 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1245 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1246 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1247 PRINTER_INFO_5 *info = (PRINTER_INFO_5*) data_buf;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1248 printer_name = info->pPrinterName;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1249 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1250 data_buf += enum_entry_size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1251
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1252 result = Fcons (build_ext_string (printer_name, Qmswindows_tstr),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1253 result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1254 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1255
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1256 def_printer = msprinter_default_printer ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1257 result = Fdelete (def_printer, result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1258 result = Fcons (def_printer, result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1259
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1260 RETURN_UNGCPRO (result);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1261 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1262
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1263
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1264 /************************************************************************/
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 syms_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1271 INIT_LRECORD_IMPLEMENTATION (devmode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1273 DEFSUBR (Fmsprinter_get_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1274 DEFSUBR (Fmsprinter_select_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1275 DEFSUBR (Fmsprinter_apply_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1276 DEFSUBR (Fmsprinter_settings_copy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1277 DEFSUBR (Fmsprinter_settings_despecialize);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1278 DEFSUBR (Fmswindows_get_default_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1279 DEFSUBR (Fmswindows_printer_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1280
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1281 DEFKEYWORD (Q_allow_selection);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1282 DEFKEYWORD (Q_allow_pages);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1283 DEFKEYWORD (Q_selected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1284 DEFSYMBOL (Qselected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1285
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1286 DEFSYMBOL (Qinit_pre_mswindows_win);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1287 DEFSYMBOL (Qinit_post_mswindows_win);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 console_type_create_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 CONSOLE_HAS_METHOD (mswindows, init_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 CONSOLE_HAS_METHOD (mswindows, finish_init_device);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1295 CONSOLE_HAS_METHOD (mswindows, mark_device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 CONSOLE_HAS_METHOD (mswindows, delete_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 CONSOLE_HAS_METHOD (mswindows, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1298 CONSOLE_IMPLEMENTATION_FLAGS (mswindows, XDEVIMPF_PIXEL_GEOMETRY);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1299
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1300 CONSOLE_HAS_METHOD (msprinter, init_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1301 CONSOLE_HAS_METHOD (msprinter, mark_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1302 CONSOLE_HAS_METHOD (msprinter, delete_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1303 CONSOLE_HAS_METHOD (msprinter, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1304 CONSOLE_IMPLEMENTATION_FLAGS (msprinter, (XDEVIMPF_PIXEL_GEOMETRY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1305 | XDEVIMPF_IS_A_PRINTER
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1306 | XDEVIMPF_NO_AUTO_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1307 | XDEVIMPF_DONT_PREEMPT_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1308 | XDEVIMPF_FRAMELESS_OK));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1311
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 vars_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 DEFVAR_LISP ("mswindows-downcase-file-names", &Vmswindows_downcase_file_names /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 Non-nil means convert all-upper case file names to lower case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 This applies when performing completions and file name expansion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 Vmswindows_downcase_file_names = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 DEFVAR_LISP ("mswindows-get-true-file-attributes", &Vmswindows_get_true_file_attributes /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 Non-nil means determine accurate link count in file-attributes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 This option slows down file-attributes noticeably, so is disabled by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 default. Note that it is only useful for files on NTFS volumes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 where hard links are supported.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 Vmswindows_get_true_file_attributes = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 }