blob: 11bc6c7288d33c6d1e46eb9862b67d268a15ae7e [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* ========================== Module Menu =========================== */
3
4#include "Python.h"
5
6
7
8#define SystemSevenOrLater 1
9
10#include "macglue.h"
11#include <Memory.h>
12#include <Dialogs.h>
13#include <Menus.h>
14#include <Controls.h>
15
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
Jack Jansen425e9eb1995-12-12 15:02:03 +000018extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
Guido van Rossum17448e21995-01-30 11:53:55 +000020
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
Jack Jansen425e9eb1995-12-12 15:02:03 +000023extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
Guido van Rossum17448e21995-01-30 11:53:55 +000025
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
Jack Jansen425e9eb1995-12-12 15:02:03 +000037extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
40extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
Guido van Rossum17448e21995-01-30 11:53:55 +000043extern PyObject *WinObj_WhichWindow(WindowPtr);
44
Guido van Rossum86c3af71995-03-19 22:42:51 +000045#include <Devices.h> /* Defines OpenDeskAcc in universal headers */
Guido van Rossum17448e21995-01-30 11:53:55 +000046#include <Menus.h>
47
48#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
49
Jack Jansene0581891999-02-07 14:02:03 +000050#define as_Menu(h) ((MenuHandle)h)
Jack Jansena1a0fef1999-12-23 14:32:06 +000051#define as_Resource(h) ((Handle)h)
Jack Jansene0581891999-02-07 14:02:03 +000052
Guido van Rossum17448e21995-01-30 11:53:55 +000053static PyObject *Menu_Error;
54
55/* ------------------------ Object type Menu ------------------------ */
56
57PyTypeObject Menu_Type;
58
59#define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
60
61typedef struct MenuObject {
62 PyObject_HEAD
63 MenuHandle ob_itself;
64} MenuObject;
65
66PyObject *MenuObj_New(itself)
Guido van Rossum227a4231995-03-10 14:42:57 +000067 MenuHandle itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000068{
69 MenuObject *it;
70 it = PyObject_NEW(MenuObject, &Menu_Type);
71 if (it == NULL) return NULL;
72 it->ob_itself = itself;
73 return (PyObject *)it;
74}
75MenuObj_Convert(v, p_itself)
76 PyObject *v;
77 MenuHandle *p_itself;
78{
79 if (!MenuObj_Check(v))
80 {
81 PyErr_SetString(PyExc_TypeError, "Menu required");
82 return 0;
83 }
84 *p_itself = ((MenuObject *)v)->ob_itself;
85 return 1;
86}
87
88static void MenuObj_dealloc(self)
89 MenuObject *self;
90{
91 /* Cleanup of self->ob_itself goes here */
92 PyMem_DEL(self);
93}
94
95static PyObject *MenuObj_DisposeMenu(_self, _args)
96 MenuObject *_self;
97 PyObject *_args;
98{
99 PyObject *_res = NULL;
100 if (!PyArg_ParseTuple(_args, ""))
101 return NULL;
102 DisposeMenu(_self->ob_itself);
103 Py_INCREF(Py_None);
104 _res = Py_None;
105 return _res;
106}
107
Jack Jansena05ac601999-12-12 21:41:51 +0000108static PyObject *MenuObj_CalcMenuSize(_self, _args)
109 MenuObject *_self;
110 PyObject *_args;
111{
112 PyObject *_res = NULL;
113 if (!PyArg_ParseTuple(_args, ""))
114 return NULL;
115 CalcMenuSize(_self->ob_itself);
116 Py_INCREF(Py_None);
117 _res = Py_None;
118 return _res;
119}
120
Jack Jansene79dc762000-06-02 21:35:07 +0000121#ifndef TARGET_API_MAC_CARBON
122
Jack Jansena05ac601999-12-12 21:41:51 +0000123static PyObject *MenuObj_CountMItems(_self, _args)
124 MenuObject *_self;
125 PyObject *_args;
126{
127 PyObject *_res = NULL;
128 short _rv;
129 if (!PyArg_ParseTuple(_args, ""))
130 return NULL;
131 _rv = CountMItems(_self->ob_itself);
132 _res = Py_BuildValue("h",
133 _rv);
134 return _res;
135}
Jack Jansene79dc762000-06-02 21:35:07 +0000136#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000137
138static PyObject *MenuObj_GetMenuFont(_self, _args)
139 MenuObject *_self;
140 PyObject *_args;
141{
142 PyObject *_res = NULL;
143 OSStatus _err;
144 SInt16 outFontID;
145 UInt16 outFontSize;
146 if (!PyArg_ParseTuple(_args, ""))
147 return NULL;
148 _err = GetMenuFont(_self->ob_itself,
149 &outFontID,
150 &outFontSize);
151 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000152 _res = Py_BuildValue("hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000153 outFontID,
154 outFontSize);
155 return _res;
156}
157
158static PyObject *MenuObj_SetMenuFont(_self, _args)
159 MenuObject *_self;
160 PyObject *_args;
161{
162 PyObject *_res = NULL;
163 OSStatus _err;
164 SInt16 inFontID;
165 UInt16 inFontSize;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000166 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000167 &inFontID,
168 &inFontSize))
169 return NULL;
170 _err = SetMenuFont(_self->ob_itself,
171 inFontID,
172 inFontSize);
173 if (_err != noErr) return PyMac_Error(_err);
174 Py_INCREF(Py_None);
175 _res = Py_None;
176 return _res;
177}
178
179static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args)
180 MenuObject *_self;
181 PyObject *_args;
182{
183 PyObject *_res = NULL;
184 Boolean _rv;
185 if (!PyArg_ParseTuple(_args, ""))
186 return NULL;
187 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
188 _res = Py_BuildValue("b",
189 _rv);
190 return _res;
191}
192
193static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args)
194 MenuObject *_self;
195 PyObject *_args;
196{
197 PyObject *_res = NULL;
198 OSStatus _err;
199 Boolean excludesMark;
200 if (!PyArg_ParseTuple(_args, "b",
201 &excludesMark))
202 return NULL;
203 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
204 excludesMark);
205 if (_err != noErr) return PyMac_Error(_err);
206 Py_INCREF(Py_None);
207 _res = Py_None;
208 return _res;
209}
210
Jack Jansen1c4e6141998-04-21 15:23:55 +0000211static PyObject *MenuObj_MacAppendMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000212 MenuObject *_self;
213 PyObject *_args;
214{
215 PyObject *_res = NULL;
216 Str255 data;
217 if (!PyArg_ParseTuple(_args, "O&",
218 PyMac_GetStr255, data))
219 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000220 MacAppendMenu(_self->ob_itself,
221 data);
Guido van Rossum17448e21995-01-30 11:53:55 +0000222 Py_INCREF(Py_None);
223 _res = Py_None;
224 return _res;
225}
226
Guido van Rossum17448e21995-01-30 11:53:55 +0000227static PyObject *MenuObj_InsertResMenu(_self, _args)
228 MenuObject *_self;
229 PyObject *_args;
230{
231 PyObject *_res = NULL;
232 ResType theType;
233 short afterItem;
234 if (!PyArg_ParseTuple(_args, "O&h",
235 PyMac_GetOSType, &theType,
236 &afterItem))
237 return NULL;
238 InsertResMenu(_self->ob_itself,
239 theType,
240 afterItem);
241 Py_INCREF(Py_None);
242 _res = Py_None;
243 return _res;
244}
245
Jack Jansen21f96871998-02-20 16:02:09 +0000246static PyObject *MenuObj_AppendResMenu(_self, _args)
247 MenuObject *_self;
248 PyObject *_args;
249{
250 PyObject *_res = NULL;
251 ResType theType;
252 if (!PyArg_ParseTuple(_args, "O&",
253 PyMac_GetOSType, &theType))
254 return NULL;
255 AppendResMenu(_self->ob_itself,
256 theType);
257 Py_INCREF(Py_None);
258 _res = Py_None;
259 return _res;
260}
261
Jack Jansen1c4e6141998-04-21 15:23:55 +0000262static PyObject *MenuObj_MacInsertMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000263 MenuObject *_self;
264 PyObject *_args;
265{
266 PyObject *_res = NULL;
267 Str255 itemString;
268 short afterItem;
269 if (!PyArg_ParseTuple(_args, "O&h",
270 PyMac_GetStr255, itemString,
271 &afterItem))
272 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000273 MacInsertMenuItem(_self->ob_itself,
274 itemString,
275 afterItem);
Guido van Rossum17448e21995-01-30 11:53:55 +0000276 Py_INCREF(Py_None);
277 _res = Py_None;
278 return _res;
279}
280
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000281static PyObject *MenuObj_DeleteMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000282 MenuObject *_self;
283 PyObject *_args;
284{
285 PyObject *_res = NULL;
286 short item;
287 if (!PyArg_ParseTuple(_args, "h",
288 &item))
289 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000290 DeleteMenuItem(_self->ob_itself,
291 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000292 Py_INCREF(Py_None);
293 _res = Py_None;
294 return _res;
295}
296
Jack Jansena05ac601999-12-12 21:41:51 +0000297static PyObject *MenuObj_InsertFontResMenu(_self, _args)
298 MenuObject *_self;
299 PyObject *_args;
300{
301 PyObject *_res = NULL;
302 short afterItem;
303 short scriptFilter;
304 if (!PyArg_ParseTuple(_args, "hh",
305 &afterItem,
306 &scriptFilter))
307 return NULL;
308 InsertFontResMenu(_self->ob_itself,
309 afterItem,
310 scriptFilter);
311 Py_INCREF(Py_None);
312 _res = Py_None;
313 return _res;
314}
315
316static PyObject *MenuObj_InsertIntlResMenu(_self, _args)
317 MenuObject *_self;
318 PyObject *_args;
319{
320 PyObject *_res = NULL;
321 ResType theType;
322 short afterItem;
323 short scriptFilter;
324 if (!PyArg_ParseTuple(_args, "O&hh",
325 PyMac_GetOSType, &theType,
326 &afterItem,
327 &scriptFilter))
328 return NULL;
329 InsertIntlResMenu(_self->ob_itself,
330 theType,
331 afterItem,
332 scriptFilter);
333 Py_INCREF(Py_None);
334 _res = Py_None;
335 return _res;
336}
337
338static PyObject *MenuObj_AppendMenuItemText(_self, _args)
339 MenuObject *_self;
340 PyObject *_args;
341{
342 PyObject *_res = NULL;
343 OSStatus _err;
344 Str255 inString;
345 if (!PyArg_ParseTuple(_args, "O&",
346 PyMac_GetStr255, inString))
347 return NULL;
348 _err = AppendMenuItemText(_self->ob_itself,
349 inString);
350 if (_err != noErr) return PyMac_Error(_err);
351 Py_INCREF(Py_None);
352 _res = Py_None;
353 return _res;
354}
355
356static PyObject *MenuObj_InsertMenuItemText(_self, _args)
357 MenuObject *_self;
358 PyObject *_args;
359{
360 PyObject *_res = NULL;
361 OSStatus _err;
362 Str255 inString;
363 UInt16 afterItem;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000364 if (!PyArg_ParseTuple(_args, "O&H",
Jack Jansena05ac601999-12-12 21:41:51 +0000365 PyMac_GetStr255, inString,
366 &afterItem))
367 return NULL;
368 _err = InsertMenuItemText(_self->ob_itself,
369 inString,
370 afterItem);
371 if (_err != noErr) return PyMac_Error(_err);
372 Py_INCREF(Py_None);
373 _res = Py_None;
374 return _res;
375}
376
377static PyObject *MenuObj_PopUpMenuSelect(_self, _args)
378 MenuObject *_self;
379 PyObject *_args;
380{
381 PyObject *_res = NULL;
382 long _rv;
383 short top;
384 short left;
385 short popUpItem;
386 if (!PyArg_ParseTuple(_args, "hhh",
387 &top,
388 &left,
389 &popUpItem))
390 return NULL;
391 _rv = PopUpMenuSelect(_self->ob_itself,
392 top,
393 left,
394 popUpItem);
395 _res = Py_BuildValue("l",
396 _rv);
397 return _res;
398}
399
400static PyObject *MenuObj_MacInsertMenu(_self, _args)
401 MenuObject *_self;
402 PyObject *_args;
403{
404 PyObject *_res = NULL;
405 short beforeID;
406 if (!PyArg_ParseTuple(_args, "h",
407 &beforeID))
408 return NULL;
409 MacInsertMenu(_self->ob_itself,
410 beforeID);
411 Py_INCREF(Py_None);
412 _res = Py_None;
413 return _res;
414}
415
Jack Jansene79dc762000-06-02 21:35:07 +0000416#ifndef TARGET_API_MAC_CARBON
417
Jack Jansena05ac601999-12-12 21:41:51 +0000418static PyObject *MenuObj_CheckItem(_self, _args)
419 MenuObject *_self;
420 PyObject *_args;
421{
422 PyObject *_res = NULL;
423 short item;
424 Boolean checked;
425 if (!PyArg_ParseTuple(_args, "hb",
426 &item,
427 &checked))
428 return NULL;
429 CheckItem(_self->ob_itself,
430 item,
431 checked);
432 Py_INCREF(Py_None);
433 _res = Py_None;
434 return _res;
435}
Jack Jansene79dc762000-06-02 21:35:07 +0000436#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000437
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000438static PyObject *MenuObj_SetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000439 MenuObject *_self;
440 PyObject *_args;
441{
442 PyObject *_res = NULL;
443 short item;
444 Str255 itemString;
445 if (!PyArg_ParseTuple(_args, "hO&",
446 &item,
447 PyMac_GetStr255, itemString))
448 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000449 SetMenuItemText(_self->ob_itself,
450 item,
451 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000452 Py_INCREF(Py_None);
453 _res = Py_None;
454 return _res;
455}
456
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000457static PyObject *MenuObj_GetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000458 MenuObject *_self;
459 PyObject *_args;
460{
461 PyObject *_res = NULL;
462 short item;
463 Str255 itemString;
464 if (!PyArg_ParseTuple(_args, "h",
465 &item))
466 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000467 GetMenuItemText(_self->ob_itself,
468 item,
469 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000470 _res = Py_BuildValue("O&",
471 PyMac_BuildStr255, itemString);
472 return _res;
473}
474
Guido van Rossum17448e21995-01-30 11:53:55 +0000475static PyObject *MenuObj_SetItemMark(_self, _args)
476 MenuObject *_self;
477 PyObject *_args;
478{
479 PyObject *_res = NULL;
480 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000481 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000482 if (!PyArg_ParseTuple(_args, "hh",
483 &item,
484 &markChar))
485 return NULL;
486 SetItemMark(_self->ob_itself,
487 item,
488 markChar);
489 Py_INCREF(Py_None);
490 _res = Py_None;
491 return _res;
492}
493
494static PyObject *MenuObj_GetItemMark(_self, _args)
495 MenuObject *_self;
496 PyObject *_args;
497{
498 PyObject *_res = NULL;
499 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000500 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000501 if (!PyArg_ParseTuple(_args, "h",
502 &item))
503 return NULL;
504 GetItemMark(_self->ob_itself,
505 item,
506 &markChar);
507 _res = Py_BuildValue("h",
508 markChar);
509 return _res;
510}
511
Jack Jansen21f96871998-02-20 16:02:09 +0000512static PyObject *MenuObj_SetItemCmd(_self, _args)
513 MenuObject *_self;
514 PyObject *_args;
515{
516 PyObject *_res = NULL;
517 short item;
518 CharParameter cmdChar;
519 if (!PyArg_ParseTuple(_args, "hh",
520 &item,
521 &cmdChar))
522 return NULL;
523 SetItemCmd(_self->ob_itself,
524 item,
525 cmdChar);
526 Py_INCREF(Py_None);
527 _res = Py_None;
528 return _res;
529}
530
531static PyObject *MenuObj_GetItemCmd(_self, _args)
532 MenuObject *_self;
533 PyObject *_args;
534{
535 PyObject *_res = NULL;
536 short item;
537 CharParameter cmdChar;
538 if (!PyArg_ParseTuple(_args, "h",
539 &item))
540 return NULL;
541 GetItemCmd(_self->ob_itself,
542 item,
543 &cmdChar);
544 _res = Py_BuildValue("h",
545 cmdChar);
546 return _res;
547}
548
Guido van Rossum17448e21995-01-30 11:53:55 +0000549static PyObject *MenuObj_SetItemIcon(_self, _args)
550 MenuObject *_self;
551 PyObject *_args;
552{
553 PyObject *_res = NULL;
554 short item;
555 short iconIndex;
556 if (!PyArg_ParseTuple(_args, "hh",
557 &item,
558 &iconIndex))
559 return NULL;
560 SetItemIcon(_self->ob_itself,
561 item,
562 iconIndex);
563 Py_INCREF(Py_None);
564 _res = Py_None;
565 return _res;
566}
567
568static PyObject *MenuObj_GetItemIcon(_self, _args)
569 MenuObject *_self;
570 PyObject *_args;
571{
572 PyObject *_res = NULL;
573 short item;
574 short iconIndex;
575 if (!PyArg_ParseTuple(_args, "h",
576 &item))
577 return NULL;
578 GetItemIcon(_self->ob_itself,
579 item,
580 &iconIndex);
581 _res = Py_BuildValue("h",
582 iconIndex);
583 return _res;
584}
585
586static PyObject *MenuObj_SetItemStyle(_self, _args)
587 MenuObject *_self;
588 PyObject *_args;
589{
590 PyObject *_res = NULL;
591 short item;
Jack Jansend6b6d881998-02-25 15:45:21 +0000592 StyleParameter chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000593 if (!PyArg_ParseTuple(_args, "hh",
594 &item,
595 &chStyle))
596 return NULL;
597 SetItemStyle(_self->ob_itself,
598 item,
599 chStyle);
600 Py_INCREF(Py_None);
601 _res = Py_None;
602 return _res;
603}
604
605static PyObject *MenuObj_GetItemStyle(_self, _args)
606 MenuObject *_self;
607 PyObject *_args;
608{
609 PyObject *_res = NULL;
610 short item;
Jack Jansen7d0bc831995-06-09 20:56:31 +0000611 Style chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000612 if (!PyArg_ParseTuple(_args, "h",
613 &item))
614 return NULL;
615 GetItemStyle(_self->ob_itself,
616 item,
617 &chStyle);
618 _res = Py_BuildValue("b",
619 chStyle);
620 return _res;
621}
622
Jack Jansene79dc762000-06-02 21:35:07 +0000623#ifndef TARGET_API_MAC_CARBON
624
Jack Jansen21f96871998-02-20 16:02:09 +0000625static PyObject *MenuObj_DisableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000626 MenuObject *_self;
627 PyObject *_args;
628{
629 PyObject *_res = NULL;
630 short item;
Guido van Rossum17448e21995-01-30 11:53:55 +0000631 if (!PyArg_ParseTuple(_args, "h",
632 &item))
633 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000634 DisableItem(_self->ob_itself,
635 item);
636 Py_INCREF(Py_None);
637 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +0000638 return _res;
639}
Jack Jansene79dc762000-06-02 21:35:07 +0000640#endif
641
642#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000643
Jack Jansen21f96871998-02-20 16:02:09 +0000644static PyObject *MenuObj_EnableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000645 MenuObject *_self;
646 PyObject *_args;
647{
648 PyObject *_res = NULL;
649 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000650 if (!PyArg_ParseTuple(_args, "h",
651 &item))
Guido van Rossum17448e21995-01-30 11:53:55 +0000652 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000653 EnableItem(_self->ob_itself,
654 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000655 Py_INCREF(Py_None);
656 _res = Py_None;
657 return _res;
658}
Jack Jansene79dc762000-06-02 21:35:07 +0000659#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000660
Jack Jansen21f96871998-02-20 16:02:09 +0000661static PyObject *MenuObj_SetMenuItemCommandID(_self, _args)
662 MenuObject *_self;
663 PyObject *_args;
664{
665 PyObject *_res = NULL;
666 OSErr _err;
667 SInt16 inItem;
668 UInt32 inCommandID;
669 if (!PyArg_ParseTuple(_args, "hl",
670 &inItem,
671 &inCommandID))
672 return NULL;
673 _err = SetMenuItemCommandID(_self->ob_itself,
674 inItem,
675 inCommandID);
676 if (_err != noErr) return PyMac_Error(_err);
677 Py_INCREF(Py_None);
678 _res = Py_None;
679 return _res;
680}
681
682static PyObject *MenuObj_GetMenuItemCommandID(_self, _args)
683 MenuObject *_self;
684 PyObject *_args;
685{
686 PyObject *_res = NULL;
687 OSErr _err;
688 SInt16 inItem;
689 UInt32 outCommandID;
690 if (!PyArg_ParseTuple(_args, "h",
691 &inItem))
692 return NULL;
693 _err = GetMenuItemCommandID(_self->ob_itself,
694 inItem,
695 &outCommandID);
696 if (_err != noErr) return PyMac_Error(_err);
697 _res = Py_BuildValue("l",
698 outCommandID);
699 return _res;
700}
701
702static PyObject *MenuObj_SetMenuItemModifiers(_self, _args)
703 MenuObject *_self;
704 PyObject *_args;
705{
706 PyObject *_res = NULL;
707 OSErr _err;
708 SInt16 inItem;
709 UInt8 inModifiers;
710 if (!PyArg_ParseTuple(_args, "hb",
711 &inItem,
712 &inModifiers))
713 return NULL;
714 _err = SetMenuItemModifiers(_self->ob_itself,
715 inItem,
716 inModifiers);
717 if (_err != noErr) return PyMac_Error(_err);
718 Py_INCREF(Py_None);
719 _res = Py_None;
720 return _res;
721}
722
723static PyObject *MenuObj_GetMenuItemModifiers(_self, _args)
724 MenuObject *_self;
725 PyObject *_args;
726{
727 PyObject *_res = NULL;
728 OSErr _err;
729 SInt16 inItem;
730 UInt8 outModifiers;
731 if (!PyArg_ParseTuple(_args, "h",
732 &inItem))
733 return NULL;
734 _err = GetMenuItemModifiers(_self->ob_itself,
735 inItem,
736 &outModifiers);
737 if (_err != noErr) return PyMac_Error(_err);
738 _res = Py_BuildValue("b",
739 outModifiers);
740 return _res;
741}
742
743static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args)
744 MenuObject *_self;
745 PyObject *_args;
746{
747 PyObject *_res = NULL;
748 OSErr _err;
749 SInt16 inItem;
750 UInt8 inIconType;
751 Handle inIconHandle;
752 if (!PyArg_ParseTuple(_args, "hbO&",
753 &inItem,
754 &inIconType,
755 ResObj_Convert, &inIconHandle))
756 return NULL;
757 _err = SetMenuItemIconHandle(_self->ob_itself,
758 inItem,
759 inIconType,
760 inIconHandle);
761 if (_err != noErr) return PyMac_Error(_err);
762 Py_INCREF(Py_None);
763 _res = Py_None;
764 return _res;
765}
766
767static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args)
768 MenuObject *_self;
769 PyObject *_args;
770{
771 PyObject *_res = NULL;
772 OSErr _err;
773 SInt16 inItem;
774 UInt8 outIconType;
775 Handle outIconHandle;
776 if (!PyArg_ParseTuple(_args, "h",
777 &inItem))
778 return NULL;
779 _err = GetMenuItemIconHandle(_self->ob_itself,
780 inItem,
781 &outIconType,
782 &outIconHandle);
783 if (_err != noErr) return PyMac_Error(_err);
784 _res = Py_BuildValue("bO&",
785 outIconType,
786 ResObj_New, outIconHandle);
787 return _res;
788}
789
790static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args)
791 MenuObject *_self;
792 PyObject *_args;
793{
794 PyObject *_res = NULL;
795 OSErr _err;
796 SInt16 inItem;
797 TextEncoding inScriptID;
798 if (!PyArg_ParseTuple(_args, "hl",
799 &inItem,
800 &inScriptID))
801 return NULL;
802 _err = SetMenuItemTextEncoding(_self->ob_itself,
803 inItem,
804 inScriptID);
805 if (_err != noErr) return PyMac_Error(_err);
806 Py_INCREF(Py_None);
807 _res = Py_None;
808 return _res;
809}
810
811static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args)
812 MenuObject *_self;
813 PyObject *_args;
814{
815 PyObject *_res = NULL;
816 OSErr _err;
817 SInt16 inItem;
818 TextEncoding outScriptID;
819 if (!PyArg_ParseTuple(_args, "h",
820 &inItem))
821 return NULL;
822 _err = GetMenuItemTextEncoding(_self->ob_itself,
823 inItem,
824 &outScriptID);
825 if (_err != noErr) return PyMac_Error(_err);
826 _res = Py_BuildValue("l",
827 outScriptID);
828 return _res;
829}
830
831static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args)
832 MenuObject *_self;
833 PyObject *_args;
834{
835 PyObject *_res = NULL;
836 OSErr _err;
837 SInt16 inItem;
838 SInt16 inHierID;
839 if (!PyArg_ParseTuple(_args, "hh",
840 &inItem,
841 &inHierID))
842 return NULL;
843 _err = SetMenuItemHierarchicalID(_self->ob_itself,
844 inItem,
845 inHierID);
846 if (_err != noErr) return PyMac_Error(_err);
847 Py_INCREF(Py_None);
848 _res = Py_None;
849 return _res;
850}
851
852static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args)
853 MenuObject *_self;
854 PyObject *_args;
855{
856 PyObject *_res = NULL;
857 OSErr _err;
858 SInt16 inItem;
859 SInt16 outHierID;
860 if (!PyArg_ParseTuple(_args, "h",
861 &inItem))
862 return NULL;
863 _err = GetMenuItemHierarchicalID(_self->ob_itself,
864 inItem,
865 &outHierID);
866 if (_err != noErr) return PyMac_Error(_err);
867 _res = Py_BuildValue("h",
868 outHierID);
869 return _res;
870}
871
872static PyObject *MenuObj_SetMenuItemFontID(_self, _args)
873 MenuObject *_self;
874 PyObject *_args;
875{
876 PyObject *_res = NULL;
877 OSErr _err;
878 SInt16 inItem;
879 SInt16 inFontID;
880 if (!PyArg_ParseTuple(_args, "hh",
881 &inItem,
882 &inFontID))
883 return NULL;
884 _err = SetMenuItemFontID(_self->ob_itself,
885 inItem,
886 inFontID);
887 if (_err != noErr) return PyMac_Error(_err);
888 Py_INCREF(Py_None);
889 _res = Py_None;
890 return _res;
891}
892
893static PyObject *MenuObj_GetMenuItemFontID(_self, _args)
894 MenuObject *_self;
895 PyObject *_args;
896{
897 PyObject *_res = NULL;
898 OSErr _err;
899 SInt16 inItem;
900 SInt16 outFontID;
901 if (!PyArg_ParseTuple(_args, "h",
902 &inItem))
903 return NULL;
904 _err = GetMenuItemFontID(_self->ob_itself,
905 inItem,
906 &outFontID);
907 if (_err != noErr) return PyMac_Error(_err);
908 _res = Py_BuildValue("h",
909 outFontID);
910 return _res;
911}
912
913static PyObject *MenuObj_SetMenuItemRefCon(_self, _args)
914 MenuObject *_self;
915 PyObject *_args;
916{
917 PyObject *_res = NULL;
918 OSErr _err;
919 SInt16 inItem;
920 UInt32 inRefCon;
921 if (!PyArg_ParseTuple(_args, "hl",
922 &inItem,
923 &inRefCon))
924 return NULL;
925 _err = SetMenuItemRefCon(_self->ob_itself,
926 inItem,
927 inRefCon);
928 if (_err != noErr) return PyMac_Error(_err);
929 Py_INCREF(Py_None);
930 _res = Py_None;
931 return _res;
932}
933
934static PyObject *MenuObj_GetMenuItemRefCon(_self, _args)
935 MenuObject *_self;
936 PyObject *_args;
937{
938 PyObject *_res = NULL;
939 OSErr _err;
940 SInt16 inItem;
941 UInt32 outRefCon;
942 if (!PyArg_ParseTuple(_args, "h",
943 &inItem))
944 return NULL;
945 _err = GetMenuItemRefCon(_self->ob_itself,
946 inItem,
947 &outRefCon);
948 if (_err != noErr) return PyMac_Error(_err);
949 _res = Py_BuildValue("l",
950 outRefCon);
951 return _res;
952}
953
Jack Jansene79dc762000-06-02 21:35:07 +0000954#ifndef TARGET_API_MAC_CARBON
955
Jack Jansen21f96871998-02-20 16:02:09 +0000956static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args)
957 MenuObject *_self;
958 PyObject *_args;
959{
960 PyObject *_res = NULL;
961 OSErr _err;
962 SInt16 inItem;
963 UInt32 inRefCon2;
964 if (!PyArg_ParseTuple(_args, "hl",
965 &inItem,
966 &inRefCon2))
967 return NULL;
968 _err = SetMenuItemRefCon2(_self->ob_itself,
969 inItem,
970 inRefCon2);
971 if (_err != noErr) return PyMac_Error(_err);
972 Py_INCREF(Py_None);
973 _res = Py_None;
974 return _res;
975}
Jack Jansene79dc762000-06-02 21:35:07 +0000976#endif
977
978#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +0000979
980static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args)
981 MenuObject *_self;
982 PyObject *_args;
983{
984 PyObject *_res = NULL;
985 OSErr _err;
986 SInt16 inItem;
987 UInt32 outRefCon2;
988 if (!PyArg_ParseTuple(_args, "h",
989 &inItem))
990 return NULL;
991 _err = GetMenuItemRefCon2(_self->ob_itself,
992 inItem,
993 &outRefCon2);
994 if (_err != noErr) return PyMac_Error(_err);
995 _res = Py_BuildValue("l",
996 outRefCon2);
997 return _res;
998}
Jack Jansene79dc762000-06-02 21:35:07 +0000999#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001000
1001static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args)
1002 MenuObject *_self;
1003 PyObject *_args;
1004{
1005 PyObject *_res = NULL;
1006 OSErr _err;
1007 SInt16 inItem;
1008 SInt16 inGlyph;
1009 if (!PyArg_ParseTuple(_args, "hh",
1010 &inItem,
1011 &inGlyph))
1012 return NULL;
1013 _err = SetMenuItemKeyGlyph(_self->ob_itself,
1014 inItem,
1015 inGlyph);
1016 if (_err != noErr) return PyMac_Error(_err);
1017 Py_INCREF(Py_None);
1018 _res = Py_None;
1019 return _res;
1020}
1021
1022static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args)
1023 MenuObject *_self;
1024 PyObject *_args;
1025{
1026 PyObject *_res = NULL;
1027 OSErr _err;
1028 SInt16 inItem;
1029 SInt16 outGlyph;
1030 if (!PyArg_ParseTuple(_args, "h",
1031 &inItem))
1032 return NULL;
1033 _err = GetMenuItemKeyGlyph(_self->ob_itself,
1034 inItem,
1035 &outGlyph);
1036 if (_err != noErr) return PyMac_Error(_err);
1037 _res = Py_BuildValue("h",
1038 outGlyph);
1039 return _res;
1040}
1041
Jack Jansena05ac601999-12-12 21:41:51 +00001042static PyObject *MenuObj_MacEnableMenuItem(_self, _args)
1043 MenuObject *_self;
1044 PyObject *_args;
1045{
1046 PyObject *_res = NULL;
1047 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001048 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001049 &item))
1050 return NULL;
1051 MacEnableMenuItem(_self->ob_itself,
1052 item);
1053 Py_INCREF(Py_None);
1054 _res = Py_None;
1055 return _res;
1056}
1057
1058static PyObject *MenuObj_DisableMenuItem(_self, _args)
1059 MenuObject *_self;
1060 PyObject *_args;
1061{
1062 PyObject *_res = NULL;
1063 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001064 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001065 &item))
1066 return NULL;
1067 DisableMenuItem(_self->ob_itself,
1068 item);
1069 Py_INCREF(Py_None);
1070 _res = Py_None;
1071 return _res;
1072}
1073
1074static PyObject *MenuObj_IsMenuItemEnabled(_self, _args)
1075 MenuObject *_self;
1076 PyObject *_args;
1077{
1078 PyObject *_res = NULL;
1079 Boolean _rv;
1080 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001081 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001082 &item))
1083 return NULL;
1084 _rv = IsMenuItemEnabled(_self->ob_itself,
1085 item);
1086 _res = Py_BuildValue("b",
1087 _rv);
1088 return _res;
1089}
1090
1091static PyObject *MenuObj_EnableMenuItemIcon(_self, _args)
1092 MenuObject *_self;
1093 PyObject *_args;
1094{
1095 PyObject *_res = NULL;
1096 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001097 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001098 &item))
1099 return NULL;
1100 EnableMenuItemIcon(_self->ob_itself,
1101 item);
1102 Py_INCREF(Py_None);
1103 _res = Py_None;
1104 return _res;
1105}
1106
1107static PyObject *MenuObj_DisableMenuItemIcon(_self, _args)
1108 MenuObject *_self;
1109 PyObject *_args;
1110{
1111 PyObject *_res = NULL;
1112 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001113 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001114 &item))
1115 return NULL;
1116 DisableMenuItemIcon(_self->ob_itself,
1117 item);
1118 Py_INCREF(Py_None);
1119 _res = Py_None;
1120 return _res;
1121}
1122
1123static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args)
1124 MenuObject *_self;
1125 PyObject *_args;
1126{
1127 PyObject *_res = NULL;
1128 Boolean _rv;
1129 UInt16 item;
Jack Jansen0b13e7c2000-07-07 13:09:35 +00001130 if (!PyArg_ParseTuple(_args, "H",
Jack Jansena05ac601999-12-12 21:41:51 +00001131 &item))
1132 return NULL;
1133 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1134 item);
1135 _res = Py_BuildValue("b",
1136 _rv);
1137 return _res;
1138}
1139
Jack Jansena1772281995-06-18 20:17:27 +00001140static PyObject *MenuObj_as_Resource(_self, _args)
1141 MenuObject *_self;
1142 PyObject *_args;
1143{
1144 PyObject *_res = NULL;
Jack Jansena1a0fef1999-12-23 14:32:06 +00001145 Handle _rv;
1146 if (!PyArg_ParseTuple(_args, ""))
1147 return NULL;
1148 _rv = as_Resource(_self->ob_itself);
1149 _res = Py_BuildValue("O&",
1150 ResObj_New, _rv);
1151 return _res;
Jack Jansena1772281995-06-18 20:17:27 +00001152}
1153
Jack Jansene180d991998-04-24 10:28:20 +00001154static PyObject *MenuObj_AppendMenu(_self, _args)
1155 MenuObject *_self;
1156 PyObject *_args;
1157{
1158 PyObject *_res = NULL;
1159 Str255 data;
1160 if (!PyArg_ParseTuple(_args, "O&",
1161 PyMac_GetStr255, data))
1162 return NULL;
1163 AppendMenu(_self->ob_itself,
1164 data);
1165 Py_INCREF(Py_None);
1166 _res = Py_None;
1167 return _res;
1168}
1169
1170static PyObject *MenuObj_InsertMenu(_self, _args)
1171 MenuObject *_self;
1172 PyObject *_args;
1173{
1174 PyObject *_res = NULL;
1175 short beforeID;
1176 if (!PyArg_ParseTuple(_args, "h",
1177 &beforeID))
1178 return NULL;
1179 InsertMenu(_self->ob_itself,
1180 beforeID);
1181 Py_INCREF(Py_None);
1182 _res = Py_None;
1183 return _res;
1184}
1185
1186static PyObject *MenuObj_InsertMenuItem(_self, _args)
1187 MenuObject *_self;
1188 PyObject *_args;
1189{
1190 PyObject *_res = NULL;
1191 Str255 itemString;
1192 short afterItem;
1193 if (!PyArg_ParseTuple(_args, "O&h",
1194 PyMac_GetStr255, itemString,
1195 &afterItem))
1196 return NULL;
1197 InsertMenuItem(_self->ob_itself,
1198 itemString,
1199 afterItem);
1200 Py_INCREF(Py_None);
1201 _res = Py_None;
1202 return _res;
1203}
1204
Guido van Rossum17448e21995-01-30 11:53:55 +00001205static PyMethodDef MenuObj_methods[] = {
1206 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1207 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001208 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1209 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001210
1211#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001212 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1213 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001214#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001215 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1216 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1217 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1218 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1219 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1220 "() -> (Boolean _rv)"},
1221 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1222 "(Boolean excludesMark) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001223 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001224 "(Str255 data) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001225 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1226 "(ResType theType, short afterItem) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001227 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1228 "(ResType theType) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001229 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001230 "(Str255 itemString, short afterItem) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001231 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001232 "(short item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001233 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1234 "(short afterItem, short scriptFilter) -> None"},
1235 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1236 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1237 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1238 "(Str255 inString) -> None"},
1239 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
1240 "(Str255 inString, UInt16 afterItem) -> None"},
1241 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1242 "(short top, short left, short popUpItem) -> (long _rv)"},
1243 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
1244 "(short beforeID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001245
1246#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001247 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1248 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001249#endif
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001250 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001251 "(short item, Str255 itemString) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001252 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001253 "(short item) -> (Str255 itemString)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001254 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001255 "(short item, CharParameter markChar) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001256 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001257 "(short item) -> (CharParameter markChar)"},
1258 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1259 "(short item, CharParameter cmdChar) -> None"},
1260 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1261 "(short item) -> (CharParameter cmdChar)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001262 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1263 "(short item, short iconIndex) -> None"},
1264 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1265 "(short item) -> (short iconIndex)"},
1266 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
Jack Jansend6b6d881998-02-25 15:45:21 +00001267 "(short item, StyleParameter chStyle) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001268 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
Jack Jansen7d0bc831995-06-09 20:56:31 +00001269 "(short item) -> (Style chStyle)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001270
1271#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001272 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1273 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001274#endif
1275
1276#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001277 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1278 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001279#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001280 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
1281 "(SInt16 inItem, UInt32 inCommandID) -> None"},
1282 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
1283 "(SInt16 inItem) -> (UInt32 outCommandID)"},
1284 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1285 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1286 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1287 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1288 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1289 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1290 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1291 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1292 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1293 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1294 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1295 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1296 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
1297 "(SInt16 inItem, SInt16 inHierID) -> None"},
1298 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
1299 "(SInt16 inItem) -> (SInt16 outHierID)"},
1300 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1301 "(SInt16 inItem, SInt16 inFontID) -> None"},
1302 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1303 "(SInt16 inItem) -> (SInt16 outFontID)"},
1304 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1305 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1306 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1307 "(SInt16 inItem) -> (UInt32 outRefCon)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001308
1309#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001310 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1311 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001312#endif
1313
1314#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001315 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1316 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001317#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001318 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1319 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1320 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1321 "(SInt16 inItem) -> (SInt16 outGlyph)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001322 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
1323 "(UInt16 item) -> None"},
1324 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
1325 "(UInt16 item) -> None"},
1326 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
1327 "(UInt16 item) -> (Boolean _rv)"},
1328 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
1329 "(UInt16 item) -> None"},
1330 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
1331 "(UInt16 item) -> None"},
1332 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
1333 "(UInt16 item) -> (Boolean _rv)"},
Jack Jansena1772281995-06-18 20:17:27 +00001334 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
Jack Jansena1a0fef1999-12-23 14:32:06 +00001335 "() -> (Handle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00001336 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
1337 "(Str255 data) -> None"},
1338 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
1339 "(short beforeID) -> None"},
1340 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
1341 "(Str255 itemString, short afterItem) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001342 {NULL, NULL, 0}
1343};
1344
1345PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
1346
1347static PyObject *MenuObj_getattr(self, name)
1348 MenuObject *self;
1349 char *name;
1350{
1351 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
1352}
1353
1354#define MenuObj_setattr NULL
1355
Jack Jansena05ac601999-12-12 21:41:51 +00001356#define MenuObj_compare NULL
1357
1358#define MenuObj_repr NULL
1359
1360#define MenuObj_hash NULL
1361
Guido van Rossum17448e21995-01-30 11:53:55 +00001362PyTypeObject Menu_Type = {
1363 PyObject_HEAD_INIT(&PyType_Type)
1364 0, /*ob_size*/
1365 "Menu", /*tp_name*/
1366 sizeof(MenuObject), /*tp_basicsize*/
1367 0, /*tp_itemsize*/
1368 /* methods */
1369 (destructor) MenuObj_dealloc, /*tp_dealloc*/
1370 0, /*tp_print*/
1371 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
1372 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00001373 (cmpfunc) MenuObj_compare, /*tp_compare*/
1374 (reprfunc) MenuObj_repr, /*tp_repr*/
1375 (PyNumberMethods *)0, /* tp_as_number */
1376 (PySequenceMethods *)0, /* tp_as_sequence */
1377 (PyMappingMethods *)0, /* tp_as_mapping */
1378 (hashfunc) MenuObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00001379};
1380
1381/* ---------------------- End object type Menu ---------------------- */
1382
1383
Jack Jansene79dc762000-06-02 21:35:07 +00001384#ifndef TARGET_API_MAC_CARBON
1385
Jack Jansena05ac601999-12-12 21:41:51 +00001386static PyObject *Menu_InitProcMenu(_self, _args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001387 PyObject *_self;
1388 PyObject *_args;
1389{
1390 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001391 short resID;
1392 if (!PyArg_ParseTuple(_args, "h",
1393 &resID))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001394 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001395 InitProcMenu(resID);
1396 Py_INCREF(Py_None);
1397 _res = Py_None;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001398 return _res;
1399}
Jack Jansene79dc762000-06-02 21:35:07 +00001400#endif
1401
1402#ifndef TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001403
Guido van Rossum17448e21995-01-30 11:53:55 +00001404static PyObject *Menu_InitMenus(_self, _args)
1405 PyObject *_self;
1406 PyObject *_args;
1407{
1408 PyObject *_res = NULL;
1409 if (!PyArg_ParseTuple(_args, ""))
1410 return NULL;
1411 InitMenus();
1412 Py_INCREF(Py_None);
1413 _res = Py_None;
1414 return _res;
1415}
Jack Jansene79dc762000-06-02 21:35:07 +00001416#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00001417
1418static PyObject *Menu_NewMenu(_self, _args)
1419 PyObject *_self;
1420 PyObject *_args;
1421{
1422 PyObject *_res = NULL;
1423 MenuHandle _rv;
1424 short menuID;
1425 Str255 menuTitle;
1426 if (!PyArg_ParseTuple(_args, "hO&",
1427 &menuID,
1428 PyMac_GetStr255, menuTitle))
1429 return NULL;
1430 _rv = NewMenu(menuID,
1431 menuTitle);
1432 _res = Py_BuildValue("O&",
1433 MenuObj_New, _rv);
1434 return _res;
1435}
1436
Jack Jansen1c4e6141998-04-21 15:23:55 +00001437static PyObject *Menu_MacGetMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001438 PyObject *_self;
1439 PyObject *_args;
1440{
1441 PyObject *_res = NULL;
1442 MenuHandle _rv;
1443 short resourceID;
1444 if (!PyArg_ParseTuple(_args, "h",
1445 &resourceID))
1446 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001447 _rv = MacGetMenu(resourceID);
Guido van Rossum17448e21995-01-30 11:53:55 +00001448 _res = Py_BuildValue("O&",
1449 MenuObj_New, _rv);
1450 return _res;
1451}
1452
Guido van Rossum17448e21995-01-30 11:53:55 +00001453static PyObject *Menu_MenuKey(_self, _args)
1454 PyObject *_self;
1455 PyObject *_args;
1456{
1457 PyObject *_res = NULL;
1458 long _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00001459 CharParameter ch;
Guido van Rossum17448e21995-01-30 11:53:55 +00001460 if (!PyArg_ParseTuple(_args, "h",
1461 &ch))
1462 return NULL;
1463 _rv = MenuKey(ch);
1464 _res = Py_BuildValue("l",
1465 _rv);
1466 return _res;
1467}
1468
Jack Jansena05ac601999-12-12 21:41:51 +00001469static PyObject *Menu_MenuSelect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001470 PyObject *_self;
1471 PyObject *_args;
1472{
1473 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001474 long _rv;
1475 Point startPt;
1476 if (!PyArg_ParseTuple(_args, "O&",
1477 PyMac_GetPoint, &startPt))
Guido van Rossum17448e21995-01-30 11:53:55 +00001478 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001479 _rv = MenuSelect(startPt);
1480 _res = Py_BuildValue("l",
1481 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00001482 return _res;
1483}
1484
Guido van Rossum17448e21995-01-30 11:53:55 +00001485static PyObject *Menu_MenuChoice(_self, _args)
1486 PyObject *_self;
1487 PyObject *_args;
1488{
1489 PyObject *_res = NULL;
1490 long _rv;
1491 if (!PyArg_ParseTuple(_args, ""))
1492 return NULL;
1493 _rv = MenuChoice();
1494 _res = Py_BuildValue("l",
1495 _rv);
1496 return _res;
1497}
1498
Jack Jansena05ac601999-12-12 21:41:51 +00001499static PyObject *Menu_MenuEvent(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00001500 PyObject *_self;
1501 PyObject *_args;
1502{
1503 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001504 UInt32 _rv;
1505 EventRecord inEvent;
1506 if (!PyArg_ParseTuple(_args, "O&",
1507 PyMac_GetEventRecord, &inEvent))
Guido van Rossum17448e21995-01-30 11:53:55 +00001508 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001509 _rv = MenuEvent(&inEvent);
1510 _res = Py_BuildValue("l",
1511 _rv);
1512 return _res;
1513}
1514
1515static PyObject *Menu_GetMBarHeight(_self, _args)
1516 PyObject *_self;
1517 PyObject *_args;
1518{
1519 PyObject *_res = NULL;
1520 short _rv;
1521 if (!PyArg_ParseTuple(_args, ""))
1522 return NULL;
1523 _rv = GetMBarHeight();
1524 _res = Py_BuildValue("h",
1525 _rv);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001526 return _res;
1527}
1528
Jack Jansen1c4e6141998-04-21 15:23:55 +00001529static PyObject *Menu_MacDrawMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001530 PyObject *_self;
1531 PyObject *_args;
1532{
1533 PyObject *_res = NULL;
1534 if (!PyArg_ParseTuple(_args, ""))
1535 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00001536 MacDrawMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00001537 Py_INCREF(Py_None);
1538 _res = Py_None;
1539 return _res;
1540}
1541
1542static PyObject *Menu_InvalMenuBar(_self, _args)
1543 PyObject *_self;
1544 PyObject *_args;
1545{
1546 PyObject *_res = NULL;
1547 if (!PyArg_ParseTuple(_args, ""))
1548 return NULL;
1549 InvalMenuBar();
1550 Py_INCREF(Py_None);
1551 _res = Py_None;
1552 return _res;
1553}
1554
Jack Jansena05ac601999-12-12 21:41:51 +00001555static PyObject *Menu_HiliteMenu(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001556 PyObject *_self;
1557 PyObject *_args;
1558{
1559 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001560 short menuID;
Jack Jansen21f96871998-02-20 16:02:09 +00001561 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001562 &menuID))
Jack Jansen21f96871998-02-20 16:02:09 +00001563 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001564 HiliteMenu(menuID);
Jack Jansen21f96871998-02-20 16:02:09 +00001565 Py_INCREF(Py_None);
1566 _res = Py_None;
1567 return _res;
1568}
1569
Jack Jansena05ac601999-12-12 21:41:51 +00001570static PyObject *Menu_GetNewMBar(_self, _args)
1571 PyObject *_self;
1572 PyObject *_args;
1573{
1574 PyObject *_res = NULL;
1575 Handle _rv;
1576 short menuBarID;
1577 if (!PyArg_ParseTuple(_args, "h",
1578 &menuBarID))
1579 return NULL;
1580 _rv = GetNewMBar(menuBarID);
1581 _res = Py_BuildValue("O&",
1582 ResObj_New, _rv);
1583 return _res;
1584}
1585
Jack Jansen21f96871998-02-20 16:02:09 +00001586static PyObject *Menu_GetMenuBar(_self, _args)
1587 PyObject *_self;
1588 PyObject *_args;
1589{
1590 PyObject *_res = NULL;
1591 Handle _rv;
1592 if (!PyArg_ParseTuple(_args, ""))
1593 return NULL;
1594 _rv = GetMenuBar();
1595 _res = Py_BuildValue("O&",
1596 ResObj_New, _rv);
1597 return _res;
1598}
1599
1600static PyObject *Menu_SetMenuBar(_self, _args)
1601 PyObject *_self;
1602 PyObject *_args;
1603{
1604 PyObject *_res = NULL;
1605 Handle menuList;
1606 if (!PyArg_ParseTuple(_args, "O&",
1607 ResObj_Convert, &menuList))
1608 return NULL;
1609 SetMenuBar(menuList);
1610 Py_INCREF(Py_None);
1611 _res = Py_None;
1612 return _res;
1613}
1614
Jack Jansena05ac601999-12-12 21:41:51 +00001615static PyObject *Menu_GetMenuHandle(_self, _args)
1616 PyObject *_self;
1617 PyObject *_args;
1618{
1619 PyObject *_res = NULL;
1620 MenuHandle _rv;
1621 short menuID;
1622 if (!PyArg_ParseTuple(_args, "h",
1623 &menuID))
1624 return NULL;
1625 _rv = GetMenuHandle(menuID);
1626 _res = Py_BuildValue("O&",
1627 MenuObj_New, _rv);
1628 return _res;
1629}
1630
1631static PyObject *Menu_MacDeleteMenu(_self, _args)
1632 PyObject *_self;
1633 PyObject *_args;
1634{
1635 PyObject *_res = NULL;
1636 short menuID;
1637 if (!PyArg_ParseTuple(_args, "h",
1638 &menuID))
1639 return NULL;
1640 MacDeleteMenu(menuID);
1641 Py_INCREF(Py_None);
1642 _res = Py_None;
1643 return _res;
1644}
1645
1646static PyObject *Menu_ClearMenuBar(_self, _args)
1647 PyObject *_self;
1648 PyObject *_args;
1649{
1650 PyObject *_res = NULL;
1651 if (!PyArg_ParseTuple(_args, ""))
1652 return NULL;
1653 ClearMenuBar();
1654 Py_INCREF(Py_None);
1655 _res = Py_None;
1656 return _res;
1657}
1658
Jack Jansene79dc762000-06-02 21:35:07 +00001659#ifndef TARGET_API_MAC_CARBON
1660
Jack Jansena05ac601999-12-12 21:41:51 +00001661static PyObject *Menu_SetMenuFlash(_self, _args)
1662 PyObject *_self;
1663 PyObject *_args;
1664{
1665 PyObject *_res = NULL;
1666 short count;
1667 if (!PyArg_ParseTuple(_args, "h",
1668 &count))
1669 return NULL;
1670 SetMenuFlash(count);
1671 Py_INCREF(Py_None);
1672 _res = Py_None;
1673 return _res;
1674}
Jack Jansene79dc762000-06-02 21:35:07 +00001675#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001676
1677static PyObject *Menu_FlashMenuBar(_self, _args)
1678 PyObject *_self;
1679 PyObject *_args;
1680{
1681 PyObject *_res = NULL;
1682 short menuID;
1683 if (!PyArg_ParseTuple(_args, "h",
1684 &menuID))
1685 return NULL;
1686 FlashMenuBar(menuID);
1687 Py_INCREF(Py_None);
1688 _res = Py_None;
1689 return _res;
1690}
1691
Jack Jansene79dc762000-06-02 21:35:07 +00001692#ifndef TARGET_API_MAC_CARBON
1693
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001694static PyObject *Menu_SystemEdit(_self, _args)
1695 PyObject *_self;
1696 PyObject *_args;
1697{
1698 PyObject *_res = NULL;
1699 Boolean _rv;
1700 short editCmd;
1701 if (!PyArg_ParseTuple(_args, "h",
1702 &editCmd))
1703 return NULL;
1704 _rv = SystemEdit(editCmd);
1705 _res = Py_BuildValue("b",
1706 _rv);
1707 return _res;
1708}
Jack Jansene79dc762000-06-02 21:35:07 +00001709#endif
1710
1711#ifndef TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001712
1713static PyObject *Menu_SystemMenu(_self, _args)
1714 PyObject *_self;
1715 PyObject *_args;
1716{
1717 PyObject *_res = NULL;
1718 long menuResult;
1719 if (!PyArg_ParseTuple(_args, "l",
1720 &menuResult))
1721 return NULL;
1722 SystemMenu(menuResult);
Guido van Rossum17448e21995-01-30 11:53:55 +00001723 Py_INCREF(Py_None);
1724 _res = Py_None;
1725 return _res;
1726}
Jack Jansene79dc762000-06-02 21:35:07 +00001727#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00001728
Jack Jansena05ac601999-12-12 21:41:51 +00001729static PyObject *Menu_IsMenuBarVisible(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001730 PyObject *_self;
1731 PyObject *_args;
1732{
1733 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001734 Boolean _rv;
1735 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00001736 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001737 _rv = IsMenuBarVisible();
1738 _res = Py_BuildValue("b",
1739 _rv);
Jack Jansen21f96871998-02-20 16:02:09 +00001740 return _res;
1741}
1742
Jack Jansena05ac601999-12-12 21:41:51 +00001743static PyObject *Menu_ShowMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001744 PyObject *_self;
1745 PyObject *_args;
1746{
1747 PyObject *_res = NULL;
1748 if (!PyArg_ParseTuple(_args, ""))
1749 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001750 ShowMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00001751 Py_INCREF(Py_None);
1752 _res = Py_None;
1753 return _res;
1754}
1755
Jack Jansena05ac601999-12-12 21:41:51 +00001756static PyObject *Menu_HideMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001757 PyObject *_self;
1758 PyObject *_args;
1759{
1760 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001761 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00001762 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001763 HideMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00001764 Py_INCREF(Py_None);
1765 _res = Py_None;
1766 return _res;
1767}
1768
Jack Jansena05ac601999-12-12 21:41:51 +00001769static PyObject *Menu_DeleteMCEntries(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001770 PyObject *_self;
1771 PyObject *_args;
1772{
1773 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001774 short menuID;
1775 short menuItem;
1776 if (!PyArg_ParseTuple(_args, "hh",
1777 &menuID,
1778 &menuItem))
Jack Jansen21f96871998-02-20 16:02:09 +00001779 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001780 DeleteMCEntries(menuID,
1781 menuItem);
1782 Py_INCREF(Py_None);
1783 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00001784 return _res;
1785}
1786
Jack Jansena05ac601999-12-12 21:41:51 +00001787static PyObject *Menu_InitContextualMenus(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00001788 PyObject *_self;
1789 PyObject *_args;
1790{
1791 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001792 OSStatus _err;
1793 if (!PyArg_ParseTuple(_args, ""))
1794 return NULL;
1795 _err = InitContextualMenus();
1796 if (_err != noErr) return PyMac_Error(_err);
1797 Py_INCREF(Py_None);
1798 _res = Py_None;
1799 return _res;
1800}
1801
1802static PyObject *Menu_IsShowContextualMenuClick(_self, _args)
1803 PyObject *_self;
1804 PyObject *_args;
1805{
1806 PyObject *_res = NULL;
1807 Boolean _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00001808 EventRecord inEvent;
1809 if (!PyArg_ParseTuple(_args, "O&",
1810 PyMac_GetEventRecord, &inEvent))
1811 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00001812 _rv = IsShowContextualMenuClick(&inEvent);
1813 _res = Py_BuildValue("b",
Jack Jansen21f96871998-02-20 16:02:09 +00001814 _rv);
1815 return _res;
1816}
1817
Jack Jansene79dc762000-06-02 21:35:07 +00001818#ifndef TARGET_API_MAC_CARBON
1819
Guido van Rossum86c3af71995-03-19 22:42:51 +00001820static PyObject *Menu_OpenDeskAcc(_self, _args)
1821 PyObject *_self;
1822 PyObject *_args;
1823{
1824 PyObject *_res = NULL;
1825 Str255 name;
1826 if (!PyArg_ParseTuple(_args, "O&",
1827 PyMac_GetStr255, name))
1828 return NULL;
1829 OpenDeskAcc(name);
1830 Py_INCREF(Py_None);
1831 _res = Py_None;
1832 return _res;
1833}
Jack Jansene79dc762000-06-02 21:35:07 +00001834#endif
Guido van Rossum86c3af71995-03-19 22:42:51 +00001835
Jack Jansene0581891999-02-07 14:02:03 +00001836static PyObject *Menu_as_Menu(_self, _args)
1837 PyObject *_self;
1838 PyObject *_args;
1839{
1840 PyObject *_res = NULL;
1841 MenuHandle _rv;
1842 Handle h;
1843 if (!PyArg_ParseTuple(_args, "O&",
1844 ResObj_Convert, &h))
1845 return NULL;
1846 _rv = as_Menu(h);
1847 _res = Py_BuildValue("O&",
1848 MenuObj_New, _rv);
1849 return _res;
1850}
1851
Jack Jansene180d991998-04-24 10:28:20 +00001852static PyObject *Menu_GetMenu(_self, _args)
1853 PyObject *_self;
1854 PyObject *_args;
1855{
1856 PyObject *_res = NULL;
1857 MenuHandle _rv;
1858 short resourceID;
1859 if (!PyArg_ParseTuple(_args, "h",
1860 &resourceID))
1861 return NULL;
1862 _rv = GetMenu(resourceID);
1863 _res = Py_BuildValue("O&",
1864 MenuObj_New, _rv);
1865 return _res;
1866}
1867
1868static PyObject *Menu_DeleteMenu(_self, _args)
1869 PyObject *_self;
1870 PyObject *_args;
1871{
1872 PyObject *_res = NULL;
1873 short menuID;
1874 if (!PyArg_ParseTuple(_args, "h",
1875 &menuID))
1876 return NULL;
1877 DeleteMenu(menuID);
1878 Py_INCREF(Py_None);
1879 _res = Py_None;
1880 return _res;
1881}
1882
1883static PyObject *Menu_DrawMenuBar(_self, _args)
1884 PyObject *_self;
1885 PyObject *_args;
1886{
1887 PyObject *_res = NULL;
1888 if (!PyArg_ParseTuple(_args, ""))
1889 return NULL;
1890 DrawMenuBar();
1891 Py_INCREF(Py_None);
1892 _res = Py_None;
1893 return _res;
1894}
1895
Guido van Rossum17448e21995-01-30 11:53:55 +00001896static PyMethodDef Menu_methods[] = {
Jack Jansene79dc762000-06-02 21:35:07 +00001897
1898#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001899 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
1900 "(short resID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001901#endif
1902
1903#ifndef TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00001904 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
1905 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001906#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00001907 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
1908 "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001909 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001910 "(short resourceID) -> (MenuHandle _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001911 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001912 "(CharParameter ch) -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001913 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
1914 "(Point startPt) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001915 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
1916 "() -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001917 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
1918 "(EventRecord inEvent) -> (UInt32 _rv)"},
1919 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
1920 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001921 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001922 "() -> None"},
1923 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
1924 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001925 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
1926 "(short menuID) -> None"},
1927 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
1928 "(short menuBarID) -> (Handle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001929 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
1930 "() -> (Handle _rv)"},
1931 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
1932 "(Handle menuList) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001933 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
1934 "(short menuID) -> (MenuHandle _rv)"},
1935 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
1936 "(short menuID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001937 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
1938 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001939
1940#ifndef TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001941 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
1942 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001943#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001944 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
1945 "(short menuID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001946
1947#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001948 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
1949 "(short editCmd) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001950#endif
1951
1952#ifndef TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001953 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
1954 "(long menuResult) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001955#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001956 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
1957 "() -> (Boolean _rv)"},
1958 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
1959 "() -> None"},
1960 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
1961 "() -> None"},
1962 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
1963 "(short menuID, short menuItem) -> None"},
1964 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
1965 "() -> None"},
1966 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
1967 "(EventRecord inEvent) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001968
1969#ifndef TARGET_API_MAC_CARBON
Guido van Rossum86c3af71995-03-19 22:42:51 +00001970 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
1971 "(Str255 name) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001972#endif
Jack Jansene0581891999-02-07 14:02:03 +00001973 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
1974 "(Handle h) -> (MenuHandle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00001975 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
1976 "(short resourceID) -> (MenuHandle _rv)"},
1977 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
1978 "(short menuID) -> None"},
1979 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
1980 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001981 {NULL, NULL, 0}
1982};
1983
1984
1985
1986
1987void initMenu()
1988{
1989 PyObject *m;
1990 PyObject *d;
1991
1992
1993
1994
1995 m = Py_InitModule("Menu", Menu_methods);
1996 d = PyModule_GetDict(m);
1997 Menu_Error = PyMac_GetOSErrException();
1998 if (Menu_Error == NULL ||
1999 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
2000 Py_FatalError("can't initialize Menu.Error");
Jack Jansena755e681997-09-20 17:40:22 +00002001 Menu_Type.ob_type = &PyType_Type;
2002 Py_INCREF(&Menu_Type);
2003 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2004 Py_FatalError("can't initialize MenuType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002005}
2006
2007/* ======================== End module Menu ========================= */
2008