1 /******************************************************************
2 Copyright 1998 by Just van Rossum, Den Haag, The Netherlands.
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted,
8 provided that the above copyright notice appear in all copies and that
9 both that copyright notice and this permission notice appear in
10 supporting documentation, and that the name of Just van Rossum not be
11 used in advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
14 JUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 EVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 PERFORMANCE OF THIS SOFTWARE.
22 ******************************************************************/
26 #include "pymactoolbox.h"
29 static PyObject
*ErrorObject
;
31 /* ----------------------------------------------------- */
34 TPRect_Convert(PyObject
*v
, TPRect
*r
)
40 return PyArg_Parse(v
, "(hhhh)", &(*r
)->left
, &(*r
)->top
, &(*r
)->right
, &(*r
)->bottom
);
44 static char Pr_NewTPrintRecord__doc__
[] =
45 "creates a new TPrint handle"
49 Pr_NewTPrintRecord(self
, args
)
50 PyObject
*self
; /* Not used */
55 if (!PyArg_ParseTuple(args
, ""))
57 hPrint
= NewHandleClear((long) sizeof(TPrint
));
58 if ( hPrint
== NULL
) {
62 return (PyObject
*)ResObj_New(hPrint
);
65 static char Pr_PrPurge__doc__
[] =
70 Pr_PrPurge(self
, args
)
71 PyObject
*self
; /* Not used */
75 if (!PyArg_ParseTuple(args
, ""))
79 OSErr _err
= PrError();
80 if (_err
!= noErr
) return PyMac_Error(_err
);
86 static char Pr_PrNoPurge__doc__
[] =
91 Pr_PrNoPurge(self
, args
)
92 PyObject
*self
; /* Not used */
96 if (!PyArg_ParseTuple(args
, ""))
100 OSErr _err
= PrError();
101 if (_err
!= noErr
) return PyMac_Error(_err
);
107 static char Pr_PrOpen__doc__
[] =
112 Pr_PrOpen(self
, args
)
113 PyObject
*self
; /* Not used */
117 if (!PyArg_ParseTuple(args
, ""))
121 OSErr _err
= PrError();
122 if (_err
!= noErr
) return PyMac_Error(_err
);
128 static char Pr_PrClose__doc__
[] =
133 Pr_PrClose(self
, args
)
134 PyObject
*self
; /* Not used */
138 if (!PyArg_ParseTuple(args
, ""))
142 OSErr _err
= PrError();
143 if (_err
!= noErr
) return PyMac_Error(_err
);
149 static char Pr_PrintDefault__doc__
[] =
150 "PrintDefault(THPrint hPrint) -> None"
154 Pr_PrintDefault(self
, args
)
155 PyObject
*self
; /* Not used */
160 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
162 PrintDefault(hPrint
);
164 OSErr _err
= PrError();
165 if (_err
!= noErr
) return PyMac_Error(_err
);
171 static char Pr_PrValidate__doc__
[] =
172 "PrValidate(THPrint hPrint) -> None"
176 Pr_PrValidate(self
, args
)
177 PyObject
*self
; /* Not used */
182 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
186 OSErr _err
= PrError();
187 if (_err
!= noErr
) return PyMac_Error(_err
);
193 static char Pr_PrStlDialog__doc__
[] =
194 "PrStlDialog(THPrint hPrint) -> Boolean"
198 Pr_PrStlDialog(self
, args
)
199 PyObject
*self
; /* Not used */
205 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
207 rv
= PrStlDialog(hPrint
);
209 OSErr _err
= PrError();
210 if (_err
!= noErr
) return PyMac_Error(_err
);
212 return Py_BuildValue("h", rv
);
215 static char Pr_PrJobDialog__doc__
[] =
216 "PrJobDialog(THPrint hPrint) -> Boolean"
220 Pr_PrJobDialog(self
, args
)
221 PyObject
*self
; /* Not used */
227 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
229 rv
= PrJobDialog(hPrint
);
231 OSErr _err
= PrError();
232 if (_err
!= noErr
) return PyMac_Error(_err
);
234 return Py_BuildValue("h", rv
);
237 static char Pr_PrJobMerge__doc__
[] =
238 "PrJobMerge(THPrint hPrintSrc, THPrint hPrintDst) -> none"
242 Pr_PrJobMerge(self
, args
)
243 PyObject
*self
; /* Not used */
246 THPrint hPrintSrc
, hPrintDst
;
248 if (!PyArg_ParseTuple(args
, "O&O&", ResObj_Convert
, &hPrintSrc
, ResObj_Convert
, &hPrintDst
))
250 PrJobMerge(hPrintSrc
, hPrintDst
);
252 OSErr _err
= PrError();
253 if (_err
!= noErr
) return PyMac_Error(_err
);
259 static char Pr_PrOpenDoc__doc__
[] =
260 "PrOpenDoc(THPrint hPrint) -> TPPrPort aTPPort"
264 Pr_PrOpenDoc(self
, args
)
265 PyObject
*self
; /* Not used */
271 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
273 aTPPort
= PrOpenDoc(hPrint
, NULL
, NULL
);
275 OSErr _err
= PrError();
276 if (_err
!= noErr
) return PyMac_Error(_err
);
278 return Py_BuildValue("O&", GrafObj_New
, aTPPort
);
281 static char Pr_PrCloseDoc__doc__
[] =
282 "PrCloseDoc(TPPrPort pPrPort) -> None"
286 Pr_PrCloseDoc(self
, args
)
287 PyObject
*self
; /* Not used */
292 if (!PyArg_ParseTuple(args
, "O&", GrafObj_Convert
, &pPrPort
))
296 OSErr _err
= PrError();
297 if (_err
!= noErr
) return PyMac_Error(_err
);
303 static char Pr_PrOpenPage__doc__
[] =
304 "PrOpenPage(TPPrPort pPrPort, TPRect pPageFrame) -> None"
308 Pr_PrOpenPage(self
, args
)
309 PyObject
*self
; /* Not used */
313 Rect dummyrect
= {0, 0, 0, 0};
314 TPRect pPageFrame
= &dummyrect
;
316 if (!PyArg_ParseTuple(args
, "O&O&", GrafObj_Convert
, &pPrPort
, TPRect_Convert
, &pPageFrame
))
318 PrOpenPage(pPrPort
, pPageFrame
);
320 OSErr _err
= PrError();
321 if (_err
!= noErr
) return PyMac_Error(_err
);
327 static char Pr_PrClosePage__doc__
[] =
328 "PrClosePage(TPPrPort pPrPort) -> None"
332 Pr_PrClosePage(self
, args
)
333 PyObject
*self
; /* Not used */
338 if (!PyArg_ParseTuple(args
, "O&", GrafObj_Convert
, &pPrPort
))
340 PrClosePage(pPrPort
);
342 OSErr _err
= PrError();
343 if (_err
!= noErr
) return PyMac_Error(_err
);
349 static char Pr_PrPicFile__doc__
[] =
350 "PrPicFile(THPrint hPrint) -> none"
354 Pr_PrPicFile(self
, args
)
355 PyObject
*self
; /* Not used */
361 if (!PyArg_ParseTuple(args
, "O&", ResObj_Convert
, &hPrint
))
363 PrPicFile(hPrint
, NULL
, NULL
, NULL
, &prStatus
);
365 OSErr _err
= PrError();
366 if (_err
!= noErr
) return PyMac_Error(_err
);
372 static char Pr_PrGeneral__doc__
[] =
377 Pr_PrGeneral(self
, args
)
378 PyObject
*self
; /* Not used */
382 if (!PyArg_ParseTuple(args
, ""))
386 OSErr _err
= PrError();
387 if (_err
!= noErr
) return PyMac_Error(_err
);
393 static char Pr_PrDrvrVers__doc__
[] =
394 "PrDrvrVers() -> version"
398 Pr_PrDrvrVers(self
, args
)
399 PyObject
*self
; /* Not used */
404 if (!PyArg_ParseTuple(args
, ""))
408 OSErr _err
= PrError();
409 if (_err
!= noErr
) return PyMac_Error(_err
);
411 return Py_BuildValue("h", rv
);
414 /* List of methods defined in the module */
416 static struct PyMethodDef Pr_methods
[] = {
417 {"NewTPrintRecord", (PyCFunction
)Pr_NewTPrintRecord
, METH_VARARGS
, Pr_NewTPrintRecord__doc__
},
418 {"PrPurge", (PyCFunction
)Pr_PrPurge
, METH_VARARGS
, Pr_PrPurge__doc__
},
419 {"PrNoPurge", (PyCFunction
)Pr_PrNoPurge
, METH_VARARGS
, Pr_PrNoPurge__doc__
},
420 {"PrOpen", (PyCFunction
)Pr_PrOpen
, METH_VARARGS
, Pr_PrOpen__doc__
},
421 {"PrClose", (PyCFunction
)Pr_PrClose
, METH_VARARGS
, Pr_PrClose__doc__
},
422 {"PrintDefault",(PyCFunction
)Pr_PrintDefault
, METH_VARARGS
, Pr_PrintDefault__doc__
},
423 {"PrValidate", (PyCFunction
)Pr_PrValidate
, METH_VARARGS
, Pr_PrValidate__doc__
},
424 {"PrStlDialog", (PyCFunction
)Pr_PrStlDialog
, METH_VARARGS
, Pr_PrStlDialog__doc__
},
425 {"PrJobDialog", (PyCFunction
)Pr_PrJobDialog
, METH_VARARGS
, Pr_PrJobDialog__doc__
},
426 {"PrJobMerge", (PyCFunction
)Pr_PrJobMerge
, METH_VARARGS
, Pr_PrJobMerge__doc__
},
427 {"PrOpenDoc", (PyCFunction
)Pr_PrOpenDoc
, METH_VARARGS
, Pr_PrOpenDoc__doc__
},
428 {"PrCloseDoc", (PyCFunction
)Pr_PrCloseDoc
, METH_VARARGS
, Pr_PrCloseDoc__doc__
},
429 {"PrOpenPage", (PyCFunction
)Pr_PrOpenPage
, METH_VARARGS
, Pr_PrOpenPage__doc__
},
430 {"PrClosePage", (PyCFunction
)Pr_PrClosePage
, METH_VARARGS
, Pr_PrClosePage__doc__
},
431 {"PrPicFile", (PyCFunction
)Pr_PrPicFile
, METH_VARARGS
, Pr_PrPicFile__doc__
},
432 // {"PrGeneral", (PyCFunction)Pr_PrGeneral, METH_VARARGS, Pr_PrGeneral__doc__},
433 {"PrDrvrVers", (PyCFunction
)Pr_PrDrvrVers
, METH_VARARGS
, Pr_PrDrvrVers__doc__
},
435 {NULL
, (PyCFunction
)NULL
, 0, NULL
} /* sentinel */
439 /* Initialization function for the module (*must* be called initPrinting) */
441 static char Printing_module_documentation
[] =
452 /* Create the module and add the functions */
453 m
= Py_InitModule4("Printing", Pr_methods
,
454 Printing_module_documentation
,
455 (PyObject
*)NULL
,PYTHON_API_VERSION
);
457 /* Add some symbolic constants to the module */
458 d
= PyModule_GetDict(m
);
459 ErrorObject
= PyString_FromString("Printing.error");
460 PyDict_SetItemString(d
, "error", ErrorObject
);
462 /* XXXX Add constants here */