Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c3c58b

Browse files
committed
Accessor functions for regions and such expect an existing region as parameter. Fixed for grafport attribute access.
Got GetPortBitMapForCopyBits() and port.portBits to work.
1 parent 9b897ec commit 5c3c58b

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

Mac/Modules/qd/Qdmodule.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,8 @@ static PyObject *GrafObj_getattr(self, name)
255255
#else
256256

257257
{ CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
258-
/*
259258
if ( strcmp(name, "portBits") == 0 )
260-
return BMObj_New((BitMapPtr)GetPortPixMap(itself_color));
261-
*/
259+
return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color));
262260
if ( strcmp(name, "chExtra") == 0 )
263261
return Py_BuildValue("h", GetPortChExtra(itself_color));
264262
if ( strcmp(name, "pnLocHFrac") == 0 )
@@ -276,24 +274,24 @@ static PyObject *GrafObj_getattr(self, name)
276274
return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c));
277275
}
278276
if ( strcmp(name, "pnPixPat") == 0 ) {
279-
PixPatHandle h=0;
277+
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
280278

281279
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h));
282280
}
283281
if ( strcmp(name, "fillPixPat") == 0 ) {
284-
PixPatHandle h=0;
282+
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
285283
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h));
286284
}
287285
if ( strcmp(name, "portRect") == 0 ) {
288286
Rect r;
289287
return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r));
290288
}
291289
if ( strcmp(name, "visRgn") == 0 ) {
292-
RgnHandle h=0;
290+
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
293291
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h));
294292
}
295293
if ( strcmp(name, "clipRgn") == 0 ) {
296-
RgnHandle h=0;
294+
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
297295
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h));
298296
}
299297
if ( strcmp(name, "pnLoc") == 0 ) {
@@ -3858,6 +3856,22 @@ static PyObject *Qd_GetPortPixMap(_self, _args)
38583856
return _res;
38593857
}
38603858

3859+
static PyObject *Qd_GetPortBitMapForCopyBits(_self, _args)
3860+
PyObject *_self;
3861+
PyObject *_args;
3862+
{
3863+
PyObject *_res = NULL;
3864+
const BitMap * _rv;
3865+
CGrafPtr port;
3866+
if (!PyArg_ParseTuple(_args, "O&",
3867+
GrafObj_Convert, &port))
3868+
return NULL;
3869+
_rv = GetPortBitMapForCopyBits(port);
3870+
_res = Py_BuildValue("O&",
3871+
BMObj_New, _rv);
3872+
return _res;
3873+
}
3874+
38613875
static PyObject *Qd_GetPortBounds(_self, _args)
38623876
PyObject *_self;
38633877
PyObject *_args;
@@ -5931,6 +5945,8 @@ static PyMethodDef Qd_methods[] = {
59315945
"(Fixed slope) -> (short _rv)"},
59325946
{"GetPortPixMap", (PyCFunction)Qd_GetPortPixMap, 1,
59335947
"(CGrafPtr port) -> (PixMapHandle _rv)"},
5948+
{"GetPortBitMapForCopyBits", (PyCFunction)Qd_GetPortBitMapForCopyBits, 1,
5949+
"(CGrafPtr port) -> (const BitMap * _rv)"},
59345950
{"GetPortBounds", (PyCFunction)Qd_GetPortBounds, 1,
59355951
"(CGrafPtr port) -> (Rect rect)"},
59365952
{"GetPortForeColor", (PyCFunction)Qd_GetPortForeColor, 1,

Mac/Modules/qd/qdscan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def makeblacklistnames(self):
100100
'GetPortHWND',
101101
'GetHWNDPort',
102102
'GetPICTFromDIB',
103-
'GetPortBitMapForCopyBits', # Something funny in the declaration
104103

105104
'HandleToRgn', # Funny signature
106105

Mac/Modules/qd/qdsupport.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def getargsCheck(self, name):
4545
CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
4646
GrafPtr = OpaqueByValueType("GrafPtr", "GrafObj")
4747
BitMap_ptr = OpaqueByValueType("BitMapPtr", "BMObj")
48+
const_BitMap_ptr = OpaqueByValueType("const BitMap *", "BMObj")
4849
BitMap = OpaqueType("BitMap", "BMObj")
4950
RGBColor = OpaqueType('RGBColor', 'QdRGB')
5051
RGBColor_ptr = RGBColor
@@ -284,10 +285,8 @@ def outputGetattrHook(self):
284285
Output("#else")
285286
Output("""
286287
{ CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
287-
/*
288288
if ( strcmp(name, "portBits") == 0 )
289-
return BMObj_New((BitMapPtr)GetPortPixMap(itself_color));
290-
*/
289+
return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color));
291290
if ( strcmp(name, "chExtra") == 0 )
292291
return Py_BuildValue("h", GetPortChExtra(itself_color));
293292
if ( strcmp(name, "pnLocHFrac") == 0 )
@@ -305,24 +304,24 @@ def outputGetattrHook(self):
305304
return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c));
306305
}
307306
if ( strcmp(name, "pnPixPat") == 0 ) {
308-
PixPatHandle h=0;
307+
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
309308
310309
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h));
311310
}
312311
if ( strcmp(name, "fillPixPat") == 0 ) {
313-
PixPatHandle h=0;
312+
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
314313
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h));
315314
}
316315
if ( strcmp(name, "portRect") == 0 ) {
317316
Rect r;
318317
return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r));
319318
}
320319
if ( strcmp(name, "visRgn") == 0 ) {
321-
RgnHandle h=0;
320+
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
322321
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h));
323322
}
324323
if ( strcmp(name, "clipRgn") == 0 ) {
325-
RgnHandle h=0;
324+
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
326325
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h));
327326
}
328327
if ( strcmp(name, "pnLoc") == 0 ) {

0 commit comments

Comments
 (0)