2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
/* ========================= Module _Qdoffs ========================= */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-18 11:39:38 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "pywintoolbox.h"
|
|
|
|
#else
|
2001-08-23 11:02:09 -03:00
|
|
|
#include "macglue.h"
|
|
|
|
#include "pymactoolbox.h"
|
2001-12-18 11:39:38 -04:00
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
/* Macro to test whether a weak-loaded CFM function exists */
|
|
|
|
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError, \
|
|
|
|
"Not available in this shared library/OS version"); \
|
|
|
|
return NULL; \
|
|
|
|
}} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITHOUT_FRAMEWORKS
|
|
|
|
#include <QDOffscreen.h>
|
|
|
|
#else
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_TOOLBOX_OBJECT_GLUE
|
|
|
|
extern PyObject *_GWorldObj_New(GWorldPtr);
|
|
|
|
extern int _GWorldObj_Convert(PyObject *, GWorldPtr *);
|
|
|
|
|
|
|
|
#define GWorldObj_New _GWorldObj_New
|
|
|
|
#define GWorldObj_Convert _GWorldObj_Convert
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define as_GrafPtr(gworld) ((GrafPtr)(gworld))
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_Error;
|
|
|
|
|
|
|
|
/* ----------------------- Object type GWorld ----------------------- */
|
|
|
|
|
|
|
|
PyTypeObject GWorld_Type;
|
|
|
|
|
|
|
|
#define GWorldObj_Check(x) ((x)->ob_type == &GWorld_Type)
|
|
|
|
|
|
|
|
typedef struct GWorldObject {
|
|
|
|
PyObject_HEAD
|
|
|
|
GWorldPtr ob_itself;
|
|
|
|
} GWorldObject;
|
|
|
|
|
|
|
|
PyObject *GWorldObj_New(GWorldPtr itself)
|
|
|
|
{
|
|
|
|
GWorldObject *it;
|
|
|
|
if (itself == NULL) return PyMac_Error(resNotFound);
|
|
|
|
it = PyObject_NEW(GWorldObject, &GWorld_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
2001-09-04 19:19:18 -03:00
|
|
|
int GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
|
|
|
if (!GWorldObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "GWorld required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((GWorldObject *)v)->ob_itself;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GWorldObj_dealloc(GWorldObject *self)
|
|
|
|
{
|
|
|
|
DisposeGWorld(self->ob_itself);
|
2002-04-23 19:46:01 -03:00
|
|
|
PyObject_Del(self);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GDHandle _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetGWorldDevice
|
|
|
|
PyMac_PRECHECK(GetGWorldDevice);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetGWorldDevice(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *GWorldObj_GetGWorldPixMap(GWorldObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetGWorldPixMap
|
|
|
|
PyMac_PRECHECK(GetGWorldPixMap);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetGWorldPixMap(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *GWorldObj_as_GrafPtr(GWorldObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GrafPtr _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef as_GrafPtr
|
|
|
|
PyMac_PRECHECK(as_GrafPtr);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = as_GrafPtr(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
GrafObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef GWorldObj_methods[] = {
|
|
|
|
{"GetGWorldDevice", (PyCFunction)GWorldObj_GetGWorldDevice, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (GDHandle _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetGWorldPixMap", (PyCFunction)GWorldObj_GetGWorldPixMap, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (PixMapHandle _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"as_GrafPtr", (PyCFunction)GWorldObj_as_GrafPtr, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (GrafPtr _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
2002-11-29 19:40:48 -04:00
|
|
|
#define GWorldObj_getsetlist NULL
|
2001-08-23 11:02:09 -03:00
|
|
|
|
2002-12-03 19:40:22 -04:00
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
#define GWorldObj_compare NULL
|
|
|
|
|
|
|
|
#define GWorldObj_repr NULL
|
|
|
|
|
|
|
|
#define GWorldObj_hash NULL
|
2002-12-03 19:40:22 -04:00
|
|
|
#define GWorldObj_tp_init 0
|
|
|
|
|
|
|
|
#define GWorldObj_tp_alloc PyType_GenericAlloc
|
|
|
|
|
|
|
|
static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
|
|
|
PyObject *self;
|
|
|
|
GWorldPtr itself;
|
|
|
|
char *kw[] = {"itself", 0};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL;
|
|
|
|
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
|
|
|
|
((GWorldObject *)self)->ob_itself = itself;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GWorldObj_tp_free PyObject_Del
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
PyTypeObject GWorld_Type = {
|
2001-11-30 10:16:36 -04:00
|
|
|
PyObject_HEAD_INIT(NULL)
|
2001-08-23 11:02:09 -03:00
|
|
|
0, /*ob_size*/
|
2001-12-08 14:02:58 -04:00
|
|
|
"_Qdoffs.GWorld", /*tp_name*/
|
2001-08-23 11:02:09 -03:00
|
|
|
sizeof(GWorldObject), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor) GWorldObj_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
2002-11-29 19:40:48 -04:00
|
|
|
(getattrfunc)0, /*tp_getattr*/
|
|
|
|
(setattrfunc)0, /*tp_setattr*/
|
2001-08-23 11:02:09 -03:00
|
|
|
(cmpfunc) GWorldObj_compare, /*tp_compare*/
|
|
|
|
(reprfunc) GWorldObj_repr, /*tp_repr*/
|
|
|
|
(PyNumberMethods *)0, /* tp_as_number */
|
|
|
|
(PySequenceMethods *)0, /* tp_as_sequence */
|
|
|
|
(PyMappingMethods *)0, /* tp_as_mapping */
|
|
|
|
(hashfunc) GWorldObj_hash, /*tp_hash*/
|
2002-11-29 19:40:48 -04:00
|
|
|
0, /*tp_call*/
|
|
|
|
0, /*tp_str*/
|
|
|
|
PyObject_GenericGetAttr, /*tp_getattro*/
|
|
|
|
PyObject_GenericSetAttr, /*tp_setattro */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_as_buffer*/
|
|
|
|
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
|
|
|
|
0, /*tp_doc*/
|
|
|
|
0, /*tp_traverse*/
|
|
|
|
0, /*tp_clear*/
|
|
|
|
0, /*tp_richcompare*/
|
|
|
|
0, /*tp_weaklistoffset*/
|
|
|
|
0, /*tp_iter*/
|
|
|
|
0, /*tp_iternext*/
|
2002-11-29 19:40:48 -04:00
|
|
|
GWorldObj_methods, /* tp_methods */
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_members*/
|
2002-11-29 19:40:48 -04:00
|
|
|
GWorldObj_getsetlist, /*tp_getset*/
|
2002-12-03 19:40:22 -04:00
|
|
|
0, /*tp_base*/
|
|
|
|
0, /*tp_dict*/
|
|
|
|
0, /*tp_descr_get*/
|
|
|
|
0, /*tp_descr_set*/
|
|
|
|
0, /*tp_dictoffset*/
|
|
|
|
GWorldObj_tp_init, /* tp_init */
|
|
|
|
GWorldObj_tp_alloc, /* tp_alloc */
|
|
|
|
GWorldObj_tp_new, /* tp_new */
|
|
|
|
GWorldObj_tp_free, /* tp_free */
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* --------------------- End object type GWorld --------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_NewGWorld(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
QDErr _err;
|
|
|
|
GWorldPtr offscreenGWorld;
|
|
|
|
short PixelDepth;
|
|
|
|
Rect boundsRect;
|
|
|
|
CTabHandle cTable;
|
|
|
|
GDHandle aGDevice;
|
|
|
|
GWorldFlags flags;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef NewGWorld
|
|
|
|
PyMac_PRECHECK(NewGWorld);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO&O&O&l",
|
|
|
|
&PixelDepth,
|
|
|
|
PyMac_GetRect, &boundsRect,
|
|
|
|
OptResObj_Convert, &cTable,
|
|
|
|
OptResObj_Convert, &aGDevice,
|
|
|
|
&flags))
|
|
|
|
return NULL;
|
|
|
|
_err = NewGWorld(&offscreenGWorld,
|
|
|
|
PixelDepth,
|
|
|
|
&boundsRect,
|
|
|
|
cTable,
|
|
|
|
aGDevice,
|
|
|
|
flags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
GWorldObj_New, offscreenGWorld);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_LockPixels(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef LockPixels
|
|
|
|
PyMac_PRECHECK(LockPixels);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
_rv = LockPixels(pm);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_UnlockPixels(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef UnlockPixels
|
|
|
|
PyMac_PRECHECK(UnlockPixels);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
UnlockPixels(pm);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_UpdateGWorld(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GWorldFlags _rv;
|
|
|
|
GWorldPtr offscreenGWorld;
|
|
|
|
short pixelDepth;
|
|
|
|
Rect boundsRect;
|
|
|
|
CTabHandle cTable;
|
|
|
|
GDHandle aGDevice;
|
|
|
|
GWorldFlags flags;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef UpdateGWorld
|
|
|
|
PyMac_PRECHECK(UpdateGWorld);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO&O&O&l",
|
|
|
|
&pixelDepth,
|
|
|
|
PyMac_GetRect, &boundsRect,
|
|
|
|
OptResObj_Convert, &cTable,
|
|
|
|
OptResObj_Convert, &aGDevice,
|
|
|
|
&flags))
|
|
|
|
return NULL;
|
|
|
|
_rv = UpdateGWorld(&offscreenGWorld,
|
|
|
|
pixelDepth,
|
|
|
|
&boundsRect,
|
|
|
|
cTable,
|
|
|
|
aGDevice,
|
|
|
|
flags);
|
|
|
|
_res = Py_BuildValue("lO&",
|
|
|
|
_rv,
|
|
|
|
GWorldObj_New, offscreenGWorld);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_GetGWorld(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
CGrafPtr port;
|
|
|
|
GDHandle gdh;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetGWorld
|
|
|
|
PyMac_PRECHECK(GetGWorld);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
GetGWorld(&port,
|
|
|
|
&gdh);
|
|
|
|
_res = Py_BuildValue("O&O&",
|
|
|
|
GrafObj_New, port,
|
|
|
|
ResObj_New, gdh);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_SetGWorld(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
CGrafPtr port;
|
|
|
|
GDHandle gdh;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetGWorld
|
|
|
|
PyMac_PRECHECK(SetGWorld);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
GrafObj_Convert, &port,
|
|
|
|
OptResObj_Convert, &gdh))
|
|
|
|
return NULL;
|
|
|
|
SetGWorld(port,
|
|
|
|
gdh);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_CTabChanged(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
CTabHandle ctab;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef CTabChanged
|
|
|
|
PyMac_PRECHECK(CTabChanged);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
OptResObj_Convert, &ctab))
|
|
|
|
return NULL;
|
|
|
|
CTabChanged(ctab);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_PixPatChanged(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixPatHandle ppat;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef PixPatChanged
|
|
|
|
PyMac_PRECHECK(PixPatChanged);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &ppat))
|
|
|
|
return NULL;
|
|
|
|
PixPatChanged(ppat);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_PortChanged(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GrafPtr port;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef PortChanged
|
|
|
|
PyMac_PRECHECK(PortChanged);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
GrafObj_Convert, &port))
|
|
|
|
return NULL;
|
|
|
|
PortChanged(port);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_GDeviceChanged(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GDHandle gdh;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GDeviceChanged
|
|
|
|
PyMac_PRECHECK(GDeviceChanged);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
OptResObj_Convert, &gdh))
|
|
|
|
return NULL;
|
|
|
|
GDeviceChanged(gdh);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_AllowPurgePixels(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef AllowPurgePixels
|
|
|
|
PyMac_PRECHECK(AllowPurgePixels);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
AllowPurgePixels(pm);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_NoPurgePixels(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef NoPurgePixels
|
|
|
|
PyMac_PRECHECK(NoPurgePixels);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
NoPurgePixels(pm);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_GetPixelsState(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
GWorldFlags _rv;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetPixelsState
|
|
|
|
PyMac_PRECHECK(GetPixelsState);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetPixelsState(pm);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_SetPixelsState(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle pm;
|
|
|
|
GWorldFlags state;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef SetPixelsState
|
|
|
|
PyMac_PRECHECK(SetPixelsState);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&l",
|
|
|
|
ResObj_Convert, &pm,
|
|
|
|
&state))
|
|
|
|
return NULL;
|
|
|
|
SetPixelsState(pm,
|
|
|
|
state);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_GetPixRowBytes(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
|
|
|
PixMapHandle pm;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef GetPixRowBytes
|
|
|
|
PyMac_PRECHECK(GetPixRowBytes);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pm))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetPixRowBytes(pm);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_NewScreenBuffer(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
QDErr _err;
|
|
|
|
Rect globalRect;
|
|
|
|
Boolean purgeable;
|
|
|
|
GDHandle gdh;
|
|
|
|
PixMapHandle offscreenPixMap;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef NewScreenBuffer
|
|
|
|
PyMac_PRECHECK(NewScreenBuffer);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&b",
|
|
|
|
PyMac_GetRect, &globalRect,
|
|
|
|
&purgeable))
|
|
|
|
return NULL;
|
|
|
|
_err = NewScreenBuffer(&globalRect,
|
|
|
|
purgeable,
|
|
|
|
&gdh,
|
|
|
|
&offscreenPixMap);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&O&",
|
|
|
|
ResObj_New, gdh,
|
|
|
|
ResObj_New, offscreenPixMap);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_DisposeScreenBuffer(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
PixMapHandle offscreenPixMap;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef DisposeScreenBuffer
|
|
|
|
PyMac_PRECHECK(DisposeScreenBuffer);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &offscreenPixMap))
|
|
|
|
return NULL;
|
|
|
|
DisposeScreenBuffer(offscreenPixMap);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_QDDone(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
GrafPtr port;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef QDDone
|
|
|
|
PyMac_PRECHECK(QDDone);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
GrafObj_Convert, &port))
|
|
|
|
return NULL;
|
|
|
|
_rv = QDDone(port);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_OffscreenVersion(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
long _rv;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef OffscreenVersion
|
|
|
|
PyMac_PRECHECK(OffscreenVersion);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = OffscreenVersion();
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_NewTempScreenBuffer(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
QDErr _err;
|
|
|
|
Rect globalRect;
|
|
|
|
Boolean purgeable;
|
|
|
|
GDHandle gdh;
|
|
|
|
PixMapHandle offscreenPixMap;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef NewTempScreenBuffer
|
|
|
|
PyMac_PRECHECK(NewTempScreenBuffer);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&b",
|
|
|
|
PyMac_GetRect, &globalRect,
|
|
|
|
&purgeable))
|
|
|
|
return NULL;
|
|
|
|
_err = NewTempScreenBuffer(&globalRect,
|
|
|
|
purgeable,
|
|
|
|
&gdh,
|
|
|
|
&offscreenPixMap);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&O&",
|
|
|
|
ResObj_New, gdh,
|
|
|
|
ResObj_New, offscreenPixMap);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_PixMap32Bit(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
PixMapHandle pmHandle;
|
2002-03-24 19:04:18 -04:00
|
|
|
#ifndef PixMap32Bit
|
|
|
|
PyMac_PRECHECK(PixMap32Bit);
|
|
|
|
#endif
|
2001-08-23 11:02:09 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &pmHandle))
|
|
|
|
return NULL;
|
|
|
|
_rv = PixMap32Bit(pmHandle);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PixMapHandle pm;
|
|
|
|
int from, length;
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
|
|
|
|
return NULL;
|
|
|
|
cp = GetPixBaseAddr(pm)+from;
|
2001-09-05 07:31:52 -03:00
|
|
|
_res = PyString_FromStringAndSize(cp, length);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PixMapHandle pm;
|
|
|
|
int from, length;
|
|
|
|
char *cp, *icp;
|
|
|
|
|
|
|
|
if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
|
|
|
|
return NULL;
|
|
|
|
cp = GetPixBaseAddr(pm)+from;
|
|
|
|
memcpy(cp, icp, length);
|
|
|
|
Py_INCREF(Py_None);
|
2001-09-05 07:31:52 -03:00
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Qdoffs_methods[] = {
|
|
|
|
{"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"LockPixels", (PyCFunction)Qdoffs_LockPixels, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> (Boolean _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"UnlockPixels", (PyCFunction)Qdoffs_UnlockPixels, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"UpdateGWorld", (PyCFunction)Qdoffs_UpdateGWorld, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(short pixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldFlags _rv, GWorldPtr offscreenGWorld)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetGWorld", (PyCFunction)Qdoffs_GetGWorld, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (CGrafPtr port, GDHandle gdh)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetGWorld", (PyCFunction)Qdoffs_SetGWorld, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(CGrafPtr port, GDHandle gdh) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"CTabChanged", (PyCFunction)Qdoffs_CTabChanged, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(CTabHandle ctab) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"PixPatChanged", (PyCFunction)Qdoffs_PixPatChanged, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixPatHandle ppat) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"PortChanged", (PyCFunction)Qdoffs_PortChanged, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(GrafPtr port) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GDeviceChanged", (PyCFunction)Qdoffs_GDeviceChanged, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(GDHandle gdh) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"AllowPurgePixels", (PyCFunction)Qdoffs_AllowPurgePixels, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"NoPurgePixels", (PyCFunction)Qdoffs_NoPurgePixels, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetPixelsState", (PyCFunction)Qdoffs_GetPixelsState, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> (GWorldFlags _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"SetPixelsState", (PyCFunction)Qdoffs_SetPixelsState, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm, GWorldFlags state) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetPixRowBytes", (PyCFunction)Qdoffs_GetPixRowBytes, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pm) -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"NewScreenBuffer", (PyCFunction)Qdoffs_NewScreenBuffer, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"DisposeScreenBuffer", (PyCFunction)Qdoffs_DisposeScreenBuffer, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle offscreenPixMap) -> None")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"QDDone", (PyCFunction)Qdoffs_QDDone, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(GrafPtr port) -> (Boolean _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"OffscreenVersion", (PyCFunction)Qdoffs_OffscreenVersion, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("() -> (long _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"NewTempScreenBuffer", (PyCFunction)Qdoffs_NewTempScreenBuffer, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"PixMap32Bit", (PyCFunction)Qdoffs_PixMap32Bit, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(PixMapHandle pmHandle) -> (Boolean _rv)")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"GetPixMapBytes", (PyCFunction)Qdoffs_GetPixMapBytes, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(pixmap, int start, int size) -> string. Return bytes from the pixmap")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{"PutPixMapBytes", (PyCFunction)Qdoffs_PutPixMapBytes, 1,
|
2002-08-16 06:09:31 -03:00
|
|
|
PyDoc_STR("(pixmap, int start, string data). Store bytes into the pixmap")},
|
2001-08-23 11:02:09 -03:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void init_Qdoffs(void)
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
|
|
|
|
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
|
|
|
|
|
|
|
|
|
|
|
|
m = Py_InitModule("_Qdoffs", Qdoffs_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Qdoffs_Error = PyMac_GetOSErrException();
|
|
|
|
if (Qdoffs_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Qdoffs_Error) != 0)
|
|
|
|
return;
|
|
|
|
GWorld_Type.ob_type = &PyType_Type;
|
|
|
|
Py_INCREF(&GWorld_Type);
|
2002-12-03 19:40:22 -04:00
|
|
|
PyModule_AddObject(m, "GWorld", (PyObject *)&GWorld_Type);
|
|
|
|
/* Backward-compatible name */
|
|
|
|
Py_INCREF(&GWorld_Type);
|
|
|
|
PyModule_AddObject(m, "GWorldType", (PyObject *)&GWorld_Type);
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================= End module _Qdoffs ======================= */
|
|
|
|
|