Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | |
| 2 | /* ========================== Module Menu =========================== */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
| 8 | #define SystemSevenOrLater 1 |
| 9 | |
| 10 | #include "macglue.h" |
| 11 | #include <Memory.h> |
| 12 | #include <Dialogs.h> |
| 13 | #include <Menus.h> |
| 14 | #include <Controls.h> |
| 15 | |
| 16 | extern PyObject *ResObj_New(Handle); |
| 17 | extern int ResObj_Convert(PyObject *, Handle *); |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 18 | extern PyObject *OptResObj_New(Handle); |
| 19 | extern int OptResObj_Convert(PyObject *, Handle *); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 20 | |
| 21 | extern PyObject *WinObj_New(WindowPtr); |
| 22 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 23 | extern PyTypeObject Window_Type; |
| 24 | #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 25 | |
| 26 | extern PyObject *DlgObj_New(DialogPtr); |
| 27 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 28 | extern PyTypeObject Dialog_Type; |
| 29 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 30 | |
| 31 | extern PyObject *MenuObj_New(MenuHandle); |
| 32 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 33 | |
| 34 | extern PyObject *CtlObj_New(ControlHandle); |
| 35 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 36 | |
Jack Jansen | 425e9eb | 1995-12-12 15:02:03 +0000 | [diff] [blame] | 37 | extern PyObject *GrafObj_New(GrafPtr); |
| 38 | extern int GrafObj_Convert(PyObject *, GrafPtr *); |
| 39 | |
| 40 | extern PyObject *BMObj_New(BitMapPtr); |
| 41 | extern int BMObj_Convert(PyObject *, BitMapPtr *); |
| 42 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 43 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
| 44 | |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 45 | #include <Devices.h> /* Defines OpenDeskAcc in universal headers */ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 46 | #include <Menus.h> |
| 47 | |
| 48 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 49 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 50 | #define as_Menu(h) ((MenuHandle)h) |
| 51 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 52 | static PyObject *Menu_Error; |
| 53 | |
| 54 | /* ------------------------ Object type Menu ------------------------ */ |
| 55 | |
| 56 | PyTypeObject Menu_Type; |
| 57 | |
| 58 | #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type) |
| 59 | |
| 60 | typedef struct MenuObject { |
| 61 | PyObject_HEAD |
| 62 | MenuHandle ob_itself; |
| 63 | } MenuObject; |
| 64 | |
| 65 | PyObject *MenuObj_New(itself) |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 66 | MenuHandle itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 67 | { |
| 68 | MenuObject *it; |
| 69 | it = PyObject_NEW(MenuObject, &Menu_Type); |
| 70 | if (it == NULL) return NULL; |
| 71 | it->ob_itself = itself; |
| 72 | return (PyObject *)it; |
| 73 | } |
| 74 | MenuObj_Convert(v, p_itself) |
| 75 | PyObject *v; |
| 76 | MenuHandle *p_itself; |
| 77 | { |
| 78 | if (!MenuObj_Check(v)) |
| 79 | { |
| 80 | PyErr_SetString(PyExc_TypeError, "Menu required"); |
| 81 | return 0; |
| 82 | } |
| 83 | *p_itself = ((MenuObject *)v)->ob_itself; |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | static void MenuObj_dealloc(self) |
| 88 | MenuObject *self; |
| 89 | { |
| 90 | /* Cleanup of self->ob_itself goes here */ |
| 91 | PyMem_DEL(self); |
| 92 | } |
| 93 | |
| 94 | static PyObject *MenuObj_DisposeMenu(_self, _args) |
| 95 | MenuObject *_self; |
| 96 | PyObject *_args; |
| 97 | { |
| 98 | PyObject *_res = NULL; |
| 99 | if (!PyArg_ParseTuple(_args, "")) |
| 100 | return NULL; |
| 101 | DisposeMenu(_self->ob_itself); |
| 102 | Py_INCREF(Py_None); |
| 103 | _res = Py_None; |
| 104 | return _res; |
| 105 | } |
| 106 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 107 | static PyObject *MenuObj_CalcMenuSize(_self, _args) |
| 108 | MenuObject *_self; |
| 109 | PyObject *_args; |
| 110 | { |
| 111 | PyObject *_res = NULL; |
| 112 | if (!PyArg_ParseTuple(_args, "")) |
| 113 | return NULL; |
| 114 | CalcMenuSize(_self->ob_itself); |
| 115 | Py_INCREF(Py_None); |
| 116 | _res = Py_None; |
| 117 | return _res; |
| 118 | } |
| 119 | |
| 120 | static PyObject *MenuObj_CountMItems(_self, _args) |
| 121 | MenuObject *_self; |
| 122 | PyObject *_args; |
| 123 | { |
| 124 | PyObject *_res = NULL; |
| 125 | short _rv; |
| 126 | if (!PyArg_ParseTuple(_args, "")) |
| 127 | return NULL; |
| 128 | _rv = CountMItems(_self->ob_itself); |
| 129 | _res = Py_BuildValue("h", |
| 130 | _rv); |
| 131 | return _res; |
| 132 | } |
| 133 | |
| 134 | static PyObject *MenuObj_GetMenuFont(_self, _args) |
| 135 | MenuObject *_self; |
| 136 | PyObject *_args; |
| 137 | { |
| 138 | PyObject *_res = NULL; |
| 139 | OSStatus _err; |
| 140 | SInt16 outFontID; |
| 141 | UInt16 outFontSize; |
| 142 | if (!PyArg_ParseTuple(_args, "")) |
| 143 | return NULL; |
| 144 | _err = GetMenuFont(_self->ob_itself, |
| 145 | &outFontID, |
| 146 | &outFontSize); |
| 147 | if (_err != noErr) return PyMac_Error(_err); |
| 148 | _res = Py_BuildValue("hh", |
| 149 | outFontID, |
| 150 | outFontSize); |
| 151 | return _res; |
| 152 | } |
| 153 | |
| 154 | static PyObject *MenuObj_SetMenuFont(_self, _args) |
| 155 | MenuObject *_self; |
| 156 | PyObject *_args; |
| 157 | { |
| 158 | PyObject *_res = NULL; |
| 159 | OSStatus _err; |
| 160 | SInt16 inFontID; |
| 161 | UInt16 inFontSize; |
| 162 | if (!PyArg_ParseTuple(_args, "hh", |
| 163 | &inFontID, |
| 164 | &inFontSize)) |
| 165 | return NULL; |
| 166 | _err = SetMenuFont(_self->ob_itself, |
| 167 | inFontID, |
| 168 | inFontSize); |
| 169 | if (_err != noErr) return PyMac_Error(_err); |
| 170 | Py_INCREF(Py_None); |
| 171 | _res = Py_None; |
| 172 | return _res; |
| 173 | } |
| 174 | |
| 175 | static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args) |
| 176 | MenuObject *_self; |
| 177 | PyObject *_args; |
| 178 | { |
| 179 | PyObject *_res = NULL; |
| 180 | Boolean _rv; |
| 181 | if (!PyArg_ParseTuple(_args, "")) |
| 182 | return NULL; |
| 183 | _rv = GetMenuExcludesMarkColumn(_self->ob_itself); |
| 184 | _res = Py_BuildValue("b", |
| 185 | _rv); |
| 186 | return _res; |
| 187 | } |
| 188 | |
| 189 | static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args) |
| 190 | MenuObject *_self; |
| 191 | PyObject *_args; |
| 192 | { |
| 193 | PyObject *_res = NULL; |
| 194 | OSStatus _err; |
| 195 | Boolean excludesMark; |
| 196 | if (!PyArg_ParseTuple(_args, "b", |
| 197 | &excludesMark)) |
| 198 | return NULL; |
| 199 | _err = SetMenuExcludesMarkColumn(_self->ob_itself, |
| 200 | excludesMark); |
| 201 | if (_err != noErr) return PyMac_Error(_err); |
| 202 | Py_INCREF(Py_None); |
| 203 | _res = Py_None; |
| 204 | return _res; |
| 205 | } |
| 206 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 207 | static PyObject *MenuObj_MacAppendMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 208 | MenuObject *_self; |
| 209 | PyObject *_args; |
| 210 | { |
| 211 | PyObject *_res = NULL; |
| 212 | Str255 data; |
| 213 | if (!PyArg_ParseTuple(_args, "O&", |
| 214 | PyMac_GetStr255, data)) |
| 215 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 216 | MacAppendMenu(_self->ob_itself, |
| 217 | data); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 218 | Py_INCREF(Py_None); |
| 219 | _res = Py_None; |
| 220 | return _res; |
| 221 | } |
| 222 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 223 | static PyObject *MenuObj_InsertResMenu(_self, _args) |
| 224 | MenuObject *_self; |
| 225 | PyObject *_args; |
| 226 | { |
| 227 | PyObject *_res = NULL; |
| 228 | ResType theType; |
| 229 | short afterItem; |
| 230 | if (!PyArg_ParseTuple(_args, "O&h", |
| 231 | PyMac_GetOSType, &theType, |
| 232 | &afterItem)) |
| 233 | return NULL; |
| 234 | InsertResMenu(_self->ob_itself, |
| 235 | theType, |
| 236 | afterItem); |
| 237 | Py_INCREF(Py_None); |
| 238 | _res = Py_None; |
| 239 | return _res; |
| 240 | } |
| 241 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 242 | static PyObject *MenuObj_AppendResMenu(_self, _args) |
| 243 | MenuObject *_self; |
| 244 | PyObject *_args; |
| 245 | { |
| 246 | PyObject *_res = NULL; |
| 247 | ResType theType; |
| 248 | if (!PyArg_ParseTuple(_args, "O&", |
| 249 | PyMac_GetOSType, &theType)) |
| 250 | return NULL; |
| 251 | AppendResMenu(_self->ob_itself, |
| 252 | theType); |
| 253 | Py_INCREF(Py_None); |
| 254 | _res = Py_None; |
| 255 | return _res; |
| 256 | } |
| 257 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 258 | static PyObject *MenuObj_MacInsertMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 259 | MenuObject *_self; |
| 260 | PyObject *_args; |
| 261 | { |
| 262 | PyObject *_res = NULL; |
| 263 | Str255 itemString; |
| 264 | short afterItem; |
| 265 | if (!PyArg_ParseTuple(_args, "O&h", |
| 266 | PyMac_GetStr255, itemString, |
| 267 | &afterItem)) |
| 268 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 269 | MacInsertMenuItem(_self->ob_itself, |
| 270 | itemString, |
| 271 | afterItem); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 272 | Py_INCREF(Py_None); |
| 273 | _res = Py_None; |
| 274 | return _res; |
| 275 | } |
| 276 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 277 | static PyObject *MenuObj_DeleteMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 278 | MenuObject *_self; |
| 279 | PyObject *_args; |
| 280 | { |
| 281 | PyObject *_res = NULL; |
| 282 | short item; |
| 283 | if (!PyArg_ParseTuple(_args, "h", |
| 284 | &item)) |
| 285 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 286 | DeleteMenuItem(_self->ob_itself, |
| 287 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 288 | Py_INCREF(Py_None); |
| 289 | _res = Py_None; |
| 290 | return _res; |
| 291 | } |
| 292 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 293 | static PyObject *MenuObj_InsertFontResMenu(_self, _args) |
| 294 | MenuObject *_self; |
| 295 | PyObject *_args; |
| 296 | { |
| 297 | PyObject *_res = NULL; |
| 298 | short afterItem; |
| 299 | short scriptFilter; |
| 300 | if (!PyArg_ParseTuple(_args, "hh", |
| 301 | &afterItem, |
| 302 | &scriptFilter)) |
| 303 | return NULL; |
| 304 | InsertFontResMenu(_self->ob_itself, |
| 305 | afterItem, |
| 306 | scriptFilter); |
| 307 | Py_INCREF(Py_None); |
| 308 | _res = Py_None; |
| 309 | return _res; |
| 310 | } |
| 311 | |
| 312 | static PyObject *MenuObj_InsertIntlResMenu(_self, _args) |
| 313 | MenuObject *_self; |
| 314 | PyObject *_args; |
| 315 | { |
| 316 | PyObject *_res = NULL; |
| 317 | ResType theType; |
| 318 | short afterItem; |
| 319 | short scriptFilter; |
| 320 | if (!PyArg_ParseTuple(_args, "O&hh", |
| 321 | PyMac_GetOSType, &theType, |
| 322 | &afterItem, |
| 323 | &scriptFilter)) |
| 324 | return NULL; |
| 325 | InsertIntlResMenu(_self->ob_itself, |
| 326 | theType, |
| 327 | afterItem, |
| 328 | scriptFilter); |
| 329 | Py_INCREF(Py_None); |
| 330 | _res = Py_None; |
| 331 | return _res; |
| 332 | } |
| 333 | |
| 334 | static PyObject *MenuObj_AppendMenuItemText(_self, _args) |
| 335 | MenuObject *_self; |
| 336 | PyObject *_args; |
| 337 | { |
| 338 | PyObject *_res = NULL; |
| 339 | OSStatus _err; |
| 340 | Str255 inString; |
| 341 | if (!PyArg_ParseTuple(_args, "O&", |
| 342 | PyMac_GetStr255, inString)) |
| 343 | return NULL; |
| 344 | _err = AppendMenuItemText(_self->ob_itself, |
| 345 | inString); |
| 346 | if (_err != noErr) return PyMac_Error(_err); |
| 347 | Py_INCREF(Py_None); |
| 348 | _res = Py_None; |
| 349 | return _res; |
| 350 | } |
| 351 | |
| 352 | static PyObject *MenuObj_InsertMenuItemText(_self, _args) |
| 353 | MenuObject *_self; |
| 354 | PyObject *_args; |
| 355 | { |
| 356 | PyObject *_res = NULL; |
| 357 | OSStatus _err; |
| 358 | Str255 inString; |
| 359 | UInt16 afterItem; |
| 360 | if (!PyArg_ParseTuple(_args, "O&h", |
| 361 | PyMac_GetStr255, inString, |
| 362 | &afterItem)) |
| 363 | return NULL; |
| 364 | _err = InsertMenuItemText(_self->ob_itself, |
| 365 | inString, |
| 366 | afterItem); |
| 367 | if (_err != noErr) return PyMac_Error(_err); |
| 368 | Py_INCREF(Py_None); |
| 369 | _res = Py_None; |
| 370 | return _res; |
| 371 | } |
| 372 | |
| 373 | static PyObject *MenuObj_PopUpMenuSelect(_self, _args) |
| 374 | MenuObject *_self; |
| 375 | PyObject *_args; |
| 376 | { |
| 377 | PyObject *_res = NULL; |
| 378 | long _rv; |
| 379 | short top; |
| 380 | short left; |
| 381 | short popUpItem; |
| 382 | if (!PyArg_ParseTuple(_args, "hhh", |
| 383 | &top, |
| 384 | &left, |
| 385 | &popUpItem)) |
| 386 | return NULL; |
| 387 | _rv = PopUpMenuSelect(_self->ob_itself, |
| 388 | top, |
| 389 | left, |
| 390 | popUpItem); |
| 391 | _res = Py_BuildValue("l", |
| 392 | _rv); |
| 393 | return _res; |
| 394 | } |
| 395 | |
| 396 | static PyObject *MenuObj_MacInsertMenu(_self, _args) |
| 397 | MenuObject *_self; |
| 398 | PyObject *_args; |
| 399 | { |
| 400 | PyObject *_res = NULL; |
| 401 | short beforeID; |
| 402 | if (!PyArg_ParseTuple(_args, "h", |
| 403 | &beforeID)) |
| 404 | return NULL; |
| 405 | MacInsertMenu(_self->ob_itself, |
| 406 | beforeID); |
| 407 | Py_INCREF(Py_None); |
| 408 | _res = Py_None; |
| 409 | return _res; |
| 410 | } |
| 411 | |
| 412 | static PyObject *MenuObj_CheckItem(_self, _args) |
| 413 | MenuObject *_self; |
| 414 | PyObject *_args; |
| 415 | { |
| 416 | PyObject *_res = NULL; |
| 417 | short item; |
| 418 | Boolean checked; |
| 419 | if (!PyArg_ParseTuple(_args, "hb", |
| 420 | &item, |
| 421 | &checked)) |
| 422 | return NULL; |
| 423 | CheckItem(_self->ob_itself, |
| 424 | item, |
| 425 | checked); |
| 426 | Py_INCREF(Py_None); |
| 427 | _res = Py_None; |
| 428 | return _res; |
| 429 | } |
| 430 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 431 | static PyObject *MenuObj_SetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 432 | MenuObject *_self; |
| 433 | PyObject *_args; |
| 434 | { |
| 435 | PyObject *_res = NULL; |
| 436 | short item; |
| 437 | Str255 itemString; |
| 438 | if (!PyArg_ParseTuple(_args, "hO&", |
| 439 | &item, |
| 440 | PyMac_GetStr255, itemString)) |
| 441 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 442 | SetMenuItemText(_self->ob_itself, |
| 443 | item, |
| 444 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 445 | Py_INCREF(Py_None); |
| 446 | _res = Py_None; |
| 447 | return _res; |
| 448 | } |
| 449 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 450 | static PyObject *MenuObj_GetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 451 | MenuObject *_self; |
| 452 | PyObject *_args; |
| 453 | { |
| 454 | PyObject *_res = NULL; |
| 455 | short item; |
| 456 | Str255 itemString; |
| 457 | if (!PyArg_ParseTuple(_args, "h", |
| 458 | &item)) |
| 459 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 460 | GetMenuItemText(_self->ob_itself, |
| 461 | item, |
| 462 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 463 | _res = Py_BuildValue("O&", |
| 464 | PyMac_BuildStr255, itemString); |
| 465 | return _res; |
| 466 | } |
| 467 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 468 | static PyObject *MenuObj_SetItemMark(_self, _args) |
| 469 | MenuObject *_self; |
| 470 | PyObject *_args; |
| 471 | { |
| 472 | PyObject *_res = NULL; |
| 473 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 474 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 475 | if (!PyArg_ParseTuple(_args, "hh", |
| 476 | &item, |
| 477 | &markChar)) |
| 478 | return NULL; |
| 479 | SetItemMark(_self->ob_itself, |
| 480 | item, |
| 481 | markChar); |
| 482 | Py_INCREF(Py_None); |
| 483 | _res = Py_None; |
| 484 | return _res; |
| 485 | } |
| 486 | |
| 487 | static PyObject *MenuObj_GetItemMark(_self, _args) |
| 488 | MenuObject *_self; |
| 489 | PyObject *_args; |
| 490 | { |
| 491 | PyObject *_res = NULL; |
| 492 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 493 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 494 | if (!PyArg_ParseTuple(_args, "h", |
| 495 | &item)) |
| 496 | return NULL; |
| 497 | GetItemMark(_self->ob_itself, |
| 498 | item, |
| 499 | &markChar); |
| 500 | _res = Py_BuildValue("h", |
| 501 | markChar); |
| 502 | return _res; |
| 503 | } |
| 504 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 505 | static PyObject *MenuObj_SetItemCmd(_self, _args) |
| 506 | MenuObject *_self; |
| 507 | PyObject *_args; |
| 508 | { |
| 509 | PyObject *_res = NULL; |
| 510 | short item; |
| 511 | CharParameter cmdChar; |
| 512 | if (!PyArg_ParseTuple(_args, "hh", |
| 513 | &item, |
| 514 | &cmdChar)) |
| 515 | return NULL; |
| 516 | SetItemCmd(_self->ob_itself, |
| 517 | item, |
| 518 | cmdChar); |
| 519 | Py_INCREF(Py_None); |
| 520 | _res = Py_None; |
| 521 | return _res; |
| 522 | } |
| 523 | |
| 524 | static PyObject *MenuObj_GetItemCmd(_self, _args) |
| 525 | MenuObject *_self; |
| 526 | PyObject *_args; |
| 527 | { |
| 528 | PyObject *_res = NULL; |
| 529 | short item; |
| 530 | CharParameter cmdChar; |
| 531 | if (!PyArg_ParseTuple(_args, "h", |
| 532 | &item)) |
| 533 | return NULL; |
| 534 | GetItemCmd(_self->ob_itself, |
| 535 | item, |
| 536 | &cmdChar); |
| 537 | _res = Py_BuildValue("h", |
| 538 | cmdChar); |
| 539 | return _res; |
| 540 | } |
| 541 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 542 | static PyObject *MenuObj_SetItemIcon(_self, _args) |
| 543 | MenuObject *_self; |
| 544 | PyObject *_args; |
| 545 | { |
| 546 | PyObject *_res = NULL; |
| 547 | short item; |
| 548 | short iconIndex; |
| 549 | if (!PyArg_ParseTuple(_args, "hh", |
| 550 | &item, |
| 551 | &iconIndex)) |
| 552 | return NULL; |
| 553 | SetItemIcon(_self->ob_itself, |
| 554 | item, |
| 555 | iconIndex); |
| 556 | Py_INCREF(Py_None); |
| 557 | _res = Py_None; |
| 558 | return _res; |
| 559 | } |
| 560 | |
| 561 | static PyObject *MenuObj_GetItemIcon(_self, _args) |
| 562 | MenuObject *_self; |
| 563 | PyObject *_args; |
| 564 | { |
| 565 | PyObject *_res = NULL; |
| 566 | short item; |
| 567 | short iconIndex; |
| 568 | if (!PyArg_ParseTuple(_args, "h", |
| 569 | &item)) |
| 570 | return NULL; |
| 571 | GetItemIcon(_self->ob_itself, |
| 572 | item, |
| 573 | &iconIndex); |
| 574 | _res = Py_BuildValue("h", |
| 575 | iconIndex); |
| 576 | return _res; |
| 577 | } |
| 578 | |
| 579 | static PyObject *MenuObj_SetItemStyle(_self, _args) |
| 580 | MenuObject *_self; |
| 581 | PyObject *_args; |
| 582 | { |
| 583 | PyObject *_res = NULL; |
| 584 | short item; |
Jack Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 585 | StyleParameter chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 586 | if (!PyArg_ParseTuple(_args, "hh", |
| 587 | &item, |
| 588 | &chStyle)) |
| 589 | return NULL; |
| 590 | SetItemStyle(_self->ob_itself, |
| 591 | item, |
| 592 | chStyle); |
| 593 | Py_INCREF(Py_None); |
| 594 | _res = Py_None; |
| 595 | return _res; |
| 596 | } |
| 597 | |
| 598 | static PyObject *MenuObj_GetItemStyle(_self, _args) |
| 599 | MenuObject *_self; |
| 600 | PyObject *_args; |
| 601 | { |
| 602 | PyObject *_res = NULL; |
| 603 | short item; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 604 | Style chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 605 | if (!PyArg_ParseTuple(_args, "h", |
| 606 | &item)) |
| 607 | return NULL; |
| 608 | GetItemStyle(_self->ob_itself, |
| 609 | item, |
| 610 | &chStyle); |
| 611 | _res = Py_BuildValue("b", |
| 612 | chStyle); |
| 613 | return _res; |
| 614 | } |
| 615 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 616 | static PyObject *MenuObj_DisableItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 617 | MenuObject *_self; |
| 618 | PyObject *_args; |
| 619 | { |
| 620 | PyObject *_res = NULL; |
| 621 | short item; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 622 | if (!PyArg_ParseTuple(_args, "h", |
| 623 | &item)) |
| 624 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 625 | DisableItem(_self->ob_itself, |
| 626 | item); |
| 627 | Py_INCREF(Py_None); |
| 628 | _res = Py_None; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 629 | return _res; |
| 630 | } |
| 631 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 632 | static PyObject *MenuObj_EnableItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 633 | MenuObject *_self; |
| 634 | PyObject *_args; |
| 635 | { |
| 636 | PyObject *_res = NULL; |
| 637 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 638 | if (!PyArg_ParseTuple(_args, "h", |
| 639 | &item)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 640 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 641 | EnableItem(_self->ob_itself, |
| 642 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 643 | Py_INCREF(Py_None); |
| 644 | _res = Py_None; |
| 645 | return _res; |
| 646 | } |
| 647 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 648 | static PyObject *MenuObj_SetMenuItemCommandID(_self, _args) |
| 649 | MenuObject *_self; |
| 650 | PyObject *_args; |
| 651 | { |
| 652 | PyObject *_res = NULL; |
| 653 | OSErr _err; |
| 654 | SInt16 inItem; |
| 655 | UInt32 inCommandID; |
| 656 | if (!PyArg_ParseTuple(_args, "hl", |
| 657 | &inItem, |
| 658 | &inCommandID)) |
| 659 | return NULL; |
| 660 | _err = SetMenuItemCommandID(_self->ob_itself, |
| 661 | inItem, |
| 662 | inCommandID); |
| 663 | if (_err != noErr) return PyMac_Error(_err); |
| 664 | Py_INCREF(Py_None); |
| 665 | _res = Py_None; |
| 666 | return _res; |
| 667 | } |
| 668 | |
| 669 | static PyObject *MenuObj_GetMenuItemCommandID(_self, _args) |
| 670 | MenuObject *_self; |
| 671 | PyObject *_args; |
| 672 | { |
| 673 | PyObject *_res = NULL; |
| 674 | OSErr _err; |
| 675 | SInt16 inItem; |
| 676 | UInt32 outCommandID; |
| 677 | if (!PyArg_ParseTuple(_args, "h", |
| 678 | &inItem)) |
| 679 | return NULL; |
| 680 | _err = GetMenuItemCommandID(_self->ob_itself, |
| 681 | inItem, |
| 682 | &outCommandID); |
| 683 | if (_err != noErr) return PyMac_Error(_err); |
| 684 | _res = Py_BuildValue("l", |
| 685 | outCommandID); |
| 686 | return _res; |
| 687 | } |
| 688 | |
| 689 | static PyObject *MenuObj_SetMenuItemModifiers(_self, _args) |
| 690 | MenuObject *_self; |
| 691 | PyObject *_args; |
| 692 | { |
| 693 | PyObject *_res = NULL; |
| 694 | OSErr _err; |
| 695 | SInt16 inItem; |
| 696 | UInt8 inModifiers; |
| 697 | if (!PyArg_ParseTuple(_args, "hb", |
| 698 | &inItem, |
| 699 | &inModifiers)) |
| 700 | return NULL; |
| 701 | _err = SetMenuItemModifiers(_self->ob_itself, |
| 702 | inItem, |
| 703 | inModifiers); |
| 704 | if (_err != noErr) return PyMac_Error(_err); |
| 705 | Py_INCREF(Py_None); |
| 706 | _res = Py_None; |
| 707 | return _res; |
| 708 | } |
| 709 | |
| 710 | static PyObject *MenuObj_GetMenuItemModifiers(_self, _args) |
| 711 | MenuObject *_self; |
| 712 | PyObject *_args; |
| 713 | { |
| 714 | PyObject *_res = NULL; |
| 715 | OSErr _err; |
| 716 | SInt16 inItem; |
| 717 | UInt8 outModifiers; |
| 718 | if (!PyArg_ParseTuple(_args, "h", |
| 719 | &inItem)) |
| 720 | return NULL; |
| 721 | _err = GetMenuItemModifiers(_self->ob_itself, |
| 722 | inItem, |
| 723 | &outModifiers); |
| 724 | if (_err != noErr) return PyMac_Error(_err); |
| 725 | _res = Py_BuildValue("b", |
| 726 | outModifiers); |
| 727 | return _res; |
| 728 | } |
| 729 | |
| 730 | static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args) |
| 731 | MenuObject *_self; |
| 732 | PyObject *_args; |
| 733 | { |
| 734 | PyObject *_res = NULL; |
| 735 | OSErr _err; |
| 736 | SInt16 inItem; |
| 737 | UInt8 inIconType; |
| 738 | Handle inIconHandle; |
| 739 | if (!PyArg_ParseTuple(_args, "hbO&", |
| 740 | &inItem, |
| 741 | &inIconType, |
| 742 | ResObj_Convert, &inIconHandle)) |
| 743 | return NULL; |
| 744 | _err = SetMenuItemIconHandle(_self->ob_itself, |
| 745 | inItem, |
| 746 | inIconType, |
| 747 | inIconHandle); |
| 748 | if (_err != noErr) return PyMac_Error(_err); |
| 749 | Py_INCREF(Py_None); |
| 750 | _res = Py_None; |
| 751 | return _res; |
| 752 | } |
| 753 | |
| 754 | static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args) |
| 755 | MenuObject *_self; |
| 756 | PyObject *_args; |
| 757 | { |
| 758 | PyObject *_res = NULL; |
| 759 | OSErr _err; |
| 760 | SInt16 inItem; |
| 761 | UInt8 outIconType; |
| 762 | Handle outIconHandle; |
| 763 | if (!PyArg_ParseTuple(_args, "h", |
| 764 | &inItem)) |
| 765 | return NULL; |
| 766 | _err = GetMenuItemIconHandle(_self->ob_itself, |
| 767 | inItem, |
| 768 | &outIconType, |
| 769 | &outIconHandle); |
| 770 | if (_err != noErr) return PyMac_Error(_err); |
| 771 | _res = Py_BuildValue("bO&", |
| 772 | outIconType, |
| 773 | ResObj_New, outIconHandle); |
| 774 | return _res; |
| 775 | } |
| 776 | |
| 777 | static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args) |
| 778 | MenuObject *_self; |
| 779 | PyObject *_args; |
| 780 | { |
| 781 | PyObject *_res = NULL; |
| 782 | OSErr _err; |
| 783 | SInt16 inItem; |
| 784 | TextEncoding inScriptID; |
| 785 | if (!PyArg_ParseTuple(_args, "hl", |
| 786 | &inItem, |
| 787 | &inScriptID)) |
| 788 | return NULL; |
| 789 | _err = SetMenuItemTextEncoding(_self->ob_itself, |
| 790 | inItem, |
| 791 | inScriptID); |
| 792 | if (_err != noErr) return PyMac_Error(_err); |
| 793 | Py_INCREF(Py_None); |
| 794 | _res = Py_None; |
| 795 | return _res; |
| 796 | } |
| 797 | |
| 798 | static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args) |
| 799 | MenuObject *_self; |
| 800 | PyObject *_args; |
| 801 | { |
| 802 | PyObject *_res = NULL; |
| 803 | OSErr _err; |
| 804 | SInt16 inItem; |
| 805 | TextEncoding outScriptID; |
| 806 | if (!PyArg_ParseTuple(_args, "h", |
| 807 | &inItem)) |
| 808 | return NULL; |
| 809 | _err = GetMenuItemTextEncoding(_self->ob_itself, |
| 810 | inItem, |
| 811 | &outScriptID); |
| 812 | if (_err != noErr) return PyMac_Error(_err); |
| 813 | _res = Py_BuildValue("l", |
| 814 | outScriptID); |
| 815 | return _res; |
| 816 | } |
| 817 | |
| 818 | static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args) |
| 819 | MenuObject *_self; |
| 820 | PyObject *_args; |
| 821 | { |
| 822 | PyObject *_res = NULL; |
| 823 | OSErr _err; |
| 824 | SInt16 inItem; |
| 825 | SInt16 inHierID; |
| 826 | if (!PyArg_ParseTuple(_args, "hh", |
| 827 | &inItem, |
| 828 | &inHierID)) |
| 829 | return NULL; |
| 830 | _err = SetMenuItemHierarchicalID(_self->ob_itself, |
| 831 | inItem, |
| 832 | inHierID); |
| 833 | if (_err != noErr) return PyMac_Error(_err); |
| 834 | Py_INCREF(Py_None); |
| 835 | _res = Py_None; |
| 836 | return _res; |
| 837 | } |
| 838 | |
| 839 | static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args) |
| 840 | MenuObject *_self; |
| 841 | PyObject *_args; |
| 842 | { |
| 843 | PyObject *_res = NULL; |
| 844 | OSErr _err; |
| 845 | SInt16 inItem; |
| 846 | SInt16 outHierID; |
| 847 | if (!PyArg_ParseTuple(_args, "h", |
| 848 | &inItem)) |
| 849 | return NULL; |
| 850 | _err = GetMenuItemHierarchicalID(_self->ob_itself, |
| 851 | inItem, |
| 852 | &outHierID); |
| 853 | if (_err != noErr) return PyMac_Error(_err); |
| 854 | _res = Py_BuildValue("h", |
| 855 | outHierID); |
| 856 | return _res; |
| 857 | } |
| 858 | |
| 859 | static PyObject *MenuObj_SetMenuItemFontID(_self, _args) |
| 860 | MenuObject *_self; |
| 861 | PyObject *_args; |
| 862 | { |
| 863 | PyObject *_res = NULL; |
| 864 | OSErr _err; |
| 865 | SInt16 inItem; |
| 866 | SInt16 inFontID; |
| 867 | if (!PyArg_ParseTuple(_args, "hh", |
| 868 | &inItem, |
| 869 | &inFontID)) |
| 870 | return NULL; |
| 871 | _err = SetMenuItemFontID(_self->ob_itself, |
| 872 | inItem, |
| 873 | inFontID); |
| 874 | if (_err != noErr) return PyMac_Error(_err); |
| 875 | Py_INCREF(Py_None); |
| 876 | _res = Py_None; |
| 877 | return _res; |
| 878 | } |
| 879 | |
| 880 | static PyObject *MenuObj_GetMenuItemFontID(_self, _args) |
| 881 | MenuObject *_self; |
| 882 | PyObject *_args; |
| 883 | { |
| 884 | PyObject *_res = NULL; |
| 885 | OSErr _err; |
| 886 | SInt16 inItem; |
| 887 | SInt16 outFontID; |
| 888 | if (!PyArg_ParseTuple(_args, "h", |
| 889 | &inItem)) |
| 890 | return NULL; |
| 891 | _err = GetMenuItemFontID(_self->ob_itself, |
| 892 | inItem, |
| 893 | &outFontID); |
| 894 | if (_err != noErr) return PyMac_Error(_err); |
| 895 | _res = Py_BuildValue("h", |
| 896 | outFontID); |
| 897 | return _res; |
| 898 | } |
| 899 | |
| 900 | static PyObject *MenuObj_SetMenuItemRefCon(_self, _args) |
| 901 | MenuObject *_self; |
| 902 | PyObject *_args; |
| 903 | { |
| 904 | PyObject *_res = NULL; |
| 905 | OSErr _err; |
| 906 | SInt16 inItem; |
| 907 | UInt32 inRefCon; |
| 908 | if (!PyArg_ParseTuple(_args, "hl", |
| 909 | &inItem, |
| 910 | &inRefCon)) |
| 911 | return NULL; |
| 912 | _err = SetMenuItemRefCon(_self->ob_itself, |
| 913 | inItem, |
| 914 | inRefCon); |
| 915 | if (_err != noErr) return PyMac_Error(_err); |
| 916 | Py_INCREF(Py_None); |
| 917 | _res = Py_None; |
| 918 | return _res; |
| 919 | } |
| 920 | |
| 921 | static PyObject *MenuObj_GetMenuItemRefCon(_self, _args) |
| 922 | MenuObject *_self; |
| 923 | PyObject *_args; |
| 924 | { |
| 925 | PyObject *_res = NULL; |
| 926 | OSErr _err; |
| 927 | SInt16 inItem; |
| 928 | UInt32 outRefCon; |
| 929 | if (!PyArg_ParseTuple(_args, "h", |
| 930 | &inItem)) |
| 931 | return NULL; |
| 932 | _err = GetMenuItemRefCon(_self->ob_itself, |
| 933 | inItem, |
| 934 | &outRefCon); |
| 935 | if (_err != noErr) return PyMac_Error(_err); |
| 936 | _res = Py_BuildValue("l", |
| 937 | outRefCon); |
| 938 | return _res; |
| 939 | } |
| 940 | |
| 941 | static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args) |
| 942 | MenuObject *_self; |
| 943 | PyObject *_args; |
| 944 | { |
| 945 | PyObject *_res = NULL; |
| 946 | OSErr _err; |
| 947 | SInt16 inItem; |
| 948 | UInt32 inRefCon2; |
| 949 | if (!PyArg_ParseTuple(_args, "hl", |
| 950 | &inItem, |
| 951 | &inRefCon2)) |
| 952 | return NULL; |
| 953 | _err = SetMenuItemRefCon2(_self->ob_itself, |
| 954 | inItem, |
| 955 | inRefCon2); |
| 956 | if (_err != noErr) return PyMac_Error(_err); |
| 957 | Py_INCREF(Py_None); |
| 958 | _res = Py_None; |
| 959 | return _res; |
| 960 | } |
| 961 | |
| 962 | static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args) |
| 963 | MenuObject *_self; |
| 964 | PyObject *_args; |
| 965 | { |
| 966 | PyObject *_res = NULL; |
| 967 | OSErr _err; |
| 968 | SInt16 inItem; |
| 969 | UInt32 outRefCon2; |
| 970 | if (!PyArg_ParseTuple(_args, "h", |
| 971 | &inItem)) |
| 972 | return NULL; |
| 973 | _err = GetMenuItemRefCon2(_self->ob_itself, |
| 974 | inItem, |
| 975 | &outRefCon2); |
| 976 | if (_err != noErr) return PyMac_Error(_err); |
| 977 | _res = Py_BuildValue("l", |
| 978 | outRefCon2); |
| 979 | return _res; |
| 980 | } |
| 981 | |
| 982 | static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args) |
| 983 | MenuObject *_self; |
| 984 | PyObject *_args; |
| 985 | { |
| 986 | PyObject *_res = NULL; |
| 987 | OSErr _err; |
| 988 | SInt16 inItem; |
| 989 | SInt16 inGlyph; |
| 990 | if (!PyArg_ParseTuple(_args, "hh", |
| 991 | &inItem, |
| 992 | &inGlyph)) |
| 993 | return NULL; |
| 994 | _err = SetMenuItemKeyGlyph(_self->ob_itself, |
| 995 | inItem, |
| 996 | inGlyph); |
| 997 | if (_err != noErr) return PyMac_Error(_err); |
| 998 | Py_INCREF(Py_None); |
| 999 | _res = Py_None; |
| 1000 | return _res; |
| 1001 | } |
| 1002 | |
| 1003 | static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args) |
| 1004 | MenuObject *_self; |
| 1005 | PyObject *_args; |
| 1006 | { |
| 1007 | PyObject *_res = NULL; |
| 1008 | OSErr _err; |
| 1009 | SInt16 inItem; |
| 1010 | SInt16 outGlyph; |
| 1011 | if (!PyArg_ParseTuple(_args, "h", |
| 1012 | &inItem)) |
| 1013 | return NULL; |
| 1014 | _err = GetMenuItemKeyGlyph(_self->ob_itself, |
| 1015 | inItem, |
| 1016 | &outGlyph); |
| 1017 | if (_err != noErr) return PyMac_Error(_err); |
| 1018 | _res = Py_BuildValue("h", |
| 1019 | outGlyph); |
| 1020 | return _res; |
| 1021 | } |
| 1022 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1023 | static PyObject *MenuObj_MacEnableMenuItem(_self, _args) |
| 1024 | MenuObject *_self; |
| 1025 | PyObject *_args; |
| 1026 | { |
| 1027 | PyObject *_res = NULL; |
| 1028 | UInt16 item; |
| 1029 | if (!PyArg_ParseTuple(_args, "h", |
| 1030 | &item)) |
| 1031 | return NULL; |
| 1032 | MacEnableMenuItem(_self->ob_itself, |
| 1033 | item); |
| 1034 | Py_INCREF(Py_None); |
| 1035 | _res = Py_None; |
| 1036 | return _res; |
| 1037 | } |
| 1038 | |
| 1039 | static PyObject *MenuObj_DisableMenuItem(_self, _args) |
| 1040 | MenuObject *_self; |
| 1041 | PyObject *_args; |
| 1042 | { |
| 1043 | PyObject *_res = NULL; |
| 1044 | UInt16 item; |
| 1045 | if (!PyArg_ParseTuple(_args, "h", |
| 1046 | &item)) |
| 1047 | return NULL; |
| 1048 | DisableMenuItem(_self->ob_itself, |
| 1049 | item); |
| 1050 | Py_INCREF(Py_None); |
| 1051 | _res = Py_None; |
| 1052 | return _res; |
| 1053 | } |
| 1054 | |
| 1055 | static PyObject *MenuObj_IsMenuItemEnabled(_self, _args) |
| 1056 | MenuObject *_self; |
| 1057 | PyObject *_args; |
| 1058 | { |
| 1059 | PyObject *_res = NULL; |
| 1060 | Boolean _rv; |
| 1061 | UInt16 item; |
| 1062 | if (!PyArg_ParseTuple(_args, "h", |
| 1063 | &item)) |
| 1064 | return NULL; |
| 1065 | _rv = IsMenuItemEnabled(_self->ob_itself, |
| 1066 | item); |
| 1067 | _res = Py_BuildValue("b", |
| 1068 | _rv); |
| 1069 | return _res; |
| 1070 | } |
| 1071 | |
| 1072 | static PyObject *MenuObj_EnableMenuItemIcon(_self, _args) |
| 1073 | MenuObject *_self; |
| 1074 | PyObject *_args; |
| 1075 | { |
| 1076 | PyObject *_res = NULL; |
| 1077 | UInt16 item; |
| 1078 | if (!PyArg_ParseTuple(_args, "h", |
| 1079 | &item)) |
| 1080 | return NULL; |
| 1081 | EnableMenuItemIcon(_self->ob_itself, |
| 1082 | item); |
| 1083 | Py_INCREF(Py_None); |
| 1084 | _res = Py_None; |
| 1085 | return _res; |
| 1086 | } |
| 1087 | |
| 1088 | static PyObject *MenuObj_DisableMenuItemIcon(_self, _args) |
| 1089 | MenuObject *_self; |
| 1090 | PyObject *_args; |
| 1091 | { |
| 1092 | PyObject *_res = NULL; |
| 1093 | UInt16 item; |
| 1094 | if (!PyArg_ParseTuple(_args, "h", |
| 1095 | &item)) |
| 1096 | return NULL; |
| 1097 | DisableMenuItemIcon(_self->ob_itself, |
| 1098 | item); |
| 1099 | Py_INCREF(Py_None); |
| 1100 | _res = Py_None; |
| 1101 | return _res; |
| 1102 | } |
| 1103 | |
| 1104 | static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args) |
| 1105 | MenuObject *_self; |
| 1106 | PyObject *_args; |
| 1107 | { |
| 1108 | PyObject *_res = NULL; |
| 1109 | Boolean _rv; |
| 1110 | UInt16 item; |
| 1111 | if (!PyArg_ParseTuple(_args, "h", |
| 1112 | &item)) |
| 1113 | return NULL; |
| 1114 | _rv = IsMenuItemIconEnabled(_self->ob_itself, |
| 1115 | item); |
| 1116 | _res = Py_BuildValue("b", |
| 1117 | _rv); |
| 1118 | return _res; |
| 1119 | } |
| 1120 | |
Jack Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1121 | static PyObject *MenuObj_as_Resource(_self, _args) |
| 1122 | MenuObject *_self; |
| 1123 | PyObject *_args; |
| 1124 | { |
| 1125 | PyObject *_res = NULL; |
| 1126 | |
| 1127 | return ResObj_New((Handle)_self->ob_itself); |
| 1128 | |
| 1129 | } |
| 1130 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1131 | static PyObject *MenuObj_AppendMenu(_self, _args) |
| 1132 | MenuObject *_self; |
| 1133 | PyObject *_args; |
| 1134 | { |
| 1135 | PyObject *_res = NULL; |
| 1136 | Str255 data; |
| 1137 | if (!PyArg_ParseTuple(_args, "O&", |
| 1138 | PyMac_GetStr255, data)) |
| 1139 | return NULL; |
| 1140 | AppendMenu(_self->ob_itself, |
| 1141 | data); |
| 1142 | Py_INCREF(Py_None); |
| 1143 | _res = Py_None; |
| 1144 | return _res; |
| 1145 | } |
| 1146 | |
| 1147 | static PyObject *MenuObj_InsertMenu(_self, _args) |
| 1148 | MenuObject *_self; |
| 1149 | PyObject *_args; |
| 1150 | { |
| 1151 | PyObject *_res = NULL; |
| 1152 | short beforeID; |
| 1153 | if (!PyArg_ParseTuple(_args, "h", |
| 1154 | &beforeID)) |
| 1155 | return NULL; |
| 1156 | InsertMenu(_self->ob_itself, |
| 1157 | beforeID); |
| 1158 | Py_INCREF(Py_None); |
| 1159 | _res = Py_None; |
| 1160 | return _res; |
| 1161 | } |
| 1162 | |
| 1163 | static PyObject *MenuObj_InsertMenuItem(_self, _args) |
| 1164 | MenuObject *_self; |
| 1165 | PyObject *_args; |
| 1166 | { |
| 1167 | PyObject *_res = NULL; |
| 1168 | Str255 itemString; |
| 1169 | short afterItem; |
| 1170 | if (!PyArg_ParseTuple(_args, "O&h", |
| 1171 | PyMac_GetStr255, itemString, |
| 1172 | &afterItem)) |
| 1173 | return NULL; |
| 1174 | InsertMenuItem(_self->ob_itself, |
| 1175 | itemString, |
| 1176 | afterItem); |
| 1177 | Py_INCREF(Py_None); |
| 1178 | _res = Py_None; |
| 1179 | return _res; |
| 1180 | } |
| 1181 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1182 | static PyMethodDef MenuObj_methods[] = { |
| 1183 | {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1, |
| 1184 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1185 | {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, |
| 1186 | "() -> None"}, |
| 1187 | {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, |
| 1188 | "() -> (short _rv)"}, |
| 1189 | {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1, |
| 1190 | "() -> (SInt16 outFontID, UInt16 outFontSize)"}, |
| 1191 | {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1, |
| 1192 | "(SInt16 inFontID, UInt16 inFontSize) -> None"}, |
| 1193 | {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1, |
| 1194 | "() -> (Boolean _rv)"}, |
| 1195 | {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1, |
| 1196 | "(Boolean excludesMark) -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1197 | {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1198 | "(Str255 data) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1199 | {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1, |
| 1200 | "(ResType theType, short afterItem) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1201 | {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1, |
| 1202 | "(ResType theType) -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1203 | {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1204 | "(Str255 itemString, short afterItem) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1205 | {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1206 | "(short item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1207 | {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1, |
| 1208 | "(short afterItem, short scriptFilter) -> None"}, |
| 1209 | {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1, |
| 1210 | "(ResType theType, short afterItem, short scriptFilter) -> None"}, |
| 1211 | {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1, |
| 1212 | "(Str255 inString) -> None"}, |
| 1213 | {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1, |
| 1214 | "(Str255 inString, UInt16 afterItem) -> None"}, |
| 1215 | {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1, |
| 1216 | "(short top, short left, short popUpItem) -> (long _rv)"}, |
| 1217 | {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1, |
| 1218 | "(short beforeID) -> None"}, |
| 1219 | {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, |
| 1220 | "(short item, Boolean checked) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1221 | {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1222 | "(short item, Str255 itemString) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1223 | {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1224 | "(short item) -> (Str255 itemString)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1225 | {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1226 | "(short item, CharParameter markChar) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1227 | {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1228 | "(short item) -> (CharParameter markChar)"}, |
| 1229 | {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1, |
| 1230 | "(short item, CharParameter cmdChar) -> None"}, |
| 1231 | {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1, |
| 1232 | "(short item) -> (CharParameter cmdChar)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1233 | {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1, |
| 1234 | "(short item, short iconIndex) -> None"}, |
| 1235 | {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1, |
| 1236 | "(short item) -> (short iconIndex)"}, |
| 1237 | {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1, |
Jack Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 1238 | "(short item, StyleParameter chStyle) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1239 | {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1240 | "(short item) -> (Style chStyle)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1241 | {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1, |
| 1242 | "(short item) -> None"}, |
| 1243 | {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1, |
| 1244 | "(short item) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1245 | {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1, |
| 1246 | "(SInt16 inItem, UInt32 inCommandID) -> None"}, |
| 1247 | {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1, |
| 1248 | "(SInt16 inItem) -> (UInt32 outCommandID)"}, |
| 1249 | {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1, |
| 1250 | "(SInt16 inItem, UInt8 inModifiers) -> None"}, |
| 1251 | {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1, |
| 1252 | "(SInt16 inItem) -> (UInt8 outModifiers)"}, |
| 1253 | {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1, |
| 1254 | "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"}, |
| 1255 | {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1, |
| 1256 | "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"}, |
| 1257 | {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1, |
| 1258 | "(SInt16 inItem, TextEncoding inScriptID) -> None"}, |
| 1259 | {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1, |
| 1260 | "(SInt16 inItem) -> (TextEncoding outScriptID)"}, |
| 1261 | {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1, |
| 1262 | "(SInt16 inItem, SInt16 inHierID) -> None"}, |
| 1263 | {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1, |
| 1264 | "(SInt16 inItem) -> (SInt16 outHierID)"}, |
| 1265 | {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1, |
| 1266 | "(SInt16 inItem, SInt16 inFontID) -> None"}, |
| 1267 | {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1, |
| 1268 | "(SInt16 inItem) -> (SInt16 outFontID)"}, |
| 1269 | {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1, |
| 1270 | "(SInt16 inItem, UInt32 inRefCon) -> None"}, |
| 1271 | {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1, |
| 1272 | "(SInt16 inItem) -> (UInt32 outRefCon)"}, |
| 1273 | {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1, |
| 1274 | "(SInt16 inItem, UInt32 inRefCon2) -> None"}, |
| 1275 | {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1, |
| 1276 | "(SInt16 inItem) -> (UInt32 outRefCon2)"}, |
| 1277 | {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1, |
| 1278 | "(SInt16 inItem, SInt16 inGlyph) -> None"}, |
| 1279 | {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1, |
| 1280 | "(SInt16 inItem) -> (SInt16 outGlyph)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1281 | {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1, |
| 1282 | "(UInt16 item) -> None"}, |
| 1283 | {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1, |
| 1284 | "(UInt16 item) -> None"}, |
| 1285 | {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1, |
| 1286 | "(UInt16 item) -> (Boolean _rv)"}, |
| 1287 | {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1, |
| 1288 | "(UInt16 item) -> None"}, |
| 1289 | {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1, |
| 1290 | "(UInt16 item) -> None"}, |
| 1291 | {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1, |
| 1292 | "(UInt16 item) -> (Boolean _rv)"}, |
Jack Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1293 | {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1, |
| 1294 | "Return this Menu as a Resource"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1295 | {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1, |
| 1296 | "(Str255 data) -> None"}, |
| 1297 | {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1, |
| 1298 | "(short beforeID) -> None"}, |
| 1299 | {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1, |
| 1300 | "(Str255 itemString, short afterItem) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1301 | {NULL, NULL, 0} |
| 1302 | }; |
| 1303 | |
| 1304 | PyMethodChain MenuObj_chain = { MenuObj_methods, NULL }; |
| 1305 | |
| 1306 | static PyObject *MenuObj_getattr(self, name) |
| 1307 | MenuObject *self; |
| 1308 | char *name; |
| 1309 | { |
| 1310 | return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name); |
| 1311 | } |
| 1312 | |
| 1313 | #define MenuObj_setattr NULL |
| 1314 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1315 | #define MenuObj_compare NULL |
| 1316 | |
| 1317 | #define MenuObj_repr NULL |
| 1318 | |
| 1319 | #define MenuObj_hash NULL |
| 1320 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1321 | PyTypeObject Menu_Type = { |
| 1322 | PyObject_HEAD_INIT(&PyType_Type) |
| 1323 | 0, /*ob_size*/ |
| 1324 | "Menu", /*tp_name*/ |
| 1325 | sizeof(MenuObject), /*tp_basicsize*/ |
| 1326 | 0, /*tp_itemsize*/ |
| 1327 | /* methods */ |
| 1328 | (destructor) MenuObj_dealloc, /*tp_dealloc*/ |
| 1329 | 0, /*tp_print*/ |
| 1330 | (getattrfunc) MenuObj_getattr, /*tp_getattr*/ |
| 1331 | (setattrfunc) MenuObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1332 | (cmpfunc) MenuObj_compare, /*tp_compare*/ |
| 1333 | (reprfunc) MenuObj_repr, /*tp_repr*/ |
| 1334 | (PyNumberMethods *)0, /* tp_as_number */ |
| 1335 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 1336 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 1337 | (hashfunc) MenuObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1338 | }; |
| 1339 | |
| 1340 | /* ---------------------- End object type Menu ---------------------- */ |
| 1341 | |
| 1342 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1343 | static PyObject *Menu_InitProcMenu(_self, _args) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1344 | PyObject *_self; |
| 1345 | PyObject *_args; |
| 1346 | { |
| 1347 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1348 | short resID; |
| 1349 | if (!PyArg_ParseTuple(_args, "h", |
| 1350 | &resID)) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1351 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1352 | InitProcMenu(resID); |
| 1353 | Py_INCREF(Py_None); |
| 1354 | _res = Py_None; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1355 | return _res; |
| 1356 | } |
| 1357 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1358 | static PyObject *Menu_InitMenus(_self, _args) |
| 1359 | PyObject *_self; |
| 1360 | PyObject *_args; |
| 1361 | { |
| 1362 | PyObject *_res = NULL; |
| 1363 | if (!PyArg_ParseTuple(_args, "")) |
| 1364 | return NULL; |
| 1365 | InitMenus(); |
| 1366 | Py_INCREF(Py_None); |
| 1367 | _res = Py_None; |
| 1368 | return _res; |
| 1369 | } |
| 1370 | |
| 1371 | static PyObject *Menu_NewMenu(_self, _args) |
| 1372 | PyObject *_self; |
| 1373 | PyObject *_args; |
| 1374 | { |
| 1375 | PyObject *_res = NULL; |
| 1376 | MenuHandle _rv; |
| 1377 | short menuID; |
| 1378 | Str255 menuTitle; |
| 1379 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1380 | &menuID, |
| 1381 | PyMac_GetStr255, menuTitle)) |
| 1382 | return NULL; |
| 1383 | _rv = NewMenu(menuID, |
| 1384 | menuTitle); |
| 1385 | _res = Py_BuildValue("O&", |
| 1386 | MenuObj_New, _rv); |
| 1387 | return _res; |
| 1388 | } |
| 1389 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1390 | static PyObject *Menu_MacGetMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1391 | PyObject *_self; |
| 1392 | PyObject *_args; |
| 1393 | { |
| 1394 | PyObject *_res = NULL; |
| 1395 | MenuHandle _rv; |
| 1396 | short resourceID; |
| 1397 | if (!PyArg_ParseTuple(_args, "h", |
| 1398 | &resourceID)) |
| 1399 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1400 | _rv = MacGetMenu(resourceID); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1401 | _res = Py_BuildValue("O&", |
| 1402 | MenuObj_New, _rv); |
| 1403 | return _res; |
| 1404 | } |
| 1405 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1406 | static PyObject *Menu_MenuKey(_self, _args) |
| 1407 | PyObject *_self; |
| 1408 | PyObject *_args; |
| 1409 | { |
| 1410 | PyObject *_res = NULL; |
| 1411 | long _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1412 | CharParameter ch; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1413 | if (!PyArg_ParseTuple(_args, "h", |
| 1414 | &ch)) |
| 1415 | return NULL; |
| 1416 | _rv = MenuKey(ch); |
| 1417 | _res = Py_BuildValue("l", |
| 1418 | _rv); |
| 1419 | return _res; |
| 1420 | } |
| 1421 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1422 | static PyObject *Menu_MenuSelect(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1423 | PyObject *_self; |
| 1424 | PyObject *_args; |
| 1425 | { |
| 1426 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1427 | long _rv; |
| 1428 | Point startPt; |
| 1429 | if (!PyArg_ParseTuple(_args, "O&", |
| 1430 | PyMac_GetPoint, &startPt)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1431 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1432 | _rv = MenuSelect(startPt); |
| 1433 | _res = Py_BuildValue("l", |
| 1434 | _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1435 | return _res; |
| 1436 | } |
| 1437 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1438 | static PyObject *Menu_MenuChoice(_self, _args) |
| 1439 | PyObject *_self; |
| 1440 | PyObject *_args; |
| 1441 | { |
| 1442 | PyObject *_res = NULL; |
| 1443 | long _rv; |
| 1444 | if (!PyArg_ParseTuple(_args, "")) |
| 1445 | return NULL; |
| 1446 | _rv = MenuChoice(); |
| 1447 | _res = Py_BuildValue("l", |
| 1448 | _rv); |
| 1449 | return _res; |
| 1450 | } |
| 1451 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1452 | static PyObject *Menu_MenuEvent(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1453 | PyObject *_self; |
| 1454 | PyObject *_args; |
| 1455 | { |
| 1456 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1457 | UInt32 _rv; |
| 1458 | EventRecord inEvent; |
| 1459 | if (!PyArg_ParseTuple(_args, "O&", |
| 1460 | PyMac_GetEventRecord, &inEvent)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1461 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1462 | _rv = MenuEvent(&inEvent); |
| 1463 | _res = Py_BuildValue("l", |
| 1464 | _rv); |
| 1465 | return _res; |
| 1466 | } |
| 1467 | |
| 1468 | static PyObject *Menu_GetMBarHeight(_self, _args) |
| 1469 | PyObject *_self; |
| 1470 | PyObject *_args; |
| 1471 | { |
| 1472 | PyObject *_res = NULL; |
| 1473 | short _rv; |
| 1474 | if (!PyArg_ParseTuple(_args, "")) |
| 1475 | return NULL; |
| 1476 | _rv = GetMBarHeight(); |
| 1477 | _res = Py_BuildValue("h", |
| 1478 | _rv); |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1479 | return _res; |
| 1480 | } |
| 1481 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1482 | static PyObject *Menu_MacDrawMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1483 | PyObject *_self; |
| 1484 | PyObject *_args; |
| 1485 | { |
| 1486 | PyObject *_res = NULL; |
| 1487 | if (!PyArg_ParseTuple(_args, "")) |
| 1488 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1489 | MacDrawMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1490 | Py_INCREF(Py_None); |
| 1491 | _res = Py_None; |
| 1492 | return _res; |
| 1493 | } |
| 1494 | |
| 1495 | static PyObject *Menu_InvalMenuBar(_self, _args) |
| 1496 | PyObject *_self; |
| 1497 | PyObject *_args; |
| 1498 | { |
| 1499 | PyObject *_res = NULL; |
| 1500 | if (!PyArg_ParseTuple(_args, "")) |
| 1501 | return NULL; |
| 1502 | InvalMenuBar(); |
| 1503 | Py_INCREF(Py_None); |
| 1504 | _res = Py_None; |
| 1505 | return _res; |
| 1506 | } |
| 1507 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1508 | static PyObject *Menu_HiliteMenu(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1509 | PyObject *_self; |
| 1510 | PyObject *_args; |
| 1511 | { |
| 1512 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1513 | short menuID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1514 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1515 | &menuID)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1516 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1517 | HiliteMenu(menuID); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1518 | Py_INCREF(Py_None); |
| 1519 | _res = Py_None; |
| 1520 | return _res; |
| 1521 | } |
| 1522 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1523 | static PyObject *Menu_GetNewMBar(_self, _args) |
| 1524 | PyObject *_self; |
| 1525 | PyObject *_args; |
| 1526 | { |
| 1527 | PyObject *_res = NULL; |
| 1528 | Handle _rv; |
| 1529 | short menuBarID; |
| 1530 | if (!PyArg_ParseTuple(_args, "h", |
| 1531 | &menuBarID)) |
| 1532 | return NULL; |
| 1533 | _rv = GetNewMBar(menuBarID); |
| 1534 | _res = Py_BuildValue("O&", |
| 1535 | ResObj_New, _rv); |
| 1536 | return _res; |
| 1537 | } |
| 1538 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1539 | static PyObject *Menu_GetMenuBar(_self, _args) |
| 1540 | PyObject *_self; |
| 1541 | PyObject *_args; |
| 1542 | { |
| 1543 | PyObject *_res = NULL; |
| 1544 | Handle _rv; |
| 1545 | if (!PyArg_ParseTuple(_args, "")) |
| 1546 | return NULL; |
| 1547 | _rv = GetMenuBar(); |
| 1548 | _res = Py_BuildValue("O&", |
| 1549 | ResObj_New, _rv); |
| 1550 | return _res; |
| 1551 | } |
| 1552 | |
| 1553 | static PyObject *Menu_SetMenuBar(_self, _args) |
| 1554 | PyObject *_self; |
| 1555 | PyObject *_args; |
| 1556 | { |
| 1557 | PyObject *_res = NULL; |
| 1558 | Handle menuList; |
| 1559 | if (!PyArg_ParseTuple(_args, "O&", |
| 1560 | ResObj_Convert, &menuList)) |
| 1561 | return NULL; |
| 1562 | SetMenuBar(menuList); |
| 1563 | Py_INCREF(Py_None); |
| 1564 | _res = Py_None; |
| 1565 | return _res; |
| 1566 | } |
| 1567 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1568 | static PyObject *Menu_GetMenuHandle(_self, _args) |
| 1569 | PyObject *_self; |
| 1570 | PyObject *_args; |
| 1571 | { |
| 1572 | PyObject *_res = NULL; |
| 1573 | MenuHandle _rv; |
| 1574 | short menuID; |
| 1575 | if (!PyArg_ParseTuple(_args, "h", |
| 1576 | &menuID)) |
| 1577 | return NULL; |
| 1578 | _rv = GetMenuHandle(menuID); |
| 1579 | _res = Py_BuildValue("O&", |
| 1580 | MenuObj_New, _rv); |
| 1581 | return _res; |
| 1582 | } |
| 1583 | |
| 1584 | static PyObject *Menu_MacDeleteMenu(_self, _args) |
| 1585 | PyObject *_self; |
| 1586 | PyObject *_args; |
| 1587 | { |
| 1588 | PyObject *_res = NULL; |
| 1589 | short menuID; |
| 1590 | if (!PyArg_ParseTuple(_args, "h", |
| 1591 | &menuID)) |
| 1592 | return NULL; |
| 1593 | MacDeleteMenu(menuID); |
| 1594 | Py_INCREF(Py_None); |
| 1595 | _res = Py_None; |
| 1596 | return _res; |
| 1597 | } |
| 1598 | |
| 1599 | static PyObject *Menu_ClearMenuBar(_self, _args) |
| 1600 | PyObject *_self; |
| 1601 | PyObject *_args; |
| 1602 | { |
| 1603 | PyObject *_res = NULL; |
| 1604 | if (!PyArg_ParseTuple(_args, "")) |
| 1605 | return NULL; |
| 1606 | ClearMenuBar(); |
| 1607 | Py_INCREF(Py_None); |
| 1608 | _res = Py_None; |
| 1609 | return _res; |
| 1610 | } |
| 1611 | |
| 1612 | static PyObject *Menu_SetMenuFlash(_self, _args) |
| 1613 | PyObject *_self; |
| 1614 | PyObject *_args; |
| 1615 | { |
| 1616 | PyObject *_res = NULL; |
| 1617 | short count; |
| 1618 | if (!PyArg_ParseTuple(_args, "h", |
| 1619 | &count)) |
| 1620 | return NULL; |
| 1621 | SetMenuFlash(count); |
| 1622 | Py_INCREF(Py_None); |
| 1623 | _res = Py_None; |
| 1624 | return _res; |
| 1625 | } |
| 1626 | |
| 1627 | static PyObject *Menu_FlashMenuBar(_self, _args) |
| 1628 | PyObject *_self; |
| 1629 | PyObject *_args; |
| 1630 | { |
| 1631 | PyObject *_res = NULL; |
| 1632 | short menuID; |
| 1633 | if (!PyArg_ParseTuple(_args, "h", |
| 1634 | &menuID)) |
| 1635 | return NULL; |
| 1636 | FlashMenuBar(menuID); |
| 1637 | Py_INCREF(Py_None); |
| 1638 | _res = Py_None; |
| 1639 | return _res; |
| 1640 | } |
| 1641 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1642 | static PyObject *Menu_SystemEdit(_self, _args) |
| 1643 | PyObject *_self; |
| 1644 | PyObject *_args; |
| 1645 | { |
| 1646 | PyObject *_res = NULL; |
| 1647 | Boolean _rv; |
| 1648 | short editCmd; |
| 1649 | if (!PyArg_ParseTuple(_args, "h", |
| 1650 | &editCmd)) |
| 1651 | return NULL; |
| 1652 | _rv = SystemEdit(editCmd); |
| 1653 | _res = Py_BuildValue("b", |
| 1654 | _rv); |
| 1655 | return _res; |
| 1656 | } |
| 1657 | |
| 1658 | static PyObject *Menu_SystemMenu(_self, _args) |
| 1659 | PyObject *_self; |
| 1660 | PyObject *_args; |
| 1661 | { |
| 1662 | PyObject *_res = NULL; |
| 1663 | long menuResult; |
| 1664 | if (!PyArg_ParseTuple(_args, "l", |
| 1665 | &menuResult)) |
| 1666 | return NULL; |
| 1667 | SystemMenu(menuResult); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1668 | Py_INCREF(Py_None); |
| 1669 | _res = Py_None; |
| 1670 | return _res; |
| 1671 | } |
| 1672 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1673 | static PyObject *Menu_IsMenuBarVisible(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1674 | PyObject *_self; |
| 1675 | PyObject *_args; |
| 1676 | { |
| 1677 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1678 | Boolean _rv; |
| 1679 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1680 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1681 | _rv = IsMenuBarVisible(); |
| 1682 | _res = Py_BuildValue("b", |
| 1683 | _rv); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1684 | return _res; |
| 1685 | } |
| 1686 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1687 | static PyObject *Menu_ShowMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1688 | PyObject *_self; |
| 1689 | PyObject *_args; |
| 1690 | { |
| 1691 | PyObject *_res = NULL; |
| 1692 | if (!PyArg_ParseTuple(_args, "")) |
| 1693 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1694 | ShowMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1695 | Py_INCREF(Py_None); |
| 1696 | _res = Py_None; |
| 1697 | return _res; |
| 1698 | } |
| 1699 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1700 | static PyObject *Menu_HideMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1701 | PyObject *_self; |
| 1702 | PyObject *_args; |
| 1703 | { |
| 1704 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1705 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1706 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1707 | HideMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1708 | Py_INCREF(Py_None); |
| 1709 | _res = Py_None; |
| 1710 | return _res; |
| 1711 | } |
| 1712 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1713 | static PyObject *Menu_DeleteMCEntries(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1714 | PyObject *_self; |
| 1715 | PyObject *_args; |
| 1716 | { |
| 1717 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1718 | short menuID; |
| 1719 | short menuItem; |
| 1720 | if (!PyArg_ParseTuple(_args, "hh", |
| 1721 | &menuID, |
| 1722 | &menuItem)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1723 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1724 | DeleteMCEntries(menuID, |
| 1725 | menuItem); |
| 1726 | Py_INCREF(Py_None); |
| 1727 | _res = Py_None; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1728 | return _res; |
| 1729 | } |
| 1730 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1731 | static PyObject *Menu_InitContextualMenus(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1732 | PyObject *_self; |
| 1733 | PyObject *_args; |
| 1734 | { |
| 1735 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1736 | OSStatus _err; |
| 1737 | if (!PyArg_ParseTuple(_args, "")) |
| 1738 | return NULL; |
| 1739 | _err = InitContextualMenus(); |
| 1740 | if (_err != noErr) return PyMac_Error(_err); |
| 1741 | Py_INCREF(Py_None); |
| 1742 | _res = Py_None; |
| 1743 | return _res; |
| 1744 | } |
| 1745 | |
| 1746 | static PyObject *Menu_IsShowContextualMenuClick(_self, _args) |
| 1747 | PyObject *_self; |
| 1748 | PyObject *_args; |
| 1749 | { |
| 1750 | PyObject *_res = NULL; |
| 1751 | Boolean _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1752 | EventRecord inEvent; |
| 1753 | if (!PyArg_ParseTuple(_args, "O&", |
| 1754 | PyMac_GetEventRecord, &inEvent)) |
| 1755 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1756 | _rv = IsShowContextualMenuClick(&inEvent); |
| 1757 | _res = Py_BuildValue("b", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1758 | _rv); |
| 1759 | return _res; |
| 1760 | } |
| 1761 | |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 1762 | static PyObject *Menu_OpenDeskAcc(_self, _args) |
| 1763 | PyObject *_self; |
| 1764 | PyObject *_args; |
| 1765 | { |
| 1766 | PyObject *_res = NULL; |
| 1767 | Str255 name; |
| 1768 | if (!PyArg_ParseTuple(_args, "O&", |
| 1769 | PyMac_GetStr255, name)) |
| 1770 | return NULL; |
| 1771 | OpenDeskAcc(name); |
| 1772 | Py_INCREF(Py_None); |
| 1773 | _res = Py_None; |
| 1774 | return _res; |
| 1775 | } |
| 1776 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 1777 | static PyObject *Menu_as_Menu(_self, _args) |
| 1778 | PyObject *_self; |
| 1779 | PyObject *_args; |
| 1780 | { |
| 1781 | PyObject *_res = NULL; |
| 1782 | MenuHandle _rv; |
| 1783 | Handle h; |
| 1784 | if (!PyArg_ParseTuple(_args, "O&", |
| 1785 | ResObj_Convert, &h)) |
| 1786 | return NULL; |
| 1787 | _rv = as_Menu(h); |
| 1788 | _res = Py_BuildValue("O&", |
| 1789 | MenuObj_New, _rv); |
| 1790 | return _res; |
| 1791 | } |
| 1792 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1793 | static PyObject *Menu_GetMenu(_self, _args) |
| 1794 | PyObject *_self; |
| 1795 | PyObject *_args; |
| 1796 | { |
| 1797 | PyObject *_res = NULL; |
| 1798 | MenuHandle _rv; |
| 1799 | short resourceID; |
| 1800 | if (!PyArg_ParseTuple(_args, "h", |
| 1801 | &resourceID)) |
| 1802 | return NULL; |
| 1803 | _rv = GetMenu(resourceID); |
| 1804 | _res = Py_BuildValue("O&", |
| 1805 | MenuObj_New, _rv); |
| 1806 | return _res; |
| 1807 | } |
| 1808 | |
| 1809 | static PyObject *Menu_DeleteMenu(_self, _args) |
| 1810 | PyObject *_self; |
| 1811 | PyObject *_args; |
| 1812 | { |
| 1813 | PyObject *_res = NULL; |
| 1814 | short menuID; |
| 1815 | if (!PyArg_ParseTuple(_args, "h", |
| 1816 | &menuID)) |
| 1817 | return NULL; |
| 1818 | DeleteMenu(menuID); |
| 1819 | Py_INCREF(Py_None); |
| 1820 | _res = Py_None; |
| 1821 | return _res; |
| 1822 | } |
| 1823 | |
| 1824 | static PyObject *Menu_DrawMenuBar(_self, _args) |
| 1825 | PyObject *_self; |
| 1826 | PyObject *_args; |
| 1827 | { |
| 1828 | PyObject *_res = NULL; |
| 1829 | if (!PyArg_ParseTuple(_args, "")) |
| 1830 | return NULL; |
| 1831 | DrawMenuBar(); |
| 1832 | Py_INCREF(Py_None); |
| 1833 | _res = Py_None; |
| 1834 | return _res; |
| 1835 | } |
| 1836 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1837 | static PyMethodDef Menu_methods[] = { |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1838 | {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1, |
| 1839 | "(short resID) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1840 | {"InitMenus", (PyCFunction)Menu_InitMenus, 1, |
| 1841 | "() -> None"}, |
| 1842 | {"NewMenu", (PyCFunction)Menu_NewMenu, 1, |
| 1843 | "(short menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1844 | {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1845 | "(short resourceID) -> (MenuHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1846 | {"MenuKey", (PyCFunction)Menu_MenuKey, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1847 | "(CharParameter ch) -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1848 | {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1, |
| 1849 | "(Point startPt) -> (long _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1850 | {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1, |
| 1851 | "() -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1852 | {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1, |
| 1853 | "(EventRecord inEvent) -> (UInt32 _rv)"}, |
| 1854 | {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1, |
| 1855 | "() -> (short _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1856 | {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1857 | "() -> None"}, |
| 1858 | {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1, |
| 1859 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1860 | {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1, |
| 1861 | "(short menuID) -> None"}, |
| 1862 | {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1, |
| 1863 | "(short menuBarID) -> (Handle _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1864 | {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1, |
| 1865 | "() -> (Handle _rv)"}, |
| 1866 | {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1, |
| 1867 | "(Handle menuList) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1868 | {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1, |
| 1869 | "(short menuID) -> (MenuHandle _rv)"}, |
| 1870 | {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1, |
| 1871 | "(short menuID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1872 | {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, |
| 1873 | "() -> None"}, |
| 1874 | {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, |
| 1875 | "(short count) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame^] | 1876 | {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, |
| 1877 | "(short menuID) -> None"}, |
| 1878 | {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, |
| 1879 | "(short editCmd) -> (Boolean _rv)"}, |
| 1880 | {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1, |
| 1881 | "(long menuResult) -> None"}, |
| 1882 | {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1, |
| 1883 | "() -> (Boolean _rv)"}, |
| 1884 | {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1, |
| 1885 | "() -> None"}, |
| 1886 | {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1, |
| 1887 | "() -> None"}, |
| 1888 | {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1, |
| 1889 | "(short menuID, short menuItem) -> None"}, |
| 1890 | {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1, |
| 1891 | "() -> None"}, |
| 1892 | {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1, |
| 1893 | "(EventRecord inEvent) -> (Boolean _rv)"}, |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 1894 | {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1, |
| 1895 | "(Str255 name) -> None"}, |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 1896 | {"as_Menu", (PyCFunction)Menu_as_Menu, 1, |
| 1897 | "(Handle h) -> (MenuHandle _rv)"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1898 | {"GetMenu", (PyCFunction)Menu_GetMenu, 1, |
| 1899 | "(short resourceID) -> (MenuHandle _rv)"}, |
| 1900 | {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1, |
| 1901 | "(short menuID) -> None"}, |
| 1902 | {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1, |
| 1903 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1904 | {NULL, NULL, 0} |
| 1905 | }; |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | void initMenu() |
| 1911 | { |
| 1912 | PyObject *m; |
| 1913 | PyObject *d; |
| 1914 | |
| 1915 | |
| 1916 | |
| 1917 | |
| 1918 | m = Py_InitModule("Menu", Menu_methods); |
| 1919 | d = PyModule_GetDict(m); |
| 1920 | Menu_Error = PyMac_GetOSErrException(); |
| 1921 | if (Menu_Error == NULL || |
| 1922 | PyDict_SetItemString(d, "Error", Menu_Error) != 0) |
| 1923 | Py_FatalError("can't initialize Menu.Error"); |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 1924 | Menu_Type.ob_type = &PyType_Type; |
| 1925 | Py_INCREF(&Menu_Type); |
| 1926 | if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0) |
| 1927 | Py_FatalError("can't initialize MenuType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1928 | } |
| 1929 | |
| 1930 | /* ======================== End module Menu ========================= */ |
| 1931 | |