annotate Mac/Modules/ctl/ctlsupport.py @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents c3a096bfbd6b
children ac192f89c109
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
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
9 MACHEADERFILE = 'Controls.h' # The Apple header file
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
10 MODNAME = '_Ctl' # The name of the module
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
11 OBJECTNAME = 'Control' # The basic name of the objects used here
2267
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
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
14 MODPREFIX = 'Ctl' # The prefix for module-wide routines
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
15 OBJECTTYPE = OBJECTNAME + 'Handle' # The C type used to represent them
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
16 OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
2267
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
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
18 OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
2267
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",
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
82 "DataBrowserTableViewColumnDesc")
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
83 DataBrowserListViewColumnDesc = OpaqueType("DataBrowserListViewColumnDesc",
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
84 "DataBrowserListViewColumnDesc")
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
85 ControlButtonContentInfo = OpaqueType("ControlButtonContentInfo",
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
86 "ControlButtonContentInfo")
21461
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):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
98 def declare(self, name):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
99 Output("%s %s;", self.typeName, name)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
100 Output("UniversalProcPtr c_callback;")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
101 def passInput(self, name):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
102 return "myactionproc_upp"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
103 def cleanup(self, name):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
104 Output("setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);")
21597
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):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
107 def cleanup(self, name):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
108 Output("setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);")
21597
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 #include <Carbon/Carbon.h>
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
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
118 #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
119 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
120 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
121
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
122 #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
123 #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
124 #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
125
24575
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
126 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
127
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
128 #define as_Control(h) ((ControlHandle)h)
11622
65dc082f7004 Unified handle-conversion scheme to
Jack Jansen <jack.jansen@cwi.nl>
parents: 11596
diff changeset
129 #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
130 #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
131
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
132 #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
133 /*
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
134 ** 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
135 */
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
136 #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
137 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
138 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
139 {
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
140
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
141 return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
142 itself->size, itself->style, itself->mode, itself->just,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
143 QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
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 #endif
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
146
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
147 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
148 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
149 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
150 return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
151 &itself->font, &itself->size, &itself->style, &itself->mode,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
152 &itself->just, QdRGB_Convert, &itself->foreColor,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
153 QdRGB_Convert, &itself->backColor);
7437
3740ff2ee053 Regenerated from Universal Headers 3.0.1. Some new calls are
Jack Jansen <jack.jansen@cwi.nl>
parents: 6061
diff changeset
154 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
155
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
156 /*
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
157 ** 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
158 */
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
159 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
160 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
161 {
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
162
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
163 return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
164 }
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
165
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
166 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
167 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
168 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
169 return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
170 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
171
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
172 /*
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
173 ** generate DataBrowserListViewColumnDesc records
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
174 */
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
175 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
176 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
177 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
178 return PyArg_Parse(v, "(lO&l)",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
179 &itself->propertyID,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
180 PyMac_GetOSType, &itself->propertyType,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
181 &itself->propertyFlags);
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
182 }
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
183
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
184 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
185 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
186 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
187 return PyArg_Parse(v, "(hO&)",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
188 &itself->contentType,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
189 OptResObj_Convert, &itself->u.iconSuite);
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
190 }
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 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
193 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
194 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
195 itself->version = kDataBrowserListViewLatestHeaderDesc;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
196 return PyArg_Parse(v, "(HHhO&HO&O&)",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
197 &itself->minimumWidth,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
198 &itself->maximumWidth,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
199 &itself->titleOffset,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
200 CFStringRefObj_Convert, &itself->titleString,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
201 &itself->initialOrder,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
202 ControlFontStyle_Convert, &itself->btnFontStyle,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
203 ControlButtonContentInfo_Convert, &itself->btnContentInfo);
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
204 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
205
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
206 static int
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
207 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
208 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
209 return PyArg_Parse(v, "(O&O&)",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
210 DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
211 DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
212 }
15499
8be889e8115b Adapted to Universal Headers 3.3.2. More to follow.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
213
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
214 /* 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
215 #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
216 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
217 static ControlActionUPP mytracker_upp;
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
218 static ControlActionUPP myactionproc_upp;
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
219 static ControlUserPaneKeyDownUPP mykeydownproc_upp;
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
220 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
221 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
222 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
223 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
224 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
225
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
226 static int settrackfunc(PyObject *); /* forward */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
227 static void clrtrackfunc(void); /* forward */
24575
920ad09930dc Got rid of staticforward.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21635
diff changeset
228 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
229 """
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
230
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 finalstuff = finalstuff + """
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
232 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
233 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
234 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
235 ControlObject *it;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
236 if (itself == NULL) return PyMac_Error(resNotFound);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
237 it = PyObject_NEW(ControlObject, &Control_Type);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
238 if (it == NULL) return NULL;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
239 it->ob_itself = itself;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
240 it->ob_callbackdict = NULL;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
241 return (PyObject *)it;
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
242 }
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
13606
c9a4a1316170 pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents: 13545
diff changeset
244 static PyObject *
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
245 CtlObj_WhichControl(ControlHandle c)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
246 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
247 PyObject *it;
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
248
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
249 if (c == NULL)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
250 it = Py_None;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
251 else {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
252 it = (PyObject *) GetControlReference(c);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
253 /*
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
254 ** If the refcon is zero or doesn't point back to the Python object
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
255 ** the control is not ours. Return a temporary object.
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
256 */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
257 if (it == NULL || ((ControlObject *)it)->ob_itself != c)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
258 return CtlObj_NewUnmanaged(c);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
259 }
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
260 Py_INCREF(it);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
261 return it;
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
262 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
263
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
264 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
265 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
266 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
267 if (tracker) {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
268 PyErr_SetString(Ctl_Error, "Tracker function in use");
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
269 return 0;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
270 }
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
271 tracker = obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
272 Py_INCREF(tracker);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
273 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
274 }
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 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
277 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
278 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
279 Py_XDECREF(tracker);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
280 tracker = 0;
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
281 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
282
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
283 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
284 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
285 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
286 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
287
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
288 args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
289 if (args && tracker) {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
290 rv = PyEval_CallObject(tracker, args);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
291 Py_DECREF(args);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
292 }
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
293 if (rv)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
294 Py_DECREF(rv);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
295 else {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
296 PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\\n");
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
297 PyErr_Print();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
298 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
299 }
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
300
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
301 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
302 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
303 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
304 ControlObject *self = (ControlObject *)myself;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
305 char keybuf[9];
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
306
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
307 if ( which == kMyControlActionProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
308 *uppp = (UniversalProcPtr)myactionproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
309 else if ( which == kControlUserPaneKeyDownProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
310 *uppp = (UniversalProcPtr)mykeydownproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
311 else if ( which == kControlUserPaneFocusProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
312 *uppp = (UniversalProcPtr)myfocusproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
313 else if ( which == kControlUserPaneDrawProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
314 *uppp = (UniversalProcPtr)mydrawproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
315 else if ( which == kControlUserPaneIdleProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
316 *uppp = (UniversalProcPtr)myidleproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
317 else if ( which == kControlUserPaneHitTestProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
318 *uppp = (UniversalProcPtr)myhittestproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
319 else if ( which == kControlUserPaneTrackingProcTag )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
320 *uppp = (UniversalProcPtr)mytrackingproc_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
321 else
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
322 return -1;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
323 /* Only now do we test for clearing of the callback: */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
324 if ( callback == Py_None )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
325 *uppp = NULL;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
326 /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
327 if ( self->ob_callbackdict == NULL )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
328 if ( (self->ob_callbackdict = PyDict_New()) == NULL )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
329 return -1;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
330 /* And store the Python callback */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
331 sprintf(keybuf, "%x", (unsigned)which);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
332 if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
333 return -1;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
334 return 0;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
335 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
336
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
337 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
338 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
339 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
340 char keybuf[9];
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
341 PyObject *func, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
342
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
343 sprintf(keybuf, "%x", (unsigned)which);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
344 if ( self->ob_callbackdict == NULL ||
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
345 (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
346 PySys_WriteStderr("Control callback %x without callback object\\n", (unsigned)which);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
347 return NULL;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
348 }
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
349 rv = PyEval_CallObject(func, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
350 if ( rv == NULL ) {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
351 PySys_WriteStderr("Exception in control callback %x handler\\n", (unsigned)which);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
352 PyErr_Print();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
353 }
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
354 return rv;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
355 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
356
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
357 static pascal void
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
358 myactionproc(ControlHandle control, SInt16 part)
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
359 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
360 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
361 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
362
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
363 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
364 arglist = Py_BuildValue("Oh", ctl_obj, part);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
365 rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
366 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
367 Py_XDECREF(rv);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
368 }
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
369
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
370 static pascal ControlPartCode
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
371 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
372 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
373 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
374 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
375 short c_rv = 0;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
376
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
377 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
378 arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
379 rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
380 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
381 if ( rv )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
382 if (!PyArg_Parse(rv, "h", &c_rv))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
383 PyErr_Clear();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
384 Py_XDECREF(rv);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
385 return (ControlPartCode)c_rv;
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
386 }
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
387
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
388 static pascal ControlPartCode
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
389 myfocusproc(ControlHandle control, ControlPartCode part)
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
390 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
391 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
392 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
393 short c_rv = kControlFocusNoPart;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
394
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
395 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
396 arglist = Py_BuildValue("Oh", ctl_obj, part);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
397 rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
398 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
399 if ( rv )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
400 if (!PyArg_Parse(rv, "h", &c_rv))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
401 PyErr_Clear();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
402 Py_XDECREF(rv);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
403 return (ControlPartCode)c_rv;
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
404 }
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
405
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
406 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
407 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
408 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
409 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
410 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
411
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
412 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
413 arglist = Py_BuildValue("Oh", ctl_obj, part);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
414 rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
415 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
416 Py_XDECREF(rv);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
417 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
418
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
419 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
420 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
421 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
422 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
423 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
424
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
425 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
426 arglist = Py_BuildValue("O", ctl_obj);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
427 rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
428 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
429 Py_XDECREF(rv);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
430 }
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
431
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
432 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
433 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
434 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
435 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
436 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
437 short c_rv = -1;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
438
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
439 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
440 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
441 rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
442 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
443 /* Ignore errors, nothing we can do about them */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
444 if ( rv )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
445 if (!PyArg_Parse(rv, "h", &c_rv))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
446 PyErr_Clear();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
447 Py_XDECREF(rv);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
448 return (ControlPartCode)c_rv;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
449 }
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
450
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
451 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
452 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
453 {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
454 ControlObject *ctl_obj;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
455 PyObject *arglist, *rv;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
456 short c_rv = -1;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
457
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
458 ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
459 /* We cannot pass the actionProc without lots of work */
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
460 arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
461 rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
462 Py_XDECREF(arglist);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
463 if ( rv )
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
464 if (!PyArg_Parse(rv, "h", &c_rv))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
465 PyErr_Clear();
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
466 Py_XDECREF(rv);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
467 return (ControlPartCode)c_rv;
12028
6e7ec9a00cce Added UserPane callbacks for HitTest and Tracking. Doesn't fully work yet.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12027
diff changeset
468 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
469 """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
470
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
471 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
472 mytracker_upp = NewControlActionUPP(mytracker);
21597
8578355d23d3 - added support for ControlActionProcs, exposing the following calls:
Just van Rossum <just@letterror.com>
parents: 21462
diff changeset
473 myactionproc_upp = NewControlActionUPP(myactionproc);
21635
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
474 mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
6ae85d838466 - added support for UserPaneKeyDownProc and UserPaneFocusProc
Just van Rossum <just@letterror.com>
parents: 21597
diff changeset
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 """
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
483
26524
7aba859cee54 Added PEP253 support to most Carbon modules. This isn't complete yet:
Jack Jansen <jack.jansen@cwi.nl>
parents: 26464
diff changeset
484 class MyObjectDefinition(PEP253Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
485 def outputStructMembers(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
486 GlobalObjectDefinition.outputStructMembers(self)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
487 Output("PyObject *ob_callbackdict;")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
488 def outputCheckNewArg(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
489 Output("if (itself == NULL) return PyMac_Error(resNotFound);")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
490 def outputInitStructMembers(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
491 GlobalObjectDefinition.outputInitStructMembers(self)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
492 Output("SetControlReference(itself, (long)it);")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
493 Output("it->ob_callbackdict = NULL;")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
494 def outputCleanupStructMembers(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
495 Output("Py_XDECREF(self->ob_callbackdict);")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
496 Output("if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */")
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
497
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
498 # Create the generator groups and link them
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
499 module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
500 object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
501 module.addobject(object)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
502
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
503 # 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
504 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
505 Method = OSErrWeakLinkMethodGenerator
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
506
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
507 # Create and populate the lists
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
508 functions = []
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
509 methods = []
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
510 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
511 execfile('ctledit.py')
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
512
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
513 # 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
514 for f in functions: module.add(f)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
515 for f in methods: object.add(f)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
516
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
517 # 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
518 trackcontrol_body = """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
519 ControlPartCode _rv;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
520 Point startPoint;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
521 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
522 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
523
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
524 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
525 PyMac_GetPoint, &startPoint, &callback))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
526 return NULL;
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
527 if (callback && callback != Py_None) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
528 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
529 upp = (ControlActionUPP)-1;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
530 else {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
531 settrackfunc(callback);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
532 upp = mytracker_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
533 }
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
534 }
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
535 _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
536 startPoint,
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
537 upp);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
538 clrtrackfunc();
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
539 _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
540 _rv);
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
541 return _res;
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
542 """
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
543
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
544 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
545 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
546 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
547
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
548 # 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
549 # 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
550 handlecontrolclick_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
551 ControlPartCode _rv;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
552 Point startPoint;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
553 SInt16 modifiers;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
554 ControlActionUPP upp = 0;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
555 PyObject *callback = 0;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
556
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
557 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
558 PyMac_GetPoint, &startPoint,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
559 &modifiers,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
560 &callback))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
561 return NULL;
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
562 if (callback && callback != Py_None) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
563 if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
564 upp = (ControlActionUPP)-1;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
565 else {
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
566 settrackfunc(callback);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
567 upp = mytracker_upp;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
568 }
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
569 }
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
570 _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
571 startPoint,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
572 modifiers,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
573 upp);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
574 clrtrackfunc();
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
575 _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
576 _rv);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
577 return _res;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
578 """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
579
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
580 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
581 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
582 object.add(f)
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 # 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
585 setcontroldata_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
586 OSErr _err;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
587 ControlPartCode inPart;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
588 ResType inTagName;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
589 Size bufferSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
590 Ptr buffer;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
591
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
592 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
593 &inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
594 PyMac_GetOSType, &inTagName,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
595 &buffer, &bufferSize))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
596 return NULL;
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
597
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
598 _err = SetControlData(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
599 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
600 inTagName,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
601 bufferSize,
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
602 buffer);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
603
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
604 if (_err != noErr)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
605 return PyMac_Error(_err);
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
606 _res = Py_None;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
607 return _res;
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
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
610 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
611 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
612 object.add(f)
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 # 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
615 getcontroldata_body = """
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
616 OSErr _err;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
617 ControlPartCode inPart;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
618 ResType inTagName;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
619 Size bufferSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
620 Ptr buffer;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
621 Size outSize;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
622
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
623 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
624 &inPart,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
625 PyMac_GetOSType, &inTagName))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
626 return NULL;
11531
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 /* 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
629 _err = GetControlDataSize(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
630 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
631 inTagName,
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
632 &bufferSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
633 if (_err != noErr)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
634 return PyMac_Error(_err);
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
635 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
636 if (buffer == NULL)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
637 return PyErr_NoMemory();
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
638
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
639 _err = GetControlData(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
640 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
641 inTagName,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
642 bufferSize,
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
643 buffer,
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
644 &outSize);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
645
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
646 if (_err != noErr) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
647 PyMem_DEL(buffer);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
648 return PyMac_Error(_err);
11531
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
649 }
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
650 _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
651 PyMem_DEL(buffer);
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
652 return _res;
8cfcd273fa5c Changes by Corran Webster to support {Get,Set}ControlData and
Jack Jansen <jack.jansen@cwi.nl>
parents: 10395
diff changeset
653 """
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 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
656 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
657 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
658
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
659 # 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
660 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
661 OSErr _err;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
662 ControlPartCode inPart;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
663 ResType inTagName;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
664 Handle buffer;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
665
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
666 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
667 &inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
668 PyMac_GetOSType, &inTagName,
11634
817589156f21 Oops, forgot & in ParseTuple argument in ControlGetDataHandle.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11622
diff changeset
669 OptResObj_Convert, &buffer))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
670 return NULL;
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
671
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
672 _err = SetControlData(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
673 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
674 inTagName,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
675 sizeof(buffer),
11638
a94c296a6fcc Nasty error: handle parameters are passed by _address_ to SetControlData.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11634
diff changeset
676 (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
677
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
678 if (_err != noErr)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
679 return PyMac_Error(_err);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
680 _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
681 return _res;
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
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
684 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
685 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
686 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
687
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
688 # 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
689 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
690 OSErr _err;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
691 ControlPartCode inPart;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
692 ResType inTagName;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
693 Size bufferSize;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
694 Handle hdl;
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
695
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
696 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
697 &inPart,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
698 PyMac_GetOSType, &inTagName))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
699 return NULL;
11596
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 /* 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
702 _err = GetControlDataSize(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
703 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
704 inTagName,
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
705 &bufferSize);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
706 if (_err != noErr)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
707 return PyMac_Error(_err);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
708 if (bufferSize != sizeof(Handle)) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
709 PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
710 return NULL;
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
711 }
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
712
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
713 _err = GetControlData(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
714 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
715 inTagName,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
716 sizeof(Handle),
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
717 (Ptr)&hdl,
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
718 &bufferSize);
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
719
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
720 if (_err != noErr) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
721 return PyMac_Error(_err);
11596
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
722 }
19723
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
723 _res = Py_BuildValue("O&", OptResObj_New, hdl);
2a9bbdbefbb1 Shut up many more gcc warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19441
diff changeset
724 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
725 """
15e5bd89395a Added {Get,Set}ControlDataHandle methods. These are {Get,Set}ControlData for
Jack Jansen <jack.jansen@cwi.nl>
parents: 11536
diff changeset
726
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
727 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
728 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
729 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
730
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
731 # 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
732 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
733 OSErr _err;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
734 ControlPartCode inPart;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
735 ResType inTagName;
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
736 PyObject *callback;
13545
1d6630792212 Fiddled declaration/implementation of setcallback() so that it is ansifyable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13398
diff changeset
737 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
738
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
739 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
740 &inPart,
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
741 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
742 &callback))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
743 return NULL;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
744
13545
1d6630792212 Fiddled declaration/implementation of setcallback() so that it is ansifyable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13398
diff changeset
745 if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
746 return NULL;
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
747 _err = SetControlData(_self->ob_itself,
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
748 inPart,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
749 inTagName,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
750 sizeof(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
751 (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
752
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
753 if (_err != noErr)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
754 return PyMac_Error(_err);
12024
25d3dd0b1ca2 Started on support for callbacks for UserPane controls. Unfinished and untested.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11638
diff changeset
755 _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
756 return _res;
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
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
759 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
760 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
761 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
762
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
763
8435
78eb40f03284 Allow an (optional) tracking function (or -1) to be specified to
Jack Jansen <jack.jansen@cwi.nl>
parents: 8083
diff changeset
764
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
765 createtabscontrol_body = """\
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
766 OSStatus _err;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
767 WindowPtr window;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
768 Rect boundsRect;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
769 UInt16 size;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
770 UInt16 direction;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
771 int i;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
772 UInt16 numTabs;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
773 ControlTabEntry tabArray[MAXTABS];
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
774 ControlHandle outControl;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
775 PyObject *tabArrayObj, *tabEntry;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
776
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
777 #ifndef CreateTabsControl
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
778 PyMac_PRECHECK(CreateTabsControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
779 #endif
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
780 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
781 WinObj_Convert, &window,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
782 PyMac_GetRect, &boundsRect,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
783 &size,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
784 &direction,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
785 &tabArrayObj))
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
786 return NULL;
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
787
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
788 i = PySequence_Length(tabArrayObj);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
789 if (i == -1)
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
790 return NULL;
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
791 if (i > MAXTABS) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
792 PyErr_SetString(Ctl_Error, "Too many tabs");
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
793 return NULL;
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
794 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
795 numTabs = i;
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
796 for (i=0; i<numTabs; i++) {
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
797 tabEntry = PySequence_GetItem(tabArrayObj, i);
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
798 if (tabEntry == NULL)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
799 return NULL;
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
800 if (!PyArg_Parse(tabEntry, "(O&O&B)",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
801 ControlButtonContentInfo_Convert, &tabArray[i].icon,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
802 CFStringRefObj_Convert, &tabArray[i].name,
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
803 &tabArray[i].enabled
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
804 ))
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30973
diff changeset
805 return NULL;
21461
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
806 }
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
807
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
808 _err = CreateTabsControl(window,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
809 &boundsRect,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
810 size,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
811 direction,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
812 numTabs,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
813 tabArray,
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
814 &outControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
815 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
816 _res = Py_BuildValue("O&",
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
817 CtlObj_New, outControl);
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
818 return _res;"""
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
819
26610
74d1ad61f843 Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents: 26524
diff changeset
820 f = ManualGenerator("CreateTabsControl", createtabscontrol_body)
21462
664ac8227cc5 Added missing docstring
Just van Rossum <just@letterror.com>
parents: 21461
diff changeset
821 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
822 module.add(f)
3303f2d92cef Added support for tab controls and initial (incomplete) support
Just van Rossum <just@letterror.com>
parents: 21378
diff changeset
823
2267
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
824 # 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
825 SetOutputFileName(OUTPUTFILE)
7411b6a06920 Committed a more or less working version.
Guido van Rossum <guido@python.org>
parents:
diff changeset
826 module.generate()