1 # Scan <Controls.h>, generating ctlgen.py.
4 BGENDIR
=os
.path
.join(sys
.prefix
, ':Tools:bgen:bgen')
5 sys
.path
.append(BGENDIR
)
7 from scantools
import Scanner
8 from bgenlocations
import TOOLBOXDIR
11 # input = "Controls.h" # Universal Headers < 3.3
12 input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
14 defsoutput
= TOOLBOXDIR
+ "Controls.py"
15 scanner
= MyScanner(input, output
, 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 TextEdit import *\n")
37 self
.defsfile
.write("from QuickDraw import *\n")
38 self
.defsfile
.write("from Dragconst import *\n")
39 self
.defsfile
.write("\n")
41 def makeblacklistnames(self
):
43 'DisposeControl', # Generated manually
44 'KillControls', # Implied by close of dialog
46 'TrackControl', # Generated manually
47 'HandleControlClick', # Generated manually
48 'SetControlData', # Generated manually
49 'GetControlData', # Generated manually
50 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
51 'kControlProgressBarIndeterminateTag', # ditto
52 # The following are unavailable for static 68k (appearance manager)
53 ## 'GetBevelButtonMenuValue',
54 ## 'SetBevelButtonMenuValue',
55 ## 'GetBevelButtonMenuHandle',
56 ## 'SetBevelButtonTransform',
57 'SetBevelButtonGraphicAlignment',
58 'SetBevelButtonTextAlignment',
59 'SetBevelButtonTextPlacement',
60 ## 'SetImageWellTransform',
61 ## 'GetTabContentRect',
63 ## 'SetDisclosureTriangleLastValue',
64 ## # Unavailable in CW Pro 3 libraries
65 ## 'SetUpControlTextColor',
66 ## # Unavailable in Jack's CW Pro 5.1 libraries
67 ## 'GetControlRegion',
68 ## 'RemoveControlProperty',
69 ## 'IsValidControlHandle',
70 ## 'SetControl32BitMinimum',
71 ## 'GetControl32BitMinimum',
72 ## 'SetControl32BitMaximum',
73 ## 'GetControl32BitMaximum',
74 ## 'SetControl32BitValue',
75 ## 'GetControl32BitValue',
76 ## 'SetControlViewSize',
77 ## 'GetControlViewSize',
81 'GetControlPropertySize',
82 'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
85 def makegreylist(self
):
87 ('#if !TARGET_API_MAC_CARBON', [
88 'GetAuxiliaryControlRecord',
90 # These have suddenly disappeared in UH 3.3.2...
91 ## 'GetBevelButtonMenuValue',
92 ## 'SetBevelButtonMenuValue',
93 ## 'GetBevelButtonMenuHandle',
94 ## 'SetBevelButtonTransform',
95 ## 'SetImageWellTransform',
96 ## 'GetTabContentRect',
98 ## 'SetDisclosureTriangleLastValue',
100 ('#if TARGET_API_MAC_CARBON', [
101 'IsAutomaticControlDragTrackingEnabledForWindow',
102 'SetAutomaticControlDragTrackingEnabledForWindow',
103 'HandleControlDragReceive',
104 'HandleControlDragTracking',
106 'IsControlDragTrackingEnabled',
107 'SetControlDragTrackingEnabled',
108 'GetControlPropertyAttributes',
109 'ChangeControlPropertyAttributes',
112 'HandleControlSetCursor',
113 'GetControlClickActivation',
114 'HandleControlContextualMenuClick',
116 ('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
117 # XXX These are silly, they should be #defined to access the fields
123 'GetControlDataHandle',
124 'GetControlPopupMenuHandle',
125 'GetControlPopupMenuID',
126 'SetControlDataHandle',
128 'SetControlPopupMenuHandle',
129 'SetControlPopupMenuID',
132 def makeblacklisttypes(self
):
136 'ControlButtonContentInfoPtr',
138 'ControlDefSpec', # Don't know how to do this yet
139 'ControlDefSpec_ptr', # ditto
140 'Collection', # Ditto
143 def makerepairinstructions(self
):
145 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
146 [("InBuffer", "*", "*")]),
148 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
149 ("long", "*", "OutMode")],
150 [("VarVarOutBuffer", "*", "InOutMode")]),
152 ## # For TrackControl
153 ## ([("ProcPtr", "actionProc", "InMode")],
154 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
155 ## ([("ControlActionUPP", "actionProc", "InMode")],
156 ## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
158 # For GetControlTitle
159 ([('Str255', 'title', 'InMode')],
160 [('Str255', 'title', 'OutMode')]),
162 ([("ControlHandle", "*", "OutMode")],
163 [("ExistingControlHandle", "*", "*")]),
164 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
165 [("ExistingControlHandle", "*", "*")]),
167 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
168 [("void", "*", "ReturnMode")]),
171 if __name__
== "__main__":