Commit f7d5aa61 authored by Jack Jansen's avatar Jack Jansen

Adapted to Universal Headers 3.3.2. More to follow.

parent c6c28384
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "pymactoolbox.h" #include "pymactoolbox.h"
#include <AppleEvents.h> #include <AppleEvents.h>
#include <AEObjects.h>
static pascal OSErr GenericEventHandler(); /* Forward */ static pascal OSErr GenericEventHandler(); /* Forward */
...@@ -69,34 +70,6 @@ static void AEDesc_dealloc(self) ...@@ -69,34 +70,6 @@ static void AEDesc_dealloc(self)
PyMem_DEL(self); PyMem_DEL(self);
} }
static PyObject *AEDesc_AESend(_self, _args)
AEDescObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
AppleEvent reply;
AESendMode sendMode;
AESendPriority sendPriority;
long timeOutInTicks;
if (!PyArg_ParseTuple(_args, "lhl",
&sendMode,
&sendPriority,
&timeOutInTicks))
return NULL;
_err = AESend(&_self->ob_itself,
&reply,
sendMode,
sendPriority,
timeOutInTicks,
upp_AEIdleProc,
(AEFilterUPP)0);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
AEDesc_New, &reply);
return _res;
}
static PyObject *AEDesc_AEResetTimer(_self, _args) static PyObject *AEDesc_AEResetTimer(_self, _args)
AEDescObject *_self; AEDescObject *_self;
PyObject *_args; PyObject *_args;
...@@ -672,9 +645,24 @@ static PyObject *AEDesc_AEPutAttributeDesc(_self, _args) ...@@ -672,9 +645,24 @@ static PyObject *AEDesc_AEPutAttributeDesc(_self, _args)
return _res; return _res;
} }
#if TARGET_API_MAC_CARBON
static PyObject *AEDesc_AEGetDescDataSize(_self, _args)
AEDescObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Size _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = AEGetDescDataSize(&_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
#endif
static PyMethodDef AEDesc_methods[] = { static PyMethodDef AEDesc_methods[] = {
{"AESend", (PyCFunction)AEDesc_AESend, 1,
"(AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks) -> (AppleEvent reply)"},
{"AEResetTimer", (PyCFunction)AEDesc_AEResetTimer, 1, {"AEResetTimer", (PyCFunction)AEDesc_AEResetTimer, 1,
"() -> None"}, "() -> None"},
{"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1, {"AESuspendTheCurrentEvent", (PyCFunction)AEDesc_AESuspendTheCurrentEvent, 1,
...@@ -725,6 +713,11 @@ static PyMethodDef AEDesc_methods[] = { ...@@ -725,6 +713,11 @@ static PyMethodDef AEDesc_methods[] = {
"(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None"}, "(AEKeyword theAEKeyword, DescType typeCode, Buffer dataPtr) -> None"},
{"AEPutAttributeDesc", (PyCFunction)AEDesc_AEPutAttributeDesc, 1, {"AEPutAttributeDesc", (PyCFunction)AEDesc_AEPutAttributeDesc, 1,
"(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None"}, "(AEKeyword theAEKeyword, AEDesc theAEDesc) -> None"},
#if TARGET_API_MAC_CARBON
{"AEGetDescDataSize", (PyCFunction)AEDesc_AEGetDescDataSize, 1,
"() -> (Size _rv)"},
#endif
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -941,6 +934,44 @@ static PyObject *AE_AEGetEventHandler(_self, _args) ...@@ -941,6 +934,44 @@ static PyObject *AE_AEGetEventHandler(_self, _args)
return _res; return _res;
} }
static PyObject *AE_AEInstallSpecialHandler(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
AEKeyword functionClass;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetOSType, &functionClass))
return NULL;
_err = AEInstallSpecialHandler(functionClass,
upp_GenericEventHandler,
0);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *AE_AERemoveSpecialHandler(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
AEKeyword functionClass;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetOSType, &functionClass))
return NULL;
_err = AERemoveSpecialHandler(functionClass,
upp_GenericEventHandler,
0);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *AE_AEManagerInfo(_self, _args) static PyObject *AE_AEManagerInfo(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
...@@ -1072,6 +1103,35 @@ static PyObject *AE_AECreateAppleEvent(_self, _args) ...@@ -1072,6 +1103,35 @@ static PyObject *AE_AECreateAppleEvent(_self, _args)
return _res; return _res;
} }
#if TARGET_API_MAC_CARBON
static PyObject *AE_AEReplaceDescData(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
DescType typeCode;
char *dataPtr__in__;
long dataPtr__len__;
int dataPtr__in_len__;
AEDesc theAEDesc;
if (!PyArg_ParseTuple(_args, "O&s#",
PyMac_GetOSType, &typeCode,
&dataPtr__in__, &dataPtr__in_len__))
return NULL;
dataPtr__len__ = dataPtr__in_len__;
_err = AEReplaceDescData(typeCode,
dataPtr__in__, dataPtr__len__,
&theAEDesc);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
AEDesc_New, &theAEDesc);
dataPtr__error__: ;
return _res;
}
#endif
static PyMethodDef AE_methods[] = { static PyMethodDef AE_methods[] = {
{"AEProcessAppleEvent", (PyCFunction)AE_AEProcessAppleEvent, 1, {"AEProcessAppleEvent", (PyCFunction)AE_AEProcessAppleEvent, 1,
"(EventRecord theEventRecord) -> None"}, "(EventRecord theEventRecord) -> None"},
...@@ -1087,6 +1147,10 @@ static PyMethodDef AE_methods[] = { ...@@ -1087,6 +1147,10 @@ static PyMethodDef AE_methods[] = {
"(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None"}, "(AEEventClass theAEEventClass, AEEventID theAEEventID) -> None"},
{"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1, {"AEGetEventHandler", (PyCFunction)AE_AEGetEventHandler, 1,
"(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)"}, "(AEEventClass theAEEventClass, AEEventID theAEEventID) -> (EventHandler handler)"},
{"AEInstallSpecialHandler", (PyCFunction)AE_AEInstallSpecialHandler, 1,
"(AEKeyword functionClass) -> None"},
{"AERemoveSpecialHandler", (PyCFunction)AE_AERemoveSpecialHandler, 1,
"(AEKeyword functionClass) -> None"},
{"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1, {"AEManagerInfo", (PyCFunction)AE_AEManagerInfo, 1,
"(AEKeyword keyWord) -> (long result)"}, "(AEKeyword keyWord) -> (long result)"},
{"AECoercePtr", (PyCFunction)AE_AECoercePtr, 1, {"AECoercePtr", (PyCFunction)AE_AECoercePtr, 1,
...@@ -1097,6 +1161,11 @@ static PyMethodDef AE_methods[] = { ...@@ -1097,6 +1161,11 @@ static PyMethodDef AE_methods[] = {
"(Buffer factoringPtr, Boolean isRecord) -> (AEDescList resultList)"}, "(Buffer factoringPtr, Boolean isRecord) -> (AEDescList resultList)"},
{"AECreateAppleEvent", (PyCFunction)AE_AECreateAppleEvent, 1, {"AECreateAppleEvent", (PyCFunction)AE_AECreateAppleEvent, 1,
"(AEEventClass theAEEventClass, AEEventID theAEEventID, AEAddressDesc target, AEReturnID returnID, AETransactionID transactionID) -> (AppleEvent result)"}, "(AEEventClass theAEEventClass, AEEventID theAEEventID, AEAddressDesc target, AEReturnID returnID, AETransactionID transactionID) -> (AppleEvent result)"},
#if TARGET_API_MAC_CARBON
{"AEReplaceDescData", (PyCFunction)AE_AEReplaceDescData, 1,
"(DescType typeCode, Buffer dataPtr) -> (AEDesc theAEDesc)"},
#endif
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -1149,7 +1218,7 @@ void initAE() ...@@ -1149,7 +1218,7 @@ void initAE()
AE_Error = PyMac_GetOSErrException(); AE_Error = PyMac_GetOSErrException();
if (AE_Error == NULL || if (AE_Error == NULL ||
PyDict_SetItemString(d, "Error", AE_Error) != 0) PyDict_SetItemString(d, "Error", AE_Error) != 0)
Py_FatalError("can't initialize AE.Error"); return;
AEDesc_Type.ob_type = &PyType_Type; AEDesc_Type.ob_type = &PyType_Type;
Py_INCREF(&AEDesc_Type); Py_INCREF(&AEDesc_Type);
if (PyDict_SetItemString(d, "AEDescType", (PyObject *)&AEDesc_Type) != 0) if (PyDict_SetItemString(d, "AEDescType", (PyObject *)&AEDesc_Type) != 0)
......
...@@ -70,11 +70,19 @@ class AppleEventsScanner(Scanner): ...@@ -70,11 +70,19 @@ class AppleEventsScanner(Scanner):
return [ return [
"AEDisposeDesc", "AEDisposeDesc",
# "AEGetEventHandler", # "AEGetEventHandler",
"AEGetDescData", # Use object.data
"AEGetSpecialHandler",
# Constants with funny definitions # Constants with funny definitions
"kAEDontDisposeOnResume", "kAEDontDisposeOnResume",
"kAEUseStandardDispatch", "kAEUseStandardDispatch",
] ]
def makegreylist(self):
return [
('#if TARGET_API_MAC_CARBON', [
'AEGetDescDataSize',
'AEReplaceDescData',
])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
return [ return [
"ProcPtr", "ProcPtr",
......
...@@ -83,6 +83,7 @@ AEMethod = OSErrMethodGenerator ...@@ -83,6 +83,7 @@ AEMethod = OSErrMethodGenerator
includestuff = includestuff + """ includestuff = includestuff + """
#include <AppleEvents.h> #include <AppleEvents.h>
#include <AEObjects.h>
static pascal OSErr GenericEventHandler(); /* Forward */ static pascal OSErr GenericEventHandler(); /* Forward */
......
...@@ -1111,6 +1111,28 @@ static PyObject *App_GetThemeTextColor(_self, _args) ...@@ -1111,6 +1111,28 @@ static PyObject *App_GetThemeTextColor(_self, _args)
return _res; return _res;
} }
#if TARGET_API_MAC_CARBON
static PyObject *App_GetThemeMetric(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
ThemeMetric inMetric;
SInt32 outMetric;
if (!PyArg_ParseTuple(_args, "l",
&inMetric))
return NULL;
_err = GetThemeMetric(inMetric,
&outMetric);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("l",
outMetric);
return _res;
}
#endif
static PyMethodDef App_methods[] = { static PyMethodDef App_methods[] = {
{"RegisterAppearanceClient", (PyCFunction)App_RegisterAppearanceClient, 1, {"RegisterAppearanceClient", (PyCFunction)App_RegisterAppearanceClient, 1,
"() -> None"}, "() -> None"},
...@@ -1218,6 +1240,11 @@ static PyMethodDef App_methods[] = { ...@@ -1218,6 +1240,11 @@ static PyMethodDef App_methods[] = {
"(ThemeBrush inBrush, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"}, "(ThemeBrush inBrush, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"},
{"GetThemeTextColor", (PyCFunction)App_GetThemeTextColor, 1, {"GetThemeTextColor", (PyCFunction)App_GetThemeTextColor, 1,
"(ThemeTextColor inColor, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"}, "(ThemeTextColor inColor, SInt16 inDepth, Boolean inColorDev) -> (RGBColor outColor)"},
#if TARGET_API_MAC_CARBON
{"GetThemeMetric", (PyCFunction)App_GetThemeMetric, 1,
"(ThemeMetric inMetric) -> (SInt32 outMetric)"},
#endif
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -1237,7 +1264,7 @@ void initApp() ...@@ -1237,7 +1264,7 @@ void initApp()
App_Error = PyMac_GetOSErrException(); App_Error = PyMac_GetOSErrException();
if (App_Error == NULL || if (App_Error == NULL ||
PyDict_SetItemString(d, "Error", App_Error) != 0) PyDict_SetItemString(d, "Error", App_Error) != 0)
Py_FatalError("can't initialize App.Error"); return;
} }
/* ========================= End module App ========================= */ /* ========================= End module App ========================= */
......
...@@ -43,6 +43,12 @@ class MyScanner(Scanner): ...@@ -43,6 +43,12 @@ class MyScanner(Scanner):
"GetThemeFont", # Funny stringbuffer in/out parameter, I think... "GetThemeFont", # Funny stringbuffer in/out parameter, I think...
] ]
def makegreylist(self):
return [
('#if TARGET_API_MAC_CARBON', [
'GetThemeMetric',
])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
return [ return [
"MenuTitleDrawingUPP", "MenuTitleDrawingUPP",
......
...@@ -65,6 +65,7 @@ ThemeGrowDirection = Type("ThemeGrowDirection", "H") ...@@ -65,6 +65,7 @@ ThemeGrowDirection = Type("ThemeGrowDirection", "H")
ThemeSoundKind = OSTypeType("ThemeSoundKind") ThemeSoundKind = OSTypeType("ThemeSoundKind")
ThemeDragSoundKind = OSTypeType("ThemeDragSoundKind") ThemeDragSoundKind = OSTypeType("ThemeDragSoundKind")
ThemeBackgroundKind = Type("ThemeBackgroundKind", "l") ThemeBackgroundKind = Type("ThemeBackgroundKind", "l")
ThemeMetric = Type("ThemeMetric", "l")
RGBColor = OpaqueType("RGBColor", "QdRGB") RGBColor = OpaqueType("RGBColor", "QdRGB")
includestuff = includestuff + """ includestuff = includestuff + """
......
...@@ -831,7 +831,7 @@ void initCm() ...@@ -831,7 +831,7 @@ void initCm()
Cm_Error = PyMac_GetOSErrException(); Cm_Error = PyMac_GetOSErrException();
if (Cm_Error == NULL || if (Cm_Error == NULL ||
PyDict_SetItemString(d, "Error", Cm_Error) != 0) PyDict_SetItemString(d, "Error", Cm_Error) != 0)
Py_FatalError("can't initialize Cm.Error"); return;
ComponentInstance_Type.ob_type = &PyType_Type; ComponentInstance_Type.ob_type = &PyType_Type;
Py_INCREF(&ComponentInstance_Type); Py_INCREF(&ComponentInstance_Type);
if (PyDict_SetItemString(d, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type) != 0) if (PyDict_SetItemString(d, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type) != 0)
......
...@@ -56,6 +56,8 @@ class MyScanner(Scanner): ...@@ -56,6 +56,8 @@ class MyScanner(Scanner):
"CallComponentClose", "CallComponentClose",
"CallComponentOpen", "CallComponentOpen",
"OpenAComponent", "OpenAComponent",
"GetComponentPublicResource", # Missing in CW Pro 6
"CallComponentGetPublicResource", # Missing in CW Pro 6
] ]
def makegreylist(self): def makegreylist(self):
...@@ -77,6 +79,8 @@ class MyScanner(Scanner): ...@@ -77,6 +79,8 @@ class MyScanner(Scanner):
"ComponentRoutineUPP", "ComponentRoutineUPP",
"ComponentMPWorkFunctionUPP", "ComponentMPWorkFunctionUPP",
"ComponentFunctionUPP",
"GetMissingComponentResourceUPP",
] ]
def makerepairinstructions(self): def makerepairinstructions(self):
......
This diff is collapsed.
...@@ -8,7 +8,8 @@ from scantools import Scanner ...@@ -8,7 +8,8 @@ from scantools import Scanner
from bgenlocations import TOOLBOXDIR from bgenlocations import TOOLBOXDIR
def main(): def main():
input = "Controls.h" # input = "Controls.h" # Universal Headers < 3.3
input = ["Controls.h", "ControlDefinitions.h"] # Universal Headers >= 3.3
output = "ctlgen.py" output = "ctlgen.py"
defsoutput = TOOLBOXDIR + "Controls.py" defsoutput = TOOLBOXDIR + "Controls.py"
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
...@@ -85,14 +86,43 @@ class MyScanner(Scanner): ...@@ -85,14 +86,43 @@ class MyScanner(Scanner):
'GetAuxiliaryControlRecord', 'GetAuxiliaryControlRecord',
'SetControlColor', 'SetControlColor',
# These have suddenly disappeared in UH 3.3.2... # These have suddenly disappeared in UH 3.3.2...
'GetBevelButtonMenuValue', ## 'GetBevelButtonMenuValue',
'SetBevelButtonMenuValue', ## 'SetBevelButtonMenuValue',
'GetBevelButtonMenuHandle', ## 'GetBevelButtonMenuHandle',
'SetBevelButtonTransform', ## 'SetBevelButtonTransform',
'SetImageWellTransform', ## 'SetImageWellTransform',
'GetTabContentRect', ## 'GetTabContentRect',
'SetTabEnabled', ## 'SetTabEnabled',
'SetDisclosureTriangleLastValue', ## 'SetDisclosureTriangleLastValue',
]),
('#if TARGET_API_MAC_CARBON', [
'IsAutomaticControlDragTrackingEnabledForWindow',
'SetAutomaticControlDragTrackingEnabledForWindow',
'GetControlByID',
'IsControlDragTrackingEnabled',
'SetControlDragTrackingEnabled',
'GetControlPropertyAttributes',
'ChangeControlPropertyAttributes',
'GetControlID',
'SetControlID',
'HandleControlSetCursor',
'GetControlClickActivation',
'HandleControlContextualMenuClick',
]),
('#if ACCESSOR_CALLS_ARE_FUNCTIONS', [
# XXX These are silly, they should be #defined to access the fields
# directly. Later...
'GetControlBounds',
'IsControlHilited',
'GetControlHilite',
'GetControlOwner',
'GetControlDataHandle',
'GetControlPopupMenuHandle',
'GetControlPopupMenuID',
'SetControlDataHandle',
'SetControlBounds',
'SetControlPopupMenuHandle',
'SetControlPopupMenuID',
])] ])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
...@@ -101,6 +131,11 @@ class MyScanner(Scanner): ...@@ -101,6 +131,11 @@ class MyScanner(Scanner):
'ControlActionUPP', 'ControlActionUPP',
'ControlButtonContentInfoPtr', 'ControlButtonContentInfoPtr',
'Ptr', 'Ptr',
'ControlDefSpec', # Don't know how to do this yet
'ControlDefSpec_ptr', # ditto
'Collection', # Ditto
'DragTrackingMessage', # Needs Drag module, must implement later
'DragReference', # ditto
] ]
def makerepairinstructions(self): def makerepairinstructions(self):
......
...@@ -32,6 +32,8 @@ ControlPartCode = Type("ControlPartCode", "h") ...@@ -32,6 +32,8 @@ ControlPartCode = Type("ControlPartCode", "h")
DragConstraint = Type("DragConstraint", "H") DragConstraint = Type("DragConstraint", "H")
ControlVariant = Type("ControlVariant", "h") ControlVariant = Type("ControlVariant", "h")
IconTransformType = Type("IconTransformType", "h") IconTransformType = Type("IconTransformType", "h")
EventModifiers = Type("EventModifiers", "H")
ClickActivationResult = Type("ClickActivationResult", "l")
ControlButtonGraphicAlignment = Type("ControlButtonGraphicAlignment", "h") ControlButtonGraphicAlignment = Type("ControlButtonGraphicAlignment", "h")
ControlButtonTextAlignment = Type("ControlButtonTextAlignment", "h") ControlButtonTextAlignment = Type("ControlButtonTextAlignment", "h")
ControlButtonTextPlacement = Type("ControlButtonTextPlacement", "h") ControlButtonTextPlacement = Type("ControlButtonTextPlacement", "h")
...@@ -40,9 +42,14 @@ ControlFocusPart = Type("ControlFocusPart", "h") ...@@ -40,9 +42,14 @@ ControlFocusPart = Type("ControlFocusPart", "h")
ControlFontStyleRec = OpaqueType('ControlFontStyleRec', 'ControlFontStyle') ControlFontStyleRec = OpaqueType('ControlFontStyleRec', 'ControlFontStyle')
ControlFontStyleRec_ptr = ControlFontStyleRec ControlFontStyleRec_ptr = ControlFontStyleRec
ControlID = OpaqueType('ControlID', 'PyControlID')
ControlID_ptr = ControlID
includestuff = includestuff + """ includestuff = includestuff + """
#include <%s>""" % MACHEADERFILE + """ #include <%s>""" % MACHEADERFILE + """
#ifndef kControlCheckBoxUncheckedValue
#include <ControlDefinitions.h>
#endif
staticforward PyObject *CtlObj_WhichControl(ControlHandle); staticforward PyObject *CtlObj_WhichControl(ControlHandle);
...@@ -80,6 +87,26 @@ ControlFontStyle_Convert(v, itself) ...@@ -80,6 +87,26 @@ ControlFontStyle_Convert(v, itself)
QdRGB_Convert, &itself->backColor); QdRGB_Convert, &itself->backColor);
} }
/*
** Parse/generate ControlID records
*/
static PyObject *
PyControlID_New(itself)
ControlID *itself;
{
return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
}
static int
PyControlID_Convert(v, itself)
PyObject *v;
ControlID *itself;
{
return PyArg_ParseTuple(v, "O&l", PyMac_GetOSType, &itself->signature, &itself->id);
}
/* TrackControl and HandleControlClick callback support */ /* TrackControl and HandleControlClick callback support */
static PyObject *tracker; static PyObject *tracker;
static ControlActionUPP mytracker_upp; static ControlActionUPP mytracker_upp;
......
...@@ -10,6 +10,13 @@ ...@@ -10,6 +10,13 @@
#include <Dialogs.h> #include <Dialogs.h>
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
#define GetDialogTextEditHandle(dlg) (((DialogPeek)(dlg))->textH)
#define SetPortDialogPort(dlg) SetPort(dlg)
#define GetDialogPort(dlg) ((CGrafPtr)(dlg))
#define GetDialogFromWindow(win) ((DialogRef)(win))
#endif
/* XXX Shouldn't this be a stack? */ /* XXX Shouldn't this be a stack? */
static PyObject *Dlg_FilterProc_callback = NULL; static PyObject *Dlg_FilterProc_callback = NULL;
...@@ -399,6 +406,63 @@ static PyObject *DlgObj_ShortenDITL(_self, _args) ...@@ -399,6 +406,63 @@ static PyObject *DlgObj_ShortenDITL(_self, _args)
return _res; return _res;
} }
#if TARGET_API_MAC_CARBON
static PyObject *DlgObj_InsertDialogItem(_self, _args)
DialogObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
DialogItemIndex afterItem;
DialogItemType itemType;
Handle itemHandle;
Rect box;
if (!PyArg_ParseTuple(_args, "hhO&O&",
&afterItem,
&itemType,
ResObj_Convert, &itemHandle,
PyMac_GetRect, &box))
return NULL;
_err = InsertDialogItem(_self->ob_itself,
afterItem,
itemType,
itemHandle,
&box);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *DlgObj_RemoveDialogItems(_self, _args)
DialogObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSStatus _err;
DialogItemIndex itemNo;
DialogItemIndex amountToRemove;
Boolean disposeItemData;
if (!PyArg_ParseTuple(_args, "hhb",
&itemNo,
&amountToRemove,
&disposeItemData))
return NULL;
_err = RemoveDialogItems(_self->ob_itself,
itemNo,
amountToRemove,
disposeItemData);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
static PyObject *DlgObj_StdFilterProc(_self, _args) static PyObject *DlgObj_StdFilterProc(_self, _args)
DialogObject *_self; DialogObject *_self;
PyObject *_args; PyObject *_args;
...@@ -666,7 +730,21 @@ static PyObject *DlgObj_GetDialogWindow(_self, _args) ...@@ -666,7 +730,21 @@ static PyObject *DlgObj_GetDialogWindow(_self, _args)
return NULL; return NULL;
_rv = GetDialogWindow(_self->ob_itself); _rv = GetDialogWindow(_self->ob_itself);
_res = Py_BuildValue("O&", _res = Py_BuildValue("O&",
WinObj_WhichWindow, _rv); WinObj_New, _rv);
return _res;
}
static PyObject *DlgObj_GetDialogTextEditHandle(_self, _args)
DialogObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
TEHandle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetDialogTextEditHandle(_self->ob_itself);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res; return _res;
} }
...@@ -712,6 +790,33 @@ static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args) ...@@ -712,6 +790,33 @@ static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args)
return _res; return _res;
} }
static PyObject *DlgObj_SetPortDialogPort(_self, _args)
DialogObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
SetPortDialogPort(_self->ob_itself);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *DlgObj_GetDialogPort(_self, _args)
DialogObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
CGrafPtr _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetDialogPort(_self->ob_itself);
_res = Py_BuildValue("O&",
GrafObj_New, _rv);
return _res;
}
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args) static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args)
...@@ -759,6 +864,16 @@ static PyMethodDef DlgObj_methods[] = { ...@@ -759,6 +864,16 @@ static PyMethodDef DlgObj_methods[] = {
"() -> (DialogItemIndex _rv)"}, "() -> (DialogItemIndex _rv)"},
{"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1,
"(DialogItemIndex numberItems) -> None"}, "(DialogItemIndex numberItems) -> None"},
#if TARGET_API_MAC_CARBON
{"InsertDialogItem", (PyCFunction)DlgObj_InsertDialogItem, 1,
"(DialogItemIndex afterItem, DialogItemType itemType, Handle itemHandle, Rect box) -> None"},
#endif
#if TARGET_API_MAC_CARBON
{"RemoveDialogItems", (PyCFunction)DlgObj_RemoveDialogItems, 1,
"(DialogItemIndex itemNo, DialogItemIndex amountToRemove, Boolean disposeItemData) -> None"},
#endif
{"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1, {"StdFilterProc", (PyCFunction)DlgObj_StdFilterProc, 1,
"() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"}, "() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"},
{"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1,
...@@ -787,12 +902,18 @@ static PyMethodDef DlgObj_methods[] = { ...@@ -787,12 +902,18 @@ static PyMethodDef DlgObj_methods[] = {
"() -> (EventMask outMask)"}, "() -> (EventMask outMask)"},
{"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1, {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1,
"() -> (WindowPtr _rv)"}, "() -> (WindowPtr _rv)"},
{"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1,
"() -> (TEHandle _rv)"},
{"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1, {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1,
"() -> (SInt16 _rv)"}, "() -> (SInt16 _rv)"},
{"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1, {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1,
"() -> (SInt16 _rv)"}, "() -> (SInt16 _rv)"},
{"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1, {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1,
"() -> (SInt16 _rv)"}, "() -> (SInt16 _rv)"},
{"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1,
"() -> None"},
{"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1,
"() -> (CGrafPtr _rv)"},
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
{"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1, {"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1,
...@@ -1168,6 +1289,33 @@ static PyObject *Dlg_ResetAlertStage(_self, _args) ...@@ -1168,6 +1289,33 @@ static PyObject *Dlg_ResetAlertStage(_self, _args)
return _res; return _res;
} }
#if TARGET_API_MAC_CARBON
static PyObject *Dlg_GetParamText(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Str255 param0;
Str255 param1;
Str255 param2;
Str255 param3;
if (!PyArg_ParseTuple(_args, "O&O&O&O&",
PyMac_GetStr255, param0,
PyMac_GetStr255, param1,
PyMac_GetStr255, param2,
PyMac_GetStr255, param3))
return NULL;
GetParamText(param0,
param1,
param2,
param3);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
static PyObject *Dlg_NewFeaturesDialog(_self, _args) static PyObject *Dlg_NewFeaturesDialog(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
...@@ -1209,6 +1357,22 @@ static PyObject *Dlg_NewFeaturesDialog(_self, _args) ...@@ -1209,6 +1357,22 @@ static PyObject *Dlg_NewFeaturesDialog(_self, _args)
return _res; return _res;
} }
static PyObject *Dlg_GetDialogFromWindow(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
DialogPtr _rv;
WindowPtr window;
if (!PyArg_ParseTuple(_args, "O&",
WinObj_Convert, &window))
return NULL;
_rv = GetDialogFromWindow(window);
_res = Py_BuildValue("O&",
DlgObj_New, _rv);
return _res;
}
static PyObject *Dlg_SetUserItemHandler(_self, _args) static PyObject *Dlg_SetUserItemHandler(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
...@@ -1273,8 +1437,15 @@ static PyMethodDef Dlg_methods[] = { ...@@ -1273,8 +1437,15 @@ static PyMethodDef Dlg_methods[] = {
"(SInt16 fontNum) -> None"}, "(SInt16 fontNum) -> None"},
{"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1,
"() -> None"}, "() -> None"},
#if TARGET_API_MAC_CARBON
{"GetParamText", (PyCFunction)Dlg_GetParamText, 1,
"(Str255 param0, Str255 param1, Str255 param2, Str255 param3) -> None"},
#endif
{"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1, {"NewFeaturesDialog", (PyCFunction)Dlg_NewFeaturesDialog, 1,
"(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)"}, "(Rect inBoundsRect, Str255 inTitle, Boolean inIsVisible, SInt16 inProcID, WindowPtr inBehind, Boolean inGoAwayFlag, SInt32 inRefCon, Handle inItemListHandle, UInt32 inFlags) -> (DialogPtr _rv)"},
{"GetDialogFromWindow", (PyCFunction)Dlg_GetDialogFromWindow, 1,
"(WindowPtr window) -> (DialogPtr _rv)"},
{"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1, {"SetUserItemHandler", (PyCFunction)Dlg_SetUserItemHandler, 1,
NULL}, NULL},
{NULL, NULL, 0} {NULL, NULL, 0}
...@@ -1282,6 +1453,17 @@ static PyMethodDef Dlg_methods[] = { ...@@ -1282,6 +1453,17 @@ static PyMethodDef Dlg_methods[] = {
/* Return the WindowPtr corresponding to a DialogObject */
WindowPtr
DlgObj_ConvertToWindow(self)
PyObject *self;
{
if ( DlgObj_Check(self) )
return GetDialogWindow(((DialogObject *)self)->ob_itself);
return NULL;
}
void initDlg() void initDlg()
{ {
...@@ -1296,7 +1478,7 @@ void initDlg() ...@@ -1296,7 +1478,7 @@ void initDlg()
Dlg_Error = PyMac_GetOSErrException(); Dlg_Error = PyMac_GetOSErrException();
if (Dlg_Error == NULL || if (Dlg_Error == NULL ||
PyDict_SetItemString(d, "Error", Dlg_Error) != 0) PyDict_SetItemString(d, "Error", Dlg_Error) != 0)
Py_FatalError("can't initialize Dlg.Error"); return;
Dialog_Type.ob_type = &PyType_Type; Dialog_Type.ob_type = &PyType_Type;
Py_INCREF(&Dialog_Type); Py_INCREF(&Dialog_Type);
if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0) if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0)
......
...@@ -59,11 +59,18 @@ class MyScanner(Scanner): ...@@ -59,11 +59,18 @@ class MyScanner(Scanner):
return [ return [
('#if !TARGET_API_MAC_CARBON', [ ('#if !TARGET_API_MAC_CARBON', [
'SetGrafPortOfDialog', 'SetGrafPortOfDialog',
]),
('#if TARGET_API_MAC_CARBON', [
'InsertDialogItem',
'RemoveDialogItems',
'GetParamText',
])] ])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
return [ return [
"AlertStdAlertParamPtr", # Too much work, for now "AlertStdAlertParamPtr", # Too much work, for now
"AlertStdAlertParamRec", # ditto
"AlertStdAlertParamRec_ptr", # ditto
"QTModelessCallbackProcPtr", "QTModelessCallbackProcPtr",
] ]
......
...@@ -19,6 +19,8 @@ ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterPr ...@@ -19,6 +19,8 @@ ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterPr
ModalFilterUPP = ModalFilterProcPtr ModalFilterUPP = ModalFilterProcPtr
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
TEHandle = OpaqueByValueType("TEHandle", "ResObj")
CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
DITLMethod = Type("DITLMethod", "h") DITLMethod = Type("DITLMethod", "h")
DialogItemIndex = Type("DialogItemIndex", "h") DialogItemIndex = Type("DialogItemIndex", "h")
...@@ -31,6 +33,13 @@ EventMask = Type("EventMask", "H") ...@@ -31,6 +33,13 @@ EventMask = Type("EventMask", "H")
includestuff = includestuff + """ includestuff = includestuff + """
#include <Dialogs.h> #include <Dialogs.h>
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
#define GetDialogTextEditHandle(dlg) (((DialogPeek)(dlg))->textH)
#define SetPortDialogPort(dlg) SetPort(dlg)
#define GetDialogPort(dlg) ((CGrafPtr)(dlg))
#define GetDialogFromWindow(win) ((DialogRef)(win))
#endif
/* XXX Shouldn't this be a stack? */ /* XXX Shouldn't this be a stack? */
static PyObject *Dlg_FilterProc_callback = NULL; static PyObject *Dlg_FilterProc_callback = NULL;
...@@ -178,14 +187,14 @@ for f in methods: object.add(f) ...@@ -178,14 +187,14 @@ for f in methods: object.add(f)
# Some methods that are currently macro's in C, but will be real routines # Some methods that are currently macro's in C, but will be real routines
# in MacOS 8. # in MacOS 8.
f = Method(ExistingWindowPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) ##f = Method(ExistingWindowPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode))
object.add(f) ##object.add(f)
f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode)) ##f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode))
object.add(f) ##object.add(f)
f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode)) ##f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode))
object.add(f) ##object.add(f)
f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode)) ##f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode))
object.add(f) ##object.add(f)
f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode), f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode),
condition='#if !TARGET_API_MAC_CARBON') condition='#if !TARGET_API_MAC_CARBON')
object.add(f) object.add(f)
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ OBJECTNAME = 'DragObj' # The basic name of the objects used here ...@@ -12,7 +12,7 @@ OBJECTNAME = 'DragObj' # The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning # The following is *usually* unchanged but may still require tuning
MODPREFIX = MODNAME # The prefix for module-wide routines MODPREFIX = MODNAME # The prefix for module-wide routines
OBJECTTYPE = 'DragReference' # The C type used to represent them OBJECTTYPE = 'DragRef' # The C type used to represent them
OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods OBJECTPREFIX = MODPREFIX + 'Obj' # The prefix for object methods
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
OUTPUTFILE = MODNAME + "module.c" # The file generated by this program OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
...@@ -21,31 +21,21 @@ from macsupport import * ...@@ -21,31 +21,21 @@ from macsupport import *
# Create the type objects # Create the type objects
DragReference = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) DragRef = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX)
DragItemRef = Type("ItemReference", "l")
# Old names
DragReference = DragRef
ItemReference = DragItemRef
##CCTabHandle = OpaqueByValueType("CCTabHandle", "ResObj")
##AuxCtlHandle = OpaqueByValueType("AuxCtlHandle", "ResObj")
##ControlPartCode = Type("ControlPartCode", "h")
##DragConstraint = Type("DragConstraint", "h")
##ControlVariant = Type("ControlVariant", "h")
##IconTransformType = Type("IconTransformType", "h")
##ControlButtonGraphicAlignment = Type("ControlButtonGraphicAlignment", "h")
##ControlButtonTextAlignment = Type("ControlButtonTextAlignment", "h")
##ControlButtonTextPlacement = Type("ControlButtonTextPlacement", "h")
##ControlContentType = Type("ControlContentType", "h")
##ControlFocusPart = Type("ControlFocusPart", "h")
##
##ControlFontStyleRec = OpaqueType('ControlFontStyleRec', 'ControlFontStyle')
##ControlFontStyleRec_ptr = ControlFontStyleRec
PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj") PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj")
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
AEDesc = OpaqueType('AEDesc') AEDesc = OpaqueType('AEDesc')
AEDesc_ptr = AEDesc AEDesc_ptr = AEDesc
RGBColor = OpaqueType("RGBColor", "QdRGB") RGBColor = OpaqueType("RGBColor", "QdRGB")
ItemReference = Type("ItemReference", "l")
FlavorType = OSTypeType("FlavorType") FlavorType = OSTypeType("FlavorType")
DragAttributes = Type("DragAttributes", "l") DragAttributes = Type("DragAttributes", "l")
DragBehaviors = Type("DragBehaviors", "l")
DragImageFlags = Type("DragImageFlags", "l") DragImageFlags = Type("DragImageFlags", "l")
DragImageTranslucency = Type("DragImageTranslucency", "l") DragImageTranslucency = Type("DragImageTranslucency", "l")
DragRegionMessage = Type("DragRegionMessage", "h") DragRegionMessage = Type("DragRegionMessage", "h")
......
...@@ -316,6 +316,57 @@ static PyObject *Evt_SystemEvent(_self, _args) ...@@ -316,6 +316,57 @@ static PyObject *Evt_SystemEvent(_self, _args)
} }
#endif #endif
#if TARGET_API_MAC_CARBON
static PyObject *Evt_GetGlobalMouse(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Point globalMouse;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
GetGlobalMouse(&globalMouse);
_res = Py_BuildValue("O&",
PyMac_BuildPoint, globalMouse);
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Evt_GetCurrentKeyModifiers(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
UInt32 _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetCurrentKeyModifiers();
_res = Py_BuildValue("l",
_rv);
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Evt_CheckEventQueueForUserCancel(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = CheckEventQueueForUserCancel();
_res = Py_BuildValue("b",
_rv);
return _res;
}
#endif
static PyObject *Evt_WaitNextEvent(_self, _args) static PyObject *Evt_WaitNextEvent(_self, _args)
PyObject *_self; PyObject *_self;
PyObject *_args; PyObject *_args;
...@@ -396,6 +447,21 @@ static PyMethodDef Evt_methods[] = { ...@@ -396,6 +447,21 @@ static PyMethodDef Evt_methods[] = {
{"SystemEvent", (PyCFunction)Evt_SystemEvent, 1, {"SystemEvent", (PyCFunction)Evt_SystemEvent, 1,
"(EventRecord theEvent) -> (Boolean _rv)"}, "(EventRecord theEvent) -> (Boolean _rv)"},
#endif #endif
#if TARGET_API_MAC_CARBON
{"GetGlobalMouse", (PyCFunction)Evt_GetGlobalMouse, 1,
"() -> (Point globalMouse)"},
#endif
#if TARGET_API_MAC_CARBON
{"GetCurrentKeyModifiers", (PyCFunction)Evt_GetCurrentKeyModifiers, 1,
"() -> (UInt32 _rv)"},
#endif
#if TARGET_API_MAC_CARBON
{"CheckEventQueueForUserCancel", (PyCFunction)Evt_CheckEventQueueForUserCancel, 1,
"() -> (Boolean _rv)"},
#endif
{"WaitNextEvent", (PyCFunction)Evt_WaitNextEvent, 1, {"WaitNextEvent", (PyCFunction)Evt_WaitNextEvent, 1,
"(EventMask eventMask, UInt32 sleep [,RegionHandle]) -> (Boolean _rv, EventRecord theEvent)"}, "(EventMask eventMask, UInt32 sleep [,RegionHandle]) -> (Boolean _rv, EventRecord theEvent)"},
{NULL, NULL, 0} {NULL, NULL, 0}
...@@ -417,7 +483,7 @@ void initEvt() ...@@ -417,7 +483,7 @@ void initEvt()
Evt_Error = PyMac_GetOSErrException(); Evt_Error = PyMac_GetOSErrException();
if (Evt_Error == NULL || if (Evt_Error == NULL ||
PyDict_SetItemString(d, "Error", Evt_Error) != 0) PyDict_SetItemString(d, "Error", Evt_Error) != 0)
Py_FatalError("can't initialize Evt.Error"); return;
} }
/* ========================= End module Evt ========================= */ /* ========================= End module Evt ========================= */
......
...@@ -43,6 +43,11 @@ class MyScanner(Scanner): ...@@ -43,6 +43,11 @@ class MyScanner(Scanner):
'SystemClick', 'SystemClick',
'GetOSEvent', 'GetOSEvent',
'OSEventAvail', 'OSEventAvail',
]),
('#if TARGET_API_MAC_CARBON', [
'CheckEventQueueForUserCancel',
'GetCurrentKeyModifiers',
'GetGlobalMouse',
])] ])]
def makeblacklistnames(self): def makeblacklistnames(self):
......
...@@ -319,14 +319,14 @@ static PyObject *Fm_SetAntiAliasedTextEnabled(_self, _args) ...@@ -319,14 +319,14 @@ static PyObject *Fm_SetAntiAliasedTextEnabled(_self, _args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
OSStatus _err; OSStatus _err;
Boolean inEnable; Boolean iEnable;
SInt16 inMinFontSize; SInt16 iMinFontSize;
if (!PyArg_ParseTuple(_args, "bh", if (!PyArg_ParseTuple(_args, "bh",
&inEnable, &iEnable,
&inMinFontSize)) &iMinFontSize))
return NULL; return NULL;
_err = SetAntiAliasedTextEnabled(inEnable, _err = SetAntiAliasedTextEnabled(iEnable,
inMinFontSize); iMinFontSize);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None); Py_INCREF(Py_None);
_res = Py_None; _res = Py_None;
...@@ -339,13 +339,13 @@ static PyObject *Fm_IsAntiAliasedTextEnabled(_self, _args) ...@@ -339,13 +339,13 @@ static PyObject *Fm_IsAntiAliasedTextEnabled(_self, _args)
{ {
PyObject *_res = NULL; PyObject *_res = NULL;
Boolean _rv; Boolean _rv;
SInt16 outMinFontSize; SInt16 oMinFontSize;
if (!PyArg_ParseTuple(_args, "")) if (!PyArg_ParseTuple(_args, ""))
return NULL; return NULL;
_rv = IsAntiAliasedTextEnabled(&outMinFontSize); _rv = IsAntiAliasedTextEnabled(&oMinFontSize);
_res = Py_BuildValue("bh", _res = Py_BuildValue("bh",
_rv, _rv,
outMinFontSize); oMinFontSize);
return _res; return _res;
} }
...@@ -394,9 +394,9 @@ static PyMethodDef Fm_methods[] = { ...@@ -394,9 +394,9 @@ static PyMethodDef Fm_methods[] = {
{"GetAppFont", (PyCFunction)Fm_GetAppFont, 1, {"GetAppFont", (PyCFunction)Fm_GetAppFont, 1,
"() -> (short _rv)"}, "() -> (short _rv)"},
{"SetAntiAliasedTextEnabled", (PyCFunction)Fm_SetAntiAliasedTextEnabled, 1, {"SetAntiAliasedTextEnabled", (PyCFunction)Fm_SetAntiAliasedTextEnabled, 1,
"(Boolean inEnable, SInt16 inMinFontSize) -> None"}, "(Boolean iEnable, SInt16 iMinFontSize) -> None"},
{"IsAntiAliasedTextEnabled", (PyCFunction)Fm_IsAntiAliasedTextEnabled, 1, {"IsAntiAliasedTextEnabled", (PyCFunction)Fm_IsAntiAliasedTextEnabled, 1,
"() -> (Boolean _rv, SInt16 outMinFontSize)"}, "() -> (Boolean _rv, SInt16 oMinFontSize)"},
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -416,7 +416,7 @@ void initFm() ...@@ -416,7 +416,7 @@ void initFm()
Fm_Error = PyMac_GetOSErrException(); Fm_Error = PyMac_GetOSErrException();
if (Fm_Error == NULL || if (Fm_Error == NULL ||
PyDict_SetItemString(d, "Error", Fm_Error) != 0) PyDict_SetItemString(d, "Error", Fm_Error) != 0)
Py_FatalError("can't initialize Fm.Error"); return;
} }
/* ========================= End module Fm ========================== */ /* ========================= End module Fm ========================== */
......
...@@ -315,7 +315,7 @@ void initHelp() ...@@ -315,7 +315,7 @@ void initHelp()
Help_Error = PyMac_GetOSErrException(); Help_Error = PyMac_GetOSErrException();
if (Help_Error == NULL || if (Help_Error == NULL ||
PyDict_SetItemString(d, "Error", Help_Error) != 0) PyDict_SetItemString(d, "Error", Help_Error) != 0)
Py_FatalError("can't initialize Help.Error"); return;
} }
/* ======================== End module Help ========================= */ /* ======================== End module Help ========================= */
......
...@@ -1248,6 +1248,120 @@ static PyObject *Icn_GetCustomIconsEnabled(_self, _args) ...@@ -1248,6 +1248,120 @@ static PyObject *Icn_GetCustomIconsEnabled(_self, _args)
return _res; return _res;
} }
static PyObject *Icn_IsIconRefMaskEmpty(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
Boolean _rv;
IconRef iconRef;
if (!PyArg_ParseTuple(_args, "O&",
ResObj_Convert, &iconRef))
return NULL;
_rv = IsIconRefMaskEmpty(iconRef);
_res = Py_BuildValue("b",
_rv);
return _res;
}
#if TARGET_API_MAC_CARBON
static PyObject *Icn_GetIconRefVariant(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
IconRef _rv;
IconRef inIconRef;
OSType inVariant;
IconTransformType outTransform;
if (!PyArg_ParseTuple(_args, "O&O&",
ResObj_Convert, &inIconRef,
PyMac_GetOSType, &inVariant))
return NULL;
_rv = GetIconRefVariant(inIconRef,
inVariant,
&outTransform);
_res = Py_BuildValue("O&h",
ResObj_New, _rv,
outTransform);
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Icn_RegisterIconRefFromIconFile(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
OSType creator;
OSType iconType;
FSSpec iconFile;
IconRef theIconRef;
if (!PyArg_ParseTuple(_args, "O&O&O&",
PyMac_GetOSType, &creator,
PyMac_GetOSType, &iconType,
PyMac_GetFSSpec, &iconFile))
return NULL;
_err = RegisterIconRefFromIconFile(creator,
iconType,
&iconFile,
&theIconRef);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
ResObj_New, theIconRef);
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Icn_ReadIconFile(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
FSSpec iconFile;
IconFamilyHandle iconFamily;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetFSSpec, &iconFile))
return NULL;
_err = ReadIconFile(&iconFile,
&iconFamily);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
ResObj_New, iconFamily);
return _res;
}
#endif
#if TARGET_API_MAC_CARBON
static PyObject *Icn_WriteIconFile(_self, _args)
PyObject *_self;
PyObject *_args;
{
PyObject *_res = NULL;
OSErr _err;
IconFamilyHandle iconFamily;
FSSpec iconFile;
if (!PyArg_ParseTuple(_args, "O&O&",
ResObj_Convert, &iconFamily,
PyMac_GetFSSpec, &iconFile))
return NULL;
_err = WriteIconFile(iconFamily,
&iconFile);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
#endif
static PyMethodDef Icn_methods[] = { static PyMethodDef Icn_methods[] = {
{"GetCIcon", (PyCFunction)Icn_GetCIcon, 1, {"GetCIcon", (PyCFunction)Icn_GetCIcon, 1,
"(SInt16 iconID) -> (CIconHandle _rv)"}, "(SInt16 iconID) -> (CIconHandle _rv)"},
...@@ -1364,6 +1478,28 @@ static PyMethodDef Icn_methods[] = { ...@@ -1364,6 +1478,28 @@ static PyMethodDef Icn_methods[] = {
"(SInt16 vRefNum, Boolean enableCustomIcons) -> None"}, "(SInt16 vRefNum, Boolean enableCustomIcons) -> None"},
{"GetCustomIconsEnabled", (PyCFunction)Icn_GetCustomIconsEnabled, 1, {"GetCustomIconsEnabled", (PyCFunction)Icn_GetCustomIconsEnabled, 1,
"(SInt16 vRefNum) -> (Boolean customIconsEnabled)"}, "(SInt16 vRefNum) -> (Boolean customIconsEnabled)"},
{"IsIconRefMaskEmpty", (PyCFunction)Icn_IsIconRefMaskEmpty, 1,
"(IconRef iconRef) -> (Boolean _rv)"},
#if TARGET_API_MAC_CARBON
{"GetIconRefVariant", (PyCFunction)Icn_GetIconRefVariant, 1,
"(IconRef inIconRef, OSType inVariant) -> (IconRef _rv, IconTransformType outTransform)"},
#endif
#if TARGET_API_MAC_CARBON
{"RegisterIconRefFromIconFile", (PyCFunction)Icn_RegisterIconRefFromIconFile, 1,
"(OSType creator, OSType iconType, FSSpec iconFile) -> (IconRef theIconRef)"},
#endif
#if TARGET_API_MAC_CARBON
{"ReadIconFile", (PyCFunction)Icn_ReadIconFile, 1,
"(FSSpec iconFile) -> (IconFamilyHandle iconFamily)"},
#endif
#if TARGET_API_MAC_CARBON
{"WriteIconFile", (PyCFunction)Icn_WriteIconFile, 1,
"(IconFamilyHandle iconFamily, FSSpec iconFile) -> None"},
#endif
{NULL, NULL, 0} {NULL, NULL, 0}
}; };
...@@ -1383,7 +1519,7 @@ void initIcn() ...@@ -1383,7 +1519,7 @@ void initIcn()
Icn_Error = PyMac_GetOSErrException(); Icn_Error = PyMac_GetOSErrException();
if (Icn_Error == NULL || if (Icn_Error == NULL ||
PyDict_SetItemString(d, "Error", Icn_Error) != 0) PyDict_SetItemString(d, "Error", Icn_Error) != 0)
Py_FatalError("can't initialize Icn.Error"); return;
} }
/* ========================= End module Icn ========================= */ /* ========================= End module Icn ========================= */
......
...@@ -49,6 +49,12 @@ class MyScanner(Scanner): ...@@ -49,6 +49,12 @@ class MyScanner(Scanner):
return [ return [
('#if !TARGET_API_MAC_CARBON', [ ('#if !TARGET_API_MAC_CARBON', [
'IconServicesTerminate', 'IconServicesTerminate',
]),
('#if TARGET_API_MAC_CARBON', [
'WriteIconFile',
'ReadIconFile',
'RegisterIconRefFromIconFile',
'GetIconRefVariant',
])] ])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
......
This diff is collapsed.
...@@ -40,10 +40,24 @@ class MyScanner(Scanner): ...@@ -40,10 +40,24 @@ class MyScanner(Scanner):
"LDispose", # Done by removing the object "LDispose", # Done by removing the object
"LSearch", # We don't want to handle procs just yet "LSearch", # We don't want to handle procs just yet
"LGetCellDataLocation", # What does this do?? "LGetCellDataLocation", # What does this do??
# These have funny argument/return values
"GetListViewBounds",
"GetListCellIndent",
"GetListCellSize",
"GetListVisibleCells",
"GetListClickLocation",
"GetListMouseLocation",
"GetListDataBounds",
"SetListLastClick",
] ]
def makeblacklisttypes(self): def makeblacklisttypes(self):
return [ return [
'ListDefSpec', # Too difficult for now
'ListDefSpec_ptr', # ditto
"ListDefUPP",
"ListClickLoopUPP",
] ]
def makerepairinstructions(self): def makerepairinstructions(self):
......
...@@ -22,16 +22,46 @@ from macsupport import * ...@@ -22,16 +22,46 @@ from macsupport import *
# Create the type objects # Create the type objects
ListHandle = OpaqueByValueType("ListHandle", "ListObj") ListHandle = OpaqueByValueType("ListHandle", "ListObj")
ListRef = ListHandle # Obsolete, but used in Lists.h
Cell = Point Cell = Point
ListBounds = Rect
ListBounds_ptr = Rect_ptr
VarOutBufferShortsize = VarHeapOutputBufferType('char', 'short', 's') # (buf, &len) VarOutBufferShortsize = VarHeapOutputBufferType('char', 'short', 's') # (buf, &len)
InBufferShortsize = VarInputBufferType('char', 'short', 's') # (buf, len) InBufferShortsize = VarInputBufferType('char', 'short', 's') # (buf, len)
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
DataHandle = OpaqueByValueType("DataHandle", "ResObj")
Handle = OpaqueByValueType("Handle", "ResObj") Handle = OpaqueByValueType("Handle", "ResObj")
CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj")
includestuff = includestuff + """ includestuff = includestuff + """
#include <%s>""" % MACHEADERFILE + """ #include <%s>""" % MACHEADERFILE + """
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
#define GetListPort(list) ((CGrafPtr)(*(list))->port)
#define GetListVerticalScrollBar(list) ((*(list))->vScroll)
#define GetListHorizontalScrollBar(list) ((*(list))->hScroll)
#define GetListActive(list) ((*(list))->lActive)
#define GetListClickTime(list) ((*(list))->clikTime)
#define GetListRefCon(list) ((*(list))->refCon)
#define GetListDefinition(list) ((*(list))->listDefProc) /* XXX Is this indeed the same? */
#define GetListUserHandle(list) ((*(list))->userHandle)
#define GetListDataHandle(list) ((*(list))->cells)
#define GetListFlags(list) ((*(list))->listFlags)
#define GetListSelectionFlags(list) ((*(list))->selFlags)
#define SetListViewBounds(list, bounds) (((*(list))->rView) = *(bounds))
#define SetListPort(list, port) (((*(list))->port) = (GrafPtr)(port))
#define SetListCellIndent(list, ind) (((*(list))->indent) = *(ind))
#define SetListClickTime(list, time) (((*(list))->clikTime) = (time))
#define SetListLastClick(list, click) (((*(list)->lastClick) = *(click))
#define SetListRefCon(list, refcon) (((*(list))->refCon) = (refcon))
#define SetListUserHandle(list, handle) (((*(list))->userHandle) = (handle))
#define SetListFlags(list, flags) (((*(list))->listFlags) = (flags))
#define SetListSelectionFlags(list, flags) (((*(list))->selFlags) = (flags))
#endif
#define as_List(x) ((ListHandle)x) #define as_List(x) ((ListHandle)x)
#define as_Resource(lh) ((Handle)lh) #define as_Resource(lh) ((Handle)lh)
""" """
......
This diff is collapsed.
...@@ -38,6 +38,10 @@ class MyScanner(Scanner): ...@@ -38,6 +38,10 @@ class MyScanner(Scanner):
"GetMenuItemPropertySize", "GetMenuItemPropertySize",
"SetMenuItemProperty", "SetMenuItemProperty",
"RemoveMenuItemProperty", "RemoveMenuItemProperty",
"SetMenuCommandProperty",
"GetMenuCommandProperty",
"GetMenuTitle", # Funny arg/returnvalue
"SetMenuTitle",
] ]
def makegreylist(self): def makegreylist(self):
...@@ -55,6 +59,31 @@ class MyScanner(Scanner): ...@@ -55,6 +59,31 @@ class MyScanner(Scanner):
'SetMenuFlash', 'SetMenuFlash',
'InitMenus', 'InitMenus',
'InitProcMenu', 'InitProcMenu',
]),
('#if TARGET_API_MAC_CARBON', [
'DisposeMenuBar',
'DuplicateMenuBar',
'CreateNewMenu',
'GetFontFamilyFromMenuSelection',
'UpdateStandardFontMenu',
'CreateStandardFontMenu',
'RemoveMenuCommandProperty',
'GetMenuCommandPropertySize',
'IsMenuCommandEnabled',
'DisableMenuCommand',
'EnableMenuCommand',
'GetIndMenuItemWithCommandID',
'CountMenuItemsWithCommandID',
'MenuHasEnabledItems',
'EnableAllMenuItems',
'DisableAllMenuItems',
'ChangeMenuItemAttributes',
'GetMenuItemAttributes',
'ChangeMenuAttributes',
'GetMenuAttributes',
'ChangeMenuItemPropertyAttributes',
'GetMenuItemPropertyAttributes',
])] ])]
def makeblacklisttypes(self): def makeblacklisttypes(self):
...@@ -64,6 +93,9 @@ class MyScanner(Scanner): ...@@ -64,6 +93,9 @@ class MyScanner(Scanner):
'MCTablePtr', 'MCTablePtr',
'AEDesc_ptr', # For now: doable, but not easy 'AEDesc_ptr', # For now: doable, but not easy
'ProcessSerialNumber', # ditto 'ProcessSerialNumber', # ditto
"MenuDefSpecPtr", # Too difficult for now
"MenuDefSpec_ptr", # ditto
"MenuTrackingData",
] ]
def makerepairinstructions(self): def makerepairinstructions(self):
......
...@@ -25,13 +25,30 @@ from macsupport import * ...@@ -25,13 +25,30 @@ from macsupport import *
MenuHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX) MenuHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX)
MenuRef = MenuHandle MenuRef = MenuHandle
Handle = OpaqueByValueType("Handle", "ResObj") Handle = OpaqueByValueType("Handle", "ResObj")
MenuBarHandle = OpaqueByValueType("MenuBarHandle", "ResObj")
MenuID = Type("MenuID", "h")
MenuItemIndex = Type("MenuItemIndex", "h")
MenuCommand = Type("MenuCommand", "l")
MenuAttributes = Type("MenuAttributes", "l")
MenuItemAttributes = Type("MenuItemAttributes", "l")
unsigned_char = Type('unsigned char', 'b') unsigned_char = Type('unsigned char', 'b')
FMFontFamily = Type("FMFontFamily", "h")
FMFontStyle = Type("FMFontStyle", "h")
includestuff = includestuff + """ includestuff = includestuff + """
#include <Devices.h> /* Defines OpenDeskAcc in universal headers */ #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
#include <%s>""" % MACHEADERFILE + """ #include <%s>""" % MACHEADERFILE + """
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
#define GetMenuID(menu) ((*(menu))->menuID)
#define GetMenuWidth(menu) ((*(menu))->menuWidth)
#define GetMenuHeight(menu) ((*(menu))->menuHeight)
#define SetMenuID(menu, id) ((*(menu))->menuID = (id))
#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
#endif
#define as_Menu(h) ((MenuHandle)h) #define as_Menu(h) ((MenuHandle)h)
#define as_Resource(h) ((Handle)h) #define as_Resource(h) ((Handle)h)
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment