This is (hopefully) last checkin before releasing 2.1c2 -- get rid of
[python/dscho.git] / Mac / Modules / menu / Menumodule.c
blob782b2706ab6b4bc1a897536fd953c39f316d73c8
2 /* ========================== Module Menu =========================== */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
12 #include <Menus.h>
14 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
15 #define GetMenuID(menu) ((*(menu))->menuID)
16 #define GetMenuWidth(menu) ((*(menu))->menuWidth)
17 #define GetMenuHeight(menu) ((*(menu))->menuHeight)
19 #define SetMenuID(menu, id) ((*(menu))->menuID = (id))
20 #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
21 #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
22 #endif
24 #define as_Menu(h) ((MenuHandle)h)
25 #define as_Resource(h) ((Handle)h)
27 static PyObject *Menu_Error;
29 /* ------------------------ Object type Menu ------------------------ */
31 PyTypeObject Menu_Type;
33 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
35 typedef struct MenuObject {
36 PyObject_HEAD
37 MenuHandle ob_itself;
38 } MenuObject;
40 PyObject *MenuObj_New(itself)
41 MenuHandle itself;
43 MenuObject *it;
44 it = PyObject_NEW(MenuObject, &Menu_Type);
45 if (it == NULL) return NULL;
46 it->ob_itself = itself;
47 return (PyObject *)it;
49 MenuObj_Convert(v, p_itself)
50 PyObject *v;
51 MenuHandle *p_itself;
53 if (!MenuObj_Check(v))
55 PyErr_SetString(PyExc_TypeError, "Menu required");
56 return 0;
58 *p_itself = ((MenuObject *)v)->ob_itself;
59 return 1;
62 static void MenuObj_dealloc(self)
63 MenuObject *self;
65 /* Cleanup of self->ob_itself goes here */
66 PyMem_DEL(self);
69 static PyObject *MenuObj_DisposeMenu(_self, _args)
70 MenuObject *_self;
71 PyObject *_args;
73 PyObject *_res = NULL;
74 if (!PyArg_ParseTuple(_args, ""))
75 return NULL;
76 DisposeMenu(_self->ob_itself);
77 Py_INCREF(Py_None);
78 _res = Py_None;
79 return _res;
82 static PyObject *MenuObj_CalcMenuSize(_self, _args)
83 MenuObject *_self;
84 PyObject *_args;
86 PyObject *_res = NULL;
87 if (!PyArg_ParseTuple(_args, ""))
88 return NULL;
89 CalcMenuSize(_self->ob_itself);
90 Py_INCREF(Py_None);
91 _res = Py_None;
92 return _res;
95 static PyObject *MenuObj_CountMenuItems(_self, _args)
96 MenuObject *_self;
97 PyObject *_args;
99 PyObject *_res = NULL;
100 short _rv;
101 if (!PyArg_ParseTuple(_args, ""))
102 return NULL;
103 _rv = CountMenuItems(_self->ob_itself);
104 _res = Py_BuildValue("h",
105 _rv);
106 return _res;
109 #if !TARGET_API_MAC_CARBON
111 static PyObject *MenuObj_CountMItems(_self, _args)
112 MenuObject *_self;
113 PyObject *_args;
115 PyObject *_res = NULL;
116 short _rv;
117 if (!PyArg_ParseTuple(_args, ""))
118 return NULL;
119 _rv = CountMItems(_self->ob_itself);
120 _res = Py_BuildValue("h",
121 _rv);
122 return _res;
124 #endif
126 static PyObject *MenuObj_GetMenuFont(_self, _args)
127 MenuObject *_self;
128 PyObject *_args;
130 PyObject *_res = NULL;
131 OSStatus _err;
132 SInt16 outFontID;
133 UInt16 outFontSize;
134 if (!PyArg_ParseTuple(_args, ""))
135 return NULL;
136 _err = GetMenuFont(_self->ob_itself,
137 &outFontID,
138 &outFontSize);
139 if (_err != noErr) return PyMac_Error(_err);
140 _res = Py_BuildValue("hH",
141 outFontID,
142 outFontSize);
143 return _res;
146 static PyObject *MenuObj_SetMenuFont(_self, _args)
147 MenuObject *_self;
148 PyObject *_args;
150 PyObject *_res = NULL;
151 OSStatus _err;
152 SInt16 inFontID;
153 UInt16 inFontSize;
154 if (!PyArg_ParseTuple(_args, "hH",
155 &inFontID,
156 &inFontSize))
157 return NULL;
158 _err = SetMenuFont(_self->ob_itself,
159 inFontID,
160 inFontSize);
161 if (_err != noErr) return PyMac_Error(_err);
162 Py_INCREF(Py_None);
163 _res = Py_None;
164 return _res;
167 static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args)
168 MenuObject *_self;
169 PyObject *_args;
171 PyObject *_res = NULL;
172 Boolean _rv;
173 if (!PyArg_ParseTuple(_args, ""))
174 return NULL;
175 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
176 _res = Py_BuildValue("b",
177 _rv);
178 return _res;
181 static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args)
182 MenuObject *_self;
183 PyObject *_args;
185 PyObject *_res = NULL;
186 OSStatus _err;
187 Boolean excludesMark;
188 if (!PyArg_ParseTuple(_args, "b",
189 &excludesMark))
190 return NULL;
191 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
192 excludesMark);
193 if (_err != noErr) return PyMac_Error(_err);
194 Py_INCREF(Py_None);
195 _res = Py_None;
196 return _res;
199 static PyObject *MenuObj_MacAppendMenu(_self, _args)
200 MenuObject *_self;
201 PyObject *_args;
203 PyObject *_res = NULL;
204 Str255 data;
205 if (!PyArg_ParseTuple(_args, "O&",
206 PyMac_GetStr255, data))
207 return NULL;
208 MacAppendMenu(_self->ob_itself,
209 data);
210 Py_INCREF(Py_None);
211 _res = Py_None;
212 return _res;
215 static PyObject *MenuObj_InsertResMenu(_self, _args)
216 MenuObject *_self;
217 PyObject *_args;
219 PyObject *_res = NULL;
220 ResType theType;
221 short afterItem;
222 if (!PyArg_ParseTuple(_args, "O&h",
223 PyMac_GetOSType, &theType,
224 &afterItem))
225 return NULL;
226 InsertResMenu(_self->ob_itself,
227 theType,
228 afterItem);
229 Py_INCREF(Py_None);
230 _res = Py_None;
231 return _res;
234 static PyObject *MenuObj_AppendResMenu(_self, _args)
235 MenuObject *_self;
236 PyObject *_args;
238 PyObject *_res = NULL;
239 ResType theType;
240 if (!PyArg_ParseTuple(_args, "O&",
241 PyMac_GetOSType, &theType))
242 return NULL;
243 AppendResMenu(_self->ob_itself,
244 theType);
245 Py_INCREF(Py_None);
246 _res = Py_None;
247 return _res;
250 static PyObject *MenuObj_MacInsertMenuItem(_self, _args)
251 MenuObject *_self;
252 PyObject *_args;
254 PyObject *_res = NULL;
255 Str255 itemString;
256 short afterItem;
257 if (!PyArg_ParseTuple(_args, "O&h",
258 PyMac_GetStr255, itemString,
259 &afterItem))
260 return NULL;
261 MacInsertMenuItem(_self->ob_itself,
262 itemString,
263 afterItem);
264 Py_INCREF(Py_None);
265 _res = Py_None;
266 return _res;
269 static PyObject *MenuObj_DeleteMenuItem(_self, _args)
270 MenuObject *_self;
271 PyObject *_args;
273 PyObject *_res = NULL;
274 short item;
275 if (!PyArg_ParseTuple(_args, "h",
276 &item))
277 return NULL;
278 DeleteMenuItem(_self->ob_itself,
279 item);
280 Py_INCREF(Py_None);
281 _res = Py_None;
282 return _res;
285 static PyObject *MenuObj_InsertFontResMenu(_self, _args)
286 MenuObject *_self;
287 PyObject *_args;
289 PyObject *_res = NULL;
290 short afterItem;
291 short scriptFilter;
292 if (!PyArg_ParseTuple(_args, "hh",
293 &afterItem,
294 &scriptFilter))
295 return NULL;
296 InsertFontResMenu(_self->ob_itself,
297 afterItem,
298 scriptFilter);
299 Py_INCREF(Py_None);
300 _res = Py_None;
301 return _res;
304 static PyObject *MenuObj_InsertIntlResMenu(_self, _args)
305 MenuObject *_self;
306 PyObject *_args;
308 PyObject *_res = NULL;
309 ResType theType;
310 short afterItem;
311 short scriptFilter;
312 if (!PyArg_ParseTuple(_args, "O&hh",
313 PyMac_GetOSType, &theType,
314 &afterItem,
315 &scriptFilter))
316 return NULL;
317 InsertIntlResMenu(_self->ob_itself,
318 theType,
319 afterItem,
320 scriptFilter);
321 Py_INCREF(Py_None);
322 _res = Py_None;
323 return _res;
326 static PyObject *MenuObj_AppendMenuItemText(_self, _args)
327 MenuObject *_self;
328 PyObject *_args;
330 PyObject *_res = NULL;
331 OSStatus _err;
332 Str255 inString;
333 if (!PyArg_ParseTuple(_args, "O&",
334 PyMac_GetStr255, inString))
335 return NULL;
336 _err = AppendMenuItemText(_self->ob_itself,
337 inString);
338 if (_err != noErr) return PyMac_Error(_err);
339 Py_INCREF(Py_None);
340 _res = Py_None;
341 return _res;
344 static PyObject *MenuObj_InsertMenuItemText(_self, _args)
345 MenuObject *_self;
346 PyObject *_args;
348 PyObject *_res = NULL;
349 OSStatus _err;
350 Str255 inString;
351 MenuItemIndex afterItem;
352 if (!PyArg_ParseTuple(_args, "O&h",
353 PyMac_GetStr255, inString,
354 &afterItem))
355 return NULL;
356 _err = InsertMenuItemText(_self->ob_itself,
357 inString,
358 afterItem);
359 if (_err != noErr) return PyMac_Error(_err);
360 Py_INCREF(Py_None);
361 _res = Py_None;
362 return _res;
365 static PyObject *MenuObj_PopUpMenuSelect(_self, _args)
366 MenuObject *_self;
367 PyObject *_args;
369 PyObject *_res = NULL;
370 long _rv;
371 short top;
372 short left;
373 short popUpItem;
374 if (!PyArg_ParseTuple(_args, "hhh",
375 &top,
376 &left,
377 &popUpItem))
378 return NULL;
379 _rv = PopUpMenuSelect(_self->ob_itself,
380 top,
381 left,
382 popUpItem);
383 _res = Py_BuildValue("l",
384 _rv);
385 return _res;
388 static PyObject *MenuObj_MacInsertMenu(_self, _args)
389 MenuObject *_self;
390 PyObject *_args;
392 PyObject *_res = NULL;
393 MenuID beforeID;
394 if (!PyArg_ParseTuple(_args, "h",
395 &beforeID))
396 return NULL;
397 MacInsertMenu(_self->ob_itself,
398 beforeID);
399 Py_INCREF(Py_None);
400 _res = Py_None;
401 return _res;
404 static PyObject *MenuObj_MacCheckMenuItem(_self, _args)
405 MenuObject *_self;
406 PyObject *_args;
408 PyObject *_res = NULL;
409 short item;
410 Boolean checked;
411 if (!PyArg_ParseTuple(_args, "hb",
412 &item,
413 &checked))
414 return NULL;
415 MacCheckMenuItem(_self->ob_itself,
416 item,
417 checked);
418 Py_INCREF(Py_None);
419 _res = Py_None;
420 return _res;
423 #if !TARGET_API_MAC_CARBON
425 static PyObject *MenuObj_CheckItem(_self, _args)
426 MenuObject *_self;
427 PyObject *_args;
429 PyObject *_res = NULL;
430 short item;
431 Boolean checked;
432 if (!PyArg_ParseTuple(_args, "hb",
433 &item,
434 &checked))
435 return NULL;
436 CheckItem(_self->ob_itself,
437 item,
438 checked);
439 Py_INCREF(Py_None);
440 _res = Py_None;
441 return _res;
443 #endif
445 static PyObject *MenuObj_SetMenuItemText(_self, _args)
446 MenuObject *_self;
447 PyObject *_args;
449 PyObject *_res = NULL;
450 short item;
451 Str255 itemString;
452 if (!PyArg_ParseTuple(_args, "hO&",
453 &item,
454 PyMac_GetStr255, itemString))
455 return NULL;
456 SetMenuItemText(_self->ob_itself,
457 item,
458 itemString);
459 Py_INCREF(Py_None);
460 _res = Py_None;
461 return _res;
464 static PyObject *MenuObj_GetMenuItemText(_self, _args)
465 MenuObject *_self;
466 PyObject *_args;
468 PyObject *_res = NULL;
469 short item;
470 Str255 itemString;
471 if (!PyArg_ParseTuple(_args, "h",
472 &item))
473 return NULL;
474 GetMenuItemText(_self->ob_itself,
475 item,
476 itemString);
477 _res = Py_BuildValue("O&",
478 PyMac_BuildStr255, itemString);
479 return _res;
482 static PyObject *MenuObj_SetItemMark(_self, _args)
483 MenuObject *_self;
484 PyObject *_args;
486 PyObject *_res = NULL;
487 short item;
488 CharParameter markChar;
489 if (!PyArg_ParseTuple(_args, "hh",
490 &item,
491 &markChar))
492 return NULL;
493 SetItemMark(_self->ob_itself,
494 item,
495 markChar);
496 Py_INCREF(Py_None);
497 _res = Py_None;
498 return _res;
501 static PyObject *MenuObj_GetItemMark(_self, _args)
502 MenuObject *_self;
503 PyObject *_args;
505 PyObject *_res = NULL;
506 short item;
507 CharParameter markChar;
508 if (!PyArg_ParseTuple(_args, "h",
509 &item))
510 return NULL;
511 GetItemMark(_self->ob_itself,
512 item,
513 &markChar);
514 _res = Py_BuildValue("h",
515 markChar);
516 return _res;
519 static PyObject *MenuObj_SetItemCmd(_self, _args)
520 MenuObject *_self;
521 PyObject *_args;
523 PyObject *_res = NULL;
524 short item;
525 CharParameter cmdChar;
526 if (!PyArg_ParseTuple(_args, "hh",
527 &item,
528 &cmdChar))
529 return NULL;
530 SetItemCmd(_self->ob_itself,
531 item,
532 cmdChar);
533 Py_INCREF(Py_None);
534 _res = Py_None;
535 return _res;
538 static PyObject *MenuObj_GetItemCmd(_self, _args)
539 MenuObject *_self;
540 PyObject *_args;
542 PyObject *_res = NULL;
543 short item;
544 CharParameter cmdChar;
545 if (!PyArg_ParseTuple(_args, "h",
546 &item))
547 return NULL;
548 GetItemCmd(_self->ob_itself,
549 item,
550 &cmdChar);
551 _res = Py_BuildValue("h",
552 cmdChar);
553 return _res;
556 static PyObject *MenuObj_SetItemIcon(_self, _args)
557 MenuObject *_self;
558 PyObject *_args;
560 PyObject *_res = NULL;
561 short item;
562 short iconIndex;
563 if (!PyArg_ParseTuple(_args, "hh",
564 &item,
565 &iconIndex))
566 return NULL;
567 SetItemIcon(_self->ob_itself,
568 item,
569 iconIndex);
570 Py_INCREF(Py_None);
571 _res = Py_None;
572 return _res;
575 static PyObject *MenuObj_GetItemIcon(_self, _args)
576 MenuObject *_self;
577 PyObject *_args;
579 PyObject *_res = NULL;
580 short item;
581 short iconIndex;
582 if (!PyArg_ParseTuple(_args, "h",
583 &item))
584 return NULL;
585 GetItemIcon(_self->ob_itself,
586 item,
587 &iconIndex);
588 _res = Py_BuildValue("h",
589 iconIndex);
590 return _res;
593 static PyObject *MenuObj_SetItemStyle(_self, _args)
594 MenuObject *_self;
595 PyObject *_args;
597 PyObject *_res = NULL;
598 short item;
599 StyleParameter chStyle;
600 if (!PyArg_ParseTuple(_args, "hh",
601 &item,
602 &chStyle))
603 return NULL;
604 SetItemStyle(_self->ob_itself,
605 item,
606 chStyle);
607 Py_INCREF(Py_None);
608 _res = Py_None;
609 return _res;
612 static PyObject *MenuObj_GetItemStyle(_self, _args)
613 MenuObject *_self;
614 PyObject *_args;
616 PyObject *_res = NULL;
617 short item;
618 Style chStyle;
619 if (!PyArg_ParseTuple(_args, "h",
620 &item))
621 return NULL;
622 GetItemStyle(_self->ob_itself,
623 item,
624 &chStyle);
625 _res = Py_BuildValue("b",
626 chStyle);
627 return _res;
630 #if !TARGET_API_MAC_CARBON
632 static PyObject *MenuObj_DisableItem(_self, _args)
633 MenuObject *_self;
634 PyObject *_args;
636 PyObject *_res = NULL;
637 short item;
638 if (!PyArg_ParseTuple(_args, "h",
639 &item))
640 return NULL;
641 DisableItem(_self->ob_itself,
642 item);
643 Py_INCREF(Py_None);
644 _res = Py_None;
645 return _res;
647 #endif
649 #if !TARGET_API_MAC_CARBON
651 static PyObject *MenuObj_EnableItem(_self, _args)
652 MenuObject *_self;
653 PyObject *_args;
655 PyObject *_res = NULL;
656 short item;
657 if (!PyArg_ParseTuple(_args, "h",
658 &item))
659 return NULL;
660 EnableItem(_self->ob_itself,
661 item);
662 Py_INCREF(Py_None);
663 _res = Py_None;
664 return _res;
666 #endif
668 static PyObject *MenuObj_SetMenuItemCommandID(_self, _args)
669 MenuObject *_self;
670 PyObject *_args;
672 PyObject *_res = NULL;
673 OSErr _err;
674 SInt16 inItem;
675 MenuCommand inCommandID;
676 if (!PyArg_ParseTuple(_args, "hl",
677 &inItem,
678 &inCommandID))
679 return NULL;
680 _err = SetMenuItemCommandID(_self->ob_itself,
681 inItem,
682 inCommandID);
683 if (_err != noErr) return PyMac_Error(_err);
684 Py_INCREF(Py_None);
685 _res = Py_None;
686 return _res;
689 static PyObject *MenuObj_GetMenuItemCommandID(_self, _args)
690 MenuObject *_self;
691 PyObject *_args;
693 PyObject *_res = NULL;
694 OSErr _err;
695 SInt16 inItem;
696 MenuCommand outCommandID;
697 if (!PyArg_ParseTuple(_args, "h",
698 &inItem))
699 return NULL;
700 _err = GetMenuItemCommandID(_self->ob_itself,
701 inItem,
702 &outCommandID);
703 if (_err != noErr) return PyMac_Error(_err);
704 _res = Py_BuildValue("l",
705 outCommandID);
706 return _res;
709 static PyObject *MenuObj_SetMenuItemModifiers(_self, _args)
710 MenuObject *_self;
711 PyObject *_args;
713 PyObject *_res = NULL;
714 OSErr _err;
715 SInt16 inItem;
716 UInt8 inModifiers;
717 if (!PyArg_ParseTuple(_args, "hb",
718 &inItem,
719 &inModifiers))
720 return NULL;
721 _err = SetMenuItemModifiers(_self->ob_itself,
722 inItem,
723 inModifiers);
724 if (_err != noErr) return PyMac_Error(_err);
725 Py_INCREF(Py_None);
726 _res = Py_None;
727 return _res;
730 static PyObject *MenuObj_GetMenuItemModifiers(_self, _args)
731 MenuObject *_self;
732 PyObject *_args;
734 PyObject *_res = NULL;
735 OSErr _err;
736 SInt16 inItem;
737 UInt8 outModifiers;
738 if (!PyArg_ParseTuple(_args, "h",
739 &inItem))
740 return NULL;
741 _err = GetMenuItemModifiers(_self->ob_itself,
742 inItem,
743 &outModifiers);
744 if (_err != noErr) return PyMac_Error(_err);
745 _res = Py_BuildValue("b",
746 outModifiers);
747 return _res;
750 static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args)
751 MenuObject *_self;
752 PyObject *_args;
754 PyObject *_res = NULL;
755 OSErr _err;
756 SInt16 inItem;
757 UInt8 inIconType;
758 Handle inIconHandle;
759 if (!PyArg_ParseTuple(_args, "hbO&",
760 &inItem,
761 &inIconType,
762 ResObj_Convert, &inIconHandle))
763 return NULL;
764 _err = SetMenuItemIconHandle(_self->ob_itself,
765 inItem,
766 inIconType,
767 inIconHandle);
768 if (_err != noErr) return PyMac_Error(_err);
769 Py_INCREF(Py_None);
770 _res = Py_None;
771 return _res;
774 static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args)
775 MenuObject *_self;
776 PyObject *_args;
778 PyObject *_res = NULL;
779 OSErr _err;
780 SInt16 inItem;
781 UInt8 outIconType;
782 Handle outIconHandle;
783 if (!PyArg_ParseTuple(_args, "h",
784 &inItem))
785 return NULL;
786 _err = GetMenuItemIconHandle(_self->ob_itself,
787 inItem,
788 &outIconType,
789 &outIconHandle);
790 if (_err != noErr) return PyMac_Error(_err);
791 _res = Py_BuildValue("bO&",
792 outIconType,
793 ResObj_New, outIconHandle);
794 return _res;
797 static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args)
798 MenuObject *_self;
799 PyObject *_args;
801 PyObject *_res = NULL;
802 OSErr _err;
803 SInt16 inItem;
804 TextEncoding inScriptID;
805 if (!PyArg_ParseTuple(_args, "hl",
806 &inItem,
807 &inScriptID))
808 return NULL;
809 _err = SetMenuItemTextEncoding(_self->ob_itself,
810 inItem,
811 inScriptID);
812 if (_err != noErr) return PyMac_Error(_err);
813 Py_INCREF(Py_None);
814 _res = Py_None;
815 return _res;
818 static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args)
819 MenuObject *_self;
820 PyObject *_args;
822 PyObject *_res = NULL;
823 OSErr _err;
824 SInt16 inItem;
825 TextEncoding outScriptID;
826 if (!PyArg_ParseTuple(_args, "h",
827 &inItem))
828 return NULL;
829 _err = GetMenuItemTextEncoding(_self->ob_itself,
830 inItem,
831 &outScriptID);
832 if (_err != noErr) return PyMac_Error(_err);
833 _res = Py_BuildValue("l",
834 outScriptID);
835 return _res;
838 static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args)
839 MenuObject *_self;
840 PyObject *_args;
842 PyObject *_res = NULL;
843 OSErr _err;
844 SInt16 inItem;
845 MenuID inHierID;
846 if (!PyArg_ParseTuple(_args, "hh",
847 &inItem,
848 &inHierID))
849 return NULL;
850 _err = SetMenuItemHierarchicalID(_self->ob_itself,
851 inItem,
852 inHierID);
853 if (_err != noErr) return PyMac_Error(_err);
854 Py_INCREF(Py_None);
855 _res = Py_None;
856 return _res;
859 static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args)
860 MenuObject *_self;
861 PyObject *_args;
863 PyObject *_res = NULL;
864 OSErr _err;
865 SInt16 inItem;
866 MenuID outHierID;
867 if (!PyArg_ParseTuple(_args, "h",
868 &inItem))
869 return NULL;
870 _err = GetMenuItemHierarchicalID(_self->ob_itself,
871 inItem,
872 &outHierID);
873 if (_err != noErr) return PyMac_Error(_err);
874 _res = Py_BuildValue("h",
875 outHierID);
876 return _res;
879 static PyObject *MenuObj_SetMenuItemFontID(_self, _args)
880 MenuObject *_self;
881 PyObject *_args;
883 PyObject *_res = NULL;
884 OSErr _err;
885 SInt16 inItem;
886 SInt16 inFontID;
887 if (!PyArg_ParseTuple(_args, "hh",
888 &inItem,
889 &inFontID))
890 return NULL;
891 _err = SetMenuItemFontID(_self->ob_itself,
892 inItem,
893 inFontID);
894 if (_err != noErr) return PyMac_Error(_err);
895 Py_INCREF(Py_None);
896 _res = Py_None;
897 return _res;
900 static PyObject *MenuObj_GetMenuItemFontID(_self, _args)
901 MenuObject *_self;
902 PyObject *_args;
904 PyObject *_res = NULL;
905 OSErr _err;
906 SInt16 inItem;
907 SInt16 outFontID;
908 if (!PyArg_ParseTuple(_args, "h",
909 &inItem))
910 return NULL;
911 _err = GetMenuItemFontID(_self->ob_itself,
912 inItem,
913 &outFontID);
914 if (_err != noErr) return PyMac_Error(_err);
915 _res = Py_BuildValue("h",
916 outFontID);
917 return _res;
920 static PyObject *MenuObj_SetMenuItemRefCon(_self, _args)
921 MenuObject *_self;
922 PyObject *_args;
924 PyObject *_res = NULL;
925 OSErr _err;
926 SInt16 inItem;
927 UInt32 inRefCon;
928 if (!PyArg_ParseTuple(_args, "hl",
929 &inItem,
930 &inRefCon))
931 return NULL;
932 _err = SetMenuItemRefCon(_self->ob_itself,
933 inItem,
934 inRefCon);
935 if (_err != noErr) return PyMac_Error(_err);
936 Py_INCREF(Py_None);
937 _res = Py_None;
938 return _res;
941 static PyObject *MenuObj_GetMenuItemRefCon(_self, _args)
942 MenuObject *_self;
943 PyObject *_args;
945 PyObject *_res = NULL;
946 OSErr _err;
947 SInt16 inItem;
948 UInt32 outRefCon;
949 if (!PyArg_ParseTuple(_args, "h",
950 &inItem))
951 return NULL;
952 _err = GetMenuItemRefCon(_self->ob_itself,
953 inItem,
954 &outRefCon);
955 if (_err != noErr) return PyMac_Error(_err);
956 _res = Py_BuildValue("l",
957 outRefCon);
958 return _res;
961 #if !TARGET_API_MAC_CARBON
963 static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args)
964 MenuObject *_self;
965 PyObject *_args;
967 PyObject *_res = NULL;
968 OSErr _err;
969 SInt16 inItem;
970 UInt32 inRefCon2;
971 if (!PyArg_ParseTuple(_args, "hl",
972 &inItem,
973 &inRefCon2))
974 return NULL;
975 _err = SetMenuItemRefCon2(_self->ob_itself,
976 inItem,
977 inRefCon2);
978 if (_err != noErr) return PyMac_Error(_err);
979 Py_INCREF(Py_None);
980 _res = Py_None;
981 return _res;
983 #endif
985 #if !TARGET_API_MAC_CARBON
987 static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args)
988 MenuObject *_self;
989 PyObject *_args;
991 PyObject *_res = NULL;
992 OSErr _err;
993 SInt16 inItem;
994 UInt32 outRefCon2;
995 if (!PyArg_ParseTuple(_args, "h",
996 &inItem))
997 return NULL;
998 _err = GetMenuItemRefCon2(_self->ob_itself,
999 inItem,
1000 &outRefCon2);
1001 if (_err != noErr) return PyMac_Error(_err);
1002 _res = Py_BuildValue("l",
1003 outRefCon2);
1004 return _res;
1006 #endif
1008 static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args)
1009 MenuObject *_self;
1010 PyObject *_args;
1012 PyObject *_res = NULL;
1013 OSErr _err;
1014 SInt16 inItem;
1015 SInt16 inGlyph;
1016 if (!PyArg_ParseTuple(_args, "hh",
1017 &inItem,
1018 &inGlyph))
1019 return NULL;
1020 _err = SetMenuItemKeyGlyph(_self->ob_itself,
1021 inItem,
1022 inGlyph);
1023 if (_err != noErr) return PyMac_Error(_err);
1024 Py_INCREF(Py_None);
1025 _res = Py_None;
1026 return _res;
1029 static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args)
1030 MenuObject *_self;
1031 PyObject *_args;
1033 PyObject *_res = NULL;
1034 OSErr _err;
1035 SInt16 inItem;
1036 SInt16 outGlyph;
1037 if (!PyArg_ParseTuple(_args, "h",
1038 &inItem))
1039 return NULL;
1040 _err = GetMenuItemKeyGlyph(_self->ob_itself,
1041 inItem,
1042 &outGlyph);
1043 if (_err != noErr) return PyMac_Error(_err);
1044 _res = Py_BuildValue("h",
1045 outGlyph);
1046 return _res;
1049 static PyObject *MenuObj_MacEnableMenuItem(_self, _args)
1050 MenuObject *_self;
1051 PyObject *_args;
1053 PyObject *_res = NULL;
1054 MenuItemIndex item;
1055 if (!PyArg_ParseTuple(_args, "h",
1056 &item))
1057 return NULL;
1058 MacEnableMenuItem(_self->ob_itself,
1059 item);
1060 Py_INCREF(Py_None);
1061 _res = Py_None;
1062 return _res;
1065 static PyObject *MenuObj_DisableMenuItem(_self, _args)
1066 MenuObject *_self;
1067 PyObject *_args;
1069 PyObject *_res = NULL;
1070 MenuItemIndex item;
1071 if (!PyArg_ParseTuple(_args, "h",
1072 &item))
1073 return NULL;
1074 DisableMenuItem(_self->ob_itself,
1075 item);
1076 Py_INCREF(Py_None);
1077 _res = Py_None;
1078 return _res;
1081 static PyObject *MenuObj_IsMenuItemEnabled(_self, _args)
1082 MenuObject *_self;
1083 PyObject *_args;
1085 PyObject *_res = NULL;
1086 Boolean _rv;
1087 MenuItemIndex item;
1088 if (!PyArg_ParseTuple(_args, "h",
1089 &item))
1090 return NULL;
1091 _rv = IsMenuItemEnabled(_self->ob_itself,
1092 item);
1093 _res = Py_BuildValue("b",
1094 _rv);
1095 return _res;
1098 static PyObject *MenuObj_EnableMenuItemIcon(_self, _args)
1099 MenuObject *_self;
1100 PyObject *_args;
1102 PyObject *_res = NULL;
1103 MenuItemIndex item;
1104 if (!PyArg_ParseTuple(_args, "h",
1105 &item))
1106 return NULL;
1107 EnableMenuItemIcon(_self->ob_itself,
1108 item);
1109 Py_INCREF(Py_None);
1110 _res = Py_None;
1111 return _res;
1114 static PyObject *MenuObj_DisableMenuItemIcon(_self, _args)
1115 MenuObject *_self;
1116 PyObject *_args;
1118 PyObject *_res = NULL;
1119 MenuItemIndex item;
1120 if (!PyArg_ParseTuple(_args, "h",
1121 &item))
1122 return NULL;
1123 DisableMenuItemIcon(_self->ob_itself,
1124 item);
1125 Py_INCREF(Py_None);
1126 _res = Py_None;
1127 return _res;
1130 static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args)
1131 MenuObject *_self;
1132 PyObject *_args;
1134 PyObject *_res = NULL;
1135 Boolean _rv;
1136 MenuItemIndex item;
1137 if (!PyArg_ParseTuple(_args, "h",
1138 &item))
1139 return NULL;
1140 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1141 item);
1142 _res = Py_BuildValue("b",
1143 _rv);
1144 return _res;
1147 #if TARGET_API_MAC_CARBON
1149 static PyObject *MenuObj_GetMenuItemPropertyAttributes(_self, _args)
1150 MenuObject *_self;
1151 PyObject *_args;
1153 PyObject *_res = NULL;
1154 OSStatus _err;
1155 MenuItemIndex item;
1156 OSType propertyCreator;
1157 OSType propertyTag;
1158 UInt32 attributes;
1159 if (!PyArg_ParseTuple(_args, "hO&O&",
1160 &item,
1161 PyMac_GetOSType, &propertyCreator,
1162 PyMac_GetOSType, &propertyTag))
1163 return NULL;
1164 _err = GetMenuItemPropertyAttributes(_self->ob_itself,
1165 item,
1166 propertyCreator,
1167 propertyTag,
1168 &attributes);
1169 if (_err != noErr) return PyMac_Error(_err);
1170 _res = Py_BuildValue("l",
1171 attributes);
1172 return _res;
1174 #endif
1176 #if TARGET_API_MAC_CARBON
1178 static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(_self, _args)
1179 MenuObject *_self;
1180 PyObject *_args;
1182 PyObject *_res = NULL;
1183 OSStatus _err;
1184 MenuItemIndex item;
1185 OSType propertyCreator;
1186 OSType propertyTag;
1187 UInt32 attributesToSet;
1188 UInt32 attributesToClear;
1189 if (!PyArg_ParseTuple(_args, "hO&O&ll",
1190 &item,
1191 PyMac_GetOSType, &propertyCreator,
1192 PyMac_GetOSType, &propertyTag,
1193 &attributesToSet,
1194 &attributesToClear))
1195 return NULL;
1196 _err = ChangeMenuItemPropertyAttributes(_self->ob_itself,
1197 item,
1198 propertyCreator,
1199 propertyTag,
1200 attributesToSet,
1201 attributesToClear);
1202 if (_err != noErr) return PyMac_Error(_err);
1203 Py_INCREF(Py_None);
1204 _res = Py_None;
1205 return _res;
1207 #endif
1209 #if TARGET_API_MAC_CARBON
1211 static PyObject *MenuObj_GetMenuAttributes(_self, _args)
1212 MenuObject *_self;
1213 PyObject *_args;
1215 PyObject *_res = NULL;
1216 OSStatus _err;
1217 MenuAttributes outAttributes;
1218 if (!PyArg_ParseTuple(_args, ""))
1219 return NULL;
1220 _err = GetMenuAttributes(_self->ob_itself,
1221 &outAttributes);
1222 if (_err != noErr) return PyMac_Error(_err);
1223 _res = Py_BuildValue("l",
1224 outAttributes);
1225 return _res;
1227 #endif
1229 #if TARGET_API_MAC_CARBON
1231 static PyObject *MenuObj_ChangeMenuAttributes(_self, _args)
1232 MenuObject *_self;
1233 PyObject *_args;
1235 PyObject *_res = NULL;
1236 OSStatus _err;
1237 MenuAttributes setTheseAttributes;
1238 MenuAttributes clearTheseAttributes;
1239 if (!PyArg_ParseTuple(_args, "ll",
1240 &setTheseAttributes,
1241 &clearTheseAttributes))
1242 return NULL;
1243 _err = ChangeMenuAttributes(_self->ob_itself,
1244 setTheseAttributes,
1245 clearTheseAttributes);
1246 if (_err != noErr) return PyMac_Error(_err);
1247 Py_INCREF(Py_None);
1248 _res = Py_None;
1249 return _res;
1251 #endif
1253 #if TARGET_API_MAC_CARBON
1255 static PyObject *MenuObj_GetMenuItemAttributes(_self, _args)
1256 MenuObject *_self;
1257 PyObject *_args;
1259 PyObject *_res = NULL;
1260 OSStatus _err;
1261 MenuItemIndex item;
1262 MenuItemAttributes outAttributes;
1263 if (!PyArg_ParseTuple(_args, "h",
1264 &item))
1265 return NULL;
1266 _err = GetMenuItemAttributes(_self->ob_itself,
1267 item,
1268 &outAttributes);
1269 if (_err != noErr) return PyMac_Error(_err);
1270 _res = Py_BuildValue("l",
1271 outAttributes);
1272 return _res;
1274 #endif
1276 #if TARGET_API_MAC_CARBON
1278 static PyObject *MenuObj_ChangeMenuItemAttributes(_self, _args)
1279 MenuObject *_self;
1280 PyObject *_args;
1282 PyObject *_res = NULL;
1283 OSStatus _err;
1284 MenuItemIndex item;
1285 MenuItemAttributes setTheseAttributes;
1286 MenuItemAttributes clearTheseAttributes;
1287 if (!PyArg_ParseTuple(_args, "hll",
1288 &item,
1289 &setTheseAttributes,
1290 &clearTheseAttributes))
1291 return NULL;
1292 _err = ChangeMenuItemAttributes(_self->ob_itself,
1293 item,
1294 setTheseAttributes,
1295 clearTheseAttributes);
1296 if (_err != noErr) return PyMac_Error(_err);
1297 Py_INCREF(Py_None);
1298 _res = Py_None;
1299 return _res;
1301 #endif
1303 #if TARGET_API_MAC_CARBON
1305 static PyObject *MenuObj_DisableAllMenuItems(_self, _args)
1306 MenuObject *_self;
1307 PyObject *_args;
1309 PyObject *_res = NULL;
1310 if (!PyArg_ParseTuple(_args, ""))
1311 return NULL;
1312 DisableAllMenuItems(_self->ob_itself);
1313 Py_INCREF(Py_None);
1314 _res = Py_None;
1315 return _res;
1317 #endif
1319 #if TARGET_API_MAC_CARBON
1321 static PyObject *MenuObj_EnableAllMenuItems(_self, _args)
1322 MenuObject *_self;
1323 PyObject *_args;
1325 PyObject *_res = NULL;
1326 if (!PyArg_ParseTuple(_args, ""))
1327 return NULL;
1328 EnableAllMenuItems(_self->ob_itself);
1329 Py_INCREF(Py_None);
1330 _res = Py_None;
1331 return _res;
1333 #endif
1335 #if TARGET_API_MAC_CARBON
1337 static PyObject *MenuObj_MenuHasEnabledItems(_self, _args)
1338 MenuObject *_self;
1339 PyObject *_args;
1341 PyObject *_res = NULL;
1342 Boolean _rv;
1343 if (!PyArg_ParseTuple(_args, ""))
1344 return NULL;
1345 _rv = MenuHasEnabledItems(_self->ob_itself);
1346 _res = Py_BuildValue("b",
1347 _rv);
1348 return _res;
1350 #endif
1352 #if TARGET_API_MAC_CARBON
1354 static PyObject *MenuObj_CountMenuItemsWithCommandID(_self, _args)
1355 MenuObject *_self;
1356 PyObject *_args;
1358 PyObject *_res = NULL;
1359 ItemCount _rv;
1360 MenuCommand commandID;
1361 if (!PyArg_ParseTuple(_args, "l",
1362 &commandID))
1363 return NULL;
1364 _rv = CountMenuItemsWithCommandID(_self->ob_itself,
1365 commandID);
1366 _res = Py_BuildValue("l",
1367 _rv);
1368 return _res;
1370 #endif
1372 #if TARGET_API_MAC_CARBON
1374 static PyObject *MenuObj_GetIndMenuItemWithCommandID(_self, _args)
1375 MenuObject *_self;
1376 PyObject *_args;
1378 PyObject *_res = NULL;
1379 OSStatus _err;
1380 MenuCommand commandID;
1381 UInt32 itemIndex;
1382 MenuHandle outMenu;
1383 MenuItemIndex outIndex;
1384 if (!PyArg_ParseTuple(_args, "ll",
1385 &commandID,
1386 &itemIndex))
1387 return NULL;
1388 _err = GetIndMenuItemWithCommandID(_self->ob_itself,
1389 commandID,
1390 itemIndex,
1391 &outMenu,
1392 &outIndex);
1393 if (_err != noErr) return PyMac_Error(_err);
1394 _res = Py_BuildValue("O&h",
1395 MenuObj_New, outMenu,
1396 outIndex);
1397 return _res;
1399 #endif
1401 #if TARGET_API_MAC_CARBON
1403 static PyObject *MenuObj_EnableMenuCommand(_self, _args)
1404 MenuObject *_self;
1405 PyObject *_args;
1407 PyObject *_res = NULL;
1408 MenuCommand commandID;
1409 if (!PyArg_ParseTuple(_args, "l",
1410 &commandID))
1411 return NULL;
1412 EnableMenuCommand(_self->ob_itself,
1413 commandID);
1414 Py_INCREF(Py_None);
1415 _res = Py_None;
1416 return _res;
1418 #endif
1420 #if TARGET_API_MAC_CARBON
1422 static PyObject *MenuObj_DisableMenuCommand(_self, _args)
1423 MenuObject *_self;
1424 PyObject *_args;
1426 PyObject *_res = NULL;
1427 MenuCommand commandID;
1428 if (!PyArg_ParseTuple(_args, "l",
1429 &commandID))
1430 return NULL;
1431 DisableMenuCommand(_self->ob_itself,
1432 commandID);
1433 Py_INCREF(Py_None);
1434 _res = Py_None;
1435 return _res;
1437 #endif
1439 #if TARGET_API_MAC_CARBON
1441 static PyObject *MenuObj_IsMenuCommandEnabled(_self, _args)
1442 MenuObject *_self;
1443 PyObject *_args;
1445 PyObject *_res = NULL;
1446 Boolean _rv;
1447 MenuCommand commandID;
1448 if (!PyArg_ParseTuple(_args, "l",
1449 &commandID))
1450 return NULL;
1451 _rv = IsMenuCommandEnabled(_self->ob_itself,
1452 commandID);
1453 _res = Py_BuildValue("b",
1454 _rv);
1455 return _res;
1457 #endif
1459 #if TARGET_API_MAC_CARBON
1461 static PyObject *MenuObj_GetMenuCommandPropertySize(_self, _args)
1462 MenuObject *_self;
1463 PyObject *_args;
1465 PyObject *_res = NULL;
1466 OSStatus _err;
1467 MenuCommand commandID;
1468 OSType propertyCreator;
1469 OSType propertyTag;
1470 ByteCount size;
1471 if (!PyArg_ParseTuple(_args, "lO&O&",
1472 &commandID,
1473 PyMac_GetOSType, &propertyCreator,
1474 PyMac_GetOSType, &propertyTag))
1475 return NULL;
1476 _err = GetMenuCommandPropertySize(_self->ob_itself,
1477 commandID,
1478 propertyCreator,
1479 propertyTag,
1480 &size);
1481 if (_err != noErr) return PyMac_Error(_err);
1482 _res = Py_BuildValue("l",
1483 size);
1484 return _res;
1486 #endif
1488 #if TARGET_API_MAC_CARBON
1490 static PyObject *MenuObj_RemoveMenuCommandProperty(_self, _args)
1491 MenuObject *_self;
1492 PyObject *_args;
1494 PyObject *_res = NULL;
1495 OSStatus _err;
1496 MenuCommand commandID;
1497 OSType propertyCreator;
1498 OSType propertyTag;
1499 if (!PyArg_ParseTuple(_args, "lO&O&",
1500 &commandID,
1501 PyMac_GetOSType, &propertyCreator,
1502 PyMac_GetOSType, &propertyTag))
1503 return NULL;
1504 _err = RemoveMenuCommandProperty(_self->ob_itself,
1505 commandID,
1506 propertyCreator,
1507 propertyTag);
1508 if (_err != noErr) return PyMac_Error(_err);
1509 Py_INCREF(Py_None);
1510 _res = Py_None;
1511 return _res;
1513 #endif
1515 #if TARGET_API_MAC_CARBON
1517 static PyObject *MenuObj_CreateStandardFontMenu(_self, _args)
1518 MenuObject *_self;
1519 PyObject *_args;
1521 PyObject *_res = NULL;
1522 OSStatus _err;
1523 MenuItemIndex afterItem;
1524 MenuID firstHierMenuID;
1525 OptionBits options;
1526 ItemCount outHierMenuCount;
1527 if (!PyArg_ParseTuple(_args, "hhl",
1528 &afterItem,
1529 &firstHierMenuID,
1530 &options))
1531 return NULL;
1532 _err = CreateStandardFontMenu(_self->ob_itself,
1533 afterItem,
1534 firstHierMenuID,
1535 options,
1536 &outHierMenuCount);
1537 if (_err != noErr) return PyMac_Error(_err);
1538 _res = Py_BuildValue("l",
1539 outHierMenuCount);
1540 return _res;
1542 #endif
1544 #if TARGET_API_MAC_CARBON
1546 static PyObject *MenuObj_UpdateStandardFontMenu(_self, _args)
1547 MenuObject *_self;
1548 PyObject *_args;
1550 PyObject *_res = NULL;
1551 OSStatus _err;
1552 ItemCount outHierMenuCount;
1553 if (!PyArg_ParseTuple(_args, ""))
1554 return NULL;
1555 _err = UpdateStandardFontMenu(_self->ob_itself,
1556 &outHierMenuCount);
1557 if (_err != noErr) return PyMac_Error(_err);
1558 _res = Py_BuildValue("l",
1559 outHierMenuCount);
1560 return _res;
1562 #endif
1564 #if TARGET_API_MAC_CARBON
1566 static PyObject *MenuObj_GetFontFamilyFromMenuSelection(_self, _args)
1567 MenuObject *_self;
1568 PyObject *_args;
1570 PyObject *_res = NULL;
1571 OSStatus _err;
1572 MenuItemIndex item;
1573 FMFontFamily outFontFamily;
1574 FMFontStyle outStyle;
1575 if (!PyArg_ParseTuple(_args, "h",
1576 &item))
1577 return NULL;
1578 _err = GetFontFamilyFromMenuSelection(_self->ob_itself,
1579 item,
1580 &outFontFamily,
1581 &outStyle);
1582 if (_err != noErr) return PyMac_Error(_err);
1583 _res = Py_BuildValue("hh",
1584 outFontFamily,
1585 outStyle);
1586 return _res;
1588 #endif
1590 static PyObject *MenuObj_GetMenuID(_self, _args)
1591 MenuObject *_self;
1592 PyObject *_args;
1594 PyObject *_res = NULL;
1595 MenuID _rv;
1596 if (!PyArg_ParseTuple(_args, ""))
1597 return NULL;
1598 _rv = GetMenuID(_self->ob_itself);
1599 _res = Py_BuildValue("h",
1600 _rv);
1601 return _res;
1604 static PyObject *MenuObj_GetMenuWidth(_self, _args)
1605 MenuObject *_self;
1606 PyObject *_args;
1608 PyObject *_res = NULL;
1609 SInt16 _rv;
1610 if (!PyArg_ParseTuple(_args, ""))
1611 return NULL;
1612 _rv = GetMenuWidth(_self->ob_itself);
1613 _res = Py_BuildValue("h",
1614 _rv);
1615 return _res;
1618 static PyObject *MenuObj_GetMenuHeight(_self, _args)
1619 MenuObject *_self;
1620 PyObject *_args;
1622 PyObject *_res = NULL;
1623 SInt16 _rv;
1624 if (!PyArg_ParseTuple(_args, ""))
1625 return NULL;
1626 _rv = GetMenuHeight(_self->ob_itself);
1627 _res = Py_BuildValue("h",
1628 _rv);
1629 return _res;
1632 static PyObject *MenuObj_SetMenuID(_self, _args)
1633 MenuObject *_self;
1634 PyObject *_args;
1636 PyObject *_res = NULL;
1637 MenuID menuID;
1638 if (!PyArg_ParseTuple(_args, "h",
1639 &menuID))
1640 return NULL;
1641 SetMenuID(_self->ob_itself,
1642 menuID);
1643 Py_INCREF(Py_None);
1644 _res = Py_None;
1645 return _res;
1648 static PyObject *MenuObj_SetMenuWidth(_self, _args)
1649 MenuObject *_self;
1650 PyObject *_args;
1652 PyObject *_res = NULL;
1653 SInt16 width;
1654 if (!PyArg_ParseTuple(_args, "h",
1655 &width))
1656 return NULL;
1657 SetMenuWidth(_self->ob_itself,
1658 width);
1659 Py_INCREF(Py_None);
1660 _res = Py_None;
1661 return _res;
1664 static PyObject *MenuObj_SetMenuHeight(_self, _args)
1665 MenuObject *_self;
1666 PyObject *_args;
1668 PyObject *_res = NULL;
1669 SInt16 height;
1670 if (!PyArg_ParseTuple(_args, "h",
1671 &height))
1672 return NULL;
1673 SetMenuHeight(_self->ob_itself,
1674 height);
1675 Py_INCREF(Py_None);
1676 _res = Py_None;
1677 return _res;
1680 static PyObject *MenuObj_as_Resource(_self, _args)
1681 MenuObject *_self;
1682 PyObject *_args;
1684 PyObject *_res = NULL;
1685 Handle _rv;
1686 if (!PyArg_ParseTuple(_args, ""))
1687 return NULL;
1688 _rv = as_Resource(_self->ob_itself);
1689 _res = Py_BuildValue("O&",
1690 ResObj_New, _rv);
1691 return _res;
1694 static PyObject *MenuObj_AppendMenu(_self, _args)
1695 MenuObject *_self;
1696 PyObject *_args;
1698 PyObject *_res = NULL;
1699 Str255 data;
1700 if (!PyArg_ParseTuple(_args, "O&",
1701 PyMac_GetStr255, data))
1702 return NULL;
1703 AppendMenu(_self->ob_itself,
1704 data);
1705 Py_INCREF(Py_None);
1706 _res = Py_None;
1707 return _res;
1710 static PyObject *MenuObj_InsertMenu(_self, _args)
1711 MenuObject *_self;
1712 PyObject *_args;
1714 PyObject *_res = NULL;
1715 short beforeID;
1716 if (!PyArg_ParseTuple(_args, "h",
1717 &beforeID))
1718 return NULL;
1719 InsertMenu(_self->ob_itself,
1720 beforeID);
1721 Py_INCREF(Py_None);
1722 _res = Py_None;
1723 return _res;
1726 static PyObject *MenuObj_InsertMenuItem(_self, _args)
1727 MenuObject *_self;
1728 PyObject *_args;
1730 PyObject *_res = NULL;
1731 Str255 itemString;
1732 short afterItem;
1733 if (!PyArg_ParseTuple(_args, "O&h",
1734 PyMac_GetStr255, itemString,
1735 &afterItem))
1736 return NULL;
1737 InsertMenuItem(_self->ob_itself,
1738 itemString,
1739 afterItem);
1740 Py_INCREF(Py_None);
1741 _res = Py_None;
1742 return _res;
1745 static PyObject *MenuObj_EnableMenuItem(_self, _args)
1746 MenuObject *_self;
1747 PyObject *_args;
1749 PyObject *_res = NULL;
1750 UInt16 item;
1751 if (!PyArg_ParseTuple(_args, "H",
1752 &item))
1753 return NULL;
1754 EnableMenuItem(_self->ob_itself,
1755 item);
1756 Py_INCREF(Py_None);
1757 _res = Py_None;
1758 return _res;
1761 static PyObject *MenuObj_CheckMenuItem(_self, _args)
1762 MenuObject *_self;
1763 PyObject *_args;
1765 PyObject *_res = NULL;
1766 short item;
1767 Boolean checked;
1768 if (!PyArg_ParseTuple(_args, "hb",
1769 &item,
1770 &checked))
1771 return NULL;
1772 CheckMenuItem(_self->ob_itself,
1773 item,
1774 checked);
1775 Py_INCREF(Py_None);
1776 _res = Py_None;
1777 return _res;
1780 static PyMethodDef MenuObj_methods[] = {
1781 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1782 "() -> None"},
1783 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1784 "() -> None"},
1785 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1786 "() -> (short _rv)"},
1788 #if !TARGET_API_MAC_CARBON
1789 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1790 "() -> (short _rv)"},
1791 #endif
1792 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1793 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1794 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1795 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1796 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1797 "() -> (Boolean _rv)"},
1798 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1799 "(Boolean excludesMark) -> None"},
1800 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
1801 "(Str255 data) -> None"},
1802 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1803 "(ResType theType, short afterItem) -> None"},
1804 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1805 "(ResType theType) -> None"},
1806 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
1807 "(Str255 itemString, short afterItem) -> None"},
1808 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
1809 "(short item) -> None"},
1810 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1811 "(short afterItem, short scriptFilter) -> None"},
1812 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1813 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1814 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1815 "(Str255 inString) -> None"},
1816 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
1817 "(Str255 inString, MenuItemIndex afterItem) -> None"},
1818 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1819 "(short top, short left, short popUpItem) -> (long _rv)"},
1820 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
1821 "(MenuID beforeID) -> None"},
1822 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1823 "(short item, Boolean checked) -> None"},
1825 #if !TARGET_API_MAC_CARBON
1826 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1827 "(short item, Boolean checked) -> None"},
1828 #endif
1829 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
1830 "(short item, Str255 itemString) -> None"},
1831 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
1832 "(short item) -> (Str255 itemString)"},
1833 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
1834 "(short item, CharParameter markChar) -> None"},
1835 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
1836 "(short item) -> (CharParameter markChar)"},
1837 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1838 "(short item, CharParameter cmdChar) -> None"},
1839 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1840 "(short item) -> (CharParameter cmdChar)"},
1841 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1842 "(short item, short iconIndex) -> None"},
1843 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1844 "(short item) -> (short iconIndex)"},
1845 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
1846 "(short item, StyleParameter chStyle) -> None"},
1847 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
1848 "(short item) -> (Style chStyle)"},
1850 #if !TARGET_API_MAC_CARBON
1851 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1852 "(short item) -> None"},
1853 #endif
1855 #if !TARGET_API_MAC_CARBON
1856 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1857 "(short item) -> None"},
1858 #endif
1859 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
1860 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
1861 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
1862 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
1863 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1864 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1865 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1866 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1867 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1868 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1869 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1870 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1871 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1872 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1873 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1874 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1875 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
1876 "(SInt16 inItem, MenuID inHierID) -> None"},
1877 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
1878 "(SInt16 inItem) -> (MenuID outHierID)"},
1879 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1880 "(SInt16 inItem, SInt16 inFontID) -> None"},
1881 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1882 "(SInt16 inItem) -> (SInt16 outFontID)"},
1883 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1884 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1885 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1886 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1888 #if !TARGET_API_MAC_CARBON
1889 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1890 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1891 #endif
1893 #if !TARGET_API_MAC_CARBON
1894 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1895 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1896 #endif
1897 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1898 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1899 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1900 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1901 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
1902 "(MenuItemIndex item) -> None"},
1903 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
1904 "(MenuItemIndex item) -> None"},
1905 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
1906 "(MenuItemIndex item) -> (Boolean _rv)"},
1907 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
1908 "(MenuItemIndex item) -> None"},
1909 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
1910 "(MenuItemIndex item) -> None"},
1911 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
1912 "(MenuItemIndex item) -> (Boolean _rv)"},
1914 #if TARGET_API_MAC_CARBON
1915 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1916 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1917 #endif
1919 #if TARGET_API_MAC_CARBON
1920 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1921 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1922 #endif
1924 #if TARGET_API_MAC_CARBON
1925 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1926 "() -> (MenuAttributes outAttributes)"},
1927 #endif
1929 #if TARGET_API_MAC_CARBON
1930 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1931 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1932 #endif
1934 #if TARGET_API_MAC_CARBON
1935 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1936 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1937 #endif
1939 #if TARGET_API_MAC_CARBON
1940 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1941 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1942 #endif
1944 #if TARGET_API_MAC_CARBON
1945 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1946 "() -> None"},
1947 #endif
1949 #if TARGET_API_MAC_CARBON
1950 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1951 "() -> None"},
1952 #endif
1954 #if TARGET_API_MAC_CARBON
1955 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1956 "() -> (Boolean _rv)"},
1957 #endif
1959 #if TARGET_API_MAC_CARBON
1960 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1961 "(MenuCommand commandID) -> (ItemCount _rv)"},
1962 #endif
1964 #if TARGET_API_MAC_CARBON
1965 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1966 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1967 #endif
1969 #if TARGET_API_MAC_CARBON
1970 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1971 "(MenuCommand commandID) -> None"},
1972 #endif
1974 #if TARGET_API_MAC_CARBON
1975 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1976 "(MenuCommand commandID) -> None"},
1977 #endif
1979 #if TARGET_API_MAC_CARBON
1980 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1981 "(MenuCommand commandID) -> (Boolean _rv)"},
1982 #endif
1984 #if TARGET_API_MAC_CARBON
1985 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1986 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1987 #endif
1989 #if TARGET_API_MAC_CARBON
1990 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
1991 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1992 #endif
1994 #if TARGET_API_MAC_CARBON
1995 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
1996 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1997 #endif
1999 #if TARGET_API_MAC_CARBON
2000 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
2001 "() -> (ItemCount outHierMenuCount)"},
2002 #endif
2004 #if TARGET_API_MAC_CARBON
2005 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
2006 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
2007 #endif
2008 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
2009 "() -> (MenuID _rv)"},
2010 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
2011 "() -> (SInt16 _rv)"},
2012 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
2013 "() -> (SInt16 _rv)"},
2014 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
2015 "(MenuID menuID) -> None"},
2016 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
2017 "(SInt16 width) -> None"},
2018 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
2019 "(SInt16 height) -> None"},
2020 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
2021 "() -> (Handle _rv)"},
2022 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
2023 "(Str255 data) -> None"},
2024 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
2025 "(short beforeID) -> None"},
2026 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
2027 "(Str255 itemString, short afterItem) -> None"},
2028 {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1,
2029 "(UInt16 item) -> None"},
2030 {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1,
2031 "(short item, Boolean checked) -> None"},
2032 {NULL, NULL, 0}
2035 PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
2037 static PyObject *MenuObj_getattr(self, name)
2038 MenuObject *self;
2039 char *name;
2041 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
2044 #define MenuObj_setattr NULL
2046 #define MenuObj_compare NULL
2048 #define MenuObj_repr NULL
2050 #define MenuObj_hash NULL
2052 PyTypeObject Menu_Type = {
2053 PyObject_HEAD_INIT(&PyType_Type)
2054 0, /*ob_size*/
2055 "Menu", /*tp_name*/
2056 sizeof(MenuObject), /*tp_basicsize*/
2057 0, /*tp_itemsize*/
2058 /* methods */
2059 (destructor) MenuObj_dealloc, /*tp_dealloc*/
2060 0, /*tp_print*/
2061 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
2062 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
2063 (cmpfunc) MenuObj_compare, /*tp_compare*/
2064 (reprfunc) MenuObj_repr, /*tp_repr*/
2065 (PyNumberMethods *)0, /* tp_as_number */
2066 (PySequenceMethods *)0, /* tp_as_sequence */
2067 (PyMappingMethods *)0, /* tp_as_mapping */
2068 (hashfunc) MenuObj_hash, /*tp_hash*/
2071 /* ---------------------- End object type Menu ---------------------- */
2074 #if !TARGET_API_MAC_CARBON
2076 static PyObject *Menu_InitProcMenu(_self, _args)
2077 PyObject *_self;
2078 PyObject *_args;
2080 PyObject *_res = NULL;
2081 short resID;
2082 if (!PyArg_ParseTuple(_args, "h",
2083 &resID))
2084 return NULL;
2085 InitProcMenu(resID);
2086 Py_INCREF(Py_None);
2087 _res = Py_None;
2088 return _res;
2090 #endif
2092 #if !TARGET_API_MAC_CARBON
2094 static PyObject *Menu_InitMenus(_self, _args)
2095 PyObject *_self;
2096 PyObject *_args;
2098 PyObject *_res = NULL;
2099 if (!PyArg_ParseTuple(_args, ""))
2100 return NULL;
2101 InitMenus();
2102 Py_INCREF(Py_None);
2103 _res = Py_None;
2104 return _res;
2106 #endif
2108 static PyObject *Menu_NewMenu(_self, _args)
2109 PyObject *_self;
2110 PyObject *_args;
2112 PyObject *_res = NULL;
2113 MenuHandle _rv;
2114 MenuID menuID;
2115 Str255 menuTitle;
2116 if (!PyArg_ParseTuple(_args, "hO&",
2117 &menuID,
2118 PyMac_GetStr255, menuTitle))
2119 return NULL;
2120 _rv = NewMenu(menuID,
2121 menuTitle);
2122 _res = Py_BuildValue("O&",
2123 MenuObj_New, _rv);
2124 return _res;
2127 static PyObject *Menu_MacGetMenu(_self, _args)
2128 PyObject *_self;
2129 PyObject *_args;
2131 PyObject *_res = NULL;
2132 MenuHandle _rv;
2133 short resourceID;
2134 if (!PyArg_ParseTuple(_args, "h",
2135 &resourceID))
2136 return NULL;
2137 _rv = MacGetMenu(resourceID);
2138 _res = Py_BuildValue("O&",
2139 MenuObj_New, _rv);
2140 return _res;
2143 #if TARGET_API_MAC_CARBON
2145 static PyObject *Menu_CreateNewMenu(_self, _args)
2146 PyObject *_self;
2147 PyObject *_args;
2149 PyObject *_res = NULL;
2150 OSStatus _err;
2151 MenuID menuID;
2152 MenuAttributes menuAttributes;
2153 MenuHandle outMenuRef;
2154 if (!PyArg_ParseTuple(_args, "hl",
2155 &menuID,
2156 &menuAttributes))
2157 return NULL;
2158 _err = CreateNewMenu(menuID,
2159 menuAttributes,
2160 &outMenuRef);
2161 if (_err != noErr) return PyMac_Error(_err);
2162 _res = Py_BuildValue("O&",
2163 MenuObj_New, outMenuRef);
2164 return _res;
2166 #endif
2168 static PyObject *Menu_MenuKey(_self, _args)
2169 PyObject *_self;
2170 PyObject *_args;
2172 PyObject *_res = NULL;
2173 long _rv;
2174 CharParameter ch;
2175 if (!PyArg_ParseTuple(_args, "h",
2176 &ch))
2177 return NULL;
2178 _rv = MenuKey(ch);
2179 _res = Py_BuildValue("l",
2180 _rv);
2181 return _res;
2184 static PyObject *Menu_MenuSelect(_self, _args)
2185 PyObject *_self;
2186 PyObject *_args;
2188 PyObject *_res = NULL;
2189 long _rv;
2190 Point startPt;
2191 if (!PyArg_ParseTuple(_args, "O&",
2192 PyMac_GetPoint, &startPt))
2193 return NULL;
2194 _rv = MenuSelect(startPt);
2195 _res = Py_BuildValue("l",
2196 _rv);
2197 return _res;
2200 static PyObject *Menu_MenuChoice(_self, _args)
2201 PyObject *_self;
2202 PyObject *_args;
2204 PyObject *_res = NULL;
2205 long _rv;
2206 if (!PyArg_ParseTuple(_args, ""))
2207 return NULL;
2208 _rv = MenuChoice();
2209 _res = Py_BuildValue("l",
2210 _rv);
2211 return _res;
2214 static PyObject *Menu_MenuEvent(_self, _args)
2215 PyObject *_self;
2216 PyObject *_args;
2218 PyObject *_res = NULL;
2219 UInt32 _rv;
2220 EventRecord inEvent;
2221 if (!PyArg_ParseTuple(_args, "O&",
2222 PyMac_GetEventRecord, &inEvent))
2223 return NULL;
2224 _rv = MenuEvent(&inEvent);
2225 _res = Py_BuildValue("l",
2226 _rv);
2227 return _res;
2230 static PyObject *Menu_GetMBarHeight(_self, _args)
2231 PyObject *_self;
2232 PyObject *_args;
2234 PyObject *_res = NULL;
2235 short _rv;
2236 if (!PyArg_ParseTuple(_args, ""))
2237 return NULL;
2238 _rv = GetMBarHeight();
2239 _res = Py_BuildValue("h",
2240 _rv);
2241 return _res;
2244 static PyObject *Menu_MacDrawMenuBar(_self, _args)
2245 PyObject *_self;
2246 PyObject *_args;
2248 PyObject *_res = NULL;
2249 if (!PyArg_ParseTuple(_args, ""))
2250 return NULL;
2251 MacDrawMenuBar();
2252 Py_INCREF(Py_None);
2253 _res = Py_None;
2254 return _res;
2257 static PyObject *Menu_InvalMenuBar(_self, _args)
2258 PyObject *_self;
2259 PyObject *_args;
2261 PyObject *_res = NULL;
2262 if (!PyArg_ParseTuple(_args, ""))
2263 return NULL;
2264 InvalMenuBar();
2265 Py_INCREF(Py_None);
2266 _res = Py_None;
2267 return _res;
2270 static PyObject *Menu_HiliteMenu(_self, _args)
2271 PyObject *_self;
2272 PyObject *_args;
2274 PyObject *_res = NULL;
2275 MenuID menuID;
2276 if (!PyArg_ParseTuple(_args, "h",
2277 &menuID))
2278 return NULL;
2279 HiliteMenu(menuID);
2280 Py_INCREF(Py_None);
2281 _res = Py_None;
2282 return _res;
2285 static PyObject *Menu_GetNewMBar(_self, _args)
2286 PyObject *_self;
2287 PyObject *_args;
2289 PyObject *_res = NULL;
2290 MenuBarHandle _rv;
2291 short menuBarID;
2292 if (!PyArg_ParseTuple(_args, "h",
2293 &menuBarID))
2294 return NULL;
2295 _rv = GetNewMBar(menuBarID);
2296 _res = Py_BuildValue("O&",
2297 ResObj_New, _rv);
2298 return _res;
2301 static PyObject *Menu_GetMenuBar(_self, _args)
2302 PyObject *_self;
2303 PyObject *_args;
2305 PyObject *_res = NULL;
2306 MenuBarHandle _rv;
2307 if (!PyArg_ParseTuple(_args, ""))
2308 return NULL;
2309 _rv = GetMenuBar();
2310 _res = Py_BuildValue("O&",
2311 ResObj_New, _rv);
2312 return _res;
2315 static PyObject *Menu_SetMenuBar(_self, _args)
2316 PyObject *_self;
2317 PyObject *_args;
2319 PyObject *_res = NULL;
2320 MenuBarHandle mbar;
2321 if (!PyArg_ParseTuple(_args, "O&",
2322 ResObj_Convert, &mbar))
2323 return NULL;
2324 SetMenuBar(mbar);
2325 Py_INCREF(Py_None);
2326 _res = Py_None;
2327 return _res;
2330 #if TARGET_API_MAC_CARBON
2332 static PyObject *Menu_DuplicateMenuBar(_self, _args)
2333 PyObject *_self;
2334 PyObject *_args;
2336 PyObject *_res = NULL;
2337 OSStatus _err;
2338 MenuBarHandle mbar;
2339 MenuBarHandle outBar;
2340 if (!PyArg_ParseTuple(_args, "O&",
2341 ResObj_Convert, &mbar))
2342 return NULL;
2343 _err = DuplicateMenuBar(mbar,
2344 &outBar);
2345 if (_err != noErr) return PyMac_Error(_err);
2346 _res = Py_BuildValue("O&",
2347 ResObj_New, outBar);
2348 return _res;
2350 #endif
2352 #if TARGET_API_MAC_CARBON
2354 static PyObject *Menu_DisposeMenuBar(_self, _args)
2355 PyObject *_self;
2356 PyObject *_args;
2358 PyObject *_res = NULL;
2359 OSStatus _err;
2360 MenuBarHandle mbar;
2361 if (!PyArg_ParseTuple(_args, "O&",
2362 ResObj_Convert, &mbar))
2363 return NULL;
2364 _err = DisposeMenuBar(mbar);
2365 if (_err != noErr) return PyMac_Error(_err);
2366 Py_INCREF(Py_None);
2367 _res = Py_None;
2368 return _res;
2370 #endif
2372 static PyObject *Menu_GetMenuHandle(_self, _args)
2373 PyObject *_self;
2374 PyObject *_args;
2376 PyObject *_res = NULL;
2377 MenuHandle _rv;
2378 MenuID menuID;
2379 if (!PyArg_ParseTuple(_args, "h",
2380 &menuID))
2381 return NULL;
2382 _rv = GetMenuHandle(menuID);
2383 _res = Py_BuildValue("O&",
2384 MenuObj_New, _rv);
2385 return _res;
2388 static PyObject *Menu_MacDeleteMenu(_self, _args)
2389 PyObject *_self;
2390 PyObject *_args;
2392 PyObject *_res = NULL;
2393 MenuID menuID;
2394 if (!PyArg_ParseTuple(_args, "h",
2395 &menuID))
2396 return NULL;
2397 MacDeleteMenu(menuID);
2398 Py_INCREF(Py_None);
2399 _res = Py_None;
2400 return _res;
2403 static PyObject *Menu_ClearMenuBar(_self, _args)
2404 PyObject *_self;
2405 PyObject *_args;
2407 PyObject *_res = NULL;
2408 if (!PyArg_ParseTuple(_args, ""))
2409 return NULL;
2410 ClearMenuBar();
2411 Py_INCREF(Py_None);
2412 _res = Py_None;
2413 return _res;
2416 static PyObject *Menu_SetMenuFlashCount(_self, _args)
2417 PyObject *_self;
2418 PyObject *_args;
2420 PyObject *_res = NULL;
2421 short count;
2422 if (!PyArg_ParseTuple(_args, "h",
2423 &count))
2424 return NULL;
2425 SetMenuFlashCount(count);
2426 Py_INCREF(Py_None);
2427 _res = Py_None;
2428 return _res;
2431 #if !TARGET_API_MAC_CARBON
2433 static PyObject *Menu_SetMenuFlash(_self, _args)
2434 PyObject *_self;
2435 PyObject *_args;
2437 PyObject *_res = NULL;
2438 short count;
2439 if (!PyArg_ParseTuple(_args, "h",
2440 &count))
2441 return NULL;
2442 SetMenuFlash(count);
2443 Py_INCREF(Py_None);
2444 _res = Py_None;
2445 return _res;
2447 #endif
2449 static PyObject *Menu_FlashMenuBar(_self, _args)
2450 PyObject *_self;
2451 PyObject *_args;
2453 PyObject *_res = NULL;
2454 MenuID menuID;
2455 if (!PyArg_ParseTuple(_args, "h",
2456 &menuID))
2457 return NULL;
2458 FlashMenuBar(menuID);
2459 Py_INCREF(Py_None);
2460 _res = Py_None;
2461 return _res;
2464 #if !TARGET_API_MAC_CARBON
2466 static PyObject *Menu_SystemEdit(_self, _args)
2467 PyObject *_self;
2468 PyObject *_args;
2470 PyObject *_res = NULL;
2471 Boolean _rv;
2472 short editCmd;
2473 if (!PyArg_ParseTuple(_args, "h",
2474 &editCmd))
2475 return NULL;
2476 _rv = SystemEdit(editCmd);
2477 _res = Py_BuildValue("b",
2478 _rv);
2479 return _res;
2481 #endif
2483 #if !TARGET_API_MAC_CARBON
2485 static PyObject *Menu_SystemMenu(_self, _args)
2486 PyObject *_self;
2487 PyObject *_args;
2489 PyObject *_res = NULL;
2490 long menuResult;
2491 if (!PyArg_ParseTuple(_args, "l",
2492 &menuResult))
2493 return NULL;
2494 SystemMenu(menuResult);
2495 Py_INCREF(Py_None);
2496 _res = Py_None;
2497 return _res;
2499 #endif
2501 static PyObject *Menu_IsMenuBarVisible(_self, _args)
2502 PyObject *_self;
2503 PyObject *_args;
2505 PyObject *_res = NULL;
2506 Boolean _rv;
2507 if (!PyArg_ParseTuple(_args, ""))
2508 return NULL;
2509 _rv = IsMenuBarVisible();
2510 _res = Py_BuildValue("b",
2511 _rv);
2512 return _res;
2515 static PyObject *Menu_ShowMenuBar(_self, _args)
2516 PyObject *_self;
2517 PyObject *_args;
2519 PyObject *_res = NULL;
2520 if (!PyArg_ParseTuple(_args, ""))
2521 return NULL;
2522 ShowMenuBar();
2523 Py_INCREF(Py_None);
2524 _res = Py_None;
2525 return _res;
2528 static PyObject *Menu_HideMenuBar(_self, _args)
2529 PyObject *_self;
2530 PyObject *_args;
2532 PyObject *_res = NULL;
2533 if (!PyArg_ParseTuple(_args, ""))
2534 return NULL;
2535 HideMenuBar();
2536 Py_INCREF(Py_None);
2537 _res = Py_None;
2538 return _res;
2541 static PyObject *Menu_DeleteMCEntries(_self, _args)
2542 PyObject *_self;
2543 PyObject *_args;
2545 PyObject *_res = NULL;
2546 MenuID menuID;
2547 short menuItem;
2548 if (!PyArg_ParseTuple(_args, "hh",
2549 &menuID,
2550 &menuItem))
2551 return NULL;
2552 DeleteMCEntries(menuID,
2553 menuItem);
2554 Py_INCREF(Py_None);
2555 _res = Py_None;
2556 return _res;
2559 static PyObject *Menu_InitContextualMenus(_self, _args)
2560 PyObject *_self;
2561 PyObject *_args;
2563 PyObject *_res = NULL;
2564 OSStatus _err;
2565 if (!PyArg_ParseTuple(_args, ""))
2566 return NULL;
2567 _err = InitContextualMenus();
2568 if (_err != noErr) return PyMac_Error(_err);
2569 Py_INCREF(Py_None);
2570 _res = Py_None;
2571 return _res;
2574 static PyObject *Menu_IsShowContextualMenuClick(_self, _args)
2575 PyObject *_self;
2576 PyObject *_args;
2578 PyObject *_res = NULL;
2579 Boolean _rv;
2580 EventRecord inEvent;
2581 if (!PyArg_ParseTuple(_args, "O&",
2582 PyMac_GetEventRecord, &inEvent))
2583 return NULL;
2584 _rv = IsShowContextualMenuClick(&inEvent);
2585 _res = Py_BuildValue("b",
2586 _rv);
2587 return _res;
2590 #if !TARGET_API_MAC_CARBON
2592 static PyObject *Menu_OpenDeskAcc(_self, _args)
2593 PyObject *_self;
2594 PyObject *_args;
2596 PyObject *_res = NULL;
2597 Str255 name;
2598 if (!PyArg_ParseTuple(_args, "O&",
2599 PyMac_GetStr255, name))
2600 return NULL;
2601 OpenDeskAcc(name);
2602 Py_INCREF(Py_None);
2603 _res = Py_None;
2604 return _res;
2606 #endif
2608 static PyObject *Menu_as_Menu(_self, _args)
2609 PyObject *_self;
2610 PyObject *_args;
2612 PyObject *_res = NULL;
2613 MenuHandle _rv;
2614 Handle h;
2615 if (!PyArg_ParseTuple(_args, "O&",
2616 ResObj_Convert, &h))
2617 return NULL;
2618 _rv = as_Menu(h);
2619 _res = Py_BuildValue("O&",
2620 MenuObj_New, _rv);
2621 return _res;
2624 static PyObject *Menu_GetMenu(_self, _args)
2625 PyObject *_self;
2626 PyObject *_args;
2628 PyObject *_res = NULL;
2629 MenuHandle _rv;
2630 short resourceID;
2631 if (!PyArg_ParseTuple(_args, "h",
2632 &resourceID))
2633 return NULL;
2634 _rv = GetMenu(resourceID);
2635 _res = Py_BuildValue("O&",
2636 MenuObj_New, _rv);
2637 return _res;
2640 static PyObject *Menu_DeleteMenu(_self, _args)
2641 PyObject *_self;
2642 PyObject *_args;
2644 PyObject *_res = NULL;
2645 short menuID;
2646 if (!PyArg_ParseTuple(_args, "h",
2647 &menuID))
2648 return NULL;
2649 DeleteMenu(menuID);
2650 Py_INCREF(Py_None);
2651 _res = Py_None;
2652 return _res;
2655 static PyObject *Menu_DrawMenuBar(_self, _args)
2656 PyObject *_self;
2657 PyObject *_args;
2659 PyObject *_res = NULL;
2660 if (!PyArg_ParseTuple(_args, ""))
2661 return NULL;
2662 DrawMenuBar();
2663 Py_INCREF(Py_None);
2664 _res = Py_None;
2665 return _res;
2668 static PyMethodDef Menu_methods[] = {
2670 #if !TARGET_API_MAC_CARBON
2671 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2672 "(short resID) -> None"},
2673 #endif
2675 #if !TARGET_API_MAC_CARBON
2676 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2677 "() -> None"},
2678 #endif
2679 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
2680 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
2681 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
2682 "(short resourceID) -> (MenuHandle _rv)"},
2684 #if TARGET_API_MAC_CARBON
2685 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2686 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2687 #endif
2688 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
2689 "(CharParameter ch) -> (long _rv)"},
2690 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2691 "(Point startPt) -> (long _rv)"},
2692 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2693 "() -> (long _rv)"},
2694 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2695 "(EventRecord inEvent) -> (UInt32 _rv)"},
2696 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2697 "() -> (short _rv)"},
2698 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
2699 "() -> None"},
2700 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2701 "() -> None"},
2702 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
2703 "(MenuID menuID) -> None"},
2704 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
2705 "(short menuBarID) -> (MenuBarHandle _rv)"},
2706 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
2707 "() -> (MenuBarHandle _rv)"},
2708 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
2709 "(MenuBarHandle mbar) -> None"},
2711 #if TARGET_API_MAC_CARBON
2712 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2713 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2714 #endif
2716 #if TARGET_API_MAC_CARBON
2717 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2718 "(MenuBarHandle mbar) -> None"},
2719 #endif
2720 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
2721 "(MenuID menuID) -> (MenuHandle _rv)"},
2722 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
2723 "(MenuID menuID) -> None"},
2724 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2725 "() -> None"},
2726 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2727 "(short count) -> None"},
2729 #if !TARGET_API_MAC_CARBON
2730 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2731 "(short count) -> None"},
2732 #endif
2733 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
2734 "(MenuID menuID) -> None"},
2736 #if !TARGET_API_MAC_CARBON
2737 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2738 "(short editCmd) -> (Boolean _rv)"},
2739 #endif
2741 #if !TARGET_API_MAC_CARBON
2742 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2743 "(long menuResult) -> None"},
2744 #endif
2745 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2746 "() -> (Boolean _rv)"},
2747 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2748 "() -> None"},
2749 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2750 "() -> None"},
2751 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
2752 "(MenuID menuID, short menuItem) -> None"},
2753 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2754 "() -> None"},
2755 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2756 "(EventRecord inEvent) -> (Boolean _rv)"},
2758 #if !TARGET_API_MAC_CARBON
2759 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2760 "(Str255 name) -> None"},
2761 #endif
2762 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2763 "(Handle h) -> (MenuHandle _rv)"},
2764 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2765 "(short resourceID) -> (MenuHandle _rv)"},
2766 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2767 "(short menuID) -> None"},
2768 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2769 "() -> None"},
2770 {NULL, NULL, 0}
2776 void initMenu()
2778 PyObject *m;
2779 PyObject *d;
2784 m = Py_InitModule("Menu", Menu_methods);
2785 d = PyModule_GetDict(m);
2786 Menu_Error = PyMac_GetOSErrException();
2787 if (Menu_Error == NULL ||
2788 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
2789 return;
2790 Menu_Type.ob_type = &PyType_Type;
2791 Py_INCREF(&Menu_Type);
2792 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2793 Py_FatalError("can't initialize MenuType");
2796 /* ======================== End module Menu ========================= */