blob: f3c2df96a85a48946aa2a986a43feba11bf28068 [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* ========================== Module Menu =========================== */
3
4#include "Python.h"
5
6
7
Guido van Rossum17448e21995-01-30 11:53:55 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Guido van Rossum17448e21995-01-30 11:53:55 +000010
Jack Jansenfa77e1a2001-05-22 21:56:42 +000011#ifdef WITHOUT_FRAMEWORKS
Guido van Rossum86c3af71995-03-19 22:42:51 +000012#include <Devices.h> /* Defines OpenDeskAcc in universal headers */
Guido van Rossum17448e21995-01-30 11:53:55 +000013#include <Menus.h>
Jack Jansenfa77e1a2001-05-22 21:56:42 +000014#else
15#include <Carbon/Carbon.h>
16#endif
17
Guido van Rossum17448e21995-01-30 11:53:55 +000018
Jack Jansen0e04eec2001-05-17 21:58:34 +000019#ifdef USE_TOOLBOX_OBJECT_GLUE
20
21extern PyObject *_MenuObj_New(MenuHandle);
22extern int _MenuObj_Convert(PyObject *, MenuHandle *);
23
24#define MenuObj_New _MenuObj_New
25#define MenuObj_Convert _MenuObj_Convert
26#endif
27
Jack Jansenf7d5aa62000-12-10 23:43:49 +000028#if !ACCESSOR_CALLS_ARE_FUNCTIONS
29#define GetMenuID(menu) ((*(menu))->menuID)
30#define GetMenuWidth(menu) ((*(menu))->menuWidth)
31#define GetMenuHeight(menu) ((*(menu))->menuHeight)
32
33#define SetMenuID(menu, id) ((*(menu))->menuID = (id))
34#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
35#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
36#endif
37
Jack Jansene0581891999-02-07 14:02:03 +000038#define as_Menu(h) ((MenuHandle)h)
Jack Jansena1a0fef1999-12-23 14:32:06 +000039#define as_Resource(h) ((Handle)h)
Jack Jansene0581891999-02-07 14:02:03 +000040
Guido van Rossum17448e21995-01-30 11:53:55 +000041static PyObject *Menu_Error;
42
43/* ------------------------ Object type Menu ------------------------ */
44
45PyTypeObject Menu_Type;
46
47#define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
48
49typedef struct MenuObject {
50 PyObject_HEAD
51 MenuHandle ob_itself;
52} MenuObject;
53
Jack Jansenfa77e1a2001-05-22 21:56:42 +000054PyObject *MenuObj_New(MenuHandle itself)
Guido van Rossum17448e21995-01-30 11:53:55 +000055{
56 MenuObject *it;
57 it = PyObject_NEW(MenuObject, &Menu_Type);
58 if (it == NULL) return NULL;
59 it->ob_itself = itself;
60 return (PyObject *)it;
61}
Jack Jansenfa77e1a2001-05-22 21:56:42 +000062MenuObj_Convert(PyObject *v, MenuHandle *p_itself)
Guido van Rossum17448e21995-01-30 11:53:55 +000063{
64 if (!MenuObj_Check(v))
65 {
66 PyErr_SetString(PyExc_TypeError, "Menu required");
67 return 0;
68 }
69 *p_itself = ((MenuObject *)v)->ob_itself;
70 return 1;
71}
72
Jack Jansenfa77e1a2001-05-22 21:56:42 +000073static void MenuObj_dealloc(MenuObject *self)
Guido van Rossum17448e21995-01-30 11:53:55 +000074{
75 /* Cleanup of self->ob_itself goes here */
76 PyMem_DEL(self);
77}
78
Jack Jansenfa77e1a2001-05-22 21:56:42 +000079static PyObject *MenuObj_DisposeMenu(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +000080{
81 PyObject *_res = NULL;
82 if (!PyArg_ParseTuple(_args, ""))
83 return NULL;
84 DisposeMenu(_self->ob_itself);
85 Py_INCREF(Py_None);
86 _res = Py_None;
87 return _res;
88}
89
Jack Jansenfa77e1a2001-05-22 21:56:42 +000090static PyObject *MenuObj_CalcMenuSize(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +000091{
92 PyObject *_res = NULL;
93 if (!PyArg_ParseTuple(_args, ""))
94 return NULL;
95 CalcMenuSize(_self->ob_itself);
96 Py_INCREF(Py_None);
97 _res = Py_None;
98 return _res;
99}
100
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000101static PyObject *MenuObj_CountMenuItems(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000102{
103 PyObject *_res = NULL;
104 short _rv;
105 if (!PyArg_ParseTuple(_args, ""))
106 return NULL;
107 _rv = CountMenuItems(_self->ob_itself);
108 _res = Py_BuildValue("h",
109 _rv);
110 return _res;
111}
112
Jack Jansen74a1e632000-07-14 22:37:27 +0000113#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000114
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000115static PyObject *MenuObj_CountMItems(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000116{
117 PyObject *_res = NULL;
118 short _rv;
119 if (!PyArg_ParseTuple(_args, ""))
120 return NULL;
121 _rv = CountMItems(_self->ob_itself);
122 _res = Py_BuildValue("h",
123 _rv);
124 return _res;
125}
Jack Jansene79dc762000-06-02 21:35:07 +0000126#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000127
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000128static PyObject *MenuObj_GetMenuFont(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000129{
130 PyObject *_res = NULL;
131 OSStatus _err;
132 SInt16 outFontID;
133 UInt16 outFontSize;
134 if (!PyArg_ParseTuple(_args, ""))
135 return NULL;
136 _err = GetMenuFont(_self->ob_itself,
137 &outFontID,
138 &outFontSize);
139 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000140 _res = Py_BuildValue("hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000141 outFontID,
142 outFontSize);
143 return _res;
144}
145
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000146static PyObject *MenuObj_SetMenuFont(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000147{
148 PyObject *_res = NULL;
149 OSStatus _err;
150 SInt16 inFontID;
151 UInt16 inFontSize;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000152 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000153 &inFontID,
154 &inFontSize))
155 return NULL;
156 _err = SetMenuFont(_self->ob_itself,
157 inFontID,
158 inFontSize);
159 if (_err != noErr) return PyMac_Error(_err);
160 Py_INCREF(Py_None);
161 _res = Py_None;
162 return _res;
163}
164
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000165static PyObject *MenuObj_GetMenuExcludesMarkColumn(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000166{
167 PyObject *_res = NULL;
168 Boolean _rv;
169 if (!PyArg_ParseTuple(_args, ""))
170 return NULL;
171 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
172 _res = Py_BuildValue("b",
173 _rv);
174 return _res;
175}
176
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000177static PyObject *MenuObj_SetMenuExcludesMarkColumn(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000178{
179 PyObject *_res = NULL;
180 OSStatus _err;
181 Boolean excludesMark;
182 if (!PyArg_ParseTuple(_args, "b",
183 &excludesMark))
184 return NULL;
185 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
186 excludesMark);
187 if (_err != noErr) return PyMac_Error(_err);
188 Py_INCREF(Py_None);
189 _res = Py_None;
190 return _res;
191}
192
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000193static PyObject *MenuObj_MacAppendMenu(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000194{
195 PyObject *_res = NULL;
196 Str255 data;
197 if (!PyArg_ParseTuple(_args, "O&",
198 PyMac_GetStr255, data))
199 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000200 MacAppendMenu(_self->ob_itself,
201 data);
Guido van Rossum17448e21995-01-30 11:53:55 +0000202 Py_INCREF(Py_None);
203 _res = Py_None;
204 return _res;
205}
206
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000207static PyObject *MenuObj_InsertResMenu(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000208{
209 PyObject *_res = NULL;
210 ResType theType;
211 short afterItem;
212 if (!PyArg_ParseTuple(_args, "O&h",
213 PyMac_GetOSType, &theType,
214 &afterItem))
215 return NULL;
216 InsertResMenu(_self->ob_itself,
217 theType,
218 afterItem);
219 Py_INCREF(Py_None);
220 _res = Py_None;
221 return _res;
222}
223
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000224static PyObject *MenuObj_AppendResMenu(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000225{
226 PyObject *_res = NULL;
227 ResType theType;
228 if (!PyArg_ParseTuple(_args, "O&",
229 PyMac_GetOSType, &theType))
230 return NULL;
231 AppendResMenu(_self->ob_itself,
232 theType);
233 Py_INCREF(Py_None);
234 _res = Py_None;
235 return _res;
236}
237
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000238static PyObject *MenuObj_MacInsertMenuItem(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000239{
240 PyObject *_res = NULL;
241 Str255 itemString;
242 short afterItem;
243 if (!PyArg_ParseTuple(_args, "O&h",
244 PyMac_GetStr255, itemString,
245 &afterItem))
246 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000247 MacInsertMenuItem(_self->ob_itself,
248 itemString,
249 afterItem);
Guido van Rossum17448e21995-01-30 11:53:55 +0000250 Py_INCREF(Py_None);
251 _res = Py_None;
252 return _res;
253}
254
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000255static PyObject *MenuObj_DeleteMenuItem(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000256{
257 PyObject *_res = NULL;
258 short item;
259 if (!PyArg_ParseTuple(_args, "h",
260 &item))
261 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000262 DeleteMenuItem(_self->ob_itself,
263 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000264 Py_INCREF(Py_None);
265 _res = Py_None;
266 return _res;
267}
268
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000269static PyObject *MenuObj_InsertFontResMenu(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000270{
271 PyObject *_res = NULL;
272 short afterItem;
273 short scriptFilter;
274 if (!PyArg_ParseTuple(_args, "hh",
275 &afterItem,
276 &scriptFilter))
277 return NULL;
278 InsertFontResMenu(_self->ob_itself,
279 afterItem,
280 scriptFilter);
281 Py_INCREF(Py_None);
282 _res = Py_None;
283 return _res;
284}
285
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000286static PyObject *MenuObj_InsertIntlResMenu(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000287{
288 PyObject *_res = NULL;
289 ResType theType;
290 short afterItem;
291 short scriptFilter;
292 if (!PyArg_ParseTuple(_args, "O&hh",
293 PyMac_GetOSType, &theType,
294 &afterItem,
295 &scriptFilter))
296 return NULL;
297 InsertIntlResMenu(_self->ob_itself,
298 theType,
299 afterItem,
300 scriptFilter);
301 Py_INCREF(Py_None);
302 _res = Py_None;
303 return _res;
304}
305
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000306static PyObject *MenuObj_AppendMenuItemText(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000307{
308 PyObject *_res = NULL;
309 OSStatus _err;
310 Str255 inString;
311 if (!PyArg_ParseTuple(_args, "O&",
312 PyMac_GetStr255, inString))
313 return NULL;
314 _err = AppendMenuItemText(_self->ob_itself,
315 inString);
316 if (_err != noErr) return PyMac_Error(_err);
317 Py_INCREF(Py_None);
318 _res = Py_None;
319 return _res;
320}
321
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000322static PyObject *MenuObj_InsertMenuItemText(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000323{
324 PyObject *_res = NULL;
325 OSStatus _err;
326 Str255 inString;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000327 MenuItemIndex afterItem;
328 if (!PyArg_ParseTuple(_args, "O&h",
Jack Jansena05ac601999-12-12 21:41:51 +0000329 PyMac_GetStr255, inString,
330 &afterItem))
331 return NULL;
332 _err = InsertMenuItemText(_self->ob_itself,
333 inString,
334 afterItem);
335 if (_err != noErr) return PyMac_Error(_err);
336 Py_INCREF(Py_None);
337 _res = Py_None;
338 return _res;
339}
340
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000341static PyObject *MenuObj_PopUpMenuSelect(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000342{
343 PyObject *_res = NULL;
344 long _rv;
345 short top;
346 short left;
347 short popUpItem;
348 if (!PyArg_ParseTuple(_args, "hhh",
349 &top,
350 &left,
351 &popUpItem))
352 return NULL;
353 _rv = PopUpMenuSelect(_self->ob_itself,
354 top,
355 left,
356 popUpItem);
357 _res = Py_BuildValue("l",
358 _rv);
359 return _res;
360}
361
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000362static PyObject *MenuObj_MacInsertMenu(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000363{
364 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000365 MenuID beforeID;
Jack Jansena05ac601999-12-12 21:41:51 +0000366 if (!PyArg_ParseTuple(_args, "h",
367 &beforeID))
368 return NULL;
369 MacInsertMenu(_self->ob_itself,
370 beforeID);
371 Py_INCREF(Py_None);
372 _res = Py_None;
373 return _res;
374}
375
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000376static PyObject *MenuObj_MacCheckMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000377{
378 PyObject *_res = NULL;
379 short item;
380 Boolean checked;
381 if (!PyArg_ParseTuple(_args, "hb",
382 &item,
383 &checked))
384 return NULL;
385 MacCheckMenuItem(_self->ob_itself,
386 item,
387 checked);
388 Py_INCREF(Py_None);
389 _res = Py_None;
390 return _res;
391}
392
Jack Jansen74a1e632000-07-14 22:37:27 +0000393#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000394
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000395static PyObject *MenuObj_CheckItem(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000396{
397 PyObject *_res = NULL;
398 short item;
399 Boolean checked;
400 if (!PyArg_ParseTuple(_args, "hb",
401 &item,
402 &checked))
403 return NULL;
404 CheckItem(_self->ob_itself,
405 item,
406 checked);
407 Py_INCREF(Py_None);
408 _res = Py_None;
409 return _res;
410}
Jack Jansene79dc762000-06-02 21:35:07 +0000411#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000412
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000413static PyObject *MenuObj_SetMenuItemText(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000414{
415 PyObject *_res = NULL;
416 short item;
417 Str255 itemString;
418 if (!PyArg_ParseTuple(_args, "hO&",
419 &item,
420 PyMac_GetStr255, itemString))
421 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000422 SetMenuItemText(_self->ob_itself,
423 item,
424 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000425 Py_INCREF(Py_None);
426 _res = Py_None;
427 return _res;
428}
429
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000430static PyObject *MenuObj_GetMenuItemText(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000431{
432 PyObject *_res = NULL;
433 short item;
434 Str255 itemString;
435 if (!PyArg_ParseTuple(_args, "h",
436 &item))
437 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000438 GetMenuItemText(_self->ob_itself,
439 item,
440 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000441 _res = Py_BuildValue("O&",
442 PyMac_BuildStr255, itemString);
443 return _res;
444}
445
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000446static PyObject *MenuObj_SetItemMark(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000447{
448 PyObject *_res = NULL;
449 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000450 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000451 if (!PyArg_ParseTuple(_args, "hh",
452 &item,
453 &markChar))
454 return NULL;
455 SetItemMark(_self->ob_itself,
456 item,
457 markChar);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
461}
462
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000463static PyObject *MenuObj_GetItemMark(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000464{
465 PyObject *_res = NULL;
466 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000467 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000468 if (!PyArg_ParseTuple(_args, "h",
469 &item))
470 return NULL;
471 GetItemMark(_self->ob_itself,
472 item,
473 &markChar);
474 _res = Py_BuildValue("h",
475 markChar);
476 return _res;
477}
478
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000479static PyObject *MenuObj_SetItemCmd(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000480{
481 PyObject *_res = NULL;
482 short item;
483 CharParameter cmdChar;
484 if (!PyArg_ParseTuple(_args, "hh",
485 &item,
486 &cmdChar))
487 return NULL;
488 SetItemCmd(_self->ob_itself,
489 item,
490 cmdChar);
491 Py_INCREF(Py_None);
492 _res = Py_None;
493 return _res;
494}
495
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000496static PyObject *MenuObj_GetItemCmd(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000497{
498 PyObject *_res = NULL;
499 short item;
500 CharParameter cmdChar;
501 if (!PyArg_ParseTuple(_args, "h",
502 &item))
503 return NULL;
504 GetItemCmd(_self->ob_itself,
505 item,
506 &cmdChar);
507 _res = Py_BuildValue("h",
508 cmdChar);
509 return _res;
510}
511
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000512static PyObject *MenuObj_SetItemIcon(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000513{
514 PyObject *_res = NULL;
515 short item;
516 short iconIndex;
517 if (!PyArg_ParseTuple(_args, "hh",
518 &item,
519 &iconIndex))
520 return NULL;
521 SetItemIcon(_self->ob_itself,
522 item,
523 iconIndex);
524 Py_INCREF(Py_None);
525 _res = Py_None;
526 return _res;
527}
528
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000529static PyObject *MenuObj_GetItemIcon(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000530{
531 PyObject *_res = NULL;
532 short item;
533 short iconIndex;
534 if (!PyArg_ParseTuple(_args, "h",
535 &item))
536 return NULL;
537 GetItemIcon(_self->ob_itself,
538 item,
539 &iconIndex);
540 _res = Py_BuildValue("h",
541 iconIndex);
542 return _res;
543}
544
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000545static PyObject *MenuObj_SetItemStyle(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000546{
547 PyObject *_res = NULL;
548 short item;
Jack Jansend6b6d881998-02-25 15:45:21 +0000549 StyleParameter chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000550 if (!PyArg_ParseTuple(_args, "hh",
551 &item,
552 &chStyle))
553 return NULL;
554 SetItemStyle(_self->ob_itself,
555 item,
556 chStyle);
557 Py_INCREF(Py_None);
558 _res = Py_None;
559 return _res;
560}
561
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000562static PyObject *MenuObj_GetItemStyle(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000563{
564 PyObject *_res = NULL;
565 short item;
Jack Jansen7d0bc831995-06-09 20:56:31 +0000566 Style chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000567 if (!PyArg_ParseTuple(_args, "h",
568 &item))
569 return NULL;
570 GetItemStyle(_self->ob_itself,
571 item,
572 &chStyle);
573 _res = Py_BuildValue("b",
574 chStyle);
575 return _res;
576}
577
Jack Jansen74a1e632000-07-14 22:37:27 +0000578#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000579
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000580static PyObject *MenuObj_DisableItem(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000581{
582 PyObject *_res = NULL;
583 short item;
Guido van Rossum17448e21995-01-30 11:53:55 +0000584 if (!PyArg_ParseTuple(_args, "h",
585 &item))
586 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000587 DisableItem(_self->ob_itself,
588 item);
589 Py_INCREF(Py_None);
590 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +0000591 return _res;
592}
Jack Jansene79dc762000-06-02 21:35:07 +0000593#endif
594
Jack Jansen74a1e632000-07-14 22:37:27 +0000595#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000596
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000597static PyObject *MenuObj_EnableItem(MenuObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000598{
599 PyObject *_res = NULL;
600 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000601 if (!PyArg_ParseTuple(_args, "h",
602 &item))
Guido van Rossum17448e21995-01-30 11:53:55 +0000603 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000604 EnableItem(_self->ob_itself,
605 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000606 Py_INCREF(Py_None);
607 _res = Py_None;
608 return _res;
609}
Jack Jansene79dc762000-06-02 21:35:07 +0000610#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000611
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000612static PyObject *MenuObj_SetMenuItemCommandID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000613{
614 PyObject *_res = NULL;
615 OSErr _err;
616 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000617 MenuCommand inCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000618 if (!PyArg_ParseTuple(_args, "hl",
619 &inItem,
620 &inCommandID))
621 return NULL;
622 _err = SetMenuItemCommandID(_self->ob_itself,
623 inItem,
624 inCommandID);
625 if (_err != noErr) return PyMac_Error(_err);
626 Py_INCREF(Py_None);
627 _res = Py_None;
628 return _res;
629}
630
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000631static PyObject *MenuObj_GetMenuItemCommandID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000632{
633 PyObject *_res = NULL;
634 OSErr _err;
635 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000636 MenuCommand outCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000637 if (!PyArg_ParseTuple(_args, "h",
638 &inItem))
639 return NULL;
640 _err = GetMenuItemCommandID(_self->ob_itself,
641 inItem,
642 &outCommandID);
643 if (_err != noErr) return PyMac_Error(_err);
644 _res = Py_BuildValue("l",
645 outCommandID);
646 return _res;
647}
648
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000649static PyObject *MenuObj_SetMenuItemModifiers(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000650{
651 PyObject *_res = NULL;
652 OSErr _err;
653 SInt16 inItem;
654 UInt8 inModifiers;
655 if (!PyArg_ParseTuple(_args, "hb",
656 &inItem,
657 &inModifiers))
658 return NULL;
659 _err = SetMenuItemModifiers(_self->ob_itself,
660 inItem,
661 inModifiers);
662 if (_err != noErr) return PyMac_Error(_err);
663 Py_INCREF(Py_None);
664 _res = Py_None;
665 return _res;
666}
667
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000668static PyObject *MenuObj_GetMenuItemModifiers(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000669{
670 PyObject *_res = NULL;
671 OSErr _err;
672 SInt16 inItem;
673 UInt8 outModifiers;
674 if (!PyArg_ParseTuple(_args, "h",
675 &inItem))
676 return NULL;
677 _err = GetMenuItemModifiers(_self->ob_itself,
678 inItem,
679 &outModifiers);
680 if (_err != noErr) return PyMac_Error(_err);
681 _res = Py_BuildValue("b",
682 outModifiers);
683 return _res;
684}
685
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000686static PyObject *MenuObj_SetMenuItemIconHandle(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000687{
688 PyObject *_res = NULL;
689 OSErr _err;
690 SInt16 inItem;
691 UInt8 inIconType;
692 Handle inIconHandle;
693 if (!PyArg_ParseTuple(_args, "hbO&",
694 &inItem,
695 &inIconType,
696 ResObj_Convert, &inIconHandle))
697 return NULL;
698 _err = SetMenuItemIconHandle(_self->ob_itself,
699 inItem,
700 inIconType,
701 inIconHandle);
702 if (_err != noErr) return PyMac_Error(_err);
703 Py_INCREF(Py_None);
704 _res = Py_None;
705 return _res;
706}
707
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000708static PyObject *MenuObj_GetMenuItemIconHandle(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000709{
710 PyObject *_res = NULL;
711 OSErr _err;
712 SInt16 inItem;
713 UInt8 outIconType;
714 Handle outIconHandle;
715 if (!PyArg_ParseTuple(_args, "h",
716 &inItem))
717 return NULL;
718 _err = GetMenuItemIconHandle(_self->ob_itself,
719 inItem,
720 &outIconType,
721 &outIconHandle);
722 if (_err != noErr) return PyMac_Error(_err);
723 _res = Py_BuildValue("bO&",
724 outIconType,
725 ResObj_New, outIconHandle);
726 return _res;
727}
728
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000729static PyObject *MenuObj_SetMenuItemTextEncoding(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000730{
731 PyObject *_res = NULL;
732 OSErr _err;
733 SInt16 inItem;
734 TextEncoding inScriptID;
735 if (!PyArg_ParseTuple(_args, "hl",
736 &inItem,
737 &inScriptID))
738 return NULL;
739 _err = SetMenuItemTextEncoding(_self->ob_itself,
740 inItem,
741 inScriptID);
742 if (_err != noErr) return PyMac_Error(_err);
743 Py_INCREF(Py_None);
744 _res = Py_None;
745 return _res;
746}
747
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000748static PyObject *MenuObj_GetMenuItemTextEncoding(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000749{
750 PyObject *_res = NULL;
751 OSErr _err;
752 SInt16 inItem;
753 TextEncoding outScriptID;
754 if (!PyArg_ParseTuple(_args, "h",
755 &inItem))
756 return NULL;
757 _err = GetMenuItemTextEncoding(_self->ob_itself,
758 inItem,
759 &outScriptID);
760 if (_err != noErr) return PyMac_Error(_err);
761 _res = Py_BuildValue("l",
762 outScriptID);
763 return _res;
764}
765
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000766static PyObject *MenuObj_SetMenuItemHierarchicalID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000767{
768 PyObject *_res = NULL;
769 OSErr _err;
770 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000771 MenuID inHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000772 if (!PyArg_ParseTuple(_args, "hh",
773 &inItem,
774 &inHierID))
775 return NULL;
776 _err = SetMenuItemHierarchicalID(_self->ob_itself,
777 inItem,
778 inHierID);
779 if (_err != noErr) return PyMac_Error(_err);
780 Py_INCREF(Py_None);
781 _res = Py_None;
782 return _res;
783}
784
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000785static PyObject *MenuObj_GetMenuItemHierarchicalID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000786{
787 PyObject *_res = NULL;
788 OSErr _err;
789 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000790 MenuID outHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000791 if (!PyArg_ParseTuple(_args, "h",
792 &inItem))
793 return NULL;
794 _err = GetMenuItemHierarchicalID(_self->ob_itself,
795 inItem,
796 &outHierID);
797 if (_err != noErr) return PyMac_Error(_err);
798 _res = Py_BuildValue("h",
799 outHierID);
800 return _res;
801}
802
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000803static PyObject *MenuObj_SetMenuItemFontID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000804{
805 PyObject *_res = NULL;
806 OSErr _err;
807 SInt16 inItem;
808 SInt16 inFontID;
809 if (!PyArg_ParseTuple(_args, "hh",
810 &inItem,
811 &inFontID))
812 return NULL;
813 _err = SetMenuItemFontID(_self->ob_itself,
814 inItem,
815 inFontID);
816 if (_err != noErr) return PyMac_Error(_err);
817 Py_INCREF(Py_None);
818 _res = Py_None;
819 return _res;
820}
821
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000822static PyObject *MenuObj_GetMenuItemFontID(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000823{
824 PyObject *_res = NULL;
825 OSErr _err;
826 SInt16 inItem;
827 SInt16 outFontID;
828 if (!PyArg_ParseTuple(_args, "h",
829 &inItem))
830 return NULL;
831 _err = GetMenuItemFontID(_self->ob_itself,
832 inItem,
833 &outFontID);
834 if (_err != noErr) return PyMac_Error(_err);
835 _res = Py_BuildValue("h",
836 outFontID);
837 return _res;
838}
839
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000840static PyObject *MenuObj_SetMenuItemRefCon(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000841{
842 PyObject *_res = NULL;
843 OSErr _err;
844 SInt16 inItem;
845 UInt32 inRefCon;
846 if (!PyArg_ParseTuple(_args, "hl",
847 &inItem,
848 &inRefCon))
849 return NULL;
850 _err = SetMenuItemRefCon(_self->ob_itself,
851 inItem,
852 inRefCon);
853 if (_err != noErr) return PyMac_Error(_err);
854 Py_INCREF(Py_None);
855 _res = Py_None;
856 return _res;
857}
858
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000859static PyObject *MenuObj_GetMenuItemRefCon(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000860{
861 PyObject *_res = NULL;
862 OSErr _err;
863 SInt16 inItem;
864 UInt32 outRefCon;
865 if (!PyArg_ParseTuple(_args, "h",
866 &inItem))
867 return NULL;
868 _err = GetMenuItemRefCon(_self->ob_itself,
869 inItem,
870 &outRefCon);
871 if (_err != noErr) return PyMac_Error(_err);
872 _res = Py_BuildValue("l",
873 outRefCon);
874 return _res;
875}
876
Jack Jansen74a1e632000-07-14 22:37:27 +0000877#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000878
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000879static PyObject *MenuObj_SetMenuItemRefCon2(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000880{
881 PyObject *_res = NULL;
882 OSErr _err;
883 SInt16 inItem;
884 UInt32 inRefCon2;
885 if (!PyArg_ParseTuple(_args, "hl",
886 &inItem,
887 &inRefCon2))
888 return NULL;
889 _err = SetMenuItemRefCon2(_self->ob_itself,
890 inItem,
891 inRefCon2);
892 if (_err != noErr) return PyMac_Error(_err);
893 Py_INCREF(Py_None);
894 _res = Py_None;
895 return _res;
896}
Jack Jansene79dc762000-06-02 21:35:07 +0000897#endif
898
Jack Jansen74a1e632000-07-14 22:37:27 +0000899#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +0000900
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000901static PyObject *MenuObj_GetMenuItemRefCon2(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000902{
903 PyObject *_res = NULL;
904 OSErr _err;
905 SInt16 inItem;
906 UInt32 outRefCon2;
907 if (!PyArg_ParseTuple(_args, "h",
908 &inItem))
909 return NULL;
910 _err = GetMenuItemRefCon2(_self->ob_itself,
911 inItem,
912 &outRefCon2);
913 if (_err != noErr) return PyMac_Error(_err);
914 _res = Py_BuildValue("l",
915 outRefCon2);
916 return _res;
917}
Jack Jansene79dc762000-06-02 21:35:07 +0000918#endif
Jack Jansen21f96871998-02-20 16:02:09 +0000919
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000920static PyObject *MenuObj_SetMenuItemKeyGlyph(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000921{
922 PyObject *_res = NULL;
923 OSErr _err;
924 SInt16 inItem;
925 SInt16 inGlyph;
926 if (!PyArg_ParseTuple(_args, "hh",
927 &inItem,
928 &inGlyph))
929 return NULL;
930 _err = SetMenuItemKeyGlyph(_self->ob_itself,
931 inItem,
932 inGlyph);
933 if (_err != noErr) return PyMac_Error(_err);
934 Py_INCREF(Py_None);
935 _res = Py_None;
936 return _res;
937}
938
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000939static PyObject *MenuObj_GetMenuItemKeyGlyph(MenuObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +0000940{
941 PyObject *_res = NULL;
942 OSErr _err;
943 SInt16 inItem;
944 SInt16 outGlyph;
945 if (!PyArg_ParseTuple(_args, "h",
946 &inItem))
947 return NULL;
948 _err = GetMenuItemKeyGlyph(_self->ob_itself,
949 inItem,
950 &outGlyph);
951 if (_err != noErr) return PyMac_Error(_err);
952 _res = Py_BuildValue("h",
953 outGlyph);
954 return _res;
955}
956
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000957static PyObject *MenuObj_MacEnableMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000958{
959 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000960 MenuItemIndex item;
961 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +0000962 &item))
963 return NULL;
964 MacEnableMenuItem(_self->ob_itself,
965 item);
966 Py_INCREF(Py_None);
967 _res = Py_None;
968 return _res;
969}
970
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000971static PyObject *MenuObj_DisableMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000972{
973 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000974 MenuItemIndex item;
975 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +0000976 &item))
977 return NULL;
978 DisableMenuItem(_self->ob_itself,
979 item);
980 Py_INCREF(Py_None);
981 _res = Py_None;
982 return _res;
983}
984
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000985static PyObject *MenuObj_IsMenuItemEnabled(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +0000986{
987 PyObject *_res = NULL;
988 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000989 MenuItemIndex item;
990 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +0000991 &item))
992 return NULL;
993 _rv = IsMenuItemEnabled(_self->ob_itself,
994 item);
995 _res = Py_BuildValue("b",
996 _rv);
997 return _res;
998}
999
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001000static PyObject *MenuObj_EnableMenuItemIcon(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00001001{
1002 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001003 MenuItemIndex item;
1004 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001005 &item))
1006 return NULL;
1007 EnableMenuItemIcon(_self->ob_itself,
1008 item);
1009 Py_INCREF(Py_None);
1010 _res = Py_None;
1011 return _res;
1012}
1013
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001014static PyObject *MenuObj_DisableMenuItemIcon(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00001015{
1016 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001017 MenuItemIndex item;
1018 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001019 &item))
1020 return NULL;
1021 DisableMenuItemIcon(_self->ob_itself,
1022 item);
1023 Py_INCREF(Py_None);
1024 _res = Py_None;
1025 return _res;
1026}
1027
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001028static PyObject *MenuObj_IsMenuItemIconEnabled(MenuObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00001029{
1030 PyObject *_res = NULL;
1031 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001032 MenuItemIndex item;
1033 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001034 &item))
1035 return NULL;
1036 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1037 item);
1038 _res = Py_BuildValue("b",
1039 _rv);
1040 return _res;
1041}
1042
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001043#if TARGET_API_MAC_CARBON
1044
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001045static PyObject *MenuObj_GetMenuItemPropertyAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001046{
1047 PyObject *_res = NULL;
1048 OSStatus _err;
1049 MenuItemIndex item;
1050 OSType propertyCreator;
1051 OSType propertyTag;
1052 UInt32 attributes;
1053 if (!PyArg_ParseTuple(_args, "hO&O&",
1054 &item,
1055 PyMac_GetOSType, &propertyCreator,
1056 PyMac_GetOSType, &propertyTag))
1057 return NULL;
1058 _err = GetMenuItemPropertyAttributes(_self->ob_itself,
1059 item,
1060 propertyCreator,
1061 propertyTag,
1062 &attributes);
1063 if (_err != noErr) return PyMac_Error(_err);
1064 _res = Py_BuildValue("l",
1065 attributes);
1066 return _res;
1067}
1068#endif
1069
1070#if TARGET_API_MAC_CARBON
1071
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001072static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001073{
1074 PyObject *_res = NULL;
1075 OSStatus _err;
1076 MenuItemIndex item;
1077 OSType propertyCreator;
1078 OSType propertyTag;
1079 UInt32 attributesToSet;
1080 UInt32 attributesToClear;
1081 if (!PyArg_ParseTuple(_args, "hO&O&ll",
1082 &item,
1083 PyMac_GetOSType, &propertyCreator,
1084 PyMac_GetOSType, &propertyTag,
1085 &attributesToSet,
1086 &attributesToClear))
1087 return NULL;
1088 _err = ChangeMenuItemPropertyAttributes(_self->ob_itself,
1089 item,
1090 propertyCreator,
1091 propertyTag,
1092 attributesToSet,
1093 attributesToClear);
1094 if (_err != noErr) return PyMac_Error(_err);
1095 Py_INCREF(Py_None);
1096 _res = Py_None;
1097 return _res;
1098}
1099#endif
1100
1101#if TARGET_API_MAC_CARBON
1102
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001103static PyObject *MenuObj_GetMenuAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001104{
1105 PyObject *_res = NULL;
1106 OSStatus _err;
1107 MenuAttributes outAttributes;
1108 if (!PyArg_ParseTuple(_args, ""))
1109 return NULL;
1110 _err = GetMenuAttributes(_self->ob_itself,
1111 &outAttributes);
1112 if (_err != noErr) return PyMac_Error(_err);
1113 _res = Py_BuildValue("l",
1114 outAttributes);
1115 return _res;
1116}
1117#endif
1118
1119#if TARGET_API_MAC_CARBON
1120
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001121static PyObject *MenuObj_ChangeMenuAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001122{
1123 PyObject *_res = NULL;
1124 OSStatus _err;
1125 MenuAttributes setTheseAttributes;
1126 MenuAttributes clearTheseAttributes;
1127 if (!PyArg_ParseTuple(_args, "ll",
1128 &setTheseAttributes,
1129 &clearTheseAttributes))
1130 return NULL;
1131 _err = ChangeMenuAttributes(_self->ob_itself,
1132 setTheseAttributes,
1133 clearTheseAttributes);
1134 if (_err != noErr) return PyMac_Error(_err);
1135 Py_INCREF(Py_None);
1136 _res = Py_None;
1137 return _res;
1138}
1139#endif
1140
1141#if TARGET_API_MAC_CARBON
1142
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001143static PyObject *MenuObj_GetMenuItemAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001144{
1145 PyObject *_res = NULL;
1146 OSStatus _err;
1147 MenuItemIndex item;
1148 MenuItemAttributes outAttributes;
1149 if (!PyArg_ParseTuple(_args, "h",
1150 &item))
1151 return NULL;
1152 _err = GetMenuItemAttributes(_self->ob_itself,
1153 item,
1154 &outAttributes);
1155 if (_err != noErr) return PyMac_Error(_err);
1156 _res = Py_BuildValue("l",
1157 outAttributes);
1158 return _res;
1159}
1160#endif
1161
1162#if TARGET_API_MAC_CARBON
1163
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001164static PyObject *MenuObj_ChangeMenuItemAttributes(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001165{
1166 PyObject *_res = NULL;
1167 OSStatus _err;
1168 MenuItemIndex item;
1169 MenuItemAttributes setTheseAttributes;
1170 MenuItemAttributes clearTheseAttributes;
1171 if (!PyArg_ParseTuple(_args, "hll",
1172 &item,
1173 &setTheseAttributes,
1174 &clearTheseAttributes))
1175 return NULL;
1176 _err = ChangeMenuItemAttributes(_self->ob_itself,
1177 item,
1178 setTheseAttributes,
1179 clearTheseAttributes);
1180 if (_err != noErr) return PyMac_Error(_err);
1181 Py_INCREF(Py_None);
1182 _res = Py_None;
1183 return _res;
1184}
1185#endif
1186
1187#if TARGET_API_MAC_CARBON
1188
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001189static PyObject *MenuObj_DisableAllMenuItems(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001190{
1191 PyObject *_res = NULL;
1192 if (!PyArg_ParseTuple(_args, ""))
1193 return NULL;
1194 DisableAllMenuItems(_self->ob_itself);
1195 Py_INCREF(Py_None);
1196 _res = Py_None;
1197 return _res;
1198}
1199#endif
1200
1201#if TARGET_API_MAC_CARBON
1202
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001203static PyObject *MenuObj_EnableAllMenuItems(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001204{
1205 PyObject *_res = NULL;
1206 if (!PyArg_ParseTuple(_args, ""))
1207 return NULL;
1208 EnableAllMenuItems(_self->ob_itself);
1209 Py_INCREF(Py_None);
1210 _res = Py_None;
1211 return _res;
1212}
1213#endif
1214
1215#if TARGET_API_MAC_CARBON
1216
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001217static PyObject *MenuObj_MenuHasEnabledItems(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001218{
1219 PyObject *_res = NULL;
1220 Boolean _rv;
1221 if (!PyArg_ParseTuple(_args, ""))
1222 return NULL;
1223 _rv = MenuHasEnabledItems(_self->ob_itself);
1224 _res = Py_BuildValue("b",
1225 _rv);
1226 return _res;
1227}
1228#endif
1229
1230#if TARGET_API_MAC_CARBON
1231
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001232static PyObject *MenuObj_CountMenuItemsWithCommandID(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001233{
1234 PyObject *_res = NULL;
1235 ItemCount _rv;
1236 MenuCommand commandID;
1237 if (!PyArg_ParseTuple(_args, "l",
1238 &commandID))
1239 return NULL;
1240 _rv = CountMenuItemsWithCommandID(_self->ob_itself,
1241 commandID);
1242 _res = Py_BuildValue("l",
1243 _rv);
1244 return _res;
1245}
1246#endif
1247
1248#if TARGET_API_MAC_CARBON
1249
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001250static PyObject *MenuObj_GetIndMenuItemWithCommandID(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001251{
1252 PyObject *_res = NULL;
1253 OSStatus _err;
1254 MenuCommand commandID;
1255 UInt32 itemIndex;
1256 MenuHandle outMenu;
1257 MenuItemIndex outIndex;
1258 if (!PyArg_ParseTuple(_args, "ll",
1259 &commandID,
1260 &itemIndex))
1261 return NULL;
1262 _err = GetIndMenuItemWithCommandID(_self->ob_itself,
1263 commandID,
1264 itemIndex,
1265 &outMenu,
1266 &outIndex);
1267 if (_err != noErr) return PyMac_Error(_err);
1268 _res = Py_BuildValue("O&h",
1269 MenuObj_New, outMenu,
1270 outIndex);
1271 return _res;
1272}
1273#endif
1274
1275#if TARGET_API_MAC_CARBON
1276
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001277static PyObject *MenuObj_EnableMenuCommand(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001278{
1279 PyObject *_res = NULL;
1280 MenuCommand commandID;
1281 if (!PyArg_ParseTuple(_args, "l",
1282 &commandID))
1283 return NULL;
1284 EnableMenuCommand(_self->ob_itself,
1285 commandID);
1286 Py_INCREF(Py_None);
1287 _res = Py_None;
1288 return _res;
1289}
1290#endif
1291
1292#if TARGET_API_MAC_CARBON
1293
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001294static PyObject *MenuObj_DisableMenuCommand(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001295{
1296 PyObject *_res = NULL;
1297 MenuCommand commandID;
1298 if (!PyArg_ParseTuple(_args, "l",
1299 &commandID))
1300 return NULL;
1301 DisableMenuCommand(_self->ob_itself,
1302 commandID);
1303 Py_INCREF(Py_None);
1304 _res = Py_None;
1305 return _res;
1306}
1307#endif
1308
1309#if TARGET_API_MAC_CARBON
1310
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001311static PyObject *MenuObj_IsMenuCommandEnabled(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001312{
1313 PyObject *_res = NULL;
1314 Boolean _rv;
1315 MenuCommand commandID;
1316 if (!PyArg_ParseTuple(_args, "l",
1317 &commandID))
1318 return NULL;
1319 _rv = IsMenuCommandEnabled(_self->ob_itself,
1320 commandID);
1321 _res = Py_BuildValue("b",
1322 _rv);
1323 return _res;
1324}
1325#endif
1326
1327#if TARGET_API_MAC_CARBON
1328
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001329static PyObject *MenuObj_GetMenuCommandPropertySize(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001330{
1331 PyObject *_res = NULL;
1332 OSStatus _err;
1333 MenuCommand commandID;
1334 OSType propertyCreator;
1335 OSType propertyTag;
1336 ByteCount size;
1337 if (!PyArg_ParseTuple(_args, "lO&O&",
1338 &commandID,
1339 PyMac_GetOSType, &propertyCreator,
1340 PyMac_GetOSType, &propertyTag))
1341 return NULL;
1342 _err = GetMenuCommandPropertySize(_self->ob_itself,
1343 commandID,
1344 propertyCreator,
1345 propertyTag,
1346 &size);
1347 if (_err != noErr) return PyMac_Error(_err);
1348 _res = Py_BuildValue("l",
1349 size);
1350 return _res;
1351}
1352#endif
1353
1354#if TARGET_API_MAC_CARBON
1355
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001356static PyObject *MenuObj_RemoveMenuCommandProperty(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001357{
1358 PyObject *_res = NULL;
1359 OSStatus _err;
1360 MenuCommand commandID;
1361 OSType propertyCreator;
1362 OSType propertyTag;
1363 if (!PyArg_ParseTuple(_args, "lO&O&",
1364 &commandID,
1365 PyMac_GetOSType, &propertyCreator,
1366 PyMac_GetOSType, &propertyTag))
1367 return NULL;
1368 _err = RemoveMenuCommandProperty(_self->ob_itself,
1369 commandID,
1370 propertyCreator,
1371 propertyTag);
1372 if (_err != noErr) return PyMac_Error(_err);
1373 Py_INCREF(Py_None);
1374 _res = Py_None;
1375 return _res;
1376}
1377#endif
1378
1379#if TARGET_API_MAC_CARBON
1380
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001381static PyObject *MenuObj_CreateStandardFontMenu(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001382{
1383 PyObject *_res = NULL;
1384 OSStatus _err;
1385 MenuItemIndex afterItem;
1386 MenuID firstHierMenuID;
1387 OptionBits options;
1388 ItemCount outHierMenuCount;
1389 if (!PyArg_ParseTuple(_args, "hhl",
1390 &afterItem,
1391 &firstHierMenuID,
1392 &options))
1393 return NULL;
1394 _err = CreateStandardFontMenu(_self->ob_itself,
1395 afterItem,
1396 firstHierMenuID,
1397 options,
1398 &outHierMenuCount);
1399 if (_err != noErr) return PyMac_Error(_err);
1400 _res = Py_BuildValue("l",
1401 outHierMenuCount);
1402 return _res;
1403}
1404#endif
1405
1406#if TARGET_API_MAC_CARBON
1407
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001408static PyObject *MenuObj_UpdateStandardFontMenu(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001409{
1410 PyObject *_res = NULL;
1411 OSStatus _err;
1412 ItemCount outHierMenuCount;
1413 if (!PyArg_ParseTuple(_args, ""))
1414 return NULL;
1415 _err = UpdateStandardFontMenu(_self->ob_itself,
1416 &outHierMenuCount);
1417 if (_err != noErr) return PyMac_Error(_err);
1418 _res = Py_BuildValue("l",
1419 outHierMenuCount);
1420 return _res;
1421}
1422#endif
1423
1424#if TARGET_API_MAC_CARBON
1425
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001426static PyObject *MenuObj_GetFontFamilyFromMenuSelection(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001427{
1428 PyObject *_res = NULL;
1429 OSStatus _err;
1430 MenuItemIndex item;
1431 FMFontFamily outFontFamily;
1432 FMFontStyle outStyle;
1433 if (!PyArg_ParseTuple(_args, "h",
1434 &item))
1435 return NULL;
1436 _err = GetFontFamilyFromMenuSelection(_self->ob_itself,
1437 item,
1438 &outFontFamily,
1439 &outStyle);
1440 if (_err != noErr) return PyMac_Error(_err);
1441 _res = Py_BuildValue("hh",
1442 outFontFamily,
1443 outStyle);
1444 return _res;
1445}
1446#endif
1447
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001448static PyObject *MenuObj_GetMenuID(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001449{
1450 PyObject *_res = NULL;
1451 MenuID _rv;
1452 if (!PyArg_ParseTuple(_args, ""))
1453 return NULL;
1454 _rv = GetMenuID(_self->ob_itself);
1455 _res = Py_BuildValue("h",
1456 _rv);
1457 return _res;
1458}
1459
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001460static PyObject *MenuObj_GetMenuWidth(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001461{
1462 PyObject *_res = NULL;
1463 SInt16 _rv;
1464 if (!PyArg_ParseTuple(_args, ""))
1465 return NULL;
1466 _rv = GetMenuWidth(_self->ob_itself);
1467 _res = Py_BuildValue("h",
1468 _rv);
1469 return _res;
1470}
1471
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001472static PyObject *MenuObj_GetMenuHeight(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001473{
1474 PyObject *_res = NULL;
1475 SInt16 _rv;
1476 if (!PyArg_ParseTuple(_args, ""))
1477 return NULL;
1478 _rv = GetMenuHeight(_self->ob_itself);
1479 _res = Py_BuildValue("h",
1480 _rv);
1481 return _res;
1482}
1483
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001484static PyObject *MenuObj_SetMenuID(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001485{
1486 PyObject *_res = NULL;
1487 MenuID menuID;
1488 if (!PyArg_ParseTuple(_args, "h",
1489 &menuID))
1490 return NULL;
1491 SetMenuID(_self->ob_itself,
1492 menuID);
1493 Py_INCREF(Py_None);
1494 _res = Py_None;
1495 return _res;
1496}
1497
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001498static PyObject *MenuObj_SetMenuWidth(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001499{
1500 PyObject *_res = NULL;
1501 SInt16 width;
1502 if (!PyArg_ParseTuple(_args, "h",
1503 &width))
1504 return NULL;
1505 SetMenuWidth(_self->ob_itself,
1506 width);
1507 Py_INCREF(Py_None);
1508 _res = Py_None;
1509 return _res;
1510}
1511
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001512static PyObject *MenuObj_SetMenuHeight(MenuObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001513{
1514 PyObject *_res = NULL;
1515 SInt16 height;
1516 if (!PyArg_ParseTuple(_args, "h",
1517 &height))
1518 return NULL;
1519 SetMenuHeight(_self->ob_itself,
1520 height);
1521 Py_INCREF(Py_None);
1522 _res = Py_None;
1523 return _res;
1524}
1525
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001526static PyObject *MenuObj_as_Resource(MenuObject *_self, PyObject *_args)
Jack Jansena1772281995-06-18 20:17:27 +00001527{
1528 PyObject *_res = NULL;
Jack Jansena1a0fef1999-12-23 14:32:06 +00001529 Handle _rv;
1530 if (!PyArg_ParseTuple(_args, ""))
1531 return NULL;
1532 _rv = as_Resource(_self->ob_itself);
1533 _res = Py_BuildValue("O&",
1534 ResObj_New, _rv);
1535 return _res;
Jack Jansena1772281995-06-18 20:17:27 +00001536}
1537
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001538static PyObject *MenuObj_AppendMenu(MenuObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00001539{
1540 PyObject *_res = NULL;
1541 Str255 data;
1542 if (!PyArg_ParseTuple(_args, "O&",
1543 PyMac_GetStr255, data))
1544 return NULL;
1545 AppendMenu(_self->ob_itself,
1546 data);
1547 Py_INCREF(Py_None);
1548 _res = Py_None;
1549 return _res;
1550}
1551
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001552static PyObject *MenuObj_InsertMenu(MenuObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00001553{
1554 PyObject *_res = NULL;
1555 short beforeID;
1556 if (!PyArg_ParseTuple(_args, "h",
1557 &beforeID))
1558 return NULL;
1559 InsertMenu(_self->ob_itself,
1560 beforeID);
1561 Py_INCREF(Py_None);
1562 _res = Py_None;
1563 return _res;
1564}
1565
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001566static PyObject *MenuObj_InsertMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00001567{
1568 PyObject *_res = NULL;
1569 Str255 itemString;
1570 short afterItem;
1571 if (!PyArg_ParseTuple(_args, "O&h",
1572 PyMac_GetStr255, itemString,
1573 &afterItem))
1574 return NULL;
1575 InsertMenuItem(_self->ob_itself,
1576 itemString,
1577 afterItem);
1578 Py_INCREF(Py_None);
1579 _res = Py_None;
1580 return _res;
1581}
1582
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001583static PyObject *MenuObj_EnableMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansen54c07872001-01-29 13:32:10 +00001584{
1585 PyObject *_res = NULL;
1586 UInt16 item;
1587 if (!PyArg_ParseTuple(_args, "H",
1588 &item))
1589 return NULL;
1590 EnableMenuItem(_self->ob_itself,
1591 item);
1592 Py_INCREF(Py_None);
1593 _res = Py_None;
1594 return _res;
1595}
1596
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001597static PyObject *MenuObj_CheckMenuItem(MenuObject *_self, PyObject *_args)
Jack Jansen54c07872001-01-29 13:32:10 +00001598{
1599 PyObject *_res = NULL;
1600 short item;
1601 Boolean checked;
1602 if (!PyArg_ParseTuple(_args, "hb",
1603 &item,
1604 &checked))
1605 return NULL;
1606 CheckMenuItem(_self->ob_itself,
1607 item,
1608 checked);
1609 Py_INCREF(Py_None);
1610 _res = Py_None;
1611 return _res;
1612}
1613
Guido van Rossum17448e21995-01-30 11:53:55 +00001614static PyMethodDef MenuObj_methods[] = {
1615 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1616 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001617 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1618 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001619 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1620 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001621
Jack Jansen74a1e632000-07-14 22:37:27 +00001622#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001623 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1624 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001625#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001626 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1627 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1628 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1629 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1630 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1631 "() -> (Boolean _rv)"},
1632 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1633 "(Boolean excludesMark) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001634 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001635 "(Str255 data) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001636 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1637 "(ResType theType, short afterItem) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001638 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1639 "(ResType theType) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001640 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001641 "(Str255 itemString, short afterItem) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001642 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001643 "(short item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001644 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1645 "(short afterItem, short scriptFilter) -> None"},
1646 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1647 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1648 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1649 "(Str255 inString) -> None"},
1650 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001651 "(Str255 inString, MenuItemIndex afterItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001652 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1653 "(short top, short left, short popUpItem) -> (long _rv)"},
1654 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001655 "(MenuID beforeID) -> None"},
1656 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1657 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001658
Jack Jansen74a1e632000-07-14 22:37:27 +00001659#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001660 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1661 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001662#endif
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001663 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001664 "(short item, Str255 itemString) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001665 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001666 "(short item) -> (Str255 itemString)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001667 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001668 "(short item, CharParameter markChar) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001669 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001670 "(short item) -> (CharParameter markChar)"},
1671 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1672 "(short item, CharParameter cmdChar) -> None"},
1673 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1674 "(short item) -> (CharParameter cmdChar)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001675 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1676 "(short item, short iconIndex) -> None"},
1677 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1678 "(short item) -> (short iconIndex)"},
1679 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
Jack Jansend6b6d881998-02-25 15:45:21 +00001680 "(short item, StyleParameter chStyle) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001681 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
Jack Jansen7d0bc831995-06-09 20:56:31 +00001682 "(short item) -> (Style chStyle)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001683
Jack Jansen74a1e632000-07-14 22:37:27 +00001684#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001685 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1686 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001687#endif
1688
Jack Jansen74a1e632000-07-14 22:37:27 +00001689#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001690 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1691 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001692#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001693 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001694 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001695 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001696 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001697 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1698 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1699 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1700 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1701 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1702 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1703 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1704 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1705 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1706 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1707 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1708 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1709 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001710 "(SInt16 inItem, MenuID inHierID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001711 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001712 "(SInt16 inItem) -> (MenuID outHierID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001713 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1714 "(SInt16 inItem, SInt16 inFontID) -> None"},
1715 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1716 "(SInt16 inItem) -> (SInt16 outFontID)"},
1717 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1718 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1719 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1720 "(SInt16 inItem) -> (UInt32 outRefCon)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001721
Jack Jansen74a1e632000-07-14 22:37:27 +00001722#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001723 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1724 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001725#endif
1726
Jack Jansen74a1e632000-07-14 22:37:27 +00001727#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001728 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1729 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001730#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001731 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1732 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1733 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1734 "(SInt16 inItem) -> (SInt16 outGlyph)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001735 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001736 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001737 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001738 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001739 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001740 "(MenuItemIndex item) -> (Boolean _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001741 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001742 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001743 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001744 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001745 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001746 "(MenuItemIndex item) -> (Boolean _rv)"},
1747
1748#if TARGET_API_MAC_CARBON
1749 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1750 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1751#endif
1752
1753#if TARGET_API_MAC_CARBON
1754 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1755 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1756#endif
1757
1758#if TARGET_API_MAC_CARBON
1759 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1760 "() -> (MenuAttributes outAttributes)"},
1761#endif
1762
1763#if TARGET_API_MAC_CARBON
1764 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1765 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1766#endif
1767
1768#if TARGET_API_MAC_CARBON
1769 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1770 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1771#endif
1772
1773#if TARGET_API_MAC_CARBON
1774 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1775 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1776#endif
1777
1778#if TARGET_API_MAC_CARBON
1779 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1780 "() -> None"},
1781#endif
1782
1783#if TARGET_API_MAC_CARBON
1784 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1785 "() -> None"},
1786#endif
1787
1788#if TARGET_API_MAC_CARBON
1789 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1790 "() -> (Boolean _rv)"},
1791#endif
1792
1793#if TARGET_API_MAC_CARBON
1794 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1795 "(MenuCommand commandID) -> (ItemCount _rv)"},
1796#endif
1797
1798#if TARGET_API_MAC_CARBON
1799 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1800 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1801#endif
1802
1803#if TARGET_API_MAC_CARBON
1804 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1805 "(MenuCommand commandID) -> None"},
1806#endif
1807
1808#if TARGET_API_MAC_CARBON
1809 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1810 "(MenuCommand commandID) -> None"},
1811#endif
1812
1813#if TARGET_API_MAC_CARBON
1814 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1815 "(MenuCommand commandID) -> (Boolean _rv)"},
1816#endif
1817
1818#if TARGET_API_MAC_CARBON
1819 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1820 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1821#endif
1822
1823#if TARGET_API_MAC_CARBON
1824 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
1825 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1826#endif
1827
1828#if TARGET_API_MAC_CARBON
1829 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
1830 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1831#endif
1832
1833#if TARGET_API_MAC_CARBON
1834 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
1835 "() -> (ItemCount outHierMenuCount)"},
1836#endif
1837
1838#if TARGET_API_MAC_CARBON
1839 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
1840 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
1841#endif
1842 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
1843 "() -> (MenuID _rv)"},
1844 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
1845 "() -> (SInt16 _rv)"},
1846 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
1847 "() -> (SInt16 _rv)"},
1848 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
1849 "(MenuID menuID) -> None"},
1850 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
1851 "(SInt16 width) -> None"},
1852 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
1853 "(SInt16 height) -> None"},
Jack Jansena1772281995-06-18 20:17:27 +00001854 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
Jack Jansena1a0fef1999-12-23 14:32:06 +00001855 "() -> (Handle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00001856 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
1857 "(Str255 data) -> None"},
1858 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
1859 "(short beforeID) -> None"},
1860 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
1861 "(Str255 itemString, short afterItem) -> None"},
Jack Jansen54c07872001-01-29 13:32:10 +00001862 {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1,
1863 "(UInt16 item) -> None"},
1864 {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1,
1865 "(short item, Boolean checked) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001866 {NULL, NULL, 0}
1867};
1868
1869PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
1870
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001871static PyObject *MenuObj_getattr(MenuObject *self, char *name)
Guido van Rossum17448e21995-01-30 11:53:55 +00001872{
1873 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
1874}
1875
1876#define MenuObj_setattr NULL
1877
Jack Jansena05ac601999-12-12 21:41:51 +00001878#define MenuObj_compare NULL
1879
1880#define MenuObj_repr NULL
1881
1882#define MenuObj_hash NULL
1883
Guido van Rossum17448e21995-01-30 11:53:55 +00001884PyTypeObject Menu_Type = {
1885 PyObject_HEAD_INIT(&PyType_Type)
1886 0, /*ob_size*/
1887 "Menu", /*tp_name*/
1888 sizeof(MenuObject), /*tp_basicsize*/
1889 0, /*tp_itemsize*/
1890 /* methods */
1891 (destructor) MenuObj_dealloc, /*tp_dealloc*/
1892 0, /*tp_print*/
1893 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
1894 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00001895 (cmpfunc) MenuObj_compare, /*tp_compare*/
1896 (reprfunc) MenuObj_repr, /*tp_repr*/
1897 (PyNumberMethods *)0, /* tp_as_number */
1898 (PySequenceMethods *)0, /* tp_as_sequence */
1899 (PyMappingMethods *)0, /* tp_as_mapping */
1900 (hashfunc) MenuObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00001901};
1902
1903/* ---------------------- End object type Menu ---------------------- */
1904
1905
Jack Jansen74a1e632000-07-14 22:37:27 +00001906#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00001907
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001908static PyObject *Menu_InitProcMenu(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001909{
1910 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001911 short resID;
1912 if (!PyArg_ParseTuple(_args, "h",
1913 &resID))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001914 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001915 InitProcMenu(resID);
1916 Py_INCREF(Py_None);
1917 _res = Py_None;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001918 return _res;
1919}
Jack Jansene79dc762000-06-02 21:35:07 +00001920#endif
1921
Jack Jansen74a1e632000-07-14 22:37:27 +00001922#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001923
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001924static PyObject *Menu_InitMenus(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001925{
1926 PyObject *_res = NULL;
1927 if (!PyArg_ParseTuple(_args, ""))
1928 return NULL;
1929 InitMenus();
1930 Py_INCREF(Py_None);
1931 _res = Py_None;
1932 return _res;
1933}
Jack Jansene79dc762000-06-02 21:35:07 +00001934#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00001935
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001936static PyObject *Menu_NewMenu(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001937{
1938 PyObject *_res = NULL;
1939 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001940 MenuID menuID;
Guido van Rossum17448e21995-01-30 11:53:55 +00001941 Str255 menuTitle;
1942 if (!PyArg_ParseTuple(_args, "hO&",
1943 &menuID,
1944 PyMac_GetStr255, menuTitle))
1945 return NULL;
1946 _rv = NewMenu(menuID,
1947 menuTitle);
1948 _res = Py_BuildValue("O&",
1949 MenuObj_New, _rv);
1950 return _res;
1951}
1952
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001953static PyObject *Menu_MacGetMenu(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001954{
1955 PyObject *_res = NULL;
1956 MenuHandle _rv;
1957 short resourceID;
1958 if (!PyArg_ParseTuple(_args, "h",
1959 &resourceID))
1960 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001961 _rv = MacGetMenu(resourceID);
Guido van Rossum17448e21995-01-30 11:53:55 +00001962 _res = Py_BuildValue("O&",
1963 MenuObj_New, _rv);
1964 return _res;
1965}
1966
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001967#if TARGET_API_MAC_CARBON
1968
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001969static PyObject *Menu_CreateNewMenu(PyObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001970{
1971 PyObject *_res = NULL;
1972 OSStatus _err;
1973 MenuID menuID;
1974 MenuAttributes menuAttributes;
1975 MenuHandle outMenuRef;
1976 if (!PyArg_ParseTuple(_args, "hl",
1977 &menuID,
1978 &menuAttributes))
1979 return NULL;
1980 _err = CreateNewMenu(menuID,
1981 menuAttributes,
1982 &outMenuRef);
1983 if (_err != noErr) return PyMac_Error(_err);
1984 _res = Py_BuildValue("O&",
1985 MenuObj_New, outMenuRef);
1986 return _res;
1987}
1988#endif
1989
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001990static PyObject *Menu_MenuKey(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001991{
1992 PyObject *_res = NULL;
1993 long _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00001994 CharParameter ch;
Guido van Rossum17448e21995-01-30 11:53:55 +00001995 if (!PyArg_ParseTuple(_args, "h",
1996 &ch))
1997 return NULL;
1998 _rv = MenuKey(ch);
1999 _res = Py_BuildValue("l",
2000 _rv);
2001 return _res;
2002}
2003
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002004static PyObject *Menu_MenuSelect(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002005{
2006 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002007 long _rv;
2008 Point startPt;
2009 if (!PyArg_ParseTuple(_args, "O&",
2010 PyMac_GetPoint, &startPt))
Guido van Rossum17448e21995-01-30 11:53:55 +00002011 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002012 _rv = MenuSelect(startPt);
2013 _res = Py_BuildValue("l",
2014 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002015 return _res;
2016}
2017
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002018static PyObject *Menu_MenuChoice(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002019{
2020 PyObject *_res = NULL;
2021 long _rv;
2022 if (!PyArg_ParseTuple(_args, ""))
2023 return NULL;
2024 _rv = MenuChoice();
2025 _res = Py_BuildValue("l",
2026 _rv);
2027 return _res;
2028}
2029
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002030static PyObject *Menu_MenuEvent(PyObject *_self, PyObject *_args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002031{
2032 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002033 UInt32 _rv;
2034 EventRecord inEvent;
2035 if (!PyArg_ParseTuple(_args, "O&",
2036 PyMac_GetEventRecord, &inEvent))
Guido van Rossum17448e21995-01-30 11:53:55 +00002037 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002038 _rv = MenuEvent(&inEvent);
2039 _res = Py_BuildValue("l",
2040 _rv);
2041 return _res;
2042}
2043
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002044static PyObject *Menu_GetMBarHeight(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002045{
2046 PyObject *_res = NULL;
2047 short _rv;
2048 if (!PyArg_ParseTuple(_args, ""))
2049 return NULL;
2050 _rv = GetMBarHeight();
2051 _res = Py_BuildValue("h",
2052 _rv);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002053 return _res;
2054}
2055
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002056static PyObject *Menu_MacDrawMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002057{
2058 PyObject *_res = NULL;
2059 if (!PyArg_ParseTuple(_args, ""))
2060 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002061 MacDrawMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002062 Py_INCREF(Py_None);
2063 _res = Py_None;
2064 return _res;
2065}
2066
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002067static PyObject *Menu_InvalMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002068{
2069 PyObject *_res = NULL;
2070 if (!PyArg_ParseTuple(_args, ""))
2071 return NULL;
2072 InvalMenuBar();
2073 Py_INCREF(Py_None);
2074 _res = Py_None;
2075 return _res;
2076}
2077
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002078static PyObject *Menu_HiliteMenu(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002079{
2080 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002081 MenuID menuID;
Jack Jansen21f96871998-02-20 16:02:09 +00002082 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00002083 &menuID))
Jack Jansen21f96871998-02-20 16:02:09 +00002084 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002085 HiliteMenu(menuID);
Jack Jansen21f96871998-02-20 16:02:09 +00002086 Py_INCREF(Py_None);
2087 _res = Py_None;
2088 return _res;
2089}
2090
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002091static PyObject *Menu_GetNewMBar(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002092{
2093 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002094 MenuBarHandle _rv;
Jack Jansena05ac601999-12-12 21:41:51 +00002095 short menuBarID;
2096 if (!PyArg_ParseTuple(_args, "h",
2097 &menuBarID))
2098 return NULL;
2099 _rv = GetNewMBar(menuBarID);
2100 _res = Py_BuildValue("O&",
2101 ResObj_New, _rv);
2102 return _res;
2103}
2104
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002105static PyObject *Menu_GetMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002106{
2107 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002108 MenuBarHandle _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002109 if (!PyArg_ParseTuple(_args, ""))
2110 return NULL;
2111 _rv = GetMenuBar();
2112 _res = Py_BuildValue("O&",
2113 ResObj_New, _rv);
2114 return _res;
2115}
2116
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002117static PyObject *Menu_SetMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002118{
2119 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002120 MenuBarHandle mbar;
Jack Jansen21f96871998-02-20 16:02:09 +00002121 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002122 ResObj_Convert, &mbar))
Jack Jansen21f96871998-02-20 16:02:09 +00002123 return NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002124 SetMenuBar(mbar);
Jack Jansen21f96871998-02-20 16:02:09 +00002125 Py_INCREF(Py_None);
2126 _res = Py_None;
2127 return _res;
2128}
2129
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002130#if TARGET_API_MAC_CARBON
2131
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002132static PyObject *Menu_DuplicateMenuBar(PyObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002133{
2134 PyObject *_res = NULL;
2135 OSStatus _err;
2136 MenuBarHandle mbar;
2137 MenuBarHandle outBar;
2138 if (!PyArg_ParseTuple(_args, "O&",
2139 ResObj_Convert, &mbar))
2140 return NULL;
2141 _err = DuplicateMenuBar(mbar,
2142 &outBar);
2143 if (_err != noErr) return PyMac_Error(_err);
2144 _res = Py_BuildValue("O&",
2145 ResObj_New, outBar);
2146 return _res;
2147}
2148#endif
2149
2150#if TARGET_API_MAC_CARBON
2151
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002152static PyObject *Menu_DisposeMenuBar(PyObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002153{
2154 PyObject *_res = NULL;
2155 OSStatus _err;
2156 MenuBarHandle mbar;
2157 if (!PyArg_ParseTuple(_args, "O&",
2158 ResObj_Convert, &mbar))
2159 return NULL;
2160 _err = DisposeMenuBar(mbar);
2161 if (_err != noErr) return PyMac_Error(_err);
2162 Py_INCREF(Py_None);
2163 _res = Py_None;
2164 return _res;
2165}
2166#endif
2167
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002168static PyObject *Menu_GetMenuHandle(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002169{
2170 PyObject *_res = NULL;
2171 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002172 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002173 if (!PyArg_ParseTuple(_args, "h",
2174 &menuID))
2175 return NULL;
2176 _rv = GetMenuHandle(menuID);
2177 _res = Py_BuildValue("O&",
2178 MenuObj_New, _rv);
2179 return _res;
2180}
2181
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002182static PyObject *Menu_MacDeleteMenu(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002183{
2184 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002185 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002186 if (!PyArg_ParseTuple(_args, "h",
2187 &menuID))
2188 return NULL;
2189 MacDeleteMenu(menuID);
2190 Py_INCREF(Py_None);
2191 _res = Py_None;
2192 return _res;
2193}
2194
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002195static PyObject *Menu_ClearMenuBar(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002196{
2197 PyObject *_res = NULL;
2198 if (!PyArg_ParseTuple(_args, ""))
2199 return NULL;
2200 ClearMenuBar();
2201 Py_INCREF(Py_None);
2202 _res = Py_None;
2203 return _res;
2204}
2205
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002206static PyObject *Menu_SetMenuFlashCount(PyObject *_self, PyObject *_args)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002207{
2208 PyObject *_res = NULL;
2209 short count;
2210 if (!PyArg_ParseTuple(_args, "h",
2211 &count))
2212 return NULL;
2213 SetMenuFlashCount(count);
2214 Py_INCREF(Py_None);
2215 _res = Py_None;
2216 return _res;
2217}
2218
Jack Jansen74a1e632000-07-14 22:37:27 +00002219#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002220
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002221static PyObject *Menu_SetMenuFlash(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002222{
2223 PyObject *_res = NULL;
2224 short count;
2225 if (!PyArg_ParseTuple(_args, "h",
2226 &count))
2227 return NULL;
2228 SetMenuFlash(count);
2229 Py_INCREF(Py_None);
2230 _res = Py_None;
2231 return _res;
2232}
Jack Jansene79dc762000-06-02 21:35:07 +00002233#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002234
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002235static PyObject *Menu_FlashMenuBar(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002236{
2237 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002238 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002239 if (!PyArg_ParseTuple(_args, "h",
2240 &menuID))
2241 return NULL;
2242 FlashMenuBar(menuID);
2243 Py_INCREF(Py_None);
2244 _res = Py_None;
2245 return _res;
2246}
2247
Jack Jansen74a1e632000-07-14 22:37:27 +00002248#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002249
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002250static PyObject *Menu_SystemEdit(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002251{
2252 PyObject *_res = NULL;
2253 Boolean _rv;
2254 short editCmd;
2255 if (!PyArg_ParseTuple(_args, "h",
2256 &editCmd))
2257 return NULL;
2258 _rv = SystemEdit(editCmd);
2259 _res = Py_BuildValue("b",
2260 _rv);
2261 return _res;
2262}
Jack Jansene79dc762000-06-02 21:35:07 +00002263#endif
2264
Jack Jansen74a1e632000-07-14 22:37:27 +00002265#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002266
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002267static PyObject *Menu_SystemMenu(PyObject *_self, PyObject *_args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002268{
2269 PyObject *_res = NULL;
2270 long menuResult;
2271 if (!PyArg_ParseTuple(_args, "l",
2272 &menuResult))
2273 return NULL;
2274 SystemMenu(menuResult);
Guido van Rossum17448e21995-01-30 11:53:55 +00002275 Py_INCREF(Py_None);
2276 _res = Py_None;
2277 return _res;
2278}
Jack Jansene79dc762000-06-02 21:35:07 +00002279#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002280
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002281static PyObject *Menu_IsMenuBarVisible(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002282{
2283 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002284 Boolean _rv;
2285 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002286 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002287 _rv = IsMenuBarVisible();
2288 _res = Py_BuildValue("b",
2289 _rv);
Jack Jansen21f96871998-02-20 16:02:09 +00002290 return _res;
2291}
2292
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002293static PyObject *Menu_ShowMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002294{
2295 PyObject *_res = NULL;
2296 if (!PyArg_ParseTuple(_args, ""))
2297 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002298 ShowMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002299 Py_INCREF(Py_None);
2300 _res = Py_None;
2301 return _res;
2302}
2303
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002304static PyObject *Menu_HideMenuBar(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002305{
2306 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002307 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002308 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002309 HideMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002310 Py_INCREF(Py_None);
2311 _res = Py_None;
2312 return _res;
2313}
2314
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002315static PyObject *Menu_DeleteMCEntries(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002316{
2317 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002318 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002319 short menuItem;
2320 if (!PyArg_ParseTuple(_args, "hh",
2321 &menuID,
2322 &menuItem))
Jack Jansen21f96871998-02-20 16:02:09 +00002323 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002324 DeleteMCEntries(menuID,
2325 menuItem);
2326 Py_INCREF(Py_None);
2327 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00002328 return _res;
2329}
2330
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002331static PyObject *Menu_InitContextualMenus(PyObject *_self, PyObject *_args)
Jack Jansen21f96871998-02-20 16:02:09 +00002332{
2333 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002334 OSStatus _err;
2335 if (!PyArg_ParseTuple(_args, ""))
2336 return NULL;
2337 _err = InitContextualMenus();
2338 if (_err != noErr) return PyMac_Error(_err);
2339 Py_INCREF(Py_None);
2340 _res = Py_None;
2341 return _res;
2342}
2343
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002344static PyObject *Menu_IsShowContextualMenuClick(PyObject *_self, PyObject *_args)
Jack Jansena05ac601999-12-12 21:41:51 +00002345{
2346 PyObject *_res = NULL;
2347 Boolean _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002348 EventRecord inEvent;
2349 if (!PyArg_ParseTuple(_args, "O&",
2350 PyMac_GetEventRecord, &inEvent))
2351 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002352 _rv = IsShowContextualMenuClick(&inEvent);
2353 _res = Py_BuildValue("b",
Jack Jansen21f96871998-02-20 16:02:09 +00002354 _rv);
2355 return _res;
2356}
2357
Jack Jansen74a1e632000-07-14 22:37:27 +00002358#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002359
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002360static PyObject *Menu_OpenDeskAcc(PyObject *_self, PyObject *_args)
Guido van Rossum86c3af71995-03-19 22:42:51 +00002361{
2362 PyObject *_res = NULL;
2363 Str255 name;
2364 if (!PyArg_ParseTuple(_args, "O&",
2365 PyMac_GetStr255, name))
2366 return NULL;
2367 OpenDeskAcc(name);
2368 Py_INCREF(Py_None);
2369 _res = Py_None;
2370 return _res;
2371}
Jack Jansene79dc762000-06-02 21:35:07 +00002372#endif
Guido van Rossum86c3af71995-03-19 22:42:51 +00002373
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002374static PyObject *Menu_as_Menu(PyObject *_self, PyObject *_args)
Jack Jansene0581891999-02-07 14:02:03 +00002375{
2376 PyObject *_res = NULL;
2377 MenuHandle _rv;
2378 Handle h;
2379 if (!PyArg_ParseTuple(_args, "O&",
2380 ResObj_Convert, &h))
2381 return NULL;
2382 _rv = as_Menu(h);
2383 _res = Py_BuildValue("O&",
2384 MenuObj_New, _rv);
2385 return _res;
2386}
2387
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002388static PyObject *Menu_GetMenu(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00002389{
2390 PyObject *_res = NULL;
2391 MenuHandle _rv;
2392 short resourceID;
2393 if (!PyArg_ParseTuple(_args, "h",
2394 &resourceID))
2395 return NULL;
2396 _rv = GetMenu(resourceID);
2397 _res = Py_BuildValue("O&",
2398 MenuObj_New, _rv);
2399 return _res;
2400}
2401
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002402static PyObject *Menu_DeleteMenu(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00002403{
2404 PyObject *_res = NULL;
2405 short menuID;
2406 if (!PyArg_ParseTuple(_args, "h",
2407 &menuID))
2408 return NULL;
2409 DeleteMenu(menuID);
2410 Py_INCREF(Py_None);
2411 _res = Py_None;
2412 return _res;
2413}
2414
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002415static PyObject *Menu_DrawMenuBar(PyObject *_self, PyObject *_args)
Jack Jansene180d991998-04-24 10:28:20 +00002416{
2417 PyObject *_res = NULL;
2418 if (!PyArg_ParseTuple(_args, ""))
2419 return NULL;
2420 DrawMenuBar();
2421 Py_INCREF(Py_None);
2422 _res = Py_None;
2423 return _res;
2424}
2425
Guido van Rossum17448e21995-01-30 11:53:55 +00002426static PyMethodDef Menu_methods[] = {
Jack Jansene79dc762000-06-02 21:35:07 +00002427
Jack Jansen74a1e632000-07-14 22:37:27 +00002428#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002429 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2430 "(short resID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002431#endif
2432
Jack Jansen74a1e632000-07-14 22:37:27 +00002433#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002434 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2435 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002436#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002437 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002438 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002439 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00002440 "(short resourceID) -> (MenuHandle _rv)"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002441
2442#if TARGET_API_MAC_CARBON
2443 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2444 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2445#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002446 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002447 "(CharParameter ch) -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002448 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2449 "(Point startPt) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002450 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2451 "() -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002452 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2453 "(EventRecord inEvent) -> (UInt32 _rv)"},
2454 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2455 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002456 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002457 "() -> None"},
2458 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2459 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002460 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002461 "(MenuID menuID) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002462 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002463 "(short menuBarID) -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002464 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002465 "() -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002466 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002467 "(MenuBarHandle mbar) -> None"},
2468
2469#if TARGET_API_MAC_CARBON
2470 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2471 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2472#endif
2473
2474#if TARGET_API_MAC_CARBON
2475 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2476 "(MenuBarHandle mbar) -> None"},
2477#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002478 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002479 "(MenuID menuID) -> (MenuHandle _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002480 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002481 "(MenuID menuID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002482 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2483 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002484 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2485 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002486
Jack Jansen74a1e632000-07-14 22:37:27 +00002487#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002488 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2489 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002490#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002491 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002492 "(MenuID menuID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002493
Jack Jansen74a1e632000-07-14 22:37:27 +00002494#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002495 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2496 "(short editCmd) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002497#endif
2498
Jack Jansen74a1e632000-07-14 22:37:27 +00002499#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002500 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2501 "(long menuResult) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002502#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002503 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2504 "() -> (Boolean _rv)"},
2505 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2506 "() -> None"},
2507 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2508 "() -> None"},
2509 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002510 "(MenuID menuID, short menuItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002511 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2512 "() -> None"},
2513 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2514 "(EventRecord inEvent) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002515
Jack Jansen74a1e632000-07-14 22:37:27 +00002516#if !TARGET_API_MAC_CARBON
Guido van Rossum86c3af71995-03-19 22:42:51 +00002517 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2518 "(Str255 name) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002519#endif
Jack Jansene0581891999-02-07 14:02:03 +00002520 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2521 "(Handle h) -> (MenuHandle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002522 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2523 "(short resourceID) -> (MenuHandle _rv)"},
2524 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2525 "(short menuID) -> None"},
2526 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2527 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002528 {NULL, NULL, 0}
2529};
2530
2531
2532
2533
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002534void initMenu(void)
Guido van Rossum17448e21995-01-30 11:53:55 +00002535{
2536 PyObject *m;
2537 PyObject *d;
2538
2539
2540
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002541 PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New);
2542 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert);
Jack Jansen0e04eec2001-05-17 21:58:34 +00002543
Guido van Rossum17448e21995-01-30 11:53:55 +00002544
2545 m = Py_InitModule("Menu", Menu_methods);
2546 d = PyModule_GetDict(m);
2547 Menu_Error = PyMac_GetOSErrException();
2548 if (Menu_Error == NULL ||
2549 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002550 return;
Jack Jansena755e681997-09-20 17:40:22 +00002551 Menu_Type.ob_type = &PyType_Type;
2552 Py_INCREF(&Menu_Type);
2553 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2554 Py_FatalError("can't initialize MenuType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002555}
2556
2557/* ======================== End module Menu ========================= */
2558