@@ -45,8 +45,12 @@ PyObject *WinObj_New(itself)
4545 it = PyObject_NEW (WindowObject , & Window_Type );
4646 if (it == NULL ) return NULL ;
4747 it -> ob_itself = itself ;
48- SetWRefCon (itself , (long )it );
49- it -> ob_freeit = PyMac_AutoDisposeWindow ;
48+ it -> ob_freeit = NULL ;
49+ if (GetWRefCon (itself ) == 0 )
50+ {
51+ SetWRefCon (itself , (long )it );
52+ it -> ob_freeit = PyMac_AutoDisposeWindow ;
53+ }
5054 return (PyObject * )it ;
5155}
5256WinObj_Convert (v , p_itself )
@@ -73,12 +77,13 @@ WinObj_Convert(v, p_itself)
7377static void WinObj_dealloc (self )
7478 WindowObject * self ;
7579{
76- if (self -> ob_itself ) SetWRefCon (self -> ob_itself , 0 );
7780 if (self -> ob_freeit && self -> ob_itself )
7881 {
82+ SetWRefCon (self -> ob_itself , 0 );
7983 self -> ob_freeit (self -> ob_itself );
8084 }
8185 self -> ob_itself = NULL ;
86+ self -> ob_freeit = NULL ;
8287 PyMem_DEL (self );
8388}
8489
@@ -394,6 +399,38 @@ static PyObject *WinObj_DrawNew(_self, _args)
394399}
395400#endif
396401
402+ static PyObject * WinObj_PaintOne (_self , _args )
403+ WindowObject * _self ;
404+ PyObject * _args ;
405+ {
406+ PyObject * _res = NULL ;
407+ RgnHandle clobberedRgn ;
408+ if (!PyArg_ParseTuple (_args , "O&" ,
409+ ResObj_Convert , & clobberedRgn ))
410+ return NULL ;
411+ PaintOne (_self -> ob_itself ,
412+ clobberedRgn );
413+ Py_INCREF (Py_None );
414+ _res = Py_None ;
415+ return _res ;
416+ }
417+
418+ static PyObject * WinObj_PaintBehind (_self , _args )
419+ WindowObject * _self ;
420+ PyObject * _args ;
421+ {
422+ PyObject * _res = NULL ;
423+ RgnHandle clobberedRgn ;
424+ if (!PyArg_ParseTuple (_args , "O&" ,
425+ ResObj_Convert , & clobberedRgn ))
426+ return NULL ;
427+ PaintBehind (_self -> ob_itself ,
428+ clobberedRgn );
429+ Py_INCREF (Py_None );
430+ _res = Py_None ;
431+ return _res ;
432+ }
433+
397434static PyObject * WinObj_CalcVis (_self , _args )
398435 WindowObject * _self ;
399436 PyObject * _args ;
@@ -407,6 +444,22 @@ static PyObject *WinObj_CalcVis(_self, _args)
407444 return _res ;
408445}
409446
447+ static PyObject * WinObj_CalcVisBehind (_self , _args )
448+ WindowObject * _self ;
449+ PyObject * _args ;
450+ {
451+ PyObject * _res = NULL ;
452+ RgnHandle clobberedRgn ;
453+ if (!PyArg_ParseTuple (_args , "O&" ,
454+ ResObj_Convert , & clobberedRgn ))
455+ return NULL ;
456+ CalcVisBehind (_self -> ob_itself ,
457+ clobberedRgn );
458+ Py_INCREF (Py_None );
459+ _res = Py_None ;
460+ return _res ;
461+ }
462+
410463static PyObject * WinObj_BringToFront (_self , _args )
411464 WindowObject * _self ;
412465 PyObject * _args ;
@@ -1032,6 +1085,26 @@ static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
10321085 return _res ;
10331086}
10341087
1088+ static PyObject * WinObj_WindowPathSelect (_self , _args )
1089+ WindowObject * _self ;
1090+ PyObject * _args ;
1091+ {
1092+ PyObject * _res = NULL ;
1093+ OSStatus _err ;
1094+ MenuHandle menu ;
1095+ SInt32 outMenuResult ;
1096+ if (!PyArg_ParseTuple (_args , "O&" ,
1097+ MenuObj_Convert , & menu ))
1098+ return NULL ;
1099+ _err = WindowPathSelect (_self -> ob_itself ,
1100+ menu ,
1101+ & outMenuResult );
1102+ if (_err != noErr ) return PyMac_Error (_err );
1103+ _res = Py_BuildValue ("l" ,
1104+ outMenuResult );
1105+ return _res ;
1106+ }
1107+
10351108static PyObject * WinObj_HiliteWindowFrameForDrag (_self , _args )
10361109 WindowObject * _self ;
10371110 PyObject * _args ;
@@ -1242,6 +1315,29 @@ static PyObject *WinObj_GetWindowBounds(_self, _args)
12421315 return _res ;
12431316}
12441317
1318+ static PyObject * WinObj_ResizeWindow (_self , _args )
1319+ WindowObject * _self ;
1320+ PyObject * _args ;
1321+ {
1322+ PyObject * _res = NULL ;
1323+ Boolean _rv ;
1324+ Point startPoint ;
1325+ Rect sizeConstraints ;
1326+ Rect newContentRect ;
1327+ if (!PyArg_ParseTuple (_args , "O&O&" ,
1328+ PyMac_GetPoint , & startPoint ,
1329+ PyMac_GetRect , & sizeConstraints ))
1330+ return NULL ;
1331+ _rv = ResizeWindow (_self -> ob_itself ,
1332+ startPoint ,
1333+ & sizeConstraints ,
1334+ & newContentRect );
1335+ _res = Py_BuildValue ("bO&" ,
1336+ _rv ,
1337+ PyMac_BuildRect , & newContentRect );
1338+ return _res ;
1339+ }
1340+
12451341static PyObject * WinObj_SetWindowBounds (_self , _args )
12461342 WindowObject * _self ;
12471343 PyObject * _args ;
@@ -1860,8 +1956,14 @@ static PyMethodDef WinObj_methods[] = {
18601956 {"DrawNew" , (PyCFunction )WinObj_DrawNew , 1 ,
18611957 "(Boolean update) -> None" },
18621958#endif
1959+ {"PaintOne" , (PyCFunction )WinObj_PaintOne , 1 ,
1960+ "(RgnHandle clobberedRgn) -> None" },
1961+ {"PaintBehind" , (PyCFunction )WinObj_PaintBehind , 1 ,
1962+ "(RgnHandle clobberedRgn) -> None" },
18631963 {"CalcVis" , (PyCFunction )WinObj_CalcVis , 1 ,
18641964 "() -> None" },
1965+ {"CalcVisBehind" , (PyCFunction )WinObj_CalcVisBehind , 1 ,
1966+ "(RgnHandle clobberedRgn) -> None" },
18651967 {"BringToFront" , (PyCFunction )WinObj_BringToFront , 1 ,
18661968 "() -> None" },
18671969 {"SendBehind" , (PyCFunction )WinObj_SendBehind , 1 ,
@@ -1942,6 +2044,8 @@ static PyMethodDef WinObj_methods[] = {
19422044 "(Boolean modified) -> None" },
19432045 {"IsWindowPathSelectClick" , (PyCFunction )WinObj_IsWindowPathSelectClick , 1 ,
19442046 "(EventRecord event) -> (Boolean _rv)" },
2047+ {"WindowPathSelect" , (PyCFunction )WinObj_WindowPathSelect , 1 ,
2048+ "(MenuHandle menu) -> (SInt32 outMenuResult)" },
19452049 {"HiliteWindowFrameForDrag" , (PyCFunction )WinObj_HiliteWindowFrameForDrag , 1 ,
19462050 "(Boolean hilited) -> None" },
19472051 {"TransitionWindow" , (PyCFunction )WinObj_TransitionWindow , 1 ,
@@ -1964,6 +2068,8 @@ static PyMethodDef WinObj_methods[] = {
19642068 "(Boolean collapse) -> None" },
19652069 {"GetWindowBounds" , (PyCFunction )WinObj_GetWindowBounds , 1 ,
19662070 "(WindowRegionCode regionCode) -> (Rect globalBounds)" },
2071+ {"ResizeWindow" , (PyCFunction )WinObj_ResizeWindow , 1 ,
2072+ "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)" },
19672073 {"SetWindowBounds" , (PyCFunction )WinObj_SetWindowBounds , 1 ,
19682074 "(WindowRegionCode regionCode, Rect globalBounds) -> None" },
19692075 {"RepositionWindow" , (PyCFunction )WinObj_RepositionWindow , 1 ,
@@ -2767,7 +2873,7 @@ WinObj_WhichWindow(w)
27672873 Py_INCREF (it );
27682874 } else {
27692875 it = (PyObject * ) GetWRefCon (w );
2770- if (it == NULL || ((WindowObject * )it )-> ob_itself != w ) {
2876+ if (it == NULL || ((WindowObject * )it )-> ob_itself != w || ! WinObj_Check ( it ) ) {
27712877 it = WinObj_New (w );
27722878 ((WindowObject * )it )-> ob_freeit = NULL ;
27732879 } else {
0 commit comments