annotate src/device-msw.c @ 410:de805c49cfc1 r21-2-35

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