blob: fac21b6db2b758ac2bdc9432c7971790e5b3eb32 [file] [log] [blame]
Jack Jansenbf2f6021997-09-09 13:52:47 +00001
2/* ========================== Module Help =========================== */
3
4#include "Python.h"
5
6
7
Jack Jansenbf2f6021997-09-09 13:52:47 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Jack Jansenbf2f6021997-09-09 13:52:47 +000010
11#include <Balloons.h>
12
Jack Jansenbf2f6021997-09-09 13:52:47 +000013static PyObject *Help_Error;
14
15static PyObject *Help_HMGetHelpMenuHandle(_self, _args)
16 PyObject *_self;
17 PyObject *_args;
18{
19 PyObject *_res = NULL;
20 OSErr _err;
Jack Jansen21f96871998-02-20 16:02:09 +000021 MenuHandle mh;
Jack Jansenbf2f6021997-09-09 13:52:47 +000022 if (!PyArg_ParseTuple(_args, ""))
23 return NULL;
24 _err = HMGetHelpMenuHandle(&mh);
25 if (_err != noErr) return PyMac_Error(_err);
26 _res = Py_BuildValue("O&",
Jack Jansena755e681997-09-20 17:40:22 +000027 MenuObj_New, mh);
Jack Jansenbf2f6021997-09-09 13:52:47 +000028 return _res;
29}
30
31static PyObject *Help_HMRemoveBalloon(_self, _args)
32 PyObject *_self;
33 PyObject *_args;
34{
35 PyObject *_res = NULL;
36 OSErr _err;
37 if (!PyArg_ParseTuple(_args, ""))
38 return NULL;
39 _err = HMRemoveBalloon();
40 if (_err != noErr) return PyMac_Error(_err);
41 Py_INCREF(Py_None);
42 _res = Py_None;
43 return _res;
44}
45
Jack Jansen21f96871998-02-20 16:02:09 +000046static PyObject *Help_HMIsBalloon(_self, _args)
47 PyObject *_self;
48 PyObject *_args;
49{
50 PyObject *_res = NULL;
51 Boolean _rv;
52 if (!PyArg_ParseTuple(_args, ""))
53 return NULL;
54 _rv = HMIsBalloon();
55 _res = Py_BuildValue("b",
56 _rv);
57 return _res;
58}
59
Jack Jansenbf2f6021997-09-09 13:52:47 +000060static PyObject *Help_HMGetBalloons(_self, _args)
61 PyObject *_self;
62 PyObject *_args;
63{
64 PyObject *_res = NULL;
65 Boolean _rv;
66 if (!PyArg_ParseTuple(_args, ""))
67 return NULL;
68 _rv = HMGetBalloons();
69 _res = Py_BuildValue("b",
70 _rv);
71 return _res;
72}
73
74static PyObject *Help_HMSetBalloons(_self, _args)
75 PyObject *_self;
76 PyObject *_args;
77{
78 PyObject *_res = NULL;
79 OSErr _err;
80 Boolean flag;
81 if (!PyArg_ParseTuple(_args, "b",
82 &flag))
83 return NULL;
84 _err = HMSetBalloons(flag);
85 if (_err != noErr) return PyMac_Error(_err);
86 Py_INCREF(Py_None);
87 _res = Py_None;
88 return _res;
89}
90
Jack Jansenbf2f6021997-09-09 13:52:47 +000091static PyObject *Help_HMSetFont(_self, _args)
92 PyObject *_self;
93 PyObject *_args;
94{
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;
106}
107
108static PyObject *Help_HMSetFontSize(_self, _args)
109 PyObject *_self;
110 PyObject *_args;
111{
112 PyObject *_res = NULL;
113 OSErr _err;
114 UInt16 fontSize;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000115 if (!PyArg_ParseTuple(_args, "H",
Jack Jansenbf2f6021997-09-09 13:52:47 +0000116 &fontSize))
117 return NULL;
118 _err = HMSetFontSize(fontSize);
119 if (_err != noErr) return PyMac_Error(_err);
120 Py_INCREF(Py_None);
121 _res = Py_None;
122 return _res;
123}
124
125static PyObject *Help_HMGetFont(_self, _args)
126 PyObject *_self;
127 PyObject *_args;
128{
129 PyObject *_res = NULL;
130 OSErr _err;
131 SInt16 font;
132 if (!PyArg_ParseTuple(_args, ""))
133 return NULL;
134 _err = HMGetFont(&font);
135 if (_err != noErr) return PyMac_Error(_err);
136 _res = Py_BuildValue("h",
137 font);
138 return _res;
139}
140
141static PyObject *Help_HMGetFontSize(_self, _args)
142 PyObject *_self;
143 PyObject *_args;
144{
145 PyObject *_res = NULL;
146 OSErr _err;
147 UInt16 fontSize;
148 if (!PyArg_ParseTuple(_args, ""))
149 return NULL;
150 _err = HMGetFontSize(&fontSize);
151 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000152 _res = Py_BuildValue("H",
Jack Jansenbf2f6021997-09-09 13:52:47 +0000153 fontSize);
154 return _res;
155}
156
157static PyObject *Help_HMSetDialogResID(_self, _args)
158 PyObject *_self;
159 PyObject *_args;
160{
161 PyObject *_res = NULL;
162 OSErr _err;
163 SInt16 resID;
164 if (!PyArg_ParseTuple(_args, "h",
165 &resID))
166 return NULL;
167 _err = HMSetDialogResID(resID);
168 if (_err != noErr) return PyMac_Error(_err);
169 Py_INCREF(Py_None);
170 _res = Py_None;
171 return _res;
172}
173
174static PyObject *Help_HMSetMenuResID(_self, _args)
175 PyObject *_self;
176 PyObject *_args;
177{
178 PyObject *_res = NULL;
179 OSErr _err;
180 SInt16 menuID;
181 SInt16 resID;
182 if (!PyArg_ParseTuple(_args, "hh",
183 &menuID,
184 &resID))
185 return NULL;
186 _err = HMSetMenuResID(menuID,
187 resID);
188 if (_err != noErr) return PyMac_Error(_err);
189 Py_INCREF(Py_None);
190 _res = Py_None;
191 return _res;
192}
193
194static PyObject *Help_HMScanTemplateItems(_self, _args)
195 PyObject *_self;
196 PyObject *_args;
197{
198 PyObject *_res = NULL;
199 OSErr _err;
200 SInt16 whichID;
201 SInt16 whichResFile;
202 ResType whichType;
203 if (!PyArg_ParseTuple(_args, "hhO&",
204 &whichID,
205 &whichResFile,
206 PyMac_GetOSType, &whichType))
207 return NULL;
208 _err = HMScanTemplateItems(whichID,
209 whichResFile,
210 whichType);
211 if (_err != noErr) return PyMac_Error(_err);
212 Py_INCREF(Py_None);
213 _res = Py_None;
214 return _res;
215}
216
217static PyObject *Help_HMGetDialogResID(_self, _args)
218 PyObject *_self;
219 PyObject *_args;
220{
221 PyObject *_res = NULL;
222 OSErr _err;
223 SInt16 resID;
224 if (!PyArg_ParseTuple(_args, ""))
225 return NULL;
226 _err = HMGetDialogResID(&resID);
227 if (_err != noErr) return PyMac_Error(_err);
228 _res = Py_BuildValue("h",
229 resID);
230 return _res;
231}
232
233static PyObject *Help_HMGetMenuResID(_self, _args)
234 PyObject *_self;
235 PyObject *_args;
236{
237 PyObject *_res = NULL;
238 OSErr _err;
239 SInt16 menuID;
240 SInt16 resID;
241 if (!PyArg_ParseTuple(_args, "h",
242 &menuID))
243 return NULL;
244 _err = HMGetMenuResID(menuID,
245 &resID);
246 if (_err != noErr) return PyMac_Error(_err);
247 _res = Py_BuildValue("h",
248 resID);
249 return _res;
250}
251
252static PyObject *Help_HMGetBalloonWindow(_self, _args)
253 PyObject *_self;
254 PyObject *_args;
255{
256 PyObject *_res = NULL;
257 OSErr _err;
258 WindowPtr window;
259 if (!PyArg_ParseTuple(_args, ""))
260 return NULL;
261 _err = HMGetBalloonWindow(&window);
262 if (_err != noErr) return PyMac_Error(_err);
263 _res = Py_BuildValue("O&",
264 WinObj_New, window);
265 return _res;
266}
267
268static PyMethodDef Help_methods[] = {
269 {"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
Jack Jansen21f96871998-02-20 16:02:09 +0000270 "() -> (MenuHandle mh)"},
Jack Jansenbf2f6021997-09-09 13:52:47 +0000271 {"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
272 "() -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +0000273 {"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
274 "() -> (Boolean _rv)"},
Jack Jansenbf2f6021997-09-09 13:52:47 +0000275 {"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
276 "() -> (Boolean _rv)"},
277 {"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
278 "(Boolean flag) -> None"},
Jack Jansenbf2f6021997-09-09 13:52:47 +0000279 {"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
280 "(SInt16 font) -> None"},
281 {"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
282 "(UInt16 fontSize) -> None"},
283 {"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
284 "() -> (SInt16 font)"},
285 {"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
286 "() -> (UInt16 fontSize)"},
287 {"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
288 "(SInt16 resID) -> None"},
289 {"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
290 "(SInt16 menuID, SInt16 resID) -> None"},
291 {"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
292 "(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None"},
293 {"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
294 "() -> (SInt16 resID)"},
295 {"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
296 "(SInt16 menuID) -> (SInt16 resID)"},
297 {"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
298 "() -> (WindowPtr window)"},
299 {NULL, NULL, 0}
300};
301
302
303
304
305void initHelp()
306{
307 PyObject *m;
308 PyObject *d;
309
310
311
312
313 m = Py_InitModule("Help", Help_methods);
314 d = PyModule_GetDict(m);
315 Help_Error = PyMac_GetOSErrException();
316 if (Help_Error == NULL ||
317 PyDict_SetItemString(d, "Error", Help_Error) != 0)
318 Py_FatalError("can't initialize Help.Error");
319}
320
321/* ======================== End module Help ========================= */
322