py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Modules / menu / Menumodule.c
blobf3c2df96a85a48946aa2a986a43feba11bf28068
2 /* ========================== Module Menu =========================== */
4 #include "Python.h"
8 #include "macglue.h"
9 #include "pymactoolbox.h"
11 #ifdef WITHOUT_FRAMEWORKS
12 #include <Devices.h> /* Defines OpenDeskAcc in universal headers */
13 #include <Menus.h>
14 #else
15 #include <Carbon/Carbon.h>
16 #endif
19 #ifdef USE_TOOLBOX_OBJECT_GLUE
21 extern PyObject *_MenuObj_New(MenuHandle);
22 extern int _MenuObj_Convert(PyObject *, MenuHandle *);
24 #define MenuObj_New _MenuObj_New
25 #define MenuObj_Convert _MenuObj_Convert
26 #endif
28 #if !ACCESSOR_CALLS_ARE_FUNCTIONS
29 #define GetMenuID(menu) ((*(menu))->menuID)
30 #define GetMenuWidth(menu) ((*(menu))->menuWidth)
31 #define GetMenuHeight(menu) ((*(menu))->menuHeight)
33 #define SetMenuID(menu, id) ((*(menu))->menuID = (id))
34 #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
35 #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
36 #endif
38 #define as_Menu(h) ((MenuHandle)h)
39 #define as_Resource(h) ((Handle)h)
41 static PyObject *Menu_Error;
43 /* ------------------------ Object type Menu ------------------------ */
45 PyTypeObject Menu_Type;
47 #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
49 typedef struct MenuObject {
50 PyObject_HEAD
51 MenuHandle ob_itself;
52 } MenuObject;
54 PyObject *MenuObj_New(MenuHandle itself)
56 MenuObject *it;
57 it = PyObject_NEW(MenuObject, &Menu_Type);
58 if (it == NULL) return NULL;
59 it->ob_itself = itself;
60 return (PyObject *)it;
62 MenuObj_Convert(PyObject *v, MenuHandle *p_itself)
64 if (!MenuObj_Check(v))
66 PyErr_SetString(PyExc_TypeError, "Menu required");
67 return 0;
69 *p_itself = ((MenuObject *)v)->ob_itself;
70 return 1;
73 static void MenuObj_dealloc(MenuObject *self)
75 /* Cleanup of self->ob_itself goes here */
76 PyMem_DEL(self);
79 static PyObject *MenuObj_DisposeMenu(MenuObject *_self, PyObject *_args)
81 PyObject *_res = NULL;
82 if (!PyArg_ParseTuple(_args, ""))
83 return NULL;
84 DisposeMenu(_self->ob_itself);
85 Py_INCREF(Py_None);
86 _res = Py_None;
87 return _res;
90 static PyObject *MenuObj_CalcMenuSize(MenuObject *_self, PyObject *_args)
92 PyObject *_res = NULL;
93 if (!PyArg_ParseTuple(_args, ""))
94 return NULL;
95 CalcMenuSize(_self->ob_itself);
96 Py_INCREF(Py_None);
97 _res = Py_None;
98 return _res;
101 static PyObject *MenuObj_CountMenuItems(MenuObject *_self, PyObject *_args)
103 PyObject *_res = NULL;
104 short _rv;
105 if (!PyArg_ParseTuple(_args, ""))
106 return NULL;
107 _rv = CountMenuItems(_self->ob_itself);
108 _res = Py_BuildValue("h",
109 _rv);
110 return _res;
113 #if !TARGET_API_MAC_CARBON
115 static PyObject *MenuObj_CountMItems(MenuObject *_self, PyObject *_args)
117 PyObject *_res = NULL;
118 short _rv;
119 if (!PyArg_ParseTuple(_args, ""))
120 return NULL;
121 _rv = CountMItems(_self->ob_itself);
122 _res = Py_BuildValue("h",
123 _rv);
124 return _res;
126 #endif
128 static PyObject *MenuObj_GetMenuFont(MenuObject *_self, 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(MenuObject *_self, PyObject *_args)
148 PyObject *_res = NULL;
149 OSStatus _err;
150 SInt16 inFontID;
151 UInt16 inFontSize;
152 if (!PyArg_ParseTuple(_args, "hH",
153 &inFontID,
154 &inFontSize))
155 return NULL;
156 _err = SetMenuFont(_self->ob_itself,
157 inFontID,
158 inFontSize);
159 if (_err != noErr) return PyMac_Error(_err);
160 Py_INCREF(Py_None);
161 _res = Py_None;
162 return _res;
165 static PyObject *MenuObj_GetMenuExcludesMarkColumn(MenuObject *_self, PyObject *_args)
167 PyObject *_res = NULL;
168 Boolean _rv;
169 if (!PyArg_ParseTuple(_args, ""))
170 return NULL;
171 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
172 _res = Py_BuildValue("b",
173 _rv);
174 return _res;
177 static PyObject *MenuObj_SetMenuExcludesMarkColumn(MenuObject *_self, PyObject *_args)
179 PyObject *_res = NULL;
180 OSStatus _err;
181 Boolean excludesMark;
182 if (!PyArg_ParseTuple(_args, "b",
183 &excludesMark))
184 return NULL;
185 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
186 excludesMark);
187 if (_err != noErr) return PyMac_Error(_err);
188 Py_INCREF(Py_None);
189 _res = Py_None;
190 return _res;
193 static PyObject *MenuObj_MacAppendMenu(MenuObject *_self, PyObject *_args)
195 PyObject *_res = NULL;
196 Str255 data;
197 if (!PyArg_ParseTuple(_args, "O&",
198 PyMac_GetStr255, data))
199 return NULL;
200 MacAppendMenu(_self->ob_itself,
201 data);
202 Py_INCREF(Py_None);
203 _res = Py_None;
204 return _res;
207 static PyObject *MenuObj_InsertResMenu(MenuObject *_self, PyObject *_args)
209 PyObject *_res = NULL;
210 ResType theType;
211 short afterItem;
212 if (!PyArg_ParseTuple(_args, "O&h",
213 PyMac_GetOSType, &theType,
214 &afterItem))
215 return NULL;
216 InsertResMenu(_self->ob_itself,
217 theType,
218 afterItem);
219 Py_INCREF(Py_None);
220 _res = Py_None;
221 return _res;
224 static PyObject *MenuObj_AppendResMenu(MenuObject *_self, PyObject *_args)
226 PyObject *_res = NULL;
227 ResType theType;
228 if (!PyArg_ParseTuple(_args, "O&",
229 PyMac_GetOSType, &theType))
230 return NULL;
231 AppendResMenu(_self->ob_itself,
232 theType);
233 Py_INCREF(Py_None);
234 _res = Py_None;
235 return _res;
238 static PyObject *MenuObj_MacInsertMenuItem(MenuObject *_self, PyObject *_args)
240 PyObject *_res = NULL;
241 Str255 itemString;
242 short afterItem;
243 if (!PyArg_ParseTuple(_args, "O&h",
244 PyMac_GetStr255, itemString,
245 &afterItem))
246 return NULL;
247 MacInsertMenuItem(_self->ob_itself,
248 itemString,
249 afterItem);
250 Py_INCREF(Py_None);
251 _res = Py_None;
252 return _res;
255 static PyObject *MenuObj_DeleteMenuItem(MenuObject *_self, PyObject *_args)
257 PyObject *_res = NULL;
258 short item;
259 if (!PyArg_ParseTuple(_args, "h",
260 &item))
261 return NULL;
262 DeleteMenuItem(_self->ob_itself,
263 item);
264 Py_INCREF(Py_None);
265 _res = Py_None;
266 return _res;
269 static PyObject *MenuObj_InsertFontResMenu(MenuObject *_self, PyObject *_args)
271 PyObject *_res = NULL;
272 short afterItem;
273 short scriptFilter;
274 if (!PyArg_ParseTuple(_args, "hh",
275 &afterItem,
276 &scriptFilter))
277 return NULL;
278 InsertFontResMenu(_self->ob_itself,
279 afterItem,
280 scriptFilter);
281 Py_INCREF(Py_None);
282 _res = Py_None;
283 return _res;
286 static PyObject *MenuObj_InsertIntlResMenu(MenuObject *_self, PyObject *_args)
288 PyObject *_res = NULL;
289 ResType theType;
290 short afterItem;
291 short scriptFilter;
292 if (!PyArg_ParseTuple(_args, "O&hh",
293 PyMac_GetOSType, &theType,
294 &afterItem,
295 &scriptFilter))
296 return NULL;
297 InsertIntlResMenu(_self->ob_itself,
298 theType,
299 afterItem,
300 scriptFilter);
301 Py_INCREF(Py_None);
302 _res = Py_None;
303 return _res;
306 static PyObject *MenuObj_AppendMenuItemText(MenuObject *_self, PyObject *_args)
308 PyObject *_res = NULL;
309 OSStatus _err;
310 Str255 inString;
311 if (!PyArg_ParseTuple(_args, "O&",
312 PyMac_GetStr255, inString))
313 return NULL;
314 _err = AppendMenuItemText(_self->ob_itself,
315 inString);
316 if (_err != noErr) return PyMac_Error(_err);
317 Py_INCREF(Py_None);
318 _res = Py_None;
319 return _res;
322 static PyObject *MenuObj_InsertMenuItemText(MenuObject *_self, PyObject *_args)
324 PyObject *_res = NULL;
325 OSStatus _err;
326 Str255 inString;
327 MenuItemIndex afterItem;
328 if (!PyArg_ParseTuple(_args, "O&h",
329 PyMac_GetStr255, inString,
330 &afterItem))
331 return NULL;
332 _err = InsertMenuItemText(_self->ob_itself,
333 inString,
334 afterItem);
335 if (_err != noErr) return PyMac_Error(_err);
336 Py_INCREF(Py_None);
337 _res = Py_None;
338 return _res;
341 static PyObject *MenuObj_PopUpMenuSelect(MenuObject *_self, PyObject *_args)
343 PyObject *_res = NULL;
344 long _rv;
345 short top;
346 short left;
347 short popUpItem;
348 if (!PyArg_ParseTuple(_args, "hhh",
349 &top,
350 &left,
351 &popUpItem))
352 return NULL;
353 _rv = PopUpMenuSelect(_self->ob_itself,
354 top,
355 left,
356 popUpItem);
357 _res = Py_BuildValue("l",
358 _rv);
359 return _res;
362 static PyObject *MenuObj_MacInsertMenu(MenuObject *_self, PyObject *_args)
364 PyObject *_res = NULL;
365 MenuID beforeID;
366 if (!PyArg_ParseTuple(_args, "h",
367 &beforeID))
368 return NULL;
369 MacInsertMenu(_self->ob_itself,
370 beforeID);
371 Py_INCREF(Py_None);
372 _res = Py_None;
373 return _res;
376 static PyObject *MenuObj_MacCheckMenuItem(MenuObject *_self, PyObject *_args)
378 PyObject *_res = NULL;
379 short item;
380 Boolean checked;
381 if (!PyArg_ParseTuple(_args, "hb",
382 &item,
383 &checked))
384 return NULL;
385 MacCheckMenuItem(_self->ob_itself,
386 item,
387 checked);
388 Py_INCREF(Py_None);
389 _res = Py_None;
390 return _res;
393 #if !TARGET_API_MAC_CARBON
395 static PyObject *MenuObj_CheckItem(MenuObject *_self, PyObject *_args)
397 PyObject *_res = NULL;
398 short item;
399 Boolean checked;
400 if (!PyArg_ParseTuple(_args, "hb",
401 &item,
402 &checked))
403 return NULL;
404 CheckItem(_self->ob_itself,
405 item,
406 checked);
407 Py_INCREF(Py_None);
408 _res = Py_None;
409 return _res;
411 #endif
413 static PyObject *MenuObj_SetMenuItemText(MenuObject *_self, PyObject *_args)
415 PyObject *_res = NULL;
416 short item;
417 Str255 itemString;
418 if (!PyArg_ParseTuple(_args, "hO&",
419 &item,
420 PyMac_GetStr255, itemString))
421 return NULL;
422 SetMenuItemText(_self->ob_itself,
423 item,
424 itemString);
425 Py_INCREF(Py_None);
426 _res = Py_None;
427 return _res;
430 static PyObject *MenuObj_GetMenuItemText(MenuObject *_self, PyObject *_args)
432 PyObject *_res = NULL;
433 short item;
434 Str255 itemString;
435 if (!PyArg_ParseTuple(_args, "h",
436 &item))
437 return NULL;
438 GetMenuItemText(_self->ob_itself,
439 item,
440 itemString);
441 _res = Py_BuildValue("O&",
442 PyMac_BuildStr255, itemString);
443 return _res;
446 static PyObject *MenuObj_SetItemMark(MenuObject *_self, PyObject *_args)
448 PyObject *_res = NULL;
449 short item;
450 CharParameter markChar;
451 if (!PyArg_ParseTuple(_args, "hh",
452 &item,
453 &markChar))
454 return NULL;
455 SetItemMark(_self->ob_itself,
456 item,
457 markChar);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
463 static PyObject *MenuObj_GetItemMark(MenuObject *_self, PyObject *_args)
465 PyObject *_res = NULL;
466 short item;
467 CharParameter markChar;
468 if (!PyArg_ParseTuple(_args, "h",
469 &item))
470 return NULL;
471 GetItemMark(_self->ob_itself,
472 item,
473 &markChar);
474 _res = Py_BuildValue("h",
475 markChar);
476 return _res;
479 static PyObject *MenuObj_SetItemCmd(MenuObject *_self, PyObject *_args)
481 PyObject *_res = NULL;
482 short item;
483 CharParameter cmdChar;
484 if (!PyArg_ParseTuple(_args, "hh",
485 &item,
486 &cmdChar))
487 return NULL;
488 SetItemCmd(_self->ob_itself,
489 item,
490 cmdChar);
491 Py_INCREF(Py_None);
492 _res = Py_None;
493 return _res;
496 static PyObject *MenuObj_GetItemCmd(MenuObject *_self, PyObject *_args)
498 PyObject *_res = NULL;
499 short item;
500 CharParameter cmdChar;
501 if (!PyArg_ParseTuple(_args, "h",
502 &item))
503 return NULL;
504 GetItemCmd(_self->ob_itself,
505 item,
506 &cmdChar);
507 _res = Py_BuildValue("h",
508 cmdChar);
509 return _res;
512 static PyObject *MenuObj_SetItemIcon(MenuObject *_self, PyObject *_args)
514 PyObject *_res = NULL;
515 short item;
516 short iconIndex;
517 if (!PyArg_ParseTuple(_args, "hh",
518 &item,
519 &iconIndex))
520 return NULL;
521 SetItemIcon(_self->ob_itself,
522 item,
523 iconIndex);
524 Py_INCREF(Py_None);
525 _res = Py_None;
526 return _res;
529 static PyObject *MenuObj_GetItemIcon(MenuObject *_self, PyObject *_args)
531 PyObject *_res = NULL;
532 short item;
533 short iconIndex;
534 if (!PyArg_ParseTuple(_args, "h",
535 &item))
536 return NULL;
537 GetItemIcon(_self->ob_itself,
538 item,
539 &iconIndex);
540 _res = Py_BuildValue("h",
541 iconIndex);
542 return _res;
545 static PyObject *MenuObj_SetItemStyle(MenuObject *_self, PyObject *_args)
547 PyObject *_res = NULL;
548 short item;
549 StyleParameter chStyle;
550 if (!PyArg_ParseTuple(_args, "hh",
551 &item,
552 &chStyle))
553 return NULL;
554 SetItemStyle(_self->ob_itself,
555 item,
556 chStyle);
557 Py_INCREF(Py_None);
558 _res = Py_None;
559 return _res;
562 static PyObject *MenuObj_GetItemStyle(MenuObject *_self, PyObject *_args)
564 PyObject *_res = NULL;
565 short item;
566 Style chStyle;
567 if (!PyArg_ParseTuple(_args, "h",
568 &item))
569 return NULL;
570 GetItemStyle(_self->ob_itself,
571 item,
572 &chStyle);
573 _res = Py_BuildValue("b",
574 chStyle);
575 return _res;
578 #if !TARGET_API_MAC_CARBON
580 static PyObject *MenuObj_DisableItem(MenuObject *_self, PyObject *_args)
582 PyObject *_res = NULL;
583 short item;
584 if (!PyArg_ParseTuple(_args, "h",
585 &item))
586 return NULL;
587 DisableItem(_self->ob_itself,
588 item);
589 Py_INCREF(Py_None);
590 _res = Py_None;
591 return _res;
593 #endif
595 #if !TARGET_API_MAC_CARBON
597 static PyObject *MenuObj_EnableItem(MenuObject *_self, PyObject *_args)
599 PyObject *_res = NULL;
600 short item;
601 if (!PyArg_ParseTuple(_args, "h",
602 &item))
603 return NULL;
604 EnableItem(_self->ob_itself,
605 item);
606 Py_INCREF(Py_None);
607 _res = Py_None;
608 return _res;
610 #endif
612 static PyObject *MenuObj_SetMenuItemCommandID(MenuObject *_self, PyObject *_args)
614 PyObject *_res = NULL;
615 OSErr _err;
616 SInt16 inItem;
617 MenuCommand inCommandID;
618 if (!PyArg_ParseTuple(_args, "hl",
619 &inItem,
620 &inCommandID))
621 return NULL;
622 _err = SetMenuItemCommandID(_self->ob_itself,
623 inItem,
624 inCommandID);
625 if (_err != noErr) return PyMac_Error(_err);
626 Py_INCREF(Py_None);
627 _res = Py_None;
628 return _res;
631 static PyObject *MenuObj_GetMenuItemCommandID(MenuObject *_self, PyObject *_args)
633 PyObject *_res = NULL;
634 OSErr _err;
635 SInt16 inItem;
636 MenuCommand outCommandID;
637 if (!PyArg_ParseTuple(_args, "h",
638 &inItem))
639 return NULL;
640 _err = GetMenuItemCommandID(_self->ob_itself,
641 inItem,
642 &outCommandID);
643 if (_err != noErr) return PyMac_Error(_err);
644 _res = Py_BuildValue("l",
645 outCommandID);
646 return _res;
649 static PyObject *MenuObj_SetMenuItemModifiers(MenuObject *_self, PyObject *_args)
651 PyObject *_res = NULL;
652 OSErr _err;
653 SInt16 inItem;
654 UInt8 inModifiers;
655 if (!PyArg_ParseTuple(_args, "hb",
656 &inItem,
657 &inModifiers))
658 return NULL;
659 _err = SetMenuItemModifiers(_self->ob_itself,
660 inItem,
661 inModifiers);
662 if (_err != noErr) return PyMac_Error(_err);
663 Py_INCREF(Py_None);
664 _res = Py_None;
665 return _res;
668 static PyObject *MenuObj_GetMenuItemModifiers(MenuObject *_self, PyObject *_args)
670 PyObject *_res = NULL;
671 OSErr _err;
672 SInt16 inItem;
673 UInt8 outModifiers;
674 if (!PyArg_ParseTuple(_args, "h",
675 &inItem))
676 return NULL;
677 _err = GetMenuItemModifiers(_self->ob_itself,
678 inItem,
679 &outModifiers);
680 if (_err != noErr) return PyMac_Error(_err);
681 _res = Py_BuildValue("b",
682 outModifiers);
683 return _res;
686 static PyObject *MenuObj_SetMenuItemIconHandle(MenuObject *_self, PyObject *_args)
688 PyObject *_res = NULL;
689 OSErr _err;
690 SInt16 inItem;
691 UInt8 inIconType;
692 Handle inIconHandle;
693 if (!PyArg_ParseTuple(_args, "hbO&",
694 &inItem,
695 &inIconType,
696 ResObj_Convert, &inIconHandle))
697 return NULL;
698 _err = SetMenuItemIconHandle(_self->ob_itself,
699 inItem,
700 inIconType,
701 inIconHandle);
702 if (_err != noErr) return PyMac_Error(_err);
703 Py_INCREF(Py_None);
704 _res = Py_None;
705 return _res;
708 static PyObject *MenuObj_GetMenuItemIconHandle(MenuObject *_self, PyObject *_args)
710 PyObject *_res = NULL;
711 OSErr _err;
712 SInt16 inItem;
713 UInt8 outIconType;
714 Handle outIconHandle;
715 if (!PyArg_ParseTuple(_args, "h",
716 &inItem))
717 return NULL;
718 _err = GetMenuItemIconHandle(_self->ob_itself,
719 inItem,
720 &outIconType,
721 &outIconHandle);
722 if (_err != noErr) return PyMac_Error(_err);
723 _res = Py_BuildValue("bO&",
724 outIconType,
725 ResObj_New, outIconHandle);
726 return _res;
729 static PyObject *MenuObj_SetMenuItemTextEncoding(MenuObject *_self, PyObject *_args)
731 PyObject *_res = NULL;
732 OSErr _err;
733 SInt16 inItem;
734 TextEncoding inScriptID;
735 if (!PyArg_ParseTuple(_args, "hl",
736 &inItem,
737 &inScriptID))
738 return NULL;
739 _err = SetMenuItemTextEncoding(_self->ob_itself,
740 inItem,
741 inScriptID);
742 if (_err != noErr) return PyMac_Error(_err);
743 Py_INCREF(Py_None);
744 _res = Py_None;
745 return _res;
748 static PyObject *MenuObj_GetMenuItemTextEncoding(MenuObject *_self, PyObject *_args)
750 PyObject *_res = NULL;
751 OSErr _err;
752 SInt16 inItem;
753 TextEncoding outScriptID;
754 if (!PyArg_ParseTuple(_args, "h",
755 &inItem))
756 return NULL;
757 _err = GetMenuItemTextEncoding(_self->ob_itself,
758 inItem,
759 &outScriptID);
760 if (_err != noErr) return PyMac_Error(_err);
761 _res = Py_BuildValue("l",
762 outScriptID);
763 return _res;
766 static PyObject *MenuObj_SetMenuItemHierarchicalID(MenuObject *_self, PyObject *_args)
768 PyObject *_res = NULL;
769 OSErr _err;
770 SInt16 inItem;
771 MenuID inHierID;
772 if (!PyArg_ParseTuple(_args, "hh",
773 &inItem,
774 &inHierID))
775 return NULL;
776 _err = SetMenuItemHierarchicalID(_self->ob_itself,
777 inItem,
778 inHierID);
779 if (_err != noErr) return PyMac_Error(_err);
780 Py_INCREF(Py_None);
781 _res = Py_None;
782 return _res;
785 static PyObject *MenuObj_GetMenuItemHierarchicalID(MenuObject *_self, PyObject *_args)
787 PyObject *_res = NULL;
788 OSErr _err;
789 SInt16 inItem;
790 MenuID outHierID;
791 if (!PyArg_ParseTuple(_args, "h",
792 &inItem))
793 return NULL;
794 _err = GetMenuItemHierarchicalID(_self->ob_itself,
795 inItem,
796 &outHierID);
797 if (_err != noErr) return PyMac_Error(_err);
798 _res = Py_BuildValue("h",
799 outHierID);
800 return _res;
803 static PyObject *MenuObj_SetMenuItemFontID(MenuObject *_self, PyObject *_args)
805 PyObject *_res = NULL;
806 OSErr _err;
807 SInt16 inItem;
808 SInt16 inFontID;
809 if (!PyArg_ParseTuple(_args, "hh",
810 &inItem,
811 &inFontID))
812 return NULL;
813 _err = SetMenuItemFontID(_self->ob_itself,
814 inItem,
815 inFontID);
816 if (_err != noErr) return PyMac_Error(_err);
817 Py_INCREF(Py_None);
818 _res = Py_None;
819 return _res;
822 static PyObject *MenuObj_GetMenuItemFontID(MenuObject *_self, PyObject *_args)
824 PyObject *_res = NULL;
825 OSErr _err;
826 SInt16 inItem;
827 SInt16 outFontID;
828 if (!PyArg_ParseTuple(_args, "h",
829 &inItem))
830 return NULL;
831 _err = GetMenuItemFontID(_self->ob_itself,
832 inItem,
833 &outFontID);
834 if (_err != noErr) return PyMac_Error(_err);
835 _res = Py_BuildValue("h",
836 outFontID);
837 return _res;
840 static PyObject *MenuObj_SetMenuItemRefCon(MenuObject *_self, PyObject *_args)
842 PyObject *_res = NULL;
843 OSErr _err;
844 SInt16 inItem;
845 UInt32 inRefCon;
846 if (!PyArg_ParseTuple(_args, "hl",
847 &inItem,
848 &inRefCon))
849 return NULL;
850 _err = SetMenuItemRefCon(_self->ob_itself,
851 inItem,
852 inRefCon);
853 if (_err != noErr) return PyMac_Error(_err);
854 Py_INCREF(Py_None);
855 _res = Py_None;
856 return _res;
859 static PyObject *MenuObj_GetMenuItemRefCon(MenuObject *_self, PyObject *_args)
861 PyObject *_res = NULL;
862 OSErr _err;
863 SInt16 inItem;
864 UInt32 outRefCon;
865 if (!PyArg_ParseTuple(_args, "h",
866 &inItem))
867 return NULL;
868 _err = GetMenuItemRefCon(_self->ob_itself,
869 inItem,
870 &outRefCon);
871 if (_err != noErr) return PyMac_Error(_err);
872 _res = Py_BuildValue("l",
873 outRefCon);
874 return _res;
877 #if !TARGET_API_MAC_CARBON
879 static PyObject *MenuObj_SetMenuItemRefCon2(MenuObject *_self, PyObject *_args)
881 PyObject *_res = NULL;
882 OSErr _err;
883 SInt16 inItem;
884 UInt32 inRefCon2;
885 if (!PyArg_ParseTuple(_args, "hl",
886 &inItem,
887 &inRefCon2))
888 return NULL;
889 _err = SetMenuItemRefCon2(_self->ob_itself,
890 inItem,
891 inRefCon2);
892 if (_err != noErr) return PyMac_Error(_err);
893 Py_INCREF(Py_None);
894 _res = Py_None;
895 return _res;
897 #endif
899 #if !TARGET_API_MAC_CARBON
901 static PyObject *MenuObj_GetMenuItemRefCon2(MenuObject *_self, PyObject *_args)
903 PyObject *_res = NULL;
904 OSErr _err;
905 SInt16 inItem;
906 UInt32 outRefCon2;
907 if (!PyArg_ParseTuple(_args, "h",
908 &inItem))
909 return NULL;
910 _err = GetMenuItemRefCon2(_self->ob_itself,
911 inItem,
912 &outRefCon2);
913 if (_err != noErr) return PyMac_Error(_err);
914 _res = Py_BuildValue("l",
915 outRefCon2);
916 return _res;
918 #endif
920 static PyObject *MenuObj_SetMenuItemKeyGlyph(MenuObject *_self, PyObject *_args)
922 PyObject *_res = NULL;
923 OSErr _err;
924 SInt16 inItem;
925 SInt16 inGlyph;
926 if (!PyArg_ParseTuple(_args, "hh",
927 &inItem,
928 &inGlyph))
929 return NULL;
930 _err = SetMenuItemKeyGlyph(_self->ob_itself,
931 inItem,
932 inGlyph);
933 if (_err != noErr) return PyMac_Error(_err);
934 Py_INCREF(Py_None);
935 _res = Py_None;
936 return _res;
939 static PyObject *MenuObj_GetMenuItemKeyGlyph(MenuObject *_self, PyObject *_args)
941 PyObject *_res = NULL;
942 OSErr _err;
943 SInt16 inItem;
944 SInt16 outGlyph;
945 if (!PyArg_ParseTuple(_args, "h",
946 &inItem))
947 return NULL;
948 _err = GetMenuItemKeyGlyph(_self->ob_itself,
949 inItem,
950 &outGlyph);
951 if (_err != noErr) return PyMac_Error(_err);
952 _res = Py_BuildValue("h",
953 outGlyph);
954 return _res;
957 static PyObject *MenuObj_MacEnableMenuItem(MenuObject *_self, PyObject *_args)
959 PyObject *_res = NULL;
960 MenuItemIndex item;
961 if (!PyArg_ParseTuple(_args, "h",
962 &item))
963 return NULL;
964 MacEnableMenuItem(_self->ob_itself,
965 item);
966 Py_INCREF(Py_None);
967 _res = Py_None;
968 return _res;
971 static PyObject *MenuObj_DisableMenuItem(MenuObject *_self, PyObject *_args)
973 PyObject *_res = NULL;
974 MenuItemIndex item;
975 if (!PyArg_ParseTuple(_args, "h",
976 &item))
977 return NULL;
978 DisableMenuItem(_self->ob_itself,
979 item);
980 Py_INCREF(Py_None);
981 _res = Py_None;
982 return _res;
985 static PyObject *MenuObj_IsMenuItemEnabled(MenuObject *_self, PyObject *_args)
987 PyObject *_res = NULL;
988 Boolean _rv;
989 MenuItemIndex item;
990 if (!PyArg_ParseTuple(_args, "h",
991 &item))
992 return NULL;
993 _rv = IsMenuItemEnabled(_self->ob_itself,
994 item);
995 _res = Py_BuildValue("b",
996 _rv);
997 return _res;
1000 static PyObject *MenuObj_EnableMenuItemIcon(MenuObject *_self, PyObject *_args)
1002 PyObject *_res = NULL;
1003 MenuItemIndex item;
1004 if (!PyArg_ParseTuple(_args, "h",
1005 &item))
1006 return NULL;
1007 EnableMenuItemIcon(_self->ob_itself,
1008 item);
1009 Py_INCREF(Py_None);
1010 _res = Py_None;
1011 return _res;
1014 static PyObject *MenuObj_DisableMenuItemIcon(MenuObject *_self, PyObject *_args)
1016 PyObject *_res = NULL;
1017 MenuItemIndex item;
1018 if (!PyArg_ParseTuple(_args, "h",
1019 &item))
1020 return NULL;
1021 DisableMenuItemIcon(_self->ob_itself,
1022 item);
1023 Py_INCREF(Py_None);
1024 _res = Py_None;
1025 return _res;
1028 static PyObject *MenuObj_IsMenuItemIconEnabled(MenuObject *_self, PyObject *_args)
1030 PyObject *_res = NULL;
1031 Boolean _rv;
1032 MenuItemIndex item;
1033 if (!PyArg_ParseTuple(_args, "h",
1034 &item))
1035 return NULL;
1036 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1037 item);
1038 _res = Py_BuildValue("b",
1039 _rv);
1040 return _res;
1043 #if TARGET_API_MAC_CARBON
1045 static PyObject *MenuObj_GetMenuItemPropertyAttributes(MenuObject *_self, PyObject *_args)
1047 PyObject *_res = NULL;
1048 OSStatus _err;
1049 MenuItemIndex item;
1050 OSType propertyCreator;
1051 OSType propertyTag;
1052 UInt32 attributes;
1053 if (!PyArg_ParseTuple(_args, "hO&O&",
1054 &item,
1055 PyMac_GetOSType, &propertyCreator,
1056 PyMac_GetOSType, &propertyTag))
1057 return NULL;
1058 _err = GetMenuItemPropertyAttributes(_self->ob_itself,
1059 item,
1060 propertyCreator,
1061 propertyTag,
1062 &attributes);
1063 if (_err != noErr) return PyMac_Error(_err);
1064 _res = Py_BuildValue("l",
1065 attributes);
1066 return _res;
1068 #endif
1070 #if TARGET_API_MAC_CARBON
1072 static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(MenuObject *_self, PyObject *_args)
1074 PyObject *_res = NULL;
1075 OSStatus _err;
1076 MenuItemIndex item;
1077 OSType propertyCreator;
1078 OSType propertyTag;
1079 UInt32 attributesToSet;
1080 UInt32 attributesToClear;
1081 if (!PyArg_ParseTuple(_args, "hO&O&ll",
1082 &item,
1083 PyMac_GetOSType, &propertyCreator,
1084 PyMac_GetOSType, &propertyTag,
1085 &attributesToSet,
1086 &attributesToClear))
1087 return NULL;
1088 _err = ChangeMenuItemPropertyAttributes(_self->ob_itself,
1089 item,
1090 propertyCreator,
1091 propertyTag,
1092 attributesToSet,
1093 attributesToClear);
1094 if (_err != noErr) return PyMac_Error(_err);
1095 Py_INCREF(Py_None);
1096 _res = Py_None;
1097 return _res;
1099 #endif
1101 #if TARGET_API_MAC_CARBON
1103 static PyObject *MenuObj_GetMenuAttributes(MenuObject *_self, PyObject *_args)
1105 PyObject *_res = NULL;
1106 OSStatus _err;
1107 MenuAttributes outAttributes;
1108 if (!PyArg_ParseTuple(_args, ""))
1109 return NULL;
1110 _err = GetMenuAttributes(_self->ob_itself,
1111 &outAttributes);
1112 if (_err != noErr) return PyMac_Error(_err);
1113 _res = Py_BuildValue("l",
1114 outAttributes);
1115 return _res;
1117 #endif
1119 #if TARGET_API_MAC_CARBON
1121 static PyObject *MenuObj_ChangeMenuAttributes(MenuObject *_self, PyObject *_args)
1123 PyObject *_res = NULL;
1124 OSStatus _err;
1125 MenuAttributes setTheseAttributes;
1126 MenuAttributes clearTheseAttributes;
1127 if (!PyArg_ParseTuple(_args, "ll",
1128 &setTheseAttributes,
1129 &clearTheseAttributes))
1130 return NULL;
1131 _err = ChangeMenuAttributes(_self->ob_itself,
1132 setTheseAttributes,
1133 clearTheseAttributes);
1134 if (_err != noErr) return PyMac_Error(_err);
1135 Py_INCREF(Py_None);
1136 _res = Py_None;
1137 return _res;
1139 #endif
1141 #if TARGET_API_MAC_CARBON
1143 static PyObject *MenuObj_GetMenuItemAttributes(MenuObject *_self, PyObject *_args)
1145 PyObject *_res = NULL;
1146 OSStatus _err;
1147 MenuItemIndex item;
1148 MenuItemAttributes outAttributes;
1149 if (!PyArg_ParseTuple(_args, "h",
1150 &item))
1151 return NULL;
1152 _err = GetMenuItemAttributes(_self->ob_itself,
1153 item,
1154 &outAttributes);
1155 if (_err != noErr) return PyMac_Error(_err);
1156 _res = Py_BuildValue("l",
1157 outAttributes);
1158 return _res;
1160 #endif
1162 #if TARGET_API_MAC_CARBON
1164 static PyObject *MenuObj_ChangeMenuItemAttributes(MenuObject *_self, PyObject *_args)
1166 PyObject *_res = NULL;
1167 OSStatus _err;
1168 MenuItemIndex item;
1169 MenuItemAttributes setTheseAttributes;
1170 MenuItemAttributes clearTheseAttributes;
1171 if (!PyArg_ParseTuple(_args, "hll",
1172 &item,
1173 &setTheseAttributes,
1174 &clearTheseAttributes))
1175 return NULL;
1176 _err = ChangeMenuItemAttributes(_self->ob_itself,
1177 item,
1178 setTheseAttributes,
1179 clearTheseAttributes);
1180 if (_err != noErr) return PyMac_Error(_err);
1181 Py_INCREF(Py_None);
1182 _res = Py_None;
1183 return _res;
1185 #endif
1187 #if TARGET_API_MAC_CARBON
1189 static PyObject *MenuObj_DisableAllMenuItems(MenuObject *_self, PyObject *_args)
1191 PyObject *_res = NULL;
1192 if (!PyArg_ParseTuple(_args, ""))
1193 return NULL;
1194 DisableAllMenuItems(_self->ob_itself);
1195 Py_INCREF(Py_None);
1196 _res = Py_None;
1197 return _res;
1199 #endif
1201 #if TARGET_API_MAC_CARBON
1203 static PyObject *MenuObj_EnableAllMenuItems(MenuObject *_self, PyObject *_args)
1205 PyObject *_res = NULL;
1206 if (!PyArg_ParseTuple(_args, ""))
1207 return NULL;
1208 EnableAllMenuItems(_self->ob_itself);
1209 Py_INCREF(Py_None);
1210 _res = Py_None;
1211 return _res;
1213 #endif
1215 #if TARGET_API_MAC_CARBON
1217 static PyObject *MenuObj_MenuHasEnabledItems(MenuObject *_self, PyObject *_args)
1219 PyObject *_res = NULL;
1220 Boolean _rv;
1221 if (!PyArg_ParseTuple(_args, ""))
1222 return NULL;
1223 _rv = MenuHasEnabledItems(_self->ob_itself);
1224 _res = Py_BuildValue("b",
1225 _rv);
1226 return _res;
1228 #endif
1230 #if TARGET_API_MAC_CARBON
1232 static PyObject *MenuObj_CountMenuItemsWithCommandID(MenuObject *_self, PyObject *_args)
1234 PyObject *_res = NULL;
1235 ItemCount _rv;
1236 MenuCommand commandID;
1237 if (!PyArg_ParseTuple(_args, "l",
1238 &commandID))
1239 return NULL;
1240 _rv = CountMenuItemsWithCommandID(_self->ob_itself,
1241 commandID);
1242 _res = Py_BuildValue("l",
1243 _rv);
1244 return _res;
1246 #endif
1248 #if TARGET_API_MAC_CARBON
1250 static PyObject *MenuObj_GetIndMenuItemWithCommandID(MenuObject *_self, PyObject *_args)
1252 PyObject *_res = NULL;
1253 OSStatus _err;
1254 MenuCommand commandID;
1255 UInt32 itemIndex;
1256 MenuHandle outMenu;
1257 MenuItemIndex outIndex;
1258 if (!PyArg_ParseTuple(_args, "ll",
1259 &commandID,
1260 &itemIndex))
1261 return NULL;
1262 _err = GetIndMenuItemWithCommandID(_self->ob_itself,
1263 commandID,
1264 itemIndex,
1265 &outMenu,
1266 &outIndex);
1267 if (_err != noErr) return PyMac_Error(_err);
1268 _res = Py_BuildValue("O&h",
1269 MenuObj_New, outMenu,
1270 outIndex);
1271 return _res;
1273 #endif
1275 #if TARGET_API_MAC_CARBON
1277 static PyObject *MenuObj_EnableMenuCommand(MenuObject *_self, PyObject *_args)
1279 PyObject *_res = NULL;
1280 MenuCommand commandID;
1281 if (!PyArg_ParseTuple(_args, "l",
1282 &commandID))
1283 return NULL;
1284 EnableMenuCommand(_self->ob_itself,
1285 commandID);
1286 Py_INCREF(Py_None);
1287 _res = Py_None;
1288 return _res;
1290 #endif
1292 #if TARGET_API_MAC_CARBON
1294 static PyObject *MenuObj_DisableMenuCommand(MenuObject *_self, PyObject *_args)
1296 PyObject *_res = NULL;
1297 MenuCommand commandID;
1298 if (!PyArg_ParseTuple(_args, "l",
1299 &commandID))
1300 return NULL;
1301 DisableMenuCommand(_self->ob_itself,
1302 commandID);
1303 Py_INCREF(Py_None);
1304 _res = Py_None;
1305 return _res;
1307 #endif
1309 #if TARGET_API_MAC_CARBON
1311 static PyObject *MenuObj_IsMenuCommandEnabled(MenuObject *_self, PyObject *_args)
1313 PyObject *_res = NULL;
1314 Boolean _rv;
1315 MenuCommand commandID;
1316 if (!PyArg_ParseTuple(_args, "l",
1317 &commandID))
1318 return NULL;
1319 _rv = IsMenuCommandEnabled(_self->ob_itself,
1320 commandID);
1321 _res = Py_BuildValue("b",
1322 _rv);
1323 return _res;
1325 #endif
1327 #if TARGET_API_MAC_CARBON
1329 static PyObject *MenuObj_GetMenuCommandPropertySize(MenuObject *_self, PyObject *_args)
1331 PyObject *_res = NULL;
1332 OSStatus _err;
1333 MenuCommand commandID;
1334 OSType propertyCreator;
1335 OSType propertyTag;
1336 ByteCount size;
1337 if (!PyArg_ParseTuple(_args, "lO&O&",
1338 &commandID,
1339 PyMac_GetOSType, &propertyCreator,
1340 PyMac_GetOSType, &propertyTag))
1341 return NULL;
1342 _err = GetMenuCommandPropertySize(_self->ob_itself,
1343 commandID,
1344 propertyCreator,
1345 propertyTag,
1346 &size);
1347 if (_err != noErr) return PyMac_Error(_err);
1348 _res = Py_BuildValue("l",
1349 size);
1350 return _res;
1352 #endif
1354 #if TARGET_API_MAC_CARBON
1356 static PyObject *MenuObj_RemoveMenuCommandProperty(MenuObject *_self, PyObject *_args)
1358 PyObject *_res = NULL;
1359 OSStatus _err;
1360 MenuCommand commandID;
1361 OSType propertyCreator;
1362 OSType propertyTag;
1363 if (!PyArg_ParseTuple(_args, "lO&O&",
1364 &commandID,
1365 PyMac_GetOSType, &propertyCreator,
1366 PyMac_GetOSType, &propertyTag))
1367 return NULL;
1368 _err = RemoveMenuCommandProperty(_self->ob_itself,
1369 commandID,
1370 propertyCreator,
1371 propertyTag);
1372 if (_err != noErr) return PyMac_Error(_err);
1373 Py_INCREF(Py_None);
1374 _res = Py_None;
1375 return _res;
1377 #endif
1379 #if TARGET_API_MAC_CARBON
1381 static PyObject *MenuObj_CreateStandardFontMenu(MenuObject *_self, PyObject *_args)
1383 PyObject *_res = NULL;
1384 OSStatus _err;
1385 MenuItemIndex afterItem;
1386 MenuID firstHierMenuID;
1387 OptionBits options;
1388 ItemCount outHierMenuCount;
1389 if (!PyArg_ParseTuple(_args, "hhl",
1390 &afterItem,
1391 &firstHierMenuID,
1392 &options))
1393 return NULL;
1394 _err = CreateStandardFontMenu(_self->ob_itself,
1395 afterItem,
1396 firstHierMenuID,
1397 options,
1398 &outHierMenuCount);
1399 if (_err != noErr) return PyMac_Error(_err);
1400 _res = Py_BuildValue("l",
1401 outHierMenuCount);
1402 return _res;
1404 #endif
1406 #if TARGET_API_MAC_CARBON
1408 static PyObject *MenuObj_UpdateStandardFontMenu(MenuObject *_self, PyObject *_args)
1410 PyObject *_res = NULL;
1411 OSStatus _err;
1412 ItemCount outHierMenuCount;
1413 if (!PyArg_ParseTuple(_args, ""))
1414 return NULL;
1415 _err = UpdateStandardFontMenu(_self->ob_itself,
1416 &outHierMenuCount);
1417 if (_err != noErr) return PyMac_Error(_err);
1418 _res = Py_BuildValue("l",
1419 outHierMenuCount);
1420 return _res;
1422 #endif
1424 #if TARGET_API_MAC_CARBON
1426 static PyObject *MenuObj_GetFontFamilyFromMenuSelection(MenuObject *_self, PyObject *_args)
1428 PyObject *_res = NULL;
1429 OSStatus _err;
1430 MenuItemIndex item;
1431 FMFontFamily outFontFamily;
1432 FMFontStyle outStyle;
1433 if (!PyArg_ParseTuple(_args, "h",
1434 &item))
1435 return NULL;
1436 _err = GetFontFamilyFromMenuSelection(_self->ob_itself,
1437 item,
1438 &outFontFamily,
1439 &outStyle);
1440 if (_err != noErr) return PyMac_Error(_err);
1441 _res = Py_BuildValue("hh",
1442 outFontFamily,
1443 outStyle);
1444 return _res;
1446 #endif
1448 static PyObject *MenuObj_GetMenuID(MenuObject *_self, PyObject *_args)
1450 PyObject *_res = NULL;
1451 MenuID _rv;
1452 if (!PyArg_ParseTuple(_args, ""))
1453 return NULL;
1454 _rv = GetMenuID(_self->ob_itself);
1455 _res = Py_BuildValue("h",
1456 _rv);
1457 return _res;
1460 static PyObject *MenuObj_GetMenuWidth(MenuObject *_self, PyObject *_args)
1462 PyObject *_res = NULL;
1463 SInt16 _rv;
1464 if (!PyArg_ParseTuple(_args, ""))
1465 return NULL;
1466 _rv = GetMenuWidth(_self->ob_itself);
1467 _res = Py_BuildValue("h",
1468 _rv);
1469 return _res;
1472 static PyObject *MenuObj_GetMenuHeight(MenuObject *_self, PyObject *_args)
1474 PyObject *_res = NULL;
1475 SInt16 _rv;
1476 if (!PyArg_ParseTuple(_args, ""))
1477 return NULL;
1478 _rv = GetMenuHeight(_self->ob_itself);
1479 _res = Py_BuildValue("h",
1480 _rv);
1481 return _res;
1484 static PyObject *MenuObj_SetMenuID(MenuObject *_self, PyObject *_args)
1486 PyObject *_res = NULL;
1487 MenuID menuID;
1488 if (!PyArg_ParseTuple(_args, "h",
1489 &menuID))
1490 return NULL;
1491 SetMenuID(_self->ob_itself,
1492 menuID);
1493 Py_INCREF(Py_None);
1494 _res = Py_None;
1495 return _res;
1498 static PyObject *MenuObj_SetMenuWidth(MenuObject *_self, PyObject *_args)
1500 PyObject *_res = NULL;
1501 SInt16 width;
1502 if (!PyArg_ParseTuple(_args, "h",
1503 &width))
1504 return NULL;
1505 SetMenuWidth(_self->ob_itself,
1506 width);
1507 Py_INCREF(Py_None);
1508 _res = Py_None;
1509 return _res;
1512 static PyObject *MenuObj_SetMenuHeight(MenuObject *_self, PyObject *_args)
1514 PyObject *_res = NULL;
1515 SInt16 height;
1516 if (!PyArg_ParseTuple(_args, "h",
1517 &height))
1518 return NULL;
1519 SetMenuHeight(_self->ob_itself,
1520 height);
1521 Py_INCREF(Py_None);
1522 _res = Py_None;
1523 return _res;
1526 static PyObject *MenuObj_as_Resource(MenuObject *_self, PyObject *_args)
1528 PyObject *_res = NULL;
1529 Handle _rv;
1530 if (!PyArg_ParseTuple(_args, ""))
1531 return NULL;
1532 _rv = as_Resource(_self->ob_itself);
1533 _res = Py_BuildValue("O&",
1534 ResObj_New, _rv);
1535 return _res;
1538 static PyObject *MenuObj_AppendMenu(MenuObject *_self, PyObject *_args)
1540 PyObject *_res = NULL;
1541 Str255 data;
1542 if (!PyArg_ParseTuple(_args, "O&",
1543 PyMac_GetStr255, data))
1544 return NULL;
1545 AppendMenu(_self->ob_itself,
1546 data);
1547 Py_INCREF(Py_None);
1548 _res = Py_None;
1549 return _res;
1552 static PyObject *MenuObj_InsertMenu(MenuObject *_self, PyObject *_args)
1554 PyObject *_res = NULL;
1555 short beforeID;
1556 if (!PyArg_ParseTuple(_args, "h",
1557 &beforeID))
1558 return NULL;
1559 InsertMenu(_self->ob_itself,
1560 beforeID);
1561 Py_INCREF(Py_None);
1562 _res = Py_None;
1563 return _res;
1566 static PyObject *MenuObj_InsertMenuItem(MenuObject *_self, PyObject *_args)
1568 PyObject *_res = NULL;
1569 Str255 itemString;
1570 short afterItem;
1571 if (!PyArg_ParseTuple(_args, "O&h",
1572 PyMac_GetStr255, itemString,
1573 &afterItem))
1574 return NULL;
1575 InsertMenuItem(_self->ob_itself,
1576 itemString,
1577 afterItem);
1578 Py_INCREF(Py_None);
1579 _res = Py_None;
1580 return _res;
1583 static PyObject *MenuObj_EnableMenuItem(MenuObject *_self, PyObject *_args)
1585 PyObject *_res = NULL;
1586 UInt16 item;
1587 if (!PyArg_ParseTuple(_args, "H",
1588 &item))
1589 return NULL;
1590 EnableMenuItem(_self->ob_itself,
1591 item);
1592 Py_INCREF(Py_None);
1593 _res = Py_None;
1594 return _res;
1597 static PyObject *MenuObj_CheckMenuItem(MenuObject *_self, PyObject *_args)
1599 PyObject *_res = NULL;
1600 short item;
1601 Boolean checked;
1602 if (!PyArg_ParseTuple(_args, "hb",
1603 &item,
1604 &checked))
1605 return NULL;
1606 CheckMenuItem(_self->ob_itself,
1607 item,
1608 checked);
1609 Py_INCREF(Py_None);
1610 _res = Py_None;
1611 return _res;
1614 static PyMethodDef MenuObj_methods[] = {
1615 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1616 "() -> None"},
1617 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1618 "() -> None"},
1619 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1620 "() -> (short _rv)"},
1622 #if !TARGET_API_MAC_CARBON
1623 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1624 "() -> (short _rv)"},
1625 #endif
1626 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1627 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1628 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1629 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1630 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1631 "() -> (Boolean _rv)"},
1632 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1633 "(Boolean excludesMark) -> None"},
1634 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
1635 "(Str255 data) -> None"},
1636 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1637 "(ResType theType, short afterItem) -> None"},
1638 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1639 "(ResType theType) -> None"},
1640 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
1641 "(Str255 itemString, short afterItem) -> None"},
1642 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
1643 "(short item) -> None"},
1644 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1645 "(short afterItem, short scriptFilter) -> None"},
1646 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1647 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1648 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1649 "(Str255 inString) -> None"},
1650 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
1651 "(Str255 inString, MenuItemIndex afterItem) -> None"},
1652 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1653 "(short top, short left, short popUpItem) -> (long _rv)"},
1654 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
1655 "(MenuID beforeID) -> None"},
1656 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1657 "(short item, Boolean checked) -> None"},
1659 #if !TARGET_API_MAC_CARBON
1660 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1661 "(short item, Boolean checked) -> None"},
1662 #endif
1663 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
1664 "(short item, Str255 itemString) -> None"},
1665 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
1666 "(short item) -> (Str255 itemString)"},
1667 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
1668 "(short item, CharParameter markChar) -> None"},
1669 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
1670 "(short item) -> (CharParameter markChar)"},
1671 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1672 "(short item, CharParameter cmdChar) -> None"},
1673 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1674 "(short item) -> (CharParameter cmdChar)"},
1675 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1676 "(short item, short iconIndex) -> None"},
1677 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1678 "(short item) -> (short iconIndex)"},
1679 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
1680 "(short item, StyleParameter chStyle) -> None"},
1681 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
1682 "(short item) -> (Style chStyle)"},
1684 #if !TARGET_API_MAC_CARBON
1685 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1686 "(short item) -> None"},
1687 #endif
1689 #if !TARGET_API_MAC_CARBON
1690 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1691 "(short item) -> None"},
1692 #endif
1693 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
1694 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
1695 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
1696 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
1697 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1698 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1699 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1700 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1701 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1702 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1703 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1704 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1705 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1706 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1707 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1708 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1709 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
1710 "(SInt16 inItem, MenuID inHierID) -> None"},
1711 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
1712 "(SInt16 inItem) -> (MenuID outHierID)"},
1713 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1714 "(SInt16 inItem, SInt16 inFontID) -> None"},
1715 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1716 "(SInt16 inItem) -> (SInt16 outFontID)"},
1717 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1718 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1719 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1720 "(SInt16 inItem) -> (UInt32 outRefCon)"},
1722 #if !TARGET_API_MAC_CARBON
1723 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1724 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
1725 #endif
1727 #if !TARGET_API_MAC_CARBON
1728 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1729 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
1730 #endif
1731 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1732 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1733 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1734 "(SInt16 inItem) -> (SInt16 outGlyph)"},
1735 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
1736 "(MenuItemIndex item) -> None"},
1737 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
1738 "(MenuItemIndex item) -> None"},
1739 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
1740 "(MenuItemIndex item) -> (Boolean _rv)"},
1741 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
1742 "(MenuItemIndex item) -> None"},
1743 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
1744 "(MenuItemIndex item) -> None"},
1745 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
1746 "(MenuItemIndex item) -> (Boolean _rv)"},
1748 #if TARGET_API_MAC_CARBON
1749 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1750 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1751 #endif
1753 #if TARGET_API_MAC_CARBON
1754 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1755 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1756 #endif
1758 #if TARGET_API_MAC_CARBON
1759 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1760 "() -> (MenuAttributes outAttributes)"},
1761 #endif
1763 #if TARGET_API_MAC_CARBON
1764 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1765 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1766 #endif
1768 #if TARGET_API_MAC_CARBON
1769 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1770 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1771 #endif
1773 #if TARGET_API_MAC_CARBON
1774 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1775 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1776 #endif
1778 #if TARGET_API_MAC_CARBON
1779 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1780 "() -> None"},
1781 #endif
1783 #if TARGET_API_MAC_CARBON
1784 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1785 "() -> None"},
1786 #endif
1788 #if TARGET_API_MAC_CARBON
1789 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1790 "() -> (Boolean _rv)"},
1791 #endif
1793 #if TARGET_API_MAC_CARBON
1794 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1795 "(MenuCommand commandID) -> (ItemCount _rv)"},
1796 #endif
1798 #if TARGET_API_MAC_CARBON
1799 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1800 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1801 #endif
1803 #if TARGET_API_MAC_CARBON
1804 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1805 "(MenuCommand commandID) -> None"},
1806 #endif
1808 #if TARGET_API_MAC_CARBON
1809 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1810 "(MenuCommand commandID) -> None"},
1811 #endif
1813 #if TARGET_API_MAC_CARBON
1814 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1815 "(MenuCommand commandID) -> (Boolean _rv)"},
1816 #endif
1818 #if TARGET_API_MAC_CARBON
1819 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1820 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1821 #endif
1823 #if TARGET_API_MAC_CARBON
1824 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
1825 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1826 #endif
1828 #if TARGET_API_MAC_CARBON
1829 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
1830 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1831 #endif
1833 #if TARGET_API_MAC_CARBON
1834 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
1835 "() -> (ItemCount outHierMenuCount)"},
1836 #endif
1838 #if TARGET_API_MAC_CARBON
1839 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
1840 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
1841 #endif
1842 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
1843 "() -> (MenuID _rv)"},
1844 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
1845 "() -> (SInt16 _rv)"},
1846 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
1847 "() -> (SInt16 _rv)"},
1848 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
1849 "(MenuID menuID) -> None"},
1850 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
1851 "(SInt16 width) -> None"},
1852 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
1853 "(SInt16 height) -> None"},
1854 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
1855 "() -> (Handle _rv)"},
1856 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
1857 "(Str255 data) -> None"},
1858 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
1859 "(short beforeID) -> None"},
1860 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
1861 "(Str255 itemString, short afterItem) -> None"},
1862 {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1,
1863 "(UInt16 item) -> None"},
1864 {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1,
1865 "(short item, Boolean checked) -> None"},
1866 {NULL, NULL, 0}
1869 PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
1871 static PyObject *MenuObj_getattr(MenuObject *self, char *name)
1873 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
1876 #define MenuObj_setattr NULL
1878 #define MenuObj_compare NULL
1880 #define MenuObj_repr NULL
1882 #define MenuObj_hash NULL
1884 PyTypeObject Menu_Type = {
1885 PyObject_HEAD_INIT(&PyType_Type)
1886 0, /*ob_size*/
1887 "Menu", /*tp_name*/
1888 sizeof(MenuObject), /*tp_basicsize*/
1889 0, /*tp_itemsize*/
1890 /* methods */
1891 (destructor) MenuObj_dealloc, /*tp_dealloc*/
1892 0, /*tp_print*/
1893 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
1894 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
1895 (cmpfunc) MenuObj_compare, /*tp_compare*/
1896 (reprfunc) MenuObj_repr, /*tp_repr*/
1897 (PyNumberMethods *)0, /* tp_as_number */
1898 (PySequenceMethods *)0, /* tp_as_sequence */
1899 (PyMappingMethods *)0, /* tp_as_mapping */
1900 (hashfunc) MenuObj_hash, /*tp_hash*/
1903 /* ---------------------- End object type Menu ---------------------- */
1906 #if !TARGET_API_MAC_CARBON
1908 static PyObject *Menu_InitProcMenu(PyObject *_self, PyObject *_args)
1910 PyObject *_res = NULL;
1911 short resID;
1912 if (!PyArg_ParseTuple(_args, "h",
1913 &resID))
1914 return NULL;
1915 InitProcMenu(resID);
1916 Py_INCREF(Py_None);
1917 _res = Py_None;
1918 return _res;
1920 #endif
1922 #if !TARGET_API_MAC_CARBON
1924 static PyObject *Menu_InitMenus(PyObject *_self, PyObject *_args)
1926 PyObject *_res = NULL;
1927 if (!PyArg_ParseTuple(_args, ""))
1928 return NULL;
1929 InitMenus();
1930 Py_INCREF(Py_None);
1931 _res = Py_None;
1932 return _res;
1934 #endif
1936 static PyObject *Menu_NewMenu(PyObject *_self, PyObject *_args)
1938 PyObject *_res = NULL;
1939 MenuHandle _rv;
1940 MenuID menuID;
1941 Str255 menuTitle;
1942 if (!PyArg_ParseTuple(_args, "hO&",
1943 &menuID,
1944 PyMac_GetStr255, menuTitle))
1945 return NULL;
1946 _rv = NewMenu(menuID,
1947 menuTitle);
1948 _res = Py_BuildValue("O&",
1949 MenuObj_New, _rv);
1950 return _res;
1953 static PyObject *Menu_MacGetMenu(PyObject *_self, PyObject *_args)
1955 PyObject *_res = NULL;
1956 MenuHandle _rv;
1957 short resourceID;
1958 if (!PyArg_ParseTuple(_args, "h",
1959 &resourceID))
1960 return NULL;
1961 _rv = MacGetMenu(resourceID);
1962 _res = Py_BuildValue("O&",
1963 MenuObj_New, _rv);
1964 return _res;
1967 #if TARGET_API_MAC_CARBON
1969 static PyObject *Menu_CreateNewMenu(PyObject *_self, PyObject *_args)
1971 PyObject *_res = NULL;
1972 OSStatus _err;
1973 MenuID menuID;
1974 MenuAttributes menuAttributes;
1975 MenuHandle outMenuRef;
1976 if (!PyArg_ParseTuple(_args, "hl",
1977 &menuID,
1978 &menuAttributes))
1979 return NULL;
1980 _err = CreateNewMenu(menuID,
1981 menuAttributes,
1982 &outMenuRef);
1983 if (_err != noErr) return PyMac_Error(_err);
1984 _res = Py_BuildValue("O&",
1985 MenuObj_New, outMenuRef);
1986 return _res;
1988 #endif
1990 static PyObject *Menu_MenuKey(PyObject *_self, PyObject *_args)
1992 PyObject *_res = NULL;
1993 long _rv;
1994 CharParameter ch;
1995 if (!PyArg_ParseTuple(_args, "h",
1996 &ch))
1997 return NULL;
1998 _rv = MenuKey(ch);
1999 _res = Py_BuildValue("l",
2000 _rv);
2001 return _res;
2004 static PyObject *Menu_MenuSelect(PyObject *_self, PyObject *_args)
2006 PyObject *_res = NULL;
2007 long _rv;
2008 Point startPt;
2009 if (!PyArg_ParseTuple(_args, "O&",
2010 PyMac_GetPoint, &startPt))
2011 return NULL;
2012 _rv = MenuSelect(startPt);
2013 _res = Py_BuildValue("l",
2014 _rv);
2015 return _res;
2018 static PyObject *Menu_MenuChoice(PyObject *_self, PyObject *_args)
2020 PyObject *_res = NULL;
2021 long _rv;
2022 if (!PyArg_ParseTuple(_args, ""))
2023 return NULL;
2024 _rv = MenuChoice();
2025 _res = Py_BuildValue("l",
2026 _rv);
2027 return _res;
2030 static PyObject *Menu_MenuEvent(PyObject *_self, PyObject *_args)
2032 PyObject *_res = NULL;
2033 UInt32 _rv;
2034 EventRecord inEvent;
2035 if (!PyArg_ParseTuple(_args, "O&",
2036 PyMac_GetEventRecord, &inEvent))
2037 return NULL;
2038 _rv = MenuEvent(&inEvent);
2039 _res = Py_BuildValue("l",
2040 _rv);
2041 return _res;
2044 static PyObject *Menu_GetMBarHeight(PyObject *_self, PyObject *_args)
2046 PyObject *_res = NULL;
2047 short _rv;
2048 if (!PyArg_ParseTuple(_args, ""))
2049 return NULL;
2050 _rv = GetMBarHeight();
2051 _res = Py_BuildValue("h",
2052 _rv);
2053 return _res;
2056 static PyObject *Menu_MacDrawMenuBar(PyObject *_self, PyObject *_args)
2058 PyObject *_res = NULL;
2059 if (!PyArg_ParseTuple(_args, ""))
2060 return NULL;
2061 MacDrawMenuBar();
2062 Py_INCREF(Py_None);
2063 _res = Py_None;
2064 return _res;
2067 static PyObject *Menu_InvalMenuBar(PyObject *_self, PyObject *_args)
2069 PyObject *_res = NULL;
2070 if (!PyArg_ParseTuple(_args, ""))
2071 return NULL;
2072 InvalMenuBar();
2073 Py_INCREF(Py_None);
2074 _res = Py_None;
2075 return _res;
2078 static PyObject *Menu_HiliteMenu(PyObject *_self, PyObject *_args)
2080 PyObject *_res = NULL;
2081 MenuID menuID;
2082 if (!PyArg_ParseTuple(_args, "h",
2083 &menuID))
2084 return NULL;
2085 HiliteMenu(menuID);
2086 Py_INCREF(Py_None);
2087 _res = Py_None;
2088 return _res;
2091 static PyObject *Menu_GetNewMBar(PyObject *_self, PyObject *_args)
2093 PyObject *_res = NULL;
2094 MenuBarHandle _rv;
2095 short menuBarID;
2096 if (!PyArg_ParseTuple(_args, "h",
2097 &menuBarID))
2098 return NULL;
2099 _rv = GetNewMBar(menuBarID);
2100 _res = Py_BuildValue("O&",
2101 ResObj_New, _rv);
2102 return _res;
2105 static PyObject *Menu_GetMenuBar(PyObject *_self, PyObject *_args)
2107 PyObject *_res = NULL;
2108 MenuBarHandle _rv;
2109 if (!PyArg_ParseTuple(_args, ""))
2110 return NULL;
2111 _rv = GetMenuBar();
2112 _res = Py_BuildValue("O&",
2113 ResObj_New, _rv);
2114 return _res;
2117 static PyObject *Menu_SetMenuBar(PyObject *_self, PyObject *_args)
2119 PyObject *_res = NULL;
2120 MenuBarHandle mbar;
2121 if (!PyArg_ParseTuple(_args, "O&",
2122 ResObj_Convert, &mbar))
2123 return NULL;
2124 SetMenuBar(mbar);
2125 Py_INCREF(Py_None);
2126 _res = Py_None;
2127 return _res;
2130 #if TARGET_API_MAC_CARBON
2132 static PyObject *Menu_DuplicateMenuBar(PyObject *_self, PyObject *_args)
2134 PyObject *_res = NULL;
2135 OSStatus _err;
2136 MenuBarHandle mbar;
2137 MenuBarHandle outBar;
2138 if (!PyArg_ParseTuple(_args, "O&",
2139 ResObj_Convert, &mbar))
2140 return NULL;
2141 _err = DuplicateMenuBar(mbar,
2142 &outBar);
2143 if (_err != noErr) return PyMac_Error(_err);
2144 _res = Py_BuildValue("O&",
2145 ResObj_New, outBar);
2146 return _res;
2148 #endif
2150 #if TARGET_API_MAC_CARBON
2152 static PyObject *Menu_DisposeMenuBar(PyObject *_self, PyObject *_args)
2154 PyObject *_res = NULL;
2155 OSStatus _err;
2156 MenuBarHandle mbar;
2157 if (!PyArg_ParseTuple(_args, "O&",
2158 ResObj_Convert, &mbar))
2159 return NULL;
2160 _err = DisposeMenuBar(mbar);
2161 if (_err != noErr) return PyMac_Error(_err);
2162 Py_INCREF(Py_None);
2163 _res = Py_None;
2164 return _res;
2166 #endif
2168 static PyObject *Menu_GetMenuHandle(PyObject *_self, PyObject *_args)
2170 PyObject *_res = NULL;
2171 MenuHandle _rv;
2172 MenuID menuID;
2173 if (!PyArg_ParseTuple(_args, "h",
2174 &menuID))
2175 return NULL;
2176 _rv = GetMenuHandle(menuID);
2177 _res = Py_BuildValue("O&",
2178 MenuObj_New, _rv);
2179 return _res;
2182 static PyObject *Menu_MacDeleteMenu(PyObject *_self, PyObject *_args)
2184 PyObject *_res = NULL;
2185 MenuID menuID;
2186 if (!PyArg_ParseTuple(_args, "h",
2187 &menuID))
2188 return NULL;
2189 MacDeleteMenu(menuID);
2190 Py_INCREF(Py_None);
2191 _res = Py_None;
2192 return _res;
2195 static PyObject *Menu_ClearMenuBar(PyObject *_self, PyObject *_args)
2197 PyObject *_res = NULL;
2198 if (!PyArg_ParseTuple(_args, ""))
2199 return NULL;
2200 ClearMenuBar();
2201 Py_INCREF(Py_None);
2202 _res = Py_None;
2203 return _res;
2206 static PyObject *Menu_SetMenuFlashCount(PyObject *_self, PyObject *_args)
2208 PyObject *_res = NULL;
2209 short count;
2210 if (!PyArg_ParseTuple(_args, "h",
2211 &count))
2212 return NULL;
2213 SetMenuFlashCount(count);
2214 Py_INCREF(Py_None);
2215 _res = Py_None;
2216 return _res;
2219 #if !TARGET_API_MAC_CARBON
2221 static PyObject *Menu_SetMenuFlash(PyObject *_self, PyObject *_args)
2223 PyObject *_res = NULL;
2224 short count;
2225 if (!PyArg_ParseTuple(_args, "h",
2226 &count))
2227 return NULL;
2228 SetMenuFlash(count);
2229 Py_INCREF(Py_None);
2230 _res = Py_None;
2231 return _res;
2233 #endif
2235 static PyObject *Menu_FlashMenuBar(PyObject *_self, PyObject *_args)
2237 PyObject *_res = NULL;
2238 MenuID menuID;
2239 if (!PyArg_ParseTuple(_args, "h",
2240 &menuID))
2241 return NULL;
2242 FlashMenuBar(menuID);
2243 Py_INCREF(Py_None);
2244 _res = Py_None;
2245 return _res;
2248 #if !TARGET_API_MAC_CARBON
2250 static PyObject *Menu_SystemEdit(PyObject *_self, PyObject *_args)
2252 PyObject *_res = NULL;
2253 Boolean _rv;
2254 short editCmd;
2255 if (!PyArg_ParseTuple(_args, "h",
2256 &editCmd))
2257 return NULL;
2258 _rv = SystemEdit(editCmd);
2259 _res = Py_BuildValue("b",
2260 _rv);
2261 return _res;
2263 #endif
2265 #if !TARGET_API_MAC_CARBON
2267 static PyObject *Menu_SystemMenu(PyObject *_self, PyObject *_args)
2269 PyObject *_res = NULL;
2270 long menuResult;
2271 if (!PyArg_ParseTuple(_args, "l",
2272 &menuResult))
2273 return NULL;
2274 SystemMenu(menuResult);
2275 Py_INCREF(Py_None);
2276 _res = Py_None;
2277 return _res;
2279 #endif
2281 static PyObject *Menu_IsMenuBarVisible(PyObject *_self, PyObject *_args)
2283 PyObject *_res = NULL;
2284 Boolean _rv;
2285 if (!PyArg_ParseTuple(_args, ""))
2286 return NULL;
2287 _rv = IsMenuBarVisible();
2288 _res = Py_BuildValue("b",
2289 _rv);
2290 return _res;
2293 static PyObject *Menu_ShowMenuBar(PyObject *_self, PyObject *_args)
2295 PyObject *_res = NULL;
2296 if (!PyArg_ParseTuple(_args, ""))
2297 return NULL;
2298 ShowMenuBar();
2299 Py_INCREF(Py_None);
2300 _res = Py_None;
2301 return _res;
2304 static PyObject *Menu_HideMenuBar(PyObject *_self, PyObject *_args)
2306 PyObject *_res = NULL;
2307 if (!PyArg_ParseTuple(_args, ""))
2308 return NULL;
2309 HideMenuBar();
2310 Py_INCREF(Py_None);
2311 _res = Py_None;
2312 return _res;
2315 static PyObject *Menu_DeleteMCEntries(PyObject *_self, PyObject *_args)
2317 PyObject *_res = NULL;
2318 MenuID menuID;
2319 short menuItem;
2320 if (!PyArg_ParseTuple(_args, "hh",
2321 &menuID,
2322 &menuItem))
2323 return NULL;
2324 DeleteMCEntries(menuID,
2325 menuItem);
2326 Py_INCREF(Py_None);
2327 _res = Py_None;
2328 return _res;
2331 static PyObject *Menu_InitContextualMenus(PyObject *_self, PyObject *_args)
2333 PyObject *_res = NULL;
2334 OSStatus _err;
2335 if (!PyArg_ParseTuple(_args, ""))
2336 return NULL;
2337 _err = InitContextualMenus();
2338 if (_err != noErr) return PyMac_Error(_err);
2339 Py_INCREF(Py_None);
2340 _res = Py_None;
2341 return _res;
2344 static PyObject *Menu_IsShowContextualMenuClick(PyObject *_self, PyObject *_args)
2346 PyObject *_res = NULL;
2347 Boolean _rv;
2348 EventRecord inEvent;
2349 if (!PyArg_ParseTuple(_args, "O&",
2350 PyMac_GetEventRecord, &inEvent))
2351 return NULL;
2352 _rv = IsShowContextualMenuClick(&inEvent);
2353 _res = Py_BuildValue("b",
2354 _rv);
2355 return _res;
2358 #if !TARGET_API_MAC_CARBON
2360 static PyObject *Menu_OpenDeskAcc(PyObject *_self, PyObject *_args)
2362 PyObject *_res = NULL;
2363 Str255 name;
2364 if (!PyArg_ParseTuple(_args, "O&",
2365 PyMac_GetStr255, name))
2366 return NULL;
2367 OpenDeskAcc(name);
2368 Py_INCREF(Py_None);
2369 _res = Py_None;
2370 return _res;
2372 #endif
2374 static PyObject *Menu_as_Menu(PyObject *_self, PyObject *_args)
2376 PyObject *_res = NULL;
2377 MenuHandle _rv;
2378 Handle h;
2379 if (!PyArg_ParseTuple(_args, "O&",
2380 ResObj_Convert, &h))
2381 return NULL;
2382 _rv = as_Menu(h);
2383 _res = Py_BuildValue("O&",
2384 MenuObj_New, _rv);
2385 return _res;
2388 static PyObject *Menu_GetMenu(PyObject *_self, PyObject *_args)
2390 PyObject *_res = NULL;
2391 MenuHandle _rv;
2392 short resourceID;
2393 if (!PyArg_ParseTuple(_args, "h",
2394 &resourceID))
2395 return NULL;
2396 _rv = GetMenu(resourceID);
2397 _res = Py_BuildValue("O&",
2398 MenuObj_New, _rv);
2399 return _res;
2402 static PyObject *Menu_DeleteMenu(PyObject *_self, PyObject *_args)
2404 PyObject *_res = NULL;
2405 short menuID;
2406 if (!PyArg_ParseTuple(_args, "h",
2407 &menuID))
2408 return NULL;
2409 DeleteMenu(menuID);
2410 Py_INCREF(Py_None);
2411 _res = Py_None;
2412 return _res;
2415 static PyObject *Menu_DrawMenuBar(PyObject *_self, PyObject *_args)
2417 PyObject *_res = NULL;
2418 if (!PyArg_ParseTuple(_args, ""))
2419 return NULL;
2420 DrawMenuBar();
2421 Py_INCREF(Py_None);
2422 _res = Py_None;
2423 return _res;
2426 static PyMethodDef Menu_methods[] = {
2428 #if !TARGET_API_MAC_CARBON
2429 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2430 "(short resID) -> None"},
2431 #endif
2433 #if !TARGET_API_MAC_CARBON
2434 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2435 "() -> None"},
2436 #endif
2437 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
2438 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
2439 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
2440 "(short resourceID) -> (MenuHandle _rv)"},
2442 #if TARGET_API_MAC_CARBON
2443 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2444 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2445 #endif
2446 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
2447 "(CharParameter ch) -> (long _rv)"},
2448 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2449 "(Point startPt) -> (long _rv)"},
2450 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2451 "() -> (long _rv)"},
2452 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2453 "(EventRecord inEvent) -> (UInt32 _rv)"},
2454 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2455 "() -> (short _rv)"},
2456 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
2457 "() -> None"},
2458 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2459 "() -> None"},
2460 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
2461 "(MenuID menuID) -> None"},
2462 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
2463 "(short menuBarID) -> (MenuBarHandle _rv)"},
2464 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
2465 "() -> (MenuBarHandle _rv)"},
2466 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
2467 "(MenuBarHandle mbar) -> None"},
2469 #if TARGET_API_MAC_CARBON
2470 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2471 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2472 #endif
2474 #if TARGET_API_MAC_CARBON
2475 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2476 "(MenuBarHandle mbar) -> None"},
2477 #endif
2478 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
2479 "(MenuID menuID) -> (MenuHandle _rv)"},
2480 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
2481 "(MenuID menuID) -> None"},
2482 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2483 "() -> None"},
2484 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2485 "(short count) -> None"},
2487 #if !TARGET_API_MAC_CARBON
2488 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2489 "(short count) -> None"},
2490 #endif
2491 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
2492 "(MenuID menuID) -> None"},
2494 #if !TARGET_API_MAC_CARBON
2495 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2496 "(short editCmd) -> (Boolean _rv)"},
2497 #endif
2499 #if !TARGET_API_MAC_CARBON
2500 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2501 "(long menuResult) -> None"},
2502 #endif
2503 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2504 "() -> (Boolean _rv)"},
2505 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2506 "() -> None"},
2507 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2508 "() -> None"},
2509 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
2510 "(MenuID menuID, short menuItem) -> None"},
2511 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2512 "() -> None"},
2513 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2514 "(EventRecord inEvent) -> (Boolean _rv)"},
2516 #if !TARGET_API_MAC_CARBON
2517 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2518 "(Str255 name) -> None"},
2519 #endif
2520 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2521 "(Handle h) -> (MenuHandle _rv)"},
2522 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2523 "(short resourceID) -> (MenuHandle _rv)"},
2524 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2525 "(short menuID) -> None"},
2526 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2527 "() -> None"},
2528 {NULL, NULL, 0}
2534 void initMenu(void)
2536 PyObject *m;
2537 PyObject *d;
2541 PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuHandle, MenuObj_New);
2542 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert);
2545 m = Py_InitModule("Menu", Menu_methods);
2546 d = PyModule_GetDict(m);
2547 Menu_Error = PyMac_GetOSErrException();
2548 if (Menu_Error == NULL ||
2549 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
2550 return;
2551 Menu_Type.ob_type = &PyType_Type;
2552 Py_INCREF(&Menu_Type);
2553 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2554 Py_FatalError("can't initialize MenuType");
2557 /* ======================== End module Menu ========================= */