annotate Mac/Modules/ctl/ctlsupport.py @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents 74d1ad61f843
children 53e4b7fe0969
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # This script generates a Python interface for an Apple Macintosh Manager.
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # It uses the "bgen" package to generate C code.
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # The function specifications are generated by scanning the mamager's header file,
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # using the "scantools" package (customized for this particular manager).
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 import string
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # Declarations that change for each manager
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 MACHEADERFILE = 'Controls.h' # The Apple header file
19441
0757098350c2 The MacOS toolbox modules have acquired an _ in front of their name. Normal usage is through a wrapper module (without underscore) which lives in the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18186
diff changeset
10 MODNAME = '_Ctl' # The name of the module
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 OBJECTNAME = 'Control' # The basic name of the objects used here
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 # The following is *usually* unchanged but may still require tuning
19441
0757098350c2 The MacOS toolbox modules have acquired an _ in front of their name. Normal usage is through a wrapper module (without underscore) which lives in the Carbon package.
Jack Jansen <jack.jansen@cwi.nl>
parents: 18186
diff changeset
14 MODPREFIX = 'Ctl' # The prefix for module-wide routines
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 from macsupport import *
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 # Create the type objects
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 ControlHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX)
2720
abf116db523f Trying again to check it in. Changes to:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2267
diff changeset
25 ControlRef = ControlHandle
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 ExistingControlHandle = OpaqueByValueType(OBJECTTYPE, "CtlObj_WhichControl", "BUG")
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
3499
5f25040fd63e Replaced various dummy updateRegions by real arguments
Jack Jansen <jack.jansen@cwi.nl>
parents: 2751
diff changeset
28 RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
6061
36df4434b3b3 Added GetAuxiliaryControlRecord and SetControlColor, there was no good
Jack Jansen <jack.jansen@cwi.nl>
parents: 5269
diff changeset
29 CCTabHandle = OpaqueByValueType("CCTabHandle", "ResObj")
36df4434b3b3 Added GetAuxiliaryControlRecord and SetControlColor, there was no good
Jack Jansen <jack.jansen@cwi.nl>
parents: 5269
diff changeset
30 AuxCtlHandle = OpaqueByValueType("AuxCtlHandle", "ResObj")
2723
a0fc94b3bb21 Ported to Universal Header 2.0.1f (i.e. CW6)
Jack Jansen <jack.jansen@cwi.nl>
parents: 2720
diff changeset
31 ControlPartCode = Type("ControlPartCode", "h")
13398
e8ce1bb056ae Changed all (hopefully) uses of unsigned 16 bit value to use H format specifier, now that h is signed-only.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12855
diff changeset
32 DragConstraint = Type("DragConstraint", "H")
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
33 ControlVariant = Type("ControlVariant", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
34 IconTransformType = Type("IconTransformType", "h")
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
35 EventModifiers = Type("EventModifiers", "H")
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
36 ClickActivationResult = Type("ClickActivationResult", "l")
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
37 ControlButtonGraphicAlignment = Type("ControlButtonGraphicAlignment", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
38 ControlButtonTextAlignment = Type("ControlButtonTextAlignment", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
39 ControlButtonTextPlacement = Type("ControlButtonTextPlacement", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
40 ControlContentType = Type("ControlContentType", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
41 ControlFocusPart = Type("ControlFocusPart", "h")
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
42
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
43 ControlFontStyleRec = OpaqueType('ControlFontStyleRec', 'ControlFontStyle')
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
44 ControlFontStyleRec_ptr = ControlFontStyleRec
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
45 ControlID = OpaqueType('ControlID', 'PyControlID')
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
46 ControlID_ptr = ControlID
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47
15527
041d57e3a2b9 More toolbox modules adapted to Universal Headers 3.3.2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15499
diff changeset
48 DragTrackingMessage = Type("DragTrackingMessage", "h")
041d57e3a2b9 More toolbox modules adapted to Universal Headers 3.3.2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15499
diff changeset
49 DragReference = OpaqueByValueType("DragReference", "DragObj")
041d57e3a2b9 More toolbox modules adapted to Universal Headers 3.3.2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15499
diff changeset
50
21375
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
51 CFStringRef = OpaqueByValueType("CFStringRef", "CFStringRefObj")
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
52 CFMutableStringRef = OpaqueByValueType("CFMutableStringRef", "CFMutableStringRefObj")
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
53 CFDataRef = OpaqueByValueType("CFDataRef", "CFDataRefObj")
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
54
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
55 ControlTabSize = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
56 ControlTabDirection = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
57 ControlPopupArrowOrientation = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
58 ControlPopupArrowSize = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
59 ControlClockType = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
60 ControlClockFlags = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
61 ControlRoundButtonSize = SInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
62 DataBrowserViewStyle = OSType
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
63 DataBrowserItemID = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
64 DataBrowserEditCommand = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
65 DataBrowserSelectionAnchorDirection = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
66 DataBrowserItemState = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
67 DataBrowserPropertyID = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
68 DataBrowserRevealOptions = UInt8
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
69 DataBrowserSortOrder = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
70 DataBrowserSelectionFlags = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
71 DataBrowserPropertyFlags = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
72 DataBrowserPropertyPart = OSType
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
73 DataBrowserTableViewColumnID = DataBrowserPropertyID
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
74 #DataBrowserTableViewColumnDesc = DataBrowserPropertyDesc
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
75 DataBrowserTableViewHiliteStyle = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
76 DataBrowserTableViewRowIndex = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
77 DataBrowserTableViewColumnIndex = UInt32
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
78 DataBrowserPropertyType = OSType
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
79 ControlDisclosureTriangleOrientation = UInt16
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
80
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
81 DataBrowserTableViewColumnDesc = OpaqueType("DataBrowserTableViewColumnDesc",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
82 "DataBrowserTableViewColumnDesc")
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
83 DataBrowserListViewColumnDesc = OpaqueType("DataBrowserListViewColumnDesc",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
84 "DataBrowserListViewColumnDesc")
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
85 ControlButtonContentInfo = OpaqueType("ControlButtonContentInfo",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
86 "ControlButtonContentInfo")
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
87 ControlButtonContentInfoPtr = ControlButtonContentInfo_ptr = ControlButtonContentInfo
21375
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
88
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
89 ControlTabEntry_ptr = OpaqueType("ControlTabEntry", "ControlTabEntry")
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
90
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
91 ControlBevelThickness = UInt16
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
92 ControlBevelButtonBehavior = UInt16
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
93 ControlBevelButtonMenuBehavior = UInt16
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
94 ControlBevelButtonMenuPlacement = UInt16
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
95 ControlPushButtonIconAlignment = UInt16
21375
7e0d2d59bbce Updated for Universal Headers 3.4.
Just van Rossum <just@letterror.com>
parents: 21113
diff changeset
96
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
97 class ControlActionDefinition(Type):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
98 def declare(self, name):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
99 Output("%s %s;", self.typeName, name)
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
100 Output("UniversalProcPtr c_callback;")
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
101 def passInput(self, name):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
102 return "myactionproc_upp"
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
103 def cleanup(self, name):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
104 Output("setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);")
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
105
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
106 class ControlActionDefinitionNewControl(ControlActionDefinition):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
107 def cleanup(self, name):
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
108 Output("setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);")
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
109
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
110 ControlActionUPP = ControlActionDefinition("PyObject*", "O")
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
111 ControlActionUPPNewControl = ControlActionDefinitionNewControl("PyObject*", "O")
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
112 ControlSliderOrientation = UInt16
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
113
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
114
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 includestuff = includestuff + """
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
116 #ifdef WITHOUT_FRAMEWORKS
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
117 #include <Controls.h>
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
118 #include <ControlDefinitions.h>
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
119 #else
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
120 #include <Carbon/Carbon.h>
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
121 #endif
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
122
17848
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
123 #ifdef USE_TOOLBOX_OBJECT_GLUE
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
124 extern PyObject *_CtlObj_New(ControlHandle);
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
125 extern int _CtlObj_Convert(PyObject *, ControlHandle *);
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
126
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
127 #define CtlObj_New _CtlObj_New
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
128 #define CtlObj_Convert _CtlObj_Convert
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
129 #endif
6960b2bbbfca First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15836
diff changeset
130
24575
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
131 static PyObject *CtlObj_WhichControl(ControlHandle);
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
132
10116
49e7e21849b3 Added Ctl.as_Control and Menu.as_Menu methods, which take a resource as
Jack Jansen <jack.jansen@cwi.nl>
parents: 9332
diff changeset
133 #define as_Control(h) ((ControlHandle)h)
11622
65dc082f7004 Unified handle-conversion scheme to
Jack Jansen <jack.jansen@cwi.nl>
parents: 11596
diff changeset
134 #define as_Resource(ctl) ((Handle)ctl)
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12250
diff changeset
135 #define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp)
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
137 #define MAXTABS 32 /* maximum number of tabs that we support in a tabs control */
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
138 /*
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
139 ** Parse/generate ControlFontStyleRec records
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
140 */
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
141 #if 0 /* Not needed */
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
142 static PyObject *
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
143 ControlFontStyle_New(ControlFontStyleRec *itself)
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
144 {
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
145
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
146 return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
147 itself->size, itself->style, itself->mode, itself->just,
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
148 QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
149 }
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
150 #endif
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
151
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
152 static int
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
153 ControlFontStyle_Convert(PyObject *v, ControlFontStyleRec *itself)
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
154 {
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
155 return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
156 &itself->font, &itself->size, &itself->style, &itself->mode,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
157 &itself->just, QdRGB_Convert, &itself->foreColor,
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
158 QdRGB_Convert, &itself->backColor);
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
159 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
160
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
161 /*
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
162 ** Parse/generate ControlID records
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
163 */
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
164 static PyObject *
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
165 PyControlID_New(ControlID *itself)
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
166 {
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
167
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
168 return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
169 }
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
170
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
171 static int
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
172 PyControlID_Convert(PyObject *v, ControlID *itself)
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
173 {
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
174 return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
175 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
176
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
177 /*
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
178 ** generate DataBrowserListViewColumnDesc records
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
179 */
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
180 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
181 DataBrowserTableViewColumnDesc_Convert(PyObject *v, DataBrowserTableViewColumnDesc *itself)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
182 {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
183 return PyArg_Parse(v, "(lO&l)",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
184 &itself->propertyID,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
185 PyMac_GetOSType, &itself->propertyType,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
186 &itself->propertyFlags);
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
187 }
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
188
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
189 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
190 ControlButtonContentInfo_Convert(PyObject *v, ControlButtonContentInfo *itself)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
191 {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
192 return PyArg_Parse(v, "(hO&)",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
193 &itself->contentType,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
194 OptResObj_Convert, &itself->u.iconSuite);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
195 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
196
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
197 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
198 DataBrowserListViewHeaderDesc_Convert(PyObject *v, DataBrowserListViewHeaderDesc *itself)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
199 {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
200 itself->version = kDataBrowserListViewLatestHeaderDesc;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
201 return PyArg_Parse(v, "(HHhO&HO&O&)",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
202 &itself->minimumWidth,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
203 &itself->maximumWidth,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
204 &itself->titleOffset,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
205 CFStringRefObj_Convert, &itself->titleString,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
206 &itself->initialOrder,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
207 ControlFontStyle_Convert, &itself->btnFontStyle,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
208 ControlButtonContentInfo_Convert, &itself->btnContentInfo);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
209 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
210
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
211 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
212 DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc *itself)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
213 {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
214 return PyArg_Parse(v, "(O&O&)",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
215 DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
216 DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
217 }
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
218
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
219 /* TrackControl and HandleControlClick callback support */
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
220 #define kMyControlActionProcTag 'ACTN' /* not an official tag, only for internal use */
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
221 static PyObject *tracker;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
222 static ControlActionUPP mytracker_upp;
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
223 static ControlActionUPP myactionproc_upp;
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
224 static ControlUserPaneKeyDownUPP mykeydownproc_upp;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
225 static ControlUserPaneFocusUPP myfocusproc_upp;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
226 static ControlUserPaneDrawUPP mydrawproc_upp;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
227 static ControlUserPaneIdleUPP myidleproc_upp;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
228 static ControlUserPaneHitTestUPP myhittestproc_upp;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
229 static ControlUserPaneTrackingUPP mytrackingproc_upp;
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
230
24575
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
231 static int settrackfunc(PyObject *); /* forward */
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
232 static void clrtrackfunc(void); /* forward */
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
233 static int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *);
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
234 """
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
235
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
236 finalstuff = finalstuff + """
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
237 static PyObject *
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
238 CtlObj_NewUnmanaged(ControlHandle itself)
10395
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
239 {
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
240 ControlObject *it;
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
241 if (itself == NULL) return PyMac_Error(resNotFound);
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
242 it = PyObject_NEW(ControlObject, &Control_Type);
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
243 if (it == NULL) return NULL;
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
244 it->ob_itself = itself;
12027
f955fbd513ee Added a GetControlRect() method to controls which returns the bounding rectangle. To my surprise this call is missing from the C API...
Jack Jansen <jack.jansen@cwi.nl>
parents: 12024
diff changeset
245 it->ob_callbackdict = NULL;
10395
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
246 return (PyObject *)it;
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
247 }
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
248
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
249 static PyObject *
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
250 CtlObj_WhichControl(ControlHandle c)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
251 {
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
252 PyObject *it;
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
253
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
254 if (c == NULL)
10395
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
255 it = Py_None;
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
256 else {
5269
4e53746e51af Changed [SG]etCRefCon to [SG]etControlReference
Jack Jansen <jack.jansen@cwi.nl>
parents: 4348
diff changeset
257 it = (PyObject *) GetControlReference(c);
10395
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
258 /*
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
259 ** If the refcon is zero or doesn't point back to the Python object
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
260 ** the control is not ours. Return a temporary object.
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
261 */
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
262 if (it == NULL || ((ControlObject *)it)->ob_itself != c)
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
263 return CtlObj_NewUnmanaged(c);
f343329500be If a control has no refcon pointing back to the Python object we create a new
Jack Jansen <jack.jansen@cwi.nl>
parents: 10116
diff changeset
264 }
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
265 Py_INCREF(it);
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
266 return it;
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
267 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
268
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
269 static int
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
270 settrackfunc(PyObject *obj)
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
271 {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
272 if (tracker) {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
273 PyErr_SetString(Ctl_Error, "Tracker function in use");
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
274 return 0;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
275 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
276 tracker = obj;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
277 Py_INCREF(tracker);
19723
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
278 return 1;
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
279 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
280
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
281 static void
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
282 clrtrackfunc(void)
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
283 {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
284 Py_XDECREF(tracker);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
285 tracker = 0;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
286 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
287
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
288 static pascal void
12836
3fe304050434 Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12250
diff changeset
289 mytracker(ControlHandle ctl, short part)
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
290 {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
291 PyObject *args, *rv=0;
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
292
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
293 args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
294 if (args && tracker) {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
295 rv = PyEval_CallObject(tracker, args);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
296 Py_DECREF(args);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
297 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
298 if (rv)
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
299 Py_DECREF(rv);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
300 else {
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
301 PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
302 PyErr_Print();
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
303 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
304 }
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
305
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
306 static int
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
307 setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr *uppp)
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
308 {
13545
1d6630792212 Fiddled declaration/implementation of setcallback() so that it is ansifyable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13398
diff changeset
309 ControlObject *self = (ControlObject *)myself;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
310 char keybuf[9];
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
311
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
312 if ( which == kMyControlActionProcTag )
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
313 *uppp = (UniversalProcPtr)myactionproc_upp;
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
314 else if ( which == kControlUserPaneKeyDownProcTag )
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
315 *uppp = (UniversalProcPtr)mykeydownproc_upp;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
316 else if ( which == kControlUserPaneFocusProcTag )
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
317 *uppp = (UniversalProcPtr)myfocusproc_upp;
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
318 else if ( which == kControlUserPaneDrawProcTag )
12250
0a3cb082c5db Added a few cast to make it 68k-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12041
diff changeset
319 *uppp = (UniversalProcPtr)mydrawproc_upp;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
320 else if ( which == kControlUserPaneIdleProcTag )
12250
0a3cb082c5db Added a few cast to make it 68k-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12041
diff changeset
321 *uppp = (UniversalProcPtr)myidleproc_upp;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
322 else if ( which == kControlUserPaneHitTestProcTag )
12250
0a3cb082c5db Added a few cast to make it 68k-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12041
diff changeset
323 *uppp = (UniversalProcPtr)myhittestproc_upp;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
324 else if ( which == kControlUserPaneTrackingProcTag )
12250
0a3cb082c5db Added a few cast to make it 68k-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12041
diff changeset
325 *uppp = (UniversalProcPtr)mytrackingproc_upp;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
326 else
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
327 return -1;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
328 /* Only now do we test for clearing of the callback: */
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
329 if ( callback == Py_None )
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
330 *uppp = NULL;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
331 /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
332 if ( self->ob_callbackdict == NULL )
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
333 if ( (self->ob_callbackdict = PyDict_New()) == NULL )
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
334 return -1;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
335 /* And store the Python callback */
19723
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
336 sprintf(keybuf, "%x", (unsigned)which);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
337 if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
338 return -1;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
339 return 0;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
340 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
341
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
342 static PyObject *
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
343 callcallback(ControlObject *self, OSType which, PyObject *arglist)
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
344 {
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
345 char keybuf[9];
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
346 PyObject *func, *rv;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
347
19723
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
348 sprintf(keybuf, "%x", (unsigned)which);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
349 if ( self->ob_callbackdict == NULL ||
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
350 (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
21378
116af2f01442 Shut up gcc warning.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21375
diff changeset
351 PySys_WriteStderr("Control callback %x without callback object\\n", (unsigned)which);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
352 return NULL;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
353 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
354 rv = PyEval_CallObject(func, arglist);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
355 if ( rv == NULL ) {
21378
116af2f01442 Shut up gcc warning.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21375
diff changeset
356 PySys_WriteStderr("Exception in control callback %x handler\\n", (unsigned)which);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
357 PyErr_Print();
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
358 }
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
359 return rv;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
360 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
361
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
362 static pascal void
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
363 myactionproc(ControlHandle control, SInt16 part)
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
364 {
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
365 ControlObject *ctl_obj;
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
366 PyObject *arglist, *rv;
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
367
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
368 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
369 arglist = Py_BuildValue("Oh", ctl_obj, part);
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
370 rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
371 Py_XDECREF(arglist);
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
372 Py_XDECREF(rv);
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
373 }
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
374
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
375 static pascal ControlPartCode
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
376 mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
377 {
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
378 ControlObject *ctl_obj;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
379 PyObject *arglist, *rv;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
380 short c_rv = 0;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
381
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
382 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
383 arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
384 rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
385 Py_XDECREF(arglist);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
386 if ( rv )
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
387 if (!PyArg_Parse(rv, "h", &c_rv))
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
388 PyErr_Clear();
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
389 Py_XDECREF(rv);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
390 return (ControlPartCode)c_rv;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
391 }
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
392
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
393 static pascal ControlPartCode
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
394 myfocusproc(ControlHandle control, ControlPartCode part)
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
395 {
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
396 ControlObject *ctl_obj;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
397 PyObject *arglist, *rv;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
398 short c_rv = kControlFocusNoPart;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
399
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
400 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
401 arglist = Py_BuildValue("Oh", ctl_obj, part);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
402 rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
403 Py_XDECREF(arglist);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
404 if ( rv )
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
405 if (!PyArg_Parse(rv, "h", &c_rv))
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
406 PyErr_Clear();
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
407 Py_XDECREF(rv);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
408 return (ControlPartCode)c_rv;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
409 }
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
410
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
411 static pascal void
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
412 mydrawproc(ControlHandle control, SInt16 part)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
413 {
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
414 ControlObject *ctl_obj;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
415 PyObject *arglist, *rv;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
416
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
417 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
418 arglist = Py_BuildValue("Oh", ctl_obj, part);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
419 rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
420 Py_XDECREF(arglist);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
421 Py_XDECREF(rv);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
422 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
423
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
424 static pascal void
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
425 myidleproc(ControlHandle control)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
426 {
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
427 ControlObject *ctl_obj;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
428 PyObject *arglist, *rv;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
429
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
430 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
431 arglist = Py_BuildValue("O", ctl_obj);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
432 rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
433 Py_XDECREF(arglist);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
434 Py_XDECREF(rv);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
435 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
436
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
437 static pascal ControlPartCode
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
438 myhittestproc(ControlHandle control, Point where)
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
439 {
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
440 ControlObject *ctl_obj;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
441 PyObject *arglist, *rv;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
442 short c_rv = -1;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
443
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
444 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
12041
019c34280fc2 Data of type Point is passed by value, not by reference.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12028
diff changeset
445 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
446 rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
447 Py_XDECREF(arglist);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
448 /* Ignore errors, nothing we can do about them */
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
449 if ( rv )
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
450 if (!PyArg_Parse(rv, "h", &c_rv))
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
451 PyErr_Clear();
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
452 Py_XDECREF(rv);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
453 return (ControlPartCode)c_rv;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
454 }
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
455
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
456 static pascal ControlPartCode
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
457 mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc)
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
458 {
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
459 ControlObject *ctl_obj;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
460 PyObject *arglist, *rv;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
461 short c_rv = -1;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
462
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
463 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
464 /* We cannot pass the actionProc without lots of work */
12041
019c34280fc2 Data of type Point is passed by value, not by reference.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12028
diff changeset
465 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
466 rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
467 Py_XDECREF(arglist);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
468 if ( rv )
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
469 if (!PyArg_Parse(rv, "h", &c_rv))
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
470 PyErr_Clear();
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
471 Py_XDECREF(rv);
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
472 return (ControlPartCode)c_rv;
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
473 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
474 """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
475
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
476 initstuff = initstuff + """
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
477 mytracker_upp = NewControlActionUPP(mytracker);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
478 myactionproc_upp = NewControlActionUPP(myactionproc);
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
479 mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
480 myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc);
17924
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
481 mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc);
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
482 myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc);
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
483 myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc);
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
484 mytrackingproc_upp = NewControlUserPaneTrackingUPP(mytrackingproc);
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
485 PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New);
474e3de00b05 Lots more Carbon/Carbon.h includes, new UPP routine names, function prototypes. Most toolbox modules now compile, link and import in MacOSX-MachO python.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17848
diff changeset
486 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
487 """
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
488
26524
7aba859cee54 Added PEP253 support to most Carbon modules. This isn't complete yet:
Jack Jansen <jack.jansen@cwi.nl>
parents: 26464
diff changeset
489 class MyObjectDefinition(PEP253Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
490 def outputStructMembers(self):
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
491 GlobalObjectDefinition.outputStructMembers(self)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
492 Output("PyObject *ob_callbackdict;")
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
493 def outputCheckNewArg(self):
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
494 Output("if (itself == NULL) return PyMac_Error(resNotFound);")
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
495 def outputInitStructMembers(self):
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
496 GlobalObjectDefinition.outputInitStructMembers(self)
5269
4e53746e51af Changed [SG]etCRefCon to [SG]etControlReference
Jack Jansen <jack.jansen@cwi.nl>
parents: 4348
diff changeset
497 Output("SetControlReference(itself, (long)it);")
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
498 Output("it->ob_callbackdict = NULL;")
3516
7879f3b39606 Fixed a nasty bug where FindControl could return a reference to a
Jack Jansen <jack.jansen@cwi.nl>
parents: 3499
diff changeset
499 def outputCleanupStructMembers(self):
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
500 Output("Py_XDECREF(self->ob_callbackdict);")
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
501 Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
502
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
503 # Create the generator groups and link them
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
504 module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
505 object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
506 module.addobject(object)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
507
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
508 # Create the generator classes used to populate the lists
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 19723
diff changeset
509 Function = OSErrWeakLinkFunctionGenerator
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 19723
diff changeset
510 Method = OSErrWeakLinkMethodGenerator
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
511
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
512 # Create and populate the lists
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
513 functions = []
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
514 methods = []
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
515 execfile(INPUTFILE)
2751
ae64003b2a75 Added as_Resource() method to convert ctl object to res object
Jack Jansen <jack.jansen@cwi.nl>
parents: 2723
diff changeset
516 execfile('ctledit.py')
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
517
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
518 # add the populated lists to the generator groups
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
519 for f in functions: module.add(f)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
520 for f in methods: object.add(f)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
521
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
522 # Manual generator for TrackControl, due to callback ideosyncracies
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
523 trackcontrol_body = """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
524 ControlPartCode _rv;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
525 Point startPoint;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
526 ControlActionUPP upp = 0;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
527 PyObject *callback = 0;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
528
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
529 if (!PyArg_ParseTuple(_args, "O&|O",
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
530 PyMac_GetPoint, &startPoint, &callback))
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
531 return NULL;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
532 if (callback && callback != Py_None) {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
533 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
534 upp = (ControlActionUPP)-1;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
535 else {
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
536 settrackfunc(callback);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
537 upp = mytracker_upp;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
538 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
539 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
540 _rv = TrackControl(_self->ob_itself,
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
541 startPoint,
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
542 upp);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
543 clrtrackfunc();
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
544 _res = Py_BuildValue("h",
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
545 _rv);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
546 return _res;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
547 """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
548
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
549 f = ManualGenerator("TrackControl", trackcontrol_body);
11536
b3e55ce0ebd7 Fixed a linebreak I forgot, added docstrings, (temporarily) blacklisted a few routines that seem to be missing in my CW Pro 5.1.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11531
diff changeset
550 f.docstring = lambda: "(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
551 object.add(f)
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
552
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
553 # CJW - added 5/12/99
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
554 # Manual generator for HandleControlClick, as for TrackControl
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
555 handlecontrolclick_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
556 ControlPartCode _rv;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
557 Point startPoint;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
558 SInt16 modifiers;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
559 ControlActionUPP upp = 0;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
560 PyObject *callback = 0;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
561
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
562 if (!PyArg_ParseTuple(_args, "O&h|O",
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
563 PyMac_GetPoint, &startPoint,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
564 &modifiers,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
565 &callback))
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
566 return NULL;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
567 if (callback && callback != Py_None) {
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
568 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
569 upp = (ControlActionUPP)-1;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
570 else {
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
571 settrackfunc(callback);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
572 upp = mytracker_upp;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
573 }
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
574 }
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
575 _rv = HandleControlClick(_self->ob_itself,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
576 startPoint,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
577 modifiers,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
578 upp);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
579 clrtrackfunc();
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
580 _res = Py_BuildValue("h",
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
581 _rv);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
582 return _res;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
583 """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
584
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
585 f = ManualGenerator("HandleControlClick", handlecontrolclick_body);
11536
b3e55ce0ebd7 Fixed a linebreak I forgot, added docstrings, (temporarily) blacklisted a few routines that seem to be missing in my CW Pro 5.1.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11531
diff changeset
586 f.docstring = lambda: "(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
587 object.add(f)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
588
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
589 # Manual Generator for SetControlData
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
590 setcontroldata_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
591 OSErr _err;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
592 ControlPartCode inPart;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
593 ResType inTagName;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
594 Size bufferSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
595 Ptr buffer;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
596
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
597 if (!PyArg_ParseTuple(_args, "hO&s#",
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
598 &inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
599 PyMac_GetOSType, &inTagName,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
600 &buffer, &bufferSize))
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
601 return NULL;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
602
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
603 _err = SetControlData(_self->ob_itself,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
604 inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
605 inTagName,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
606 bufferSize,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
607 buffer);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
608
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
609 if (_err != noErr)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
610 return PyMac_Error(_err);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
611 _res = Py_None;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
612 return _res;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
613 """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
614
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
615 f = ManualGenerator("SetControlData", setcontroldata_body);
11536
b3e55ce0ebd7 Fixed a linebreak I forgot, added docstrings, (temporarily) blacklisted a few routines that seem to be missing in my CW Pro 5.1.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11531
diff changeset
616 f.docstring = lambda: "(stuff) -> None"
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
617 object.add(f)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
618
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
619 # Manual Generator for GetControlData
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
620 getcontroldata_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
621 OSErr _err;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
622 ControlPartCode inPart;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
623 ResType inTagName;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
624 Size bufferSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
625 Ptr buffer;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
626 Size outSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
627
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
628 if (!PyArg_ParseTuple(_args, "hO&",
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
629 &inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
630 PyMac_GetOSType, &inTagName))
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
631 return NULL;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
632
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
633 /* allocate a buffer for the data */
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
634 _err = GetControlDataSize(_self->ob_itself,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
635 inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
636 inTagName,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
637 &bufferSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
638 if (_err != noErr)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
639 return PyMac_Error(_err);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
640 buffer = PyMem_NEW(char, bufferSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
641 if (buffer == NULL)
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
642 return PyErr_NoMemory();
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
643
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
644 _err = GetControlData(_self->ob_itself,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
645 inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
646 inTagName,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
647 bufferSize,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
648 buffer,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
649 &outSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
650
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
651 if (_err != noErr) {
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
652 PyMem_DEL(buffer);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
653 return PyMac_Error(_err);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
654 }
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
655 _res = Py_BuildValue("s#", buffer, outSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
656 PyMem_DEL(buffer);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
657 return _res;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
658 """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
659
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
660 f = ManualGenerator("GetControlData", getcontroldata_body);
11536
b3e55ce0ebd7 Fixed a linebreak I forgot, added docstrings, (temporarily) blacklisted a few routines that seem to be missing in my CW Pro 5.1.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11531
diff changeset
661 f.docstring = lambda: "(part, type) -> String"
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
662 object.add(f)
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
663
15783
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
664 # Manual Generator for SetControlData_Handle
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
665 setcontroldata_handle_body = """
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
666 OSErr _err;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
667 ControlPartCode inPart;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
668 ResType inTagName;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
669 Handle buffer;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
670
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
671 if (!PyArg_ParseTuple(_args, "hO&O&",
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
672 &inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
673 PyMac_GetOSType, &inTagName,
11634
817589156f21 Oops, forgot & in ParseTuple argument in ControlGetDataHandle.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11622
diff changeset
674 OptResObj_Convert, &buffer))
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
675 return NULL;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
676
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
677 _err = SetControlData(_self->ob_itself,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
678 inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
679 inTagName,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
680 sizeof(buffer),
11638
a94c296a6fcc Nasty error: handle parameters are passed by _address_ to SetControlData.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11634
diff changeset
681 (Ptr)&buffer);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
682
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
683 if (_err != noErr)
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
684 return PyMac_Error(_err);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
685 _res = Py_None;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
686 return _res;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
687 """
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
688
15783
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
689 f = ManualGenerator("SetControlData_Handle", setcontroldata_handle_body);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
690 f.docstring = lambda: "(ResObj) -> None"
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
691 object.add(f)
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
692
15783
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
693 # Manual Generator for GetControlData_Handle
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
694 getcontroldata_handle_body = """
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
695 OSErr _err;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
696 ControlPartCode inPart;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
697 ResType inTagName;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
698 Size bufferSize;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
699 Handle hdl;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
700
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
701 if (!PyArg_ParseTuple(_args, "hO&",
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
702 &inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
703 PyMac_GetOSType, &inTagName))
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
704 return NULL;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
705
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
706 /* Check it is handle-sized */
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
707 _err = GetControlDataSize(_self->ob_itself,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
708 inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
709 inTagName,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
710 &bufferSize);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
711 if (_err != noErr)
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
712 return PyMac_Error(_err);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
713 if (bufferSize != sizeof(Handle)) {
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
714 PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
715 return NULL;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
716 }
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
717
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
718 _err = GetControlData(_self->ob_itself,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
719 inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
720 inTagName,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
721 sizeof(Handle),
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
722 (Ptr)&hdl,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
723 &bufferSize);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
724
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
725 if (_err != noErr) {
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
726 return PyMac_Error(_err);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
727 }
19723
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
728 _res = Py_BuildValue("O&", OptResObj_New, hdl);
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
729 return _res;
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
730 """
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
731
15783
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
732 f = ManualGenerator("GetControlData_Handle", getcontroldata_handle_body);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
733 f.docstring = lambda: "(part, type) -> ResObj"
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
734 object.add(f)
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
735
15783
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
736 # Manual Generator for SetControlData_Callback
fca2cf850e4a Carbon defines {Get,Set}ControlDataHandle, so unfortunately our variants on {Get,Set}ControlData have gotten an underscore: GetControlData_Handle, etc. This is an incompatible change:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 15527
diff changeset
737 setcontroldata_callback_body = """
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
738 OSErr _err;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
739 ControlPartCode inPart;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
740 ResType inTagName;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
741 PyObject *callback;
13545
1d6630792212 Fiddled declaration/implementation of setcallback() so that it is ansifyable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13398
diff changeset
742 UniversalProcPtr c_callback;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
743
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
744 if (!PyArg_ParseTuple(_args, "hO&O",
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
745 &inPart,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
746 PyMac_GetOSType, &inTagName,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
747 &callback))
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
748 return NULL;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
749
13545
1d6630792212 Fiddled declaration/implementation of setcallback() so that it is ansifyable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13398
diff changeset
750 if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
751 return NULL;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
752 _err = SetControlData(_self->ob_itself,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
753 inPart,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
754 inTagName,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
755 sizeof(c_callback),
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
756 (Ptr)&c_callback);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
757
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
758 if (_err != noErr)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
759 return PyMac_Error(_err);
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
760 _res = Py_None;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
761 return _res;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
762 """
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
763
15836
0e4f48c5fc84 SetpopupData and GetPopupData are gone under Carbon, use {Get,Set}PopupMenu{Handle,ID} in stead.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15783
diff changeset
764 f = ManualGenerator("SetControlData_Callback", setcontroldata_callback_body);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
765 f.docstring = lambda: "(callbackfunc) -> None"
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
766 object.add(f)
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
767
8527
5f1e431a0a82 Added {Get,Set}PopupData calls to get at the data for popup menu controls.
Jack Jansen <jack.jansen@cwi.nl>
parents: 8435
diff changeset
768
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
769
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
770 createtabscontrol_body = """\
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
771 OSStatus _err;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
772 WindowPtr window;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
773 Rect boundsRect;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
774 UInt16 size;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
775 UInt16 direction;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
776 int i;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
777 UInt16 numTabs;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
778 ControlTabEntry tabArray[MAXTABS];
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
779 ControlHandle outControl;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
780 PyObject *tabArrayObj, *tabEntry;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
781
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
782 #ifndef CreateTabsControl
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
783 PyMac_PRECHECK(CreateTabsControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
784 #endif
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
785 if (!PyArg_ParseTuple(_args, "O&O&HHO",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
786 WinObj_Convert, &window,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
787 PyMac_GetRect, &boundsRect,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
788 &size,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
789 &direction,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
790 &tabArrayObj))
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
791 return NULL;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
792
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
793 i = PySequence_Length(tabArrayObj);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
794 if (i == -1)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
795 return NULL;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
796 if (i > MAXTABS) {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
797 PyErr_SetString(Ctl_Error, "Too many tabs");
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
798 return NULL;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
799 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
800 numTabs = i;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
801 for (i=0; i<numTabs; i++) {
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
802 tabEntry = PySequence_GetItem(tabArrayObj, i);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
803 if (tabEntry == NULL)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
804 return NULL;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
805 if (!PyArg_Parse(tabEntry, "(O&O&B)",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
806 ControlButtonContentInfo_Convert, &tabArray[i].icon,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
807 CFStringRefObj_Convert, &tabArray[i].name,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
808 &tabArray[i].enabled
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
809 ))
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
810 return NULL;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
811 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
812
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
813 _err = CreateTabsControl(window,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
814 &boundsRect,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
815 size,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
816 direction,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
817 numTabs,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
818 tabArray,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
819 &outControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
820 if (_err != noErr) return PyMac_Error(_err);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
821 _res = Py_BuildValue("O&",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
822 CtlObj_New, outControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
823 return _res;"""
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
824
26610
74d1ad61f843 Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents: 26524
diff changeset
825 f = ManualGenerator("CreateTabsControl", createtabscontrol_body)
21462
664ac8227cc5 Added missing docstring
Just van Rossum <just@letterror.com>
parents: 21461
diff changeset
826 f.docstring = lambda: "(WindowPtr window, Rect boundsRect, UInt16 size, UInt16 direction, ControlTabEntry tabArray) -> (ControlHandle outControl)"
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
827 module.add(f)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
828
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 # generate output (open the output file as late as possible)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
830 SetOutputFileName(OUTPUTFILE)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
831 module.generate()