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 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 10 | |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 11 | #include <Devices.h> /* Defines OpenDeskAcc in universal headers */ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 12 | #include <Menus.h> |
| 13 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 14 | #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 Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 24 | #define as_Menu(h) ((MenuHandle)h) |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 25 | #define as_Resource(h) ((Handle)h) |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 26 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 27 | static PyObject *Menu_Error; |
| 28 | |
| 29 | /* ------------------------ Object type Menu ------------------------ */ |
| 30 | |
| 31 | PyTypeObject Menu_Type; |
| 32 | |
| 33 | #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type) |
| 34 | |
| 35 | typedef struct MenuObject { |
| 36 | PyObject_HEAD |
| 37 | MenuHandle ob_itself; |
| 38 | } MenuObject; |
| 39 | |
| 40 | PyObject *MenuObj_New(itself) |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 41 | MenuHandle itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 42 | { |
| 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 | } |
| 49 | MenuObj_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 | |
| 62 | static void MenuObj_dealloc(self) |
| 63 | MenuObject *self; |
| 64 | { |
| 65 | /* Cleanup of self->ob_itself goes here */ |
| 66 | PyMem_DEL(self); |
| 67 | } |
| 68 | |
| 69 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 82 | static 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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 95 | static 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 109 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 110 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 111 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 124 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 125 | |
| 126 | static 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 Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 140 | _res = Py_BuildValue("hH", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 141 | outFontID, |
| 142 | outFontSize); |
| 143 | return _res; |
| 144 | } |
| 145 | |
| 146 | static 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 Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 154 | if (!PyArg_ParseTuple(_args, "hH", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 155 | &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 | |
| 167 | static 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 | |
| 181 | static 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 199 | static PyObject *MenuObj_MacAppendMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 200 | 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 208 | MacAppendMenu(_self->ob_itself, |
| 209 | data); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 210 | Py_INCREF(Py_None); |
| 211 | _res = Py_None; |
| 212 | return _res; |
| 213 | } |
| 214 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 215 | static 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 Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 234 | static 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 250 | static PyObject *MenuObj_MacInsertMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 251 | 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 261 | MacInsertMenuItem(_self->ob_itself, |
| 262 | itemString, |
| 263 | afterItem); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 264 | Py_INCREF(Py_None); |
| 265 | _res = Py_None; |
| 266 | return _res; |
| 267 | } |
| 268 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 269 | static PyObject *MenuObj_DeleteMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 270 | 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 278 | DeleteMenuItem(_self->ob_itself, |
| 279 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 280 | Py_INCREF(Py_None); |
| 281 | _res = Py_None; |
| 282 | return _res; |
| 283 | } |
| 284 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 285 | static 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 | |
| 304 | static 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 | |
| 326 | static 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 | |
| 344 | static PyObject *MenuObj_InsertMenuItemText(_self, _args) |
| 345 | MenuObject *_self; |
| 346 | PyObject *_args; |
| 347 | { |
| 348 | PyObject *_res = NULL; |
| 349 | OSStatus _err; |
| 350 | Str255 inString; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 351 | MenuItemIndex afterItem; |
| 352 | if (!PyArg_ParseTuple(_args, "O&h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 353 | 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 | |
| 365 | static 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 | |
| 388 | static PyObject *MenuObj_MacInsertMenu(_self, _args) |
| 389 | MenuObject *_self; |
| 390 | PyObject *_args; |
| 391 | { |
| 392 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 393 | MenuID beforeID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 394 | 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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 404 | static 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 423 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 424 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 425 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 443 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 444 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 445 | static PyObject *MenuObj_SetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 446 | 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 456 | SetMenuItemText(_self->ob_itself, |
| 457 | item, |
| 458 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 459 | Py_INCREF(Py_None); |
| 460 | _res = Py_None; |
| 461 | return _res; |
| 462 | } |
| 463 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 464 | static PyObject *MenuObj_GetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 465 | 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 474 | GetMenuItemText(_self->ob_itself, |
| 475 | item, |
| 476 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 477 | _res = Py_BuildValue("O&", |
| 478 | PyMac_BuildStr255, itemString); |
| 479 | return _res; |
| 480 | } |
| 481 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 482 | static PyObject *MenuObj_SetItemMark(_self, _args) |
| 483 | MenuObject *_self; |
| 484 | PyObject *_args; |
| 485 | { |
| 486 | PyObject *_res = NULL; |
| 487 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 488 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 489 | 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 | |
| 501 | static PyObject *MenuObj_GetItemMark(_self, _args) |
| 502 | MenuObject *_self; |
| 503 | PyObject *_args; |
| 504 | { |
| 505 | PyObject *_res = NULL; |
| 506 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 507 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 508 | 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 Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 519 | static 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 | |
| 538 | static 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 556 | static 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 | |
| 575 | static 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 | |
| 593 | static PyObject *MenuObj_SetItemStyle(_self, _args) |
| 594 | MenuObject *_self; |
| 595 | PyObject *_args; |
| 596 | { |
| 597 | PyObject *_res = NULL; |
| 598 | short item; |
Jack Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 599 | StyleParameter chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 600 | 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 | |
| 612 | static PyObject *MenuObj_GetItemStyle(_self, _args) |
| 613 | MenuObject *_self; |
| 614 | PyObject *_args; |
| 615 | { |
| 616 | PyObject *_res = NULL; |
| 617 | short item; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 618 | Style chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 619 | 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 630 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 631 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 632 | static PyObject *MenuObj_DisableItem(_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; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 638 | if (!PyArg_ParseTuple(_args, "h", |
| 639 | &item)) |
| 640 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 641 | DisableItem(_self->ob_itself, |
| 642 | item); |
| 643 | Py_INCREF(Py_None); |
| 644 | _res = Py_None; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 645 | return _res; |
| 646 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 647 | #endif |
| 648 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 649 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 650 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 651 | static PyObject *MenuObj_EnableItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 652 | MenuObject *_self; |
| 653 | PyObject *_args; |
| 654 | { |
| 655 | PyObject *_res = NULL; |
| 656 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 657 | if (!PyArg_ParseTuple(_args, "h", |
| 658 | &item)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 659 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 660 | EnableItem(_self->ob_itself, |
| 661 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 662 | Py_INCREF(Py_None); |
| 663 | _res = Py_None; |
| 664 | return _res; |
| 665 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 666 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 667 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 668 | static PyObject *MenuObj_SetMenuItemCommandID(_self, _args) |
| 669 | MenuObject *_self; |
| 670 | PyObject *_args; |
| 671 | { |
| 672 | PyObject *_res = NULL; |
| 673 | OSErr _err; |
| 674 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 675 | MenuCommand inCommandID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 676 | 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 | |
| 689 | static PyObject *MenuObj_GetMenuItemCommandID(_self, _args) |
| 690 | MenuObject *_self; |
| 691 | PyObject *_args; |
| 692 | { |
| 693 | PyObject *_res = NULL; |
| 694 | OSErr _err; |
| 695 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 696 | MenuCommand outCommandID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 697 | 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 | |
| 709 | static 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 | |
| 730 | static 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 | |
| 750 | static 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 | |
| 774 | static 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 | |
| 797 | static 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 | |
| 818 | static 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 | |
| 838 | static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args) |
| 839 | MenuObject *_self; |
| 840 | PyObject *_args; |
| 841 | { |
| 842 | PyObject *_res = NULL; |
| 843 | OSErr _err; |
| 844 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 845 | MenuID inHierID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 846 | 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 | |
| 859 | static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args) |
| 860 | MenuObject *_self; |
| 861 | PyObject *_args; |
| 862 | { |
| 863 | PyObject *_res = NULL; |
| 864 | OSErr _err; |
| 865 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 866 | MenuID outHierID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 867 | 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 | |
| 879 | static 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 | |
| 900 | static 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 | |
| 920 | static 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 | |
| 941 | static 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 961 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 962 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 963 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 983 | #endif |
| 984 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 985 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 986 | |
| 987 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1006 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1007 | |
| 1008 | static 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 | |
| 1029 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1049 | static PyObject *MenuObj_MacEnableMenuItem(_self, _args) |
| 1050 | MenuObject *_self; |
| 1051 | PyObject *_args; |
| 1052 | { |
| 1053 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1054 | MenuItemIndex item; |
| 1055 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1056 | &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 | |
| 1065 | static PyObject *MenuObj_DisableMenuItem(_self, _args) |
| 1066 | MenuObject *_self; |
| 1067 | PyObject *_args; |
| 1068 | { |
| 1069 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1070 | MenuItemIndex item; |
| 1071 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1072 | &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 | |
| 1081 | static PyObject *MenuObj_IsMenuItemEnabled(_self, _args) |
| 1082 | MenuObject *_self; |
| 1083 | PyObject *_args; |
| 1084 | { |
| 1085 | PyObject *_res = NULL; |
| 1086 | Boolean _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1087 | MenuItemIndex item; |
| 1088 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1089 | &item)) |
| 1090 | return NULL; |
| 1091 | _rv = IsMenuItemEnabled(_self->ob_itself, |
| 1092 | item); |
| 1093 | _res = Py_BuildValue("b", |
| 1094 | _rv); |
| 1095 | return _res; |
| 1096 | } |
| 1097 | |
| 1098 | static PyObject *MenuObj_EnableMenuItemIcon(_self, _args) |
| 1099 | MenuObject *_self; |
| 1100 | PyObject *_args; |
| 1101 | { |
| 1102 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1103 | MenuItemIndex item; |
| 1104 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1105 | &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 | |
| 1114 | static PyObject *MenuObj_DisableMenuItemIcon(_self, _args) |
| 1115 | MenuObject *_self; |
| 1116 | PyObject *_args; |
| 1117 | { |
| 1118 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1119 | MenuItemIndex item; |
| 1120 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1121 | &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 | |
| 1130 | static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args) |
| 1131 | MenuObject *_self; |
| 1132 | PyObject *_args; |
| 1133 | { |
| 1134 | PyObject *_res = NULL; |
| 1135 | Boolean _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1136 | MenuItemIndex item; |
| 1137 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1138 | &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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1147 | #if TARGET_API_MAC_CARBON |
| 1148 | |
| 1149 | static 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 | |
| 1178 | static 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 | |
| 1211 | static 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 | |
| 1231 | static 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 | |
| 1255 | static 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 | |
| 1278 | static 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 | |
| 1305 | static 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 | |
| 1321 | static 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 | |
| 1337 | static 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 | |
| 1354 | static 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 | |
| 1374 | static 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 | |
| 1403 | static 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 | |
| 1422 | static 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 | |
| 1441 | static 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 | |
| 1461 | static 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 | |
| 1490 | static 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 | |
| 1517 | static 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 | |
| 1546 | static 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 | |
| 1566 | static 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 | |
| 1590 | static 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 | |
| 1604 | static 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 | |
| 1618 | static 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 | |
| 1632 | static 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 | |
| 1648 | static 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 | |
| 1664 | static 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 Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1680 | static PyObject *MenuObj_as_Resource(_self, _args) |
| 1681 | MenuObject *_self; |
| 1682 | PyObject *_args; |
| 1683 | { |
| 1684 | PyObject *_res = NULL; |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 1685 | 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 Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1692 | } |
| 1693 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1694 | static 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 | |
| 1710 | static 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 | |
| 1726 | static 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 Jansen | 54c0787 | 2001-01-29 13:32:10 +0000 | [diff] [blame] | 1745 | static 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 | |
| 1761 | static 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1780 | static PyMethodDef MenuObj_methods[] = { |
| 1781 | {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1, |
| 1782 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1783 | {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, |
| 1784 | "() -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1785 | {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1, |
| 1786 | "() -> (short _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1787 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1788 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1789 | {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, |
| 1790 | "() -> (short _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1791 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1792 | {"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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1800 | {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1801 | "(Str255 data) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1802 | {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1, |
| 1803 | "(ResType theType, short afterItem) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1804 | {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1, |
| 1805 | "(ResType theType) -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1806 | {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1807 | "(Str255 itemString, short afterItem) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1808 | {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1809 | "(short item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1810 | {"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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1817 | "(Str255 inString, MenuItemIndex afterItem) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1818 | {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1, |
| 1819 | "(short top, short left, short popUpItem) -> (long _rv)"}, |
| 1820 | {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1821 | "(MenuID beforeID) -> None"}, |
| 1822 | {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1, |
| 1823 | "(short item, Boolean checked) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1824 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1825 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1826 | {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, |
| 1827 | "(short item, Boolean checked) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1828 | #endif |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1829 | {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1830 | "(short item, Str255 itemString) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1831 | {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1832 | "(short item) -> (Str255 itemString)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1833 | {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1834 | "(short item, CharParameter markChar) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1835 | {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1836 | "(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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1841 | {"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 Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 1846 | "(short item, StyleParameter chStyle) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1847 | {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1848 | "(short item) -> (Style chStyle)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1849 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1850 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1851 | {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1, |
| 1852 | "(short item) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1853 | #endif |
| 1854 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1855 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1856 | {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1, |
| 1857 | "(short item) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1858 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1859 | {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1860 | "(SInt16 inItem, MenuCommand inCommandID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1861 | {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1862 | "(SInt16 inItem) -> (MenuCommand outCommandID)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1863 | {"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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1876 | "(SInt16 inItem, MenuID inHierID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1877 | {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1878 | "(SInt16 inItem) -> (MenuID outHierID)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1879 | {"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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1887 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1888 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1889 | {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1, |
| 1890 | "(SInt16 inItem, UInt32 inRefCon2) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1891 | #endif |
| 1892 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1893 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1894 | {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1, |
| 1895 | "(SInt16 inItem) -> (UInt32 outRefCon2)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1896 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1897 | {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1, |
| 1898 | "(SInt16 inItem, SInt16 inGlyph) -> None"}, |
| 1899 | {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1, |
| 1900 | "(SInt16 inItem) -> (SInt16 outGlyph)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1901 | {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1902 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1903 | {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1904 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1905 | {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1906 | "(MenuItemIndex item) -> (Boolean _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1907 | {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1908 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1909 | {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1910 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1911 | {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1912 | "(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 Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 2020 | {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1, |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 2021 | "() -> (Handle _rv)"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2022 | {"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 Jansen | 54c0787 | 2001-01-29 13:32:10 +0000 | [diff] [blame] | 2028 | {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1, |
| 2029 | "(UInt16 item) -> None"}, |
| 2030 | {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1, |
| 2031 | "(short item, Boolean checked) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2032 | {NULL, NULL, 0} |
| 2033 | }; |
| 2034 | |
| 2035 | PyMethodChain MenuObj_chain = { MenuObj_methods, NULL }; |
| 2036 | |
| 2037 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2046 | #define MenuObj_compare NULL |
| 2047 | |
| 2048 | #define MenuObj_repr NULL |
| 2049 | |
| 2050 | #define MenuObj_hash NULL |
| 2051 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2052 | PyTypeObject 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2063 | (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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2069 | }; |
| 2070 | |
| 2071 | /* ---------------------- End object type Menu ---------------------- */ |
| 2072 | |
| 2073 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2074 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2075 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2076 | static PyObject *Menu_InitProcMenu(_self, _args) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2077 | PyObject *_self; |
| 2078 | PyObject *_args; |
| 2079 | { |
| 2080 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2081 | short resID; |
| 2082 | if (!PyArg_ParseTuple(_args, "h", |
| 2083 | &resID)) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2084 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2085 | InitProcMenu(resID); |
| 2086 | Py_INCREF(Py_None); |
| 2087 | _res = Py_None; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2088 | return _res; |
| 2089 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2090 | #endif |
| 2091 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2092 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2093 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2094 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2106 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2107 | |
| 2108 | static PyObject *Menu_NewMenu(_self, _args) |
| 2109 | PyObject *_self; |
| 2110 | PyObject *_args; |
| 2111 | { |
| 2112 | PyObject *_res = NULL; |
| 2113 | MenuHandle _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2114 | MenuID menuID; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2115 | 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2127 | static PyObject *Menu_MacGetMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2128 | 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 Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2137 | _rv = MacGetMenu(resourceID); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2138 | _res = Py_BuildValue("O&", |
| 2139 | MenuObj_New, _rv); |
| 2140 | return _res; |
| 2141 | } |
| 2142 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2143 | #if TARGET_API_MAC_CARBON |
| 2144 | |
| 2145 | static 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2168 | static PyObject *Menu_MenuKey(_self, _args) |
| 2169 | PyObject *_self; |
| 2170 | PyObject *_args; |
| 2171 | { |
| 2172 | PyObject *_res = NULL; |
| 2173 | long _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2174 | CharParameter ch; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2175 | 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2184 | static PyObject *Menu_MenuSelect(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2185 | PyObject *_self; |
| 2186 | PyObject *_args; |
| 2187 | { |
| 2188 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2189 | long _rv; |
| 2190 | Point startPt; |
| 2191 | if (!PyArg_ParseTuple(_args, "O&", |
| 2192 | PyMac_GetPoint, &startPt)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2193 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2194 | _rv = MenuSelect(startPt); |
| 2195 | _res = Py_BuildValue("l", |
| 2196 | _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2197 | return _res; |
| 2198 | } |
| 2199 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2200 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2214 | static PyObject *Menu_MenuEvent(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2215 | PyObject *_self; |
| 2216 | PyObject *_args; |
| 2217 | { |
| 2218 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2219 | UInt32 _rv; |
| 2220 | EventRecord inEvent; |
| 2221 | if (!PyArg_ParseTuple(_args, "O&", |
| 2222 | PyMac_GetEventRecord, &inEvent)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2223 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2224 | _rv = MenuEvent(&inEvent); |
| 2225 | _res = Py_BuildValue("l", |
| 2226 | _rv); |
| 2227 | return _res; |
| 2228 | } |
| 2229 | |
| 2230 | static 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 Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2241 | return _res; |
| 2242 | } |
| 2243 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2244 | static PyObject *Menu_MacDrawMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2245 | PyObject *_self; |
| 2246 | PyObject *_args; |
| 2247 | { |
| 2248 | PyObject *_res = NULL; |
| 2249 | if (!PyArg_ParseTuple(_args, "")) |
| 2250 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2251 | MacDrawMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2252 | Py_INCREF(Py_None); |
| 2253 | _res = Py_None; |
| 2254 | return _res; |
| 2255 | } |
| 2256 | |
| 2257 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2270 | static PyObject *Menu_HiliteMenu(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2271 | PyObject *_self; |
| 2272 | PyObject *_args; |
| 2273 | { |
| 2274 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2275 | MenuID menuID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2276 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2277 | &menuID)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2278 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2279 | HiliteMenu(menuID); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2280 | Py_INCREF(Py_None); |
| 2281 | _res = Py_None; |
| 2282 | return _res; |
| 2283 | } |
| 2284 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2285 | static PyObject *Menu_GetNewMBar(_self, _args) |
| 2286 | PyObject *_self; |
| 2287 | PyObject *_args; |
| 2288 | { |
| 2289 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2290 | MenuBarHandle _rv; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2291 | 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 Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2301 | static PyObject *Menu_GetMenuBar(_self, _args) |
| 2302 | PyObject *_self; |
| 2303 | PyObject *_args; |
| 2304 | { |
| 2305 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2306 | MenuBarHandle _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2307 | if (!PyArg_ParseTuple(_args, "")) |
| 2308 | return NULL; |
| 2309 | _rv = GetMenuBar(); |
| 2310 | _res = Py_BuildValue("O&", |
| 2311 | ResObj_New, _rv); |
| 2312 | return _res; |
| 2313 | } |
| 2314 | |
| 2315 | static PyObject *Menu_SetMenuBar(_self, _args) |
| 2316 | PyObject *_self; |
| 2317 | PyObject *_args; |
| 2318 | { |
| 2319 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2320 | MenuBarHandle mbar; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2321 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2322 | ResObj_Convert, &mbar)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2323 | return NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2324 | SetMenuBar(mbar); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2325 | Py_INCREF(Py_None); |
| 2326 | _res = Py_None; |
| 2327 | return _res; |
| 2328 | } |
| 2329 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2330 | #if TARGET_API_MAC_CARBON |
| 2331 | |
| 2332 | static 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 | |
| 2354 | static 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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2372 | static PyObject *Menu_GetMenuHandle(_self, _args) |
| 2373 | PyObject *_self; |
| 2374 | PyObject *_args; |
| 2375 | { |
| 2376 | PyObject *_res = NULL; |
| 2377 | MenuHandle _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2378 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2379 | 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 | |
| 2388 | static PyObject *Menu_MacDeleteMenu(_self, _args) |
| 2389 | PyObject *_self; |
| 2390 | PyObject *_args; |
| 2391 | { |
| 2392 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2393 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2394 | 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 | |
| 2403 | static 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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2416 | static 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2431 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2432 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2433 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2447 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2448 | |
| 2449 | static PyObject *Menu_FlashMenuBar(_self, _args) |
| 2450 | PyObject *_self; |
| 2451 | PyObject *_args; |
| 2452 | { |
| 2453 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2454 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2455 | 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 Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2464 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2465 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2466 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2481 | #endif |
| 2482 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2483 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2484 | |
| 2485 | static 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2495 | Py_INCREF(Py_None); |
| 2496 | _res = Py_None; |
| 2497 | return _res; |
| 2498 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2499 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2500 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2501 | static PyObject *Menu_IsMenuBarVisible(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2502 | PyObject *_self; |
| 2503 | PyObject *_args; |
| 2504 | { |
| 2505 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2506 | Boolean _rv; |
| 2507 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2508 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2509 | _rv = IsMenuBarVisible(); |
| 2510 | _res = Py_BuildValue("b", |
| 2511 | _rv); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2512 | return _res; |
| 2513 | } |
| 2514 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2515 | static PyObject *Menu_ShowMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2516 | PyObject *_self; |
| 2517 | PyObject *_args; |
| 2518 | { |
| 2519 | PyObject *_res = NULL; |
| 2520 | if (!PyArg_ParseTuple(_args, "")) |
| 2521 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2522 | ShowMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2523 | Py_INCREF(Py_None); |
| 2524 | _res = Py_None; |
| 2525 | return _res; |
| 2526 | } |
| 2527 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2528 | static PyObject *Menu_HideMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2529 | PyObject *_self; |
| 2530 | PyObject *_args; |
| 2531 | { |
| 2532 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2533 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2534 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2535 | HideMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2536 | Py_INCREF(Py_None); |
| 2537 | _res = Py_None; |
| 2538 | return _res; |
| 2539 | } |
| 2540 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2541 | static PyObject *Menu_DeleteMCEntries(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2542 | PyObject *_self; |
| 2543 | PyObject *_args; |
| 2544 | { |
| 2545 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2546 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2547 | short menuItem; |
| 2548 | if (!PyArg_ParseTuple(_args, "hh", |
| 2549 | &menuID, |
| 2550 | &menuItem)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2551 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2552 | DeleteMCEntries(menuID, |
| 2553 | menuItem); |
| 2554 | Py_INCREF(Py_None); |
| 2555 | _res = Py_None; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2556 | return _res; |
| 2557 | } |
| 2558 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2559 | static PyObject *Menu_InitContextualMenus(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2560 | PyObject *_self; |
| 2561 | PyObject *_args; |
| 2562 | { |
| 2563 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2564 | 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 | |
| 2574 | static PyObject *Menu_IsShowContextualMenuClick(_self, _args) |
| 2575 | PyObject *_self; |
| 2576 | PyObject *_args; |
| 2577 | { |
| 2578 | PyObject *_res = NULL; |
| 2579 | Boolean _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2580 | EventRecord inEvent; |
| 2581 | if (!PyArg_ParseTuple(_args, "O&", |
| 2582 | PyMac_GetEventRecord, &inEvent)) |
| 2583 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2584 | _rv = IsShowContextualMenuClick(&inEvent); |
| 2585 | _res = Py_BuildValue("b", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2586 | _rv); |
| 2587 | return _res; |
| 2588 | } |
| 2589 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2590 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2591 | |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2592 | static 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 Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2606 | #endif |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2607 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2608 | static 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 Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2624 | static 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 | |
| 2640 | static 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 | |
| 2655 | static 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2668 | static PyMethodDef Menu_methods[] = { |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2669 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2670 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2671 | {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1, |
| 2672 | "(short resID) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2673 | #endif |
| 2674 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2675 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2676 | {"InitMenus", (PyCFunction)Menu_InitMenus, 1, |
| 2677 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2678 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2679 | {"NewMenu", (PyCFunction)Menu_NewMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2680 | "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2681 | {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2682 | "(short resourceID) -> (MenuHandle _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2683 | |
| 2684 | #if TARGET_API_MAC_CARBON |
| 2685 | {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1, |
| 2686 | "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"}, |
| 2687 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2688 | {"MenuKey", (PyCFunction)Menu_MenuKey, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2689 | "(CharParameter ch) -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2690 | {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1, |
| 2691 | "(Point startPt) -> (long _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2692 | {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1, |
| 2693 | "() -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2694 | {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1, |
| 2695 | "(EventRecord inEvent) -> (UInt32 _rv)"}, |
| 2696 | {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1, |
| 2697 | "() -> (short _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2698 | {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2699 | "() -> None"}, |
| 2700 | {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1, |
| 2701 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2702 | {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2703 | "(MenuID menuID) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2704 | {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2705 | "(short menuBarID) -> (MenuBarHandle _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2706 | {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2707 | "() -> (MenuBarHandle _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2708 | {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2709 | "(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 Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2720 | {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2721 | "(MenuID menuID) -> (MenuHandle _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2722 | {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2723 | "(MenuID menuID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2724 | {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, |
| 2725 | "() -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2726 | {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1, |
| 2727 | "(short count) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2728 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2729 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2730 | {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, |
| 2731 | "(short count) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2732 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2733 | {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2734 | "(MenuID menuID) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2735 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2736 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2737 | {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, |
| 2738 | "(short editCmd) -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2739 | #endif |
| 2740 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2741 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2742 | {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1, |
| 2743 | "(long menuResult) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2744 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2745 | {"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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2752 | "(MenuID menuID, short menuItem) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2753 | {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1, |
| 2754 | "() -> None"}, |
| 2755 | {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1, |
| 2756 | "(EventRecord inEvent) -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2757 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2758 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2759 | {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1, |
| 2760 | "(Str255 name) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2761 | #endif |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2762 | {"as_Menu", (PyCFunction)Menu_as_Menu, 1, |
| 2763 | "(Handle h) -> (MenuHandle _rv)"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2764 | {"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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2770 | {NULL, NULL, 0} |
| 2771 | }; |
| 2772 | |
| 2773 | |
| 2774 | |
| 2775 | |
| 2776 | void 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 Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2789 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 2790 | 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 Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | /* ======================== End module Menu ========================= */ |
| 2797 | |