This commit was manufactured by cvs2svn to create tag 'r221'.
[python/dscho.git] / Mac / Modules / help / _Helpmodule.c
blob46f1a358da120b8567176e97a4d0e1e39ec936f4
2 /* ========================== Module _Help ========================== */
4 #include "Python.h"
8 #ifdef _WIN32
9 #include "pywintoolbox.h"
10 #else
11 #include "macglue.h"
12 #include "pymactoolbox.h"
13 #endif
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
19 return NULL; \
20 }} while(0)
23 #include <Balloons.h>
25 static PyObject *Help_Error;
27 static PyObject *Help_HMGetHelpMenuHandle(PyObject *_self, PyObject *_args)
29 PyObject *_res = NULL;
30 OSErr _err;
31 MenuRef mh;
32 if (!PyArg_ParseTuple(_args, ""))
33 return NULL;
34 _err = HMGetHelpMenuHandle(&mh);
35 if (_err != noErr) return PyMac_Error(_err);
36 _res = Py_BuildValue("O&",
37 MenuObj_New, mh);
38 return _res;
41 static PyObject *Help_HMRemoveBalloon(PyObject *_self, PyObject *_args)
43 PyObject *_res = NULL;
44 OSErr _err;
45 if (!PyArg_ParseTuple(_args, ""))
46 return NULL;
47 _err = HMRemoveBalloon();
48 if (_err != noErr) return PyMac_Error(_err);
49 Py_INCREF(Py_None);
50 _res = Py_None;
51 return _res;
54 static PyObject *Help_HMIsBalloon(PyObject *_self, PyObject *_args)
56 PyObject *_res = NULL;
57 Boolean _rv;
58 if (!PyArg_ParseTuple(_args, ""))
59 return NULL;
60 _rv = HMIsBalloon();
61 _res = Py_BuildValue("b",
62 _rv);
63 return _res;
66 static PyObject *Help_HMGetBalloons(PyObject *_self, PyObject *_args)
68 PyObject *_res = NULL;
69 Boolean _rv;
70 if (!PyArg_ParseTuple(_args, ""))
71 return NULL;
72 _rv = HMGetBalloons();
73 _res = Py_BuildValue("b",
74 _rv);
75 return _res;
78 static PyObject *Help_HMSetBalloons(PyObject *_self, PyObject *_args)
80 PyObject *_res = NULL;
81 OSErr _err;
82 Boolean flag;
83 if (!PyArg_ParseTuple(_args, "b",
84 &flag))
85 return NULL;
86 _err = HMSetBalloons(flag);
87 if (_err != noErr) return PyMac_Error(_err);
88 Py_INCREF(Py_None);
89 _res = Py_None;
90 return _res;
93 static PyObject *Help_HMSetFont(PyObject *_self, PyObject *_args)
95 PyObject *_res = NULL;
96 OSErr _err;
97 SInt16 font;
98 if (!PyArg_ParseTuple(_args, "h",
99 &font))
100 return NULL;
101 _err = HMSetFont(font);
102 if (_err != noErr) return PyMac_Error(_err);
103 Py_INCREF(Py_None);
104 _res = Py_None;
105 return _res;
108 static PyObject *Help_HMSetFontSize(PyObject *_self, PyObject *_args)
110 PyObject *_res = NULL;
111 OSErr _err;
112 UInt16 fontSize;
113 if (!PyArg_ParseTuple(_args, "H",
114 &fontSize))
115 return NULL;
116 _err = HMSetFontSize(fontSize);
117 if (_err != noErr) return PyMac_Error(_err);
118 Py_INCREF(Py_None);
119 _res = Py_None;
120 return _res;
123 static PyObject *Help_HMGetFont(PyObject *_self, PyObject *_args)
125 PyObject *_res = NULL;
126 OSErr _err;
127 SInt16 font;
128 if (!PyArg_ParseTuple(_args, ""))
129 return NULL;
130 _err = HMGetFont(&font);
131 if (_err != noErr) return PyMac_Error(_err);
132 _res = Py_BuildValue("h",
133 font);
134 return _res;
137 static PyObject *Help_HMGetFontSize(PyObject *_self, PyObject *_args)
139 PyObject *_res = NULL;
140 OSErr _err;
141 UInt16 fontSize;
142 if (!PyArg_ParseTuple(_args, ""))
143 return NULL;
144 _err = HMGetFontSize(&fontSize);
145 if (_err != noErr) return PyMac_Error(_err);
146 _res = Py_BuildValue("H",
147 fontSize);
148 return _res;
151 static PyObject *Help_HMSetDialogResID(PyObject *_self, PyObject *_args)
153 PyObject *_res = NULL;
154 OSErr _err;
155 SInt16 resID;
156 if (!PyArg_ParseTuple(_args, "h",
157 &resID))
158 return NULL;
159 _err = HMSetDialogResID(resID);
160 if (_err != noErr) return PyMac_Error(_err);
161 Py_INCREF(Py_None);
162 _res = Py_None;
163 return _res;
166 static PyObject *Help_HMSetMenuResID(PyObject *_self, PyObject *_args)
168 PyObject *_res = NULL;
169 OSErr _err;
170 SInt16 menuID;
171 SInt16 resID;
172 if (!PyArg_ParseTuple(_args, "hh",
173 &menuID,
174 &resID))
175 return NULL;
176 _err = HMSetMenuResID(menuID,
177 resID);
178 if (_err != noErr) return PyMac_Error(_err);
179 Py_INCREF(Py_None);
180 _res = Py_None;
181 return _res;
184 static PyObject *Help_HMScanTemplateItems(PyObject *_self, PyObject *_args)
186 PyObject *_res = NULL;
187 OSErr _err;
188 SInt16 whichID;
189 SInt16 whichResFile;
190 ResType whichType;
191 if (!PyArg_ParseTuple(_args, "hhO&",
192 &whichID,
193 &whichResFile,
194 PyMac_GetOSType, &whichType))
195 return NULL;
196 _err = HMScanTemplateItems(whichID,
197 whichResFile,
198 whichType);
199 if (_err != noErr) return PyMac_Error(_err);
200 Py_INCREF(Py_None);
201 _res = Py_None;
202 return _res;
205 static PyObject *Help_HMGetDialogResID(PyObject *_self, PyObject *_args)
207 PyObject *_res = NULL;
208 OSErr _err;
209 SInt16 resID;
210 if (!PyArg_ParseTuple(_args, ""))
211 return NULL;
212 _err = HMGetDialogResID(&resID);
213 if (_err != noErr) return PyMac_Error(_err);
214 _res = Py_BuildValue("h",
215 resID);
216 return _res;
219 static PyObject *Help_HMGetMenuResID(PyObject *_self, PyObject *_args)
221 PyObject *_res = NULL;
222 OSErr _err;
223 SInt16 menuID;
224 SInt16 resID;
225 if (!PyArg_ParseTuple(_args, "h",
226 &menuID))
227 return NULL;
228 _err = HMGetMenuResID(menuID,
229 &resID);
230 if (_err != noErr) return PyMac_Error(_err);
231 _res = Py_BuildValue("h",
232 resID);
233 return _res;
236 static PyObject *Help_HMGetBalloonWindow(PyObject *_self, PyObject *_args)
238 PyObject *_res = NULL;
239 OSErr _err;
240 WindowPtr window;
241 if (!PyArg_ParseTuple(_args, ""))
242 return NULL;
243 _err = HMGetBalloonWindow(&window);
244 if (_err != noErr) return PyMac_Error(_err);
245 _res = Py_BuildValue("O&",
246 WinObj_New, window);
247 return _res;
250 static PyMethodDef Help_methods[] = {
251 {"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
252 "() -> (MenuRef mh)"},
253 {"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
254 "() -> None"},
255 {"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
256 "() -> (Boolean _rv)"},
257 {"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
258 "() -> (Boolean _rv)"},
259 {"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
260 "(Boolean flag) -> None"},
261 {"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
262 "(SInt16 font) -> None"},
263 {"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
264 "(UInt16 fontSize) -> None"},
265 {"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
266 "() -> (SInt16 font)"},
267 {"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
268 "() -> (UInt16 fontSize)"},
269 {"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
270 "(SInt16 resID) -> None"},
271 {"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
272 "(SInt16 menuID, SInt16 resID) -> None"},
273 {"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
274 "(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None"},
275 {"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
276 "() -> (SInt16 resID)"},
277 {"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
278 "(SInt16 menuID) -> (SInt16 resID)"},
279 {"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
280 "() -> (WindowPtr window)"},
281 {NULL, NULL, 0}
287 void init_Help(void)
289 PyObject *m;
290 PyObject *d;
295 m = Py_InitModule("_Help", Help_methods);
296 d = PyModule_GetDict(m);
297 Help_Error = PyMac_GetOSErrException();
298 if (Help_Error == NULL ||
299 PyDict_SetItemString(d, "Error", Help_Error) != 0)
300 return;
303 /* ======================== End module _Help ======================== */