Mercurial > hg > xemacs-beta
comparison src/device-msw.c @ 5178:97eb4942aec8
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 29 Mar 2010 21:28:13 -0500 |
parents | 8b2f75cecb89 6c6d78781d59 |
children | 635f4b506855 |
comparison
equal
deleted
inserted
replaced
5177:b785049378e3 | 5178:97eb4942aec8 |
---|---|
1 /* device functions for mswindows. | 1 /* device functions for mswindows. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
4 Copyright (C) 2000, 2001, 2002 Ben Wing. | 4 Copyright (C) 2000, 2001, 2002, 2010 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
73 { XD_LISP_OBJECT, offsetof (struct mswindows_device, fontlist) }, | 73 { XD_LISP_OBJECT, offsetof (struct mswindows_device, fontlist) }, |
74 { XD_END } | 74 { XD_END } |
75 }; | 75 }; |
76 | 76 |
77 #ifdef NEW_GC | 77 #ifdef NEW_GC |
78 DEFINE_LRECORD_IMPLEMENTATION ("mswindows-device", mswindows_device, | 78 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("mswindows-device", mswindows_device, |
79 1, /*dumpable-flag*/ | 79 0, mswindows_device_data_description_1, |
80 0, 0, 0, 0, 0, | 80 Lisp_Mswindows_Device); |
81 mswindows_device_data_description_1, | |
82 Lisp_Mswindows_Device); | |
83 #else /* not NEW_GC */ | 81 #else /* not NEW_GC */ |
84 extern const struct sized_memory_description mswindows_device_data_description; | 82 extern const struct sized_memory_description mswindows_device_data_description; |
85 | 83 |
86 const struct sized_memory_description mswindows_device_data_description = { | 84 const struct sized_memory_description mswindows_device_data_description = { |
87 sizeof (struct mswindows_device), mswindows_device_data_description_1 | 85 sizeof (struct mswindows_device), mswindows_device_data_description_1 |
94 { XD_LISP_OBJECT, offsetof (struct msprinter_device, fontlist) }, | 92 { XD_LISP_OBJECT, offsetof (struct msprinter_device, fontlist) }, |
95 { XD_END } | 93 { XD_END } |
96 }; | 94 }; |
97 | 95 |
98 #ifdef NEW_GC | 96 #ifdef NEW_GC |
99 DEFINE_LRECORD_IMPLEMENTATION ("msprinter-device", msprinter_device, | 97 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("msprinter-device", msprinter_device, |
100 1, /*dumpable-flag*/ | 98 0, msprinter_device_data_description_1, |
101 0, 0, 0, 0, 0, | 99 Lisp_Msprinter_Device); |
102 msprinter_device_data_description_1, | |
103 Lisp_Msprinter_Device); | |
104 #else /* not NEW_GC */ | 100 #else /* not NEW_GC */ |
105 extern const struct sized_memory_description msprinter_device_data_description; | 101 extern const struct sized_memory_description msprinter_device_data_description; |
106 | 102 |
107 const struct sized_memory_description msprinter_device_data_description = { | 103 const struct sized_memory_description msprinter_device_data_description = { |
108 sizeof (struct msprinter_device), msprinter_device_data_description_1 | 104 sizeof (struct msprinter_device), msprinter_device_data_description_1 |
164 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; | 160 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; |
165 init_baud_rate (d); | 161 init_baud_rate (d); |
166 init_one_device (d); | 162 init_one_device (d); |
167 | 163 |
168 #ifdef NEW_GC | 164 #ifdef NEW_GC |
169 d->device_data = alloc_lrecord_type (struct mswindows_device, | 165 d->device_data = XMSWINDOWS_DEVICE (ALLOC_NORMAL_LISP_OBJECT (mswindows_device)); |
170 &lrecord_mswindows_device); | |
171 #else /* not NEW_GC */ | 166 #else /* not NEW_GC */ |
172 d->device_data = xnew_and_zero (struct mswindows_device); | 167 d->device_data = xnew_and_zero (struct mswindows_device); |
173 #endif /* not NEW_GC */ | 168 #endif /* not NEW_GC */ |
174 hdc = CreateCompatibleDC (NULL); | 169 hdc = CreateCompatibleDC (NULL); |
175 assert (hdc != NULL); | 170 assert (hdc != NULL); |
521 DEVMODEW *pdm; | 516 DEVMODEW *pdm; |
522 LONG dm_size; | 517 LONG dm_size; |
523 Extbyte *printer_name; | 518 Extbyte *printer_name; |
524 | 519 |
525 #ifdef NEW_GC | 520 #ifdef NEW_GC |
526 d->device_data = alloc_lrecord_type (struct msprinter_device, | 521 d->device_data = XMSPRINTER_DEVICE (ALLOC_NORMAL_LISP_OBJECT (msprinter_device)); |
527 &lrecord_msprinter_device); | |
528 #else /* not NEW_GC */ | 522 #else /* not NEW_GC */ |
529 d->device_data = xnew_and_zero (struct msprinter_device); | 523 d->device_data = xnew_and_zero (struct msprinter_device); |
530 #endif /* not NEW_GC */ | 524 #endif /* not NEW_GC */ |
531 | 525 |
532 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; | 526 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; |
578 DEVICE_MSPRINTER_DEVMODE (d) = Qnil; | 572 DEVICE_MSPRINTER_DEVMODE (d) = Qnil; |
579 } | 573 } |
580 | 574 |
581 #ifndef NEW_GC | 575 #ifndef NEW_GC |
582 xfree (d->device_data); | 576 xfree (d->device_data); |
577 d->device_data = 0; | |
583 #endif /* not NEW_GC */ | 578 #endif /* not NEW_GC */ |
584 } | 579 } |
585 } | 580 } |
586 | 581 |
587 static Lisp_Object | 582 static Lisp_Object |
669 Nothing wrong on the Windows side, just forge a unique | 664 Nothing wrong on the Windows side, just forge a unique |
670 connection name. Use the memory address of d as a unique | 665 connection name. Use the memory address of d as a unique |
671 suffix. */ | 666 suffix. */ |
672 Ibyte new_connext[20]; | 667 Ibyte new_connext[20]; |
673 | 668 |
674 qxesprintf (new_connext, ":%X", d->header.uid); | 669 qxesprintf (new_connext, ":%X", LISP_OBJECT_UID (wrap_device (d))); |
675 new_connection = concat2 (devname, build_istring (new_connext)); | 670 new_connection = concat2 (devname, build_istring (new_connext)); |
676 } | 671 } |
677 DEVICE_CONNECTION (d) = new_connection; | 672 DEVICE_CONNECTION (d) = new_connection; |
678 | 673 |
679 /* Reinitialize printer. The device can pop off in process */ | 674 /* Reinitialize printer. The device can pop off in process */ |
1152 print_devmode (Lisp_Object obj, Lisp_Object printcharfun, | 1147 print_devmode (Lisp_Object obj, Lisp_Object printcharfun, |
1153 int UNUSED (escapeflag)) | 1148 int UNUSED (escapeflag)) |
1154 { | 1149 { |
1155 Lisp_Devmode *dm = XDEVMODE (obj); | 1150 Lisp_Devmode *dm = XDEVMODE (obj); |
1156 if (print_readably) | 1151 if (print_readably) |
1157 printing_unreadable_lcrecord (obj, 0); | 1152 printing_unreadable_lisp_object (obj, 0); |
1158 write_ascstring (printcharfun, "#<msprinter-settings"); | 1153 write_ascstring (printcharfun, "#<msprinter-settings"); |
1159 if (!NILP (dm->printer_name)) | 1154 if (!NILP (dm->printer_name)) |
1160 write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name); | 1155 write_fmt_string_lisp (printcharfun, " for %S", 1, dm->printer_name); |
1161 if (!NILP (dm->device)) | 1156 if (!NILP (dm->device)) |
1162 write_fmt_string_lisp (printcharfun, " (currently on %s)", 1, dm->device); | 1157 write_fmt_string_lisp (printcharfun, " (currently on %s)", 1, dm->device); |
1163 write_fmt_string (printcharfun, " 0x%x>", dm->header.uid); | 1158 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); |
1164 } | 1159 } |
1165 | 1160 |
1166 static void | 1161 static void |
1167 finalize_devmode (void *header, int for_disksave) | 1162 finalize_devmode (Lisp_Object obj) |
1168 { | 1163 { |
1169 Lisp_Devmode *dm = (Lisp_Devmode *) header; | 1164 Lisp_Devmode *dm = XDEVMODE (obj); |
1170 | |
1171 if (for_disksave) | |
1172 { | |
1173 Lisp_Object devmode = wrap_devmode (dm); | |
1174 | |
1175 invalid_operation | |
1176 ("Cannot dump XEmacs containing an msprinter-settings object", | |
1177 devmode); | |
1178 } | |
1179 | 1165 |
1180 assert (NILP (dm->device)); | 1166 assert (NILP (dm->device)); |
1181 } | 1167 } |
1182 | 1168 |
1183 static int | 1169 static int |
1207 dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm)) | 1193 dm->devmode ? memory_hash (dm->devmode, XDEVMODE_SIZE (dm)) |
1208 : 0, | 1194 : 0, |
1209 internal_hash (dm->printer_name, depth + 1)); | 1195 internal_hash (dm->printer_name, depth + 1)); |
1210 } | 1196 } |
1211 | 1197 |
1212 DEFINE_LRECORD_IMPLEMENTATION ("msprinter-settings", devmode, | 1198 DEFINE_NODUMP_LISP_OBJECT ("msprinter-settings", devmode, |
1213 0, /*dumpable-flag*/ | 1199 mark_devmode, print_devmode, |
1214 mark_devmode, print_devmode, finalize_devmode, | 1200 finalize_devmode, |
1215 equal_devmode, hash_devmode, | 1201 equal_devmode, hash_devmode, |
1216 devmode_description, | 1202 devmode_description, |
1217 Lisp_Devmode); | 1203 Lisp_Devmode); |
1218 | 1204 |
1219 static Lisp_Object | 1205 static Lisp_Object |
1220 allocate_devmode (DEVMODEW* src_devmode, int do_copy, | 1206 allocate_devmode (DEVMODEW* src_devmode, int do_copy, |
1221 Lisp_Object src_name, struct device *d) | 1207 Lisp_Object src_name, struct device *d) |
1222 { | 1208 { |
1223 Lisp_Devmode *dm; | 1209 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (devmode); |
1224 | 1210 Lisp_Devmode *dm = XDEVMODE (obj); |
1225 dm = ALLOC_LCRECORD_TYPE (Lisp_Devmode, &lrecord_devmode); | |
1226 | 1211 |
1227 if (d) | 1212 if (d) |
1228 dm->device = wrap_device (d); | 1213 dm->device = wrap_device (d); |
1229 else | 1214 else |
1230 dm->device = Qnil; | 1215 dm->device = Qnil; |
1239 else | 1224 else |
1240 { | 1225 { |
1241 dm->devmode = src_devmode; | 1226 dm->devmode = src_devmode; |
1242 } | 1227 } |
1243 | 1228 |
1244 return wrap_devmode (dm); | 1229 return obj; |
1245 } | 1230 } |
1246 | 1231 |
1247 DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /* | 1232 DEFUN ("msprinter-settings-copy", Fmsprinter_settings_copy, 1, 1, 0, /* |
1248 Create and returns an exact copy of a printer settings object. | 1233 Create and returns an exact copy of a printer settings object. |
1249 */ | 1234 */ |
1375 /************************************************************************/ | 1360 /************************************************************************/ |
1376 | 1361 |
1377 void | 1362 void |
1378 syms_of_device_mswindows (void) | 1363 syms_of_device_mswindows (void) |
1379 { | 1364 { |
1380 INIT_LRECORD_IMPLEMENTATION (devmode); | 1365 INIT_LISP_OBJECT (devmode); |
1381 | 1366 |
1382 #ifdef NEW_GC | 1367 #ifdef NEW_GC |
1383 INIT_LRECORD_IMPLEMENTATION (mswindows_device); | 1368 INIT_LISP_OBJECT (mswindows_device); |
1384 INIT_LRECORD_IMPLEMENTATION (msprinter_device); | 1369 INIT_LISP_OBJECT (msprinter_device); |
1385 #endif /* NEW_GC */ | 1370 #endif /* NEW_GC */ |
1386 | 1371 |
1387 DEFSUBR (Fmsprinter_get_settings); | 1372 DEFSUBR (Fmsprinter_get_settings); |
1388 DEFSUBR (Fmsprinter_select_settings); | 1373 DEFSUBR (Fmsprinter_select_settings); |
1389 DEFSUBR (Fmsprinter_apply_settings); | 1374 DEFSUBR (Fmsprinter_apply_settings); |