1
# Scan <Controls.h>, generating ctlgen.py.
3
from bgenlocations import TOOLBOXDIR, BGENDIR
4
sys.path.append(BGENDIR)
6
from scantools import Scanner
9
# input = "Controls.h" # Universal Headers < 3.3
10
input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
12
defsoutput = TOOLBOXDIR + "Controls.py"
13
scanner = MyScanner(input, output, defsoutput)
16
print "=== Testing definitions output code ==="
17
execfile(defsoutput, {}, {})
18
print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
20
print "=== Done. It's up to you to compile Ctlmodule.c ==="
22
class MyScanner(Scanner):
24
def destination(self, type, name, arglist):
25
classname = "Function"
26
listname = "functions"
29
if t in ("ControlHandle", "ControlRef") and m == "InMode":
32
return classname, listname
34
def writeinitialdefs(self):
35
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
36
self.defsfile.write("from Carbon.TextEdit import *\n")
37
self.defsfile.write("from Carbon.QuickDraw import *\n")
38
self.defsfile.write("from Carbon.Dragconst import *\n")
39
self.defsfile.write("from Carbon.CarbonEvents import *\n")
40
self.defsfile.write("from Carbon.Appearance import *\n")
41
self.defsfile.write("kDataBrowserItemAnyState = -1\n")
42
self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
43
self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
44
self.defsfile.write("\n")
46
def makeblacklistnames(self):
48
'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
49
'DisposeControl', # Generated manually
50
'KillControls', # Implied by close of dialog
52
'TrackControl', # Generated manually
53
'HandleControlClick', # Generated manually
54
'SetControlData', # Generated manually
55
'GetControlData', # Generated manually
56
'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
57
'kDataBrowserClientPropertyFlagsMask', # ditto
58
'kDataBrowserItemAnyState', # and ditto
59
# The following are unavailable for static 68k (appearance manager)
60
## 'GetBevelButtonMenuValue',
61
## 'SetBevelButtonMenuValue',
62
## 'GetBevelButtonMenuHandle',
63
## 'SetBevelButtonTransform',
64
'SetBevelButtonGraphicAlignment',
65
'SetBevelButtonTextAlignment',
66
'SetBevelButtonTextPlacement',
67
## 'SetImageWellTransform',
68
## 'GetTabContentRect',
70
## 'SetDisclosureTriangleLastValue',
71
## # Unavailable in CW Pro 3 libraries
72
## 'SetUpControlTextColor',
73
## # Unavailable in Jack's CW Pro 5.1 libraries
74
## 'GetControlRegion',
75
## 'RemoveControlProperty',
76
## 'IsValidControlHandle',
77
## 'SetControl32BitMinimum',
78
## 'GetControl32BitMinimum',
79
## 'SetControl32BitMaximum',
80
## 'GetControl32BitMaximum',
81
## 'SetControl32BitValue',
82
## 'GetControl32BitValue',
83
## 'SetControlViewSize',
84
## 'GetControlViewSize',
88
'GetControlPropertySize',
89
'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
90
'CreateTabsControl', # wrote manually
91
'GetControlAction', # too much effort for too little usefulness
94
'GetImageWellContentInfo',
95
'GetBevelButtonContentInfo',
97
'GetAuxiliaryControlRecord',
101
def makeblacklisttypes(self):
104
# 'ControlActionUPP',
106
'ControlDefSpec', # Don't know how to do this yet
107
'ControlDefSpec_ptr', # ditto
108
'Collection', # Ditto
109
# not-yet-supported stuff in Universal Headers 3.4:
111
'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
112
# 'ControlTabEntry_ptr', # XXX needed for tabs
113
# 'ControlButtonContentInfoPtr',
114
# 'ControlButtonContentInfo', # XXX ugh: a union
115
# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
116
'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
117
'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
118
'DataBrowserItemUPP',
119
'DataBrowserItemDataRef', # XXX void *
120
'DataBrowserCallbacks', # difficult struct
121
'DataBrowserCallbacks_ptr',
122
'DataBrowserCustomCallbacks',
123
'DataBrowserCustomCallbacks_ptr',
124
## 'DataBrowserTableViewColumnDesc',
125
## 'DataBrowserListViewColumnDesc',
127
'DataBrowserListViewHeaderDesc', # difficult struct
130
def makerepairinstructions(self):
132
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
133
[("InBuffer", "*", "*")]),
135
([("void", "*", "OutMode"), ("long", "*", "InMode"),
136
("long", "*", "OutMode")],
137
[("VarVarOutBuffer", "*", "InOutMode")]),
139
## # For TrackControl
140
## ([("ProcPtr", "actionProc", "InMode")],
141
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
142
## ([("ControlActionUPP", "actionProc", "InMode")],
143
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
145
# For GetControlTitle
146
([('Str255', 'title', 'InMode')],
147
[('Str255', 'title', 'OutMode')]),
149
([("ControlHandle", "*", "OutMode")],
150
[("ExistingControlHandle", "*", "*")]),
151
([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
152
[("ExistingControlHandle", "*", "*")]),
154
([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
155
[("void", "*", "ReturnMode")]),
157
([("DataBrowserListViewColumnDesc", "*", "OutMode")],
158
[("DataBrowserListViewColumnDesc", "*", "InMode")]),
160
([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
161
[("ControlButtonContentInfoPtr", '*', "OutMode")]),
163
([("ControlButtonContentInfo", '*', "OutMode")],
164
[("ControlButtonContentInfo", '*', "InMode")]),
166
([("ControlActionUPP", 'liveTrackingProc', "InMode")],
167
[("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
170
if __name__ == "__main__":