Added 'description' class attribute to every command class (to help the
[python/dscho.git] / Mac / Modules / help / Helpmodule.c
blob9f5c6c45ae6e5a63ef3b7a980d452b5fbaf22c62
2 /* ========================== Module Help =========================== */
4 #include "Python.h"
8 #define SystemSevenOrLater 1
10 #include "macglue.h"
11 #include <Memory.h>
12 #include <Dialogs.h>
13 #include <Menus.h>
14 #include <Controls.h>
16 extern PyObject *ResObj_New(Handle);
17 extern int ResObj_Convert(PyObject *, Handle *);
18 extern PyObject *OptResObj_New(Handle);
19 extern int OptResObj_Convert(PyObject *, Handle *);
21 extern PyObject *WinObj_New(WindowPtr);
22 extern int WinObj_Convert(PyObject *, WindowPtr *);
23 extern PyTypeObject Window_Type;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject *DlgObj_New(DialogPtr);
27 extern int DlgObj_Convert(PyObject *, DialogPtr *);
28 extern PyTypeObject Dialog_Type;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject *MenuObj_New(MenuHandle);
32 extern int MenuObj_Convert(PyObject *, MenuHandle *);
34 extern PyObject *CtlObj_New(ControlHandle);
35 extern int CtlObj_Convert(PyObject *, ControlHandle *);
37 extern PyObject *GrafObj_New(GrafPtr);
38 extern int GrafObj_Convert(PyObject *, GrafPtr *);
40 extern PyObject *BMObj_New(BitMapPtr);
41 extern int BMObj_Convert(PyObject *, BitMapPtr *);
43 extern PyObject *WinObj_WhichWindow(WindowPtr);
45 #include <Balloons.h>
47 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
49 static PyObject *Help_Error;
51 static PyObject *Help_HMGetHelpMenuHandle(_self, _args)
52 PyObject *_self;
53 PyObject *_args;
55 PyObject *_res = NULL;
56 OSErr _err;
57 MenuHandle mh;
58 if (!PyArg_ParseTuple(_args, ""))
59 return NULL;
60 _err = HMGetHelpMenuHandle(&mh);
61 if (_err != noErr) return PyMac_Error(_err);
62 _res = Py_BuildValue("O&",
63 MenuObj_New, mh);
64 return _res;
67 static PyObject *Help_HMRemoveBalloon(_self, _args)
68 PyObject *_self;
69 PyObject *_args;
71 PyObject *_res = NULL;
72 OSErr _err;
73 if (!PyArg_ParseTuple(_args, ""))
74 return NULL;
75 _err = HMRemoveBalloon();
76 if (_err != noErr) return PyMac_Error(_err);
77 Py_INCREF(Py_None);
78 _res = Py_None;
79 return _res;
82 static PyObject *Help_HMIsBalloon(_self, _args)
83 PyObject *_self;
84 PyObject *_args;
86 PyObject *_res = NULL;
87 Boolean _rv;
88 if (!PyArg_ParseTuple(_args, ""))
89 return NULL;
90 _rv = HMIsBalloon();
91 _res = Py_BuildValue("b",
92 _rv);
93 return _res;
96 static PyObject *Help_HMGetBalloons(_self, _args)
97 PyObject *_self;
98 PyObject *_args;
100 PyObject *_res = NULL;
101 Boolean _rv;
102 if (!PyArg_ParseTuple(_args, ""))
103 return NULL;
104 _rv = HMGetBalloons();
105 _res = Py_BuildValue("b",
106 _rv);
107 return _res;
110 static PyObject *Help_HMSetBalloons(_self, _args)
111 PyObject *_self;
112 PyObject *_args;
114 PyObject *_res = NULL;
115 OSErr _err;
116 Boolean flag;
117 if (!PyArg_ParseTuple(_args, "b",
118 &flag))
119 return NULL;
120 _err = HMSetBalloons(flag);
121 if (_err != noErr) return PyMac_Error(_err);
122 Py_INCREF(Py_None);
123 _res = Py_None;
124 return _res;
127 static PyObject *Help_HMSetFont(_self, _args)
128 PyObject *_self;
129 PyObject *_args;
131 PyObject *_res = NULL;
132 OSErr _err;
133 SInt16 font;
134 if (!PyArg_ParseTuple(_args, "h",
135 &font))
136 return NULL;
137 _err = HMSetFont(font);
138 if (_err != noErr) return PyMac_Error(_err);
139 Py_INCREF(Py_None);
140 _res = Py_None;
141 return _res;
144 static PyObject *Help_HMSetFontSize(_self, _args)
145 PyObject *_self;
146 PyObject *_args;
148 PyObject *_res = NULL;
149 OSErr _err;
150 UInt16 fontSize;
151 if (!PyArg_ParseTuple(_args, "h",
152 &fontSize))
153 return NULL;
154 _err = HMSetFontSize(fontSize);
155 if (_err != noErr) return PyMac_Error(_err);
156 Py_INCREF(Py_None);
157 _res = Py_None;
158 return _res;
161 static PyObject *Help_HMGetFont(_self, _args)
162 PyObject *_self;
163 PyObject *_args;
165 PyObject *_res = NULL;
166 OSErr _err;
167 SInt16 font;
168 if (!PyArg_ParseTuple(_args, ""))
169 return NULL;
170 _err = HMGetFont(&font);
171 if (_err != noErr) return PyMac_Error(_err);
172 _res = Py_BuildValue("h",
173 font);
174 return _res;
177 static PyObject *Help_HMGetFontSize(_self, _args)
178 PyObject *_self;
179 PyObject *_args;
181 PyObject *_res = NULL;
182 OSErr _err;
183 UInt16 fontSize;
184 if (!PyArg_ParseTuple(_args, ""))
185 return NULL;
186 _err = HMGetFontSize(&fontSize);
187 if (_err != noErr) return PyMac_Error(_err);
188 _res = Py_BuildValue("h",
189 fontSize);
190 return _res;
193 static PyObject *Help_HMSetDialogResID(_self, _args)
194 PyObject *_self;
195 PyObject *_args;
197 PyObject *_res = NULL;
198 OSErr _err;
199 SInt16 resID;
200 if (!PyArg_ParseTuple(_args, "h",
201 &resID))
202 return NULL;
203 _err = HMSetDialogResID(resID);
204 if (_err != noErr) return PyMac_Error(_err);
205 Py_INCREF(Py_None);
206 _res = Py_None;
207 return _res;
210 static PyObject *Help_HMSetMenuResID(_self, _args)
211 PyObject *_self;
212 PyObject *_args;
214 PyObject *_res = NULL;
215 OSErr _err;
216 SInt16 menuID;
217 SInt16 resID;
218 if (!PyArg_ParseTuple(_args, "hh",
219 &menuID,
220 &resID))
221 return NULL;
222 _err = HMSetMenuResID(menuID,
223 resID);
224 if (_err != noErr) return PyMac_Error(_err);
225 Py_INCREF(Py_None);
226 _res = Py_None;
227 return _res;
230 static PyObject *Help_HMScanTemplateItems(_self, _args)
231 PyObject *_self;
232 PyObject *_args;
234 PyObject *_res = NULL;
235 OSErr _err;
236 SInt16 whichID;
237 SInt16 whichResFile;
238 ResType whichType;
239 if (!PyArg_ParseTuple(_args, "hhO&",
240 &whichID,
241 &whichResFile,
242 PyMac_GetOSType, &whichType))
243 return NULL;
244 _err = HMScanTemplateItems(whichID,
245 whichResFile,
246 whichType);
247 if (_err != noErr) return PyMac_Error(_err);
248 Py_INCREF(Py_None);
249 _res = Py_None;
250 return _res;
253 static PyObject *Help_HMGetDialogResID(_self, _args)
254 PyObject *_self;
255 PyObject *_args;
257 PyObject *_res = NULL;
258 OSErr _err;
259 SInt16 resID;
260 if (!PyArg_ParseTuple(_args, ""))
261 return NULL;
262 _err = HMGetDialogResID(&resID);
263 if (_err != noErr) return PyMac_Error(_err);
264 _res = Py_BuildValue("h",
265 resID);
266 return _res;
269 static PyObject *Help_HMGetMenuResID(_self, _args)
270 PyObject *_self;
271 PyObject *_args;
273 PyObject *_res = NULL;
274 OSErr _err;
275 SInt16 menuID;
276 SInt16 resID;
277 if (!PyArg_ParseTuple(_args, "h",
278 &menuID))
279 return NULL;
280 _err = HMGetMenuResID(menuID,
281 &resID);
282 if (_err != noErr) return PyMac_Error(_err);
283 _res = Py_BuildValue("h",
284 resID);
285 return _res;
288 static PyObject *Help_HMGetBalloonWindow(_self, _args)
289 PyObject *_self;
290 PyObject *_args;
292 PyObject *_res = NULL;
293 OSErr _err;
294 WindowPtr window;
295 if (!PyArg_ParseTuple(_args, ""))
296 return NULL;
297 _err = HMGetBalloonWindow(&window);
298 if (_err != noErr) return PyMac_Error(_err);
299 _res = Py_BuildValue("O&",
300 WinObj_New, window);
301 return _res;
304 static PyMethodDef Help_methods[] = {
305 {"HMGetHelpMenuHandle", (PyCFunction)Help_HMGetHelpMenuHandle, 1,
306 "() -> (MenuHandle mh)"},
307 {"HMRemoveBalloon", (PyCFunction)Help_HMRemoveBalloon, 1,
308 "() -> None"},
309 {"HMIsBalloon", (PyCFunction)Help_HMIsBalloon, 1,
310 "() -> (Boolean _rv)"},
311 {"HMGetBalloons", (PyCFunction)Help_HMGetBalloons, 1,
312 "() -> (Boolean _rv)"},
313 {"HMSetBalloons", (PyCFunction)Help_HMSetBalloons, 1,
314 "(Boolean flag) -> None"},
315 {"HMSetFont", (PyCFunction)Help_HMSetFont, 1,
316 "(SInt16 font) -> None"},
317 {"HMSetFontSize", (PyCFunction)Help_HMSetFontSize, 1,
318 "(UInt16 fontSize) -> None"},
319 {"HMGetFont", (PyCFunction)Help_HMGetFont, 1,
320 "() -> (SInt16 font)"},
321 {"HMGetFontSize", (PyCFunction)Help_HMGetFontSize, 1,
322 "() -> (UInt16 fontSize)"},
323 {"HMSetDialogResID", (PyCFunction)Help_HMSetDialogResID, 1,
324 "(SInt16 resID) -> None"},
325 {"HMSetMenuResID", (PyCFunction)Help_HMSetMenuResID, 1,
326 "(SInt16 menuID, SInt16 resID) -> None"},
327 {"HMScanTemplateItems", (PyCFunction)Help_HMScanTemplateItems, 1,
328 "(SInt16 whichID, SInt16 whichResFile, ResType whichType) -> None"},
329 {"HMGetDialogResID", (PyCFunction)Help_HMGetDialogResID, 1,
330 "() -> (SInt16 resID)"},
331 {"HMGetMenuResID", (PyCFunction)Help_HMGetMenuResID, 1,
332 "(SInt16 menuID) -> (SInt16 resID)"},
333 {"HMGetBalloonWindow", (PyCFunction)Help_HMGetBalloonWindow, 1,
334 "() -> (WindowPtr window)"},
335 {NULL, NULL, 0}
341 void initHelp()
343 PyObject *m;
344 PyObject *d;
349 m = Py_InitModule("Help", Help_methods);
350 d = PyModule_GetDict(m);
351 Help_Error = PyMac_GetOSErrException();
352 if (Help_Error == NULL ||
353 PyDict_SetItemString(d, "Error", Help_Error) != 0)
354 Py_FatalError("can't initialize Help.Error");
357 /* ======================== End module Help ========================= */