PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Mac/Modules/ColorPickermodule.c

http://unladen-swallow.googlecode.com/
C | 90 lines | 40 code | 21 blank | 29 comment | 3 complexity | 2c905d213c50b4cb72f6586be119cdfd MD5 | raw file
 1/******************************************************************
 2Copyright 1998 by Just van Rossum, Den Haag, The Netherlands.
 3
 4                        All Rights Reserved
 5
 6Permission to use, copy, modify, and distribute this software and its
 7documentation for any purpose and without fee is hereby granted,
 8provided that the above copyright notice appear in all copies and that
 9both that copyright notice and this permission notice appear in
10supporting documentation, and that the name of Just van Rossum not be 
11used in advertising or publicity pertaining to distribution of the 
12software without specific, written prior permission.
13
14JUST VAN ROSSUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
15INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 
16EVENT SHALL JUST VAN ROSSUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR 
17CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 
18USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 
19OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20PERFORMANCE OF THIS SOFTWARE.
21
22******************************************************************/
23
24#include <Carbon/Carbon.h>
25#include "Python.h"
26#include "pymactoolbox.h"
27
28/* ----------------------------------------------------- */
29
30
31#ifndef __LP64__
32
33static char cp_GetColor__doc__[] =
34"GetColor(prompt, (r, g, b)) -> (r, g, b), ok"
35;
36
37static PyObject *
38cp_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 /* __LP64__ */
53
54/* List of methods defined in the module */
55
56static struct PyMethodDef cp_methods[] = {
57#ifndef __LP64__
58	{"GetColor",	(PyCFunction)cp_GetColor,	METH_VARARGS,	cp_GetColor__doc__},
59#endif /* __LP64__ */
60	{NULL,	 		(PyCFunction)NULL, 			0, 				NULL}		/* sentinel */
61};
62
63
64/* Initialization function for the module (*must* be called initColorPicker) */
65
66static char cp_module_documentation[] = 
67""
68;
69
70void initColorPicker(void)
71{
72	PyObject *m;
73	
74	if (PyErr_WarnPy3k("In 3.x, ColorPicker 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