1 # This script generates a Python interface for an Apple Macintosh Manager.
2 # It uses the "bgen" package to generate C code.
3 # The function specifications are generated by scanning the mamager's header file,
4 # using the "scantools" package (customized for this particular manager).
8 # Declarations that change for each manager
9 MACHEADERFILE
= 'Controls.h' # The Apple header file
10 MODNAME
= '_Ctl' # The name of the module
11 OBJECTNAME
= 'Control' # The basic name of the objects used here
13 # The following is *usually* unchanged but may still require tuning
14 MODPREFIX
= 'Ctl' # The prefix for module-wide routines
15 OBJECTTYPE
= OBJECTNAME
+ 'Handle' # The C type used to represent them
16 OBJECTPREFIX
= MODPREFIX
+ 'Obj' # The prefix for object methods
17 INPUTFILE
= string
.lower(MODPREFIX
) + 'gen.py' # The file generated by the scanner
18 OUTPUTFILE
= MODNAME
+ "module.c" # The file generated by this program
20 from macsupport
import *
22 # Create the type objects
24 ControlHandle
= OpaqueByValueType(OBJECTTYPE
, OBJECTPREFIX
)
25 ControlRef
= ControlHandle
26 ExistingControlHandle
= OpaqueByValueType(OBJECTTYPE
, "CtlObj_WhichControl", "BUG")
28 RgnHandle
= OpaqueByValueType("RgnHandle", "ResObj")
29 CCTabHandle
= OpaqueByValueType("CCTabHandle", "ResObj")
30 AuxCtlHandle
= OpaqueByValueType("AuxCtlHandle", "ResObj")
31 ControlPartCode
= Type("ControlPartCode", "h")
32 DragConstraint
= Type("DragConstraint", "H")
33 ControlVariant
= Type("ControlVariant", "h")
34 IconTransformType
= Type("IconTransformType", "h")
35 EventModifiers
= Type("EventModifiers", "H")
36 ClickActivationResult
= Type("ClickActivationResult", "l")
37 ControlButtonGraphicAlignment
= Type("ControlButtonGraphicAlignment", "h")
38 ControlButtonTextAlignment
= Type("ControlButtonTextAlignment", "h")
39 ControlButtonTextPlacement
= Type("ControlButtonTextPlacement", "h")
40 ControlContentType
= Type("ControlContentType", "h")
41 ControlFocusPart
= Type("ControlFocusPart", "h")
43 ControlFontStyleRec
= OpaqueType('ControlFontStyleRec', 'ControlFontStyle')
44 ControlFontStyleRec_ptr
= ControlFontStyleRec
45 ControlID
= OpaqueType('ControlID', 'PyControlID')
46 ControlID_ptr
= ControlID
48 DragTrackingMessage
= Type("DragTrackingMessage", "h")
49 DragReference
= OpaqueByValueType("DragReference", "DragObj")
51 CFStringRef
= OpaqueByValueType("CFStringRef", "CFStringRefObj")
52 CFMutableStringRef
= OpaqueByValueType("CFMutableStringRef", "CFMutableStringRefObj")
53 CFDataRef
= OpaqueByValueType("CFDataRef", "CFDataRefObj")
55 ControlTabSize
= UInt16
56 ControlTabDirection
= UInt16
57 ControlPopupArrowOrientation
= UInt16
58 ControlPopupArrowSize
= UInt16
59 ControlClockType
= UInt16
60 ControlClockFlags
= UInt32
61 ControlRoundButtonSize
= SInt16
62 DataBrowserViewStyle
= OSType
63 DataBrowserItemID
= UInt32
64 DataBrowserEditCommand
= UInt32
65 DataBrowserSelectionAnchorDirection
= UInt32
66 DataBrowserItemState
= UInt32
67 DataBrowserPropertyID
= UInt32
68 DataBrowserRevealOptions
= UInt8
69 DataBrowserSortOrder
= UInt16
70 DataBrowserSelectionFlags
= UInt32
71 DataBrowserPropertyFlags
= UInt32
72 DataBrowserPropertyPart
= OSType
73 DataBrowserTableViewColumnID
= DataBrowserPropertyID
74 #DataBrowserTableViewColumnDesc = DataBrowserPropertyDesc
75 DataBrowserTableViewHiliteStyle
= UInt32
76 DataBrowserTableViewRowIndex
= UInt32
77 DataBrowserTableViewColumnIndex
= UInt32
78 DataBrowserPropertyType
= OSType
79 ControlDisclosureTriangleOrientation
= UInt16
81 DataBrowserTableViewColumnDesc
= OpaqueType("DataBrowserTableViewColumnDesc",
82 "DataBrowserTableViewColumnDesc")
83 DataBrowserListViewColumnDesc
= OpaqueType("DataBrowserListViewColumnDesc",
84 "DataBrowserListViewColumnDesc")
85 ControlButtonContentInfo
= OpaqueType("ControlButtonContentInfo",
86 "ControlButtonContentInfo")
87 ControlButtonContentInfoPtr
= ControlButtonContentInfo_ptr
= ControlButtonContentInfo
89 ControlTabEntry_ptr
= OpaqueType("ControlTabEntry", "ControlTabEntry")
91 ControlBevelThickness
= UInt16
92 ControlBevelButtonBehavior
= UInt16
93 ControlBevelButtonMenuBehavior
= UInt16
94 ControlBevelButtonMenuPlacement
= UInt16
95 ControlPushButtonIconAlignment
= UInt16
97 class ControlActionDefinition(Type
):
98 def declare(self
, name
):
99 Output("%s %s;", self
.typeName
, name
)
100 Output("UniversalProcPtr c_callback;")
101 def passInput(self
, name
):
102 return "myactionproc_upp"
103 def cleanup(self
, name
):
104 Output("setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);")
106 class ControlActionDefinitionNewControl(ControlActionDefinition
):
107 def cleanup(self
, name
):
108 Output("setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);")
110 ControlActionUPP
= ControlActionDefinition("PyObject*", "O")
111 ControlActionUPPNewControl
= ControlActionDefinitionNewControl("PyObject*", "O")
112 ControlSliderOrientation
= UInt16
115 includestuff
= includestuff
+ """
116 #ifdef WITHOUT_FRAMEWORKS
117 #include <Controls.h>
118 #include <ControlDefinitions.h>
120 #include <Carbon/Carbon.h>
123 #ifdef USE_TOOLBOX_OBJECT_GLUE
124 extern PyObject *_CtlObj_New(ControlHandle);
125 extern int _CtlObj_Convert(PyObject *, ControlHandle *);
127 #define CtlObj_New _CtlObj_New
128 #define CtlObj_Convert _CtlObj_Convert
131 staticforward PyObject *CtlObj_WhichControl(ControlHandle);
133 #define as_Control(h) ((ControlHandle)h)
134 #define as_Resource(ctl) ((Handle)ctl)
135 #if TARGET_API_MAC_CARBON
136 #define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp)
138 #define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect))
141 #define MAXTABS 32 /* maximum number of tabs that we support in a tabs control */
143 ** Parse/generate ControlFontStyleRec records
145 #if 0 /* Not needed */
147 ControlFontStyle_New(ControlFontStyleRec *itself)
150 return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
151 itself->size, itself->style, itself->mode, itself->just,
152 QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
157 ControlFontStyle_Convert(PyObject *v, ControlFontStyleRec *itself)
159 return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
160 &itself->font, &itself->size, &itself->style, &itself->mode,
161 &itself->just, QdRGB_Convert, &itself->foreColor,
162 QdRGB_Convert, &itself->backColor);
166 ** Parse/generate ControlID records
169 PyControlID_New(ControlID *itself)
172 return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
176 PyControlID_Convert(PyObject *v, ControlID *itself)
178 return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
182 ** generate DataBrowserListViewColumnDesc records
185 DataBrowserTableViewColumnDesc_Convert(PyObject *v, DataBrowserTableViewColumnDesc *itself)
187 return PyArg_Parse(v, "(lO&l)",
189 PyMac_GetOSType, &itself->propertyType,
190 &itself->propertyFlags);
194 ControlButtonContentInfo_Convert(PyObject *v, ControlButtonContentInfo *itself)
196 return PyArg_Parse(v, "(hO&)",
197 &itself->contentType,
198 OptResObj_Convert, &itself->u.iconSuite);
202 DataBrowserListViewHeaderDesc_Convert(PyObject *v, DataBrowserListViewHeaderDesc *itself)
204 itself->version = kDataBrowserListViewLatestHeaderDesc;
205 return PyArg_Parse(v, "(HHhO&HO&O&)",
206 &itself->minimumWidth,
207 &itself->maximumWidth,
208 &itself->titleOffset,
209 CFStringRefObj_Convert, &itself->titleString,
210 &itself->initialOrder,
211 ControlFontStyle_Convert, &itself->btnFontStyle,
212 ControlButtonContentInfo_Convert, &itself->btnContentInfo);
216 DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc *itself)
218 return PyArg_Parse(v, "(O&O&)",
219 DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
220 DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
223 /* TrackControl and HandleControlClick callback support */
224 #define kMyControlActionProcTag 'ACTN' /* not an official tag, only for internal use */
225 static PyObject *tracker;
226 static ControlActionUPP mytracker_upp;
227 static ControlActionUPP myactionproc_upp;
228 static ControlUserPaneKeyDownUPP mykeydownproc_upp;
229 static ControlUserPaneFocusUPP myfocusproc_upp;
230 static ControlUserPaneDrawUPP mydrawproc_upp;
231 static ControlUserPaneIdleUPP myidleproc_upp;
232 static ControlUserPaneHitTestUPP myhittestproc_upp;
233 static ControlUserPaneTrackingUPP mytrackingproc_upp;
235 staticforward int settrackfunc(PyObject *); /* forward */
236 staticforward void clrtrackfunc(void); /* forward */
237 staticforward int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *);
240 finalstuff
= finalstuff
+ """
242 CtlObj_NewUnmanaged(ControlHandle itself)
245 if (itself == NULL) return PyMac_Error(resNotFound);
246 it = PyObject_NEW(ControlObject, &Control_Type);
247 if (it == NULL) return NULL;
248 it->ob_itself = itself;
249 it->ob_callbackdict = NULL;
250 return (PyObject *)it;
254 CtlObj_WhichControl(ControlHandle c)
261 it = (PyObject *) GetControlReference(c);
263 ** If the refcon is zero or doesn't point back to the Python object
264 ** the control is not ours. Return a temporary object.
266 if (it == NULL || ((ControlObject *)it)->ob_itself != c)
267 return CtlObj_NewUnmanaged(c);
274 settrackfunc(PyObject *obj)
277 PyErr_SetString(Ctl_Error, "Tracker function in use");
293 mytracker(ControlHandle ctl, short part)
295 PyObject *args, *rv=0;
297 args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
298 if (args && tracker) {
299 rv = PyEval_CallObject(tracker, args);
305 PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
311 setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr *uppp)
313 ControlObject *self = (ControlObject *)myself;
316 if ( which == kMyControlActionProcTag )
317 *uppp = (UniversalProcPtr)myactionproc_upp;
318 else if ( which == kControlUserPaneKeyDownProcTag )
319 *uppp = (UniversalProcPtr)mykeydownproc_upp;
320 else if ( which == kControlUserPaneFocusProcTag )
321 *uppp = (UniversalProcPtr)myfocusproc_upp;
322 else if ( which == kControlUserPaneDrawProcTag )
323 *uppp = (UniversalProcPtr)mydrawproc_upp;
324 else if ( which == kControlUserPaneIdleProcTag )
325 *uppp = (UniversalProcPtr)myidleproc_upp;
326 else if ( which == kControlUserPaneHitTestProcTag )
327 *uppp = (UniversalProcPtr)myhittestproc_upp;
328 else if ( which == kControlUserPaneTrackingProcTag )
329 *uppp = (UniversalProcPtr)mytrackingproc_upp;
332 /* Only now do we test for clearing of the callback: */
333 if ( callback == Py_None )
335 /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
336 if ( self->ob_callbackdict == NULL )
337 if ( (self->ob_callbackdict = PyDict_New()) == NULL )
339 /* And store the Python callback */
340 sprintf(keybuf, "%x", (unsigned)which);
341 if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
347 callcallback(ControlObject *self, OSType which, PyObject *arglist)
352 sprintf(keybuf, "%x", (unsigned)which);
353 if ( self->ob_callbackdict == NULL ||
354 (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
355 PySys_WriteStderr("Control callback %x without callback object\\n", (unsigned)which);
358 rv = PyEval_CallObject(func, arglist);
360 PySys_WriteStderr("Exception in control callback %x handler\\n", (unsigned)which);
367 myactionproc(ControlHandle control, SInt16 part)
369 ControlObject *ctl_obj;
370 PyObject *arglist, *rv;
372 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
373 arglist = Py_BuildValue("Oh", ctl_obj, part);
374 rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
379 static pascal ControlPartCode
380 mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
382 ControlObject *ctl_obj;
383 PyObject *arglist, *rv;
386 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
387 arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
388 rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
391 if (!PyArg_Parse(rv, "h", &c_rv))
394 return (ControlPartCode)c_rv;
397 static pascal ControlPartCode
398 myfocusproc(ControlHandle control, ControlPartCode part)
400 ControlObject *ctl_obj;
401 PyObject *arglist, *rv;
402 short c_rv = kControlFocusNoPart;
404 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
405 arglist = Py_BuildValue("Oh", ctl_obj, part);
406 rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
409 if (!PyArg_Parse(rv, "h", &c_rv))
412 return (ControlPartCode)c_rv;
416 mydrawproc(ControlHandle control, SInt16 part)
418 ControlObject *ctl_obj;
419 PyObject *arglist, *rv;
421 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
422 arglist = Py_BuildValue("Oh", ctl_obj, part);
423 rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
429 myidleproc(ControlHandle control)
431 ControlObject *ctl_obj;
432 PyObject *arglist, *rv;
434 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
435 arglist = Py_BuildValue("O", ctl_obj);
436 rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
441 static pascal ControlPartCode
442 myhittestproc(ControlHandle control, Point where)
444 ControlObject *ctl_obj;
445 PyObject *arglist, *rv;
448 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
449 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
450 rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
452 /* Ignore errors, nothing we can do about them */
454 if (!PyArg_Parse(rv, "h", &c_rv))
457 return (ControlPartCode)c_rv;
460 static pascal ControlPartCode
461 mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc)
463 ControlObject *ctl_obj;
464 PyObject *arglist, *rv;
467 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
468 /* We cannot pass the actionProc without lots of work */
469 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
470 rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
473 if (!PyArg_Parse(rv, "h", &c_rv))
476 return (ControlPartCode)c_rv;
480 initstuff
= initstuff
+ """
481 mytracker_upp = NewControlActionUPP(mytracker);
482 myactionproc_upp = NewControlActionUPP(myactionproc);
483 mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
484 myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc);
485 mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc);
486 myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc);
487 myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc);
488 mytrackingproc_upp = NewControlUserPaneTrackingUPP(mytrackingproc);
489 PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New);
490 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
493 class MyObjectDefinition(ObjectIdentityMixin
, GlobalObjectDefinition
):
494 def outputStructMembers(self
):
495 GlobalObjectDefinition
.outputStructMembers(self
)
496 Output("PyObject *ob_callbackdict;")
497 def outputCheckNewArg(self
):
498 Output("if (itself == NULL) return PyMac_Error(resNotFound);")
499 def outputInitStructMembers(self
):
500 GlobalObjectDefinition
.outputInitStructMembers(self
)
501 Output("SetControlReference(itself, (long)it);")
502 Output("it->ob_callbackdict = NULL;")
503 def outputCleanupStructMembers(self
):
504 Output("Py_XDECREF(self->ob_callbackdict);")
505 Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
507 # Create the generator groups and link them
508 module
= MacModule(MODNAME
, MODPREFIX
, includestuff
, finalstuff
, initstuff
)
509 object = MyObjectDefinition(OBJECTNAME
, OBJECTPREFIX
, OBJECTTYPE
)
510 module
.addobject(object)
512 # Create the generator classes used to populate the lists
513 Function
= OSErrWeakLinkFunctionGenerator
514 Method
= OSErrWeakLinkMethodGenerator
516 # Create and populate the lists
520 execfile('ctledit.py')
522 # add the populated lists to the generator groups
523 for f
in functions
: module
.add(f
)
524 for f
in methods
: object.add(f
)
526 # Manual generator for TrackControl, due to callback ideosyncracies
527 trackcontrol_body
= """
530 ControlActionUPP upp = 0;
531 PyObject *callback = 0;
533 if (!PyArg_ParseTuple(_args, "O&|O",
534 PyMac_GetPoint, &startPoint, &callback))
536 if (callback && callback != Py_None) {
537 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
538 upp = (ControlActionUPP)-1;
540 settrackfunc(callback);
544 _rv = TrackControl(_self->ob_itself,
548 _res = Py_BuildValue("h",
553 f
= ManualGenerator("TrackControl", trackcontrol_body
);
554 f
.docstring
= lambda: "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
557 # CJW - added 5/12/99
558 # Manual generator for HandleControlClick, as for TrackControl
559 handlecontrolclick_body
= """
563 ControlActionUPP upp = 0;
564 PyObject *callback = 0;
566 if (!PyArg_ParseTuple(_args, "O&h|O",
567 PyMac_GetPoint, &startPoint,
571 if (callback && callback != Py_None) {
572 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
573 upp = (ControlActionUPP)-1;
575 settrackfunc(callback);
579 _rv = HandleControlClick(_self->ob_itself,
584 _res = Py_BuildValue("h",
589 f
= ManualGenerator("HandleControlClick", handlecontrolclick_body
);
590 f
.docstring
= lambda: "(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"
593 # Manual Generator for SetControlData
594 setcontroldata_body
= """
596 ControlPartCode inPart;
601 if (!PyArg_ParseTuple(_args, "hO&s#",
603 PyMac_GetOSType, &inTagName,
604 &buffer, &bufferSize))
607 _err = SetControlData(_self->ob_itself,
614 return PyMac_Error(_err);
619 f
= ManualGenerator("SetControlData", setcontroldata_body
);
620 f
.docstring
= lambda: "(stuff) -> None"
623 # Manual Generator for GetControlData
624 getcontroldata_body
= """
626 ControlPartCode inPart;
632 if (!PyArg_ParseTuple(_args, "hO&",
634 PyMac_GetOSType, &inTagName))
637 /* allocate a buffer for the data */
638 _err = GetControlDataSize(_self->ob_itself,
643 return PyMac_Error(_err);
644 buffer = PyMem_NEW(char, bufferSize);
646 return PyErr_NoMemory();
648 _err = GetControlData(_self->ob_itself,
657 return PyMac_Error(_err);
659 _res = Py_BuildValue("s#", buffer, outSize);
664 f
= ManualGenerator("GetControlData", getcontroldata_body
);
665 f
.docstring
= lambda: "(part, type) -> String"
668 # Manual Generator for SetControlData_Handle
669 setcontroldata_handle_body
= """
671 ControlPartCode inPart;
675 if (!PyArg_ParseTuple(_args, "hO&O&",
677 PyMac_GetOSType, &inTagName,
678 OptResObj_Convert, &buffer))
681 _err = SetControlData(_self->ob_itself,
688 return PyMac_Error(_err);
693 f
= ManualGenerator("SetControlData_Handle", setcontroldata_handle_body
);
694 f
.docstring
= lambda: "(ResObj) -> None"
697 # Manual Generator for GetControlData_Handle
698 getcontroldata_handle_body
= """
700 ControlPartCode inPart;
705 if (!PyArg_ParseTuple(_args, "hO&",
707 PyMac_GetOSType, &inTagName))
710 /* Check it is handle-sized */
711 _err = GetControlDataSize(_self->ob_itself,
716 return PyMac_Error(_err);
717 if (bufferSize != sizeof(Handle)) {
718 PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
722 _err = GetControlData(_self->ob_itself,
730 return PyMac_Error(_err);
732 _res = Py_BuildValue("O&", OptResObj_New, hdl);
736 f
= ManualGenerator("GetControlData_Handle", getcontroldata_handle_body
);
737 f
.docstring
= lambda: "(part, type) -> ResObj"
740 # Manual Generator for SetControlData_Callback
741 setcontroldata_callback_body
= """
743 ControlPartCode inPart;
746 UniversalProcPtr c_callback;
748 if (!PyArg_ParseTuple(_args, "hO&O",
750 PyMac_GetOSType, &inTagName,
754 if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
756 _err = SetControlData(_self->ob_itself,
763 return PyMac_Error(_err);
768 f
= ManualGenerator("SetControlData_Callback", setcontroldata_callback_body
);
769 f
.docstring
= lambda: "(callbackfunc) -> None"
772 # And manual generators to get/set popup menu information
773 getpopupdata_body
= """
774 PopupPrivateDataHandle hdl;
776 if ( (*_self->ob_itself)->contrlData == NULL ) {
777 PyErr_SetString(Ctl_Error, "No contrlData handle in control");
780 hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
782 _res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID);
783 HUnlock((Handle)hdl);
786 f
= ManualGenerator("GetPopupData", getpopupdata_body
, condition
="#if !TARGET_API_MAC_CARBON")
789 setpopupdata_body
= """
790 PopupPrivateDataHandle hdl;
794 if (!PyArg_ParseTuple(_args, "O&h", MenuObj_Convert, &mHandle, &mID) )
796 if ( (*_self->ob_itself)->contrlData == NULL ) {
797 PyErr_SetString(Ctl_Error, "No contrlData handle in control");
800 hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
801 (*hdl)->mHandle = mHandle;
806 f
= ManualGenerator("SetPopupData", setpopupdata_body
, condition
="#if !TARGET_API_MAC_CARBON")
810 createtabscontrol_body
= """\
818 ControlTabEntry tabArray[MAXTABS];
819 ControlHandle outControl;
820 PyObject *tabArrayObj, *tabEntry;
822 #ifndef CreateTabsControl
823 PyMac_PRECHECK(CreateTabsControl);
825 if (!PyArg_ParseTuple(_args, "O&O&HHO",
826 WinObj_Convert, &window,
827 PyMac_GetRect, &boundsRect,
833 i = PySequence_Length(tabArrayObj);
837 PyErr_SetString(Ctl_Error, "Too many tabs");
841 for (i=0; i<numTabs; i++) {
842 tabEntry = PySequence_GetItem(tabArrayObj, i);
843 if (tabEntry == NULL)
845 if (!PyArg_Parse(tabEntry, "(O&O&B)",
846 ControlButtonContentInfo_Convert, &tabArray[i].icon,
847 CFStringRefObj_Convert, &tabArray[i].name,
853 _err = CreateTabsControl(window,
860 if (_err != noErr) return PyMac_Error(_err);
861 _res = Py_BuildValue("O&",
862 CtlObj_New, outControl);
865 f
= ManualGenerator("CreateTabsControl", createtabscontrol_body
, condition
="#if TARGET_API_MAC_CARBON")
866 f
.docstring
= lambda: "(WindowPtr window, Rect boundsRect, UInt16 size, UInt16 direction, ControlTabEntry tabArray) -> (ControlHandle outControl)"
869 # generate output (open the output file as late as possible)
870 SetOutputFileName(OUTPUTFILE
)