Home | History | Annotate | Download | only in Modules
      1 /******************************************************************
      2 Copyright 1998 by Just van Rossum, Den Haag, The Netherlands.
      3 
      4                         All Rights Reserved
      5 
      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.
     13 
     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.
     21 
     22 ******************************************************************/
     23 
     24 #include <Carbon/Carbon.h>
     25 #include "Python.h"
     26 #include "pymactoolbox.h"
     27 
     28 /* ----------------------------------------------------- */
     29 
     30 
     31 #if APPLE_SUPPORTS_QUICKTIME
     32 
     33 static char cp_GetColor__doc__[] =
     34 "GetColor(prompt, (r, g, b)) -> (r, g, b), ok"
     35 ;
     36 
     37 static PyObject *
     38 cp_GetColor(PyObject *self, PyObject *args)
     39 {
     40     RGBColor inColor, outColor;
     41     Boolean ok;
     42     Point where = {0, 0};
     43     Str255 prompt;
     44 
     45     if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetStr255, prompt, QdRGB_Convert, &inColor))
     46         return NULL;
     47 
     48     ok = GetColor(where, prompt, &inColor, &outColor);
     49 
     50     return Py_BuildValue("O&h", QdRGB_New, &outColor, ok);
     51 }
     52 #endif /* APPLE_SUPPORTS_QUICKTIME */
     53 
     54 /* List of methods defined in the module */
     55 
     56 static struct PyMethodDef cp_methods[] = {
     57 #if APPLE_SUPPORTS_QUICKTIME
     58     {"GetColor",        (PyCFunction)cp_GetColor,       METH_VARARGS,   cp_GetColor__doc__},
     59 #endif /* APPLE_SUPPORTS_QUICKTIME */
     60     {NULL,                      (PyCFunction)NULL,                      0,                              NULL}           /* sentinel */
     61 };
     62 
     63 
     64 /* Initialization function for the module (*must* be called initColorPicker) */
     65 
     66 static char cp_module_documentation[] =
     67 ""
     68 ;
     69 
     70 void initColorPicker(void)
     71 {
     72     PyObject *m;
     73 
     74     if (PyErr_WarnPy3k("In 3.x, the ColorPicker module is removed.", 1) < 0)
     75         return;
     76 
     77     /* Create the module and add the functions */
     78     m = Py_InitModule4("ColorPicker", cp_methods,
     79         cp_module_documentation,
     80         (PyObject*)NULL,PYTHON_API_VERSION);
     81 
     82     /* Add symbolic constants to the module here */
     83 
     84     /* XXXX Add constants here */
     85 
     86     /* Check for errors */
     87     if (PyErr_Occurred())
     88         Py_FatalError("can't initialize module ColorPicker");
     89 }
     90