blob: 709fa10b332ac02abf920ef951c042dec9c4512f [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001# Scan <Controls.h>, generating ctlgen.py.
Jack Jansen0c4d9471998-04-17 14:07:56 +00002import sys
3import os
4BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
5sys.path.append(BGENDIR)
Guido van Rossum17448e21995-01-30 11:53:55 +00006
7from scantools import Scanner
Jack Jansenc574b431996-04-12 16:26:59 +00008from bgenlocations import TOOLBOXDIR
Guido van Rossum17448e21995-01-30 11:53:55 +00009
10def main():
Jack Jansenf7d5aa62000-12-10 23:43:49 +000011# input = "Controls.h" # Universal Headers < 3.3
12 input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
Guido van Rossum17448e21995-01-30 11:53:55 +000013 output = "ctlgen.py"
Jack Jansenc574b431996-04-12 16:26:59 +000014 defsoutput = TOOLBOXDIR + "Controls.py"
Guido van Rossum17448e21995-01-30 11:53:55 +000015 scanner = MyScanner(input, output, defsoutput)
16 scanner.scan()
17 scanner.close()
18 print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
19 import ctlsupport
20 print "=== Done. It's up to you to compile Ctlmodule.c ==="
21
22class MyScanner(Scanner):
23
24 def destination(self, type, name, arglist):
25 classname = "Function"
26 listname = "functions"
27 if arglist:
28 t, n, m = arglist[0]
Jack Jansenae8a68f1995-06-06 12:55:40 +000029 if t in ("ControlHandle", "ControlRef") and m == "InMode":
Guido van Rossum17448e21995-01-30 11:53:55 +000030 classname = "Method"
31 listname = "methods"
32 return classname, listname
33
Jack Jansen21f96871998-02-20 16:02:09 +000034 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("\n")
39
Guido van Rossum17448e21995-01-30 11:53:55 +000040 def makeblacklistnames(self):
41 return [
Jack Jansencfb60ee1996-10-01 10:46:46 +000042 'DisposeControl', # Generated manually
Guido van Rossum17448e21995-01-30 11:53:55 +000043 'KillControls', # Implied by close of dialog
44 'SetCtlAction',
Jack Jansen848250c1998-05-28 14:20:09 +000045 'TrackControl', # Generated manually
Jack Jansen229c0861999-12-09 16:03:50 +000046 'HandleControlClick', # Generated manually
47 'SetControlData', # Generated manually
48 'GetControlData', # Generated manually
Jack Jansen21f96871998-02-20 16:02:09 +000049 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
50 'kControlProgressBarIndeterminateTag', # ditto
51 # The following are unavailable for static 68k (appearance manager)
Jack Jansene79dc762000-06-02 21:35:07 +000052## 'GetBevelButtonMenuValue',
53## 'SetBevelButtonMenuValue',
54## 'GetBevelButtonMenuHandle',
55## 'SetBevelButtonTransform',
Jack Jansen21f96871998-02-20 16:02:09 +000056 'SetBevelButtonGraphicAlignment',
57 'SetBevelButtonTextAlignment',
58 'SetBevelButtonTextPlacement',
Jack Jansene79dc762000-06-02 21:35:07 +000059## 'SetImageWellTransform',
60## 'GetTabContentRect',
61## 'SetTabEnabled',
62## 'SetDisclosureTriangleLastValue',
Jack Jansena05ac601999-12-12 21:41:51 +000063## # Unavailable in CW Pro 3 libraries
64## 'SetUpControlTextColor',
65## # Unavailable in Jack's CW Pro 5.1 libraries
66## 'GetControlRegion',
67## 'RemoveControlProperty',
68## 'IsValidControlHandle',
69## 'SetControl32BitMinimum',
70## 'GetControl32BitMinimum',
71## 'SetControl32BitMaximum',
72## 'GetControl32BitMaximum',
73## 'SetControl32BitValue',
74## 'GetControl32BitValue',
75## 'SetControlViewSize',
76## 'GetControlViewSize',
Jack Jansen229c0861999-12-09 16:03:50 +000077 # Generally Bad News
78 'GetControlProperty',
79 'SetControlProperty',
80 'GetControlPropertySize',
Guido van Rossum17448e21995-01-30 11:53:55 +000081 ]
82
Jack Jansene79dc762000-06-02 21:35:07 +000083 def makegreylist(self):
84 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000085 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000086 'GetAuxiliaryControlRecord',
87 'SetControlColor',
Jack Jansen9d8b96c2000-07-14 22:16:45 +000088 # These have suddenly disappeared in UH 3.3.2...
Jack Jansenf7d5aa62000-12-10 23:43:49 +000089## 'GetBevelButtonMenuValue',
90## 'SetBevelButtonMenuValue',
91## 'GetBevelButtonMenuHandle',
92## 'SetBevelButtonTransform',
93## 'SetImageWellTransform',
94## 'GetTabContentRect',
95## 'SetTabEnabled',
96## 'SetDisclosureTriangleLastValue',
97 ]),
98 ('#if TARGET_API_MAC_CARBON', [
99 'IsAutomaticControlDragTrackingEnabledForWindow',
100 'SetAutomaticControlDragTrackingEnabledForWindow',
101 'GetControlByID',
102 'IsControlDragTrackingEnabled',
103 'SetControlDragTrackingEnabled',
104 'GetControlPropertyAttributes',
105 'ChangeControlPropertyAttributes',
106 'GetControlID',
107 'SetControlID',
108 'HandleControlSetCursor',
109 'GetControlClickActivation',
110 'HandleControlContextualMenuClick',
111 ]),
112 ('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
113 # XXX These are silly, they should be #defined to access the fields
114 # directly. Later...
115 'GetControlBounds',
116 'IsControlHilited',
117 'GetControlHilite',
118 'GetControlOwner',
119 'GetControlDataHandle',
120 'GetControlPopupMenuHandle',
121 'GetControlPopupMenuID',
122 'SetControlDataHandle',
123 'SetControlBounds',
124 'SetControlPopupMenuHandle',
125 'SetControlPopupMenuID',
Jack Jansene79dc762000-06-02 21:35:07 +0000126 ])]
127
Guido van Rossum17448e21995-01-30 11:53:55 +0000128 def makeblacklisttypes(self):
129 return [
130 'ProcPtr',
Jack Jansenae8a68f1995-06-06 12:55:40 +0000131 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +0000132 'ControlButtonContentInfoPtr',
133 'Ptr',
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000134 'ControlDefSpec', # Don't know how to do this yet
135 'ControlDefSpec_ptr', # ditto
136 'Collection', # Ditto
137 'DragTrackingMessage', # Needs Drag module, must implement later
138 'DragReference', # ditto
Guido van Rossum17448e21995-01-30 11:53:55 +0000139 ]
140
141 def makerepairinstructions(self):
142 return [
143 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
144 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000145
Guido van Rossum17448e21995-01-30 11:53:55 +0000146 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
147 ("long", "*", "OutMode")],
148 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000149
Jack Jansen848250c1998-05-28 14:20:09 +0000150## # For TrackControl
151## ([("ProcPtr", "actionProc", "InMode")],
152## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
153## ([("ControlActionUPP", "actionProc", "InMode")],
154## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000155
Jack Jansen41009001999-03-07 20:05:20 +0000156 # For GetControlTitle
157 ([('Str255', 'title', 'InMode')],
158 [('Str255', 'title', 'OutMode')]),
Jack Jansen229c0861999-12-09 16:03:50 +0000159
Guido van Rossum17448e21995-01-30 11:53:55 +0000160 ([("ControlHandle", "*", "OutMode")],
161 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +0000162 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
163 [("ExistingControlHandle", "*", "*")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000164 ]
165
166if __name__ == "__main__":
167 main()