2001-08-23 16:02:09 +02:00
|
|
|
|
|
|
|
/* ========================== Module _Help ========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-18 16:39:38 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "pywintoolbox.h"
|
|
|
|
#else
|
2001-08-23 16:02:09 +02:00
|
|
|
#include "macglue.h"
|
|
|
|
#include "pymactoolbox.h"
|
2001-12-18 16:39:38 +01:00
|
|
|
#endif
|
2001-08-23 16:02:09 +02:00
|
|
|
|
|
|
|
/* Macro to test whether a weak-loaded CFM function exists */
|
|
|
|
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError, \
|
|
|
|
"Not available in this shared library/OS version"); \
|
|
|
|
return NULL; \
|
|
|
|
}} while(0)
|
|
|
|
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
#ifdef WITHOUT_FRAMEWORKS
|
|
|
|
#include <MacHelp.h>
|
|
|
|
#else
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#endif
|
2001-08-23 16:02:09 +02:00
|
|
|
|
|
|
|
static PyObject *Help_Error;
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMGetHelpMenu(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
MenuRef outHelpMenu;
|
|
|
|
MenuItemIndex outFirstCustomItemIndex;
|
2001-08-23 16:02:09 +02:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMGetHelpMenu(&outHelpMenu,
|
|
|
|
&outFirstCustomItemIndex);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
2002-08-29 23:09:00 +02:00
|
|
|
_res = Py_BuildValue("O&H",
|
|
|
|
MenuObj_New, outHelpMenu,
|
|
|
|
outFirstCustomItemIndex);
|
2001-08-23 16:02:09 +02:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMAreHelpTagsDisplayed(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_rv = HMAreHelpTagsDisplayed();
|
2001-08-23 16:02:09 +02:00
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMSetHelpTagsDisplayed(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
Boolean inDisplayTags;
|
2001-08-23 16:02:09 +02:00
|
|
|
if (!PyArg_ParseTuple(_args, "b",
|
2002-08-29 23:09:00 +02:00
|
|
|
&inDisplayTags))
|
2001-08-23 16:02:09 +02:00
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMSetHelpTagsDisplayed(inDisplayTags);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMSetTagDelay(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
Duration inDelay;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&inDelay))
|
2001-08-23 16:02:09 +02:00
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMSetTagDelay(inDelay);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMGetTagDelay(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
Duration outDelay;
|
2001-08-23 16:02:09 +02:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMGetTagDelay(&outDelay);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
2002-08-29 23:09:00 +02:00
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
outDelay);
|
2001-08-23 16:02:09 +02:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMSetMenuHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
MenuRef inMenu;
|
|
|
|
SInt16 inHmnuRsrcID;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
MenuObj_Convert, &inMenu,
|
|
|
|
&inHmnuRsrcID))
|
2001-08-23 16:02:09 +02:00
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMSetMenuHelpFromBalloonRsrc(inMenu,
|
|
|
|
inHmnuRsrcID);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2002-08-29 23:09:00 +02:00
|
|
|
static PyObject *Help_HMSetDialogHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
|
2001-08-23 16:02:09 +02:00
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
OSStatus _err;
|
|
|
|
DialogPtr inDialog;
|
|
|
|
SInt16 inHdlgRsrcID;
|
|
|
|
SInt16 inItemStart;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&hh",
|
|
|
|
DlgObj_Convert, &inDialog,
|
|
|
|
&inHdlgRsrcID,
|
|
|
|
&inItemStart))
|
2001-08-23 16:02:09 +02:00
|
|
|
return NULL;
|
2002-08-29 23:09:00 +02:00
|
|
|
_err = HMSetDialogHelpFromBalloonRsrc(inDialog,
|
|
|
|
inHdlgRsrcID,
|
|
|
|
inItemStart);
|
2001-08-23 16:02:09 +02:00
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Help_methods[] = {
|
2002-08-29 23:09:00 +02:00
|
|
|
{"HMGetHelpMenu", (PyCFunction)Help_HMGetHelpMenu, 1,
|
|
|
|
PyDoc_STR("() -> (MenuRef outHelpMenu, MenuItemIndex outFirstCustomItemIndex)")},
|
|
|
|
{"HMAreHelpTagsDisplayed", (PyCFunction)Help_HMAreHelpTagsDisplayed, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (Boolean _rv)")},
|
2002-08-29 23:09:00 +02:00
|
|
|
{"HMSetHelpTagsDisplayed", (PyCFunction)Help_HMSetHelpTagsDisplayed, 1,
|
|
|
|
PyDoc_STR("(Boolean inDisplayTags) -> None")},
|
|
|
|
{"HMSetTagDelay", (PyCFunction)Help_HMSetTagDelay, 1,
|
|
|
|
PyDoc_STR("(Duration inDelay) -> None")},
|
|
|
|
{"HMGetTagDelay", (PyCFunction)Help_HMGetTagDelay, 1,
|
|
|
|
PyDoc_STR("() -> (Duration outDelay)")},
|
|
|
|
{"HMSetMenuHelpFromBalloonRsrc", (PyCFunction)Help_HMSetMenuHelpFromBalloonRsrc, 1,
|
|
|
|
PyDoc_STR("(MenuRef inMenu, SInt16 inHmnuRsrcID) -> None")},
|
|
|
|
{"HMSetDialogHelpFromBalloonRsrc", (PyCFunction)Help_HMSetDialogHelpFromBalloonRsrc, 1,
|
|
|
|
PyDoc_STR("(DialogPtr inDialog, SInt16 inHdlgRsrcID, SInt16 inItemStart) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void init_Help(void)
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m = Py_InitModule("_Help", Help_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Help_Error = PyMac_GetOSErrException();
|
|
|
|
if (Help_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Help_Error) != 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================== End module _Help ======================== */
|
|
|
|
|