summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/help
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-08-29 21:09:00 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-08-29 21:09:00 (GMT)
commit983258ed7e96897e00c7a4459034d83816018181 (patch)
tree31117f49ebc283ef7affa094343af9c32e4b6ecb /Mac/Modules/help
parentd94c28e467cc550cc09d082eb8bd078e4f2df2e4 (diff)
downloadcpython-983258ed7e96897e00c7a4459034d83816018181.zip
cpython-983258ed7e96897e00c7a4459034d83816018181.tar.gz
cpython-983258ed7e96897e00c7a4459034d83816018181.tar.bz2
Revived the Carbon.Help module, but implementing the MacHelp API in stead
of the defunct Balloons API. Help tags are TBD, but at least this gives us access to the help menu.
Diffstat (limited to 'Mac/Modules/help')
-rw-r--r--Mac/Modules/help/_Helpmodule.c257
-rw-r--r--Mac/Modules/help/helpscan.py19
-rw-r--r--Mac/Modules/help/helpsupport.py17
3 files changed, 90 insertions, 203 deletions
diff --git a/Mac/Modules/help/_Helpmodule.c b/Mac/Modules/help/_Helpmodule.c
index 66cd7b5..328bc3a 100644
--- a/Mac/Modules/help/_Helpmodule.c
+++ b/Mac/Modules/help/_Helpmodule.c
@@ -20,264 +20,141 @@
}} while(0)
-#include <Balloons.h>
+#ifdef WITHOUT_FRAMEWORKS
+#include <MacHelp.h>
+#else
+#include <Carbon/Carbon.h>
+#endif
static PyObject *Help_Error;
-static PyObject *Help_HMGetHelpMenuHandle(PyObject *_self, PyObject *_args)
-{
- PyObject *_res = NULL;
- OSErr _err;
- MenuRef mh;
- 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)
+static PyObject *Help_HMGetHelpMenu(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- OSErr _err;
+ OSStatus _err;
+ MenuRef outHelpMenu;
+ MenuItemIndex outFirstCustomItemIndex;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
- _err = HMRemoveBalloon();
+ _err = HMGetHelpMenu(&outHelpMenu,
+ &outFirstCustomItemIndex);
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);
+ _res = Py_BuildValue("O&H",
+ MenuObj_New, outHelpMenu,
+ outFirstCustomItemIndex);
return _res;
}
-static PyObject *Help_HMGetBalloons(PyObject *_self, PyObject *_args)
+static PyObject *Help_HMAreHelpTagsDisplayed(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Boolean _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
- _rv = HMGetBalloons();
+ _rv = HMAreHelpTagsDisplayed();
_res = Py_BuildValue("b",
_rv);
return _res;
}
-static PyObject *Help_HMSetBalloons(PyObject *_self, PyObject *_args)
+static PyObject *Help_HMSetHelpTagsDisplayed(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- OSErr _err;
- Boolean flag;
+ OSStatus _err;
+ Boolean inDisplayTags;
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))
+ &inDisplayTags))
return NULL;
- _err = HMSetFont(font);
+ _err = HMSetHelpTagsDisplayed(inDisplayTags);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
-static PyObject *Help_HMSetFontSize(PyObject *_self, PyObject *_args)
+static PyObject *Help_HMSetTagDelay(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- OSErr _err;
- UInt16 fontSize;
- if (!PyArg_ParseTuple(_args, "H",
- &fontSize))
+ OSStatus _err;
+ Duration inDelay;
+ if (!PyArg_ParseTuple(_args, "l",
+ &inDelay))
return NULL;
- _err = HMSetFontSize(fontSize);
+ _err = HMSetTagDelay(inDelay);
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)
+static PyObject *Help_HMGetTagDelay(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- OSErr _err;
- UInt16 fontSize;
+ OSStatus _err;
+ Duration outDelay;
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);
+ _err = HMGetTagDelay(&outDelay);
if (_err != noErr) return PyMac_Error(_err);
- Py_INCREF(Py_None);
- _res = Py_None;
+ _res = Py_BuildValue("l",
+ outDelay);
return _res;
}
-static PyObject *Help_HMSetMenuResID(PyObject *_self, PyObject *_args)
+static PyObject *Help_HMSetMenuHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- OSErr _err;
- SInt16 menuID;
- SInt16 resID;
- if (!PyArg_ParseTuple(_args, "hh",
- &menuID,
- &resID))
+ OSStatus _err;
+ MenuRef inMenu;
+ SInt16 inHmnuRsrcID;
+ if (!PyArg_ParseTuple(_args, "O&h",
+ MenuObj_Convert, &inMenu,
+ &inHmnuRsrcID))
return NULL;
- _err = HMSetMenuResID(menuID,
- resID);
+ _err = HMSetMenuHelpFromBalloonRsrc(inMenu,
+ inHmnuRsrcID);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
-static PyObject *Help_HMScanTemplateItems(PyObject *_self, PyObject *_args)
+static PyObject *Help_HMSetDialogHelpFromBalloonRsrc(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))
+ OSStatus _err;
+ DialogPtr inDialog;
+ SInt16 inHdlgRsrcID;
+ SInt16 inItemStart;
+ if (!PyArg_ParseTuple(_args, "O&hh",
+ DlgObj_Convert, &inDialog,
+ &inHdlgRsrcID,
+ &inItemStart))
return NULL;
- _err = HMScanTemplateItems(whichID,
- whichResFile,
- whichType);
+ _err = HMSetDialogHelpFromBalloonRsrc(inDialog,
+ inHdlgRsrcID,
+ inItemStart);
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&",
- WinObj_New, window);
- return _res;
-}
-
static PyMethodDef Help_methods[] = {
- {"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
- PyDoc_STR("() -> (MenuRef mh)")},
- {"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
- PyDoc_STR("() -> None")},
- {"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
- PyDoc_STR("() -> (Boolean _rv)")},
- {"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
+ {"HMGetHelpMenu", (PyCFunction)Help_HMGetHelpMenu, 1,
+ PyDoc_STR("() -> (MenuRef outHelpMenu, MenuItemIndex outFirstCustomItemIndex)")},
+ {"HMAreHelpTagsDisplayed", (PyCFunction)Help_HMAreHelpTagsDisplayed, 1,
PyDoc_STR("() -> (Boolean _rv)")},
- {"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
- PyDoc_STR("(Boolean flag) -> None")},
- {"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
- PyDoc_STR("(SInt16 font) -> None")},
- {"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
- PyDoc_STR("(UInt16 fontSize) -> None")},
- {"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
- PyDoc_STR("() -> (SInt16 font)")},
- {"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
- PyDoc_STR("() -> (UInt16 fontSize)")},
- {"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
- PyDoc_STR("(SInt16 resID) -> None")},
- {"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
- PyDoc_STR("(SInt16 menuID, SInt16 resID) -> None")},
- {"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
- PyDoc_STR("(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None")},
- {"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
- PyDoc_STR("() -> (SInt16 resID)")},
- {"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
- PyDoc_STR("(SInt16 menuID) -> (SInt16 resID)")},
- {"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
- PyDoc_STR("() -> (WindowPtr window)")},
+ {"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")},
{NULL, NULL, 0}
};
diff --git a/Mac/Modules/help/helpscan.py b/Mac/Modules/help/helpscan.py
index 67a7e53..32a759a 100644
--- a/Mac/Modules/help/helpscan.py
+++ b/Mac/Modules/help/helpscan.py
@@ -6,7 +6,7 @@ from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
-LONG = "Balloons"
+LONG = "MacHelp"
SHORT = "help"
OBJECT = "NOTUSED"
@@ -45,15 +45,22 @@ class MyScanner(Scanner):
def makeblacklisttypes(self):
return [
- "TipFunctionUPP",
- "HMMessageRecord",
- "HMMessageRecord_ptr",
+## "TipFunctionUPP",
+## "HMMessageRecord",
+## "HMMessageRecord_ptr",
+ "HMWindowContentUPP",
+ "HMMenuTitleContentUPP",
+ "HMControlContentUPP",
+ "HMMenuItemContentUPP",
+ # For the moment
+ "HMHelpContentRec",
+ "HMHelpContentRec_ptr",
]
def makerepairinstructions(self):
return [
- ([("WindowPtr", "*", "OutMode")],
- [("ExistingWindowPtr", "*", "*")]),
+## ([("WindowPtr", "*", "OutMode")],
+## [("ExistingWindowPtr", "*", "*")]),
]
if __name__ == "__main__":
diff --git a/Mac/Modules/help/helpsupport.py b/Mac/Modules/help/helpsupport.py
index 96fbfe2..26fa054 100644
--- a/Mac/Modules/help/helpsupport.py
+++ b/Mac/Modules/help/helpsupport.py
@@ -6,7 +6,6 @@
import string
# Declarations that change for each manager
-MACHEADERFILE = 'Balloons.h' # The Apple header file
MODNAME = '_Help' # The name of the module
OBJECTNAME = 'UNUSED' # The basic name of the objects used here
KIND = 'Record' # Usually 'Ptr' or 'Handle'
@@ -22,22 +21,26 @@ from macsupport import *
# Create the type objects
MenuRef = OpaqueByValueType("MenuRef", "MenuObj")
-
+MenuItemIndex = Type("MenuItemIndex", "H")
#WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
-RgnHandle = FakeType("(RgnHandle)0")
+#RgnHandle = FakeType("(RgnHandle)0")
# XXXX Should be next, but this will break a lot of code...
# RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
-KeyMap = ArrayOutputBufferType("KeyMap")
+#KeyMap = ArrayOutputBufferType("KeyMap")
##MacOSEventKind = Type("MacOSEventKind", "h") # Old-style
##MacOSEventMask = Type("MacOSEventMask", "h") # Old-style
-EventMask = Type("EventMask", "H")
-EventKind = Type("EventKind", "H")
+#EventMask = Type("EventMask", "H")
+#EventKind = Type("EventKind", "H")
includestuff = includestuff + """
-#include <%s>""" % MACHEADERFILE + """
+#ifdef WITHOUT_FRAMEWORKS
+#include <MacHelp.h>
+#else
+#include <Carbon/Carbon.h>
+#endif
"""
class MyObjectDefinition(GlobalObjectDefinition):