Clarify portability and main program.
[python/dscho.git] / Mac / Modules / menu / Menumodule.c
blob3e16440db4836d2723e36dc480c2d546a4a82367
2 /* ========================== Module Menu =========================== */
4 #include "Python.h"
8 #define SystemSevenOrLater 1
10 #include "macglue.h"
11 #include <Memory.h>
12 #include <Dialogs.h>
13 #include <Menus.h>
14 #include <Controls.h>
16 extern PyObject *ResObj_New(Handle);
17 extern int ResObj_Convert(PyObject *, Handle *);
18 extern PyObject *OptResObj_New(Handle);
19 extern int OptResObj_Convert(PyObject *, Handle *);
21 extern PyObject *WinObj_New(WindowPtr);
22 extern int WinObj_Convert(PyObject *, WindowPtr *);
23 extern PyTypeObject Window_Type;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject *DlgObj_New(DialogPtr);
27 extern int DlgObj_Convert(PyObject *, DialogPtr *);
28 extern PyTypeObject Dialog_Type;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject *MenuObj_New(MenuHandle);
32 extern int MenuObj_Convert(PyObject *, MenuHandle *);
34 extern PyObject *CtlObj_New(ControlHandle);
35 extern int CtlObj_Convert(PyObject *, ControlHandle *);
37 extern PyObject *GrafObj_New(GrafPtr);
38 extern int GrafObj_Convert(PyObject *, GrafPtr *);
40 extern PyObject *BMObj_New(BitMapPtr);
41 extern int BMObj_Convert(PyObject *, BitMapPtr *);
43 extern PyObject *WinObj_WhichWindow(WindowPtr);
45 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
46 #include <Menus.h>
48 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
50 static PyObject *Menu_Error;
52 /* ------------------------ Object type Menu ------------------------ */
54 PyTypeObject Menu_Type;
56 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
58 typedef struct MenuObject {
59 PyObject_HEAD
60 MenuHandle ob_itself;
61 } MenuObject;
63 PyObject *MenuObj_New(itself)
64 MenuHandle itself;
66 MenuObject *it;
67 it = PyObject_NEW(MenuObject, &Menu_Type);
68 if (it == NULL) return NULL;
69 it->ob_itself = itself;
70 return (PyObject *)it;
72 MenuObj_Convert(v, p_itself)
73 PyObject *v;
74 MenuHandle *p_itself;
76 if (!MenuObj_Check(v))
78 PyErr_SetString(PyExc_TypeError, "Menu required");
79 return 0;
81 *p_itself = ((MenuObject *)v)->ob_itself;
82 return 1;
85 static void MenuObj_dealloc(self)
86 MenuObject *self;
88 /* Cleanup of self->ob_itself goes here */
89 PyMem_DEL(self);
92 static PyObject *MenuObj_DisposeMenu(_self, _args)
93 MenuObject *_self;
94 PyObject *_args;
96 PyObject *_res = NULL;
97 if (!PyArg_ParseTuple(_args, ""))
98 return NULL;
99 DisposeMenu(_self->ob_itself);
100 Py_INCREF(Py_None);
101 _res = Py_None;
102 return _res;
105 static PyObject *MenuObj_MacAppendMenu(_self, _args)
106 MenuObject *_self;
107 PyObject *_args;
109 PyObject *_res = NULL;
110 Str255 data;
111 if (!PyArg_ParseTuple(_args, "O&",
112 PyMac_GetStr255, data))
113 return NULL;
114 MacAppendMenu(_self->ob_itself,
115 data);
116 Py_INCREF(Py_None);
117 _res = Py_None;
118 return _res;
121 static PyObject *MenuObj_InsertResMenu(_self, _args)
122 MenuObject *_self;
123 PyObject *_args;
125 PyObject *_res = NULL;
126 ResType theType;
127 short afterItem;
128 if (!PyArg_ParseTuple(_args, "O&h",
129 PyMac_GetOSType, &theType,
130 &afterItem))
131 return NULL;
132 InsertResMenu(_self->ob_itself,
133 theType,
134 afterItem);
135 Py_INCREF(Py_None);
136 _res = Py_None;
137 return _res;
140 static PyObject *MenuObj_MacInsertMenu(_self, _args)
141 MenuObject *_self;
142 PyObject *_args;
144 PyObject *_res = NULL;
145 short beforeID;
146 if (!PyArg_ParseTuple(_args, "h",
147 &beforeID))
148 return NULL;
149 MacInsertMenu(_self->ob_itself,
150 beforeID);
151 Py_INCREF(Py_None);
152 _res = Py_None;
153 return _res;
156 static PyObject *MenuObj_AppendResMenu(_self, _args)
157 MenuObject *_self;
158 PyObject *_args;
160 PyObject *_res = NULL;
161 ResType theType;
162 if (!PyArg_ParseTuple(_args, "O&",
163 PyMac_GetOSType, &theType))
164 return NULL;
165 AppendResMenu(_self->ob_itself,
166 theType);
167 Py_INCREF(Py_None);
168 _res = Py_None;
169 return _res;
172 static PyObject *MenuObj_MacInsertMenuItem(_self, _args)
173 MenuObject *_self;
174 PyObject *_args;
176 PyObject *_res = NULL;
177 Str255 itemString;
178 short afterItem;
179 if (!PyArg_ParseTuple(_args, "O&h",
180 PyMac_GetStr255, itemString,
181 &afterItem))
182 return NULL;
183 MacInsertMenuItem(_self->ob_itself,
184 itemString,
185 afterItem);
186 Py_INCREF(Py_None);
187 _res = Py_None;
188 return _res;
191 static PyObject *MenuObj_DeleteMenuItem(_self, _args)
192 MenuObject *_self;
193 PyObject *_args;
195 PyObject *_res = NULL;
196 short item;
197 if (!PyArg_ParseTuple(_args, "h",
198 &item))
199 return NULL;
200 DeleteMenuItem(_self->ob_itself,
201 item);
202 Py_INCREF(Py_None);
203 _res = Py_None;
204 return _res;
207 static PyObject *MenuObj_SetMenuItemText(_self, _args)
208 MenuObject *_self;
209 PyObject *_args;
211 PyObject *_res = NULL;
212 short item;
213 Str255 itemString;
214 if (!PyArg_ParseTuple(_args, "hO&",
215 &item,
216 PyMac_GetStr255, itemString))
217 return NULL;
218 SetMenuItemText(_self->ob_itself,
219 item,
220 itemString);
221 Py_INCREF(Py_None);
222 _res = Py_None;
223 return _res;
226 static PyObject *MenuObj_GetMenuItemText(_self, _args)
227 MenuObject *_self;
228 PyObject *_args;
230 PyObject *_res = NULL;
231 short item;
232 Str255 itemString;
233 if (!PyArg_ParseTuple(_args, "h",
234 &item))
235 return NULL;
236 GetMenuItemText(_self->ob_itself,
237 item,
238 itemString);
239 _res = Py_BuildValue("O&",
240 PyMac_BuildStr255, itemString);
241 return _res;
244 static PyObject *MenuObj_SetItemMark(_self, _args)
245 MenuObject *_self;
246 PyObject *_args;
248 PyObject *_res = NULL;
249 short item;
250 CharParameter markChar;
251 if (!PyArg_ParseTuple(_args, "hh",
252 &item,
253 &markChar))
254 return NULL;
255 SetItemMark(_self->ob_itself,
256 item,
257 markChar);
258 Py_INCREF(Py_None);
259 _res = Py_None;
260 return _res;
263 static PyObject *MenuObj_GetItemMark(_self, _args)
264 MenuObject *_self;
265 PyObject *_args;
267 PyObject *_res = NULL;
268 short item;
269 CharParameter markChar;
270 if (!PyArg_ParseTuple(_args, "h",
271 &item))
272 return NULL;
273 GetItemMark(_self->ob_itself,
274 item,
275 &markChar);
276 _res = Py_BuildValue("h",
277 markChar);
278 return _res;
281 static PyObject *MenuObj_SetItemCmd(_self, _args)
282 MenuObject *_self;
283 PyObject *_args;
285 PyObject *_res = NULL;
286 short item;
287 CharParameter cmdChar;
288 if (!PyArg_ParseTuple(_args, "hh",
289 &item,
290 &cmdChar))
291 return NULL;
292 SetItemCmd(_self->ob_itself,
293 item,
294 cmdChar);
295 Py_INCREF(Py_None);
296 _res = Py_None;
297 return _res;
300 static PyObject *MenuObj_GetItemCmd(_self, _args)
301 MenuObject *_self;
302 PyObject *_args;
304 PyObject *_res = NULL;
305 short item;
306 CharParameter cmdChar;
307 if (!PyArg_ParseTuple(_args, "h",
308 &item))
309 return NULL;
310 GetItemCmd(_self->ob_itself,
311 item,
312 &cmdChar);
313 _res = Py_BuildValue("h",
314 cmdChar);
315 return _res;
318 static PyObject *MenuObj_SetItemIcon(_self, _args)
319 MenuObject *_self;
320 PyObject *_args;
322 PyObject *_res = NULL;
323 short item;
324 short iconIndex;
325 if (!PyArg_ParseTuple(_args, "hh",
326 &item,
327 &iconIndex))
328 return NULL;
329 SetItemIcon(_self->ob_itself,
330 item,
331 iconIndex);
332 Py_INCREF(Py_None);
333 _res = Py_None;
334 return _res;
337 static PyObject *MenuObj_GetItemIcon(_self, _args)
338 MenuObject *_self;
339 PyObject *_args;
341 PyObject *_res = NULL;
342 short item;
343 short iconIndex;
344 if (!PyArg_ParseTuple(_args, "h",
345 &item))
346 return NULL;
347 GetItemIcon(_self->ob_itself,
348 item,
349 &iconIndex);
350 _res = Py_BuildValue("h",
351 iconIndex);
352 return _res;
355 static PyObject *MenuObj_SetItemStyle(_self, _args)
356 MenuObject *_self;
357 PyObject *_args;
359 PyObject *_res = NULL;
360 short item;
361 StyleParameter chStyle;
362 if (!PyArg_ParseTuple(_args, "hh",
363 &item,
364 &chStyle))
365 return NULL;
366 SetItemStyle(_self->ob_itself,
367 item,
368 chStyle);
369 Py_INCREF(Py_None);
370 _res = Py_None;
371 return _res;
374 static PyObject *MenuObj_GetItemStyle(_self, _args)
375 MenuObject *_self;
376 PyObject *_args;
378 PyObject *_res = NULL;
379 short item;
380 Style chStyle;
381 if (!PyArg_ParseTuple(_args, "h",
382 &item))
383 return NULL;
384 GetItemStyle(_self->ob_itself,
385 item,
386 &chStyle);
387 _res = Py_BuildValue("b",
388 chStyle);
389 return _res;
392 static PyObject *MenuObj_CalcMenuSize(_self, _args)
393 MenuObject *_self;
394 PyObject *_args;
396 PyObject *_res = NULL;
397 if (!PyArg_ParseTuple(_args, ""))
398 return NULL;
399 CalcMenuSize(_self->ob_itself);
400 Py_INCREF(Py_None);
401 _res = Py_None;
402 return _res;
405 static PyObject *MenuObj_DisableItem(_self, _args)
406 MenuObject *_self;
407 PyObject *_args;
409 PyObject *_res = NULL;
410 short item;
411 if (!PyArg_ParseTuple(_args, "h",
412 &item))
413 return NULL;
414 DisableItem(_self->ob_itself,
415 item);
416 Py_INCREF(Py_None);
417 _res = Py_None;
418 return _res;
421 static PyObject *MenuObj_EnableItem(_self, _args)
422 MenuObject *_self;
423 PyObject *_args;
425 PyObject *_res = NULL;
426 short item;
427 if (!PyArg_ParseTuple(_args, "h",
428 &item))
429 return NULL;
430 EnableItem(_self->ob_itself,
431 item);
432 Py_INCREF(Py_None);
433 _res = Py_None;
434 return _res;
437 static PyObject *MenuObj_PopUpMenuSelect(_self, _args)
438 MenuObject *_self;
439 PyObject *_args;
441 PyObject *_res = NULL;
442 long _rv;
443 short top;
444 short left;
445 short popUpItem;
446 if (!PyArg_ParseTuple(_args, "hhh",
447 &top,
448 &left,
449 &popUpItem))
450 return NULL;
451 _rv = PopUpMenuSelect(_self->ob_itself,
452 top,
453 left,
454 popUpItem);
455 _res = Py_BuildValue("l",
456 _rv);
457 return _res;
460 static PyObject *MenuObj_CheckItem(_self, _args)
461 MenuObject *_self;
462 PyObject *_args;
464 PyObject *_res = NULL;
465 short item;
466 Boolean checked;
467 if (!PyArg_ParseTuple(_args, "hb",
468 &item,
469 &checked))
470 return NULL;
471 CheckItem(_self->ob_itself,
472 item,
473 checked);
474 Py_INCREF(Py_None);
475 _res = Py_None;
476 return _res;
479 static PyObject *MenuObj_CountMItems(_self, _args)
480 MenuObject *_self;
481 PyObject *_args;
483 PyObject *_res = NULL;
484 short _rv;
485 if (!PyArg_ParseTuple(_args, ""))
486 return NULL;
487 _rv = CountMItems(_self->ob_itself);
488 _res = Py_BuildValue("h",
489 _rv);
490 return _res;
493 static PyObject *MenuObj_InsertFontResMenu(_self, _args)
494 MenuObject *_self;
495 PyObject *_args;
497 PyObject *_res = NULL;
498 short afterItem;
499 short scriptFilter;
500 if (!PyArg_ParseTuple(_args, "hh",
501 &afterItem,
502 &scriptFilter))
503 return NULL;
504 InsertFontResMenu(_self->ob_itself,
505 afterItem,
506 scriptFilter);
507 Py_INCREF(Py_None);
508 _res = Py_None;
509 return _res;
512 static PyObject *MenuObj_InsertIntlResMenu(_self, _args)
513 MenuObject *_self;
514 PyObject *_args;
516 PyObject *_res = NULL;
517 ResType theType;
518 short afterItem;
519 short scriptFilter;
520 if (!PyArg_ParseTuple(_args, "O&hh",
521 PyMac_GetOSType, &theType,
522 &afterItem,
523 &scriptFilter))
524 return NULL;
525 InsertIntlResMenu(_self->ob_itself,
526 theType,
527 afterItem,
528 scriptFilter);
529 Py_INCREF(Py_None);
530 _res = Py_None;
531 return _res;
534 static PyObject *MenuObj_SetMenuItemCommandID(_self, _args)
535 MenuObject *_self;
536 PyObject *_args;
538 PyObject *_res = NULL;
539 OSErr _err;
540 SInt16 inItem;
541 UInt32 inCommandID;
542 if (!PyArg_ParseTuple(_args, "hl",
543 &inItem,
544 &inCommandID))
545 return NULL;
546 _err = SetMenuItemCommandID(_self->ob_itself,
547 inItem,
548 inCommandID);
549 if (_err != noErr) return PyMac_Error(_err);
550 Py_INCREF(Py_None);
551 _res = Py_None;
552 return _res;
555 static PyObject *MenuObj_GetMenuItemCommandID(_self, _args)
556 MenuObject *_self;
557 PyObject *_args;
559 PyObject *_res = NULL;
560 OSErr _err;
561 SInt16 inItem;
562 UInt32 outCommandID;
563 if (!PyArg_ParseTuple(_args, "h",
564 &inItem))
565 return NULL;
566 _err = GetMenuItemCommandID(_self->ob_itself,
567 inItem,
568 &outCommandID);
569 if (_err != noErr) return PyMac_Error(_err);
570 _res = Py_BuildValue("l",
571 outCommandID);
572 return _res;
575 static PyObject *MenuObj_SetMenuItemModifiers(_self, _args)
576 MenuObject *_self;
577 PyObject *_args;
579 PyObject *_res = NULL;
580 OSErr _err;
581 SInt16 inItem;
582 UInt8 inModifiers;
583 if (!PyArg_ParseTuple(_args, "hb",
584 &inItem,
585 &inModifiers))
586 return NULL;
587 _err = SetMenuItemModifiers(_self->ob_itself,
588 inItem,
589 inModifiers);
590 if (_err != noErr) return PyMac_Error(_err);
591 Py_INCREF(Py_None);
592 _res = Py_None;
593 return _res;
596 static PyObject *MenuObj_GetMenuItemModifiers(_self, _args)
597 MenuObject *_self;
598 PyObject *_args;
600 PyObject *_res = NULL;
601 OSErr _err;
602 SInt16 inItem;
603 UInt8 outModifiers;
604 if (!PyArg_ParseTuple(_args, "h",
605 &inItem))
606 return NULL;
607 _err = GetMenuItemModifiers(_self->ob_itself,
608 inItem,
609 &outModifiers);
610 if (_err != noErr) return PyMac_Error(_err);
611 _res = Py_BuildValue("b",
612 outModifiers);
613 return _res;
616 static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args)
617 MenuObject *_self;
618 PyObject *_args;
620 PyObject *_res = NULL;
621 OSErr _err;
622 SInt16 inItem;
623 UInt8 inIconType;
624 Handle inIconHandle;
625 if (!PyArg_ParseTuple(_args, "hbO&",
626 &inItem,
627 &inIconType,
628 ResObj_Convert, &inIconHandle))
629 return NULL;
630 _err = SetMenuItemIconHandle(_self->ob_itself,
631 inItem,
632 inIconType,
633 inIconHandle);
634 if (_err != noErr) return PyMac_Error(_err);
635 Py_INCREF(Py_None);
636 _res = Py_None;
637 return _res;
640 static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args)
641 MenuObject *_self;
642 PyObject *_args;
644 PyObject *_res = NULL;
645 OSErr _err;
646 SInt16 inItem;
647 UInt8 outIconType;
648 Handle outIconHandle;
649 if (!PyArg_ParseTuple(_args, "h",
650 &inItem))
651 return NULL;
652 _err = GetMenuItemIconHandle(_self->ob_itself,
653 inItem,
654 &outIconType,
655 &outIconHandle);
656 if (_err != noErr) return PyMac_Error(_err);
657 _res = Py_BuildValue("bO&",
658 outIconType,
659 ResObj_New, outIconHandle);
660 return _res;
663 static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args)
664 MenuObject *_self;
665 PyObject *_args;
667 PyObject *_res = NULL;
668 OSErr _err;
669 SInt16 inItem;
670 TextEncoding inScriptID;
671 if (!PyArg_ParseTuple(_args, "hl",
672 &inItem,
673 &inScriptID))
674 return NULL;
675 _err = SetMenuItemTextEncoding(_self->ob_itself,
676 inItem,
677 inScriptID);
678 if (_err != noErr) return PyMac_Error(_err);
679 Py_INCREF(Py_None);
680 _res = Py_None;
681 return _res;
684 static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args)
685 MenuObject *_self;
686 PyObject *_args;
688 PyObject *_res = NULL;
689 OSErr _err;
690 SInt16 inItem;
691 TextEncoding outScriptID;
692 if (!PyArg_ParseTuple(_args, "h",
693 &inItem))
694 return NULL;
695 _err = GetMenuItemTextEncoding(_self->ob_itself,
696 inItem,
697 &outScriptID);
698 if (_err != noErr) return PyMac_Error(_err);
699 _res = Py_BuildValue("l",
700 outScriptID);
701 return _res;
704 static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args)
705 MenuObject *_self;
706 PyObject *_args;
708 PyObject *_res = NULL;
709 OSErr _err;
710 SInt16 inItem;
711 SInt16 inHierID;
712 if (!PyArg_ParseTuple(_args, "hh",
713 &inItem,
714 &inHierID))
715 return NULL;
716 _err = SetMenuItemHierarchicalID(_self->ob_itself,
717 inItem,
718 inHierID);
719 if (_err != noErr) return PyMac_Error(_err);
720 Py_INCREF(Py_None);
721 _res = Py_None;
722 return _res;
725 static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args)
726 MenuObject *_self;
727 PyObject *_args;
729 PyObject *_res = NULL;
730 OSErr _err;
731 SInt16 inItem;
732 SInt16 outHierID;
733 if (!PyArg_ParseTuple(_args, "h",
734 &inItem))
735 return NULL;
736 _err = GetMenuItemHierarchicalID(_self->ob_itself,
737 inItem,
738 &outHierID);
739 if (_err != noErr) return PyMac_Error(_err);
740 _res = Py_BuildValue("h",
741 outHierID);
742 return _res;
745 static PyObject *MenuObj_SetMenuItemFontID(_self, _args)
746 MenuObject *_self;
747 PyObject *_args;
749 PyObject *_res = NULL;
750 OSErr _err;
751 SInt16 inItem;
752 SInt16 inFontID;
753 if (!PyArg_ParseTuple(_args, "hh",
754 &inItem,
755 &inFontID))
756 return NULL;
757 _err = SetMenuItemFontID(_self->ob_itself,
758 inItem,
759 inFontID);
760 if (_err != noErr) return PyMac_Error(_err);
761 Py_INCREF(Py_None);
762 _res = Py_None;
763 return _res;
766 static PyObject *MenuObj_GetMenuItemFontID(_self, _args)
767 MenuObject *_self;
768 PyObject *_args;
770 PyObject *_res = NULL;
771 OSErr _err;
772 SInt16 inItem;
773 SInt16 outFontID;
774 if (!PyArg_ParseTuple(_args, "h",
775 &inItem))
776 return NULL;
777 _err = GetMenuItemFontID(_self->ob_itself,
778 inItem,
779 &outFontID);
780 if (_err != noErr) return PyMac_Error(_err);
781 _res = Py_BuildValue("h",
782 outFontID);
783 return _res;
786 static PyObject *MenuObj_SetMenuItemRefCon(_self, _args)
787 MenuObject *_self;
788 PyObject *_args;
790 PyObject *_res = NULL;
791 OSErr _err;
792 SInt16 inItem;
793 UInt32 inRefCon;
794 if (!PyArg_ParseTuple(_args, "hl",
795 &inItem,
796 &inRefCon))
797 return NULL;
798 _err = SetMenuItemRefCon(_self->ob_itself,
799 inItem,
800 inRefCon);
801 if (_err != noErr) return PyMac_Error(_err);
802 Py_INCREF(Py_None);
803 _res = Py_None;
804 return _res;
807 static PyObject *MenuObj_GetMenuItemRefCon(_self, _args)
808 MenuObject *_self;
809 PyObject *_args;
811 PyObject *_res = NULL;
812 OSErr _err;
813 SInt16 inItem;
814 UInt32 outRefCon;
815 if (!PyArg_ParseTuple(_args, "h",
816 &inItem))
817 return NULL;
818 _err = GetMenuItemRefCon(_self->ob_itself,
819 inItem,
820 &outRefCon);
821 if (_err != noErr) return PyMac_Error(_err);
822 _res = Py_BuildValue("l",
823 outRefCon);
824 return _res;
827 static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args)
828 MenuObject *_self;
829 PyObject *_args;
831 PyObject *_res = NULL;
832 OSErr _err;
833 SInt16 inItem;
834 UInt32 inRefCon2;
835 if (!PyArg_ParseTuple(_args, "hl",
836 &inItem,
837 &inRefCon2))
838 return NULL;
839 _err = SetMenuItemRefCon2(_self->ob_itself,
840 inItem,
841 inRefCon2);
842 if (_err != noErr) return PyMac_Error(_err);
843 Py_INCREF(Py_None);
844 _res = Py_None;
845 return _res;
848 static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args)
849 MenuObject *_self;
850 PyObject *_args;
852 PyObject *_res = NULL;
853 OSErr _err;
854 SInt16 inItem;
855 UInt32 outRefCon2;
856 if (!PyArg_ParseTuple(_args, "h",
857 &inItem))
858 return NULL;
859 _err = GetMenuItemRefCon2(_self->ob_itself,
860 inItem,
861 &outRefCon2);
862 if (_err != noErr) return PyMac_Error(_err);
863 _res = Py_BuildValue("l",
864 outRefCon2);
865 return _res;
868 static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args)
869 MenuObject *_self;
870 PyObject *_args;
872 PyObject *_res = NULL;
873 OSErr _err;
874 SInt16 inItem;
875 SInt16 inGlyph;
876 if (!PyArg_ParseTuple(_args, "hh",
877 &inItem,
878 &inGlyph))
879 return NULL;
880 _err = SetMenuItemKeyGlyph(_self->ob_itself,
881 inItem,
882 inGlyph);
883 if (_err != noErr) return PyMac_Error(_err);
884 Py_INCREF(Py_None);
885 _res = Py_None;
886 return _res;
889 static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args)
890 MenuObject *_self;
891 PyObject *_args;
893 PyObject *_res = NULL;
894 OSErr _err;
895 SInt16 inItem;
896 SInt16 outGlyph;
897 if (!PyArg_ParseTuple(_args, "h",
898 &inItem))
899 return NULL;
900 _err = GetMenuItemKeyGlyph(_self->ob_itself,
901 inItem,
902 &outGlyph);
903 if (_err != noErr) return PyMac_Error(_err);
904 _res = Py_BuildValue("h",
905 outGlyph);
906 return _res;
909 static PyObject *MenuObj_as_Resource(_self, _args)
910 MenuObject *_self;
911 PyObject *_args;
913 PyObject *_res = NULL;
915 return ResObj_New((Handle)_self->ob_itself);
919 static PyObject *MenuObj_AppendMenu(_self, _args)
920 MenuObject *_self;
921 PyObject *_args;
923 PyObject *_res = NULL;
924 Str255 data;
925 if (!PyArg_ParseTuple(_args, "O&",
926 PyMac_GetStr255, data))
927 return NULL;
928 AppendMenu(_self->ob_itself,
929 data);
930 Py_INCREF(Py_None);
931 _res = Py_None;
932 return _res;
935 static PyObject *MenuObj_InsertMenu(_self, _args)
936 MenuObject *_self;
937 PyObject *_args;
939 PyObject *_res = NULL;
940 short beforeID;
941 if (!PyArg_ParseTuple(_args, "h",
942 &beforeID))
943 return NULL;
944 InsertMenu(_self->ob_itself,
945 beforeID);
946 Py_INCREF(Py_None);
947 _res = Py_None;
948 return _res;
951 static PyObject *MenuObj_InsertMenuItem(_self, _args)
952 MenuObject *_self;
953 PyObject *_args;
955 PyObject *_res = NULL;
956 Str255 itemString;
957 short afterItem;
958 if (!PyArg_ParseTuple(_args, "O&h",
959 PyMac_GetStr255, itemString,
960 &afterItem))
961 return NULL;
962 InsertMenuItem(_self->ob_itself,
963 itemString,
964 afterItem);
965 Py_INCREF(Py_None);
966 _res = Py_None;
967 return _res;
970 static PyMethodDef MenuObj_methods[] = {
971 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
972 "() -> None"},
973 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
974 "(Str255 data) -> None"},
975 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
976 "(ResType theType, short afterItem) -> None"},
977 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
978 "(short beforeID) -> None"},
979 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
980 "(ResType theType) -> None"},
981 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
982 "(Str255 itemString, short afterItem) -> None"},
983 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
984 "(short item) -> None"},
985 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
986 "(short item, Str255 itemString) -> None"},
987 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
988 "(short item) -> (Str255 itemString)"},
989 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
990 "(short item, CharParameter markChar) -> None"},
991 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
992 "(short item) -> (CharParameter markChar)"},
993 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
994 "(short item, CharParameter cmdChar) -> None"},
995 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
996 "(short item) -> (CharParameter cmdChar)"},
997 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
998 "(short item, short iconIndex) -> None"},
999 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1000 "(short item) -> (short iconIndex)"},
1001 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
1002 "(short item, StyleParameter chStyle) -> None"},
1003 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
1004 "(short item) -> (Style chStyle)"},
1005 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1006 "() -> None"},
1007 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1008 "(short item) -> None"},
1009 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1010 "(short item) -> None"},
1011 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1012 "(short top, short left, short popUpItem) -> (long _rv)"},
1013 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1014 "(short item, Boolean checked) -> None"},
1015 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1016 "() -> (short _rv)"},
1017 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1018 "(short afterItem, short scriptFilter) -> None"},
1019 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1020 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1021 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
1022 "(SInt16 inItem, UInt32 inCommandID) -> None"},
1023 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
1024 "(SInt16 inItem) -> (UInt32 outCommandID)"},
1025 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1026 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1027 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1028 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1029 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1030 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1031 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1032 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1033 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1034 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1035 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1036 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1037 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
1038 "(SInt16 inItem, SInt16 inHierID) -> None"},
1039 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
1040 "(SInt16 inItem) -> (SInt16 outHierID)"},
1041 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1042 "(SInt16 inItem, SInt16 inFontID) -> None"},
1043 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1044 "(SInt16 inItem) -> (SInt16 outFontID)"},
1045 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1046 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1047 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1048 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1049 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1050 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1051 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1052 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1053 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1054 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1055 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1056 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1057 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
1058 "Return this Menu as a Resource"},
1059 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
1060 "(Str255 data) -> None"},
1061 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
1062 "(short beforeID) -> None"},
1063 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
1064 "(Str255 itemString, short afterItem) -> None"},
1065 {NULL, NULL, 0}
1068 PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
1070 static PyObject *MenuObj_getattr(self, name)
1071 MenuObject *self;
1072 char *name;
1074 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
1077 #define MenuObj_setattr NULL
1079 PyTypeObject Menu_Type = {
1080 PyObject_HEAD_INIT(&PyType_Type)
1081 0, /*ob_size*/
1082 "Menu", /*tp_name*/
1083 sizeof(MenuObject), /*tp_basicsize*/
1084 0, /*tp_itemsize*/
1085 /* methods */
1086 (destructor) MenuObj_dealloc, /*tp_dealloc*/
1087 0, /*tp_print*/
1088 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
1089 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
1092 /* ---------------------- End object type Menu ---------------------- */
1095 static PyObject *Menu_GetMBarHeight(_self, _args)
1096 PyObject *_self;
1097 PyObject *_args;
1099 PyObject *_res = NULL;
1100 short _rv;
1101 if (!PyArg_ParseTuple(_args, ""))
1102 return NULL;
1103 _rv = GetMBarHeight();
1104 _res = Py_BuildValue("h",
1105 _rv);
1106 return _res;
1109 static PyObject *Menu_InitMenus(_self, _args)
1110 PyObject *_self;
1111 PyObject *_args;
1113 PyObject *_res = NULL;
1114 if (!PyArg_ParseTuple(_args, ""))
1115 return NULL;
1116 InitMenus();
1117 Py_INCREF(Py_None);
1118 _res = Py_None;
1119 return _res;
1122 static PyObject *Menu_NewMenu(_self, _args)
1123 PyObject *_self;
1124 PyObject *_args;
1126 PyObject *_res = NULL;
1127 MenuHandle _rv;
1128 short menuID;
1129 Str255 menuTitle;
1130 if (!PyArg_ParseTuple(_args, "hO&",
1131 &menuID,
1132 PyMac_GetStr255, menuTitle))
1133 return NULL;
1134 _rv = NewMenu(menuID,
1135 menuTitle);
1136 _res = Py_BuildValue("O&",
1137 MenuObj_New, _rv);
1138 return _res;
1141 static PyObject *Menu_MacGetMenu(_self, _args)
1142 PyObject *_self;
1143 PyObject *_args;
1145 PyObject *_res = NULL;
1146 MenuHandle _rv;
1147 short resourceID;
1148 if (!PyArg_ParseTuple(_args, "h",
1149 &resourceID))
1150 return NULL;
1151 _rv = MacGetMenu(resourceID);
1152 _res = Py_BuildValue("O&",
1153 MenuObj_New, _rv);
1154 return _res;
1157 static PyObject *Menu_MacDeleteMenu(_self, _args)
1158 PyObject *_self;
1159 PyObject *_args;
1161 PyObject *_res = NULL;
1162 short menuID;
1163 if (!PyArg_ParseTuple(_args, "h",
1164 &menuID))
1165 return NULL;
1166 MacDeleteMenu(menuID);
1167 Py_INCREF(Py_None);
1168 _res = Py_None;
1169 return _res;
1172 static PyObject *Menu_MenuKey(_self, _args)
1173 PyObject *_self;
1174 PyObject *_args;
1176 PyObject *_res = NULL;
1177 long _rv;
1178 CharParameter ch;
1179 if (!PyArg_ParseTuple(_args, "h",
1180 &ch))
1181 return NULL;
1182 _rv = MenuKey(ch);
1183 _res = Py_BuildValue("l",
1184 _rv);
1185 return _res;
1188 static PyObject *Menu_HiliteMenu(_self, _args)
1189 PyObject *_self;
1190 PyObject *_args;
1192 PyObject *_res = NULL;
1193 short menuID;
1194 if (!PyArg_ParseTuple(_args, "h",
1195 &menuID))
1196 return NULL;
1197 HiliteMenu(menuID);
1198 Py_INCREF(Py_None);
1199 _res = Py_None;
1200 return _res;
1203 static PyObject *Menu_GetMenuHandle(_self, _args)
1204 PyObject *_self;
1205 PyObject *_args;
1207 PyObject *_res = NULL;
1208 MenuHandle _rv;
1209 short menuID;
1210 if (!PyArg_ParseTuple(_args, "h",
1211 &menuID))
1212 return NULL;
1213 _rv = GetMenuHandle(menuID);
1214 _res = Py_BuildValue("O&",
1215 MenuObj_New, _rv);
1216 return _res;
1219 static PyObject *Menu_FlashMenuBar(_self, _args)
1220 PyObject *_self;
1221 PyObject *_args;
1223 PyObject *_res = NULL;
1224 short menuID;
1225 if (!PyArg_ParseTuple(_args, "h",
1226 &menuID))
1227 return NULL;
1228 FlashMenuBar(menuID);
1229 Py_INCREF(Py_None);
1230 _res = Py_None;
1231 return _res;
1234 static PyObject *Menu_MenuChoice(_self, _args)
1235 PyObject *_self;
1236 PyObject *_args;
1238 PyObject *_res = NULL;
1239 long _rv;
1240 if (!PyArg_ParseTuple(_args, ""))
1241 return NULL;
1242 _rv = MenuChoice();
1243 _res = Py_BuildValue("l",
1244 _rv);
1245 return _res;
1248 static PyObject *Menu_DeleteMCEntries(_self, _args)
1249 PyObject *_self;
1250 PyObject *_args;
1252 PyObject *_res = NULL;
1253 short menuID;
1254 short menuItem;
1255 if (!PyArg_ParseTuple(_args, "hh",
1256 &menuID,
1257 &menuItem))
1258 return NULL;
1259 DeleteMCEntries(menuID,
1260 menuItem);
1261 Py_INCREF(Py_None);
1262 _res = Py_None;
1263 return _res;
1266 static PyObject *Menu_MacDrawMenuBar(_self, _args)
1267 PyObject *_self;
1268 PyObject *_args;
1270 PyObject *_res = NULL;
1271 if (!PyArg_ParseTuple(_args, ""))
1272 return NULL;
1273 MacDrawMenuBar();
1274 Py_INCREF(Py_None);
1275 _res = Py_None;
1276 return _res;
1279 static PyObject *Menu_InvalMenuBar(_self, _args)
1280 PyObject *_self;
1281 PyObject *_args;
1283 PyObject *_res = NULL;
1284 if (!PyArg_ParseTuple(_args, ""))
1285 return NULL;
1286 InvalMenuBar();
1287 Py_INCREF(Py_None);
1288 _res = Py_None;
1289 return _res;
1292 static PyObject *Menu_InitProcMenu(_self, _args)
1293 PyObject *_self;
1294 PyObject *_args;
1296 PyObject *_res = NULL;
1297 short resID;
1298 if (!PyArg_ParseTuple(_args, "h",
1299 &resID))
1300 return NULL;
1301 InitProcMenu(resID);
1302 Py_INCREF(Py_None);
1303 _res = Py_None;
1304 return _res;
1307 static PyObject *Menu_GetMenuBar(_self, _args)
1308 PyObject *_self;
1309 PyObject *_args;
1311 PyObject *_res = NULL;
1312 Handle _rv;
1313 if (!PyArg_ParseTuple(_args, ""))
1314 return NULL;
1315 _rv = GetMenuBar();
1316 _res = Py_BuildValue("O&",
1317 ResObj_New, _rv);
1318 return _res;
1321 static PyObject *Menu_SetMenuBar(_self, _args)
1322 PyObject *_self;
1323 PyObject *_args;
1325 PyObject *_res = NULL;
1326 Handle menuList;
1327 if (!PyArg_ParseTuple(_args, "O&",
1328 ResObj_Convert, &menuList))
1329 return NULL;
1330 SetMenuBar(menuList);
1331 Py_INCREF(Py_None);
1332 _res = Py_None;
1333 return _res;
1336 static PyObject *Menu_SystemEdit(_self, _args)
1337 PyObject *_self;
1338 PyObject *_args;
1340 PyObject *_res = NULL;
1341 Boolean _rv;
1342 short editCmd;
1343 if (!PyArg_ParseTuple(_args, "h",
1344 &editCmd))
1345 return NULL;
1346 _rv = SystemEdit(editCmd);
1347 _res = Py_BuildValue("b",
1348 _rv);
1349 return _res;
1352 static PyObject *Menu_SystemMenu(_self, _args)
1353 PyObject *_self;
1354 PyObject *_args;
1356 PyObject *_res = NULL;
1357 long menuResult;
1358 if (!PyArg_ParseTuple(_args, "l",
1359 &menuResult))
1360 return NULL;
1361 SystemMenu(menuResult);
1362 Py_INCREF(Py_None);
1363 _res = Py_None;
1364 return _res;
1367 static PyObject *Menu_GetNewMBar(_self, _args)
1368 PyObject *_self;
1369 PyObject *_args;
1371 PyObject *_res = NULL;
1372 Handle _rv;
1373 short menuBarID;
1374 if (!PyArg_ParseTuple(_args, "h",
1375 &menuBarID))
1376 return NULL;
1377 _rv = GetNewMBar(menuBarID);
1378 _res = Py_BuildValue("O&",
1379 ResObj_New, _rv);
1380 return _res;
1383 static PyObject *Menu_ClearMenuBar(_self, _args)
1384 PyObject *_self;
1385 PyObject *_args;
1387 PyObject *_res = NULL;
1388 if (!PyArg_ParseTuple(_args, ""))
1389 return NULL;
1390 ClearMenuBar();
1391 Py_INCREF(Py_None);
1392 _res = Py_None;
1393 return _res;
1396 static PyObject *Menu_SetMenuFlash(_self, _args)
1397 PyObject *_self;
1398 PyObject *_args;
1400 PyObject *_res = NULL;
1401 short count;
1402 if (!PyArg_ParseTuple(_args, "h",
1403 &count))
1404 return NULL;
1405 SetMenuFlash(count);
1406 Py_INCREF(Py_None);
1407 _res = Py_None;
1408 return _res;
1411 static PyObject *Menu_MenuSelect(_self, _args)
1412 PyObject *_self;
1413 PyObject *_args;
1415 PyObject *_res = NULL;
1416 long _rv;
1417 Point startPt;
1418 if (!PyArg_ParseTuple(_args, "O&",
1419 PyMac_GetPoint, &startPt))
1420 return NULL;
1421 _rv = MenuSelect(startPt);
1422 _res = Py_BuildValue("l",
1423 _rv);
1424 return _res;
1427 static PyObject *Menu_MenuEvent(_self, _args)
1428 PyObject *_self;
1429 PyObject *_args;
1431 PyObject *_res = NULL;
1432 UInt32 _rv;
1433 EventRecord inEvent;
1434 if (!PyArg_ParseTuple(_args, "O&",
1435 PyMac_GetEventRecord, &inEvent))
1436 return NULL;
1437 _rv = MenuEvent(&inEvent);
1438 _res = Py_BuildValue("l",
1439 _rv);
1440 return _res;
1443 static PyObject *Menu_OpenDeskAcc(_self, _args)
1444 PyObject *_self;
1445 PyObject *_args;
1447 PyObject *_res = NULL;
1448 Str255 name;
1449 if (!PyArg_ParseTuple(_args, "O&",
1450 PyMac_GetStr255, name))
1451 return NULL;
1452 OpenDeskAcc(name);
1453 Py_INCREF(Py_None);
1454 _res = Py_None;
1455 return _res;
1458 static PyObject *Menu_GetMenu(_self, _args)
1459 PyObject *_self;
1460 PyObject *_args;
1462 PyObject *_res = NULL;
1463 MenuHandle _rv;
1464 short resourceID;
1465 if (!PyArg_ParseTuple(_args, "h",
1466 &resourceID))
1467 return NULL;
1468 _rv = GetMenu(resourceID);
1469 _res = Py_BuildValue("O&",
1470 MenuObj_New, _rv);
1471 return _res;
1474 static PyObject *Menu_DeleteMenu(_self, _args)
1475 PyObject *_self;
1476 PyObject *_args;
1478 PyObject *_res = NULL;
1479 short menuID;
1480 if (!PyArg_ParseTuple(_args, "h",
1481 &menuID))
1482 return NULL;
1483 DeleteMenu(menuID);
1484 Py_INCREF(Py_None);
1485 _res = Py_None;
1486 return _res;
1489 static PyObject *Menu_DrawMenuBar(_self, _args)
1490 PyObject *_self;
1491 PyObject *_args;
1493 PyObject *_res = NULL;
1494 if (!PyArg_ParseTuple(_args, ""))
1495 return NULL;
1496 DrawMenuBar();
1497 Py_INCREF(Py_None);
1498 _res = Py_None;
1499 return _res;
1502 static PyMethodDef Menu_methods[] = {
1503 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
1504 "() -> (short _rv)"},
1505 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
1506 "() -> None"},
1507 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
1508 "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
1509 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
1510 "(short resourceID) -> (MenuHandle _rv)"},
1511 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
1512 "(short menuID) -> None"},
1513 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
1514 "(CharParameter ch) -> (long _rv)"},
1515 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
1516 "(short menuID) -> None"},
1517 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
1518 "(short menuID) -> (MenuHandle _rv)"},
1519 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
1520 "(short menuID) -> None"},
1521 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
1522 "() -> (long _rv)"},
1523 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
1524 "(short menuID, short menuItem) -> None"},
1525 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
1526 "() -> None"},
1527 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
1528 "() -> None"},
1529 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
1530 "(short resID) -> None"},
1531 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
1532 "() -> (Handle _rv)"},
1533 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
1534 "(Handle menuList) -> None"},
1535 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
1536 "(short editCmd) -> (Boolean _rv)"},
1537 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
1538 "(long menuResult) -> None"},
1539 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
1540 "(short menuBarID) -> (Handle _rv)"},
1541 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
1542 "() -> None"},
1543 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
1544 "(short count) -> None"},
1545 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
1546 "(Point startPt) -> (long _rv)"},
1547 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
1548 "(EventRecord inEvent) -> (UInt32 _rv)"},
1549 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
1550 "(Str255 name) -> None"},
1551 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
1552 "(short resourceID) -> (MenuHandle _rv)"},
1553 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
1554 "(short menuID) -> None"},
1555 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
1556 "() -> None"},
1557 {NULL, NULL, 0}
1563 void initMenu()
1565 PyObject *m;
1566 PyObject *d;
1571 m = Py_InitModule("Menu", Menu_methods);
1572 d = PyModule_GetDict(m);
1573 Menu_Error = PyMac_GetOSErrException();
1574 if (Menu_Error == NULL ||
1575 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
1576 Py_FatalError("can't initialize Menu.Error");
1577 Menu_Type.ob_type = &PyType_Type;
1578 Py_INCREF(&Menu_Type);
1579 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
1580 Py_FatalError("can't initialize MenuType");
1583 /* ======================== End module Menu ========================= */