blob: 7f1533098f47063ba58bf399b4e320c8888573c3 [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 Jansenf7d5aa62000-12-10 23:43:49 +000014#if !ACCESSOR_CALLS_ARE_FUNCTIONS
15#define GetMenuID(menu) ((*(menu))->menuID)
16#define GetMenuWidth(menu) ((*(menu))->menuWidth)
17#define GetMenuHeight(menu) ((*(menu))->menuHeight)
18
19#define SetMenuID(menu, id) ((*(menu))->menuID = (id))
20#define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width))
21#define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height))
22#endif
23
Jack Jansene0581891999-02-07 14:02:03 +000024#define as_Menu(h) ((MenuHandle)h)
Jack Jansena1a0fef1999-12-23 14:32:06 +000025#define as_Resource(h) ((Handle)h)
Jack Jansene0581891999-02-07 14:02:03 +000026
Guido van Rossum17448e21995-01-30 11:53:55 +000027static PyObject *Menu_Error;
28
29/* ------------------------ Object type Menu ------------------------ */
30
31PyTypeObject Menu_Type;
32
33#define MenuObj_Check(x) ((x)->ob_type == &Menu_Type)
34
35typedef struct MenuObject {
36 PyObject_HEAD
37 MenuHandle ob_itself;
38} MenuObject;
39
40PyObject *MenuObj_New(itself)
Guido van Rossum227a4231995-03-10 14:42:57 +000041 MenuHandle itself;
Guido van Rossum17448e21995-01-30 11:53:55 +000042{
43 MenuObject *it;
44 it = PyObject_NEW(MenuObject, &Menu_Type);
45 if (it == NULL) return NULL;
46 it->ob_itself = itself;
47 return (PyObject *)it;
48}
49MenuObj_Convert(v, p_itself)
50 PyObject *v;
51 MenuHandle *p_itself;
52{
53 if (!MenuObj_Check(v))
54 {
55 PyErr_SetString(PyExc_TypeError, "Menu required");
56 return 0;
57 }
58 *p_itself = ((MenuObject *)v)->ob_itself;
59 return 1;
60}
61
62static void MenuObj_dealloc(self)
63 MenuObject *self;
64{
65 /* Cleanup of self->ob_itself goes here */
66 PyMem_DEL(self);
67}
68
69static PyObject *MenuObj_DisposeMenu(_self, _args)
70 MenuObject *_self;
71 PyObject *_args;
72{
73 PyObject *_res = NULL;
74 if (!PyArg_ParseTuple(_args, ""))
75 return NULL;
76 DisposeMenu(_self->ob_itself);
77 Py_INCREF(Py_None);
78 _res = Py_None;
79 return _res;
80}
81
Jack Jansena05ac601999-12-12 21:41:51 +000082static PyObject *MenuObj_CalcMenuSize(_self, _args)
83 MenuObject *_self;
84 PyObject *_args;
85{
86 PyObject *_res = NULL;
87 if (!PyArg_ParseTuple(_args, ""))
88 return NULL;
89 CalcMenuSize(_self->ob_itself);
90 Py_INCREF(Py_None);
91 _res = Py_None;
92 return _res;
93}
94
Jack Jansenf7d5aa62000-12-10 23:43:49 +000095static PyObject *MenuObj_CountMenuItems(_self, _args)
96 MenuObject *_self;
97 PyObject *_args;
98{
99 PyObject *_res = NULL;
100 short _rv;
101 if (!PyArg_ParseTuple(_args, ""))
102 return NULL;
103 _rv = CountMenuItems(_self->ob_itself);
104 _res = Py_BuildValue("h",
105 _rv);
106 return _res;
107}
108
Jack Jansen74a1e632000-07-14 22:37:27 +0000109#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000110
Jack Jansena05ac601999-12-12 21:41:51 +0000111static PyObject *MenuObj_CountMItems(_self, _args)
112 MenuObject *_self;
113 PyObject *_args;
114{
115 PyObject *_res = NULL;
116 short _rv;
117 if (!PyArg_ParseTuple(_args, ""))
118 return NULL;
119 _rv = CountMItems(_self->ob_itself);
120 _res = Py_BuildValue("h",
121 _rv);
122 return _res;
123}
Jack Jansene79dc762000-06-02 21:35:07 +0000124#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000125
126static PyObject *MenuObj_GetMenuFont(_self, _args)
127 MenuObject *_self;
128 PyObject *_args;
129{
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);
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000140 _res = Py_BuildValue("hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000141 outFontID,
142 outFontSize);
143 return _res;
144}
145
146static PyObject *MenuObj_SetMenuFont(_self, _args)
147 MenuObject *_self;
148 PyObject *_args;
149{
150 PyObject *_res = NULL;
151 OSStatus _err;
152 SInt16 inFontID;
153 UInt16 inFontSize;
Jack Jansen0b13e7c2000-07-07 13:09:35 +0000154 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansena05ac601999-12-12 21:41:51 +0000155 &inFontID,
156 &inFontSize))
157 return NULL;
158 _err = SetMenuFont(_self->ob_itself,
159 inFontID,
160 inFontSize);
161 if (_err != noErr) return PyMac_Error(_err);
162 Py_INCREF(Py_None);
163 _res = Py_None;
164 return _res;
165}
166
167static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args)
168 MenuObject *_self;
169 PyObject *_args;
170{
171 PyObject *_res = NULL;
172 Boolean _rv;
173 if (!PyArg_ParseTuple(_args, ""))
174 return NULL;
175 _rv = GetMenuExcludesMarkColumn(_self->ob_itself);
176 _res = Py_BuildValue("b",
177 _rv);
178 return _res;
179}
180
181static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args)
182 MenuObject *_self;
183 PyObject *_args;
184{
185 PyObject *_res = NULL;
186 OSStatus _err;
187 Boolean excludesMark;
188 if (!PyArg_ParseTuple(_args, "b",
189 &excludesMark))
190 return NULL;
191 _err = SetMenuExcludesMarkColumn(_self->ob_itself,
192 excludesMark);
193 if (_err != noErr) return PyMac_Error(_err);
194 Py_INCREF(Py_None);
195 _res = Py_None;
196 return _res;
197}
198
Jack Jansen1c4e6141998-04-21 15:23:55 +0000199static PyObject *MenuObj_MacAppendMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000200 MenuObject *_self;
201 PyObject *_args;
202{
203 PyObject *_res = NULL;
204 Str255 data;
205 if (!PyArg_ParseTuple(_args, "O&",
206 PyMac_GetStr255, data))
207 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000208 MacAppendMenu(_self->ob_itself,
209 data);
Guido van Rossum17448e21995-01-30 11:53:55 +0000210 Py_INCREF(Py_None);
211 _res = Py_None;
212 return _res;
213}
214
Guido van Rossum17448e21995-01-30 11:53:55 +0000215static PyObject *MenuObj_InsertResMenu(_self, _args)
216 MenuObject *_self;
217 PyObject *_args;
218{
219 PyObject *_res = NULL;
220 ResType theType;
221 short afterItem;
222 if (!PyArg_ParseTuple(_args, "O&h",
223 PyMac_GetOSType, &theType,
224 &afterItem))
225 return NULL;
226 InsertResMenu(_self->ob_itself,
227 theType,
228 afterItem);
229 Py_INCREF(Py_None);
230 _res = Py_None;
231 return _res;
232}
233
Jack Jansen21f96871998-02-20 16:02:09 +0000234static PyObject *MenuObj_AppendResMenu(_self, _args)
235 MenuObject *_self;
236 PyObject *_args;
237{
238 PyObject *_res = NULL;
239 ResType theType;
240 if (!PyArg_ParseTuple(_args, "O&",
241 PyMac_GetOSType, &theType))
242 return NULL;
243 AppendResMenu(_self->ob_itself,
244 theType);
245 Py_INCREF(Py_None);
246 _res = Py_None;
247 return _res;
248}
249
Jack Jansen1c4e6141998-04-21 15:23:55 +0000250static PyObject *MenuObj_MacInsertMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000251 MenuObject *_self;
252 PyObject *_args;
253{
254 PyObject *_res = NULL;
255 Str255 itemString;
256 short afterItem;
257 if (!PyArg_ParseTuple(_args, "O&h",
258 PyMac_GetStr255, itemString,
259 &afterItem))
260 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +0000261 MacInsertMenuItem(_self->ob_itself,
262 itemString,
263 afterItem);
Guido van Rossum17448e21995-01-30 11:53:55 +0000264 Py_INCREF(Py_None);
265 _res = Py_None;
266 return _res;
267}
268
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000269static PyObject *MenuObj_DeleteMenuItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000270 MenuObject *_self;
271 PyObject *_args;
272{
273 PyObject *_res = NULL;
274 short item;
275 if (!PyArg_ParseTuple(_args, "h",
276 &item))
277 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000278 DeleteMenuItem(_self->ob_itself,
279 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000280 Py_INCREF(Py_None);
281 _res = Py_None;
282 return _res;
283}
284
Jack Jansena05ac601999-12-12 21:41:51 +0000285static PyObject *MenuObj_InsertFontResMenu(_self, _args)
286 MenuObject *_self;
287 PyObject *_args;
288{
289 PyObject *_res = NULL;
290 short afterItem;
291 short scriptFilter;
292 if (!PyArg_ParseTuple(_args, "hh",
293 &afterItem,
294 &scriptFilter))
295 return NULL;
296 InsertFontResMenu(_self->ob_itself,
297 afterItem,
298 scriptFilter);
299 Py_INCREF(Py_None);
300 _res = Py_None;
301 return _res;
302}
303
304static PyObject *MenuObj_InsertIntlResMenu(_self, _args)
305 MenuObject *_self;
306 PyObject *_args;
307{
308 PyObject *_res = NULL;
309 ResType theType;
310 short afterItem;
311 short scriptFilter;
312 if (!PyArg_ParseTuple(_args, "O&hh",
313 PyMac_GetOSType, &theType,
314 &afterItem,
315 &scriptFilter))
316 return NULL;
317 InsertIntlResMenu(_self->ob_itself,
318 theType,
319 afterItem,
320 scriptFilter);
321 Py_INCREF(Py_None);
322 _res = Py_None;
323 return _res;
324}
325
326static PyObject *MenuObj_AppendMenuItemText(_self, _args)
327 MenuObject *_self;
328 PyObject *_args;
329{
330 PyObject *_res = NULL;
331 OSStatus _err;
332 Str255 inString;
333 if (!PyArg_ParseTuple(_args, "O&",
334 PyMac_GetStr255, inString))
335 return NULL;
336 _err = AppendMenuItemText(_self->ob_itself,
337 inString);
338 if (_err != noErr) return PyMac_Error(_err);
339 Py_INCREF(Py_None);
340 _res = Py_None;
341 return _res;
342}
343
344static PyObject *MenuObj_InsertMenuItemText(_self, _args)
345 MenuObject *_self;
346 PyObject *_args;
347{
348 PyObject *_res = NULL;
349 OSStatus _err;
350 Str255 inString;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000351 MenuItemIndex afterItem;
352 if (!PyArg_ParseTuple(_args, "O&h",
Jack Jansena05ac601999-12-12 21:41:51 +0000353 PyMac_GetStr255, inString,
354 &afterItem))
355 return NULL;
356 _err = InsertMenuItemText(_self->ob_itself,
357 inString,
358 afterItem);
359 if (_err != noErr) return PyMac_Error(_err);
360 Py_INCREF(Py_None);
361 _res = Py_None;
362 return _res;
363}
364
365static PyObject *MenuObj_PopUpMenuSelect(_self, _args)
366 MenuObject *_self;
367 PyObject *_args;
368{
369 PyObject *_res = NULL;
370 long _rv;
371 short top;
372 short left;
373 short popUpItem;
374 if (!PyArg_ParseTuple(_args, "hhh",
375 &top,
376 &left,
377 &popUpItem))
378 return NULL;
379 _rv = PopUpMenuSelect(_self->ob_itself,
380 top,
381 left,
382 popUpItem);
383 _res = Py_BuildValue("l",
384 _rv);
385 return _res;
386}
387
388static PyObject *MenuObj_MacInsertMenu(_self, _args)
389 MenuObject *_self;
390 PyObject *_args;
391{
392 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000393 MenuID beforeID;
Jack Jansena05ac601999-12-12 21:41:51 +0000394 if (!PyArg_ParseTuple(_args, "h",
395 &beforeID))
396 return NULL;
397 MacInsertMenu(_self->ob_itself,
398 beforeID);
399 Py_INCREF(Py_None);
400 _res = Py_None;
401 return _res;
402}
403
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000404static PyObject *MenuObj_MacCheckMenuItem(_self, _args)
405 MenuObject *_self;
406 PyObject *_args;
407{
408 PyObject *_res = NULL;
409 short item;
410 Boolean checked;
411 if (!PyArg_ParseTuple(_args, "hb",
412 &item,
413 &checked))
414 return NULL;
415 MacCheckMenuItem(_self->ob_itself,
416 item,
417 checked);
418 Py_INCREF(Py_None);
419 _res = Py_None;
420 return _res;
421}
422
Jack Jansen74a1e632000-07-14 22:37:27 +0000423#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000424
Jack Jansena05ac601999-12-12 21:41:51 +0000425static PyObject *MenuObj_CheckItem(_self, _args)
426 MenuObject *_self;
427 PyObject *_args;
428{
429 PyObject *_res = NULL;
430 short item;
431 Boolean checked;
432 if (!PyArg_ParseTuple(_args, "hb",
433 &item,
434 &checked))
435 return NULL;
436 CheckItem(_self->ob_itself,
437 item,
438 checked);
439 Py_INCREF(Py_None);
440 _res = Py_None;
441 return _res;
442}
Jack Jansene79dc762000-06-02 21:35:07 +0000443#endif
Jack Jansena05ac601999-12-12 21:41:51 +0000444
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000445static PyObject *MenuObj_SetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000446 MenuObject *_self;
447 PyObject *_args;
448{
449 PyObject *_res = NULL;
450 short item;
451 Str255 itemString;
452 if (!PyArg_ParseTuple(_args, "hO&",
453 &item,
454 PyMac_GetStr255, itemString))
455 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000456 SetMenuItemText(_self->ob_itself,
457 item,
458 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000459 Py_INCREF(Py_None);
460 _res = Py_None;
461 return _res;
462}
463
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000464static PyObject *MenuObj_GetMenuItemText(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000465 MenuObject *_self;
466 PyObject *_args;
467{
468 PyObject *_res = NULL;
469 short item;
470 Str255 itemString;
471 if (!PyArg_ParseTuple(_args, "h",
472 &item))
473 return NULL;
Jack Jansenb81cf9d1995-06-06 13:08:40 +0000474 GetMenuItemText(_self->ob_itself,
475 item,
476 itemString);
Guido van Rossum17448e21995-01-30 11:53:55 +0000477 _res = Py_BuildValue("O&",
478 PyMac_BuildStr255, itemString);
479 return _res;
480}
481
Guido van Rossum17448e21995-01-30 11:53:55 +0000482static PyObject *MenuObj_SetItemMark(_self, _args)
483 MenuObject *_self;
484 PyObject *_args;
485{
486 PyObject *_res = NULL;
487 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000488 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000489 if (!PyArg_ParseTuple(_args, "hh",
490 &item,
491 &markChar))
492 return NULL;
493 SetItemMark(_self->ob_itself,
494 item,
495 markChar);
496 Py_INCREF(Py_None);
497 _res = Py_None;
498 return _res;
499}
500
501static PyObject *MenuObj_GetItemMark(_self, _args)
502 MenuObject *_self;
503 PyObject *_args;
504{
505 PyObject *_res = NULL;
506 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000507 CharParameter markChar;
Guido van Rossum17448e21995-01-30 11:53:55 +0000508 if (!PyArg_ParseTuple(_args, "h",
509 &item))
510 return NULL;
511 GetItemMark(_self->ob_itself,
512 item,
513 &markChar);
514 _res = Py_BuildValue("h",
515 markChar);
516 return _res;
517}
518
Jack Jansen21f96871998-02-20 16:02:09 +0000519static PyObject *MenuObj_SetItemCmd(_self, _args)
520 MenuObject *_self;
521 PyObject *_args;
522{
523 PyObject *_res = NULL;
524 short item;
525 CharParameter cmdChar;
526 if (!PyArg_ParseTuple(_args, "hh",
527 &item,
528 &cmdChar))
529 return NULL;
530 SetItemCmd(_self->ob_itself,
531 item,
532 cmdChar);
533 Py_INCREF(Py_None);
534 _res = Py_None;
535 return _res;
536}
537
538static PyObject *MenuObj_GetItemCmd(_self, _args)
539 MenuObject *_self;
540 PyObject *_args;
541{
542 PyObject *_res = NULL;
543 short item;
544 CharParameter cmdChar;
545 if (!PyArg_ParseTuple(_args, "h",
546 &item))
547 return NULL;
548 GetItemCmd(_self->ob_itself,
549 item,
550 &cmdChar);
551 _res = Py_BuildValue("h",
552 cmdChar);
553 return _res;
554}
555
Guido van Rossum17448e21995-01-30 11:53:55 +0000556static PyObject *MenuObj_SetItemIcon(_self, _args)
557 MenuObject *_self;
558 PyObject *_args;
559{
560 PyObject *_res = NULL;
561 short item;
562 short iconIndex;
563 if (!PyArg_ParseTuple(_args, "hh",
564 &item,
565 &iconIndex))
566 return NULL;
567 SetItemIcon(_self->ob_itself,
568 item,
569 iconIndex);
570 Py_INCREF(Py_None);
571 _res = Py_None;
572 return _res;
573}
574
575static PyObject *MenuObj_GetItemIcon(_self, _args)
576 MenuObject *_self;
577 PyObject *_args;
578{
579 PyObject *_res = NULL;
580 short item;
581 short iconIndex;
582 if (!PyArg_ParseTuple(_args, "h",
583 &item))
584 return NULL;
585 GetItemIcon(_self->ob_itself,
586 item,
587 &iconIndex);
588 _res = Py_BuildValue("h",
589 iconIndex);
590 return _res;
591}
592
593static PyObject *MenuObj_SetItemStyle(_self, _args)
594 MenuObject *_self;
595 PyObject *_args;
596{
597 PyObject *_res = NULL;
598 short item;
Jack Jansend6b6d881998-02-25 15:45:21 +0000599 StyleParameter chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000600 if (!PyArg_ParseTuple(_args, "hh",
601 &item,
602 &chStyle))
603 return NULL;
604 SetItemStyle(_self->ob_itself,
605 item,
606 chStyle);
607 Py_INCREF(Py_None);
608 _res = Py_None;
609 return _res;
610}
611
612static PyObject *MenuObj_GetItemStyle(_self, _args)
613 MenuObject *_self;
614 PyObject *_args;
615{
616 PyObject *_res = NULL;
617 short item;
Jack Jansen7d0bc831995-06-09 20:56:31 +0000618 Style chStyle;
Guido van Rossum17448e21995-01-30 11:53:55 +0000619 if (!PyArg_ParseTuple(_args, "h",
620 &item))
621 return NULL;
622 GetItemStyle(_self->ob_itself,
623 item,
624 &chStyle);
625 _res = Py_BuildValue("b",
626 chStyle);
627 return _res;
628}
629
Jack Jansen74a1e632000-07-14 22:37:27 +0000630#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000631
Jack Jansen21f96871998-02-20 16:02:09 +0000632static PyObject *MenuObj_DisableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000633 MenuObject *_self;
634 PyObject *_args;
635{
636 PyObject *_res = NULL;
637 short item;
Guido van Rossum17448e21995-01-30 11:53:55 +0000638 if (!PyArg_ParseTuple(_args, "h",
639 &item))
640 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000641 DisableItem(_self->ob_itself,
642 item);
643 Py_INCREF(Py_None);
644 _res = Py_None;
Guido van Rossum17448e21995-01-30 11:53:55 +0000645 return _res;
646}
Jack Jansene79dc762000-06-02 21:35:07 +0000647#endif
648
Jack Jansen74a1e632000-07-14 22:37:27 +0000649#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +0000650
Jack Jansen21f96871998-02-20 16:02:09 +0000651static PyObject *MenuObj_EnableItem(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +0000652 MenuObject *_self;
653 PyObject *_args;
654{
655 PyObject *_res = NULL;
656 short item;
Jack Jansen21f96871998-02-20 16:02:09 +0000657 if (!PyArg_ParseTuple(_args, "h",
658 &item))
Guido van Rossum17448e21995-01-30 11:53:55 +0000659 return NULL;
Jack Jansen21f96871998-02-20 16:02:09 +0000660 EnableItem(_self->ob_itself,
661 item);
Guido van Rossum17448e21995-01-30 11:53:55 +0000662 Py_INCREF(Py_None);
663 _res = Py_None;
664 return _res;
665}
Jack Jansene79dc762000-06-02 21:35:07 +0000666#endif
Guido van Rossum17448e21995-01-30 11:53:55 +0000667
Jack Jansen21f96871998-02-20 16:02:09 +0000668static PyObject *MenuObj_SetMenuItemCommandID(_self, _args)
669 MenuObject *_self;
670 PyObject *_args;
671{
672 PyObject *_res = NULL;
673 OSErr _err;
674 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000675 MenuCommand inCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000676 if (!PyArg_ParseTuple(_args, "hl",
677 &inItem,
678 &inCommandID))
679 return NULL;
680 _err = SetMenuItemCommandID(_self->ob_itself,
681 inItem,
682 inCommandID);
683 if (_err != noErr) return PyMac_Error(_err);
684 Py_INCREF(Py_None);
685 _res = Py_None;
686 return _res;
687}
688
689static PyObject *MenuObj_GetMenuItemCommandID(_self, _args)
690 MenuObject *_self;
691 PyObject *_args;
692{
693 PyObject *_res = NULL;
694 OSErr _err;
695 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000696 MenuCommand outCommandID;
Jack Jansen21f96871998-02-20 16:02:09 +0000697 if (!PyArg_ParseTuple(_args, "h",
698 &inItem))
699 return NULL;
700 _err = GetMenuItemCommandID(_self->ob_itself,
701 inItem,
702 &outCommandID);
703 if (_err != noErr) return PyMac_Error(_err);
704 _res = Py_BuildValue("l",
705 outCommandID);
706 return _res;
707}
708
709static PyObject *MenuObj_SetMenuItemModifiers(_self, _args)
710 MenuObject *_self;
711 PyObject *_args;
712{
713 PyObject *_res = NULL;
714 OSErr _err;
715 SInt16 inItem;
716 UInt8 inModifiers;
717 if (!PyArg_ParseTuple(_args, "hb",
718 &inItem,
719 &inModifiers))
720 return NULL;
721 _err = SetMenuItemModifiers(_self->ob_itself,
722 inItem,
723 inModifiers);
724 if (_err != noErr) return PyMac_Error(_err);
725 Py_INCREF(Py_None);
726 _res = Py_None;
727 return _res;
728}
729
730static PyObject *MenuObj_GetMenuItemModifiers(_self, _args)
731 MenuObject *_self;
732 PyObject *_args;
733{
734 PyObject *_res = NULL;
735 OSErr _err;
736 SInt16 inItem;
737 UInt8 outModifiers;
738 if (!PyArg_ParseTuple(_args, "h",
739 &inItem))
740 return NULL;
741 _err = GetMenuItemModifiers(_self->ob_itself,
742 inItem,
743 &outModifiers);
744 if (_err != noErr) return PyMac_Error(_err);
745 _res = Py_BuildValue("b",
746 outModifiers);
747 return _res;
748}
749
750static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args)
751 MenuObject *_self;
752 PyObject *_args;
753{
754 PyObject *_res = NULL;
755 OSErr _err;
756 SInt16 inItem;
757 UInt8 inIconType;
758 Handle inIconHandle;
759 if (!PyArg_ParseTuple(_args, "hbO&",
760 &inItem,
761 &inIconType,
762 ResObj_Convert, &inIconHandle))
763 return NULL;
764 _err = SetMenuItemIconHandle(_self->ob_itself,
765 inItem,
766 inIconType,
767 inIconHandle);
768 if (_err != noErr) return PyMac_Error(_err);
769 Py_INCREF(Py_None);
770 _res = Py_None;
771 return _res;
772}
773
774static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args)
775 MenuObject *_self;
776 PyObject *_args;
777{
778 PyObject *_res = NULL;
779 OSErr _err;
780 SInt16 inItem;
781 UInt8 outIconType;
782 Handle outIconHandle;
783 if (!PyArg_ParseTuple(_args, "h",
784 &inItem))
785 return NULL;
786 _err = GetMenuItemIconHandle(_self->ob_itself,
787 inItem,
788 &outIconType,
789 &outIconHandle);
790 if (_err != noErr) return PyMac_Error(_err);
791 _res = Py_BuildValue("bO&",
792 outIconType,
793 ResObj_New, outIconHandle);
794 return _res;
795}
796
797static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args)
798 MenuObject *_self;
799 PyObject *_args;
800{
801 PyObject *_res = NULL;
802 OSErr _err;
803 SInt16 inItem;
804 TextEncoding inScriptID;
805 if (!PyArg_ParseTuple(_args, "hl",
806 &inItem,
807 &inScriptID))
808 return NULL;
809 _err = SetMenuItemTextEncoding(_self->ob_itself,
810 inItem,
811 inScriptID);
812 if (_err != noErr) return PyMac_Error(_err);
813 Py_INCREF(Py_None);
814 _res = Py_None;
815 return _res;
816}
817
818static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args)
819 MenuObject *_self;
820 PyObject *_args;
821{
822 PyObject *_res = NULL;
823 OSErr _err;
824 SInt16 inItem;
825 TextEncoding outScriptID;
826 if (!PyArg_ParseTuple(_args, "h",
827 &inItem))
828 return NULL;
829 _err = GetMenuItemTextEncoding(_self->ob_itself,
830 inItem,
831 &outScriptID);
832 if (_err != noErr) return PyMac_Error(_err);
833 _res = Py_BuildValue("l",
834 outScriptID);
835 return _res;
836}
837
838static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args)
839 MenuObject *_self;
840 PyObject *_args;
841{
842 PyObject *_res = NULL;
843 OSErr _err;
844 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000845 MenuID inHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000846 if (!PyArg_ParseTuple(_args, "hh",
847 &inItem,
848 &inHierID))
849 return NULL;
850 _err = SetMenuItemHierarchicalID(_self->ob_itself,
851 inItem,
852 inHierID);
853 if (_err != noErr) return PyMac_Error(_err);
854 Py_INCREF(Py_None);
855 _res = Py_None;
856 return _res;
857}
858
859static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args)
860 MenuObject *_self;
861 PyObject *_args;
862{
863 PyObject *_res = NULL;
864 OSErr _err;
865 SInt16 inItem;
Jack Jansenf7d5aa62000-12-10 23:43:49 +0000866 MenuID outHierID;
Jack Jansen21f96871998-02-20 16:02:09 +0000867 if (!PyArg_ParseTuple(_args, "h",
868 &inItem))
869 return NULL;
870 _err = GetMenuItemHierarchicalID(_self->ob_itself,
871 inItem,
872 &outHierID);
873 if (_err != noErr) return PyMac_Error(_err);
874 _res = Py_BuildValue("h",
875 outHierID);
876 return _res;
877}
878
879static PyObject *MenuObj_SetMenuItemFontID(_self, _args)
880 MenuObject *_self;
881 PyObject *_args;
882{
883 PyObject *_res = NULL;
884 OSErr _err;
885 SInt16 inItem;
886 SInt16 inFontID;
887 if (!PyArg_ParseTuple(_args, "hh",
888 &inItem,
889 &inFontID))
890 return NULL;
891 _err = SetMenuItemFontID(_self->ob_itself,
892 inItem,
893 inFontID);
894 if (_err != noErr) return PyMac_Error(_err);
895 Py_INCREF(Py_None);
896 _res = Py_None;
897 return _res;
898}
899
900static PyObject *MenuObj_GetMenuItemFontID(_self, _args)
901 MenuObject *_self;
902 PyObject *_args;
903{
904 PyObject *_res = NULL;
905 OSErr _err;
906 SInt16 inItem;
907 SInt16 outFontID;
908 if (!PyArg_ParseTuple(_args, "h",
909 &inItem))
910 return NULL;
911 _err = GetMenuItemFontID(_self->ob_itself,
912 inItem,
913 &outFontID);
914 if (_err != noErr) return PyMac_Error(_err);
915 _res = Py_BuildValue("h",
916 outFontID);
917 return _res;
918}
919
920static PyObject *MenuObj_SetMenuItemRefCon(_self, _args)
921 MenuObject *_self;
922 PyObject *_args;
923{
924 PyObject *_res = NULL;
925 OSErr _err;
926 SInt16 inItem;
927 UInt32 inRefCon;
928 if (!PyArg_ParseTuple(_args, "hl",
929 &inItem,
930 &inRefCon))
931 return NULL;
932 _err = SetMenuItemRefCon(_self->ob_itself,
933 inItem,
934 inRefCon);
935 if (_err != noErr) return PyMac_Error(_err);
936 Py_INCREF(Py_None);
937 _res = Py_None;
938 return _res;
939}
940
941static PyObject *MenuObj_GetMenuItemRefCon(_self, _args)
942 MenuObject *_self;
943 PyObject *_args;
944{
945 PyObject *_res = NULL;
946 OSErr _err;
947 SInt16 inItem;
948 UInt32 outRefCon;
949 if (!PyArg_ParseTuple(_args, "h",
950 &inItem))
951 return NULL;
952 _err = GetMenuItemRefCon(_self->ob_itself,
953 inItem,
954 &outRefCon);
955 if (_err != noErr) return PyMac_Error(_err);
956 _res = Py_BuildValue("l",
957 outRefCon);
958 return _res;
959}
960
Jack Jansen74a1e632000-07-14 22:37:27 +0000961#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +0000962
Jack Jansen21f96871998-02-20 16:02:09 +0000963static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args)
964 MenuObject *_self;
965 PyObject *_args;
966{
967 PyObject *_res = NULL;
968 OSErr _err;
969 SInt16 inItem;
970 UInt32 inRefCon2;
971 if (!PyArg_ParseTuple(_args, "hl",
972 &inItem,
973 &inRefCon2))
974 return NULL;
975 _err = SetMenuItemRefCon2(_self->ob_itself,
976 inItem,
977 inRefCon2);
978 if (_err != noErr) return PyMac_Error(_err);
979 Py_INCREF(Py_None);
980 _res = Py_None;
981 return _res;
982}
Jack Jansene79dc762000-06-02 21:35:07 +0000983#endif
984
Jack Jansen74a1e632000-07-14 22:37:27 +0000985#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +0000986
987static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args)
988 MenuObject *_self;
989 PyObject *_args;
990{
991 PyObject *_res = NULL;
992 OSErr _err;
993 SInt16 inItem;
994 UInt32 outRefCon2;
995 if (!PyArg_ParseTuple(_args, "h",
996 &inItem))
997 return NULL;
998 _err = GetMenuItemRefCon2(_self->ob_itself,
999 inItem,
1000 &outRefCon2);
1001 if (_err != noErr) return PyMac_Error(_err);
1002 _res = Py_BuildValue("l",
1003 outRefCon2);
1004 return _res;
1005}
Jack Jansene79dc762000-06-02 21:35:07 +00001006#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001007
1008static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args)
1009 MenuObject *_self;
1010 PyObject *_args;
1011{
1012 PyObject *_res = NULL;
1013 OSErr _err;
1014 SInt16 inItem;
1015 SInt16 inGlyph;
1016 if (!PyArg_ParseTuple(_args, "hh",
1017 &inItem,
1018 &inGlyph))
1019 return NULL;
1020 _err = SetMenuItemKeyGlyph(_self->ob_itself,
1021 inItem,
1022 inGlyph);
1023 if (_err != noErr) return PyMac_Error(_err);
1024 Py_INCREF(Py_None);
1025 _res = Py_None;
1026 return _res;
1027}
1028
1029static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args)
1030 MenuObject *_self;
1031 PyObject *_args;
1032{
1033 PyObject *_res = NULL;
1034 OSErr _err;
1035 SInt16 inItem;
1036 SInt16 outGlyph;
1037 if (!PyArg_ParseTuple(_args, "h",
1038 &inItem))
1039 return NULL;
1040 _err = GetMenuItemKeyGlyph(_self->ob_itself,
1041 inItem,
1042 &outGlyph);
1043 if (_err != noErr) return PyMac_Error(_err);
1044 _res = Py_BuildValue("h",
1045 outGlyph);
1046 return _res;
1047}
1048
Jack Jansena05ac601999-12-12 21:41:51 +00001049static PyObject *MenuObj_MacEnableMenuItem(_self, _args)
1050 MenuObject *_self;
1051 PyObject *_args;
1052{
1053 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001054 MenuItemIndex item;
1055 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001056 &item))
1057 return NULL;
1058 MacEnableMenuItem(_self->ob_itself,
1059 item);
1060 Py_INCREF(Py_None);
1061 _res = Py_None;
1062 return _res;
1063}
1064
1065static PyObject *MenuObj_DisableMenuItem(_self, _args)
1066 MenuObject *_self;
1067 PyObject *_args;
1068{
1069 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001070 MenuItemIndex item;
1071 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001072 &item))
1073 return NULL;
1074 DisableMenuItem(_self->ob_itself,
1075 item);
1076 Py_INCREF(Py_None);
1077 _res = Py_None;
1078 return _res;
1079}
1080
1081static PyObject *MenuObj_IsMenuItemEnabled(_self, _args)
1082 MenuObject *_self;
1083 PyObject *_args;
1084{
1085 PyObject *_res = NULL;
1086 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001087 MenuItemIndex item;
1088 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001089 &item))
1090 return NULL;
1091 _rv = IsMenuItemEnabled(_self->ob_itself,
1092 item);
1093 _res = Py_BuildValue("b",
1094 _rv);
1095 return _res;
1096}
1097
1098static PyObject *MenuObj_EnableMenuItemIcon(_self, _args)
1099 MenuObject *_self;
1100 PyObject *_args;
1101{
1102 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001103 MenuItemIndex item;
1104 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001105 &item))
1106 return NULL;
1107 EnableMenuItemIcon(_self->ob_itself,
1108 item);
1109 Py_INCREF(Py_None);
1110 _res = Py_None;
1111 return _res;
1112}
1113
1114static PyObject *MenuObj_DisableMenuItemIcon(_self, _args)
1115 MenuObject *_self;
1116 PyObject *_args;
1117{
1118 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001119 MenuItemIndex item;
1120 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001121 &item))
1122 return NULL;
1123 DisableMenuItemIcon(_self->ob_itself,
1124 item);
1125 Py_INCREF(Py_None);
1126 _res = Py_None;
1127 return _res;
1128}
1129
1130static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args)
1131 MenuObject *_self;
1132 PyObject *_args;
1133{
1134 PyObject *_res = NULL;
1135 Boolean _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001136 MenuItemIndex item;
1137 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00001138 &item))
1139 return NULL;
1140 _rv = IsMenuItemIconEnabled(_self->ob_itself,
1141 item);
1142 _res = Py_BuildValue("b",
1143 _rv);
1144 return _res;
1145}
1146
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001147#if TARGET_API_MAC_CARBON
1148
1149static PyObject *MenuObj_GetMenuItemPropertyAttributes(_self, _args)
1150 MenuObject *_self;
1151 PyObject *_args;
1152{
1153 PyObject *_res = NULL;
1154 OSStatus _err;
1155 MenuItemIndex item;
1156 OSType propertyCreator;
1157 OSType propertyTag;
1158 UInt32 attributes;
1159 if (!PyArg_ParseTuple(_args, "hO&O&",
1160 &item,
1161 PyMac_GetOSType, &propertyCreator,
1162 PyMac_GetOSType, &propertyTag))
1163 return NULL;
1164 _err = GetMenuItemPropertyAttributes(_self->ob_itself,
1165 item,
1166 propertyCreator,
1167 propertyTag,
1168 &attributes);
1169 if (_err != noErr) return PyMac_Error(_err);
1170 _res = Py_BuildValue("l",
1171 attributes);
1172 return _res;
1173}
1174#endif
1175
1176#if TARGET_API_MAC_CARBON
1177
1178static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(_self, _args)
1179 MenuObject *_self;
1180 PyObject *_args;
1181{
1182 PyObject *_res = NULL;
1183 OSStatus _err;
1184 MenuItemIndex item;
1185 OSType propertyCreator;
1186 OSType propertyTag;
1187 UInt32 attributesToSet;
1188 UInt32 attributesToClear;
1189 if (!PyArg_ParseTuple(_args, "hO&O&ll",
1190 &item,
1191 PyMac_GetOSType, &propertyCreator,
1192 PyMac_GetOSType, &propertyTag,
1193 &attributesToSet,
1194 &attributesToClear))
1195 return NULL;
1196 _err = ChangeMenuItemPropertyAttributes(_self->ob_itself,
1197 item,
1198 propertyCreator,
1199 propertyTag,
1200 attributesToSet,
1201 attributesToClear);
1202 if (_err != noErr) return PyMac_Error(_err);
1203 Py_INCREF(Py_None);
1204 _res = Py_None;
1205 return _res;
1206}
1207#endif
1208
1209#if TARGET_API_MAC_CARBON
1210
1211static PyObject *MenuObj_GetMenuAttributes(_self, _args)
1212 MenuObject *_self;
1213 PyObject *_args;
1214{
1215 PyObject *_res = NULL;
1216 OSStatus _err;
1217 MenuAttributes outAttributes;
1218 if (!PyArg_ParseTuple(_args, ""))
1219 return NULL;
1220 _err = GetMenuAttributes(_self->ob_itself,
1221 &outAttributes);
1222 if (_err != noErr) return PyMac_Error(_err);
1223 _res = Py_BuildValue("l",
1224 outAttributes);
1225 return _res;
1226}
1227#endif
1228
1229#if TARGET_API_MAC_CARBON
1230
1231static PyObject *MenuObj_ChangeMenuAttributes(_self, _args)
1232 MenuObject *_self;
1233 PyObject *_args;
1234{
1235 PyObject *_res = NULL;
1236 OSStatus _err;
1237 MenuAttributes setTheseAttributes;
1238 MenuAttributes clearTheseAttributes;
1239 if (!PyArg_ParseTuple(_args, "ll",
1240 &setTheseAttributes,
1241 &clearTheseAttributes))
1242 return NULL;
1243 _err = ChangeMenuAttributes(_self->ob_itself,
1244 setTheseAttributes,
1245 clearTheseAttributes);
1246 if (_err != noErr) return PyMac_Error(_err);
1247 Py_INCREF(Py_None);
1248 _res = Py_None;
1249 return _res;
1250}
1251#endif
1252
1253#if TARGET_API_MAC_CARBON
1254
1255static PyObject *MenuObj_GetMenuItemAttributes(_self, _args)
1256 MenuObject *_self;
1257 PyObject *_args;
1258{
1259 PyObject *_res = NULL;
1260 OSStatus _err;
1261 MenuItemIndex item;
1262 MenuItemAttributes outAttributes;
1263 if (!PyArg_ParseTuple(_args, "h",
1264 &item))
1265 return NULL;
1266 _err = GetMenuItemAttributes(_self->ob_itself,
1267 item,
1268 &outAttributes);
1269 if (_err != noErr) return PyMac_Error(_err);
1270 _res = Py_BuildValue("l",
1271 outAttributes);
1272 return _res;
1273}
1274#endif
1275
1276#if TARGET_API_MAC_CARBON
1277
1278static PyObject *MenuObj_ChangeMenuItemAttributes(_self, _args)
1279 MenuObject *_self;
1280 PyObject *_args;
1281{
1282 PyObject *_res = NULL;
1283 OSStatus _err;
1284 MenuItemIndex item;
1285 MenuItemAttributes setTheseAttributes;
1286 MenuItemAttributes clearTheseAttributes;
1287 if (!PyArg_ParseTuple(_args, "hll",
1288 &item,
1289 &setTheseAttributes,
1290 &clearTheseAttributes))
1291 return NULL;
1292 _err = ChangeMenuItemAttributes(_self->ob_itself,
1293 item,
1294 setTheseAttributes,
1295 clearTheseAttributes);
1296 if (_err != noErr) return PyMac_Error(_err);
1297 Py_INCREF(Py_None);
1298 _res = Py_None;
1299 return _res;
1300}
1301#endif
1302
1303#if TARGET_API_MAC_CARBON
1304
1305static PyObject *MenuObj_DisableAllMenuItems(_self, _args)
1306 MenuObject *_self;
1307 PyObject *_args;
1308{
1309 PyObject *_res = NULL;
1310 if (!PyArg_ParseTuple(_args, ""))
1311 return NULL;
1312 DisableAllMenuItems(_self->ob_itself);
1313 Py_INCREF(Py_None);
1314 _res = Py_None;
1315 return _res;
1316}
1317#endif
1318
1319#if TARGET_API_MAC_CARBON
1320
1321static PyObject *MenuObj_EnableAllMenuItems(_self, _args)
1322 MenuObject *_self;
1323 PyObject *_args;
1324{
1325 PyObject *_res = NULL;
1326 if (!PyArg_ParseTuple(_args, ""))
1327 return NULL;
1328 EnableAllMenuItems(_self->ob_itself);
1329 Py_INCREF(Py_None);
1330 _res = Py_None;
1331 return _res;
1332}
1333#endif
1334
1335#if TARGET_API_MAC_CARBON
1336
1337static PyObject *MenuObj_MenuHasEnabledItems(_self, _args)
1338 MenuObject *_self;
1339 PyObject *_args;
1340{
1341 PyObject *_res = NULL;
1342 Boolean _rv;
1343 if (!PyArg_ParseTuple(_args, ""))
1344 return NULL;
1345 _rv = MenuHasEnabledItems(_self->ob_itself);
1346 _res = Py_BuildValue("b",
1347 _rv);
1348 return _res;
1349}
1350#endif
1351
1352#if TARGET_API_MAC_CARBON
1353
1354static PyObject *MenuObj_CountMenuItemsWithCommandID(_self, _args)
1355 MenuObject *_self;
1356 PyObject *_args;
1357{
1358 PyObject *_res = NULL;
1359 ItemCount _rv;
1360 MenuCommand commandID;
1361 if (!PyArg_ParseTuple(_args, "l",
1362 &commandID))
1363 return NULL;
1364 _rv = CountMenuItemsWithCommandID(_self->ob_itself,
1365 commandID);
1366 _res = Py_BuildValue("l",
1367 _rv);
1368 return _res;
1369}
1370#endif
1371
1372#if TARGET_API_MAC_CARBON
1373
1374static PyObject *MenuObj_GetIndMenuItemWithCommandID(_self, _args)
1375 MenuObject *_self;
1376 PyObject *_args;
1377{
1378 PyObject *_res = NULL;
1379 OSStatus _err;
1380 MenuCommand commandID;
1381 UInt32 itemIndex;
1382 MenuHandle outMenu;
1383 MenuItemIndex outIndex;
1384 if (!PyArg_ParseTuple(_args, "ll",
1385 &commandID,
1386 &itemIndex))
1387 return NULL;
1388 _err = GetIndMenuItemWithCommandID(_self->ob_itself,
1389 commandID,
1390 itemIndex,
1391 &outMenu,
1392 &outIndex);
1393 if (_err != noErr) return PyMac_Error(_err);
1394 _res = Py_BuildValue("O&h",
1395 MenuObj_New, outMenu,
1396 outIndex);
1397 return _res;
1398}
1399#endif
1400
1401#if TARGET_API_MAC_CARBON
1402
1403static PyObject *MenuObj_EnableMenuCommand(_self, _args)
1404 MenuObject *_self;
1405 PyObject *_args;
1406{
1407 PyObject *_res = NULL;
1408 MenuCommand commandID;
1409 if (!PyArg_ParseTuple(_args, "l",
1410 &commandID))
1411 return NULL;
1412 EnableMenuCommand(_self->ob_itself,
1413 commandID);
1414 Py_INCREF(Py_None);
1415 _res = Py_None;
1416 return _res;
1417}
1418#endif
1419
1420#if TARGET_API_MAC_CARBON
1421
1422static PyObject *MenuObj_DisableMenuCommand(_self, _args)
1423 MenuObject *_self;
1424 PyObject *_args;
1425{
1426 PyObject *_res = NULL;
1427 MenuCommand commandID;
1428 if (!PyArg_ParseTuple(_args, "l",
1429 &commandID))
1430 return NULL;
1431 DisableMenuCommand(_self->ob_itself,
1432 commandID);
1433 Py_INCREF(Py_None);
1434 _res = Py_None;
1435 return _res;
1436}
1437#endif
1438
1439#if TARGET_API_MAC_CARBON
1440
1441static PyObject *MenuObj_IsMenuCommandEnabled(_self, _args)
1442 MenuObject *_self;
1443 PyObject *_args;
1444{
1445 PyObject *_res = NULL;
1446 Boolean _rv;
1447 MenuCommand commandID;
1448 if (!PyArg_ParseTuple(_args, "l",
1449 &commandID))
1450 return NULL;
1451 _rv = IsMenuCommandEnabled(_self->ob_itself,
1452 commandID);
1453 _res = Py_BuildValue("b",
1454 _rv);
1455 return _res;
1456}
1457#endif
1458
1459#if TARGET_API_MAC_CARBON
1460
1461static PyObject *MenuObj_GetMenuCommandPropertySize(_self, _args)
1462 MenuObject *_self;
1463 PyObject *_args;
1464{
1465 PyObject *_res = NULL;
1466 OSStatus _err;
1467 MenuCommand commandID;
1468 OSType propertyCreator;
1469 OSType propertyTag;
1470 ByteCount size;
1471 if (!PyArg_ParseTuple(_args, "lO&O&",
1472 &commandID,
1473 PyMac_GetOSType, &propertyCreator,
1474 PyMac_GetOSType, &propertyTag))
1475 return NULL;
1476 _err = GetMenuCommandPropertySize(_self->ob_itself,
1477 commandID,
1478 propertyCreator,
1479 propertyTag,
1480 &size);
1481 if (_err != noErr) return PyMac_Error(_err);
1482 _res = Py_BuildValue("l",
1483 size);
1484 return _res;
1485}
1486#endif
1487
1488#if TARGET_API_MAC_CARBON
1489
1490static PyObject *MenuObj_RemoveMenuCommandProperty(_self, _args)
1491 MenuObject *_self;
1492 PyObject *_args;
1493{
1494 PyObject *_res = NULL;
1495 OSStatus _err;
1496 MenuCommand commandID;
1497 OSType propertyCreator;
1498 OSType propertyTag;
1499 if (!PyArg_ParseTuple(_args, "lO&O&",
1500 &commandID,
1501 PyMac_GetOSType, &propertyCreator,
1502 PyMac_GetOSType, &propertyTag))
1503 return NULL;
1504 _err = RemoveMenuCommandProperty(_self->ob_itself,
1505 commandID,
1506 propertyCreator,
1507 propertyTag);
1508 if (_err != noErr) return PyMac_Error(_err);
1509 Py_INCREF(Py_None);
1510 _res = Py_None;
1511 return _res;
1512}
1513#endif
1514
1515#if TARGET_API_MAC_CARBON
1516
1517static PyObject *MenuObj_CreateStandardFontMenu(_self, _args)
1518 MenuObject *_self;
1519 PyObject *_args;
1520{
1521 PyObject *_res = NULL;
1522 OSStatus _err;
1523 MenuItemIndex afterItem;
1524 MenuID firstHierMenuID;
1525 OptionBits options;
1526 ItemCount outHierMenuCount;
1527 if (!PyArg_ParseTuple(_args, "hhl",
1528 &afterItem,
1529 &firstHierMenuID,
1530 &options))
1531 return NULL;
1532 _err = CreateStandardFontMenu(_self->ob_itself,
1533 afterItem,
1534 firstHierMenuID,
1535 options,
1536 &outHierMenuCount);
1537 if (_err != noErr) return PyMac_Error(_err);
1538 _res = Py_BuildValue("l",
1539 outHierMenuCount);
1540 return _res;
1541}
1542#endif
1543
1544#if TARGET_API_MAC_CARBON
1545
1546static PyObject *MenuObj_UpdateStandardFontMenu(_self, _args)
1547 MenuObject *_self;
1548 PyObject *_args;
1549{
1550 PyObject *_res = NULL;
1551 OSStatus _err;
1552 ItemCount outHierMenuCount;
1553 if (!PyArg_ParseTuple(_args, ""))
1554 return NULL;
1555 _err = UpdateStandardFontMenu(_self->ob_itself,
1556 &outHierMenuCount);
1557 if (_err != noErr) return PyMac_Error(_err);
1558 _res = Py_BuildValue("l",
1559 outHierMenuCount);
1560 return _res;
1561}
1562#endif
1563
1564#if TARGET_API_MAC_CARBON
1565
1566static PyObject *MenuObj_GetFontFamilyFromMenuSelection(_self, _args)
1567 MenuObject *_self;
1568 PyObject *_args;
1569{
1570 PyObject *_res = NULL;
1571 OSStatus _err;
1572 MenuItemIndex item;
1573 FMFontFamily outFontFamily;
1574 FMFontStyle outStyle;
1575 if (!PyArg_ParseTuple(_args, "h",
1576 &item))
1577 return NULL;
1578 _err = GetFontFamilyFromMenuSelection(_self->ob_itself,
1579 item,
1580 &outFontFamily,
1581 &outStyle);
1582 if (_err != noErr) return PyMac_Error(_err);
1583 _res = Py_BuildValue("hh",
1584 outFontFamily,
1585 outStyle);
1586 return _res;
1587}
1588#endif
1589
1590static PyObject *MenuObj_GetMenuID(_self, _args)
1591 MenuObject *_self;
1592 PyObject *_args;
1593{
1594 PyObject *_res = NULL;
1595 MenuID _rv;
1596 if (!PyArg_ParseTuple(_args, ""))
1597 return NULL;
1598 _rv = GetMenuID(_self->ob_itself);
1599 _res = Py_BuildValue("h",
1600 _rv);
1601 return _res;
1602}
1603
1604static PyObject *MenuObj_GetMenuWidth(_self, _args)
1605 MenuObject *_self;
1606 PyObject *_args;
1607{
1608 PyObject *_res = NULL;
1609 SInt16 _rv;
1610 if (!PyArg_ParseTuple(_args, ""))
1611 return NULL;
1612 _rv = GetMenuWidth(_self->ob_itself);
1613 _res = Py_BuildValue("h",
1614 _rv);
1615 return _res;
1616}
1617
1618static PyObject *MenuObj_GetMenuHeight(_self, _args)
1619 MenuObject *_self;
1620 PyObject *_args;
1621{
1622 PyObject *_res = NULL;
1623 SInt16 _rv;
1624 if (!PyArg_ParseTuple(_args, ""))
1625 return NULL;
1626 _rv = GetMenuHeight(_self->ob_itself);
1627 _res = Py_BuildValue("h",
1628 _rv);
1629 return _res;
1630}
1631
1632static PyObject *MenuObj_SetMenuID(_self, _args)
1633 MenuObject *_self;
1634 PyObject *_args;
1635{
1636 PyObject *_res = NULL;
1637 MenuID menuID;
1638 if (!PyArg_ParseTuple(_args, "h",
1639 &menuID))
1640 return NULL;
1641 SetMenuID(_self->ob_itself,
1642 menuID);
1643 Py_INCREF(Py_None);
1644 _res = Py_None;
1645 return _res;
1646}
1647
1648static PyObject *MenuObj_SetMenuWidth(_self, _args)
1649 MenuObject *_self;
1650 PyObject *_args;
1651{
1652 PyObject *_res = NULL;
1653 SInt16 width;
1654 if (!PyArg_ParseTuple(_args, "h",
1655 &width))
1656 return NULL;
1657 SetMenuWidth(_self->ob_itself,
1658 width);
1659 Py_INCREF(Py_None);
1660 _res = Py_None;
1661 return _res;
1662}
1663
1664static PyObject *MenuObj_SetMenuHeight(_self, _args)
1665 MenuObject *_self;
1666 PyObject *_args;
1667{
1668 PyObject *_res = NULL;
1669 SInt16 height;
1670 if (!PyArg_ParseTuple(_args, "h",
1671 &height))
1672 return NULL;
1673 SetMenuHeight(_self->ob_itself,
1674 height);
1675 Py_INCREF(Py_None);
1676 _res = Py_None;
1677 return _res;
1678}
1679
Jack Jansena1772281995-06-18 20:17:27 +00001680static PyObject *MenuObj_as_Resource(_self, _args)
1681 MenuObject *_self;
1682 PyObject *_args;
1683{
1684 PyObject *_res = NULL;
Jack Jansena1a0fef1999-12-23 14:32:06 +00001685 Handle _rv;
1686 if (!PyArg_ParseTuple(_args, ""))
1687 return NULL;
1688 _rv = as_Resource(_self->ob_itself);
1689 _res = Py_BuildValue("O&",
1690 ResObj_New, _rv);
1691 return _res;
Jack Jansena1772281995-06-18 20:17:27 +00001692}
1693
Jack Jansene180d991998-04-24 10:28:20 +00001694static PyObject *MenuObj_AppendMenu(_self, _args)
1695 MenuObject *_self;
1696 PyObject *_args;
1697{
1698 PyObject *_res = NULL;
1699 Str255 data;
1700 if (!PyArg_ParseTuple(_args, "O&",
1701 PyMac_GetStr255, data))
1702 return NULL;
1703 AppendMenu(_self->ob_itself,
1704 data);
1705 Py_INCREF(Py_None);
1706 _res = Py_None;
1707 return _res;
1708}
1709
1710static PyObject *MenuObj_InsertMenu(_self, _args)
1711 MenuObject *_self;
1712 PyObject *_args;
1713{
1714 PyObject *_res = NULL;
1715 short beforeID;
1716 if (!PyArg_ParseTuple(_args, "h",
1717 &beforeID))
1718 return NULL;
1719 InsertMenu(_self->ob_itself,
1720 beforeID);
1721 Py_INCREF(Py_None);
1722 _res = Py_None;
1723 return _res;
1724}
1725
1726static PyObject *MenuObj_InsertMenuItem(_self, _args)
1727 MenuObject *_self;
1728 PyObject *_args;
1729{
1730 PyObject *_res = NULL;
1731 Str255 itemString;
1732 short afterItem;
1733 if (!PyArg_ParseTuple(_args, "O&h",
1734 PyMac_GetStr255, itemString,
1735 &afterItem))
1736 return NULL;
1737 InsertMenuItem(_self->ob_itself,
1738 itemString,
1739 afterItem);
1740 Py_INCREF(Py_None);
1741 _res = Py_None;
1742 return _res;
1743}
1744
Guido van Rossum17448e21995-01-30 11:53:55 +00001745static PyMethodDef MenuObj_methods[] = {
1746 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1747 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001748 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1749 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001750 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1751 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001752
Jack Jansen74a1e632000-07-14 22:37:27 +00001753#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001754 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1755 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001756#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001757 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1758 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1759 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1760 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1761 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1762 "() -> (Boolean _rv)"},
1763 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1764 "(Boolean excludesMark) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001765 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001766 "(Str255 data) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001767 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1768 "(ResType theType, short afterItem) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001769 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1770 "(ResType theType) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001771 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001772 "(Str255 itemString, short afterItem) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001773 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001774 "(short item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001775 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1776 "(short afterItem, short scriptFilter) -> None"},
1777 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1778 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1779 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1780 "(Str255 inString) -> None"},
1781 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001782 "(Str255 inString, MenuItemIndex afterItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001783 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1784 "(short top, short left, short popUpItem) -> (long _rv)"},
1785 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001786 "(MenuID beforeID) -> None"},
1787 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1788 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001789
Jack Jansen74a1e632000-07-14 22:37:27 +00001790#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001791 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1792 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001793#endif
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001794 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001795 "(short item, Str255 itemString) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001796 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001797 "(short item) -> (Str255 itemString)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001798 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001799 "(short item, CharParameter markChar) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001800 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001801 "(short item) -> (CharParameter markChar)"},
1802 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1803 "(short item, CharParameter cmdChar) -> None"},
1804 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1805 "(short item) -> (CharParameter cmdChar)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001806 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1807 "(short item, short iconIndex) -> None"},
1808 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1809 "(short item) -> (short iconIndex)"},
1810 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
Jack Jansend6b6d881998-02-25 15:45:21 +00001811 "(short item, StyleParameter chStyle) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001812 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
Jack Jansen7d0bc831995-06-09 20:56:31 +00001813 "(short item) -> (Style chStyle)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001814
Jack Jansen74a1e632000-07-14 22:37:27 +00001815#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001816 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1817 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001818#endif
1819
Jack Jansen74a1e632000-07-14 22:37:27 +00001820#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001821 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1822 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001823#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001824 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001825 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001826 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001827 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001828 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1829 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1830 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1831 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1832 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1833 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1834 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1835 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1836 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1837 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1838 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1839 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1840 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001841 "(SInt16 inItem, MenuID inHierID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001842 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001843 "(SInt16 inItem) -> (MenuID outHierID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001844 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1845 "(SInt16 inItem, SInt16 inFontID) -> None"},
1846 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1847 "(SInt16 inItem) -> (SInt16 outFontID)"},
1848 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1849 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1850 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1851 "(SInt16 inItem) -> (UInt32 outRefCon)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001852
Jack Jansen74a1e632000-07-14 22:37:27 +00001853#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001854 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1855 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001856#endif
1857
Jack Jansen74a1e632000-07-14 22:37:27 +00001858#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001859 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1860 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001861#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001862 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1863 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1864 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1865 "(SInt16 inItem) -> (SInt16 outGlyph)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001866 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001867 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001868 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001869 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001870 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001871 "(MenuItemIndex item) -> (Boolean _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001872 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001873 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001874 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001875 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001876 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001877 "(MenuItemIndex item) -> (Boolean _rv)"},
1878
1879#if TARGET_API_MAC_CARBON
1880 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1881 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1882#endif
1883
1884#if TARGET_API_MAC_CARBON
1885 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1886 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1887#endif
1888
1889#if TARGET_API_MAC_CARBON
1890 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1891 "() -> (MenuAttributes outAttributes)"},
1892#endif
1893
1894#if TARGET_API_MAC_CARBON
1895 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1896 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1897#endif
1898
1899#if TARGET_API_MAC_CARBON
1900 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1901 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1902#endif
1903
1904#if TARGET_API_MAC_CARBON
1905 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1906 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1907#endif
1908
1909#if TARGET_API_MAC_CARBON
1910 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1911 "() -> None"},
1912#endif
1913
1914#if TARGET_API_MAC_CARBON
1915 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1916 "() -> None"},
1917#endif
1918
1919#if TARGET_API_MAC_CARBON
1920 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1921 "() -> (Boolean _rv)"},
1922#endif
1923
1924#if TARGET_API_MAC_CARBON
1925 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1926 "(MenuCommand commandID) -> (ItemCount _rv)"},
1927#endif
1928
1929#if TARGET_API_MAC_CARBON
1930 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1931 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1932#endif
1933
1934#if TARGET_API_MAC_CARBON
1935 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1936 "(MenuCommand commandID) -> None"},
1937#endif
1938
1939#if TARGET_API_MAC_CARBON
1940 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1941 "(MenuCommand commandID) -> None"},
1942#endif
1943
1944#if TARGET_API_MAC_CARBON
1945 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1946 "(MenuCommand commandID) -> (Boolean _rv)"},
1947#endif
1948
1949#if TARGET_API_MAC_CARBON
1950 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1951 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1952#endif
1953
1954#if TARGET_API_MAC_CARBON
1955 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
1956 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1957#endif
1958
1959#if TARGET_API_MAC_CARBON
1960 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
1961 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1962#endif
1963
1964#if TARGET_API_MAC_CARBON
1965 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
1966 "() -> (ItemCount outHierMenuCount)"},
1967#endif
1968
1969#if TARGET_API_MAC_CARBON
1970 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
1971 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
1972#endif
1973 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
1974 "() -> (MenuID _rv)"},
1975 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
1976 "() -> (SInt16 _rv)"},
1977 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
1978 "() -> (SInt16 _rv)"},
1979 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
1980 "(MenuID menuID) -> None"},
1981 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
1982 "(SInt16 width) -> None"},
1983 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
1984 "(SInt16 height) -> None"},
Jack Jansena1772281995-06-18 20:17:27 +00001985 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
Jack Jansena1a0fef1999-12-23 14:32:06 +00001986 "() -> (Handle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00001987 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
1988 "(Str255 data) -> None"},
1989 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
1990 "(short beforeID) -> None"},
1991 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
1992 "(Str255 itemString, short afterItem) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001993 {NULL, NULL, 0}
1994};
1995
1996PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
1997
1998static PyObject *MenuObj_getattr(self, name)
1999 MenuObject *self;
2000 char *name;
2001{
2002 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
2003}
2004
2005#define MenuObj_setattr NULL
2006
Jack Jansena05ac601999-12-12 21:41:51 +00002007#define MenuObj_compare NULL
2008
2009#define MenuObj_repr NULL
2010
2011#define MenuObj_hash NULL
2012
Guido van Rossum17448e21995-01-30 11:53:55 +00002013PyTypeObject Menu_Type = {
2014 PyObject_HEAD_INIT(&PyType_Type)
2015 0, /*ob_size*/
2016 "Menu", /*tp_name*/
2017 sizeof(MenuObject), /*tp_basicsize*/
2018 0, /*tp_itemsize*/
2019 /* methods */
2020 (destructor) MenuObj_dealloc, /*tp_dealloc*/
2021 0, /*tp_print*/
2022 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
2023 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002024 (cmpfunc) MenuObj_compare, /*tp_compare*/
2025 (reprfunc) MenuObj_repr, /*tp_repr*/
2026 (PyNumberMethods *)0, /* tp_as_number */
2027 (PySequenceMethods *)0, /* tp_as_sequence */
2028 (PyMappingMethods *)0, /* tp_as_mapping */
2029 (hashfunc) MenuObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002030};
2031
2032/* ---------------------- End object type Menu ---------------------- */
2033
2034
Jack Jansen74a1e632000-07-14 22:37:27 +00002035#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002036
Jack Jansena05ac601999-12-12 21:41:51 +00002037static PyObject *Menu_InitProcMenu(_self, _args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002038 PyObject *_self;
2039 PyObject *_args;
2040{
2041 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002042 short resID;
2043 if (!PyArg_ParseTuple(_args, "h",
2044 &resID))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002045 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002046 InitProcMenu(resID);
2047 Py_INCREF(Py_None);
2048 _res = Py_None;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002049 return _res;
2050}
Jack Jansene79dc762000-06-02 21:35:07 +00002051#endif
2052
Jack Jansen74a1e632000-07-14 22:37:27 +00002053#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002054
Guido van Rossum17448e21995-01-30 11:53:55 +00002055static PyObject *Menu_InitMenus(_self, _args)
2056 PyObject *_self;
2057 PyObject *_args;
2058{
2059 PyObject *_res = NULL;
2060 if (!PyArg_ParseTuple(_args, ""))
2061 return NULL;
2062 InitMenus();
2063 Py_INCREF(Py_None);
2064 _res = Py_None;
2065 return _res;
2066}
Jack Jansene79dc762000-06-02 21:35:07 +00002067#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002068
2069static PyObject *Menu_NewMenu(_self, _args)
2070 PyObject *_self;
2071 PyObject *_args;
2072{
2073 PyObject *_res = NULL;
2074 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002075 MenuID menuID;
Guido van Rossum17448e21995-01-30 11:53:55 +00002076 Str255 menuTitle;
2077 if (!PyArg_ParseTuple(_args, "hO&",
2078 &menuID,
2079 PyMac_GetStr255, menuTitle))
2080 return NULL;
2081 _rv = NewMenu(menuID,
2082 menuTitle);
2083 _res = Py_BuildValue("O&",
2084 MenuObj_New, _rv);
2085 return _res;
2086}
2087
Jack Jansen1c4e6141998-04-21 15:23:55 +00002088static PyObject *Menu_MacGetMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002089 PyObject *_self;
2090 PyObject *_args;
2091{
2092 PyObject *_res = NULL;
2093 MenuHandle _rv;
2094 short resourceID;
2095 if (!PyArg_ParseTuple(_args, "h",
2096 &resourceID))
2097 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002098 _rv = MacGetMenu(resourceID);
Guido van Rossum17448e21995-01-30 11:53:55 +00002099 _res = Py_BuildValue("O&",
2100 MenuObj_New, _rv);
2101 return _res;
2102}
2103
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002104#if TARGET_API_MAC_CARBON
2105
2106static PyObject *Menu_CreateNewMenu(_self, _args)
2107 PyObject *_self;
2108 PyObject *_args;
2109{
2110 PyObject *_res = NULL;
2111 OSStatus _err;
2112 MenuID menuID;
2113 MenuAttributes menuAttributes;
2114 MenuHandle outMenuRef;
2115 if (!PyArg_ParseTuple(_args, "hl",
2116 &menuID,
2117 &menuAttributes))
2118 return NULL;
2119 _err = CreateNewMenu(menuID,
2120 menuAttributes,
2121 &outMenuRef);
2122 if (_err != noErr) return PyMac_Error(_err);
2123 _res = Py_BuildValue("O&",
2124 MenuObj_New, outMenuRef);
2125 return _res;
2126}
2127#endif
2128
Guido van Rossum17448e21995-01-30 11:53:55 +00002129static PyObject *Menu_MenuKey(_self, _args)
2130 PyObject *_self;
2131 PyObject *_args;
2132{
2133 PyObject *_res = NULL;
2134 long _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002135 CharParameter ch;
Guido van Rossum17448e21995-01-30 11:53:55 +00002136 if (!PyArg_ParseTuple(_args, "h",
2137 &ch))
2138 return NULL;
2139 _rv = MenuKey(ch);
2140 _res = Py_BuildValue("l",
2141 _rv);
2142 return _res;
2143}
2144
Jack Jansena05ac601999-12-12 21:41:51 +00002145static PyObject *Menu_MenuSelect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002146 PyObject *_self;
2147 PyObject *_args;
2148{
2149 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002150 long _rv;
2151 Point startPt;
2152 if (!PyArg_ParseTuple(_args, "O&",
2153 PyMac_GetPoint, &startPt))
Guido van Rossum17448e21995-01-30 11:53:55 +00002154 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002155 _rv = MenuSelect(startPt);
2156 _res = Py_BuildValue("l",
2157 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002158 return _res;
2159}
2160
Guido van Rossum17448e21995-01-30 11:53:55 +00002161static PyObject *Menu_MenuChoice(_self, _args)
2162 PyObject *_self;
2163 PyObject *_args;
2164{
2165 PyObject *_res = NULL;
2166 long _rv;
2167 if (!PyArg_ParseTuple(_args, ""))
2168 return NULL;
2169 _rv = MenuChoice();
2170 _res = Py_BuildValue("l",
2171 _rv);
2172 return _res;
2173}
2174
Jack Jansena05ac601999-12-12 21:41:51 +00002175static PyObject *Menu_MenuEvent(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002176 PyObject *_self;
2177 PyObject *_args;
2178{
2179 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002180 UInt32 _rv;
2181 EventRecord inEvent;
2182 if (!PyArg_ParseTuple(_args, "O&",
2183 PyMac_GetEventRecord, &inEvent))
Guido van Rossum17448e21995-01-30 11:53:55 +00002184 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002185 _rv = MenuEvent(&inEvent);
2186 _res = Py_BuildValue("l",
2187 _rv);
2188 return _res;
2189}
2190
2191static PyObject *Menu_GetMBarHeight(_self, _args)
2192 PyObject *_self;
2193 PyObject *_args;
2194{
2195 PyObject *_res = NULL;
2196 short _rv;
2197 if (!PyArg_ParseTuple(_args, ""))
2198 return NULL;
2199 _rv = GetMBarHeight();
2200 _res = Py_BuildValue("h",
2201 _rv);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002202 return _res;
2203}
2204
Jack Jansen1c4e6141998-04-21 15:23:55 +00002205static PyObject *Menu_MacDrawMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002206 PyObject *_self;
2207 PyObject *_args;
2208{
2209 PyObject *_res = NULL;
2210 if (!PyArg_ParseTuple(_args, ""))
2211 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002212 MacDrawMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002213 Py_INCREF(Py_None);
2214 _res = Py_None;
2215 return _res;
2216}
2217
2218static PyObject *Menu_InvalMenuBar(_self, _args)
2219 PyObject *_self;
2220 PyObject *_args;
2221{
2222 PyObject *_res = NULL;
2223 if (!PyArg_ParseTuple(_args, ""))
2224 return NULL;
2225 InvalMenuBar();
2226 Py_INCREF(Py_None);
2227 _res = Py_None;
2228 return _res;
2229}
2230
Jack Jansena05ac601999-12-12 21:41:51 +00002231static PyObject *Menu_HiliteMenu(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002232 PyObject *_self;
2233 PyObject *_args;
2234{
2235 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002236 MenuID menuID;
Jack Jansen21f96871998-02-20 16:02:09 +00002237 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00002238 &menuID))
Jack Jansen21f96871998-02-20 16:02:09 +00002239 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002240 HiliteMenu(menuID);
Jack Jansen21f96871998-02-20 16:02:09 +00002241 Py_INCREF(Py_None);
2242 _res = Py_None;
2243 return _res;
2244}
2245
Jack Jansena05ac601999-12-12 21:41:51 +00002246static PyObject *Menu_GetNewMBar(_self, _args)
2247 PyObject *_self;
2248 PyObject *_args;
2249{
2250 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002251 MenuBarHandle _rv;
Jack Jansena05ac601999-12-12 21:41:51 +00002252 short menuBarID;
2253 if (!PyArg_ParseTuple(_args, "h",
2254 &menuBarID))
2255 return NULL;
2256 _rv = GetNewMBar(menuBarID);
2257 _res = Py_BuildValue("O&",
2258 ResObj_New, _rv);
2259 return _res;
2260}
2261
Jack Jansen21f96871998-02-20 16:02:09 +00002262static PyObject *Menu_GetMenuBar(_self, _args)
2263 PyObject *_self;
2264 PyObject *_args;
2265{
2266 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002267 MenuBarHandle _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002268 if (!PyArg_ParseTuple(_args, ""))
2269 return NULL;
2270 _rv = GetMenuBar();
2271 _res = Py_BuildValue("O&",
2272 ResObj_New, _rv);
2273 return _res;
2274}
2275
2276static PyObject *Menu_SetMenuBar(_self, _args)
2277 PyObject *_self;
2278 PyObject *_args;
2279{
2280 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002281 MenuBarHandle mbar;
Jack Jansen21f96871998-02-20 16:02:09 +00002282 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002283 ResObj_Convert, &mbar))
Jack Jansen21f96871998-02-20 16:02:09 +00002284 return NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002285 SetMenuBar(mbar);
Jack Jansen21f96871998-02-20 16:02:09 +00002286 Py_INCREF(Py_None);
2287 _res = Py_None;
2288 return _res;
2289}
2290
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002291#if TARGET_API_MAC_CARBON
2292
2293static PyObject *Menu_DuplicateMenuBar(_self, _args)
2294 PyObject *_self;
2295 PyObject *_args;
2296{
2297 PyObject *_res = NULL;
2298 OSStatus _err;
2299 MenuBarHandle mbar;
2300 MenuBarHandle outBar;
2301 if (!PyArg_ParseTuple(_args, "O&",
2302 ResObj_Convert, &mbar))
2303 return NULL;
2304 _err = DuplicateMenuBar(mbar,
2305 &outBar);
2306 if (_err != noErr) return PyMac_Error(_err);
2307 _res = Py_BuildValue("O&",
2308 ResObj_New, outBar);
2309 return _res;
2310}
2311#endif
2312
2313#if TARGET_API_MAC_CARBON
2314
2315static PyObject *Menu_DisposeMenuBar(_self, _args)
2316 PyObject *_self;
2317 PyObject *_args;
2318{
2319 PyObject *_res = NULL;
2320 OSStatus _err;
2321 MenuBarHandle mbar;
2322 if (!PyArg_ParseTuple(_args, "O&",
2323 ResObj_Convert, &mbar))
2324 return NULL;
2325 _err = DisposeMenuBar(mbar);
2326 if (_err != noErr) return PyMac_Error(_err);
2327 Py_INCREF(Py_None);
2328 _res = Py_None;
2329 return _res;
2330}
2331#endif
2332
Jack Jansena05ac601999-12-12 21:41:51 +00002333static PyObject *Menu_GetMenuHandle(_self, _args)
2334 PyObject *_self;
2335 PyObject *_args;
2336{
2337 PyObject *_res = NULL;
2338 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002339 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002340 if (!PyArg_ParseTuple(_args, "h",
2341 &menuID))
2342 return NULL;
2343 _rv = GetMenuHandle(menuID);
2344 _res = Py_BuildValue("O&",
2345 MenuObj_New, _rv);
2346 return _res;
2347}
2348
2349static PyObject *Menu_MacDeleteMenu(_self, _args)
2350 PyObject *_self;
2351 PyObject *_args;
2352{
2353 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002354 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002355 if (!PyArg_ParseTuple(_args, "h",
2356 &menuID))
2357 return NULL;
2358 MacDeleteMenu(menuID);
2359 Py_INCREF(Py_None);
2360 _res = Py_None;
2361 return _res;
2362}
2363
2364static PyObject *Menu_ClearMenuBar(_self, _args)
2365 PyObject *_self;
2366 PyObject *_args;
2367{
2368 PyObject *_res = NULL;
2369 if (!PyArg_ParseTuple(_args, ""))
2370 return NULL;
2371 ClearMenuBar();
2372 Py_INCREF(Py_None);
2373 _res = Py_None;
2374 return _res;
2375}
2376
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002377static PyObject *Menu_SetMenuFlashCount(_self, _args)
2378 PyObject *_self;
2379 PyObject *_args;
2380{
2381 PyObject *_res = NULL;
2382 short count;
2383 if (!PyArg_ParseTuple(_args, "h",
2384 &count))
2385 return NULL;
2386 SetMenuFlashCount(count);
2387 Py_INCREF(Py_None);
2388 _res = Py_None;
2389 return _res;
2390}
2391
Jack Jansen74a1e632000-07-14 22:37:27 +00002392#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002393
Jack Jansena05ac601999-12-12 21:41:51 +00002394static PyObject *Menu_SetMenuFlash(_self, _args)
2395 PyObject *_self;
2396 PyObject *_args;
2397{
2398 PyObject *_res = NULL;
2399 short count;
2400 if (!PyArg_ParseTuple(_args, "h",
2401 &count))
2402 return NULL;
2403 SetMenuFlash(count);
2404 Py_INCREF(Py_None);
2405 _res = Py_None;
2406 return _res;
2407}
Jack Jansene79dc762000-06-02 21:35:07 +00002408#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002409
2410static PyObject *Menu_FlashMenuBar(_self, _args)
2411 PyObject *_self;
2412 PyObject *_args;
2413{
2414 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002415 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002416 if (!PyArg_ParseTuple(_args, "h",
2417 &menuID))
2418 return NULL;
2419 FlashMenuBar(menuID);
2420 Py_INCREF(Py_None);
2421 _res = Py_None;
2422 return _res;
2423}
2424
Jack Jansen74a1e632000-07-14 22:37:27 +00002425#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002426
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002427static PyObject *Menu_SystemEdit(_self, _args)
2428 PyObject *_self;
2429 PyObject *_args;
2430{
2431 PyObject *_res = NULL;
2432 Boolean _rv;
2433 short editCmd;
2434 if (!PyArg_ParseTuple(_args, "h",
2435 &editCmd))
2436 return NULL;
2437 _rv = SystemEdit(editCmd);
2438 _res = Py_BuildValue("b",
2439 _rv);
2440 return _res;
2441}
Jack Jansene79dc762000-06-02 21:35:07 +00002442#endif
2443
Jack Jansen74a1e632000-07-14 22:37:27 +00002444#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002445
2446static PyObject *Menu_SystemMenu(_self, _args)
2447 PyObject *_self;
2448 PyObject *_args;
2449{
2450 PyObject *_res = NULL;
2451 long menuResult;
2452 if (!PyArg_ParseTuple(_args, "l",
2453 &menuResult))
2454 return NULL;
2455 SystemMenu(menuResult);
Guido van Rossum17448e21995-01-30 11:53:55 +00002456 Py_INCREF(Py_None);
2457 _res = Py_None;
2458 return _res;
2459}
Jack Jansene79dc762000-06-02 21:35:07 +00002460#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002461
Jack Jansena05ac601999-12-12 21:41:51 +00002462static PyObject *Menu_IsMenuBarVisible(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002463 PyObject *_self;
2464 PyObject *_args;
2465{
2466 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002467 Boolean _rv;
2468 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002469 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002470 _rv = IsMenuBarVisible();
2471 _res = Py_BuildValue("b",
2472 _rv);
Jack Jansen21f96871998-02-20 16:02:09 +00002473 return _res;
2474}
2475
Jack Jansena05ac601999-12-12 21:41:51 +00002476static PyObject *Menu_ShowMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002477 PyObject *_self;
2478 PyObject *_args;
2479{
2480 PyObject *_res = NULL;
2481 if (!PyArg_ParseTuple(_args, ""))
2482 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002483 ShowMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002484 Py_INCREF(Py_None);
2485 _res = Py_None;
2486 return _res;
2487}
2488
Jack Jansena05ac601999-12-12 21:41:51 +00002489static PyObject *Menu_HideMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002490 PyObject *_self;
2491 PyObject *_args;
2492{
2493 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002494 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002495 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002496 HideMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002497 Py_INCREF(Py_None);
2498 _res = Py_None;
2499 return _res;
2500}
2501
Jack Jansena05ac601999-12-12 21:41:51 +00002502static PyObject *Menu_DeleteMCEntries(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002503 PyObject *_self;
2504 PyObject *_args;
2505{
2506 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002507 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002508 short menuItem;
2509 if (!PyArg_ParseTuple(_args, "hh",
2510 &menuID,
2511 &menuItem))
Jack Jansen21f96871998-02-20 16:02:09 +00002512 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002513 DeleteMCEntries(menuID,
2514 menuItem);
2515 Py_INCREF(Py_None);
2516 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00002517 return _res;
2518}
2519
Jack Jansena05ac601999-12-12 21:41:51 +00002520static PyObject *Menu_InitContextualMenus(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002521 PyObject *_self;
2522 PyObject *_args;
2523{
2524 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002525 OSStatus _err;
2526 if (!PyArg_ParseTuple(_args, ""))
2527 return NULL;
2528 _err = InitContextualMenus();
2529 if (_err != noErr) return PyMac_Error(_err);
2530 Py_INCREF(Py_None);
2531 _res = Py_None;
2532 return _res;
2533}
2534
2535static PyObject *Menu_IsShowContextualMenuClick(_self, _args)
2536 PyObject *_self;
2537 PyObject *_args;
2538{
2539 PyObject *_res = NULL;
2540 Boolean _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002541 EventRecord inEvent;
2542 if (!PyArg_ParseTuple(_args, "O&",
2543 PyMac_GetEventRecord, &inEvent))
2544 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002545 _rv = IsShowContextualMenuClick(&inEvent);
2546 _res = Py_BuildValue("b",
Jack Jansen21f96871998-02-20 16:02:09 +00002547 _rv);
2548 return _res;
2549}
2550
Jack Jansen74a1e632000-07-14 22:37:27 +00002551#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002552
Guido van Rossum86c3af71995-03-19 22:42:51 +00002553static PyObject *Menu_OpenDeskAcc(_self, _args)
2554 PyObject *_self;
2555 PyObject *_args;
2556{
2557 PyObject *_res = NULL;
2558 Str255 name;
2559 if (!PyArg_ParseTuple(_args, "O&",
2560 PyMac_GetStr255, name))
2561 return NULL;
2562 OpenDeskAcc(name);
2563 Py_INCREF(Py_None);
2564 _res = Py_None;
2565 return _res;
2566}
Jack Jansene79dc762000-06-02 21:35:07 +00002567#endif
Guido van Rossum86c3af71995-03-19 22:42:51 +00002568
Jack Jansene0581891999-02-07 14:02:03 +00002569static PyObject *Menu_as_Menu(_self, _args)
2570 PyObject *_self;
2571 PyObject *_args;
2572{
2573 PyObject *_res = NULL;
2574 MenuHandle _rv;
2575 Handle h;
2576 if (!PyArg_ParseTuple(_args, "O&",
2577 ResObj_Convert, &h))
2578 return NULL;
2579 _rv = as_Menu(h);
2580 _res = Py_BuildValue("O&",
2581 MenuObj_New, _rv);
2582 return _res;
2583}
2584
Jack Jansene180d991998-04-24 10:28:20 +00002585static PyObject *Menu_GetMenu(_self, _args)
2586 PyObject *_self;
2587 PyObject *_args;
2588{
2589 PyObject *_res = NULL;
2590 MenuHandle _rv;
2591 short resourceID;
2592 if (!PyArg_ParseTuple(_args, "h",
2593 &resourceID))
2594 return NULL;
2595 _rv = GetMenu(resourceID);
2596 _res = Py_BuildValue("O&",
2597 MenuObj_New, _rv);
2598 return _res;
2599}
2600
2601static PyObject *Menu_DeleteMenu(_self, _args)
2602 PyObject *_self;
2603 PyObject *_args;
2604{
2605 PyObject *_res = NULL;
2606 short menuID;
2607 if (!PyArg_ParseTuple(_args, "h",
2608 &menuID))
2609 return NULL;
2610 DeleteMenu(menuID);
2611 Py_INCREF(Py_None);
2612 _res = Py_None;
2613 return _res;
2614}
2615
2616static PyObject *Menu_DrawMenuBar(_self, _args)
2617 PyObject *_self;
2618 PyObject *_args;
2619{
2620 PyObject *_res = NULL;
2621 if (!PyArg_ParseTuple(_args, ""))
2622 return NULL;
2623 DrawMenuBar();
2624 Py_INCREF(Py_None);
2625 _res = Py_None;
2626 return _res;
2627}
2628
Guido van Rossum17448e21995-01-30 11:53:55 +00002629static PyMethodDef Menu_methods[] = {
Jack Jansene79dc762000-06-02 21:35:07 +00002630
Jack Jansen74a1e632000-07-14 22:37:27 +00002631#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002632 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2633 "(short resID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002634#endif
2635
Jack Jansen74a1e632000-07-14 22:37:27 +00002636#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002637 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2638 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002639#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002640 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002641 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002642 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00002643 "(short resourceID) -> (MenuHandle _rv)"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002644
2645#if TARGET_API_MAC_CARBON
2646 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2647 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2648#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002649 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002650 "(CharParameter ch) -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002651 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2652 "(Point startPt) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002653 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2654 "() -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002655 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2656 "(EventRecord inEvent) -> (UInt32 _rv)"},
2657 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2658 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002659 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002660 "() -> None"},
2661 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2662 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002663 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002664 "(MenuID menuID) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002665 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002666 "(short menuBarID) -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002667 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002668 "() -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002669 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002670 "(MenuBarHandle mbar) -> None"},
2671
2672#if TARGET_API_MAC_CARBON
2673 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2674 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2675#endif
2676
2677#if TARGET_API_MAC_CARBON
2678 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2679 "(MenuBarHandle mbar) -> None"},
2680#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002681 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002682 "(MenuID menuID) -> (MenuHandle _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002683 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002684 "(MenuID menuID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002685 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2686 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002687 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2688 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002689
Jack Jansen74a1e632000-07-14 22:37:27 +00002690#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002691 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2692 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002693#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002694 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002695 "(MenuID menuID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002696
Jack Jansen74a1e632000-07-14 22:37:27 +00002697#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002698 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2699 "(short editCmd) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002700#endif
2701
Jack Jansen74a1e632000-07-14 22:37:27 +00002702#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002703 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2704 "(long menuResult) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002705#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002706 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2707 "() -> (Boolean _rv)"},
2708 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2709 "() -> None"},
2710 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2711 "() -> None"},
2712 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002713 "(MenuID menuID, short menuItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002714 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2715 "() -> None"},
2716 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2717 "(EventRecord inEvent) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002718
Jack Jansen74a1e632000-07-14 22:37:27 +00002719#if !TARGET_API_MAC_CARBON
Guido van Rossum86c3af71995-03-19 22:42:51 +00002720 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2721 "(Str255 name) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002722#endif
Jack Jansene0581891999-02-07 14:02:03 +00002723 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2724 "(Handle h) -> (MenuHandle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002725 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2726 "(short resourceID) -> (MenuHandle _rv)"},
2727 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2728 "(short menuID) -> None"},
2729 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2730 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002731 {NULL, NULL, 0}
2732};
2733
2734
2735
2736
2737void initMenu()
2738{
2739 PyObject *m;
2740 PyObject *d;
2741
2742
2743
2744
2745 m = Py_InitModule("Menu", Menu_methods);
2746 d = PyModule_GetDict(m);
2747 Menu_Error = PyMac_GetOSErrException();
2748 if (Menu_Error == NULL ||
2749 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002750 return;
Jack Jansena755e681997-09-20 17:40:22 +00002751 Menu_Type.ob_type = &PyType_Type;
2752 Py_INCREF(&Menu_Type);
2753 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2754 Py_FatalError("can't initialize MenuType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002755}
2756
2757/* ======================== End module Menu ========================= */
2758