mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
- Added color window/pixmap support
- Added support for obtaining pixmap data - Added OptResObj_* routines for optional handles
This commit is contained in:
parent
72b56e831f
commit
425e9eb6cb
26 changed files with 231 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AEObjects.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AEObjects.h'
|
||||
|
||||
kAEAND = 'AND '
|
||||
kAEOR = 'OR '
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AERegistry.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AERegistry.h'
|
||||
|
||||
cAEList = 'list'
|
||||
cApplication = 'capp'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AppleEvents.h'
|
||||
|
||||
typeBoolean = 'bool'
|
||||
typeChar = 'TEXT'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Dialogs.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Dialogs.h'
|
||||
|
||||
ctrlItem = 4
|
||||
btnCtrl = 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Menus.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Menus.h'
|
||||
|
||||
noMark = 0
|
||||
mDrawMsg = 0
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <AppleEvents.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:AppleEvents.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:AppleEvents.h'
|
||||
|
||||
f = AEFunction(OSErr, 'AECreateDesc',
|
||||
(DescType, 'typeCode', InMode),
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Controls.h>
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Dialogs.h>
|
||||
|
@ -192,7 +201,7 @@ static PyObject *DlgObj_GetDialogItem(_self, _args)
|
|||
&box);
|
||||
_res = Py_BuildValue("hO&O&",
|
||||
itemType,
|
||||
ResObj_OptNew, item,
|
||||
OptResObj_New, item,
|
||||
PyMac_BuildRect, &box);
|
||||
return _res;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Dialogs.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Dialogs.h'
|
||||
|
||||
f = Function(DialogRef, 'NewDialog',
|
||||
(NullStorage, 'wStorage', InMode),
|
||||
|
|
|
@ -13,11 +13,9 @@ from macsupport import *
|
|||
DialogPtr = OpaqueByValueType("DialogPtr", "DlgObj")
|
||||
DialogRef = DialogPtr
|
||||
|
||||
# XXXX There must be a more elegant way to do this. An OptHandle is
|
||||
# either a handle or None (in case NULL is passed in). This is needed
|
||||
# for GetDialogItem().
|
||||
OptHandle = OpaqueByValueType("Handle", "ResObj")
|
||||
OptHandle.new = "ResObj_OptNew"
|
||||
# An OptHandle is either a handle or None (in case NULL is passed in).
|
||||
# This is needed for GetDialogItem().
|
||||
OptHandle = OpaqueByValueType("Handle", "OptResObj")
|
||||
|
||||
ModalFilterProcPtr = InputOnlyType("PyObject*", "O")
|
||||
ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Events.h>
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Lists.h>
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Devices.h> /* Defines OpenDeskAcc in universal headers */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated from 'Sap:CodeWarrior6:Metrowerks C/C++:Headers:Universal Headers 2.0.1f:Menus.h'
|
||||
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Menus.h'
|
||||
|
||||
f = Function(short, 'GetMBarHeight',
|
||||
)
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
|
@ -130,8 +131,15 @@ static PyObject *GrafObj_getattr(self, name)
|
|||
{
|
||||
if ( strcmp(name, "device") == 0 )
|
||||
return PyInt_FromLong((long)self->ob_itself->device);
|
||||
if ( strcmp(name, "portBits") == 0 )
|
||||
return BMObj_New(&self->ob_itself->portBits);
|
||||
if ( strcmp(name, "portBits") == 0 ) {
|
||||
CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
|
||||
|
||||
if ( (itself_color->portVersion&0xc000) == 0xc000 )
|
||||
/* XXXX Do we need HLock() stuff here?? */
|
||||
return BMObj_New((BitMapPtr)*itself_color->portPixMap);
|
||||
else
|
||||
return BMObj_New(&self->ob_itself->portBits);
|
||||
}
|
||||
if ( strcmp(name, "portRect") == 0 )
|
||||
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
|
||||
/* XXXX Add more, as needed */
|
||||
|
@ -220,6 +228,10 @@ static PyObject *BMObj_getattr(self, name)
|
|||
if ( strcmp(name, "bounds") == 0 )
|
||||
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
|
||||
/* XXXX Add more, as needed */
|
||||
if ( strcmp(name, "bitmap_data") == 0 )
|
||||
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
|
||||
if ( strcmp(name, "pixmap_data") == 0 )
|
||||
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
|
||||
|
||||
return Py_FindMethodInChain(&BMObj_chain, (PyObject *)self, name);
|
||||
}
|
||||
|
@ -1525,7 +1537,7 @@ static PyObject *Qd_CopyBits(_self, _args)
|
|||
PyMac_GetRect, &srcRect,
|
||||
PyMac_GetRect, &dstRect,
|
||||
&mode,
|
||||
ResObj_Convert, &maskRgn))
|
||||
OptResObj_Convert, &maskRgn))
|
||||
return NULL;
|
||||
CopyBits(srcBits,
|
||||
dstBits,
|
||||
|
@ -1978,7 +1990,7 @@ static PyObject *Qd_StdBits(_self, _args)
|
|||
PyMac_GetRect, &srcRect,
|
||||
PyMac_GetRect, &dstRect,
|
||||
&mode,
|
||||
ResObj_Convert, &maskRgn))
|
||||
OptResObj_Convert, &maskRgn))
|
||||
return NULL;
|
||||
StdBits(srcBits,
|
||||
&srcRect,
|
||||
|
@ -2721,7 +2733,7 @@ static PyObject *Qd_CopyDeepMask(_self, _args)
|
|||
PyMac_GetRect, &maskRect,
|
||||
PyMac_GetRect, &dstRect,
|
||||
&mode,
|
||||
ResObj_Convert, &maskRgn))
|
||||
OptResObj_Convert, &maskRgn))
|
||||
return NULL;
|
||||
CopyDeepMask(srcBits,
|
||||
maskBits,
|
||||
|
@ -3071,6 +3083,31 @@ static PyObject *Qd_BitMap(_self, _args)
|
|||
|
||||
}
|
||||
|
||||
static PyObject *Qd_RawBitMap(_self, _args)
|
||||
PyObject *_self;
|
||||
PyObject *_args;
|
||||
{
|
||||
PyObject *_res = NULL;
|
||||
|
||||
BitMap *ptr;
|
||||
PyObject *source;
|
||||
|
||||
if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
|
||||
return NULL;
|
||||
if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
|
||||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
ptr = (BitMapPtr)PyString_AsString(source);
|
||||
if ( (_res = BMObj_New(ptr)) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
((BitMapObject *)_res)->referred_object = source;
|
||||
Py_INCREF(source);
|
||||
return _res;
|
||||
|
||||
}
|
||||
|
||||
static PyMethodDef Qd_methods[] = {
|
||||
{"SetPort", (PyCFunction)Qd_SetPort, 1,
|
||||
"(GrafPtr port) -> None"},
|
||||
|
@ -3394,6 +3431,8 @@ static PyMethodDef Qd_methods[] = {
|
|||
"(Fixed extra) -> None"},
|
||||
{"BitMap", (PyCFunction)Qd_BitMap, 1,
|
||||
"Take (string, int, Rect) argument and create BitMap"},
|
||||
{"RawBitMap", (PyCFunction)Qd_RawBitMap, 1,
|
||||
"Take string BitMap and turn into BitMap object"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ f = Function(void, 'CopyBits',
|
|||
(Rect_ptr, 'srcRect', InMode),
|
||||
(Rect_ptr, 'dstRect', InMode),
|
||||
(short, 'mode', InMode),
|
||||
(RgnHandle, 'maskRgn', InMode),
|
||||
(OptRgnHandle, 'maskRgn', InMode),
|
||||
)
|
||||
functions.append(f)
|
||||
|
||||
|
@ -571,7 +571,7 @@ f = Function(void, 'StdBits',
|
|||
(Rect_ptr, 'srcRect', InMode),
|
||||
(Rect_ptr, 'dstRect', InMode),
|
||||
(short, 'mode', InMode),
|
||||
(RgnHandle, 'maskRgn', InMode),
|
||||
(OptRgnHandle, 'maskRgn', InMode),
|
||||
)
|
||||
functions.append(f)
|
||||
|
||||
|
@ -817,7 +817,7 @@ f = Function(void, 'CopyDeepMask',
|
|||
(Rect_ptr, 'maskRect', InMode),
|
||||
(Rect_ptr, 'dstRect', InMode),
|
||||
(short, 'mode', InMode),
|
||||
(RgnHandle, 'maskRgn', InMode),
|
||||
(OptRgnHandle, 'maskRgn', InMode),
|
||||
)
|
||||
functions.append(f)
|
||||
|
||||
|
|
|
@ -127,6 +127,10 @@ class MyScanner(Scanner):
|
|||
[('Rect', 'r', 'InOutMode'),
|
||||
('Rect_ptr', 'srcRect', 'InMode'),
|
||||
('Rect_ptr', 'dstRect', 'InMode')]),
|
||||
|
||||
# CopyBits and friends
|
||||
([('RgnHandle', 'maskRgn', 'InMode')],
|
||||
[('OptRgnHandle', 'maskRgn', 'InMode')]),
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ TextThingie = TextThingieClass(None)
|
|||
|
||||
# These are temporary!
|
||||
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
|
||||
OptRgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
|
||||
PicHandle = OpaqueByValueType("PicHandle", "ResObj")
|
||||
PolyHandle = OpaqueByValueType("PolyHandle", "ResObj")
|
||||
PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj")
|
||||
|
@ -101,8 +102,15 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
|
|||
def outputGetattrHook(self):
|
||||
Output("""if ( strcmp(name, "device") == 0 )
|
||||
return PyInt_FromLong((long)self->ob_itself->device);
|
||||
if ( strcmp(name, "portBits") == 0 )
|
||||
return BMObj_New(&self->ob_itself->portBits);
|
||||
if ( strcmp(name, "portBits") == 0 ) {
|
||||
CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
|
||||
|
||||
if ( (itself_color->portVersion&0xc000) == 0xc000 )
|
||||
/* XXXX Do we need HLock() stuff here?? */
|
||||
return BMObj_New((BitMapPtr)*itself_color->portPixMap);
|
||||
else
|
||||
return BMObj_New(&self->ob_itself->portBits);
|
||||
}
|
||||
if ( strcmp(name, "portRect") == 0 )
|
||||
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
|
||||
/* XXXX Add more, as needed */
|
||||
|
@ -132,6 +140,10 @@ class MyBMObjectDefinition(GlobalObjectDefinition):
|
|||
if ( strcmp(name, "bounds") == 0 )
|
||||
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
|
||||
/* XXXX Add more, as needed */
|
||||
if ( strcmp(name, "bitmap_data") == 0 )
|
||||
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
|
||||
if ( strcmp(name, "pixmap_data") == 0 )
|
||||
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
|
||||
""")
|
||||
|
||||
# Create the generator groups and link them
|
||||
|
@ -195,6 +207,32 @@ f = ManualGenerator("BitMap", BitMap_body)
|
|||
f.docstring = lambda: """Take (string, int, Rect) argument and create BitMap"""
|
||||
module.add(f)
|
||||
|
||||
#
|
||||
# And again, for turning a correctly-formatted structure into the object
|
||||
#
|
||||
RawBitMap_body = """
|
||||
BitMap *ptr;
|
||||
PyObject *source;
|
||||
|
||||
if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
|
||||
return NULL;
|
||||
if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
|
||||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
ptr = (BitMapPtr)PyString_AsString(source);
|
||||
if ( (_res = BMObj_New(ptr)) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
((BitMapObject *)_res)->referred_object = source;
|
||||
Py_INCREF(source);
|
||||
return _res;
|
||||
"""
|
||||
|
||||
f = ManualGenerator("RawBitMap", RawBitMap_body)
|
||||
f.docstring = lambda: """Take string BitMap and turn into BitMap object"""
|
||||
module.add(f)
|
||||
|
||||
# generate output (open the output file as late as possible)
|
||||
SetOutputFileName(OUTPUTFILE)
|
||||
module.generate()
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Resources.h>
|
||||
|
@ -1333,7 +1342,7 @@ static PyMethodDef Res_methods[] = {
|
|||
|
||||
|
||||
/* Alternative version of ResObj_New, which returns None for null argument */
|
||||
PyObject *ResObj_OptNew(itself)
|
||||
PyObject *OptResObj_New(itself)
|
||||
Handle itself;
|
||||
{
|
||||
ResourceObject *it;
|
||||
|
@ -1344,6 +1353,23 @@ PyObject *ResObj_OptNew(itself)
|
|||
return ResObj_New(itself);
|
||||
}
|
||||
|
||||
OptResObj_Convert(v, p_itself)
|
||||
PyObject *v;
|
||||
Handle *p_itself;
|
||||
{
|
||||
if ( v == Py_None ) {
|
||||
*p_itself = NULL;
|
||||
return 1;
|
||||
}
|
||||
if (!ResObj_Check(v))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Resource required");
|
||||
return 0;
|
||||
}
|
||||
*p_itself = ((ResourceObject *)v)->ob_itself;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initRes()
|
||||
|
|
|
@ -32,7 +32,7 @@ includestuff = includestuff + """
|
|||
finalstuff = finalstuff + """
|
||||
|
||||
/* Alternative version of ResObj_New, which returns None for null argument */
|
||||
PyObject *ResObj_OptNew(itself)
|
||||
PyObject *OptResObj_New(itself)
|
||||
Handle itself;
|
||||
{
|
||||
ResourceObject *it;
|
||||
|
@ -43,6 +43,23 @@ PyObject *ResObj_OptNew(itself)
|
|||
return ResObj_New(itself);
|
||||
}
|
||||
|
||||
OptResObj_Convert(v, p_itself)
|
||||
PyObject *v;
|
||||
Handle *p_itself;
|
||||
{
|
||||
if ( v == Py_None ) {
|
||||
*p_itself = NULL;
|
||||
return 1;
|
||||
}
|
||||
if (!ResObj_Check(v))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Resource required");
|
||||
return 0;
|
||||
}
|
||||
*p_itself = ((ResourceObject *)v)->ob_itself;
|
||||
return 1;
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
initstuff = initstuff + """
|
||||
|
|
|
@ -14,11 +14,14 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
extern PyTypeObject Window_Type;
|
||||
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
||||
|
||||
extern PyObject *DlgObj_New(DialogPtr);
|
||||
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
||||
|
@ -31,6 +34,12 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|||
extern PyObject *CtlObj_New(ControlHandle);
|
||||
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
||||
|
||||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Sound.h>
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
|
@ -36,6 +37,9 @@ extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
|||
extern PyObject *GrafObj_New(GrafPtr);
|
||||
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
||||
|
||||
extern PyObject *BMObj_New(BitMapPtr);
|
||||
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
||||
|
||||
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
||||
|
||||
#include <Windows.h>
|
||||
|
|
|
@ -99,8 +99,9 @@ includestuff = """
|
|||
#include <Controls.h>
|
||||
|
||||
extern PyObject *ResObj_New(Handle);
|
||||
extern PyObject *ResObj_OptNew(Handle);
|
||||
extern int ResObj_Convert(PyObject *, Handle *);
|
||||
extern PyObject *OptResObj_New(Handle);
|
||||
extern int OptResObj_Convert(PyObject *, Handle *);
|
||||
|
||||
extern PyObject *WinObj_New(WindowPtr);
|
||||
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue