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