blob: 782b2706ab6b4bc1a897536fd953c39f316d73c8 [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
Jack Jansen54c07872001-01-29 13:32:10 +00001745static PyObject *MenuObj_EnableMenuItem(_self, _args)
1746 MenuObject *_self;
1747 PyObject *_args;
1748{
1749 PyObject *_res = NULL;
1750 UInt16 item;
1751 if (!PyArg_ParseTuple(_args, "H",
1752 &item))
1753 return NULL;
1754 EnableMenuItem(_self->ob_itself,
1755 item);
1756 Py_INCREF(Py_None);
1757 _res = Py_None;
1758 return _res;
1759}
1760
1761static PyObject *MenuObj_CheckMenuItem(_self, _args)
1762 MenuObject *_self;
1763 PyObject *_args;
1764{
1765 PyObject *_res = NULL;
1766 short item;
1767 Boolean checked;
1768 if (!PyArg_ParseTuple(_args, "hb",
1769 &item,
1770 &checked))
1771 return NULL;
1772 CheckMenuItem(_self->ob_itself,
1773 item,
1774 checked);
1775 Py_INCREF(Py_None);
1776 _res = Py_None;
1777 return _res;
1778}
1779
Guido van Rossum17448e21995-01-30 11:53:55 +00001780static PyMethodDef MenuObj_methods[] = {
1781 {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1,
1782 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001783 {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1,
1784 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001785 {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1,
1786 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001787
Jack Jansen74a1e632000-07-14 22:37:27 +00001788#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001789 {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1,
1790 "() -> (short _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001791#endif
Jack Jansena05ac601999-12-12 21:41:51 +00001792 {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1,
1793 "() -> (SInt16 outFontID, UInt16 outFontSize)"},
1794 {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1,
1795 "(SInt16 inFontID, UInt16 inFontSize) -> None"},
1796 {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1,
1797 "() -> (Boolean _rv)"},
1798 {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1,
1799 "(Boolean excludesMark) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001800 {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001801 "(Str255 data) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001802 {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1,
1803 "(ResType theType, short afterItem) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001804 {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1,
1805 "(ResType theType) -> None"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00001806 {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001807 "(Str255 itemString, short afterItem) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001808 {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001809 "(short item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001810 {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1,
1811 "(short afterItem, short scriptFilter) -> None"},
1812 {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1,
1813 "(ResType theType, short afterItem, short scriptFilter) -> None"},
1814 {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1,
1815 "(Str255 inString) -> None"},
1816 {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001817 "(Str255 inString, MenuItemIndex afterItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001818 {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1,
1819 "(short top, short left, short popUpItem) -> (long _rv)"},
1820 {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001821 "(MenuID beforeID) -> None"},
1822 {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1,
1823 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001824
Jack Jansen74a1e632000-07-14 22:37:27 +00001825#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00001826 {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1,
1827 "(short item, Boolean checked) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001828#endif
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001829 {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001830 "(short item, Str255 itemString) -> None"},
Jack Jansenb81cf9d1995-06-06 13:08:40 +00001831 {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00001832 "(short item) -> (Str255 itemString)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001833 {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001834 "(short item, CharParameter markChar) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001835 {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00001836 "(short item) -> (CharParameter markChar)"},
1837 {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1,
1838 "(short item, CharParameter cmdChar) -> None"},
1839 {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1,
1840 "(short item) -> (CharParameter cmdChar)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001841 {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1,
1842 "(short item, short iconIndex) -> None"},
1843 {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1,
1844 "(short item) -> (short iconIndex)"},
1845 {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1,
Jack Jansend6b6d881998-02-25 15:45:21 +00001846 "(short item, StyleParameter chStyle) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00001847 {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1,
Jack Jansen7d0bc831995-06-09 20:56:31 +00001848 "(short item) -> (Style chStyle)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001849
Jack Jansen74a1e632000-07-14 22:37:27 +00001850#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001851 {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1,
1852 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001853#endif
1854
Jack Jansen74a1e632000-07-14 22:37:27 +00001855#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001856 {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1,
1857 "(short item) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001858#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001859 {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001860 "(SInt16 inItem, MenuCommand inCommandID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001861 {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001862 "(SInt16 inItem) -> (MenuCommand outCommandID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001863 {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1,
1864 "(SInt16 inItem, UInt8 inModifiers) -> None"},
1865 {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1,
1866 "(SInt16 inItem) -> (UInt8 outModifiers)"},
1867 {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1,
1868 "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"},
1869 {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1,
1870 "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"},
1871 {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1,
1872 "(SInt16 inItem, TextEncoding inScriptID) -> None"},
1873 {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1,
1874 "(SInt16 inItem) -> (TextEncoding outScriptID)"},
1875 {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001876 "(SInt16 inItem, MenuID inHierID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00001877 {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001878 "(SInt16 inItem) -> (MenuID outHierID)"},
Jack Jansen21f96871998-02-20 16:02:09 +00001879 {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1,
1880 "(SInt16 inItem, SInt16 inFontID) -> None"},
1881 {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1,
1882 "(SInt16 inItem) -> (SInt16 outFontID)"},
1883 {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1,
1884 "(SInt16 inItem, UInt32 inRefCon) -> None"},
1885 {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1,
1886 "(SInt16 inItem) -> (UInt32 outRefCon)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001887
Jack Jansen74a1e632000-07-14 22:37:27 +00001888#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001889 {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1,
1890 "(SInt16 inItem, UInt32 inRefCon2) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00001891#endif
1892
Jack Jansen74a1e632000-07-14 22:37:27 +00001893#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00001894 {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1,
1895 "(SInt16 inItem) -> (UInt32 outRefCon2)"},
Jack Jansene79dc762000-06-02 21:35:07 +00001896#endif
Jack Jansen21f96871998-02-20 16:02:09 +00001897 {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1,
1898 "(SInt16 inItem, SInt16 inGlyph) -> None"},
1899 {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1,
1900 "(SInt16 inItem) -> (SInt16 outGlyph)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001901 {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001902 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001903 {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001904 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001905 {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001906 "(MenuItemIndex item) -> (Boolean _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00001907 {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001908 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001909 {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001910 "(MenuItemIndex item) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00001911 {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00001912 "(MenuItemIndex item) -> (Boolean _rv)"},
1913
1914#if TARGET_API_MAC_CARBON
1915 {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1,
1916 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"},
1917#endif
1918
1919#if TARGET_API_MAC_CARBON
1920 {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1,
1921 "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"},
1922#endif
1923
1924#if TARGET_API_MAC_CARBON
1925 {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1,
1926 "() -> (MenuAttributes outAttributes)"},
1927#endif
1928
1929#if TARGET_API_MAC_CARBON
1930 {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1,
1931 "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"},
1932#endif
1933
1934#if TARGET_API_MAC_CARBON
1935 {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1,
1936 "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"},
1937#endif
1938
1939#if TARGET_API_MAC_CARBON
1940 {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1,
1941 "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"},
1942#endif
1943
1944#if TARGET_API_MAC_CARBON
1945 {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1,
1946 "() -> None"},
1947#endif
1948
1949#if TARGET_API_MAC_CARBON
1950 {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1,
1951 "() -> None"},
1952#endif
1953
1954#if TARGET_API_MAC_CARBON
1955 {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1,
1956 "() -> (Boolean _rv)"},
1957#endif
1958
1959#if TARGET_API_MAC_CARBON
1960 {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1,
1961 "(MenuCommand commandID) -> (ItemCount _rv)"},
1962#endif
1963
1964#if TARGET_API_MAC_CARBON
1965 {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1,
1966 "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"},
1967#endif
1968
1969#if TARGET_API_MAC_CARBON
1970 {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1,
1971 "(MenuCommand commandID) -> None"},
1972#endif
1973
1974#if TARGET_API_MAC_CARBON
1975 {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1,
1976 "(MenuCommand commandID) -> None"},
1977#endif
1978
1979#if TARGET_API_MAC_CARBON
1980 {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1,
1981 "(MenuCommand commandID) -> (Boolean _rv)"},
1982#endif
1983
1984#if TARGET_API_MAC_CARBON
1985 {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1,
1986 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"},
1987#endif
1988
1989#if TARGET_API_MAC_CARBON
1990 {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1,
1991 "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"},
1992#endif
1993
1994#if TARGET_API_MAC_CARBON
1995 {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1,
1996 "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"},
1997#endif
1998
1999#if TARGET_API_MAC_CARBON
2000 {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1,
2001 "() -> (ItemCount outHierMenuCount)"},
2002#endif
2003
2004#if TARGET_API_MAC_CARBON
2005 {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1,
2006 "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"},
2007#endif
2008 {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1,
2009 "() -> (MenuID _rv)"},
2010 {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1,
2011 "() -> (SInt16 _rv)"},
2012 {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1,
2013 "() -> (SInt16 _rv)"},
2014 {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1,
2015 "(MenuID menuID) -> None"},
2016 {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1,
2017 "(SInt16 width) -> None"},
2018 {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1,
2019 "(SInt16 height) -> None"},
Jack Jansena1772281995-06-18 20:17:27 +00002020 {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
Jack Jansena1a0fef1999-12-23 14:32:06 +00002021 "() -> (Handle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002022 {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
2023 "(Str255 data) -> None"},
2024 {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
2025 "(short beforeID) -> None"},
2026 {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1,
2027 "(Str255 itemString, short afterItem) -> None"},
Jack Jansen54c07872001-01-29 13:32:10 +00002028 {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1,
2029 "(UInt16 item) -> None"},
2030 {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1,
2031 "(short item, Boolean checked) -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002032 {NULL, NULL, 0}
2033};
2034
2035PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
2036
2037static PyObject *MenuObj_getattr(self, name)
2038 MenuObject *self;
2039 char *name;
2040{
2041 return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
2042}
2043
2044#define MenuObj_setattr NULL
2045
Jack Jansena05ac601999-12-12 21:41:51 +00002046#define MenuObj_compare NULL
2047
2048#define MenuObj_repr NULL
2049
2050#define MenuObj_hash NULL
2051
Guido van Rossum17448e21995-01-30 11:53:55 +00002052PyTypeObject Menu_Type = {
2053 PyObject_HEAD_INIT(&PyType_Type)
2054 0, /*ob_size*/
2055 "Menu", /*tp_name*/
2056 sizeof(MenuObject), /*tp_basicsize*/
2057 0, /*tp_itemsize*/
2058 /* methods */
2059 (destructor) MenuObj_dealloc, /*tp_dealloc*/
2060 0, /*tp_print*/
2061 (getattrfunc) MenuObj_getattr, /*tp_getattr*/
2062 (setattrfunc) MenuObj_setattr, /*tp_setattr*/
Jack Jansena05ac601999-12-12 21:41:51 +00002063 (cmpfunc) MenuObj_compare, /*tp_compare*/
2064 (reprfunc) MenuObj_repr, /*tp_repr*/
2065 (PyNumberMethods *)0, /* tp_as_number */
2066 (PySequenceMethods *)0, /* tp_as_sequence */
2067 (PyMappingMethods *)0, /* tp_as_mapping */
2068 (hashfunc) MenuObj_hash, /*tp_hash*/
Guido van Rossum17448e21995-01-30 11:53:55 +00002069};
2070
2071/* ---------------------- End object type Menu ---------------------- */
2072
2073
Jack Jansen74a1e632000-07-14 22:37:27 +00002074#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002075
Jack Jansena05ac601999-12-12 21:41:51 +00002076static PyObject *Menu_InitProcMenu(_self, _args)
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002077 PyObject *_self;
2078 PyObject *_args;
2079{
2080 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002081 short resID;
2082 if (!PyArg_ParseTuple(_args, "h",
2083 &resID))
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002084 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002085 InitProcMenu(resID);
2086 Py_INCREF(Py_None);
2087 _res = Py_None;
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002088 return _res;
2089}
Jack Jansene79dc762000-06-02 21:35:07 +00002090#endif
2091
Jack Jansen74a1e632000-07-14 22:37:27 +00002092#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002093
Guido van Rossum17448e21995-01-30 11:53:55 +00002094static PyObject *Menu_InitMenus(_self, _args)
2095 PyObject *_self;
2096 PyObject *_args;
2097{
2098 PyObject *_res = NULL;
2099 if (!PyArg_ParseTuple(_args, ""))
2100 return NULL;
2101 InitMenus();
2102 Py_INCREF(Py_None);
2103 _res = Py_None;
2104 return _res;
2105}
Jack Jansene79dc762000-06-02 21:35:07 +00002106#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002107
2108static PyObject *Menu_NewMenu(_self, _args)
2109 PyObject *_self;
2110 PyObject *_args;
2111{
2112 PyObject *_res = NULL;
2113 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002114 MenuID menuID;
Guido van Rossum17448e21995-01-30 11:53:55 +00002115 Str255 menuTitle;
2116 if (!PyArg_ParseTuple(_args, "hO&",
2117 &menuID,
2118 PyMac_GetStr255, menuTitle))
2119 return NULL;
2120 _rv = NewMenu(menuID,
2121 menuTitle);
2122 _res = Py_BuildValue("O&",
2123 MenuObj_New, _rv);
2124 return _res;
2125}
2126
Jack Jansen1c4e6141998-04-21 15:23:55 +00002127static PyObject *Menu_MacGetMenu(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002128 PyObject *_self;
2129 PyObject *_args;
2130{
2131 PyObject *_res = NULL;
2132 MenuHandle _rv;
2133 short resourceID;
2134 if (!PyArg_ParseTuple(_args, "h",
2135 &resourceID))
2136 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002137 _rv = MacGetMenu(resourceID);
Guido van Rossum17448e21995-01-30 11:53:55 +00002138 _res = Py_BuildValue("O&",
2139 MenuObj_New, _rv);
2140 return _res;
2141}
2142
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002143#if TARGET_API_MAC_CARBON
2144
2145static PyObject *Menu_CreateNewMenu(_self, _args)
2146 PyObject *_self;
2147 PyObject *_args;
2148{
2149 PyObject *_res = NULL;
2150 OSStatus _err;
2151 MenuID menuID;
2152 MenuAttributes menuAttributes;
2153 MenuHandle outMenuRef;
2154 if (!PyArg_ParseTuple(_args, "hl",
2155 &menuID,
2156 &menuAttributes))
2157 return NULL;
2158 _err = CreateNewMenu(menuID,
2159 menuAttributes,
2160 &outMenuRef);
2161 if (_err != noErr) return PyMac_Error(_err);
2162 _res = Py_BuildValue("O&",
2163 MenuObj_New, outMenuRef);
2164 return _res;
2165}
2166#endif
2167
Guido van Rossum17448e21995-01-30 11:53:55 +00002168static PyObject *Menu_MenuKey(_self, _args)
2169 PyObject *_self;
2170 PyObject *_args;
2171{
2172 PyObject *_res = NULL;
2173 long _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002174 CharParameter ch;
Guido van Rossum17448e21995-01-30 11:53:55 +00002175 if (!PyArg_ParseTuple(_args, "h",
2176 &ch))
2177 return NULL;
2178 _rv = MenuKey(ch);
2179 _res = Py_BuildValue("l",
2180 _rv);
2181 return _res;
2182}
2183
Jack Jansena05ac601999-12-12 21:41:51 +00002184static PyObject *Menu_MenuSelect(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002185 PyObject *_self;
2186 PyObject *_args;
2187{
2188 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002189 long _rv;
2190 Point startPt;
2191 if (!PyArg_ParseTuple(_args, "O&",
2192 PyMac_GetPoint, &startPt))
Guido van Rossum17448e21995-01-30 11:53:55 +00002193 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002194 _rv = MenuSelect(startPt);
2195 _res = Py_BuildValue("l",
2196 _rv);
Guido van Rossum17448e21995-01-30 11:53:55 +00002197 return _res;
2198}
2199
Guido van Rossum17448e21995-01-30 11:53:55 +00002200static PyObject *Menu_MenuChoice(_self, _args)
2201 PyObject *_self;
2202 PyObject *_args;
2203{
2204 PyObject *_res = NULL;
2205 long _rv;
2206 if (!PyArg_ParseTuple(_args, ""))
2207 return NULL;
2208 _rv = MenuChoice();
2209 _res = Py_BuildValue("l",
2210 _rv);
2211 return _res;
2212}
2213
Jack Jansena05ac601999-12-12 21:41:51 +00002214static PyObject *Menu_MenuEvent(_self, _args)
Guido van Rossum17448e21995-01-30 11:53:55 +00002215 PyObject *_self;
2216 PyObject *_args;
2217{
2218 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002219 UInt32 _rv;
2220 EventRecord inEvent;
2221 if (!PyArg_ParseTuple(_args, "O&",
2222 PyMac_GetEventRecord, &inEvent))
Guido van Rossum17448e21995-01-30 11:53:55 +00002223 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002224 _rv = MenuEvent(&inEvent);
2225 _res = Py_BuildValue("l",
2226 _rv);
2227 return _res;
2228}
2229
2230static PyObject *Menu_GetMBarHeight(_self, _args)
2231 PyObject *_self;
2232 PyObject *_args;
2233{
2234 PyObject *_res = NULL;
2235 short _rv;
2236 if (!PyArg_ParseTuple(_args, ""))
2237 return NULL;
2238 _rv = GetMBarHeight();
2239 _res = Py_BuildValue("h",
2240 _rv);
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002241 return _res;
2242}
2243
Jack Jansen1c4e6141998-04-21 15:23:55 +00002244static PyObject *Menu_MacDrawMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002245 PyObject *_self;
2246 PyObject *_args;
2247{
2248 PyObject *_res = NULL;
2249 if (!PyArg_ParseTuple(_args, ""))
2250 return NULL;
Jack Jansen1c4e6141998-04-21 15:23:55 +00002251 MacDrawMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002252 Py_INCREF(Py_None);
2253 _res = Py_None;
2254 return _res;
2255}
2256
2257static PyObject *Menu_InvalMenuBar(_self, _args)
2258 PyObject *_self;
2259 PyObject *_args;
2260{
2261 PyObject *_res = NULL;
2262 if (!PyArg_ParseTuple(_args, ""))
2263 return NULL;
2264 InvalMenuBar();
2265 Py_INCREF(Py_None);
2266 _res = Py_None;
2267 return _res;
2268}
2269
Jack Jansena05ac601999-12-12 21:41:51 +00002270static PyObject *Menu_HiliteMenu(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002271 PyObject *_self;
2272 PyObject *_args;
2273{
2274 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002275 MenuID menuID;
Jack Jansen21f96871998-02-20 16:02:09 +00002276 if (!PyArg_ParseTuple(_args, "h",
Jack Jansena05ac601999-12-12 21:41:51 +00002277 &menuID))
Jack Jansen21f96871998-02-20 16:02:09 +00002278 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002279 HiliteMenu(menuID);
Jack Jansen21f96871998-02-20 16:02:09 +00002280 Py_INCREF(Py_None);
2281 _res = Py_None;
2282 return _res;
2283}
2284
Jack Jansena05ac601999-12-12 21:41:51 +00002285static PyObject *Menu_GetNewMBar(_self, _args)
2286 PyObject *_self;
2287 PyObject *_args;
2288{
2289 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002290 MenuBarHandle _rv;
Jack Jansena05ac601999-12-12 21:41:51 +00002291 short menuBarID;
2292 if (!PyArg_ParseTuple(_args, "h",
2293 &menuBarID))
2294 return NULL;
2295 _rv = GetNewMBar(menuBarID);
2296 _res = Py_BuildValue("O&",
2297 ResObj_New, _rv);
2298 return _res;
2299}
2300
Jack Jansen21f96871998-02-20 16:02:09 +00002301static PyObject *Menu_GetMenuBar(_self, _args)
2302 PyObject *_self;
2303 PyObject *_args;
2304{
2305 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002306 MenuBarHandle _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002307 if (!PyArg_ParseTuple(_args, ""))
2308 return NULL;
2309 _rv = GetMenuBar();
2310 _res = Py_BuildValue("O&",
2311 ResObj_New, _rv);
2312 return _res;
2313}
2314
2315static PyObject *Menu_SetMenuBar(_self, _args)
2316 PyObject *_self;
2317 PyObject *_args;
2318{
2319 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002320 MenuBarHandle mbar;
Jack Jansen21f96871998-02-20 16:02:09 +00002321 if (!PyArg_ParseTuple(_args, "O&",
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002322 ResObj_Convert, &mbar))
Jack Jansen21f96871998-02-20 16:02:09 +00002323 return NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002324 SetMenuBar(mbar);
Jack Jansen21f96871998-02-20 16:02:09 +00002325 Py_INCREF(Py_None);
2326 _res = Py_None;
2327 return _res;
2328}
2329
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002330#if TARGET_API_MAC_CARBON
2331
2332static PyObject *Menu_DuplicateMenuBar(_self, _args)
2333 PyObject *_self;
2334 PyObject *_args;
2335{
2336 PyObject *_res = NULL;
2337 OSStatus _err;
2338 MenuBarHandle mbar;
2339 MenuBarHandle outBar;
2340 if (!PyArg_ParseTuple(_args, "O&",
2341 ResObj_Convert, &mbar))
2342 return NULL;
2343 _err = DuplicateMenuBar(mbar,
2344 &outBar);
2345 if (_err != noErr) return PyMac_Error(_err);
2346 _res = Py_BuildValue("O&",
2347 ResObj_New, outBar);
2348 return _res;
2349}
2350#endif
2351
2352#if TARGET_API_MAC_CARBON
2353
2354static PyObject *Menu_DisposeMenuBar(_self, _args)
2355 PyObject *_self;
2356 PyObject *_args;
2357{
2358 PyObject *_res = NULL;
2359 OSStatus _err;
2360 MenuBarHandle mbar;
2361 if (!PyArg_ParseTuple(_args, "O&",
2362 ResObj_Convert, &mbar))
2363 return NULL;
2364 _err = DisposeMenuBar(mbar);
2365 if (_err != noErr) return PyMac_Error(_err);
2366 Py_INCREF(Py_None);
2367 _res = Py_None;
2368 return _res;
2369}
2370#endif
2371
Jack Jansena05ac601999-12-12 21:41:51 +00002372static PyObject *Menu_GetMenuHandle(_self, _args)
2373 PyObject *_self;
2374 PyObject *_args;
2375{
2376 PyObject *_res = NULL;
2377 MenuHandle _rv;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002378 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002379 if (!PyArg_ParseTuple(_args, "h",
2380 &menuID))
2381 return NULL;
2382 _rv = GetMenuHandle(menuID);
2383 _res = Py_BuildValue("O&",
2384 MenuObj_New, _rv);
2385 return _res;
2386}
2387
2388static PyObject *Menu_MacDeleteMenu(_self, _args)
2389 PyObject *_self;
2390 PyObject *_args;
2391{
2392 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002393 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002394 if (!PyArg_ParseTuple(_args, "h",
2395 &menuID))
2396 return NULL;
2397 MacDeleteMenu(menuID);
2398 Py_INCREF(Py_None);
2399 _res = Py_None;
2400 return _res;
2401}
2402
2403static PyObject *Menu_ClearMenuBar(_self, _args)
2404 PyObject *_self;
2405 PyObject *_args;
2406{
2407 PyObject *_res = NULL;
2408 if (!PyArg_ParseTuple(_args, ""))
2409 return NULL;
2410 ClearMenuBar();
2411 Py_INCREF(Py_None);
2412 _res = Py_None;
2413 return _res;
2414}
2415
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002416static PyObject *Menu_SetMenuFlashCount(_self, _args)
2417 PyObject *_self;
2418 PyObject *_args;
2419{
2420 PyObject *_res = NULL;
2421 short count;
2422 if (!PyArg_ParseTuple(_args, "h",
2423 &count))
2424 return NULL;
2425 SetMenuFlashCount(count);
2426 Py_INCREF(Py_None);
2427 _res = Py_None;
2428 return _res;
2429}
2430
Jack Jansen74a1e632000-07-14 22:37:27 +00002431#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002432
Jack Jansena05ac601999-12-12 21:41:51 +00002433static PyObject *Menu_SetMenuFlash(_self, _args)
2434 PyObject *_self;
2435 PyObject *_args;
2436{
2437 PyObject *_res = NULL;
2438 short count;
2439 if (!PyArg_ParseTuple(_args, "h",
2440 &count))
2441 return NULL;
2442 SetMenuFlash(count);
2443 Py_INCREF(Py_None);
2444 _res = Py_None;
2445 return _res;
2446}
Jack Jansene79dc762000-06-02 21:35:07 +00002447#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002448
2449static PyObject *Menu_FlashMenuBar(_self, _args)
2450 PyObject *_self;
2451 PyObject *_args;
2452{
2453 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002454 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002455 if (!PyArg_ParseTuple(_args, "h",
2456 &menuID))
2457 return NULL;
2458 FlashMenuBar(menuID);
2459 Py_INCREF(Py_None);
2460 _res = Py_None;
2461 return _res;
2462}
2463
Jack Jansen74a1e632000-07-14 22:37:27 +00002464#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002465
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002466static PyObject *Menu_SystemEdit(_self, _args)
2467 PyObject *_self;
2468 PyObject *_args;
2469{
2470 PyObject *_res = NULL;
2471 Boolean _rv;
2472 short editCmd;
2473 if (!PyArg_ParseTuple(_args, "h",
2474 &editCmd))
2475 return NULL;
2476 _rv = SystemEdit(editCmd);
2477 _res = Py_BuildValue("b",
2478 _rv);
2479 return _res;
2480}
Jack Jansene79dc762000-06-02 21:35:07 +00002481#endif
2482
Jack Jansen74a1e632000-07-14 22:37:27 +00002483#if !TARGET_API_MAC_CARBON
Jack Jansenb81cf9d1995-06-06 13:08:40 +00002484
2485static PyObject *Menu_SystemMenu(_self, _args)
2486 PyObject *_self;
2487 PyObject *_args;
2488{
2489 PyObject *_res = NULL;
2490 long menuResult;
2491 if (!PyArg_ParseTuple(_args, "l",
2492 &menuResult))
2493 return NULL;
2494 SystemMenu(menuResult);
Guido van Rossum17448e21995-01-30 11:53:55 +00002495 Py_INCREF(Py_None);
2496 _res = Py_None;
2497 return _res;
2498}
Jack Jansene79dc762000-06-02 21:35:07 +00002499#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002500
Jack Jansena05ac601999-12-12 21:41:51 +00002501static PyObject *Menu_IsMenuBarVisible(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002502 PyObject *_self;
2503 PyObject *_args;
2504{
2505 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002506 Boolean _rv;
2507 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002508 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002509 _rv = IsMenuBarVisible();
2510 _res = Py_BuildValue("b",
2511 _rv);
Jack Jansen21f96871998-02-20 16:02:09 +00002512 return _res;
2513}
2514
Jack Jansena05ac601999-12-12 21:41:51 +00002515static PyObject *Menu_ShowMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002516 PyObject *_self;
2517 PyObject *_args;
2518{
2519 PyObject *_res = NULL;
2520 if (!PyArg_ParseTuple(_args, ""))
2521 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002522 ShowMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002523 Py_INCREF(Py_None);
2524 _res = Py_None;
2525 return _res;
2526}
2527
Jack Jansena05ac601999-12-12 21:41:51 +00002528static PyObject *Menu_HideMenuBar(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002529 PyObject *_self;
2530 PyObject *_args;
2531{
2532 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002533 if (!PyArg_ParseTuple(_args, ""))
Jack Jansen21f96871998-02-20 16:02:09 +00002534 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002535 HideMenuBar();
Jack Jansen21f96871998-02-20 16:02:09 +00002536 Py_INCREF(Py_None);
2537 _res = Py_None;
2538 return _res;
2539}
2540
Jack Jansena05ac601999-12-12 21:41:51 +00002541static PyObject *Menu_DeleteMCEntries(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002542 PyObject *_self;
2543 PyObject *_args;
2544{
2545 PyObject *_res = NULL;
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002546 MenuID menuID;
Jack Jansena05ac601999-12-12 21:41:51 +00002547 short menuItem;
2548 if (!PyArg_ParseTuple(_args, "hh",
2549 &menuID,
2550 &menuItem))
Jack Jansen21f96871998-02-20 16:02:09 +00002551 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002552 DeleteMCEntries(menuID,
2553 menuItem);
2554 Py_INCREF(Py_None);
2555 _res = Py_None;
Jack Jansen21f96871998-02-20 16:02:09 +00002556 return _res;
2557}
2558
Jack Jansena05ac601999-12-12 21:41:51 +00002559static PyObject *Menu_InitContextualMenus(_self, _args)
Jack Jansen21f96871998-02-20 16:02:09 +00002560 PyObject *_self;
2561 PyObject *_args;
2562{
2563 PyObject *_res = NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002564 OSStatus _err;
2565 if (!PyArg_ParseTuple(_args, ""))
2566 return NULL;
2567 _err = InitContextualMenus();
2568 if (_err != noErr) return PyMac_Error(_err);
2569 Py_INCREF(Py_None);
2570 _res = Py_None;
2571 return _res;
2572}
2573
2574static PyObject *Menu_IsShowContextualMenuClick(_self, _args)
2575 PyObject *_self;
2576 PyObject *_args;
2577{
2578 PyObject *_res = NULL;
2579 Boolean _rv;
Jack Jansen21f96871998-02-20 16:02:09 +00002580 EventRecord inEvent;
2581 if (!PyArg_ParseTuple(_args, "O&",
2582 PyMac_GetEventRecord, &inEvent))
2583 return NULL;
Jack Jansena05ac601999-12-12 21:41:51 +00002584 _rv = IsShowContextualMenuClick(&inEvent);
2585 _res = Py_BuildValue("b",
Jack Jansen21f96871998-02-20 16:02:09 +00002586 _rv);
2587 return _res;
2588}
2589
Jack Jansen74a1e632000-07-14 22:37:27 +00002590#if !TARGET_API_MAC_CARBON
Jack Jansene79dc762000-06-02 21:35:07 +00002591
Guido van Rossum86c3af71995-03-19 22:42:51 +00002592static PyObject *Menu_OpenDeskAcc(_self, _args)
2593 PyObject *_self;
2594 PyObject *_args;
2595{
2596 PyObject *_res = NULL;
2597 Str255 name;
2598 if (!PyArg_ParseTuple(_args, "O&",
2599 PyMac_GetStr255, name))
2600 return NULL;
2601 OpenDeskAcc(name);
2602 Py_INCREF(Py_None);
2603 _res = Py_None;
2604 return _res;
2605}
Jack Jansene79dc762000-06-02 21:35:07 +00002606#endif
Guido van Rossum86c3af71995-03-19 22:42:51 +00002607
Jack Jansene0581891999-02-07 14:02:03 +00002608static PyObject *Menu_as_Menu(_self, _args)
2609 PyObject *_self;
2610 PyObject *_args;
2611{
2612 PyObject *_res = NULL;
2613 MenuHandle _rv;
2614 Handle h;
2615 if (!PyArg_ParseTuple(_args, "O&",
2616 ResObj_Convert, &h))
2617 return NULL;
2618 _rv = as_Menu(h);
2619 _res = Py_BuildValue("O&",
2620 MenuObj_New, _rv);
2621 return _res;
2622}
2623
Jack Jansene180d991998-04-24 10:28:20 +00002624static PyObject *Menu_GetMenu(_self, _args)
2625 PyObject *_self;
2626 PyObject *_args;
2627{
2628 PyObject *_res = NULL;
2629 MenuHandle _rv;
2630 short resourceID;
2631 if (!PyArg_ParseTuple(_args, "h",
2632 &resourceID))
2633 return NULL;
2634 _rv = GetMenu(resourceID);
2635 _res = Py_BuildValue("O&",
2636 MenuObj_New, _rv);
2637 return _res;
2638}
2639
2640static PyObject *Menu_DeleteMenu(_self, _args)
2641 PyObject *_self;
2642 PyObject *_args;
2643{
2644 PyObject *_res = NULL;
2645 short menuID;
2646 if (!PyArg_ParseTuple(_args, "h",
2647 &menuID))
2648 return NULL;
2649 DeleteMenu(menuID);
2650 Py_INCREF(Py_None);
2651 _res = Py_None;
2652 return _res;
2653}
2654
2655static PyObject *Menu_DrawMenuBar(_self, _args)
2656 PyObject *_self;
2657 PyObject *_args;
2658{
2659 PyObject *_res = NULL;
2660 if (!PyArg_ParseTuple(_args, ""))
2661 return NULL;
2662 DrawMenuBar();
2663 Py_INCREF(Py_None);
2664 _res = Py_None;
2665 return _res;
2666}
2667
Guido van Rossum17448e21995-01-30 11:53:55 +00002668static PyMethodDef Menu_methods[] = {
Jack Jansene79dc762000-06-02 21:35:07 +00002669
Jack Jansen74a1e632000-07-14 22:37:27 +00002670#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002671 {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1,
2672 "(short resID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002673#endif
2674
Jack Jansen74a1e632000-07-14 22:37:27 +00002675#if !TARGET_API_MAC_CARBON
Guido van Rossum17448e21995-01-30 11:53:55 +00002676 {"InitMenus", (PyCFunction)Menu_InitMenus, 1,
2677 "() -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002678#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002679 {"NewMenu", (PyCFunction)Menu_NewMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002680 "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002681 {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1,
Guido van Rossum17448e21995-01-30 11:53:55 +00002682 "(short resourceID) -> (MenuHandle _rv)"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002683
2684#if TARGET_API_MAC_CARBON
2685 {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1,
2686 "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"},
2687#endif
Guido van Rossum17448e21995-01-30 11:53:55 +00002688 {"MenuKey", (PyCFunction)Menu_MenuKey, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002689 "(CharParameter ch) -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002690 {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1,
2691 "(Point startPt) -> (long _rv)"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002692 {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1,
2693 "() -> (long _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002694 {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1,
2695 "(EventRecord inEvent) -> (UInt32 _rv)"},
2696 {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1,
2697 "() -> (short _rv)"},
Jack Jansen1c4e6141998-04-21 15:23:55 +00002698 {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1,
Jack Jansen21f96871998-02-20 16:02:09 +00002699 "() -> None"},
2700 {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1,
2701 "() -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002702 {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002703 "(MenuID menuID) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002704 {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002705 "(short menuBarID) -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002706 {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002707 "() -> (MenuBarHandle _rv)"},
Jack Jansen21f96871998-02-20 16:02:09 +00002708 {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002709 "(MenuBarHandle mbar) -> None"},
2710
2711#if TARGET_API_MAC_CARBON
2712 {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1,
2713 "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"},
2714#endif
2715
2716#if TARGET_API_MAC_CARBON
2717 {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1,
2718 "(MenuBarHandle mbar) -> None"},
2719#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002720 {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002721 "(MenuID menuID) -> (MenuHandle _rv)"},
Jack Jansena05ac601999-12-12 21:41:51 +00002722 {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002723 "(MenuID menuID) -> None"},
Jack Jansen21f96871998-02-20 16:02:09 +00002724 {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1,
2725 "() -> None"},
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002726 {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1,
2727 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002728
Jack Jansen74a1e632000-07-14 22:37:27 +00002729#if !TARGET_API_MAC_CARBON
Jack Jansen21f96871998-02-20 16:02:09 +00002730 {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1,
2731 "(short count) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002732#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002733 {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002734 "(MenuID menuID) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002735
Jack Jansen74a1e632000-07-14 22:37:27 +00002736#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002737 {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1,
2738 "(short editCmd) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002739#endif
2740
Jack Jansen74a1e632000-07-14 22:37:27 +00002741#if !TARGET_API_MAC_CARBON
Jack Jansena05ac601999-12-12 21:41:51 +00002742 {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1,
2743 "(long menuResult) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002744#endif
Jack Jansena05ac601999-12-12 21:41:51 +00002745 {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1,
2746 "() -> (Boolean _rv)"},
2747 {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1,
2748 "() -> None"},
2749 {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1,
2750 "() -> None"},
2751 {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1,
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002752 "(MenuID menuID, short menuItem) -> None"},
Jack Jansena05ac601999-12-12 21:41:51 +00002753 {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1,
2754 "() -> None"},
2755 {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1,
2756 "(EventRecord inEvent) -> (Boolean _rv)"},
Jack Jansene79dc762000-06-02 21:35:07 +00002757
Jack Jansen74a1e632000-07-14 22:37:27 +00002758#if !TARGET_API_MAC_CARBON
Guido van Rossum86c3af71995-03-19 22:42:51 +00002759 {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1,
2760 "(Str255 name) -> None"},
Jack Jansene79dc762000-06-02 21:35:07 +00002761#endif
Jack Jansene0581891999-02-07 14:02:03 +00002762 {"as_Menu", (PyCFunction)Menu_as_Menu, 1,
2763 "(Handle h) -> (MenuHandle _rv)"},
Jack Jansene180d991998-04-24 10:28:20 +00002764 {"GetMenu", (PyCFunction)Menu_GetMenu, 1,
2765 "(short resourceID) -> (MenuHandle _rv)"},
2766 {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1,
2767 "(short menuID) -> None"},
2768 {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1,
2769 "() -> None"},
Guido van Rossum17448e21995-01-30 11:53:55 +00002770 {NULL, NULL, 0}
2771};
2772
2773
2774
2775
2776void initMenu()
2777{
2778 PyObject *m;
2779 PyObject *d;
2780
2781
2782
2783
2784 m = Py_InitModule("Menu", Menu_methods);
2785 d = PyModule_GetDict(m);
2786 Menu_Error = PyMac_GetOSErrException();
2787 if (Menu_Error == NULL ||
2788 PyDict_SetItemString(d, "Error", Menu_Error) != 0)
Jack Jansenf7d5aa62000-12-10 23:43:49 +00002789 return;
Jack Jansena755e681997-09-20 17:40:22 +00002790 Menu_Type.ob_type = &PyType_Type;
2791 Py_INCREF(&Menu_Type);
2792 if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0)
2793 Py_FatalError("can't initialize MenuType");
Guido van Rossum17448e21995-01-30 11:53:55 +00002794}
2795
2796/* ======================== End module Menu ========================= */
2797