1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
/******************************************************************
Copyright 1998 by Just van Rossum, Den Haag, The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Just van Rossum not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
JUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#include "Python.h"
#include "macglue.h"
#include "pymactoolbox.h"
#include <Printing.h>
static PyObject *ErrorObject;
/* ----------------------------------------------------- */
static int
TPRect_Convert(PyObject *v, TPRect *r)
{
if (v == Py_None) {
*r = NULL;
return 1;
}
return PyArg_Parse(v, "(hhhh)", &(*r)->left, &(*r)->top, &(*r)->right, &(*r)->bottom);
}
static char Pr_NewTPrintRecord__doc__[] =
"creates a new TPrint handle"
;
static PyObject *
Pr_NewTPrintRecord(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
Handle hPrint;
if (!PyArg_ParseTuple(args, ""))
return NULL;
hPrint = NewHandleClear((long) sizeof(TPrint));
if ( hPrint == NULL ) {
PyErr_NoMemory();
return NULL;
}
return (PyObject *)ResObj_New(hPrint);
}
static char Pr_PrPurge__doc__[] =
"PrPurge() -> None"
;
static PyObject *
Pr_PrPurge(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PrPurge();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrNoPurge__doc__[] =
"PrNoPurge() -> None"
;
static PyObject *
Pr_PrNoPurge(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PrNoPurge();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrOpen__doc__[] =
"PrOpen() -> None"
;
static PyObject *
Pr_PrOpen(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PrOpen();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrClose__doc__[] =
"PrClose() -> None"
;
static PyObject *
Pr_PrClose(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
PrClose();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrintDefault__doc__[] =
"PrintDefault(THPrint hPrint) -> None"
;
static PyObject *
Pr_PrintDefault(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
PrintDefault(hPrint);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrValidate__doc__[] =
"PrValidate(THPrint hPrint) -> None"
;
static PyObject *
Pr_PrValidate(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
PrValidate(hPrint);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrStlDialog__doc__[] =
"PrStlDialog(THPrint hPrint) -> Boolean"
;
static PyObject *
Pr_PrStlDialog(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
Boolean rv;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
rv = PrStlDialog(hPrint);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
return Py_BuildValue("h", rv);
}
static char Pr_PrJobDialog__doc__[] =
"PrJobDialog(THPrint hPrint) -> Boolean"
;
static PyObject *
Pr_PrJobDialog(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
Boolean rv;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
rv = PrJobDialog(hPrint);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
return Py_BuildValue("h", rv);
}
static char Pr_PrJobMerge__doc__[] =
"PrJobMerge(THPrint hPrintSrc, THPrint hPrintDst) -> none"
;
static PyObject *
Pr_PrJobMerge(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrintSrc, hPrintDst;
if (!PyArg_ParseTuple(args, "O&O&", ResObj_Convert, &hPrintSrc, ResObj_Convert, &hPrintDst))
return NULL;
PrJobMerge(hPrintSrc, hPrintDst);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrOpenDoc__doc__[] =
"PrOpenDoc(THPrint hPrint) -> TPPrPort aTPPort"
;
static PyObject *
Pr_PrOpenDoc(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
TPPrPort aTPPort;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
aTPPort = PrOpenDoc(hPrint, NULL, NULL);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
return Py_BuildValue("O&", GrafObj_New, aTPPort);
}
static char Pr_PrCloseDoc__doc__[] =
"PrCloseDoc(TPPrPort pPrPort) -> None"
;
static PyObject *
Pr_PrCloseDoc(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
TPPrPort pPrPort;
if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort))
return NULL;
PrCloseDoc(pPrPort);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrOpenPage__doc__[] =
"PrOpenPage(TPPrPort pPrPort, TPRect pPageFrame) -> None"
;
static PyObject *
Pr_PrOpenPage(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
TPPrPort pPrPort;
Rect dummyrect = {0, 0, 0, 0};
TPRect pPageFrame = &dummyrect;
if (!PyArg_ParseTuple(args, "O&O&", GrafObj_Convert, &pPrPort, TPRect_Convert, &pPageFrame))
return NULL;
PrOpenPage(pPrPort, pPageFrame);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrClosePage__doc__[] =
"PrClosePage(TPPrPort pPrPort) -> None"
;
static PyObject *
Pr_PrClosePage(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
TPPrPort pPrPort;
if (!PyArg_ParseTuple(args, "O&", GrafObj_Convert, &pPrPort))
return NULL;
PrClosePage(pPrPort);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrPicFile__doc__[] =
"PrPicFile(THPrint hPrint) -> none"
;
static PyObject *
Pr_PrPicFile(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
THPrint hPrint;
TPrStatus prStatus;
if (!PyArg_ParseTuple(args, "O&", ResObj_Convert, &hPrint))
return NULL;
PrPicFile(hPrint, NULL, NULL, NULL, &prStatus);
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrGeneral__doc__[] =
"not implemented"
;
static PyObject *
Pr_PrGeneral(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
//PrGeneral();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
Py_INCREF(Py_None);
return Py_None;
}
static char Pr_PrDrvrVers__doc__[] =
"PrDrvrVers() -> version"
;
static PyObject *
Pr_PrDrvrVers(self, args)
PyObject *self; /* Not used */
PyObject *args;
{
short rv;
if (!PyArg_ParseTuple(args, ""))
return NULL;
rv = PrDrvrVers();
{
OSErr _err = PrError();
if (_err != noErr) return PyMac_Error(_err);
}
return Py_BuildValue("h", rv);
}
/* List of methods defined in the module */
static struct PyMethodDef Pr_methods[] = {
{"NewTPrintRecord", (PyCFunction)Pr_NewTPrintRecord, METH_VARARGS, Pr_NewTPrintRecord__doc__},
{"PrPurge", (PyCFunction)Pr_PrPurge, METH_VARARGS, Pr_PrPurge__doc__},
{"PrNoPurge", (PyCFunction)Pr_PrNoPurge, METH_VARARGS, Pr_PrNoPurge__doc__},
{"PrOpen", (PyCFunction)Pr_PrOpen, METH_VARARGS, Pr_PrOpen__doc__},
{"PrClose", (PyCFunction)Pr_PrClose, METH_VARARGS, Pr_PrClose__doc__},
{"PrintDefault",(PyCFunction)Pr_PrintDefault, METH_VARARGS, Pr_PrintDefault__doc__},
{"PrValidate", (PyCFunction)Pr_PrValidate, METH_VARARGS, Pr_PrValidate__doc__},
{"PrStlDialog", (PyCFunction)Pr_PrStlDialog, METH_VARARGS, Pr_PrStlDialog__doc__},
{"PrJobDialog", (PyCFunction)Pr_PrJobDialog, METH_VARARGS, Pr_PrJobDialog__doc__},
{"PrJobMerge", (PyCFunction)Pr_PrJobMerge, METH_VARARGS, Pr_PrJobMerge__doc__},
{"PrOpenDoc", (PyCFunction)Pr_PrOpenDoc, METH_VARARGS, Pr_PrOpenDoc__doc__},
{"PrCloseDoc", (PyCFunction)Pr_PrCloseDoc, METH_VARARGS, Pr_PrCloseDoc__doc__},
{"PrOpenPage", (PyCFunction)Pr_PrOpenPage, METH_VARARGS, Pr_PrOpenPage__doc__},
{"PrClosePage", (PyCFunction)Pr_PrClosePage, METH_VARARGS, Pr_PrClosePage__doc__},
{"PrPicFile", (PyCFunction)Pr_PrPicFile, METH_VARARGS, Pr_PrPicFile__doc__},
// {"PrGeneral", (PyCFunction)Pr_PrGeneral, METH_VARARGS, Pr_PrGeneral__doc__},
{"PrDrvrVers", (PyCFunction)Pr_PrDrvrVers, METH_VARARGS, Pr_PrDrvrVers__doc__},
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
};
/* Initialization function for the module (*must* be called initPrinting) */
static char Printing_module_documentation[] =
""
;
void initPrinting();
void
initPrinting()
{
PyObject *m, *d;
/* Create the module and add the functions */
m = Py_InitModule4("Printing", Pr_methods,
Printing_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
ErrorObject = PyString_FromString("Printing.error");
PyDict_SetItemString(d, "error", ErrorObject);
/* XXXX Add constants here */
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module Printing");
}
|