blob: f965586252f697acc25c1c0b5dfe4679522a35de [file] [log] [blame]
Guido van Rossum17448e21995-01-30 11:53:55 +00001
2/* ========================== Module Menu =========================== */
3
4#include "Python.h"
5
6
7
Guido van Rossum17448e21995-01-30 11:53:55 +00008#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +00009#include "pymactoolbox.h"
Guido van Rossum17448e21995-01-30 11:53:55 +000010
Guido van Rossum86c3af71995-03-19 22:42:51 +000011#include <Devices.h> /* Defines OpenDeskAcc in universal headers */
Guido van Rossum17448e21995-01-30 11:53:55 +000012#include <Menus.h>
13
Jack Jansen0e04eec2001-05-17 21:58:34 +000014#ifdef USE_TOOLBOX_OBJECT_GLUE
15
16extern PyObject *_MenuObj_New(MenuHandle);
17extern int _MenuObj_Convert(PyObject *, MenuHandle *);
18
19#define MenuObj_New _MenuObj_New
20#define MenuObj_Convert _MenuObj_Convert
21#endif
22
Jack Jansenf7d5aa62000-12-10 23:43:49 +000023#if !ACCESSOR_CALLS_ARE_FUNCTIONS
24#define GetMenuID(menu) ((*(menu))->menuID)
25#define GetMenuWidth(menu) ((*(menu))->menuWidth)
26#define GetMenuHeight(menu) ((*(menu))->menuHeight)
27
28#define SetMenuID(menu, id) ((*(menu))->menuID = (id))
29#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
30#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
31#endif
32
Jack Jansene0581891999-02-07 14:02:03 +000033#define as_Menu(h) ((MenuHandle)h)
Jack Jansena1a0fef1999-12-23 14:32:06 +000034#define as_Resource(h) ((Handle)h)
Jack Jansene0581891999-02-07 14:02:03 +000035
Guido van Rossum17448e21995-01-30 11:53:55 +000036static PyObject *Menu_Error;
37
38/* ------------------------ Object type Menu ------------------------ */
39
40PyTypeObject Menu_Type;
41
42#define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
43
44typedef struct MenuObject {
45 PyObject_HEAD
46 MenuHandle ob_itself;
47} MenuObject;
48
49PyObject *MenuObj_New(itself)
Guido van Rossum227a4231995-03-10 14:42:57 +000050 MenuHandle itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000051{
52 MenuObject *it;
53 it = PyObject_NEW(MenuObject, &Menu_Type);
54 if (it == NULL) return NULL;
55 it->ob_itself = itself;
56 return (PyObject *)it;
57}
58MenuObj_Convert(v, p_itself)
59 PyObject *v;
60 MenuHandle *p_itself;
61{
62 if (!MenuObj_Check(v))
63 {
64 PyErr_SetString(PyExc_TypeError, "Menu required");
65 return 0;
66 }
67 *p_itself = ((MenuObject *)v)->ob_itself;
68 return 1;
69}
70
71static void MenuObj_dealloc(self)
72 MenuObject *self;
73{
74 /* Cleanup of self->ob_itself goes here */
75 PyMem_DEL(self);
76}
77
78static PyObject *MenuObj_DisposeMenu(_self, _args)
79 MenuObject *_self;
80 PyObject *_args;
81{
82 PyObject *_res = NULL;
83 if (!PyArg_ParseTuple(_args, ""))
84 return NULL;
85 DisposeMenu(_self->ob_itself);
86 Py_INCREF(Py_None);
87 _res = Py_None;
88 return _res;
89}
90
Jack Jansena05ac601999-12-12 21:41:51 +000091static PyObject *MenuObj_CalcMenuSize(_self, _args)
92 MenuObject *_self;
93 PyObject *_args;
94{
95 PyObject *_res = NULL;
96 if (!PyArg_ParseTuple(_args, ""))
97 return NULL;
98 CalcMenuSize(_self->ob_itself);
99 Py_INCREF(Py_None);
100 _res = Py_None;
101 return _res;
102}
103
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000104static PyObject *MenuObj_CountMenuItems(_self, _args)
105 MenuObject *_self;
106 PyObject *_args;
107{
108 PyObject *_res = NULL;
109 short _rv;
110 if (!PyArg_ParseTuple(_args, ""))
111 return NULL;
112 _rv = CountMenuItems(_self->ob_itself);
113 _res = Py_BuildValue("h",
114 _rv);
115 return _res;
116}
117
Jack Jansen74a1e632000-07-14 22:37:27 +0000118#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000119
Jack Jansena05ac601999-12-12 21:41:51 +0000120static PyObject *MenuObj_CountMItems(_self, _args)
121 MenuObject *_self;
122 PyObject *_args;
123{
124 PyObject *_res = NULL;
125 short _rv;
126 if (!PyArg_ParseTuple(_args, ""))
127 return NULL;
128 _rv = CountMItems(_self->ob_itself);
129 _res = Py_BuildValue("h",
130 _rv);
131 return _res;
132}
Jack Jansene79dc762000-06-02 21:35:07 +0000133#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000134
135static PyObject *MenuObj_GetMenuFont(_self, _args)
136 MenuObject *_self;
137 PyObject *_args;
138{
139 PyObject *_res = NULL;
140 OSStatus _err;
141 SInt16 outFontID;
142 UInt16 outFontSize;
143 if (!PyArg_ParseTuple(_args, ""))
144 return NULL;
145 _err = GetMenuFont(_self->ob_itself,
146 &outFontID,
147 &outFontSize);
148 if (_err != noErr) return PyMac_Error(_err);
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000149 _res = Py_BuildValue("hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000150 outFontID,
151 outFontSize);
152 return _res;
153}
154
155static PyObject *MenuObj_SetMenuFont(_self, _args)
156 MenuObject *_self;
157 PyObject *_args;
158{
159 PyObject *_res = NULL;
160 OSStatus _err;
161 SInt16 inFontID;
162 UInt16 inFontSize;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000163 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000164 &inFontID,
165 &inFontSize))
166 return NULL;
167 _err = SetMenuFont(_self->ob_itself,
168 inFontID,
169 inFontSize);
170 if (_err != noErr) return PyMac_Error(_err);
171 Py_INCREF(Py_None);
172 _res = Py_None;
173 return _res;
174}
175
176static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args)
177 MenuObject *_self;
178 PyObject *_args;
179{
180 PyObject *_res = NULL;
181 Boolean _rv;
182 if (!PyArg_ParseTuple(_args, ""))
183 return NULL;
184 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
185 _res = Py_BuildValue("b",
186 _rv);
187 return _res;
188}
189
190static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args)
191 MenuObject *_self;
192 PyObject *_args;
193{
194 PyObject *_res = NULL;
195 OSStatus _err;
196 Boolean excludesMark;
197 if (!PyArg_ParseTuple(_args, "b",
198 &excludesMark))
199 return NULL;
200 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
201 excludesMark);
202 if (_err != noErr) return PyMac_Error(_err);
203 Py_INCREF(Py_None);
204 _res = Py_None;
205 return _res;
206}
207
Jack Jansen1c4e6141998-04-21 15:23:55 +0000208static PyObject *MenuObj_MacAppendMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000209 MenuObject *_self;
210 PyObject *_args;
211{
212 PyObject *_res = NULL;
213 Str255 data;
214 if (!PyArg_ParseTuple(_args, "O&",
215 PyMac_GetStr255, data))
216 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000217 MacAppendMenu(_self->ob_itself,
218 data);
Guido van Rossum17448e21995-01-30 11:53:55 +0000219 Py_INCREF(Py_None);
220 _res = Py_None;
221 return _res;
222}
223
Guido van Rossum17448e21995-01-30 11:53:55 +0000224static PyObject *MenuObj_InsertResMenu(_self, _args)
225 MenuObject *_self;
226 PyObject *_args;
227{
228 PyObject *_res = NULL;
229 ResType theType;
230 short afterItem;
231 if (!PyArg_ParseTuple(_args, "O&h",
232 PyMac_GetOSType, &theType,
233 &afterItem))
234 return NULL;
235 InsertResMenu(_self->ob_itself,
236 theType,
237 afterItem);
238 Py_INCREF(Py_None);
239 _res = Py_None;
240 return _res;
241}
242
Jack Jansen21f96871998-02-20 16:02:09 +0000243static PyObject *MenuObj_AppendResMenu(_self, _args)
244 MenuObject *_self;
245 PyObject *_args;
246{
247 PyObject *_res = NULL;
248 ResType theType;
249 if (!PyArg_ParseTuple(_args, "O&",
250 PyMac_GetOSType, &theType))
251 return NULL;
252 AppendResMenu(_self->ob_itself,
253 theType);
254 Py_INCREF(Py_None);
255 _res = Py_None;
256 return _res;
257}
258
Jack Jansen1c4e6141998-04-21 15:23:55 +0000259static PyObject *MenuObj_MacInsertMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000260 MenuObject *_self;
261 PyObject *_args;
262{
263 PyObject *_res = NULL;
264 Str255 itemString;
265 short afterItem;
266 if (!PyArg_ParseTuple(_args, "O&h",
267 PyMac_GetStr255, itemString,
268 &afterItem))
269 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000270 MacInsertMenuItem(_self->ob_itself,
271 itemString,
272 afterItem);
Guido van Rossum17448e21995-01-30 11:53:55 +0000273 Py_INCREF(Py_None);
274 _res = Py_None;
275 return _res;
276}
277
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000278static PyObject *MenuObj_DeleteMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000279 MenuObject *_self;
280 PyObject *_args;
281{
282 PyObject *_res = NULL;
283 short item;
284 if (!PyArg_ParseTuple(_args, "h",
285 &item))
286 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000287 DeleteMenuItem(_self->ob_itself,
288 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000289 Py_INCREF(Py_None);
290 _res = Py_None;
291 return _res;
292}
293
Jack Jansena05ac601999-12-12 21:41:51 +0000294static PyObject *MenuObj_InsertFontResMenu(_self, _args)
295 MenuObject *_self;
296 PyObject *_args;
297{
298 PyObject *_res = NULL;
299 short afterItem;
300 short scriptFilter;
301 if (!PyArg_ParseTuple(_args, "hh",
302 &afterItem,
303 &scriptFilter))
304 return NULL;
305 InsertFontResMenu(_self->ob_itself,
306 afterItem,
307 scriptFilter);
308 Py_INCREF(Py_None);
309 _res = Py_None;
310 return _res;
311}
312
313static PyObject *MenuObj_InsertIntlResMenu(_self, _args)
314 MenuObject *_self;
315 PyObject *_args;
316{
317 PyObject *_res = NULL;
318 ResType theType;
319 short afterItem;
320 short scriptFilter;
321 if (!PyArg_ParseTuple(_args, "O&hh",
322 PyMac_GetOSType, &theType,
323 &afterItem,
324 &scriptFilter))
325 return NULL;
326 InsertIntlResMenu(_self->ob_itself,
327 theType,
328 afterItem,
329 scriptFilter);
330 Py_INCREF(Py_None);
331 _res = Py_None;
332 return _res;
333}
334
335static PyObject *MenuObj_AppendMenuItemText(_self, _args)
336 MenuObject *_self;
337 PyObject *_args;
338{
339 PyObject *_res = NULL;
340 OSStatus _err;
341 Str255 inString;
342 if (!PyArg_ParseTuple(_args, "O&",
343 PyMac_GetStr255, inString))
344 return NULL;
345 _err = AppendMenuItemText(_self->ob_itself,
346 inString);
347 if (_err != noErr) return PyMac_Error(_err);
348 Py_INCREF(Py_None);
349 _res = Py_None;
350 return _res;
351}
352
353static PyObject *MenuObj_InsertMenuItemText(_self, _args)
354 MenuObject *_self;
355 PyObject *_args;
356{
357 PyObject *_res = NULL;
358 OSStatus _err;
359 Str255 inString;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000360 MenuItemIndex afterItem;
361 if (!PyArg_ParseTuple(_args, "O&h",
Jack Jansena05ac601999-12-12 21:41:51 +0000362 PyMac_GetStr255, inString,
363 &afterItem))
364 return NULL;
365 _err = InsertMenuItemText(_self->ob_itself,
366 inString,
367 afterItem);
368 if (_err != noErr) return PyMac_Error(_err);
369 Py_INCREF(Py_None);
370 _res = Py_None;
371 return _res;
372}
373
374static PyObject *MenuObj_PopUpMenuSelect(_self, _args)
375 MenuObject *_self;
376 PyObject *_args;
377{
378 PyObject *_res = NULL;
379 long _rv;
380 short top;
381 short left;
382 short popUpItem;
383 if (!PyArg_ParseTuple(_args, "hhh",
384 &top,
385 &left,
386 &popUpItem))
387 return NULL;
388 _rv = PopUpMenuSelect(_self->ob_itself,
389 top,
390 left,
391 popUpItem);
392 _res = Py_BuildValue("l",
393 _rv);
394 return _res;
395}
396
397static PyObject *MenuObj_MacInsertMenu(_self, _args)
398 MenuObject *_self;
399 PyObject *_args;
400{
401 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000402 MenuID beforeID;
Jack Jansena05ac601999-12-12 21:41:51 +0000403 if (!PyArg_ParseTuple(_args, "h",
404 &beforeID))
405 return NULL;
406 MacInsertMenu(_self->ob_itself,
407 beforeID);
408 Py_INCREF(Py_None);
409 _res = Py_None;
410 return _res;
411}
412
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000413static PyObject *MenuObj_MacCheckMenuItem(_self, _args)
414 MenuObject *_self;
415 PyObject *_args;
416{
417 PyObject *_res = NULL;
418 short item;
419 Boolean checked;
420 if (!PyArg_ParseTuple(_args, "hb",
421 &item,
422 &checked))
423 return NULL;
424 MacCheckMenuItem(_self->ob_itself,
425 item,
426 checked);
427 Py_INCREF(Py_None);
428 _res = Py_None;
429 return _res;
430}
431
Jack Jansen74a1e632000-07-14 22:37:27 +0000432#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000433
Jack Jansena05ac601999-12-12 21:41:51 +0000434static PyObject *MenuObj_CheckItem(_self, _args)
435 MenuObject *_self;
436 PyObject *_args;
437{
438 PyObject *_res = NULL;
439 short item;
440 Boolean checked;
441 if (!PyArg_ParseTuple(_args, "hb",
442 &item,
443 &checked))
444 return NULL;
445 CheckItem(_self->ob_itself,
446 item,
447 checked);
448 Py_INCREF(Py_None);
449 _res = Py_None;
450 return _res;
451}
Jack Jansene79dc762000-06-02 21:35:07 +0000452#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000453
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000454static PyObject *MenuObj_SetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000455 MenuObject *_self;
456 PyObject *_args;
457{
458 PyObject *_res = NULL;
459 short item;
460 Str255 itemString;
461 if (!PyArg_ParseTuple(_args, "hO&",
462 &item,
463 PyMac_GetStr255, itemString))
464 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000465 SetMenuItemText(_self->ob_itself,
466 item,
467 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000468 Py_INCREF(Py_None);
469 _res = Py_None;
470 return _res;
471}
472
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000473static PyObject *MenuObj_GetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000474 MenuObject *_self;
475 PyObject *_args;
476{
477 PyObject *_res = NULL;
478 short item;
479 Str255 itemString;
480 if (!PyArg_ParseTuple(_args, "h",
481 &item))
482 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000483 GetMenuItemText(_self->ob_itself,
484 item,
485 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000486 _res = Py_BuildValue("O&",
487 PyMac_BuildStr255, itemString);
488 return _res;
489}
490
Guido van Rossum17448e21995-01-30 11:53:55 +0000491static PyObject *MenuObj_SetItemMark(_self, _args)
492 MenuObject *_self;
493 PyObject *_args;
494{
495 PyObject *_res = NULL;
496 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000497 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000498 if (!PyArg_ParseTuple(_args, "hh",
499 &item,
500 &markChar))
501 return NULL;
502 SetItemMark(_self->ob_itself,
503 item,
504 markChar);
505 Py_INCREF(Py_None);
506 _res = Py_None;
507 return _res;
508}
509
510static PyObject *MenuObj_GetItemMark(_self, _args)
511 MenuObject *_self;
512 PyObject *_args;
513{
514 PyObject *_res = NULL;
515 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000516 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000517 if (!PyArg_ParseTuple(_args, "h",
518 &item))
519 return NULL;
520 GetItemMark(_self->ob_itself,
521 item,
522 &markChar);
523 _res = Py_BuildValue("h",
524 markChar);
525 return _res;
526}
527
Jack Jansen21f96871998-02-20 16:02:09 +0000528static PyObject *MenuObj_SetItemCmd(_self, _args)
529 MenuObject *_self;
530 PyObject *_args;
531{
532 PyObject *_res = NULL;
533 short item;
534 CharParameter cmdChar;
535 if (!PyArg_ParseTuple(_args, "hh",
536 &item,
537 &cmdChar))
538 return NULL;
539 SetItemCmd(_self->ob_itself,
540 item,
541 cmdChar);
542 Py_INCREF(Py_None);
543 _res = Py_None;
544 return _res;
545}
546
547static PyObject *MenuObj_GetItemCmd(_self, _args)
548 MenuObject *_self;
549 PyObject *_args;
550{
551 PyObject *_res = NULL;
552 short item;
553 CharParameter cmdChar;
554 if (!PyArg_ParseTuple(_args, "h",
555 &item))
556 return NULL;
557 GetItemCmd(_self->ob_itself,
558 item,
559 &cmdChar);
560 _res = Py_BuildValue("h",
561 cmdChar);
562 return _res;
563}
564
Guido van Rossum17448e21995-01-30 11:53:55 +0000565static PyObject *MenuObj_SetItemIcon(_self, _args)
566 MenuObject *_self;
567 PyObject *_args;
568{
569 PyObject *_res = NULL;
570 short item;
571 short iconIndex;
572 if (!PyArg_ParseTuple(_args, "hh",
573 &item,
574 &iconIndex))
575 return NULL;
576 SetItemIcon(_self->ob_itself,
577 item,
578 iconIndex);
579 Py_INCREF(Py_None);
580 _res = Py_None;
581 return _res;
582}
583
584static PyObject *MenuObj_GetItemIcon(_self, _args)
585 MenuObject *_self;
586 PyObject *_args;
587{
588 PyObject *_res = NULL;
589 short item;
590 short iconIndex;
591 if (!PyArg_ParseTuple(_args, "h",
592 &item))
593 return NULL;
594 GetItemIcon(_self->ob_itself,
595 item,
596 &iconIndex);
597 _res = Py_BuildValue("h",
598 iconIndex);
599 return _res;
600}
601
602static PyObject *MenuObj_SetItemStyle(_self, _args)
603 MenuObject *_self;
604 PyObject *_args;
605{
606 PyObject *_res = NULL;
607 short item;
Jack Jansend6b6d881998-02-25 15:45:21 +0000608 StyleParameter chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000609 if (!PyArg_ParseTuple(_args, "hh",
610 &item,
611 &chStyle))
612 return NULL;
613 SetItemStyle(_self->ob_itself,
614 item,
615 chStyle);
616 Py_INCREF(Py_None);
617 _res = Py_None;
618 return _res;
619}
620
621static PyObject *MenuObj_GetItemStyle(_self, _args)
622 MenuObject *_self;
623 PyObject *_args;
624{
625 PyObject *_res = NULL;
626 short item;
Jack Jansen7d0bc831995-06-09 20:56:31 +0000627 Style chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000628 if (!PyArg_ParseTuple(_args, "h",
629 &item))
630 return NULL;
631 GetItemStyle(_self->ob_itself,
632 item,
633 &chStyle);
634 _res = Py_BuildValue("b",
635 chStyle);
636 return _res;
637}
638
Jack Jansen74a1e632000-07-14 22:37:27 +0000639#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000640
Jack Jansen21f96871998-02-20 16:02:09 +0000641static PyObject *MenuObj_DisableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000642 MenuObject *_self;
643 PyObject *_args;
644{
645 PyObject *_res = NULL;
646 short item;
Guido van Rossum17448e21995-01-30 11:53:55 +0000647 if (!PyArg_ParseTuple(_args, "h",
648 &item))
649 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000650 DisableItem(_self->ob_itself,
651 item);
652 Py_INCREF(Py_None);
653 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +0000654 return _res;
655}
Jack Jansene79dc762000-06-02 21:35:07 +0000656#endif
657
Jack Jansen74a1e632000-07-14 22:37:27 +0000658#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000659
Jack Jansen21f96871998-02-20 16:02:09 +0000660static PyObject *MenuObj_EnableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000661 MenuObject *_self;
662 PyObject *_args;
663{
664 PyObject *_res = NULL;
665 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000666 if (!PyArg_ParseTuple(_args, "h",
667 &item))
Guido van Rossum17448e21995-01-30 11:53:55 +0000668 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000669 EnableItem(_self->ob_itself,
670 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000671 Py_INCREF(Py_None);
672 _res = Py_None;
673 return _res;
674}
Jack Jansene79dc762000-06-02 21:35:07 +0000675#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000676
Jack Jansen21f96871998-02-20 16:02:09 +0000677static PyObject *MenuObj_SetMenuItemCommandID(_self, _args)
678 MenuObject *_self;
679 PyObject *_args;
680{
681 PyObject *_res = NULL;
682 OSErr _err;
683 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000684 MenuCommand inCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000685 if (!PyArg_ParseTuple(_args, "hl",
686 &inItem,
687 &inCommandID))
688 return NULL;
689 _err = SetMenuItemCommandID(_self->ob_itself,
690 inItem,
691 inCommandID);
692 if (_err != noErr) return PyMac_Error(_err);
693 Py_INCREF(Py_None);
694 _res = Py_None;
695 return _res;
696}
697
698static PyObject *MenuObj_GetMenuItemCommandID(_self, _args)
699 MenuObject *_self;
700 PyObject *_args;
701{
702 PyObject *_res = NULL;
703 OSErr _err;
704 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000705 MenuCommand outCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000706 if (!PyArg_ParseTuple(_args, "h",
707 &inItem))
708 return NULL;
709 _err = GetMenuItemCommandID(_self->ob_itself,
710 inItem,
711 &outCommandID);
712 if (_err != noErr) return PyMac_Error(_err);
713 _res = Py_BuildValue("l",
714 outCommandID);
715 return _res;
716}
717
718static PyObject *MenuObj_SetMenuItemModifiers(_self, _args)
719 MenuObject *_self;
720 PyObject *_args;
721{
722 PyObject *_res = NULL;
723 OSErr _err;
724 SInt16 inItem;
725 UInt8 inModifiers;
726 if (!PyArg_ParseTuple(_args, "hb",
727 &inItem,
728 &inModifiers))
729 return NULL;
730 _err = SetMenuItemModifiers(_self->ob_itself,
731 inItem,
732 inModifiers);
733 if (_err != noErr) return PyMac_Error(_err);
734 Py_INCREF(Py_None);
735 _res = Py_None;
736 return _res;
737}
738
739static PyObject *MenuObj_GetMenuItemModifiers(_self, _args)
740 MenuObject *_self;
741 PyObject *_args;
742{
743 PyObject *_res = NULL;
744 OSErr _err;
745 SInt16 inItem;
746 UInt8 outModifiers;
747 if (!PyArg_ParseTuple(_args, "h",
748 &inItem))
749 return NULL;
750 _err = GetMenuItemModifiers(_self->ob_itself,
751 inItem,
752 &outModifiers);
753 if (_err != noErr) return PyMac_Error(_err);
754 _res = Py_BuildValue("b",
755 outModifiers);
756 return _res;
757}
758
759static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args)
760 MenuObject *_self;
761 PyObject *_args;
762{
763 PyObject *_res = NULL;
764 OSErr _err;
765 SInt16 inItem;
766 UInt8 inIconType;
767 Handle inIconHandle;
768 if (!PyArg_ParseTuple(_args, "hbO&",
769 &inItem,
770 &inIconType,
771 ResObj_Convert, &inIconHandle))
772 return NULL;
773 _err = SetMenuItemIconHandle(_self->ob_itself,
774 inItem,
775 inIconType,
776 inIconHandle);
777 if (_err != noErr) return PyMac_Error(_err);
778 Py_INCREF(Py_None);
779 _res = Py_None;
780 return _res;
781}
782
783static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args)
784 MenuObject *_self;
785 PyObject *_args;
786{
787 PyObject *_res = NULL;
788 OSErr _err;
789 SInt16 inItem;
790 UInt8 outIconType;
791 Handle outIconHandle;
792 if (!PyArg_ParseTuple(_args, "h",
793 &inItem))
794 return NULL;
795 _err = GetMenuItemIconHandle(_self->ob_itself,
796 inItem,
797 &outIconType,
798 &outIconHandle);
799 if (_err != noErr) return PyMac_Error(_err);
800 _res = Py_BuildValue("bO&",
801 outIconType,
802 ResObj_New, outIconHandle);
803 return _res;
804}
805
806static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args)
807 MenuObject *_self;
808 PyObject *_args;
809{
810 PyObject *_res = NULL;
811 OSErr _err;
812 SInt16 inItem;
813 TextEncoding inScriptID;
814 if (!PyArg_ParseTuple(_args, "hl",
815 &inItem,
816 &inScriptID))
817 return NULL;
818 _err = SetMenuItemTextEncoding(_self->ob_itself,
819 inItem,
820 inScriptID);
821 if (_err != noErr) return PyMac_Error(_err);
822 Py_INCREF(Py_None);
823 _res = Py_None;
824 return _res;
825}
826
827static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args)
828 MenuObject *_self;
829 PyObject *_args;
830{
831 PyObject *_res = NULL;
832 OSErr _err;
833 SInt16 inItem;
834 TextEncoding outScriptID;
835 if (!PyArg_ParseTuple(_args, "h",
836 &inItem))
837 return NULL;
838 _err = GetMenuItemTextEncoding(_self->ob_itself,
839 inItem,
840 &outScriptID);
841 if (_err != noErr) return PyMac_Error(_err);
842 _res = Py_BuildValue("l",
843 outScriptID);
844 return _res;
845}
846
847static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args)
848 MenuObject *_self;
849 PyObject *_args;
850{
851 PyObject *_res = NULL;
852 OSErr _err;
853 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000854 MenuID inHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000855 if (!PyArg_ParseTuple(_args, "hh",
856 &inItem,
857 &inHierID))
858 return NULL;
859 _err = SetMenuItemHierarchicalID(_self->ob_itself,
860 inItem,
861 inHierID);
862 if (_err != noErr) return PyMac_Error(_err);
863 Py_INCREF(Py_None);
864 _res = Py_None;
865 return _res;
866}
867
868static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args)
869 MenuObject *_self;
870 PyObject *_args;
871{
872 PyObject *_res = NULL;
873 OSErr _err;
874 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000875 MenuID outHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000876 if (!PyArg_ParseTuple(_args, "h",
877 &inItem))
878 return NULL;
879 _err = GetMenuItemHierarchicalID(_self->ob_itself,
880 inItem,
881 &outHierID);
882 if (_err != noErr) return PyMac_Error(_err);
883 _res = Py_BuildValue("h",
884 outHierID);
885 return _res;
886}
887
888static PyObject *MenuObj_SetMenuItemFontID(_self, _args)
889 MenuObject *_self;
890 PyObject *_args;
891{
892 PyObject *_res = NULL;
893 OSErr _err;
894 SInt16 inItem;
895 SInt16 inFontID;
896 if (!PyArg_ParseTuple(_args, "hh",
897 &inItem,
898 &inFontID))
899 return NULL;
900 _err = SetMenuItemFontID(_self->ob_itself,
901 inItem,
902 inFontID);
903 if (_err != noErr) return PyMac_Error(_err);
904 Py_INCREF(Py_None);
905 _res = Py_None;
906 return _res;
907}
908
909static PyObject *MenuObj_GetMenuItemFontID(_self, _args)
910 MenuObject *_self;
911 PyObject *_args;
912{
913 PyObject *_res = NULL;
914 OSErr _err;
915 SInt16 inItem;
916 SInt16 outFontID;
917 if (!PyArg_ParseTuple(_args, "h",
918 &inItem))
919 return NULL;
920 _err = GetMenuItemFontID(_self->ob_itself,
921 inItem,
922 &outFontID);
923 if (_err != noErr) return PyMac_Error(_err);
924 _res = Py_BuildValue("h",
925 outFontID);
926 return _res;
927}
928
929static PyObject *MenuObj_SetMenuItemRefCon(_self, _args)
930 MenuObject *_self;
931 PyObject *_args;
932{
933 PyObject *_res = NULL;
934 OSErr _err;
935 SInt16 inItem;
936 UInt32 inRefCon;
937 if (!PyArg_ParseTuple(_args, "hl",
938 &inItem,
939 &inRefCon))
940 return NULL;
941 _err = SetMenuItemRefCon(_self->ob_itself,
942 inItem,
943 inRefCon);
944 if (_err != noErr) return PyMac_Error(_err);
945 Py_INCREF(Py_None);
946 _res = Py_None;
947 return _res;
948}
949
950static PyObject *MenuObj_GetMenuItemRefCon(_self, _args)
951 MenuObject *_self;
952 PyObject *_args;
953{
954 PyObject *_res = NULL;
955 OSErr _err;
956 SInt16 inItem;
957 UInt32 outRefCon;
958 if (!PyArg_ParseTuple(_args, "h",
959 &inItem))
960 return NULL;
961 _err = GetMenuItemRefCon(_self->ob_itself,
962 inItem,
963 &outRefCon);
964 if (_err != noErr) return PyMac_Error(_err);
965 _res = Py_BuildValue("l",
966 outRefCon);
967 return _res;
968}
969
Jack Jansen74a1e632000-07-14 22:37:27 +0000970#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000971
Jack Jansen21f96871998-02-20 16:02:09 +0000972static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args)
973 MenuObject *_self;
974 PyObject *_args;
975{
976 PyObject *_res = NULL;
977 OSErr _err;
978 SInt16 inItem;
979 UInt32 inRefCon2;
980 if (!PyArg_ParseTuple(_args, "hl",
981 &inItem,
982 &inRefCon2))
983 return NULL;
984 _err = SetMenuItemRefCon2(_self->ob_itself,
985 inItem,
986 inRefCon2);
987 if (_err != noErr) return PyMac_Error(_err);
988 Py_INCREF(Py_None);
989 _res = Py_None;
990 return _res;
991}
Jack Jansene79dc762000-06-02 21:35:07 +0000992#endif
993
Jack Jansen74a1e632000-07-14 22:37:27 +0000994#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +0000995
996static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args)
997 MenuObject *_self;
998 PyObject *_args;
999{
1000 PyObject *_res = NULL;
1001 OSErr _err;
1002 SInt16 inItem;
1003 UInt32 outRefCon2;
1004 if (!PyArg_ParseTuple(_args, "h",
1005 &inItem))
1006 return NULL;
1007 _err = GetMenuItemRefCon2(_self->ob_itself,
1008 inItem,
1009 &outRefCon2);
1010 if (_err != noErr) return PyMac_Error(_err);
1011 _res = Py_BuildValue("l",
1012 outRefCon2);
1013 return _res;
1014}
Jack Jansene79dc762000-06-02 21:35:07 +00001015#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001016
1017static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args)
1018 MenuObject *_self;
1019 PyObject *_args;
1020{
1021 PyObject *_res = NULL;
1022 OSErr _err;
1023 SInt16 inItem;
1024 SInt16 inGlyph;
1025 if (!PyArg_ParseTuple(_args, "hh",
1026 &inItem,
1027 &inGlyph))
1028 return NULL;
1029 _err = SetMenuItemKeyGlyph(_self->ob_itself,
1030 inItem,
1031 inGlyph);
1032 if (_err != noErr) return PyMac_Error(_err);
1033 Py_INCREF(Py_None);
1034 _res = Py_None;
1035 return _res;
1036}
1037
1038static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args)
1039 MenuObject *_self;
1040 PyObject *_args;
1041{
1042 PyObject *_res = NULL;
1043 OSErr _err;
1044 SInt16 inItem;
1045 SInt16 outGlyph;
1046 if (!PyArg_ParseTuple(_args, "h",
1047 &inItem))
1048 return NULL;
1049 _err = GetMenuItemKeyGlyph(_self->ob_itself,
1050 inItem,
1051 &outGlyph);
1052 if (_err != noErr) return PyMac_Error(_err);
1053 _res = Py_BuildValue("h",
1054 outGlyph);
1055 return _res;
1056}
1057
Jack Jansena05ac601999-12-12 21:41:51 +00001058static PyObject *MenuObj_MacEnableMenuItem(_self, _args)
1059 MenuObject *_self;
1060 PyObject *_args;
1061{
1062 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001063 MenuItemIndex item;
1064 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001065 &item))
1066 return NULL;
1067 MacEnableMenuItem(_self->ob_itself,
1068 item);
1069 Py_INCREF(Py_None);
1070 _res = Py_None;
1071 return _res;
1072}
1073
1074static PyObject *MenuObj_DisableMenuItem(_self, _args)
1075 MenuObject *_self;
1076 PyObject *_args;
1077{
1078 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001079 MenuItemIndex item;
1080 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001081 &item))
1082 return NULL;
1083 DisableMenuItem(_self->ob_itself,
1084 item);
1085 Py_INCREF(Py_None);
1086 _res = Py_None;
1087 return _res;
1088}
1089
1090static PyObject *MenuObj_IsMenuItemEnabled(_self, _args)
1091 MenuObject *_self;
1092 PyObject *_args;
1093{
1094 PyObject *_res = NULL;
1095 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001096 MenuItemIndex item;
1097 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001098 &item))
1099 return NULL;
1100 _rv = IsMenuItemEnabled(_self->ob_itself,
1101 item);
1102 _res = Py_BuildValue("b",
1103 _rv);
1104 return _res;
1105}
1106
1107static PyObject *MenuObj_EnableMenuItemIcon(_self, _args)
1108 MenuObject *_self;
1109 PyObject *_args;
1110{
1111 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001112 MenuItemIndex item;
1113 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001114 &item))
1115 return NULL;
1116 EnableMenuItemIcon(_self->ob_itself,
1117 item);
1118 Py_INCREF(Py_None);
1119 _res = Py_None;
1120 return _res;
1121}
1122
1123static PyObject *MenuObj_DisableMenuItemIcon(_self, _args)
1124 MenuObject *_self;
1125 PyObject *_args;
1126{
1127 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001128 MenuItemIndex item;
1129 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001130 &item))
1131 return NULL;
1132 DisableMenuItemIcon(_self->ob_itself,
1133 item);
1134 Py_INCREF(Py_None);
1135 _res = Py_None;
1136 return _res;
1137}
1138
1139static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args)
1140 MenuObject *_self;
1141 PyObject *_args;
1142{
1143 PyObject *_res = NULL;
1144 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001145 MenuItemIndex item;
1146 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001147 &item))
1148 return NULL;
1149 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1150 item);
1151 _res = Py_BuildValue("b",
1152 _rv);
1153 return _res;
1154}
1155
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001156#if TARGET_API_MAC_CARBON
1157
1158static PyObject *MenuObj_GetMenuItemPropertyAttributes(_self, _args)
1159 MenuObject *_self;
1160 PyObject *_args;
1161{
1162 PyObject *_res = NULL;
1163 OSStatus _err;
1164 MenuItemIndex item;
1165 OSType propertyCreator;
1166 OSType propertyTag;
1167 UInt32 attributes;
1168 if (!PyArg_ParseTuple(_args, "hO&O&",
1169 &item,
1170 PyMac_GetOSType, &propertyCreator,
1171 PyMac_GetOSType, &propertyTag))
1172 return NULL;
1173 _err = GetMenuItemPropertyAttributes(_self->ob_itself,
1174 item,
1175 propertyCreator,
1176 propertyTag,
1177 &attributes);
1178 if (_err != noErr) return PyMac_Error(_err);
1179 _res = Py_BuildValue("l",
1180 attributes);
1181 return _res;
1182}
1183#endif
1184
1185#if TARGET_API_MAC_CARBON
1186
1187static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(_self, _args)
1188 MenuObject *_self;
1189 PyObject *_args;
1190{
1191 PyObject *_res = NULL;
1192 OSStatus _err;
1193 MenuItemIndex item;
1194 OSType propertyCreator;
1195 OSType propertyTag;
1196 UInt32 attributesToSet;
1197 UInt32 attributesToClear;
1198 if (!PyArg_ParseTuple(_args, "hO&O&ll",
1199 &item,
1200 PyMac_GetOSType, &propertyCreator,
1201 PyMac_GetOSType, &propertyTag,
1202 &attributesToSet,
1203 &attributesToClear))
1204 return NULL;
1205 _err = ChangeMenuItemPropertyAttributes(_self->ob_itself,
1206 item,
1207 propertyCreator,
1208 propertyTag,
1209 attributesToSet,
1210 attributesToClear);
1211 if (_err != noErr) return PyMac_Error(_err);
1212 Py_INCREF(Py_None);
1213 _res = Py_None;
1214 return _res;
1215}
1216#endif
1217
1218#if TARGET_API_MAC_CARBON
1219
1220static PyObject *MenuObj_GetMenuAttributes(_self, _args)
1221 MenuObject *_self;
1222 PyObject *_args;
1223{
1224 PyObject *_res = NULL;
1225 OSStatus _err;
1226 MenuAttributes outAttributes;
1227 if (!PyArg_ParseTuple(_args, ""))
1228 return NULL;
1229 _err = GetMenuAttributes(_self->ob_itself,
1230 &outAttributes);
1231 if (_err != noErr) return PyMac_Error(_err);
1232 _res = Py_BuildValue("l",
1233 outAttributes);
1234 return _res;
1235}
1236#endif
1237
1238#if TARGET_API_MAC_CARBON
1239
1240static PyObject *MenuObj_ChangeMenuAttributes(_self, _args)
1241 MenuObject *_self;
1242 PyObject *_args;
1243{
1244 PyObject *_res = NULL;
1245 OSStatus _err;
1246 MenuAttributes setTheseAttributes;
1247 MenuAttributes clearTheseAttributes;
1248 if (!PyArg_ParseTuple(_args, "ll",
1249 &setTheseAttributes,
1250 &clearTheseAttributes))
1251 return NULL;
1252 _err = ChangeMenuAttributes(_self->ob_itself,
1253 setTheseAttributes,
1254 clearTheseAttributes);
1255 if (_err != noErr) return PyMac_Error(_err);
1256 Py_INCREF(Py_None);
1257 _res = Py_None;
1258 return _res;
1259}
1260#endif
1261
1262#if TARGET_API_MAC_CARBON
1263
1264static PyObject *MenuObj_GetMenuItemAttributes(_self, _args)
1265 MenuObject *_self;
1266 PyObject *_args;
1267{
1268 PyObject *_res = NULL;
1269 OSStatus _err;
1270 MenuItemIndex item;
1271 MenuItemAttributes outAttributes;
1272 if (!PyArg_ParseTuple(_args, "h",
1273 &item))
1274 return NULL;
1275 _err = GetMenuItemAttributes(_self->ob_itself,
1276 item,
1277 &outAttributes);
1278 if (_err != noErr) return PyMac_Error(_err);
1279 _res = Py_BuildValue("l",
1280 outAttributes);
1281 return _res;
1282}
1283#endif
1284
1285#if TARGET_API_MAC_CARBON
1286
1287static PyObject *MenuObj_ChangeMenuItemAttributes(_self, _args)
1288 MenuObject *_self;
1289 PyObject *_args;
1290{
1291 PyObject *_res = NULL;
1292 OSStatus _err;
1293 MenuItemIndex item;
1294 MenuItemAttributes setTheseAttributes;
1295 MenuItemAttributes clearTheseAttributes;
1296 if (!PyArg_ParseTuple(_args, "hll",
1297 &item,
1298 &setTheseAttributes,
1299 &clearTheseAttributes))
1300 return NULL;
1301 _err = ChangeMenuItemAttributes(_self->ob_itself,
1302 item,
1303 setTheseAttributes,
1304 clearTheseAttributes);
1305 if (_err != noErr) return PyMac_Error(_err);
1306 Py_INCREF(Py_None);
1307 _res = Py_None;
1308 return _res;
1309}
1310#endif
1311
1312#if TARGET_API_MAC_CARBON
1313
1314static PyObject *MenuObj_DisableAllMenuItems(_self, _args)
1315 MenuObject *_self;
1316 PyObject *_args;
1317{
1318 PyObject *_res = NULL;
1319 if (!PyArg_ParseTuple(_args, ""))
1320 return NULL;
1321 DisableAllMenuItems(_self->ob_itself);
1322 Py_INCREF(Py_None);
1323 _res = Py_None;
1324 return _res;
1325}
1326#endif
1327
1328#if TARGET_API_MAC_CARBON
1329
1330static PyObject *MenuObj_EnableAllMenuItems(_self, _args)
1331 MenuObject *_self;
1332 PyObject *_args;
1333{
1334 PyObject *_res = NULL;
1335 if (!PyArg_ParseTuple(_args, ""))
1336 return NULL;
1337 EnableAllMenuItems(_self->ob_itself);
1338 Py_INCREF(Py_None);
1339 _res = Py_None;
1340 return _res;
1341}
1342#endif
1343
1344#if TARGET_API_MAC_CARBON
1345
1346static PyObject *MenuObj_MenuHasEnabledItems(_self, _args)
1347 MenuObject *_self;
1348 PyObject *_args;
1349{
1350 PyObject *_res = NULL;
1351 Boolean _rv;
1352 if (!PyArg_ParseTuple(_args, ""))
1353 return NULL;
1354 _rv = MenuHasEnabledItems(_self->ob_itself);
1355 _res = Py_BuildValue("b",
1356 _rv);
1357 return _res;
1358}
1359#endif
1360
1361#if TARGET_API_MAC_CARBON
1362
1363static PyObject *MenuObj_CountMenuItemsWithCommandID(_self, _args)
1364 MenuObject *_self;
1365 PyObject *_args;
1366{
1367 PyObject *_res = NULL;
1368 ItemCount _rv;
1369 MenuCommand commandID;
1370 if (!PyArg_ParseTuple(_args, "l",
1371 &commandID))
1372 return NULL;
1373 _rv = CountMenuItemsWithCommandID(_self->ob_itself,
1374 commandID);
1375 _res = Py_BuildValue("l",
1376 _rv);
1377 return _res;
1378}
1379#endif
1380
1381#if TARGET_API_MAC_CARBON
1382
1383static PyObject *MenuObj_GetIndMenuItemWithCommandID(_self, _args)
1384 MenuObject *_self;
1385 PyObject *_args;
1386{
1387 PyObject *_res = NULL;
1388 OSStatus _err;
1389 MenuCommand commandID;
1390 UInt32 itemIndex;
1391 MenuHandle outMenu;
1392 MenuItemIndex outIndex;
1393 if (!PyArg_ParseTuple(_args, "ll",
1394 &commandID,
1395 &itemIndex))
1396 return NULL;
1397 _err = GetIndMenuItemWithCommandID(_self->ob_itself,
1398 commandID,
1399 itemIndex,
1400 &outMenu,
1401 &outIndex);
1402 if (_err != noErr) return PyMac_Error(_err);
1403 _res = Py_BuildValue("O&h",
1404 MenuObj_New, outMenu,
1405 outIndex);
1406 return _res;
1407}
1408#endif
1409
1410#if TARGET_API_MAC_CARBON
1411
1412static PyObject *MenuObj_EnableMenuCommand(_self, _args)
1413 MenuObject *_self;
1414 PyObject *_args;
1415{
1416 PyObject *_res = NULL;
1417 MenuCommand commandID;
1418 if (!PyArg_ParseTuple(_args, "l",
1419 &commandID))
1420 return NULL;
1421 EnableMenuCommand(_self->ob_itself,
1422 commandID);
1423 Py_INCREF(Py_None);
1424 _res = Py_None;
1425 return _res;
1426}
1427#endif
1428
1429#if TARGET_API_MAC_CARBON
1430
1431static PyObject *MenuObj_DisableMenuCommand(_self, _args)
1432 MenuObject *_self;
1433 PyObject *_args;
1434{
1435 PyObject *_res = NULL;
1436 MenuCommand commandID;
1437 if (!PyArg_ParseTuple(_args, "l",
1438 &commandID))
1439 return NULL;
1440 DisableMenuCommand(_self->ob_itself,
1441 commandID);
1442 Py_INCREF(Py_None);
1443 _res = Py_None;
1444 return _res;
1445}
1446#endif
1447
1448#if TARGET_API_MAC_CARBON
1449
1450static PyObject *MenuObj_IsMenuCommandEnabled(_self, _args)
1451 MenuObject *_self;
1452 PyObject *_args;
1453{
1454 PyObject *_res = NULL;
1455 Boolean _rv;
1456 MenuCommand commandID;
1457 if (!PyArg_ParseTuple(_args, "l",
1458 &commandID))
1459 return NULL;
1460 _rv = IsMenuCommandEnabled(_self->ob_itself,
1461 commandID);
1462 _res = Py_BuildValue("b",
1463 _rv);
1464 return _res;
1465}
1466#endif
1467
1468#if TARGET_API_MAC_CARBON
1469
1470static PyObject *MenuObj_GetMenuCommandPropertySize(_self, _args)
1471 MenuObject *_self;
1472 PyObject *_args;
1473{
1474 PyObject *_res = NULL;
1475 OSStatus _err;
1476 MenuCommand commandID;
1477 OSType propertyCreator;
1478 OSType propertyTag;
1479 ByteCount size;
1480 if (!PyArg_ParseTuple(_args, "lO&O&",
1481 &commandID,
1482 PyMac_GetOSType, &propertyCreator,
1483 PyMac_GetOSType, &propertyTag))
1484 return NULL;
1485 _err = GetMenuCommandPropertySize(_self->ob_itself,
1486 commandID,
1487 propertyCreator,
1488 propertyTag,
1489 &size);
1490 if (_err != noErr) return PyMac_Error(_err);
1491 _res = Py_BuildValue("l",
1492 size);
1493 return _res;
1494}
1495#endif
1496
1497#if TARGET_API_MAC_CARBON
1498
1499static PyObject *MenuObj_RemoveMenuCommandProperty(_self, _args)
1500 MenuObject *_self;
1501 PyObject *_args;
1502{
1503 PyObject *_res = NULL;
1504 OSStatus _err;
1505 MenuCommand commandID;
1506 OSType propertyCreator;
1507 OSType propertyTag;
1508 if (!PyArg_ParseTuple(_args, "lO&O&",
1509 &commandID,
1510 PyMac_GetOSType, &propertyCreator,
1511 PyMac_GetOSType, &propertyTag))
1512 return NULL;
1513 _err = RemoveMenuCommandProperty(_self->ob_itself,
1514 commandID,
1515 propertyCreator,
1516 propertyTag);
1517 if (_err != noErr) return PyMac_Error(_err);
1518 Py_INCREF(Py_None);
1519 _res = Py_None;
1520 return _res;
1521}
1522#endif
1523
1524#if TARGET_API_MAC_CARBON
1525
1526static PyObject *MenuObj_CreateStandardFontMenu(_self, _args)
1527 MenuObject *_self;
1528 PyObject *_args;
1529{
1530 PyObject *_res = NULL;
1531 OSStatus _err;
1532 MenuItemIndex afterItem;
1533 MenuID firstHierMenuID;
1534 OptionBits options;
1535 ItemCount outHierMenuCount;
1536 if (!PyArg_ParseTuple(_args, "hhl",
1537 &afterItem,
1538 &firstHierMenuID,
1539 &options))
1540 return NULL;
1541 _err = CreateStandardFontMenu(_self->ob_itself,
1542 afterItem,
1543 firstHierMenuID,
1544 options,
1545 &outHierMenuCount);
1546 if (_err != noErr) return PyMac_Error(_err);
1547 _res = Py_BuildValue("l",
1548 outHierMenuCount);
1549 return _res;
1550}
1551#endif
1552
1553#if TARGET_API_MAC_CARBON
1554
1555static PyObject *MenuObj_UpdateStandardFontMenu(_self, _args)
1556 MenuObject *_self;
1557 PyObject *_args;
1558{
1559 PyObject *_res = NULL;
1560 OSStatus _err;
1561 ItemCount outHierMenuCount;
1562 if (!PyArg_ParseTuple(_args, ""))
1563 return NULL;
1564 _err = UpdateStandardFontMenu(_self->ob_itself,
1565 &outHierMenuCount);
1566 if (_err != noErr) return PyMac_Error(_err);
1567 _res = Py_BuildValue("l",
1568 outHierMenuCount);
1569 return _res;
1570}
1571#endif
1572
1573#if TARGET_API_MAC_CARBON
1574
1575static PyObject *MenuObj_GetFontFamilyFromMenuSelection(_self, _args)
1576 MenuObject *_self;
1577 PyObject *_args;
1578{
1579 PyObject *_res = NULL;
1580 OSStatus _err;
1581 MenuItemIndex item;
1582 FMFontFamily outFontFamily;
1583 FMFontStyle outStyle;
1584 if (!PyArg_ParseTuple(_args, "h",
1585 &item))
1586 return NULL;
1587 _err = GetFontFamilyFromMenuSelection(_self->ob_itself,
1588 item,
1589 &outFontFamily,
1590 &outStyle);
1591 if (_err != noErr) return PyMac_Error(_err);
1592 _res = Py_BuildValue("hh",
1593 outFontFamily,
1594 outStyle);
1595 return _res;
1596}
1597#endif
1598
1599static PyObject *MenuObj_GetMenuID(_self, _args)
1600 MenuObject *_self;
1601 PyObject *_args;
1602{
1603 PyObject *_res = NULL;
1604 MenuID _rv;
1605 if (!PyArg_ParseTuple(_args, ""))
1606 return NULL;
1607 _rv = GetMenuID(_self->ob_itself);
1608 _res = Py_BuildValue("h",
1609 _rv);
1610 return _res;
1611}
1612
1613static PyObject *MenuObj_GetMenuWidth(_self, _args)
1614 MenuObject *_self;
1615 PyObject *_args;
1616{
1617 PyObject *_res = NULL;
1618 SInt16 _rv;
1619 if (!PyArg_ParseTuple(_args, ""))
1620 return NULL;
1621 _rv = GetMenuWidth(_self->ob_itself);
1622 _res = Py_BuildValue("h",
1623 _rv);
1624 return _res;
1625}
1626
1627static PyObject *MenuObj_GetMenuHeight(_self, _args)
1628 MenuObject *_self;
1629 PyObject *_args;
1630{
1631 PyObject *_res = NULL;
1632 SInt16 _rv;
1633 if (!PyArg_ParseTuple(_args, ""))
1634 return NULL;
1635 _rv = GetMenuHeight(_self->ob_itself);
1636 _res = Py_BuildValue("h",
1637 _rv);
1638 return _res;
1639}
1640
1641static PyObject *MenuObj_SetMenuID(_self, _args)
1642 MenuObject *_self;
1643 PyObject *_args;
1644{
1645 PyObject *_res = NULL;
1646 MenuID menuID;
1647 if (!PyArg_ParseTuple(_args, "h",
1648 &menuID))
1649 return NULL;
1650 SetMenuID(_self->ob_itself,
1651 menuID);
1652 Py_INCREF(Py_None);
1653 _res = Py_None;
1654 return _res;
1655}
1656
1657static PyObject *MenuObj_SetMenuWidth(_self, _args)
1658 MenuObject *_self;
1659 PyObject *_args;
1660{
1661 PyObject *_res = NULL;
1662 SInt16 width;
1663 if (!PyArg_ParseTuple(_args, "h",
1664 &width))
1665 return NULL;
1666 SetMenuWidth(_self->ob_itself,
1667 width);
1668 Py_INCREF(Py_None);
1669 _res = Py_None;
1670 return _res;
1671}
1672
1673static PyObject *MenuObj_SetMenuHeight(_self, _args)
1674 MenuObject *_self;
1675 PyObject *_args;
1676{
1677 PyObject *_res = NULL;
1678 SInt16 height;
1679 if (!PyArg_ParseTuple(_args, "h",
1680 &height))
1681 return NULL;
1682 SetMenuHeight(_self->ob_itself,
1683 height);
1684 Py_INCREF(Py_None);
1685 _res = Py_None;
1686 return _res;
1687}
1688
Jack Jansena1772281995-06-18 20:17:27 +00001689static PyObject *MenuObj_as_Resource(_self, _args)
1690 MenuObject *_self;
1691 PyObject *_args;
1692{
1693 PyObject *_res = NULL;
Jack Jansena1a0fef1999-12-23 14:32:06 +00001694 Handle _rv;
1695 if (!PyArg_ParseTuple(_args, ""))
1696 return NULL;
1697 _rv = as_Resource(_self->ob_itself);
1698 _res = Py_BuildValue("O&",
1699 ResObj_New, _rv);
1700 return _res;
Jack Jansena1772281995-06-18 20:17:27 +00001701}
1702
Jack Jansene180d991998-04-24 10:28:20 +00001703static PyObject *MenuObj_AppendMenu(_self, _args)
1704 MenuObject *_self;
1705 PyObject *_args;
1706{
1707 PyObject *_res = NULL;
1708 Str255 data;
1709 if (!PyArg_ParseTuple(_args, "O&",
1710 PyMac_GetStr255, data))
1711 return NULL;
1712 AppendMenu(_self->ob_itself,
1713 data);
1714 Py_INCREF(Py_None);
1715 _res = Py_None;
1716 return _res;
1717}
1718
1719static PyObject *MenuObj_InsertMenu(_self, _args)
1720 MenuObject *_self;
1721 PyObject *_args;
1722{
1723 PyObject *_res = NULL;
1724 short beforeID;
1725 if (!PyArg_ParseTuple(_args, "h",
1726 &beforeID))
1727 return NULL;
1728 InsertMenu(_self->ob_itself,
1729 beforeID);
1730 Py_INCREF(Py_None);
1731 _res = Py_None;
1732 return _res;
1733}
1734
1735static PyObject *MenuObj_InsertMenuItem(_self, _args)
1736 MenuObject *_self;
1737 PyObject *_args;
1738{
1739 PyObject *_res = NULL;
1740 Str255 itemString;
1741 short afterItem;
1742 if (!PyArg_ParseTuple(_args, "O&h",
1743 PyMac_GetStr255, itemString,
1744 &afterItem))
1745 return NULL;
1746 InsertMenuItem(_self->ob_itself,
1747 itemString,
1748 afterItem);
1749 Py_INCREF(Py_None);
1750 _res = Py_None;
1751 return _res;
1752}
1753
Jack Jansen54c07872001-01-29 13:32:10 +00001754static PyObject *MenuObj_EnableMenuItem(_self, _args)
1755 MenuObject *_self;
1756 PyObject *_args;
1757{
1758 PyObject *_res = NULL;
1759 UInt16 item;
1760 if (!PyArg_ParseTuple(_args, "H",
1761 &item))
1762 return NULL;
1763 EnableMenuItem(_self->ob_itself,
1764 item);
1765 Py_INCREF(Py_None);
1766 _res = Py_None;
1767 return _res;
1768}
1769
1770static PyObject *MenuObj_CheckMenuItem(_self, _args)
1771 MenuObject *_self;
1772 PyObject *_args;
1773{
1774 PyObject *_res = NULL;
1775 short item;
1776 Boolean checked;
1777 if (!PyArg_ParseTuple(_args, "hb",
1778 &item,
1779 &checked))
1780 return NULL;
1781 CheckMenuItem(_self->ob_itself,
1782 item,
1783 checked);
1784 Py_INCREF(Py_None);
1785 _res = Py_None;
1786 return _res;
1787}
1788
Guido van Rossum17448e21995-01-30 11:53:55 +00001789static PyMethodDef MenuObj_methods[] = {
1790 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1791 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001792 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1793 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001794 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1795 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001796
Jack Jansen74a1e632000-07-14 22:37:27 +00001797#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001798 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1799 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001800#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001801 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1802 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1803 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1804 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1805 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1806 "() -> (Boolean _rv)"},
1807 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1808 "(Boolean excludesMark) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001809 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001810 "(Str255 data) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001811 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1812 "(ResType theType, short afterItem) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001813 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1814 "(ResType theType) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001815 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001816 "(Str255 itemString, short afterItem) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001817 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001818 "(short item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001819 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1820 "(short afterItem, short scriptFilter) -> None"},
1821 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1822 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1823 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1824 "(Str255 inString) -> None"},
1825 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001826 "(Str255 inString, MenuItemIndex afterItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001827 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1828 "(short top, short left, short popUpItem) -> (long _rv)"},
1829 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001830 "(MenuID beforeID) -> None"},
1831 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1832 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001833
Jack Jansen74a1e632000-07-14 22:37:27 +00001834#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001835 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1836 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001837#endif
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001838 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001839 "(short item, Str255 itemString) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001840 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001841 "(short item) -> (Str255 itemString)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001842 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001843 "(short item, CharParameter markChar) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001844 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001845 "(short item) -> (CharParameter markChar)"},
1846 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1847 "(short item, CharParameter cmdChar) -> None"},
1848 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1849 "(short item) -> (CharParameter cmdChar)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001850 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1851 "(short item, short iconIndex) -> None"},
1852 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1853 "(short item) -> (short iconIndex)"},
1854 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
Jack Jansend6b6d881998-02-25 15:45:21 +00001855 "(short item, StyleParameter chStyle) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001856 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
Jack Jansen7d0bc831995-06-09 20:56:31 +00001857 "(short item) -> (Style chStyle)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001858
Jack Jansen74a1e632000-07-14 22:37:27 +00001859#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001860 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1861 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001862#endif
1863
Jack Jansen74a1e632000-07-14 22:37:27 +00001864#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001865 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1866 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001867#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001868 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001869 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001870 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001871 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001872 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1873 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1874 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1875 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1876 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1877 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1878 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1879 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1880 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1881 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1882 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1883 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1884 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001885 "(SInt16 inItem, MenuID inHierID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001886 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001887 "(SInt16 inItem) -> (MenuID outHierID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001888 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1889 "(SInt16 inItem, SInt16 inFontID) -> None"},
1890 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1891 "(SInt16 inItem) -> (SInt16 outFontID)"},
1892 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1893 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1894 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1895 "(SInt16 inItem) -> (UInt32 outRefCon)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001896
Jack Jansen74a1e632000-07-14 22:37:27 +00001897#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001898 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1899 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001900#endif
1901
Jack Jansen74a1e632000-07-14 22:37:27 +00001902#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001903 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1904 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001905#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001906 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1907 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1908 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1909 "(SInt16 inItem) -> (SInt16 outGlyph)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001910 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001911 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001912 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001913 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001914 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001915 "(MenuItemIndex item) -> (Boolean _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001916 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001917 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001918 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001919 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001920 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001921 "(MenuItemIndex item) -> (Boolean _rv)"},
1922
1923#if TARGET_API_MAC_CARBON
1924 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1925 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1926#endif
1927
1928#if TARGET_API_MAC_CARBON
1929 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1930 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1931#endif
1932
1933#if TARGET_API_MAC_CARBON
1934 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1935 "() -> (MenuAttributes outAttributes)"},
1936#endif
1937
1938#if TARGET_API_MAC_CARBON
1939 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1940 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1941#endif
1942
1943#if TARGET_API_MAC_CARBON
1944 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1945 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1946#endif
1947
1948#if TARGET_API_MAC_CARBON
1949 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1950 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1951#endif
1952
1953#if TARGET_API_MAC_CARBON
1954 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1955 "() -> None"},
1956#endif
1957
1958#if TARGET_API_MAC_CARBON
1959 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1960 "() -> None"},
1961#endif
1962
1963#if TARGET_API_MAC_CARBON
1964 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1965 "() -> (Boolean _rv)"},
1966#endif
1967
1968#if TARGET_API_MAC_CARBON
1969 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1970 "(MenuCommand commandID) -> (ItemCount _rv)"},
1971#endif
1972
1973#if TARGET_API_MAC_CARBON
1974 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1975 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1976#endif
1977
1978#if TARGET_API_MAC_CARBON
1979 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1980 "(MenuCommand commandID) -> None"},
1981#endif
1982
1983#if TARGET_API_MAC_CARBON
1984 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1985 "(MenuCommand commandID) -> None"},
1986#endif
1987
1988#if TARGET_API_MAC_CARBON
1989 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1990 "(MenuCommand commandID) -> (Boolean _rv)"},
1991#endif
1992
1993#if TARGET_API_MAC_CARBON
1994 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1995 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1996#endif
1997
1998#if TARGET_API_MAC_CARBON
1999 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
2000 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
2001#endif
2002
2003#if TARGET_API_MAC_CARBON
2004 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
2005 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
2006#endif
2007
2008#if TARGET_API_MAC_CARBON
2009 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
2010 "() -> (ItemCount outHierMenuCount)"},
2011#endif
2012
2013#if TARGET_API_MAC_CARBON
2014 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
2015 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
2016#endif
2017 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
2018 "() -> (MenuID _rv)"},
2019 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
2020 "() -> (SInt16 _rv)"},
2021 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
2022 "() -> (SInt16 _rv)"},
2023 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
2024 "(MenuID menuID) -> None"},
2025 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
2026 "(SInt16 width) -> None"},
2027 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
2028 "(SInt16 height) -> None"},
Jack Jansena1772281995-06-18 20:17:27 +00002029 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
Jack Jansena1a0fef1999-12-23 14:32:06 +00002030 "() -> (Handle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002031 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
2032 "(Str255 data) -> None"},
2033 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
2034 "(short beforeID) -> None"},
2035 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
2036 "(Str255 itemString, short afterItem) -> None"},
Jack Jansen54c07872001-01-29 13:32:10 +00002037 {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1,
2038 "(UInt16 item) -> None"},
2039 {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1,
2040 "(short item, Boolean checked) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002041 {NULL, NULL, 0}
2042};
2043
2044PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
2045
2046static PyObject *MenuObj_getattr(self, name)
2047 MenuObject *self;
2048 char *name;
2049{
2050 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
2051}
2052
2053#define MenuObj_setattr NULL
2054
Jack Jansena05ac601999-12-12 21:41:51 +00002055#define MenuObj_compare NULL
2056
2057#define MenuObj_repr NULL
2058
2059#define MenuObj_hash NULL
2060
Guido van Rossum17448e21995-01-30 11:53:55 +00002061PyTypeObject Menu_Type = {
2062 PyObject_HEAD_INIT(&PyType_Type)
2063 0, /*ob_size*/
2064 "Menu", /*tp_name*/
2065 sizeof(MenuObject), /*tp_basicsize*/
2066 0, /*tp_itemsize*/
2067 /* methods */
2068 (destructor) MenuObj_dealloc, /*tp_dealloc*/
2069 0, /*tp_print*/
2070 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
2071 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002072 (cmpfunc) MenuObj_compare, /*tp_compare*/
2073 (reprfunc) MenuObj_repr, /*tp_repr*/
2074 (PyNumberMethods *)0, /* tp_as_number */
2075 (PySequenceMethods *)0, /* tp_as_sequence */
2076 (PyMappingMethods *)0, /* tp_as_mapping */
2077 (hashfunc) MenuObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002078};
2079
2080/* ---------------------- End object type Menu ---------------------- */
2081
2082
Jack Jansen74a1e632000-07-14 22:37:27 +00002083#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002084
Jack Jansena05ac601999-12-12 21:41:51 +00002085static PyObject *Menu_InitProcMenu(_self, _args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002086 PyObject *_self;
2087 PyObject *_args;
2088{
2089 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002090 short resID;
2091 if (!PyArg_ParseTuple(_args, "h",
2092 &resID))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002093 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002094 InitProcMenu(resID);
2095 Py_INCREF(Py_None);
2096 _res = Py_None;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002097 return _res;
2098}
Jack Jansene79dc762000-06-02 21:35:07 +00002099#endif
2100
Jack Jansen74a1e632000-07-14 22:37:27 +00002101#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002102
Guido van Rossum17448e21995-01-30 11:53:55 +00002103static PyObject *Menu_InitMenus(_self, _args)
2104 PyObject *_self;
2105 PyObject *_args;
2106{
2107 PyObject *_res = NULL;
2108 if (!PyArg_ParseTuple(_args, ""))
2109 return NULL;
2110 InitMenus();
2111 Py_INCREF(Py_None);
2112 _res = Py_None;
2113 return _res;
2114}
Jack Jansene79dc762000-06-02 21:35:07 +00002115#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002116
2117static PyObject *Menu_NewMenu(_self, _args)
2118 PyObject *_self;
2119 PyObject *_args;
2120{
2121 PyObject *_res = NULL;
2122 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002123 MenuID menuID;
Guido van Rossum17448e21995-01-30 11:53:55 +00002124 Str255 menuTitle;
2125 if (!PyArg_ParseTuple(_args, "hO&",
2126 &menuID,
2127 PyMac_GetStr255, menuTitle))
2128 return NULL;
2129 _rv = NewMenu(menuID,
2130 menuTitle);
2131 _res = Py_BuildValue("O&",
2132 MenuObj_New, _rv);
2133 return _res;
2134}
2135
Jack Jansen1c4e6141998-04-21 15:23:55 +00002136static PyObject *Menu_MacGetMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002137 PyObject *_self;
2138 PyObject *_args;
2139{
2140 PyObject *_res = NULL;
2141 MenuHandle _rv;
2142 short resourceID;
2143 if (!PyArg_ParseTuple(_args, "h",
2144 &resourceID))
2145 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002146 _rv = MacGetMenu(resourceID);
Guido van Rossum17448e21995-01-30 11:53:55 +00002147 _res = Py_BuildValue("O&",
2148 MenuObj_New, _rv);
2149 return _res;
2150}
2151
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002152#if TARGET_API_MAC_CARBON
2153
2154static PyObject *Menu_CreateNewMenu(_self, _args)
2155 PyObject *_self;
2156 PyObject *_args;
2157{
2158 PyObject *_res = NULL;
2159 OSStatus _err;
2160 MenuID menuID;
2161 MenuAttributes menuAttributes;
2162 MenuHandle outMenuRef;
2163 if (!PyArg_ParseTuple(_args, "hl",
2164 &menuID,
2165 &menuAttributes))
2166 return NULL;
2167 _err = CreateNewMenu(menuID,
2168 menuAttributes,
2169 &outMenuRef);
2170 if (_err != noErr) return PyMac_Error(_err);
2171 _res = Py_BuildValue("O&",
2172 MenuObj_New, outMenuRef);
2173 return _res;
2174}
2175#endif
2176
Guido van Rossum17448e21995-01-30 11:53:55 +00002177static PyObject *Menu_MenuKey(_self, _args)
2178 PyObject *_self;
2179 PyObject *_args;
2180{
2181 PyObject *_res = NULL;
2182 long _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002183 CharParameter ch;
Guido van Rossum17448e21995-01-30 11:53:55 +00002184 if (!PyArg_ParseTuple(_args, "h",
2185 &ch))
2186 return NULL;
2187 _rv = MenuKey(ch);
2188 _res = Py_BuildValue("l",
2189 _rv);
2190 return _res;
2191}
2192
Jack Jansena05ac601999-12-12 21:41:51 +00002193static PyObject *Menu_MenuSelect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002194 PyObject *_self;
2195 PyObject *_args;
2196{
2197 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002198 long _rv;
2199 Point startPt;
2200 if (!PyArg_ParseTuple(_args, "O&",
2201 PyMac_GetPoint, &startPt))
Guido van Rossum17448e21995-01-30 11:53:55 +00002202 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002203 _rv = MenuSelect(startPt);
2204 _res = Py_BuildValue("l",
2205 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002206 return _res;
2207}
2208
Guido van Rossum17448e21995-01-30 11:53:55 +00002209static PyObject *Menu_MenuChoice(_self, _args)
2210 PyObject *_self;
2211 PyObject *_args;
2212{
2213 PyObject *_res = NULL;
2214 long _rv;
2215 if (!PyArg_ParseTuple(_args, ""))
2216 return NULL;
2217 _rv = MenuChoice();
2218 _res = Py_BuildValue("l",
2219 _rv);
2220 return _res;
2221}
2222
Jack Jansena05ac601999-12-12 21:41:51 +00002223static PyObject *Menu_MenuEvent(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002224 PyObject *_self;
2225 PyObject *_args;
2226{
2227 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002228 UInt32 _rv;
2229 EventRecord inEvent;
2230 if (!PyArg_ParseTuple(_args, "O&",
2231 PyMac_GetEventRecord, &inEvent))
Guido van Rossum17448e21995-01-30 11:53:55 +00002232 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002233 _rv = MenuEvent(&inEvent);
2234 _res = Py_BuildValue("l",
2235 _rv);
2236 return _res;
2237}
2238
2239static PyObject *Menu_GetMBarHeight(_self, _args)
2240 PyObject *_self;
2241 PyObject *_args;
2242{
2243 PyObject *_res = NULL;
2244 short _rv;
2245 if (!PyArg_ParseTuple(_args, ""))
2246 return NULL;
2247 _rv = GetMBarHeight();
2248 _res = Py_BuildValue("h",
2249 _rv);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002250 return _res;
2251}
2252
Jack Jansen1c4e6141998-04-21 15:23:55 +00002253static PyObject *Menu_MacDrawMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002254 PyObject *_self;
2255 PyObject *_args;
2256{
2257 PyObject *_res = NULL;
2258 if (!PyArg_ParseTuple(_args, ""))
2259 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002260 MacDrawMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002261 Py_INCREF(Py_None);
2262 _res = Py_None;
2263 return _res;
2264}
2265
2266static PyObject *Menu_InvalMenuBar(_self, _args)
2267 PyObject *_self;
2268 PyObject *_args;
2269{
2270 PyObject *_res = NULL;
2271 if (!PyArg_ParseTuple(_args, ""))
2272 return NULL;
2273 InvalMenuBar();
2274 Py_INCREF(Py_None);
2275 _res = Py_None;
2276 return _res;
2277}
2278
Jack Jansena05ac601999-12-12 21:41:51 +00002279static PyObject *Menu_HiliteMenu(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002280 PyObject *_self;
2281 PyObject *_args;
2282{
2283 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002284 MenuID menuID;
Jack Jansen21f96871998-02-20 16:02:09 +00002285 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00002286 &menuID))
Jack Jansen21f96871998-02-20 16:02:09 +00002287 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002288 HiliteMenu(menuID);
Jack Jansen21f96871998-02-20 16:02:09 +00002289 Py_INCREF(Py_None);
2290 _res = Py_None;
2291 return _res;
2292}
2293
Jack Jansena05ac601999-12-12 21:41:51 +00002294static PyObject *Menu_GetNewMBar(_self, _args)
2295 PyObject *_self;
2296 PyObject *_args;
2297{
2298 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002299 MenuBarHandle _rv;
Jack Jansena05ac601999-12-12 21:41:51 +00002300 short menuBarID;
2301 if (!PyArg_ParseTuple(_args, "h",
2302 &menuBarID))
2303 return NULL;
2304 _rv = GetNewMBar(menuBarID);
2305 _res = Py_BuildValue("O&",
2306 ResObj_New, _rv);
2307 return _res;
2308}
2309
Jack Jansen21f96871998-02-20 16:02:09 +00002310static PyObject *Menu_GetMenuBar(_self, _args)
2311 PyObject *_self;
2312 PyObject *_args;
2313{
2314 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002315 MenuBarHandle _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002316 if (!PyArg_ParseTuple(_args, ""))
2317 return NULL;
2318 _rv = GetMenuBar();
2319 _res = Py_BuildValue("O&",
2320 ResObj_New, _rv);
2321 return _res;
2322}
2323
2324static PyObject *Menu_SetMenuBar(_self, _args)
2325 PyObject *_self;
2326 PyObject *_args;
2327{
2328 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002329 MenuBarHandle mbar;
Jack Jansen21f96871998-02-20 16:02:09 +00002330 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002331 ResObj_Convert, &mbar))
Jack Jansen21f96871998-02-20 16:02:09 +00002332 return NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002333 SetMenuBar(mbar);
Jack Jansen21f96871998-02-20 16:02:09 +00002334 Py_INCREF(Py_None);
2335 _res = Py_None;
2336 return _res;
2337}
2338
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002339#if TARGET_API_MAC_CARBON
2340
2341static PyObject *Menu_DuplicateMenuBar(_self, _args)
2342 PyObject *_self;
2343 PyObject *_args;
2344{
2345 PyObject *_res = NULL;
2346 OSStatus _err;
2347 MenuBarHandle mbar;
2348 MenuBarHandle outBar;
2349 if (!PyArg_ParseTuple(_args, "O&",
2350 ResObj_Convert, &mbar))
2351 return NULL;
2352 _err = DuplicateMenuBar(mbar,
2353 &outBar);
2354 if (_err != noErr) return PyMac_Error(_err);
2355 _res = Py_BuildValue("O&",
2356 ResObj_New, outBar);
2357 return _res;
2358}
2359#endif
2360
2361#if TARGET_API_MAC_CARBON
2362
2363static PyObject *Menu_DisposeMenuBar(_self, _args)
2364 PyObject *_self;
2365 PyObject *_args;
2366{
2367 PyObject *_res = NULL;
2368 OSStatus _err;
2369 MenuBarHandle mbar;
2370 if (!PyArg_ParseTuple(_args, "O&",
2371 ResObj_Convert, &mbar))
2372 return NULL;
2373 _err = DisposeMenuBar(mbar);
2374 if (_err != noErr) return PyMac_Error(_err);
2375 Py_INCREF(Py_None);
2376 _res = Py_None;
2377 return _res;
2378}
2379#endif
2380
Jack Jansena05ac601999-12-12 21:41:51 +00002381static PyObject *Menu_GetMenuHandle(_self, _args)
2382 PyObject *_self;
2383 PyObject *_args;
2384{
2385 PyObject *_res = NULL;
2386 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002387 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002388 if (!PyArg_ParseTuple(_args, "h",
2389 &menuID))
2390 return NULL;
2391 _rv = GetMenuHandle(menuID);
2392 _res = Py_BuildValue("O&",
2393 MenuObj_New, _rv);
2394 return _res;
2395}
2396
2397static PyObject *Menu_MacDeleteMenu(_self, _args)
2398 PyObject *_self;
2399 PyObject *_args;
2400{
2401 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002402 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002403 if (!PyArg_ParseTuple(_args, "h",
2404 &menuID))
2405 return NULL;
2406 MacDeleteMenu(menuID);
2407 Py_INCREF(Py_None);
2408 _res = Py_None;
2409 return _res;
2410}
2411
2412static PyObject *Menu_ClearMenuBar(_self, _args)
2413 PyObject *_self;
2414 PyObject *_args;
2415{
2416 PyObject *_res = NULL;
2417 if (!PyArg_ParseTuple(_args, ""))
2418 return NULL;
2419 ClearMenuBar();
2420 Py_INCREF(Py_None);
2421 _res = Py_None;
2422 return _res;
2423}
2424
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002425static PyObject *Menu_SetMenuFlashCount(_self, _args)
2426 PyObject *_self;
2427 PyObject *_args;
2428{
2429 PyObject *_res = NULL;
2430 short count;
2431 if (!PyArg_ParseTuple(_args, "h",
2432 &count))
2433 return NULL;
2434 SetMenuFlashCount(count);
2435 Py_INCREF(Py_None);
2436 _res = Py_None;
2437 return _res;
2438}
2439
Jack Jansen74a1e632000-07-14 22:37:27 +00002440#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002441
Jack Jansena05ac601999-12-12 21:41:51 +00002442static PyObject *Menu_SetMenuFlash(_self, _args)
2443 PyObject *_self;
2444 PyObject *_args;
2445{
2446 PyObject *_res = NULL;
2447 short count;
2448 if (!PyArg_ParseTuple(_args, "h",
2449 &count))
2450 return NULL;
2451 SetMenuFlash(count);
2452 Py_INCREF(Py_None);
2453 _res = Py_None;
2454 return _res;
2455}
Jack Jansene79dc762000-06-02 21:35:07 +00002456#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002457
2458static PyObject *Menu_FlashMenuBar(_self, _args)
2459 PyObject *_self;
2460 PyObject *_args;
2461{
2462 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002463 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002464 if (!PyArg_ParseTuple(_args, "h",
2465 &menuID))
2466 return NULL;
2467 FlashMenuBar(menuID);
2468 Py_INCREF(Py_None);
2469 _res = Py_None;
2470 return _res;
2471}
2472
Jack Jansen74a1e632000-07-14 22:37:27 +00002473#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002474
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002475static PyObject *Menu_SystemEdit(_self, _args)
2476 PyObject *_self;
2477 PyObject *_args;
2478{
2479 PyObject *_res = NULL;
2480 Boolean _rv;
2481 short editCmd;
2482 if (!PyArg_ParseTuple(_args, "h",
2483 &editCmd))
2484 return NULL;
2485 _rv = SystemEdit(editCmd);
2486 _res = Py_BuildValue("b",
2487 _rv);
2488 return _res;
2489}
Jack Jansene79dc762000-06-02 21:35:07 +00002490#endif
2491
Jack Jansen74a1e632000-07-14 22:37:27 +00002492#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002493
2494static PyObject *Menu_SystemMenu(_self, _args)
2495 PyObject *_self;
2496 PyObject *_args;
2497{
2498 PyObject *_res = NULL;
2499 long menuResult;
2500 if (!PyArg_ParseTuple(_args, "l",
2501 &menuResult))
2502 return NULL;
2503 SystemMenu(menuResult);
Guido van Rossum17448e21995-01-30 11:53:55 +00002504 Py_INCREF(Py_None);
2505 _res = Py_None;
2506 return _res;
2507}
Jack Jansene79dc762000-06-02 21:35:07 +00002508#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002509
Jack Jansena05ac601999-12-12 21:41:51 +00002510static PyObject *Menu_IsMenuBarVisible(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002511 PyObject *_self;
2512 PyObject *_args;
2513{
2514 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002515 Boolean _rv;
2516 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002517 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002518 _rv = IsMenuBarVisible();
2519 _res = Py_BuildValue("b",
2520 _rv);
Jack Jansen21f96871998-02-20 16:02:09 +00002521 return _res;
2522}
2523
Jack Jansena05ac601999-12-12 21:41:51 +00002524static PyObject *Menu_ShowMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002525 PyObject *_self;
2526 PyObject *_args;
2527{
2528 PyObject *_res = NULL;
2529 if (!PyArg_ParseTuple(_args, ""))
2530 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002531 ShowMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002532 Py_INCREF(Py_None);
2533 _res = Py_None;
2534 return _res;
2535}
2536
Jack Jansena05ac601999-12-12 21:41:51 +00002537static PyObject *Menu_HideMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002538 PyObject *_self;
2539 PyObject *_args;
2540{
2541 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002542 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002543 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002544 HideMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002545 Py_INCREF(Py_None);
2546 _res = Py_None;
2547 return _res;
2548}
2549
Jack Jansena05ac601999-12-12 21:41:51 +00002550static PyObject *Menu_DeleteMCEntries(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002551 PyObject *_self;
2552 PyObject *_args;
2553{
2554 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002555 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002556 short menuItem;
2557 if (!PyArg_ParseTuple(_args, "hh",
2558 &menuID,
2559 &menuItem))
Jack Jansen21f96871998-02-20 16:02:09 +00002560 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002561 DeleteMCEntries(menuID,
2562 menuItem);
2563 Py_INCREF(Py_None);
2564 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00002565 return _res;
2566}
2567
Jack Jansena05ac601999-12-12 21:41:51 +00002568static PyObject *Menu_InitContextualMenus(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002569 PyObject *_self;
2570 PyObject *_args;
2571{
2572 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002573 OSStatus _err;
2574 if (!PyArg_ParseTuple(_args, ""))
2575 return NULL;
2576 _err = InitContextualMenus();
2577 if (_err != noErr) return PyMac_Error(_err);
2578 Py_INCREF(Py_None);
2579 _res = Py_None;
2580 return _res;
2581}
2582
2583static PyObject *Menu_IsShowContextualMenuClick(_self, _args)
2584 PyObject *_self;
2585 PyObject *_args;
2586{
2587 PyObject *_res = NULL;
2588 Boolean _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002589 EventRecord inEvent;
2590 if (!PyArg_ParseTuple(_args, "O&",
2591 PyMac_GetEventRecord, &inEvent))
2592 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002593 _rv = IsShowContextualMenuClick(&inEvent);
2594 _res = Py_BuildValue("b",
Jack Jansen21f96871998-02-20 16:02:09 +00002595 _rv);
2596 return _res;
2597}
2598
Jack Jansen74a1e632000-07-14 22:37:27 +00002599#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002600
Guido van Rossum86c3af71995-03-19 22:42:51 +00002601static PyObject *Menu_OpenDeskAcc(_self, _args)
2602 PyObject *_self;
2603 PyObject *_args;
2604{
2605 PyObject *_res = NULL;
2606 Str255 name;
2607 if (!PyArg_ParseTuple(_args, "O&",
2608 PyMac_GetStr255, name))
2609 return NULL;
2610 OpenDeskAcc(name);
2611 Py_INCREF(Py_None);
2612 _res = Py_None;
2613 return _res;
2614}
Jack Jansene79dc762000-06-02 21:35:07 +00002615#endif
Guido van Rossum86c3af71995-03-19 22:42:51 +00002616
Jack Jansene0581891999-02-07 14:02:03 +00002617static PyObject *Menu_as_Menu(_self, _args)
2618 PyObject *_self;
2619 PyObject *_args;
2620{
2621 PyObject *_res = NULL;
2622 MenuHandle _rv;
2623 Handle h;
2624 if (!PyArg_ParseTuple(_args, "O&",
2625 ResObj_Convert, &h))
2626 return NULL;
2627 _rv = as_Menu(h);
2628 _res = Py_BuildValue("O&",
2629 MenuObj_New, _rv);
2630 return _res;
2631}
2632
Jack Jansene180d991998-04-24 10:28:20 +00002633static PyObject *Menu_GetMenu(_self, _args)
2634 PyObject *_self;
2635 PyObject *_args;
2636{
2637 PyObject *_res = NULL;
2638 MenuHandle _rv;
2639 short resourceID;
2640 if (!PyArg_ParseTuple(_args, "h",
2641 &resourceID))
2642 return NULL;
2643 _rv = GetMenu(resourceID);
2644 _res = Py_BuildValue("O&",
2645 MenuObj_New, _rv);
2646 return _res;
2647}
2648
2649static PyObject *Menu_DeleteMenu(_self, _args)
2650 PyObject *_self;
2651 PyObject *_args;
2652{
2653 PyObject *_res = NULL;
2654 short menuID;
2655 if (!PyArg_ParseTuple(_args, "h",
2656 &menuID))
2657 return NULL;
2658 DeleteMenu(menuID);
2659 Py_INCREF(Py_None);
2660 _res = Py_None;
2661 return _res;
2662}
2663
2664static PyObject *Menu_DrawMenuBar(_self, _args)
2665 PyObject *_self;
2666 PyObject *_args;
2667{
2668 PyObject *_res = NULL;
2669 if (!PyArg_ParseTuple(_args, ""))
2670 return NULL;
2671 DrawMenuBar();
2672 Py_INCREF(Py_None);
2673 _res = Py_None;
2674 return _res;
2675}
2676
Guido van Rossum17448e21995-01-30 11:53:55 +00002677static PyMethodDef Menu_methods[] = {
Jack Jansene79dc762000-06-02 21:35:07 +00002678
Jack Jansen74a1e632000-07-14 22:37:27 +00002679#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002680 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2681 "(short resID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002682#endif
2683
Jack Jansen74a1e632000-07-14 22:37:27 +00002684#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002685 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2686 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002687#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002688 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002689 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002690 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00002691 "(short resourceID) -> (MenuHandle _rv)"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002692
2693#if TARGET_API_MAC_CARBON
2694 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2695 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2696#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002697 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002698 "(CharParameter ch) -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002699 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2700 "(Point startPt) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002701 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2702 "() -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002703 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2704 "(EventRecord inEvent) -> (UInt32 _rv)"},
2705 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2706 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002707 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002708 "() -> None"},
2709 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2710 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002711 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002712 "(MenuID menuID) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002713 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002714 "(short menuBarID) -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002715 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002716 "() -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002717 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002718 "(MenuBarHandle mbar) -> None"},
2719
2720#if TARGET_API_MAC_CARBON
2721 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2722 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2723#endif
2724
2725#if TARGET_API_MAC_CARBON
2726 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2727 "(MenuBarHandle mbar) -> None"},
2728#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002729 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002730 "(MenuID menuID) -> (MenuHandle _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002731 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002732 "(MenuID menuID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002733 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2734 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002735 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2736 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002737
Jack Jansen74a1e632000-07-14 22:37:27 +00002738#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002739 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2740 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002741#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002742 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002743 "(MenuID menuID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002744
Jack Jansen74a1e632000-07-14 22:37:27 +00002745#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002746 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2747 "(short editCmd) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002748#endif
2749
Jack Jansen74a1e632000-07-14 22:37:27 +00002750#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002751 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2752 "(long menuResult) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002753#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002754 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2755 "() -> (Boolean _rv)"},
2756 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2757 "() -> None"},
2758 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2759 "() -> None"},
2760 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002761 "(MenuID menuID, short menuItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002762 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2763 "() -> None"},
2764 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2765 "(EventRecord inEvent) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002766
Jack Jansen74a1e632000-07-14 22:37:27 +00002767#if !TARGET_API_MAC_CARBON
Guido van Rossum86c3af71995-03-19 22:42:51 +00002768 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2769 "(Str255 name) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002770#endif
Jack Jansene0581891999-02-07 14:02:03 +00002771 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2772 "(Handle h) -> (MenuHandle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002773 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2774 "(short resourceID) -> (MenuHandle _rv)"},
2775 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2776 "(short menuID) -> None"},
2777 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2778 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002779 {NULL, NULL, 0}
2780};
2781
2782
2783
2784
2785void initMenu()
2786{
2787 PyObject *m;
2788 PyObject *d;
2789
2790
2791
Jack Jansen0e04eec2001-05-17 21:58:34 +00002792 PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuObj_New);
2793 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuObj_Convert);
2794
Guido van Rossum17448e21995-01-30 11:53:55 +00002795
2796 m = Py_InitModule("Menu", Menu_methods);
2797 d = PyModule_GetDict(m);
2798 Menu_Error = PyMac_GetOSErrException();
2799 if (Menu_Error == NULL ||
2800 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002801 return;
Jack Jansena755e681997-09-20 17:40:22 +00002802 Menu_Type.ob_type = &PyType_Type;
2803 Py_INCREF(&Menu_Type);
2804 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2805 Py_FatalError("can't initialize MenuType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002806}
2807
2808/* ======================== End module Menu ========================= */
2809