[Python-checkins] python/dist/src/Mac/Modules/help _Helpmodule.c,1.6,1.7 helpscan.py,1.6,1.7 helpsupport.py,1.5,1.6

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Thu, 29 Aug 2002 14:09:02 -0700


Update of /cvsroot/python/python/dist/src/Mac/Modules/help
In directory usw-pr-cvs1:/tmp/cvs-serv4709/Mac/Modules/help

Modified Files:
	_Helpmodule.c helpscan.py helpsupport.py 
Log Message:
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.


Index: _Helpmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/_Helpmodule.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** _Helpmodule.c	16 Aug 2002 09:09:26 -0000	1.6
--- _Helpmodule.c	29 Aug 2002 21:09:00 -0000	1.7
***************
*** 21,68 ****
  
  
! #include <Balloons.h>
  
  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)
  {
  	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;
--- 21,50 ----
  
  
! #ifdef WITHOUT_FRAMEWORKS
! #include <MacHelp.h>
! #else
! #include <Carbon/Carbon.h>
! #endif
  
  static PyObject *Help_Error;
  
! static PyObject *Help_HMGetHelpMenu(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	MenuRef outHelpMenu;
! 	MenuItemIndex outFirstCustomItemIndex;
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
! 	_err = HMGetHelpMenu(&outHelpMenu,
! 	                     &outFirstCustomItemIndex);
  	if (_err != noErr) return PyMac_Error(_err);
! 	_res = Py_BuildValue("O&H",
! 	                     MenuObj_New, outHelpMenu,
! 	                     outFirstCustomItemIndex);
  	return _res;
  }
  
! static PyObject *Help_HMAreHelpTagsDisplayed(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
***************
*** 70,74 ****
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
! 	_rv = HMGetBalloons();
  	_res = Py_BuildValue("b",
  	                     _rv);
--- 52,56 ----
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
! 	_rv = HMAreHelpTagsDisplayed();
  	_res = Py_BuildValue("b",
  	                     _rv);
***************
*** 76,103 ****
  }
  
! 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);
--- 58,70 ----
  }
  
! static PyObject *Help_HMSetHelpTagsDisplayed(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	Boolean inDisplayTags;
  	if (!PyArg_ParseTuple(_args, "b",
! 	                      &inDisplayTags))
  		return NULL;
! 	_err = HMSetHelpTagsDisplayed(inDisplayTags);
  	if (_err != noErr) return PyMac_Error(_err);
  	Py_INCREF(Py_None);
***************
*** 106,118 ****
  }
  
! 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);
--- 73,85 ----
  }
  
! static PyObject *Help_HMSetTagDelay(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	Duration inDelay;
! 	if (!PyArg_ParseTuple(_args, "l",
! 	                      &inDelay))
  		return NULL;
! 	_err = HMSetTagDelay(inDelay);
  	if (_err != noErr) return PyMac_Error(_err);
  	Py_INCREF(Py_None);
***************
*** 121,179 ****
  }
  
! 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);
--- 88,117 ----
  }
  
! static PyObject *Help_HMGetTagDelay(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	Duration outDelay;
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
! 	_err = HMGetTagDelay(&outDelay);
  	if (_err != noErr) return PyMac_Error(_err);
! 	_res = Py_BuildValue("l",
! 	                     outDelay);
  	return _res;
  }
  
! static PyObject *Help_HMSetMenuHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	MenuRef inMenu;
! 	SInt16 inHmnuRsrcID;
! 	if (!PyArg_ParseTuple(_args, "O&h",
! 	                      MenuObj_Convert, &inMenu,
! 	                      &inHmnuRsrcID))
  		return NULL;
! 	_err = HMSetMenuHelpFromBalloonRsrc(inMenu,
! 	                                    inHmnuRsrcID);
  	if (_err != noErr) return PyMac_Error(_err);
  	Py_INCREF(Py_None);
***************
*** 182,200 ****
  }
  
! 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);
--- 120,138 ----
  }
  
! static PyObject *Help_HMSetDialogHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
  {
  	PyObject *_res = NULL;
! 	OSStatus _err;
! 	DialogPtr inDialog;
! 	SInt16 inHdlgRsrcID;
! 	SInt16 inItemStart;
! 	if (!PyArg_ParseTuple(_args, "O&hh",
! 	                      DlgObj_Convert, &inDialog,
! 	                      &inHdlgRsrcID,
! 	                      &inItemStart))
  		return NULL;
! 	_err = HMSetDialogHelpFromBalloonRsrc(inDialog,
! 	                                      inHdlgRsrcID,
! 	                                      inItemStart);
  	if (_err != noErr) return PyMac_Error(_err);
  	Py_INCREF(Py_None);
***************
*** 203,282 ****
  }
  
