diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-12-10 23:43:49 (GMT) |
commit | f7d5aa61d34cb7816ead2757860e5a66f7da0dcb (patch) | |
tree | faba3f23c2f0fdfa74a156d441f6fa8945c337f8 /Mac/Modules/dlg | |
parent | c6c283840316dec54244b311657511e95e742eb0 (diff) | |
download | cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.zip cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.gz cpython-f7d5aa61d34cb7816ead2757860e5a66f7da0dcb.tar.bz2 |
Adapted to Universal Headers 3.3.2. More to follow.
Diffstat (limited to 'Mac/Modules/dlg')
-rw-r--r-- | Mac/Modules/dlg/Dlgmodule.c | 186 | ||||
-rw-r--r-- | Mac/Modules/dlg/dlgscan.py | 7 | ||||
-rw-r--r-- | Mac/Modules/dlg/dlgsupport.py | 25 |
3 files changed, 208 insertions, 10 deletions
diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c index b686839..3ab14a0 100644 --- a/Mac/Modules/dlg/Dlgmodule.c +++ b/Mac/Modules/dlg/Dlgmodule.c @@ -10,6 +10,13 @@ #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? */ static PyObject *Dlg_FilterProc_callback = NULL; @@ -399,6 +406,63 @@ static PyObject *DlgObj_ShortenDITL(_self, _args) 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) DialogObject *_self; PyObject *_args; @@ -666,7 +730,21 @@ static PyObject *DlgObj_GetDialogWindow(_self, _args) return NULL; _rv = GetDialogWindow(_self->ob_itself); _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; } @@ -712,6 +790,33 @@ static PyObject *DlgObj_GetDialogKeyboardFocusItem(_self, _args) 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 static PyObject *DlgObj_SetGrafPortOfDialog(_self, _args) @@ -759,6 +864,16 @@ static PyMethodDef DlgObj_methods[] = { "() -> (DialogItemIndex _rv)"}, {"ShortenDITL", (PyCFunction)DlgObj_ShortenDITL, 1, "(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, "() -> (Boolean _rv, EventRecord event, DialogItemIndex itemHit)"}, {"SetDialogDefaultItem", (PyCFunction)DlgObj_SetDialogDefaultItem, 1, @@ -787,12 +902,18 @@ static PyMethodDef DlgObj_methods[] = { "() -> (EventMask outMask)"}, {"GetDialogWindow", (PyCFunction)DlgObj_GetDialogWindow, 1, "() -> (WindowPtr _rv)"}, + {"GetDialogTextEditHandle", (PyCFunction)DlgObj_GetDialogTextEditHandle, 1, + "() -> (TEHandle _rv)"}, {"GetDialogDefaultItem", (PyCFunction)DlgObj_GetDialogDefaultItem, 1, "() -> (SInt16 _rv)"}, {"GetDialogCancelItem", (PyCFunction)DlgObj_GetDialogCancelItem, 1, "() -> (SInt16 _rv)"}, {"GetDialogKeyboardFocusItem", (PyCFunction)DlgObj_GetDialogKeyboardFocusItem, 1, "() -> (SInt16 _rv)"}, + {"SetPortDialogPort", (PyCFunction)DlgObj_SetPortDialogPort, 1, + "() -> None"}, + {"GetDialogPort", (PyCFunction)DlgObj_GetDialogPort, 1, + "() -> (CGrafPtr _rv)"}, #if !TARGET_API_MAC_CARBON {"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1, @@ -1168,6 +1289,33 @@ static PyObject *Dlg_ResetAlertStage(_self, _args) 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) PyObject *_self; PyObject *_args; @@ -1209,6 +1357,22 @@ static PyObject *Dlg_NewFeaturesDialog(_self, _args) 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) PyObject *_self; PyObject *_args; @@ -1273,8 +1437,15 @@ static PyMethodDef Dlg_methods[] = { "(SInt16 fontNum) -> None"}, {"ResetAlertStage", (PyCFunction)Dlg_ResetAlertStage, 1, "() -> 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, "(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, NULL}, {NULL, NULL, 0} @@ -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() { @@ -1296,7 +1478,7 @@ void initDlg() Dlg_Error = PyMac_GetOSErrException(); if (Dlg_Error == NULL || PyDict_SetItemString(d, "Error", Dlg_Error) != 0) - Py_FatalError("can't initialize Dlg.Error"); + return; Dialog_Type.ob_type = &PyType_Type; Py_INCREF(&Dialog_Type); if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0) diff --git a/Mac/Modules/dlg/dlgscan.py b/Mac/Modules/dlg/dlgscan.py index 3092dec..549d0b3 100644 --- a/Mac/Modules/dlg/dlgscan.py +++ b/Mac/Modules/dlg/dlgscan.py @@ -59,11 +59,18 @@ class MyScanner(Scanner): return [ ('#if !TARGET_API_MAC_CARBON', [ 'SetGrafPortOfDialog', + ]), + ('#if TARGET_API_MAC_CARBON', [ + 'InsertDialogItem', + 'RemoveDialogItems', + 'GetParamText', ])] def makeblacklisttypes(self): return [ "AlertStdAlertParamPtr", # Too much work, for now + "AlertStdAlertParamRec", # ditto + "AlertStdAlertParamRec_ptr", # ditto "QTModelessCallbackProcPtr", ] diff --git a/Mac/Modules/dlg/dlgsupport.py b/Mac/Modules/dlg/dlgsupport.py index f243cc1..e537c66 100644 --- a/Mac/Modules/dlg/dlgsupport.py +++ b/Mac/Modules/dlg/dlgsupport.py @@ -19,6 +19,8 @@ ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterPr ModalFilterUPP = ModalFilterProcPtr RgnHandle = OpaqueByValueType("RgnHandle", "ResObj") +TEHandle = OpaqueByValueType("TEHandle", "ResObj") +CGrafPtr = OpaqueByValueType("CGrafPtr", "GrafObj") DITLMethod = Type("DITLMethod", "h") DialogItemIndex = Type("DialogItemIndex", "h") @@ -31,6 +33,13 @@ EventMask = Type("EventMask", "H") includestuff = includestuff + """ #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? */ static PyObject *Dlg_FilterProc_callback = NULL; @@ -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 # in MacOS 8. -f = Method(ExistingWindowPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) -object.add(f) -f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode)) -object.add(f) -f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode)) -object.add(f) -f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode)) -object.add(f) +##f = Method(ExistingWindowPtr, 'GetDialogWindow', (DialogRef, 'dialog', InMode)) +##object.add(f) +##f = Method(SInt16, 'GetDialogDefaultItem', (DialogRef, 'dialog', InMode)) +##object.add(f) +##f = Method(SInt16, 'GetDialogCancelItem', (DialogRef, 'dialog', InMode)) +##object.add(f) +##f = Method(SInt16, 'GetDialogKeyboardFocusItem', (DialogRef, 'dialog', InMode)) +##object.add(f) f = Method(void, 'SetGrafPortOfDialog', (DialogRef, 'dialog', InMode), condition='#if !TARGET_API_MAC_CARBON') object.add(f) |