annotate src/device-msw.c @ 5934:e2fae7783046 cygwin

lots of use of EMACS_INT, a few others, to eliminate all pointer truncation warnings
author Henry Thompson <ht@markup.co.uk>
date Sat, 12 Dec 2015 19:08:46 +0000
parents 56144c8593a8
children 574f0cded429
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* device functions for mswindows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
4 Copyright (C) 2000, 2001, 2002, 2010 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5192
diff changeset
8 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5192
diff changeset
10 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5192
diff changeset
11 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5192
diff changeset
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
23 /* This file Mule-ized 8-11-2000. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
24
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 Original authors: Jamie Zawinski and the FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 Rewritten by Ben Wing and Chuck Thompson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
30 Print support added by Kirill Katsnelson, July 2000.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
33 #define NEED_MSWINDOWS_COMMCTRL
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
34 #define NEED_MSWINDOWS_OBJBASE /* for CoInitialize */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
39 #include "device-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
40 #include "events.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
41 #include "faces.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
42 #include "frame.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
43
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
44 #include "console-msw-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #include "console-stream.h"
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
46 #include "fontcolor-msw.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
47
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #include "sysdep.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* win32 DDE management library globals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #ifdef HAVE_DRAGNDROP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 DWORD mswindows_dde_mlid;
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
53 int mswindows_dde_enable;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 HSZ mswindows_dde_service;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 HSZ mswindows_dde_topic_system;
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
56 HSZ mswindows_dde_topic_eval;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
57 HSZ mswindows_dde_item_result;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 HSZ mswindows_dde_item_open;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
61 Lisp_Object Qmake_device_early_mswindows_entry_point,
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
62 Qmake_device_late_mswindows_entry_point;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 Lisp_Object Qdevmodep;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
65 static Lisp_Object Q_allow_selection;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
66 static Lisp_Object Q_allow_pages;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
67 static Lisp_Object Q_selected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
68 static Lisp_Object Qselected_page_button;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
69
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
70 static const struct memory_description mswindows_device_data_description_1 [] = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
71 { XD_LISP_OBJECT, offsetof (struct mswindows_device, fontlist) },
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
72 { XD_END }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
73 };
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
74
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
75 #ifdef NEW_GC
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
76 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("mswindows-device", mswindows_device,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
77 0, mswindows_device_data_description_1,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
78 Lisp_Mswindows_Device);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
79 #else /* not NEW_GC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
80 extern const struct sized_memory_description mswindows_device_data_description;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
81
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
82 const struct sized_memory_description mswindows_device_data_description = {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
83 sizeof (struct mswindows_device), mswindows_device_data_description_1
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
84 };
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
85 #endif /* not NEW_GC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
86
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
87 static const struct memory_description msprinter_device_data_description_1 [] = {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
88 { XD_LISP_OBJECT, offsetof (struct msprinter_device, name) },
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
89 { XD_LISP_OBJECT, offsetof (struct msprinter_device, devmode) },
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
90 { XD_LISP_OBJECT, offsetof (struct msprinter_device, fontlist) },
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
91 { XD_END }
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
92 };
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
93
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
94 #ifdef NEW_GC
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
95 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("msprinter-device", msprinter_device,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
96 0, msprinter_device_data_description_1,
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
97 Lisp_Msprinter_Device);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
98 #else /* not NEW_GC */
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
99 extern const struct sized_memory_description msprinter_device_data_description;
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
100
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
101 const struct sized_memory_description msprinter_device_data_description = {
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
102 sizeof (struct msprinter_device), msprinter_device_data_description_1
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
103 };
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
104 #endif /* not NEW_GC */
1346
01c57eb70ae9 [xemacs-hg @ 2003-03-09 02:27:27 by ben]
ben
parents: 1204
diff changeset
105
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
106 static Lisp_Object allocate_devmode (DEVMODEW *src_devmode, int do_copy,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
107 Lisp_Object src_name, struct device *d);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 /* helpers */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
114 build_syscolor_string (int idx)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116 return (idx < 0 ? Qnil : mswindows_color_to_string (GetSysColor (idx)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 build_syscolor_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 Lisp_Object color1, color2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 GCPRO1 (color1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 color1 = build_syscolor_string (index1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 color2 = build_syscolor_string (index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 RETURN_UNGCPRO (Fcons (color1, color2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 build_sysmetrics_cons (int index1, int index2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
133 return Fcons (index1 < 0 ? Qnil : make_fixnum (GetSystemMetrics (index1)),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
134 index2 < 0 ? Qnil : make_fixnum (GetSystemMetrics (index2)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
137 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
138 build_devicecaps_cons (HDC hdc, int index1, int index2)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
139 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
140 return Fcons (index1 < 0 ? Qnil : make_fixnum (GetDeviceCaps (hdc, index1)),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
141 index2 < 0 ? Qnil : make_fixnum (GetDeviceCaps (hdc, index2)));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
142 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
143
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 /************************************************************************/
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
146 /* display methods */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
150 mswindows_init_device (struct device *d, Lisp_Object UNUSED (props))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 HDC hdc;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
153 WNDCLASSEXW wc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
155 call0 (Qmake_device_early_mswindows_entry_point);
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
156
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 DEVICE_CLASS (d) = Qcolor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 init_baud_rate (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 init_one_device (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
162 #ifdef NEW_GC
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
163 d->device_data = XMSWINDOWS_DEVICE (ALLOC_NORMAL_LISP_OBJECT (mswindows_device));
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
164 #else /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 d->device_data = xnew_and_zero (struct mswindows_device);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
166 #endif /* not NEW_GC */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 hdc = CreateCompatibleDC (NULL);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
168 assert (hdc != NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
169 DEVICE_MSWINDOWS_HCDC (d) = hdc;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
170 DEVICE_MSWINDOWS_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 DEVICE_MSWINDOWS_UPDATE_TICK (d) = GetTickCount ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* Register the main window class */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
174 wc.cbSize = sizeof (wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 wc.style = CS_OWNDC; /* One DC per window */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 wc.lpfnWndProc = (WNDPROC) mswindows_wnd_proc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 wc.cbClsExtra = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 wc.cbWndExtra = MSWINDOWS_WINDOW_EXTRA_BYTES;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 /* This must match whatever is passed to CreateWIndowEx, NULL is ok
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 for this. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
181 wc.hInstance = NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
182 wc.hIcon = qxeLoadIcon (qxeGetModuleHandle (NULL), XETEXT (XEMACS_CLASS));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
183 wc.hCursor = qxeLoadCursor (NULL, IDC_ARROW);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 /* Background brush is only used during sizing, when XEmacs cannot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 take over */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
186 wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 wc.lpszMenuName = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
189 wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CLASS);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
190 wc.hIconSm = (HICON) qxeLoadImage (qxeGetModuleHandle (NULL),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
191 XETEXT (XEMACS_CLASS),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
192 IMAGE_ICON, 16, 16, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
193 qxeRegisterClassEx (&wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 #ifdef HAVE_WIDGETS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 xzero (wc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 /* Register the main window class */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
198 wc.cbSize = sizeof (wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 wc.lpfnWndProc = (WNDPROC) mswindows_control_wnd_proc;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
200 wc.lpszClassName = (XELPTSTR) XETEXT (XEMACS_CONTROL_CLASS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 wc.hInstance = NULL;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
202 qxeRegisterClassEx (&wc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
205 #if defined (HAVE_TOOLBARS) || defined (HAVE_WIDGETS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 InitCommonControls ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
210 #ifdef HAVE_DRAGNDROP
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
212 mswindows_init_dde (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 /* Initialize DDE management library and our related globals. We execute a
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
215 * dde Open ("file") by simulating a drop, so this depends on dnd support. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
216
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 mswindows_dde_mlid = 0;
659
f1a615a0d9e0 [xemacs-hg @ 2001-09-10 19:31:41 by andyp]
andyp
parents: 657
diff changeset
218 mswindows_dde_enable = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
219 qxeDdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
220 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
221 CBF_FAIL_POKES|CBF_SKIP_ALLNOTIFICATIONS,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
222 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
223
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
224 mswindows_dde_service =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
225 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
226 XETEXT (XEMACS_CLASS),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
227 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
228 /* The following strings we Unicode-ize ourselves:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
229 -- SZDDESYS_TOPIC is system-provided
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
230 -- MSWINDOWS_DDE_TOPIC_EVAL is defined by us
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
231 -- MSWINDOWS_DDE_ITEM_RESULT is defined by us
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
232 -- MSWINDOWS_DDE_ITEM_OPEN is used in internal-format comparisons
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
233 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
234 mswindows_dde_topic_system =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
235 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
236 XETEXT (SZDDESYS_TOPIC),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
237 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
238 mswindows_dde_topic_eval =
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
239 qxeDdeCreateStringHandle (mswindows_dde_mlid,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
240 XETEXT (MSWINDOWS_DDE_TOPIC_EVAL),
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
241 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
242 mswindows_dde_item_result =
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
243 qxeDdeCreateStringHandle (mswindows_dde_mlid,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
244 XETEXT (MSWINDOWS_DDE_ITEM_RESULT),
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
245 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
246 mswindows_dde_item_open =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
247 qxeDdeCreateStringHandle (mswindows_dde_mlid,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
248 XETEXT (MSWINDOWS_DDE_ITEM_OPEN),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
249 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
251 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
252 #endif /* HAVE_DRAGNDROP */
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
253
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
254 void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
255 init_mswindows_dde_very_early (void)
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
256 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
257 #if !defined (NO_CYGWIN_COM_SUPPORT)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
258 /* Needed by SHBrowseForFolder, so do it always */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
259 CoInitialize (NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
260 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
261
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
262 #ifdef HAVE_DRAGNDROP
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
263 /* Initializing dde when the device is created is too late - the
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
264 client will give up waiting. Instead we initialize here and tell
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
265 the client we're too busy until the rest of initialization has
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
266 happened. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
267 mswindows_init_dde ();
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
268 #endif
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
269 }
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
270
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
271 static void
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
272 mswindows_finish_init_device (struct device *d,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
273 Lisp_Object UNUSED (props))
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
274 {
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
275 #ifdef HAVE_DRAGNDROP
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
276 /* Tell pending clients we are ready. */
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 647
diff changeset
277 mswindows_dde_enable = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 #endif
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
279 call1 (Qmake_device_late_mswindows_entry_point, wrap_device(d));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 mswindows_delete_device (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 #ifdef HAVE_DRAGNDROP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
286 DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_UNREGISTER);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
287 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_result);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
288 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_item_open);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
289 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_system);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
290 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_topic_eval);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
291 DdeFreeStringHandle (mswindows_dde_mlid, mswindows_dde_service);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 DdeUninitialize (mswindows_dde_mlid);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
294 # if !defined (NO_CYGWIN_COM_SUPPORT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
295 CoUninitialize ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
299 DeleteDC (DEVICE_MSWINDOWS_HCDC (d));
4117
229bd619740a [xemacs-hg @ 2007-08-15 11:06:02 by crestani]
crestani
parents: 3092
diff changeset
300 #ifndef NEW_GC
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
301 xfree (d->device_data);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
302 #endif /* not NEW_GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
303 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 mswindows_get_workspace_coords (RECT *rc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
308 qxeSystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
311 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
312 mswindows_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
313 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
314 mark_object (DEVICE_MSWINDOWS_FONTLIST (d));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
315 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
316
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 mswindows_device_system_metrics (struct device *d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 enum device_metrics m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 const HDC hdc = DEVICE_MSWINDOWS_HCDC(d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 switch (m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 case DM_size_device:
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
326 return Fcons (make_fixnum (GetDeviceCaps (hdc, HORZRES)),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
327 make_fixnum (GetDeviceCaps (hdc, VERTRES)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 break;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
329 case DM_device_dpi:
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
330 return Fcons (make_fixnum (GetDeviceCaps (hdc, LOGPIXELSX)),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
331 make_fixnum (GetDeviceCaps (hdc, LOGPIXELSY)));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
332 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 case DM_size_device_mm:
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
334 return Fcons (make_fixnum (GetDeviceCaps (hdc, HORZSIZE)),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
335 make_fixnum (GetDeviceCaps (hdc, VERTSIZE)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 case DM_num_bit_planes:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 /* this is what X means by bitplanes therefore we ought to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 consistent. num planes is always 1 under mswindows and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 therefore useless */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
341 return make_fixnum (GetDeviceCaps (hdc, BITSPIXEL));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 case DM_num_color_cells:
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
344 /* #### SIZEPALETTE only valid if RC_PALETTE bit set in RASTERCAPS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
345 what should we return for a non-palette-based device? */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
346 return make_fixnum (GetDeviceCaps (hdc, SIZEPALETTE));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 /*** Colors ***/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
350 #define FROB(met, fore, back) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 case DM_##met: \
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352 return build_syscolor_cons (fore, back);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
353
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
354 FROB (color_default, COLOR_WINDOWTEXT, COLOR_WINDOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355 FROB (color_select, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 FROB (color_balloon, COLOR_INFOTEXT, COLOR_INFOBK);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357 FROB (color_3d_face, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
358 FROB (color_3d_light, COLOR_3DHILIGHT, COLOR_3DLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359 FROB (color_3d_dark, COLOR_3DDKSHADOW, COLOR_3DSHADOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 FROB (color_menu, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 FROB (color_menu_highlight, COLOR_HIGHLIGHTTEXT, COLOR_HIGHLIGHT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 FROB (color_menu_button, COLOR_MENUTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 FROB (color_menu_disabled, COLOR_GRAYTEXT, COLOR_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 FROB (color_toolbar, COLOR_BTNTEXT, COLOR_BTNFACE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 FROB (color_scrollbar, COLOR_CAPTIONTEXT, COLOR_SCROLLBAR);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 FROB (color_desktop, -1, COLOR_DESKTOP);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 FROB (color_workspace, -1, COLOR_APPWORKSPACE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 /*** Sizes ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 #define FROB(met, index1, index2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 case DM_##met: \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 return build_sysmetrics_cons (index1, index2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 FROB (size_cursor, SM_CXCURSOR, SM_CYCURSOR);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 FROB (size_scrollbar, SM_CXVSCROLL, SM_CYHSCROLL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 FROB (size_menu, -1, SM_CYMENU);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 FROB (size_icon, SM_CXICON, SM_CYICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 FROB (size_icon_small, SM_CXSMICON, SM_CYSMICON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 case DM_size_workspace:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 RECT rc;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 mswindows_get_workspace_coords (&rc);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
386 return Fcons (make_fixnum (rc.right - rc.left),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
387 make_fixnum (rc.bottom - rc.top));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390 case DM_offset_workspace:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392 RECT rc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393 mswindows_get_workspace_coords (&rc);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
394 return Fcons (make_fixnum (rc.left), make_fixnum (rc.top));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 case DM_size_toolbar:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 case DM_size_toolbar_button:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 case DM_size_toolbar_border:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 /*** Features ***/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 #define FROB(met, index) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 case DM_##met: \
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
406 return make_fixnum (GetSystemMetrics (index));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 FROB (mouse_buttons, SM_CMOUSEBUTTONS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 FROB (swap_buttons, SM_SWAPBUTTON);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 FROB (show_sounds, SM_SHOWSOUNDS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 FROB (slow_device, SM_SLOWMACHINE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 FROB (security, SM_SECURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 #undef FROB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 /* Do not know such property */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
423 /* printer helpers */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
424 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
425
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
426 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
427 signal_open_printer_error (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
428 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
429 invalid_operation ("Failed to open printer", DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
432
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
433 /* Helper function */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
434 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
435 msprinter_init_device_internal (struct device *d, Lisp_Object printer_name)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
437 Extbyte *printer_ext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
438 HDC hdc;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
440 DEVICE_MSPRINTER_NAME (d) = printer_name;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
441
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
442 printer_ext = LISP_STRING_TO_TSTR (printer_name);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
443
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
444 if (!qxeOpenPrinter (printer_ext, &DEVICE_MSPRINTER_HPRINTER (d), NULL))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446 DEVICE_MSPRINTER_HPRINTER (d) = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
450 DEVICE_MSPRINTER_HDC (d) = qxeCreateDC (XETEXT ("WINSPOOL"), printer_ext,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
451 NULL, NULL);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 if (DEVICE_MSPRINTER_HDC (d) == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
455 hdc = CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
456 DEVICE_MSPRINTER_HCDC (d) = hdc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
457 DEVICE_MSPRINTER_FONTLIST (d) = mswindows_enumerate_fonts (hdc);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461 > 1) ? Qcolor : Qmono;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 return 1;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
463 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
464
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
465 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 msprinter_delete_device_internal (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
468 if (DEVICE_MSPRINTER_HPRINTER (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
469 ClosePrinter (DEVICE_MSPRINTER_HPRINTER (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 if (DEVICE_MSPRINTER_HDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 DeleteDC (DEVICE_MSPRINTER_HDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 if (DEVICE_MSPRINTER_HCDC (d))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 DeleteDC (DEVICE_MSPRINTER_HCDC (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
479 msprinter_reinit_device (struct device *d, Lisp_Object devname)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 return msprinter_init_device_internal (d, devname);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 msprinter_default_printer (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488 Extbyte name[666];
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
489 Ibyte *nameint;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
491 if (qxeGetProfileString (XETEXT ("windows"), XETEXT ("device"), NULL, name,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
492 sizeof (name) / XETCHAR_SIZE) <= 0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493 return Qnil;
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
494 nameint = TSTR_TO_ITEXT (name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
495
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
496 if (nameint[0] == '\0')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
497 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
498
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
499 /* this is destructive, but that's ok because the string is either in
851
e7ee5f8bde58 [xemacs-hg @ 2002-05-23 11:46:08 by ben]
ben
parents: 850
diff changeset
500 name[] or ALLOCA ()ed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
501 qxestrtok (nameint, ",");
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
502
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
503 return build_istring (nameint);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
505
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508 /* printer methods */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
512 msprinter_init_device (struct device *d, Lisp_Object UNUSED (props))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
513 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
514 DEVMODEW *pdm;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 593
diff changeset
515 LONG dm_size;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
516 Extbyte *printer_name;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
517
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
518 #ifdef NEW_GC
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
519 d->device_data = XMSPRINTER_DEVICE (ALLOC_NORMAL_LISP_OBJECT (msprinter_device));
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
520 #else /* not NEW_GC */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
521 d->device_data = xnew_and_zero (struct msprinter_device);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
522 #endif /* not NEW_GC */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
523
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
524 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
525 DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
526 DEVICE_MSPRINTER_NAME (d) = Qnil;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
527
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
528 #if 0 /* #### deleted in new ikeyama ws */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
529 /* We do not use printer font list as we do with the display
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
530 device. Rather, we allow GDI to pick the closest match to the
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
531 display font. */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
532 DEVICE_MSPRINTER_FONTLIST (d) = Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
533 #endif /* 0 */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
534
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 CHECK_STRING (DEVICE_CONNECTION (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
536
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
537 if (!msprinter_init_device_internal (d, DEVICE_CONNECTION (d)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
540 printer_name = LISP_STRING_TO_TSTR (DEVICE_CONNECTION (d));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 /* Determine DEVMODE size and store the default DEVMODE */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
542 dm_size = qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
543 printer_name, NULL, NULL, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544 if (dm_size <= 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 signal_open_printer_error (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
547 pdm = (DEVMODEW *) xmalloc (dm_size);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
548 if (qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER(d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
549 printer_name, pdm,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
550 NULL, DM_OUT_BUFFER) < 0)
552
a3adcf42bcec [xemacs-hg @ 2001-05-21 06:19:40 by mta]
mta
parents: 545
diff changeset
551 signal_open_printer_error (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 assert (DEVMODE_SIZE (pdm) <= dm_size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
555 DEVICE_MSPRINTER_DEVMODE (d) =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
556 allocate_devmode (pdm, 0, DEVICE_CONNECTION (d), d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
558
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
559 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 msprinter_delete_device (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
561 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 if (d->device_data)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 msprinter_delete_device_internal (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 /* Disassociate the selected devmode with the device */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
567 if (!NILP (DEVICE_MSPRINTER_DEVMODE (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d))->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572
4117
229bd619740a [xemacs-hg @ 2007-08-15 11:06:02 by crestani]
crestani
parents: 3092
diff changeset
573 #ifndef NEW_GC
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
574 xfree (d->device_data);
5169
6c6d78781d59 cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents: 5146
diff changeset
575 d->device_data = 0;
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
576 #endif /* not NEW_GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
578 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
579
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
580 static Lisp_Object
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
581 msprinter_device_system_metrics (struct device *d,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
582 enum device_metrics m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
583 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
584 switch (m)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
585 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
586 /* Device sizes - pixel and mm */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
587 #define FROB(met, index1, index2) \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
588 case DM_##met: \
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
589 return build_devicecaps_cons \
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
590 (DEVICE_MSPRINTER_HDC (d), index1, index2);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
591
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
592 FROB (size_device, PHYSICALWIDTH, PHYSICALHEIGHT);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
593 FROB (size_device_mm, HORZSIZE, VERTSIZE);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
594 FROB (size_workspace, HORZRES, VERTRES);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
595 FROB (offset_workspace, PHYSICALOFFSETX, PHYSICALOFFSETY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
596 FROB (device_dpi, LOGPIXELSX, LOGPIXELSY);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
597 #undef FROB
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
598
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
599 case DM_num_bit_planes:
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
600 /* this is what X means by bitplanes therefore we ought to be
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
601 consistent. num planes is always 1 under mswindows and
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
602 therefore useless */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
603 return make_fixnum (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
604
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
605 case DM_num_color_cells: /* Printers are non-palette devices */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
606 case DM_slow_device: /* Animation would be a really bad idea */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
607 case DM_security: /* Not provided by windows */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
608 return Qzero;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
609 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
610
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
611 /* Do not know such property */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
612 return Qunbound;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
613 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
614
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
615 static void
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
616 msprinter_mark_device (struct device *d)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
617 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
618 mark_object (DEVICE_MSPRINTER_FONTLIST (d));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 mark_object (DEVICE_MSPRINTER_DEVMODE (d));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
620 mark_object (DEVICE_MSPRINTER_NAME (d));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
621 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
622
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
623
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
624 /************************************************************************/
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 /* printer Lisp subroutines */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
626 /************************************************************************/
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
627
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629 global_free_2_maybe (HGLOBAL hg1, HGLOBAL hg2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 if (hg1 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 GlobalFree (hg1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 if (hg2 != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
634 GlobalFree (hg2);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 static HGLOBAL
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 devmode_to_hglobal (Lisp_Devmode *ldm)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
640 HGLOBAL hg = GlobalAlloc (GHND, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641 memcpy (GlobalLock (hg), ldm->devmode, XDEVMODE_SIZE (ldm));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
642 GlobalUnlock (hg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
643 return hg;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646 /* Returns 0 if the printer has been deleted due to a fatal I/O error,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
647 1 otherwise. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
648 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
649 sync_printer_with_devmode (struct device* d, DEVMODEW* devmode_in,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
650 DEVMODEW* devmode_out, Lisp_Object devname)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
651 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 /* Change connection if the device changed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
653 if (!NILP (devname)
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
654 && lisp_strcasecmp_i18n (devname, DEVICE_MSPRINTER_NAME (d)) != 0)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
656 Lisp_Object new_connection = devname;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 DEVICE_CONNECTION (d) = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 if (!NILP (Ffind_device (new_connection, Qmsprinter)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 /* We are in trouble - second msprinter for the same device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 Nothing wrong on the Windows side, just forge a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663 connection name. Use the memory address of d as a unique
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 suffix. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
665 Ibyte new_connext[20];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
666
5146
88bd4f3ef8e4 make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents: 5142
diff changeset
667 qxesprintf (new_connext, ":%X", LISP_OBJECT_UID (wrap_device (d)));
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
668 new_connection = concat2 (devname, build_istring (new_connext));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 DEVICE_CONNECTION (d) = new_connection;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672 /* Reinitialize printer. The device can pop off in process */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 if (!msprinter_reinit_device (d, devname))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675 /* Kaboom! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676 delete_device_internal (d, 1, 0, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
680 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
681 Extbyte *nameext;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
683 nameext = LISP_STRING_TO_TSTR (DEVICE_MSPRINTER_NAME (d));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
684
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
685 /* Apply the new devmode to the printer */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
686 qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
687 nameext, devmode_out, devmode_in,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
688 DM_IN_BUFFER | DM_OUT_BUFFER);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
689
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
690 /* #### ResetDC fails sometimes, Bill only knows why.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
691 The solution below looks more like a workaround to me,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
692 although it might be fine. --kkm */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
693 if (qxeResetDC (DEVICE_MSPRINTER_HDC (d), devmode_out) == NULL)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
694 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
695 DeleteDC (DEVICE_MSPRINTER_HDC (d));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
696 DEVICE_MSPRINTER_HDC (d) =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
697 qxeCreateDC (XETEXT ("WINSPOOL"), nameext, NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
698 devmode_out);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
699 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
700 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
701
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 handle_devmode_changes (Lisp_Devmode *ldm, HGLOBAL hDevNames, HGLOBAL hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
708 DEVNAMES *devnames = (DEVNAMES *) GlobalLock (hDevNames);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
709 Extbyte *new_name =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
710 devnames ?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
711 (Extbyte *) devnames + XETCHAR_SIZE * devnames->wDeviceOffset : NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
712 DEVMODEW *devmode = (DEVMODEW *) GlobalLock (hDevMode);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 /* Size and name may have changed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
715 ldm->devmode = (DEVMODEW *) xrealloc (ldm->devmode, DEVMODE_SIZE (devmode));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
716 if (new_name)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
717 ldm->printer_name = build_tstr_string (new_name);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
718
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721 /* Apply the new devmode to the printer and get a compete one back */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
722 struct device *d = XDEVICE (ldm->device);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
723 if (!sync_printer_with_devmode (d, devmode, ldm->devmode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
724 new_name ? ldm->printer_name : Qnil))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 global_free_2_maybe (hDevNames, hDevMode);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
727 signal_error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
728 (Qio_error,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
729 "Printer device initialization I/O error, device deleted",
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
730 ldm->device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
731 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
733 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
734 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
735 /* Just copy the devmode structure */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
736 memcpy (ldm->devmode, devmode, DEVMODE_SIZE (devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
737 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
738 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
739
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
740 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
741 ensure_not_printing (struct device *d)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
742 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743 if (!NILP (DEVICE_FRAME_LIST (d)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
745 Lisp_Object device = wrap_device (d);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
746
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
747 invalid_operation ("Cannot change settings while print job is active",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
748 device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
749 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
751
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
752 static Lisp_Devmode *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
753 decode_devmode (Lisp_Object dev)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
754 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
755 if (DEVMODEP (dev))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
756 return XDEVMODE (dev);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
757 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
758 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
759 ensure_not_printing (XDEVICE (dev));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
760 return XDEVMODE (DEVICE_MSPRINTER_DEVMODE (XDEVICE (dev)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
761 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
762 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
763
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
764 /*
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
765 * DEV can be either a printer or devmode
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
766 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
767 static Lisp_Object
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
768 print_dialog_worker (Lisp_Object dev, DWORD flags)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
769 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
770 Lisp_Devmode *ldm = decode_devmode (dev);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
771 PRINTDLGW pd;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
773 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
774 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
775 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
776 pd.hDevMode = devmode_to_hglobal (ldm);
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
777 pd.Flags = flags | PD_USEDEVMODECOPIESANDCOLLATE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
778 pd.nMinPage = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
779 pd.nMaxPage = 0xFFFF;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
780
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
781 if (!qxePrintDlg (&pd))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
782 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
783 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
784 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
785 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
786
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
787 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
788
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
790 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
791 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
792 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
793 GCPRO1 (result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
794
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
795 /* Do consing in reverse order.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
796 Number of copies */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
797 result = Fcons (Qcopies, Fcons (make_fixnum (pd.nCopies), result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
798
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
799 /* Page range */
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
800 if (pd.Flags & PD_PAGENUMS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
801 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
802 result = Fcons (Qto_page, Fcons (make_fixnum (pd.nToPage), result));
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
803 result = Fcons (Qfrom_page, Fcons (make_fixnum (pd.nFromPage), result));
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
804 result = Fcons (Qselected_page_button, Fcons (Qpages, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
805 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
806 else if (pd.Flags & PD_SELECTION)
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
807 result = Fcons (Qselected_page_button, Fcons (Qselection, result));
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
808 else
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
809 result = Fcons (Qselected_page_button, Fcons (Qall, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
810
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
811 /* Device name */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
812 result = Fcons (Qname, Fcons (ldm->printer_name, result));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
813 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
814
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
815 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
816 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
817 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
818 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
819
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
820 Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
821 mswindows_handle_print_dialog_box (struct frame *UNUSED (f), Lisp_Object keys)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
822 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
823 Lisp_Object device = Qunbound, settings = Qunbound;
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
824 DWORD flags = PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
825
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
826 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
827 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
828 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
829 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
830 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
831 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
832 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
833 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
834 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
835 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
836 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
837 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
838 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
839 else if (EQ (key, Q_allow_pages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
840 {
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
841 if (NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
842 flags |= PD_NOPAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
843 }
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
844 else if (EQ (key, Q_allow_selection))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
845 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
846 if (!NILP (value))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
847 flags &= ~PD_NOSELECTION;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
848 }
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
849 else if (EQ (key, Q_selected_page_button))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
850 {
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
851 if (EQ (value, Qselection))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
852 flags |= PD_SELECTION;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
853 else if (EQ (value, Qpages))
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
854 flags |= PD_PAGENUMS;
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
855 else if (!EQ (value, Qall))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
856 invalid_constant ("for :selected-page-button", value);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
857 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
858 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
859 invalid_constant ("Unrecognized print-dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
860 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
861 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
862
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
863 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
864 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
865 sferror ("Exactly one of :device and :printer-settings must be given",
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
866 keys);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
868 return print_dialog_worker (!UNBOUNDP (device) ? device : settings, flags);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
870
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
871 int
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
872 mswindows_get_default_margin (Lisp_Object prop)
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
873 {
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
874 if (EQ (prop, Qleft_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
875 if (EQ (prop, Qright_margin)) return 1440;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
876 if (EQ (prop, Qtop_margin)) return 720;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
877 if (EQ (prop, Qbottom_margin)) return 720;
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
878 ABORT ();
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
879 return 0;
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
880 }
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
881
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
882 static int
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
883 plist_get_margin (Lisp_Object plist, Lisp_Object prop, int mm_p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
884 {
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 446
diff changeset
885 Lisp_Object val =
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
886 Fplist_get (plist, prop, make_fixnum (mswindows_get_default_margin (prop)));
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
887 if (!FIXNUMP (val))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
888 invalid_argument ("Margin value must be an integer", val);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
889
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
890 return MulDiv (XFIXNUM (val), mm_p ? 254 : 100, 144);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
891 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
892
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893 static Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
894 plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
895 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
896 Lisp_Object val = make_fixnum (MulDiv (margin, 144, mm_p ? 254 : 100));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
897 return Fcons (prop, Fcons (val, plist));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
898 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
899
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
900 Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
901 mswindows_handle_page_setup_dialog_box (struct frame *UNUSED (f),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
902 Lisp_Object keys)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
903 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 Lisp_Object device = Qunbound, settings = Qunbound;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
905 Lisp_Object plist = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
906
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
907 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908 EXTERNAL_PROPERTY_LIST_LOOP_3 (key, value, keys)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 if (EQ (key, Q_device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
911 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
912 device = wrap_device (decode_device (value));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
913 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
914 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915 else if (EQ (key, Q_printer_settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
916 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
917 CHECK_DEVMODE (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
918 settings = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
919 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
920 else if (EQ (key, Q_properties))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
921 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 CHECK_LIST (value);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
923 plist = value;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
925 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
926 invalid_constant ("Unrecognized page-setup dialog keyword", key);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
927 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
928 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
929
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
930 if ((UNBOUNDP (device) && UNBOUNDP (settings)) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
931 (!UNBOUNDP (device) && !UNBOUNDP (settings)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
932 sferror ("Exactly one of :device and :printer-settings must be given",
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
933 keys);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
934
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
935 if (UNBOUNDP (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
936 device = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
937
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
938 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
939 Lisp_Devmode *ldm = decode_devmode (device);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
940 PAGESETUPDLGW pd;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
941 Extbyte measure[2 * MAX_XETCHAR_SIZE];
850
f915ad7befaf [xemacs-hg @ 2002-05-21 23:47:38 by jhar]
jhar
parents: 826
diff changeset
942 int data;
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
943
850
f915ad7befaf [xemacs-hg @ 2002-05-21 23:47:38 by jhar]
jhar
parents: 826
diff changeset
944 qxeGetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IMEASURE,
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
945 measure, sizeof (measure) / XETCHAR_SIZE);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
946 data = qxetcscmp (measure, XETEXT ("0"));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
947
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
948 memset (&pd, 0, sizeof (pd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
949 pd.lStructSize = sizeof (pd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
950 pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
951 pd.Flags = PSD_MARGINS;
798
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
952 pd.rtMargin.left = plist_get_margin (plist, Qleft_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
953 pd.rtMargin.top = plist_get_margin (plist, Qtop_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
954 pd.rtMargin.right = plist_get_margin (plist, Qright_margin, !data);
1f5108485fe7 [xemacs-hg @ 2002-03-29 18:26:33 by jhar]
jhar
parents: 793
diff changeset
955 pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin, !data);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
956 pd.hDevMode = devmode_to_hglobal (ldm);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
957
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
958 if (!qxePageSetupDlg (&pd))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
960 global_free_2_maybe (pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
961 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
962 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
963
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
964 if (pd.hDevMode)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
965 handle_devmode_changes (ldm, pd.hDevNames, pd.hDevMode);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
966
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
967 /* Finally, build the resulting plist */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
968 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
969 Lisp_Object result = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
970 int mm_p = pd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
971 result = plist_set_margin (result, Qbottom_margin, pd.rtMargin.bottom,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
972 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
973 result = plist_set_margin (result, Qright_margin, pd.rtMargin.right,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
974 mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
975 result = plist_set_margin (result, Qtop_margin, pd.rtMargin.top, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
976 result = plist_set_margin (result, Qleft_margin, pd.rtMargin.left, mm_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
977 return result;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
978 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
979 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
980 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
981
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
982 DEFUN ("msprinter-get-settings", Fmsprinter_get_settings, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983 Return the settings object currently used by DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
984 The object returned is not a copy, but rather a pointer to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
985 original one. Use `msprinter-settings-copy' to create a copy of it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
986 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
987 (device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
988 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
989 struct device *d = decode_device (device);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
990 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
991 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
992 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
993 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
994
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
995 DEFUN ("msprinter-select-settings", Fmsprinter_select_settings, 2, 2, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
996 Select SETTINGS object into a DEVICE.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
997 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
998 printer, possibly changing even the target printer itself, and all
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
999 future changes are applied synchronously to the printer device and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1000 selected printer object, until a different settings object is selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1001 into the same printer.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1002
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1003 A settings object can be selected to no more than one printer at a time.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1004
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1005 If the supplied settings object is not specialized, it is specialized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1006 for the printer immediately upon selection. The object can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1007 despecialized after it is unselected by calling the function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1008 `msprinter-settings-despecialize'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1009
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1010 Return value is the previously selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1011 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1012 (device, settings))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1013 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1014 Lisp_Devmode *ldm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1015 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1016
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1017 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1018 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1019
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1020 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1021 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1022 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1023 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1024
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1025 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1026 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1027 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1028
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1029 /* If the object being selected is de-specialized, then its
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1030 size is perhaps not enough to receive the new devmode. We can ask
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1031 for printer's devmode size here, because despecialized settings
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 cannot force switching to a different printer, as they supply no
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 printer name at all. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1034 if (NILP (ldm->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1035 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1036 Extbyte *nameext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1037 LONG dm_size;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1038
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
1039 nameext = LISP_STRING_TO_TSTR (DEVICE_MSPRINTER_NAME (d));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1040 dm_size = qxeDocumentProperties (NULL, DEVICE_MSPRINTER_HPRINTER (d),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1041 nameext, NULL, NULL, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1042 if (dm_size <= 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1043 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1044 "Unable to specialize settings, printer error",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1045 device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1047 assert (XDEVMODE_SIZE (ldm) <= dm_size);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1048 ldm->devmode = (DEVMODEW *) xrealloc (ldm->devmode, dm_size);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1049 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1050
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1051 /* If we bail out on signal here, no damage is done, except that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1052 the storage for the DEVMODE structure might be reallocated to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1053 hold a larger one - not a big deal */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1054 if (!sync_printer_with_devmode (d, ldm->devmode, ldm->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1055 ldm->printer_name))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1056 signal_error (Qio_error,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 552
diff changeset
1057 "Printer device initialization I/O error, device deleted",
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1058 device);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1059
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1060 if (NILP (ldm->printer_name ))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1061 ldm->printer_name = DEVICE_MSPRINTER_NAME (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1062
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1063 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1064 Lisp_Object old_mode = DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1065 ldm->device = device;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1066 XDEVMODE (old_mode)->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1067 DEVICE_MSPRINTER_DEVMODE (d) = settings;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1068 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1069 return old_mode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1070 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1071 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1072
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1073 DEFUN ("msprinter-apply-settings", Fmsprinter_apply_settings, 2, 2, 0, /*
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 3017
diff changeset
1074 Apply settings from a SETTINGS object to a `msprinter' DEVICE.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1075 The settings from the settings object are immediately applied to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1076 printer, possibly changing even the target printer itself. The SETTING
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1077 object is not modified, unlike `msprinter-select-settings', and the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1078 supplied object is not changed. The changes are immediately recorded
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1079 into the settings object which is currently selected into the printer
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1080 device.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1081
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1082 Return value is the currently selected settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1083 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1084 (device, settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1085 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1086 Lisp_Devmode *ldm_current, *ldm_new;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1087 struct device *d = decode_device (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1088
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1089 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1090 GCPRO1 (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1091
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1092 device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1093 CHECK_MSPRINTER_DEVICE (device);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1094 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1095 ldm_new = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1096 ldm_current = XDEVMODE (DEVICE_MSPRINTER_DEVMODE (d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1097
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1098 /* If the supplied devmode is not specialized, then the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1099 devmode size will always be sufficient, as the printer does
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1100 not change. If it is specialized, we must reallocate the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1101 devmode storage to match with the supplied one, as it has the right
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1102 size for the new printer, if it is going to change. The correct
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1103 way is to use the largest of the two though, to keep the old
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1104 contents unchanged in case of preliminary exit.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1105 */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1106 if (!NILP (ldm_new->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1107 ldm_current->devmode =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1108 (DEVMODEW*) xrealloc (ldm_current->devmode,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1109 max (XDEVMODE_SIZE (ldm_new),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1110 XDEVMODE_SIZE (ldm_current)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1111
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1112 if (!sync_printer_with_devmode (d, ldm_new->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1113 ldm_current->devmode,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1114 ldm_new->printer_name))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1115 signal_error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1116 (Qio_error,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1117 "Printer device initialization I/O error, device deleted", device);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1118
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1119 if (!NILP (ldm_new->printer_name))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1120 ldm_current->printer_name = ldm_new->printer_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1121
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 442
diff changeset
1122 UNGCPRO;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1123 return DEVICE_MSPRINTER_DEVMODE (d);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1124 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1125
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1126 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1127 /* devmode */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1128 /************************************************************************/
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1129
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 964
diff changeset
1130 static const struct memory_description devmode_description[] = {
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1131 { XD_LISP_OBJECT, offsetof (struct Lisp_Devmode, printer_name) },
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 934
diff changeset
1132 { XD_LISP_OBJECT, offsetof (struct Lisp_Devmode, device) },
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1133 { XD_END }
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1134 };
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1135
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1136 static Lisp_Object
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1137 mark_devmode (Lisp_Object obj)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1138 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1139 Lisp_Devmode *data = XDEVMODE (obj);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1140 mark_object (data->printer_name);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1141 return data->device;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1142 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1143
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1144 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1145 print_devmode (Lisp_Object obj, Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1146 int UNUSED (escapeflag))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1147 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1148 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1149 if (print_readably)
5142
f965e31a35f0 reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents: 5127
diff changeset
1150 printing_unreadable_lisp_object (obj, 0);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
1151 write_ascstring (printcharfun, "#<msprinter-settings");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1152 if (!NILP (dm->printer_name))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
1153 write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1154 if (!NILP (dm->device))
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 798
diff changeset
1155 write_fmt_string_lisp (printcharfun, " (currently on %s)", 1, dm->device);
5146
88bd4f3ef8e4 make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents: 5142
diff changeset
1156 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1157 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1158
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1159 static void
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
1160 finalize_devmode (Lisp_Object obj)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1161 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
1162 Lisp_Devmode *dm = XDEVMODE (obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1163
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1164 assert (NILP (dm->device));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1165 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1166
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1167 static int
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
1168 equal_devmode (Lisp_Object obj1, Lisp_Object obj2, int UNUSED (depth),
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
1169 int UNUSED (foldcase))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1170 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1171 Lisp_Devmode *dm1 = XDEVMODE (obj1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1172 Lisp_Devmode *dm2 = XDEVMODE (obj2);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1173
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1174 if ((dm1->devmode != NULL) != (dm1->devmode != NULL))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1175 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1176 if (dm1->devmode == NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1177 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178 if (memcmp (dm1->devmode, dm2->devmode, XDEVMODE_SIZE (dm1)) != 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1179 return 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1180 if (NILP (dm1->printer_name) || NILP (dm2->printer_name))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1181 return 1;
4906
6ef8256a020a implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents: 4846
diff changeset
1182 return lisp_strcasecmp_i18n (dm1->printer_name, dm2->printer_name) == 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1183 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1184
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 659
diff changeset
1185 static Hashcode
5192
635f4b506855 Call internal_hash() with its new arg, Win32-specific code, fixing build
Aidan Kehoe <kehoea@parhasard.net>
parents: 5178
diff changeset
1186 hash_devmode (Lisp_Object obj, int depth, Boolint UNUSED (equalp))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1187 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1188 Lisp_Devmode *dm = XDEVMODE (obj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1189
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1190 return HASH3 (XDEVMODE_SIZE (dm),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1191 dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1192 : 0,
5192
635f4b506855 Call internal_hash() with its new arg, Win32-specific code, fixing build
Aidan Kehoe <kehoea@parhasard.net>
parents: 5178
diff changeset
1193 internal_hash (dm->printer_name, depth + 1, 0));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1194 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1195
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
1196 DEFINE_NODUMP_LISP_OBJECT ("msprinter-settings", devmode,
5124
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
1197 mark_devmode, print_devmode,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
1198 finalize_devmode,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
1199 equal_devmode, hash_devmode,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
1200 devmode_description,
623d57b7fbe8 separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents: 5120
diff changeset
1201 Lisp_Devmode);
934
c925bacdda60 [xemacs-hg @ 2002-07-29 09:21:12 by michaels]
michaels
parents: 903
diff changeset
1202
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1203 static Lisp_Object
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1204 allocate_devmode (DEVMODEW* src_devmode, int do_copy,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1205 Lisp_Object src_name, struct device *d)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1206 {
5127
a9c41067dd88 more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents: 5125
diff changeset
1207 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (devmode);
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
1208 Lisp_Devmode *dm = XDEVMODE (obj);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1209
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1210 if (d)
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1211 dm->device = wrap_device (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1212 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1213 dm->device = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1214
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1215 dm->printer_name = src_name;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1216
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1217 if (src_devmode != NULL && do_copy)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1218 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1219 dm->devmode = (DEVMODEW*) xmalloc (DEVMODE_SIZE (src_devmode));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1220 memcpy (dm->devmode, src_devmode, DEVMODE_SIZE (src_devmode));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1221 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1222 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1223 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1224 dm->devmode = src_devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1225 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1226
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
1227 return obj;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1228 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1229
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1230 DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1231 Create and returns an exact copy of a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1232 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1233 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1234 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1235 Lisp_Devmode *dm;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1236
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1237 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1238 dm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1239
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1240 return allocate_devmode (dm->devmode, 1, dm->printer_name, NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1241 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1242
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1243 DEFUN ("msprinter-settings-despecialize", Fmsprinter_settings_despecialize, 1, 1, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1244 Erase printer-specific settings from a printer settings object.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1245 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1246 (settings))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1247 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1248 Lisp_Devmode *ldm;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1249 DEVMODEW *dm;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1250
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1251 CHECK_DEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1252 ldm = XDEVMODE (settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1253
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1254 if (!NILP (ldm->device))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1255 invalid_operation ("The object is currently selected into a device",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1256 settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1257
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1258 dm = ldm->devmode;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1259
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1260 /* #### TODO. Either remove references to device specific bins,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1261 paper sizes etc, or signal an error of they are present. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1262
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1263 dm->dmDriverExtra = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1264 dm->dmDeviceName[0] = '\0';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1265
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1266 ldm->printer_name = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1267
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1268 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1269 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1270
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1271 DEFUN ("mswindows-get-default-printer", Fmswindows_get_default_printer, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1272 Return name of the default printer, as string, on nil if there is no default.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1273 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1274 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1275 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1276 return msprinter_default_printer ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1277 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1278
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1279 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1280 signal_enum_printer_error (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1281 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5468
diff changeset
1282 invalid_operation ("Error enumerating printers", make_fixnum (GetLastError ()));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1283 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1284
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1285 DEFUN ("mswindows-printer-list", Fmswindows_printer_list, 0, 0, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1286 Return a list of string names of installed printers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1287 If there is a default printer, it is returned as the first element of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1288 the list. If there is no default printer, the first element of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1289 list will be nil. The rest of elements are guaranteed to have string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1290 values. Return value is nil if there are no printers installed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1291 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292 ())
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1293 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1294 int have_nt, ok;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1295 BYTE *data_buf, dummy_byte;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 659
diff changeset
1296 Bytecount enum_entry_size;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1297 DWORD enum_flags, enum_level, bytes_needed, num_printers;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1298 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1299 Lisp_Object result = Qnil, def_printer = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1300
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1301 /* Determine OS flavor, to use the fastest enumeration method available */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1302 have_nt = !mswindows_windows9x_p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1303 enum_flags = PRINTER_ENUM_LOCAL | (have_nt ? PRINTER_ENUM_CONNECTIONS : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1304 enum_level = have_nt ? 4 : 5;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1305 enum_entry_size = (have_nt ? sizeof (PRINTER_INFO_4) :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1306 sizeof (PRINTER_INFO_5));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1307
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1308 /* Allocate memory for printer enum structure */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1309 ok = qxeEnumPrinters (enum_flags, NULL, enum_level, &dummy_byte, 1,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1310 &bytes_needed, &num_printers);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1311 if (ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1312 /* No printers, if just 1 byte is enough */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1313 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1314
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1315 if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1316 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
1318 data_buf = alloca_array (BYTE, bytes_needed);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1319 ok = qxeEnumPrinters (enum_flags, NULL, enum_level, data_buf, bytes_needed,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1320 &bytes_needed, &num_printers);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1321 if (!ok)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1322 signal_enum_printer_error ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1323
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1324 if (num_printers == 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1325 /* Strange but... */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1326 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1327
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1328 GCPRO2 (result, def_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1329
5338
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1330 def_printer = msprinter_default_printer ();
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1331
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1332 while (num_printers--)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1333 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1334 Extbyte *printer_name;
5338
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1335 Lisp_Object printer_name_lisp;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 if (have_nt)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1338 PRINTER_INFO_4 *info = (PRINTER_INFO_4 *) data_buf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1339 printer_name = (Extbyte *) info->pPrinterName;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1341 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1342 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1343 PRINTER_INFO_5 *info = (PRINTER_INFO_5 *) data_buf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1344 printer_name = (Extbyte *) info->pPrinterName;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1345 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1346 data_buf += enum_entry_size;
5338
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1347
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1348 printer_name_lisp = build_tstr_string (printer_name);
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1349 if (0 != qxestrcasecmp (XSTRING_DATA (def_printer),
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1350 XSTRING_DATA (printer_name_lisp)))
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1351 {
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1352 result = Fcons (printer_name_lisp, result);
8608eadee6ba Move #'delq, #'delete to Lisp, adding support for sequences.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5192
diff changeset
1353 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1354 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1355
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1356 result = Fcons (def_printer, result);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1357
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1358 RETURN_UNGCPRO (result);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1359 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1360
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1361
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1362 /************************************************************************/
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 syms_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 {
5117
3742ea8250b5 Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents: 3025
diff changeset
1369 INIT_LISP_OBJECT (devmode);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1370
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
1371 #ifdef NEW_GC
5118
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
1372 INIT_LISP_OBJECT (mswindows_device);
e0db3c197671 merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents: 5117 4477
diff changeset
1373 INIT_LISP_OBJECT (msprinter_device);
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
1374 #endif /* NEW_GC */
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
1375
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1376 DEFSUBR (Fmsprinter_get_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1377 DEFSUBR (Fmsprinter_select_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1378 DEFSUBR (Fmsprinter_apply_settings);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1379 DEFSUBR (Fmsprinter_settings_copy);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1380 DEFSUBR (Fmsprinter_settings_despecialize);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1381 DEFSUBR (Fmswindows_get_default_printer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1382 DEFSUBR (Fmswindows_printer_list);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1383
510
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1384 DEFKEYWORD (Q_allow_selection);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1385 DEFKEYWORD (Q_allow_pages);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1386 DEFKEYWORD (Q_selected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1387 DEFSYMBOL (Qselected_page_button);
5bdbc721d46a [xemacs-hg @ 2001-05-06 08:33:35 by ben]
ben
parents: 506
diff changeset
1388
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
1389 DEFSYMBOL (Qmake_device_early_mswindows_entry_point);
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4117
diff changeset
1390 DEFSYMBOL ( Qmake_device_late_mswindows_entry_point);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 console_type_create_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 CONSOLE_HAS_METHOD (mswindows, init_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 CONSOLE_HAS_METHOD (mswindows, finish_init_device);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1398 CONSOLE_HAS_METHOD (mswindows, mark_device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 CONSOLE_HAS_METHOD (mswindows, delete_device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 CONSOLE_HAS_METHOD (mswindows, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1401 CONSOLE_IMPLEMENTATION_FLAGS (mswindows, XDEVIMPF_PIXEL_GEOMETRY);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1402
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1403 CONSOLE_HAS_METHOD (msprinter, init_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1404 CONSOLE_HAS_METHOD (msprinter, mark_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1405 CONSOLE_HAS_METHOD (msprinter, delete_device);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1406 CONSOLE_HAS_METHOD (msprinter, device_system_metrics);
545
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1407 CONSOLE_IMPLEMENTATION_FLAGS (msprinter, (XDEVIMPF_PIXEL_GEOMETRY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1408 | XDEVIMPF_IS_A_PRINTER
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1409 | XDEVIMPF_NO_AUTO_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1410 | XDEVIMPF_DONT_PREEMPT_REDISPLAY
9a775fb11bb7 [xemacs-hg @ 2001-05-18 04:39:39 by kkm]
kkm
parents: 510
diff changeset
1411 | XDEVIMPF_FRAMELESS_OK));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1414
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 vars_of_device_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 }