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)
|
|
|
|
|
|
|
|
|
|
|
|
#include <Balloons.h>
|
|
|
|
|
|
|
|
static PyObject *Help_Error;
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetHelpMenuHandle(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
2001-12-16 21:18:40 +01:00
|
|
|
MenuRef mh;
|
2001-08-23 16:02:09 +02:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetHelpMenuHandle(&mh);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
MenuObj_New, mh);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMRemoveBalloon(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMRemoveBalloon();
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMIsBalloon(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = HMIsBalloon();
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetBalloons(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = HMGetBalloons();
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMSetBalloons(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Boolean flag;
|
|
|
|
if (!PyArg_ParseTuple(_args, "b",
|
|
|
|
&flag))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetBalloons(flag);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMSetFont(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 font;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&font))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetFont(font);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMSetFontSize(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
UInt16 fontSize;
|
|
|
|
if (!PyArg_ParseTuple(_args, "H",
|
|
|
|
&fontSize))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetFontSize(fontSize);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetFont(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 font;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetFont(&font);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
font);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetFontSize(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
UInt16 fontSize;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetFontSize(&fontSize);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("H",
|
|
|
|
fontSize);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMSetDialogResID(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 resID;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&resID))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetDialogResID(resID);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMSetMenuResID(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 menuID;
|
|
|
|
SInt16 resID;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hh",
|
|
|
|
&menuID,
|
|
|
|
&resID))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetMenuResID(menuID,
|
|
|
|
resID);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMScanTemplateItems(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 whichID;
|
|
|
|
SInt16 whichResFile;
|
|
|
|
ResType whichType;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hhO&",
|
|
|
|
&whichID,
|
|
|
|
&whichResFile,
|
|
|
|
PyMac_GetOSType, &whichType))
|
|
|
|
return NULL;
|
|
|
|
_err = HMScanTemplateItems(whichID,
|
|
|
|
whichResFile,
|
|
|
|
whichType);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetDialogResID(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 resID;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetDialogResID(&resID);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
resID);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetMenuResID(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 menuID;
|
|
|
|
SInt16 resID;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&menuID))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetMenuResID(menuID,
|
|
|
|
&resID);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
resID);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Help_HMGetBalloonWindow(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr window;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetBalloonWindow(&window);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
2001-12-16 21:18:40 +01:00
|
|
|
WinObj_New, window);
|
2001-08-23 16:02:09 +02:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Help_methods[] = {
|
|
|
|
{"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (MenuRef mh)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (Boolean _rv)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (Boolean _rv)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(Boolean flag) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(SInt16 font) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(UInt16 fontSize) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (SInt16 font)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (UInt16 fontSize)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(SInt16 resID) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(SInt16 menuID, SInt16 resID) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (SInt16 resID)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("(SInt16 menuID) -> (SInt16 resID)")},
|
2001-08-23 16:02:09 +02:00
|
|
|
{"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
|
2002-08-16 11:09:31 +02:00
|
|
|
PyDoc_STR("() -> (WindowPtr window)")},
|
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 ======================== */
|
|
|
|
|