- 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,
  	 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)")},
  	{NULL, NULL, 0}
  };
--- 141,159 ----
  }
  
  static PyMethodDef Help_methods[] = {
! 	{"HMGetHelpMenu", (PyCFunction)Help_HMGetHelpMenu, 1,
! 	 PyDoc_STR("() -> (MenuRef outHelpMenu, MenuItemIndex outFirstCustomItemIndex)")},
! 	{"HMAreHelpTagsDisplayed", (PyCFunction)Help_HMAreHelpTagsDisplayed, 1,
  	 PyDoc_STR("() -> (Boolean _rv)")},
! 	{"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}
  };

Index: helpscan.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/helpscan.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** helpscan.py	15 Aug 2002 21:48:14 -0000	1.6
--- helpscan.py	29 Aug 2002 21:09:00 -0000	1.7
***************
*** 7,11 ****
  from scantools import Scanner
  
! LONG = "Balloons"
  SHORT = "help"
  OBJECT = "NOTUSED"
--- 7,11 ----
  from scantools import Scanner
  
! LONG = "MacHelp"
  SHORT = "help"
  OBJECT = "NOTUSED"
***************
*** 46,58 ****
  	def makeblacklisttypes(self):
  		return [
! 			"TipFunctionUPP",
! 			"HMMessageRecord",
! 			"HMMessageRecord_ptr",
  			]
  
  	def makerepairinstructions(self):
  		return [
! 			([("WindowPtr", "*", "OutMode")],
! 			 [("ExistingWindowPtr", "*", "*")]),
  			]
  			
--- 46,65 ----
  	def makeblacklisttypes(self):
  		return [
! ##			"TipFunctionUPP",
! ##			"HMMessageRecord",
! ##			"HMMessageRecord_ptr",
! 			"HMWindowContentUPP",
! 			"HMMenuTitleContentUPP",
! 			"HMControlContentUPP",
! 			"HMMenuItemContentUPP",
! 			# For the moment
! 			"HMHelpContentRec",
! 			"HMHelpContentRec_ptr",
  			]
  
  	def makerepairinstructions(self):
  		return [
! ##			([("WindowPtr", "*", "OutMode")],
! ##			 [("ExistingWindowPtr", "*", "*")]),
  			]
  			

Index: helpsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/help/helpsupport.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** helpsupport.py	23 Aug 2001 13:49:19 -0000	1.5
--- helpsupport.py	29 Aug 2002 21:09:00 -0000	1.6
***************
*** 7,11 ****
  
  # 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
--- 7,10 ----
***************
*** 23,42 ****
  # Create the type objects
  MenuRef = OpaqueByValueType("MenuRef", "MenuObj")
! 
  
  #WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
  
! RgnHandle = FakeType("(RgnHandle)0")
  # XXXX Should be next, but this will break a lot of code...
  # RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
  
! KeyMap = ArrayOutputBufferType("KeyMap")
  ##MacOSEventKind = Type("MacOSEventKind", "h") # Old-style
  ##MacOSEventMask = Type("MacOSEventMask", "h") # Old-style
! EventMask = Type("EventMask", "H")
! EventKind = Type("EventKind", "H")
  
  includestuff = includestuff + """
! #include <%s>""" % MACHEADERFILE + """
  """
  
--- 22,45 ----
  # Create the type objects
  MenuRef = OpaqueByValueType("MenuRef", "MenuObj")
! MenuItemIndex = Type("MenuItemIndex", "H")
  
  #WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
  
! #RgnHandle = FakeType("(RgnHandle)0")
  # XXXX Should be next, but this will break a lot of code...
  # RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
  
! #KeyMap = ArrayOutputBufferType("KeyMap")
  ##MacOSEventKind = Type("MacOSEventKind", "h") # Old-style
  ##MacOSEventMask = Type("MacOSEventMask", "h") # Old-style
! #EventMask = Type("EventMask", "H")
! #EventKind = Type("EventKind", "H")
  
  includestuff = includestuff + """
! #ifdef WITHOUT_FRAMEWORKS
! #include <MacHelp.h>
! #else
! #include <Carbon/Carbon.h>
! #endif
  """