diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1998-04-21 15:23:02 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1998-04-21 15:23:02 (GMT) |
commit | 02facaf90a39b0f2d3dafbca2ef17c8e8c678b10 (patch) | |
tree | afc5d658fdabf850997203a31519ea176d52b1f7 /Mac | |
parent | 4e126636a2dcc1014b3928ccd8ded204e8631924 (diff) | |
download | cpython-02facaf90a39b0f2d3dafbca2ef17c8e8c678b10.zip cpython-02facaf90a39b0f2d3dafbca2ef17c8e8c678b10.tar.gz cpython-02facaf90a39b0f2d3dafbca2ef17c8e8c678b10.tar.bz2 |
Added ColorPicker and Printing modules, donated by Just. In config.c
they're dependent on the WITH_TOOLBOX define.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Modules/ColorPickermodule.c | 92 | ||||
-rw-r--r-- | Mac/Modules/Printingmodule.c | 474 | ||||
-rw-r--r-- | Mac/Modules/config.c | 4 |
3 files changed, 570 insertions, 0 deletions
diff --git a/Mac/Modules/ColorPickermodule.c b/Mac/Modules/ColorPickermodule.c new file mode 100644 index 0000000..5101d25 --- /dev/null +++ b/Mac/Modules/ColorPickermodule.c @@ -0,0 +1,92 @@ +/****************************************************************** +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 <ColorPicker.h> +#include "Python.h" + + +/* ----------------------------------------------------- */ + +extern QdRGB_Convert(PyObject *v, RGBColorPtr p_itself); +extern PyObject *QdRGB_New(RGBColorPtr itself); + +static char cp_GetColor__doc__[] = +"GetColor(prompt, (r, g, b)) -> (r, g, b), ok" +; + +static PyObject * +cp_GetColor(self, args) + PyObject *self; /* Not used */ + PyObject *args; +{ + RGBColor inColor, outColor; + Boolean ok; + Point where = {0, 0}; + char * prompt; + Str255 pprompt; + + if (!PyArg_ParseTuple(args, "sO&", &prompt, QdRGB_Convert, &inColor)) + return NULL; + + BlockMove(prompt, pprompt + 1, strlen(prompt)); + pprompt[0] = strlen(prompt); + + ok = GetColor(where, pprompt, &inColor, &outColor); + + return Py_BuildValue("O&h", QdRGB_New, &outColor, ok); +} + +/* List of methods defined in the module */ + +static struct PyMethodDef cp_methods[] = { + {"GetColor", (PyCFunction)cp_GetColor, METH_VARARGS, cp_GetColor__doc__}, + {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ +}; + + +/* Initialization function for the module (*must* be called initColorPicker) */ + +static char cp_module_documentation[] = +"" +; + +void initColorPicker(); + +void initColorPicker() +{ + PyObject *m; + + /* Create the module and add the functions */ + m = Py_InitModule4("ColorPicker", cp_methods, + cp_module_documentation, + (PyObject*)NULL,PYTHON_API_VERSION); + + /* Add symbolic constants to the module here */ + + /* XXXX Add constants here */ + + /* Check for errors */ + if (PyErr_Occurred()) + Py_FatalError("can't initialize module ColorPicker"); +} + diff --git a/Mac/Modules/Printingmodule.c b/Mac/Modules/Printingmodule.c new file mode 100644 index 0000000..e4cac9b --- /dev/null +++ b/Mac/Modules/Printingmodule.c @@ -0,0 +1,474 @@ +/****************************************************************** +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 <Printing.h> + +extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *DlgObj_New(DialogPtr); +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); +extern PyObject *ResObj_New(Handle); + + +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"); +} + diff --git a/Mac/Modules/config.c b/Mac/Modules/config.c index d18148a..7beb909 100644 --- a/Mac/Modules/config.c +++ b/Mac/Modules/config.c @@ -111,6 +111,8 @@ extern void initSndihooks(); extern void initScrap(); extern void initTE(); extern void initWin(); +extern void initColorPicker(); +extern void initPrinting(); #endif #ifdef USE_QT extern void initCm(); @@ -219,6 +221,8 @@ struct _inittab _PyImport_Inittab[] = { {"TE", initTE}, {"Win", initWin}, {"Res", initRes}, + {"ColorPicker", initColorPicker}, + {"Printing", initPrinting}, #endif #ifdef USE_QT {"Cm", initCm}, |