1995-01-30 07:53:55 -04:00
|
|
|
# Scan <Controls.h>, generating ctlgen.py.
|
1998-04-17 11:07:56 -03:00
|
|
|
import sys
|
|
|
|
import os
|
2002-08-05 12:39:30 -03:00
|
|
|
from bgenlocations import TOOLBOXDIR, BGENDIR
|
1998-04-17 11:07:56 -03:00
|
|
|
sys.path.append(BGENDIR)
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
from scantools import Scanner
|
|
|
|
|
|
|
|
def main():
|
2000-12-10 19:43:49 -04:00
|
|
|
# input = "Controls.h" # Universal Headers < 3.3
|
|
|
|
input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
|
1995-01-30 07:53:55 -04:00
|
|
|
output = "ctlgen.py"
|
1996-04-12 13:26:59 -03:00
|
|
|
defsoutput = TOOLBOXDIR + "Controls.py"
|
1995-01-30 07:53:55 -04:00
|
|
|
scanner = MyScanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
2002-08-15 18:48:16 -03:00
|
|
|
print "=== Testing definitions output code ==="
|
|
|
|
execfile(defsoutput, {}, {})
|
1995-01-30 07:53:55 -04:00
|
|
|
print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
|
|
|
|
import ctlsupport
|
|
|
|
print "=== Done. It's up to you to compile Ctlmodule.c ==="
|
|
|
|
|
|
|
|
class MyScanner(Scanner):
|
|
|
|
|
|
|
|
def destination(self, type, name, arglist):
|
|
|
|
classname = "Function"
|
|
|
|
listname = "functions"
|
|
|
|
if arglist:
|
|
|
|
t, n, m = arglist[0]
|
1995-06-06 09:55:40 -03:00
|
|
|
if t in ("ControlHandle", "ControlRef") and m == "InMode":
|
1995-01-30 07:53:55 -04:00
|
|
|
classname = "Method"
|
|
|
|
listname = "methods"
|
|
|
|
return classname, listname
|
|
|
|
|
1998-02-20 12:02:09 -04:00
|
|
|
def writeinitialdefs(self):
|
|
|
|
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
2002-08-15 19:05:58 -03:00
|
|
|
self.defsfile.write("from Carbon.TextEdit import *\n")
|
|
|
|
self.defsfile.write("from Carbon.QuickDraw import *\n")
|
|
|
|
self.defsfile.write("from Carbon.Dragconst import *\n")
|
|
|
|
self.defsfile.write("from Carbon.CarbonEvents import *\n")
|
|
|
|
self.defsfile.write("from Carbon.Appearance import *\n")
|
2001-12-12 18:40:27 -04:00
|
|
|
self.defsfile.write("kDataBrowserItemAnyState = -1\n")
|
|
|
|
self.defsfile.write("kControlBevelButtonCenterPopupGlyphTag = -1\n")
|
2002-08-15 19:05:58 -03:00
|
|
|
self.defsfile.write("kDataBrowserClientPropertyFlagsMask = 0xFF000000\n")
|
1998-02-20 12:02:09 -04:00
|
|
|
self.defsfile.write("\n")
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
2001-12-13 17:24:37 -04:00
|
|
|
'FindControlUnderMouse', # Generated manually, returns an existing control, not a new one.
|
1996-10-01 07:46:46 -03:00
|
|
|
'DisposeControl', # Generated manually
|
1995-01-30 07:53:55 -04:00
|
|
|
'KillControls', # Implied by close of dialog
|
|
|
|
'SetCtlAction',
|
1998-05-28 11:20:09 -03:00
|
|
|
'TrackControl', # Generated manually
|
1999-12-09 12:03:50 -04:00
|
|
|
'HandleControlClick', # Generated manually
|
|
|
|
'SetControlData', # Generated manually
|
|
|
|
'GetControlData', # Generated manually
|
1998-02-20 12:02:09 -04:00
|
|
|
'kControlBevelButtonCenterPopupGlyphTag', # Constant with funny definition
|
2001-12-12 18:40:27 -04:00
|
|
|
'kDataBrowserClientPropertyFlagsMask', # ditto
|
|
|
|
'kDataBrowserItemAnyState', # and ditto
|
1998-02-20 12:02:09 -04:00
|
|
|
# The following are unavailable for static 68k (appearance manager)
|
2000-06-02 18:35:07 -03:00
|
|
|
## 'GetBevelButtonMenuValue',
|
|
|
|
## 'SetBevelButtonMenuValue',
|
|
|
|
## 'GetBevelButtonMenuHandle',
|
|
|
|
## 'SetBevelButtonTransform',
|
1998-02-20 12:02:09 -04:00
|
|
|
'SetBevelButtonGraphicAlignment',
|
|
|
|
'SetBevelButtonTextAlignment',
|
|
|
|
'SetBevelButtonTextPlacement',
|
2000-06-02 18:35:07 -03:00
|
|
|
## 'SetImageWellTransform',
|
|
|
|
## 'GetTabContentRect',
|
|
|
|
## 'SetTabEnabled',
|
|
|
|
## 'SetDisclosureTriangleLastValue',
|
1999-12-12 17:41:51 -04:00
|
|
|
## # Unavailable in CW Pro 3 libraries
|
|
|
|
## 'SetUpControlTextColor',
|
|
|
|
## # Unavailable in Jack's CW Pro 5.1 libraries
|
|
|
|
## 'GetControlRegion',
|
|
|
|
## 'RemoveControlProperty',
|
|
|
|
## 'IsValidControlHandle',
|
|
|
|
## 'SetControl32BitMinimum',
|
|
|
|
## 'GetControl32BitMinimum',
|
|
|
|
## 'SetControl32BitMaximum',
|
|
|
|
## 'GetControl32BitMaximum',
|
|
|
|
## 'SetControl32BitValue',
|
|
|
|
## 'GetControl32BitValue',
|
|
|
|
## 'SetControlViewSize',
|
|
|
|
## 'GetControlViewSize',
|
1999-12-09 12:03:50 -04:00
|
|
|
# Generally Bad News
|
|
|
|
'GetControlProperty',
|
|
|
|
'SetControlProperty',
|
|
|
|
'GetControlPropertySize',
|
2001-06-20 18:31:28 -03:00
|
|
|
'SendControlMessage', # Parameter changed from long to void* from UH3.3 to UH3.4
|
2001-12-18 08:47:47 -04:00
|
|
|
'CreateTabsControl', # wrote manually
|
2001-12-30 17:25:26 -04:00
|
|
|
'GetControlAction', # too much effort for too little usefulness
|
2001-12-18 08:47:47 -04:00
|
|
|
|
|
|
|
# too lazy for now
|
|
|
|
'GetImageWellContentInfo',
|
|
|
|
'GetBevelButtonContentInfo',
|
2002-12-12 06:31:54 -04:00
|
|
|
# OS8 only
|
|
|
|
'GetAuxiliaryControlRecord',
|
|
|
|
'SetControlColor',
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
def makeblacklisttypes(self):
|
|
|
|
return [
|
|
|
|
'ProcPtr',
|
2001-12-30 17:25:26 -04:00
|
|
|
# 'ControlActionUPP',
|
1998-02-20 12:02:09 -04:00
|
|
|
'Ptr',
|
2000-12-10 19:43:49 -04:00
|
|
|
'ControlDefSpec', # Don't know how to do this yet
|
|
|
|
'ControlDefSpec_ptr', # ditto
|
|
|
|
'Collection', # Ditto
|
2001-12-12 18:40:27 -04:00
|
|
|
# not-yet-supported stuff in Universal Headers 3.4:
|
|
|
|
'ControlColorUPP',
|
|
|
|
'ControlKind', # XXX easy: 2-tuple containing 2 OSType's
|
2001-12-18 08:47:47 -04:00
|
|
|
# 'ControlTabEntry_ptr', # XXX needed for tabs
|
|
|
|
# 'ControlButtonContentInfoPtr',
|
|
|
|
# 'ControlButtonContentInfo', # XXX ugh: a union
|
|
|
|
# 'ControlButtonContentInfo_ptr', # XXX ugh: a union
|
2001-12-12 18:40:27 -04:00
|
|
|
'ListDefSpec_ptr', # XXX see _Listmodule.c, tricky but possible
|
|
|
|
'DataBrowserItemID_ptr', # XXX array of UInt32, for BrowserView
|
|
|
|
'DataBrowserItemUPP',
|
|
|
|
'DataBrowserItemDataRef', # XXX void *
|
|
|
|
'DataBrowserCallbacks', # difficult struct
|
|
|
|
'DataBrowserCallbacks_ptr',
|
|
|
|
'DataBrowserCustomCallbacks',
|
|
|
|
'DataBrowserCustomCallbacks_ptr',
|
2001-12-18 08:47:47 -04:00
|
|
|
## 'DataBrowserTableViewColumnDesc',
|
|
|
|
## 'DataBrowserListViewColumnDesc',
|
2001-12-12 18:40:27 -04:00
|
|
|
'CFDataRef',
|
2003-12-03 19:20:13 -04:00
|
|
|
'DataBrowserListViewHeaderDesc', # difficult struct
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
def makerepairinstructions(self):
|
|
|
|
return [
|
|
|
|
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
|
|
|
|
[("InBuffer", "*", "*")]),
|
1999-12-09 12:03:50 -04:00
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
([("void", "*", "OutMode"), ("long", "*", "InMode"),
|
|
|
|
("long", "*", "OutMode")],
|
|
|
|
[("VarVarOutBuffer", "*", "InOutMode")]),
|
1999-12-09 12:03:50 -04:00
|
|
|
|
1998-05-28 11:20:09 -03:00
|
|
|
## # For TrackControl
|
|
|
|
## ([("ProcPtr", "actionProc", "InMode")],
|
|
|
|
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
|
|
|
|
## ([("ControlActionUPP", "actionProc", "InMode")],
|
|
|
|
## [("FakeType('(ControlActionUPP)0')", "*", "*")]),
|
1999-12-09 12:03:50 -04:00
|
|
|
|
1999-03-07 16:05:20 -04:00
|
|
|
# For GetControlTitle
|
|
|
|
([('Str255', 'title', 'InMode')],
|
|
|
|
[('Str255', 'title', 'OutMode')]),
|
1999-12-09 12:03:50 -04:00
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
([("ControlHandle", "*", "OutMode")],
|
|
|
|
[("ExistingControlHandle", "*", "*")]),
|
1995-06-06 09:55:40 -03:00
|
|
|
([("ControlRef", "*", "OutMode")], # Ditto, for Universal Headers
|
|
|
|
[("ExistingControlHandle", "*", "*")]),
|
2001-01-09 18:10:16 -04:00
|
|
|
|
|
|
|
([("Rect_ptr", "*", "ReturnMode")], # GetControlBounds
|
|
|
|
[("void", "*", "ReturnMode")]),
|
2001-12-18 08:47:47 -04:00
|
|
|
|
|
|
|
([("DataBrowserListViewColumnDesc", "*", "OutMode")],
|
|
|
|
[("DataBrowserListViewColumnDesc", "*", "InMode")]),
|
|
|
|
|
|
|
|
([("ControlButtonContentInfoPtr", 'outContent', "InMode")],
|
|
|
|
[("ControlButtonContentInfoPtr", '*', "OutMode")]),
|
|
|
|
|
|
|
|
([("ControlButtonContentInfo", '*', "OutMode")],
|
|
|
|
[("ControlButtonContentInfo", '*', "InMode")]),
|
2001-12-30 17:25:26 -04:00
|
|
|
|
|
|
|
([("ControlActionUPP", 'liveTrackingProc', "InMode")],
|
|
|
|
[("ControlActionUPPNewControl", 'liveTrackingProc', "InMode")]),
|
1995-01-30 07:53:55 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|