Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | # Scan <Controls.h>, generating ctlgen.py. |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 2 | import sys |
| 3 | import os |
| 4 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 5 | sys.path.append(BGENDIR) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 6 | |
| 7 | from scantools import Scanner |
Jack Jansen | c574b43 | 1996-04-12 16:26:59 +0000 | [diff] [blame] | 8 | from bgenlocations import TOOLBOXDIR |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 9 | |
| 10 | def main(): |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 11 | # input = "Controls.h" # Universal Headers < 3.3 |
| 12 | input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3 |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 13 | output = "ctlgen.py" |
Jack Jansen | c574b43 | 1996-04-12 16:26:59 +0000 | [diff] [blame] | 14 | defsoutput = TOOLBOXDIR + "Controls.py" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 15 | 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 | |
| 22 | class 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 Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 29 | if t in ("ControlHandle", "ControlRef") and m == "InMode": |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 30 | classname = "Method" |
| 31 | listname = "methods" |
| 32 | return classname, listname |
| 33 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 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("\n") |
| 39 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 40 | def makeblacklistnames(self): |
| 41 | return [ |
Jack Jansen | cfb60ee | 1996-10-01 10:46:46 +0000 | [diff] [blame] | 42 | 'DisposeControl', # Generated manually |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 43 | 'KillControls', # Implied by close of dialog |
| 44 | 'SetCtlAction', |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 45 | 'TrackControl', # Generated manually |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 46 | 'HandleControlClick', # Generated manually |
| 47 | 'SetControlData', # Generated manually |
| 48 | 'GetControlData', # Generated manually |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 49 | 'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition |
| 50 | 'kControlProgressBarIndeterminateTag', # ditto |
| 51 | # The following are unavailable for static 68k (appearance manager) |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 52 | ## 'GetBevelButtonMenuValue', |
| 53 | ## 'SetBevelButtonMenuValue', |
| 54 | ## 'GetBevelButtonMenuHandle', |
| 55 | ## 'SetBevelButtonTransform', |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 56 | 'SetBevelButtonGraphicAlignment', |
| 57 | 'SetBevelButtonTextAlignment', |
| 58 | 'SetBevelButtonTextPlacement', |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 59 | ## 'SetImageWellTransform', |
| 60 | ## 'GetTabContentRect', |
| 61 | ## 'SetTabEnabled', |
| 62 | ## 'SetDisclosureTriangleLastValue', |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 63 | ## # 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 Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 77 | # Generally Bad News |
| 78 | 'GetControlProperty', |
| 79 | 'SetControlProperty', |
| 80 | 'GetControlPropertySize', |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 81 | ] |
| 82 | |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 83 | def makegreylist(self): |
| 84 | return [ |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 85 | ('#if !TARGET_API_MAC_CARBON', [ |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 86 | 'GetAuxiliaryControlRecord', |
| 87 | 'SetControlColor', |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 88 | # These have suddenly disappeared in UH 3.3.2... |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 89 | ## '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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 126 | ])] |
| 127 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 128 | def makeblacklisttypes(self): |
| 129 | return [ |
| 130 | 'ProcPtr', |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 131 | 'ControlActionUPP', |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 132 | 'ControlButtonContentInfoPtr', |
| 133 | 'Ptr', |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame^] | 134 | '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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 139 | ] |
| 140 | |
| 141 | def makerepairinstructions(self): |
| 142 | return [ |
| 143 | ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")], |
| 144 | [("InBuffer", "*", "*")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 145 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 146 | ([("void", "*", "OutMode"), ("long", "*", "InMode"), |
| 147 | ("long", "*", "OutMode")], |
| 148 | [("VarVarOutBuffer", "*", "InOutMode")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 149 | |
Jack Jansen | 848250c | 1998-05-28 14:20:09 +0000 | [diff] [blame] | 150 | ## # For TrackControl |
| 151 | ## ([("ProcPtr", "actionProc", "InMode")], |
| 152 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]), |
| 153 | ## ([("ControlActionUPP", "actionProc", "InMode")], |
| 154 | ## [("FakeType('(ControlActionUPP)0')", "*", "*")]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 155 | |
Jack Jansen | 4100900 | 1999-03-07 20:05:20 +0000 | [diff] [blame] | 156 | # For GetControlTitle |
| 157 | ([('Str255', 'title', 'InMode')], |
| 158 | [('Str255', 'title', 'OutMode')]), |
Jack Jansen | 229c086 | 1999-12-09 16:03:50 +0000 | [diff] [blame] | 159 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 160 | ([("ControlHandle", "*", "OutMode")], |
| 161 | [("ExistingControlHandle", "*", "*")]), |
Jack Jansen | ae8a68f | 1995-06-06 12:55:40 +0000 | [diff] [blame] | 162 | ([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers |
| 163 | [("ExistingControlHandle", "*", "*")]), |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 164 | ] |
| 165 | |
| 166 | if __name__ == "__main__": |
| 167 | main() |