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