blob: 1a502d6ea34eab33972b64405cf91cd442acedf6 [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")
Jack Jansen723ad8a2000-12-12 22:10:21 +000038 self.defsfile.write("from Dragconst import *\n")
Jack Jansen21f96871998-02-20 16:02:09 +000039 self.defsfile.write("\n")
40
Guido van Rossum17448e21995-01-30 11:53:55 +000041 def makeblacklistnames(self):
42 return [
Jack Jansencfb60ee1996-10-01 10:46:46 +000043 'DisposeControl', # Generated manually
Guido van Rossum17448e21995-01-30 11:53:55 +000044 'KillControls', # Implied by close of dialog
45 'SetCtlAction',
Jack Jansen848250c1998-05-28 14:20:09 +000046 'TrackControl', # Generated manually
Jack Jansen229c0861999-12-09 16:03:50 +000047 'HandleControlClick', # Generated manually
48 'SetControlData', # Generated manually
49 'GetControlData', # Generated manually
Jack Jansen21f96871998-02-20 16:02:09 +000050 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
51 'kControlProgressBarIndeterminateTag', # ditto
52 # The following are unavailable for static 68k (appearance manager)
Jack Jansene79dc762000-06-02 21:35:07 +000053## 'GetBevelButtonMenuValue',
54## 'SetBevelButtonMenuValue',
55## 'GetBevelButtonMenuHandle',
56## 'SetBevelButtonTransform',
Jack Jansen21f96871998-02-20 16:02:09 +000057 'SetBevelButtonGraphicAlignment',
58 'SetBevelButtonTextAlignment',
59 'SetBevelButtonTextPlacement',
Jack Jansene79dc762000-06-02 21:35:07 +000060## 'SetImageWellTransform',
61## 'GetTabContentRect',
62## 'SetTabEnabled',
63## 'SetDisclosureTriangleLastValue',
Jack Jansena05ac601999-12-12 21:41:51 +000064## # 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',
Jack Jansen229c0861999-12-09 16:03:50 +000078 # Generally Bad News
79 'GetControlProperty',
80 'SetControlProperty',
81 'GetControlPropertySize',
Guido van Rossum17448e21995-01-30 11:53:55 +000082 ]
83
Jack Jansene79dc762000-06-02 21:35:07 +000084 def makegreylist(self):
85 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000086 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansene79dc762000-06-02 21:35:07 +000087 'GetAuxiliaryControlRecord',
88 'SetControlColor',
Jack Jansen9d8b96c2000-07-14 22:16:45 +000089 # These have suddenly disappeared in UH 3.3.2...
Jack Jansenf7d5aa62000-12-10 23:43:49 +000090## 'GetBevelButtonMenuValue',
91## 'SetBevelButtonMenuValue',
92## 'GetBevelButtonMenuHandle',
93## 'SetBevelButtonTransform',
94## 'SetImageWellTransform',
95## 'GetTabContentRect',
96## 'SetTabEnabled',
97## 'SetDisclosureTriangleLastValue',
98 ]),
99 ('#if TARGET_API_MAC_CARBON', [
100 'IsAutomaticControlDragTrackingEnabledForWindow',
101 'SetAutomaticControlDragTrackingEnabledForWindow',
Jack Jansen723ad8a2000-12-12 22:10:21 +0000102 'HandleControlDragReceive',
103 'HandleControlDragTracking',
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000104 'GetControlByID',
105 'IsControlDragTrackingEnabled',
106 'SetControlDragTrackingEnabled',
107 'GetControlPropertyAttributes',
108 'ChangeControlPropertyAttributes',
109 'GetControlID',
110 'SetControlID',
111 'HandleControlSetCursor',
112 'GetControlClickActivation',
113 'HandleControlContextualMenuClick',
114 ]),
115 ('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
116 # XXX These are silly, they should be #defined to access the fields
117 # directly. Later...
118 'GetControlBounds',
119 'IsControlHilited',
120 'GetControlHilite',
121 'GetControlOwner',
122 'GetControlDataHandle',
123 'GetControlPopupMenuHandle',
124 'GetControlPopupMenuID',
125 'SetControlDataHandle',
126 'SetControlBounds',
127 'SetControlPopupMenuHandle',
128 'SetControlPopupMenuID',
Jack Jansene79dc762000-06-02 21:35:07 +0000129 ])]
130
Guido van Rossum17448e21995-01-30 11:53:55 +0000131 def makeblacklisttypes(self):
132 return [
133 'ProcPtr',
Jack Jansenae8a68f1995-06-06 12:55:40 +0000134 'ControlActionUPP',
Jack Jansen21f96871998-02-20 16:02:09 +0000135 'ControlButtonContentInfoPtr',
136 'Ptr',
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000137 'ControlDefSpec', # Don't know how to do this yet
138 'ControlDefSpec_ptr', # ditto
139 'Collection', # Ditto
Guido van Rossum17448e21995-01-30 11:53:55 +0000140 ]
141
142 def makerepairinstructions(self):
143 return [
144 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
145 [("InBuffer", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000146
Guido van Rossum17448e21995-01-30 11:53:55 +0000147 ([("void", "*", "OutMode"), ("long", "*", "InMode"),
148 ("long", "*", "OutMode")],
149 [("VarVarOutBuffer", "*", "InOutMode")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000150
Jack Jansen848250c1998-05-28 14:20:09 +0000151## # For TrackControl
152## ([("ProcPtr", "actionProc", "InMode")],
153## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
154## ([("ControlActionUPP", "actionProc", "InMode")],
155## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
Jack Jansen229c0861999-12-09 16:03:50 +0000156
Jack Jansen41009001999-03-07 20:05:20 +0000157 # For GetControlTitle
158 ([('Str255', 'title', 'InMode')],
159 [('Str255', 'title', 'OutMode')]),
Jack Jansen229c0861999-12-09 16:03:50 +0000160
Guido van Rossum17448e21995-01-30 11:53:55 +0000161 ([("ControlHandle", "*", "OutMode")],
162 [("ExistingControlHandle", "*", "*")]),
Jack Jansenae8a68f1995-06-06 12:55:40 +0000163 ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
164 [("ExistingControlHandle", "*", "*")]),
Jack Jansena9e3db32001-01-09 22:10:16 +0000165
166 ([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
167 [("void", "*", "ReturnMode")]),
Guido van Rossum17448e21995-01-30 11:53:55 +0000168 ]
169
170if __name__ == "__main__":
171 main()