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 | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 14 | #ifdef USE_TOOLBOX_OBJECT_GLUE |
| 15 | |
| 16 | extern PyObject *_MenuObj_New(MenuHandle); |
| 17 | extern int _MenuObj_Convert(PyObject *, MenuHandle *); |
| 18 | |
| 19 | #define MenuObj_New _MenuObj_New |
| 20 | #define MenuObj_Convert _MenuObj_Convert |
| 21 | #endif |
| 22 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 23 | #if !ACCESSOR_CALLS_ARE_FUNCTIONS |
| 24 | #define GetMenuID(menu) ((*(menu))->menuID) |
| 25 | #define GetMenuWidth(menu) ((*(menu))->menuWidth) |
| 26 | #define GetMenuHeight(menu) ((*(menu))->menuHeight) |
| 27 | |
| 28 | #define SetMenuID(menu, id) ((*(menu))->menuID = (id)) |
| 29 | #define SetMenuWidth(menu, width) ((*(menu))->menuWidth = (width)) |
| 30 | #define SetMenuHeight(menu, height) ((*(menu))->menuHeight = (height)) |
| 31 | #endif |
| 32 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 33 | #define as_Menu(h) ((MenuHandle)h) |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 34 | #define as_Resource(h) ((Handle)h) |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 35 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 36 | static PyObject *Menu_Error; |
| 37 | |
| 38 | /* ------------------------ Object type Menu ------------------------ */ |
| 39 | |
| 40 | PyTypeObject Menu_Type; |
| 41 | |
| 42 | #define MenuObj_Check(x) ((x)->ob_type == &Menu_Type) |
| 43 | |
| 44 | typedef struct MenuObject { |
| 45 | PyObject_HEAD |
| 46 | MenuHandle ob_itself; |
| 47 | } MenuObject; |
| 48 | |
| 49 | PyObject *MenuObj_New(itself) |
Guido van Rossum | 227a423 | 1995-03-10 14:42:57 +0000 | [diff] [blame] | 50 | MenuHandle itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 51 | { |
| 52 | MenuObject *it; |
| 53 | it = PyObject_NEW(MenuObject, &Menu_Type); |
| 54 | if (it == NULL) return NULL; |
| 55 | it->ob_itself = itself; |
| 56 | return (PyObject *)it; |
| 57 | } |
| 58 | MenuObj_Convert(v, p_itself) |
| 59 | PyObject *v; |
| 60 | MenuHandle *p_itself; |
| 61 | { |
| 62 | if (!MenuObj_Check(v)) |
| 63 | { |
| 64 | PyErr_SetString(PyExc_TypeError, "Menu required"); |
| 65 | return 0; |
| 66 | } |
| 67 | *p_itself = ((MenuObject *)v)->ob_itself; |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | static void MenuObj_dealloc(self) |
| 72 | MenuObject *self; |
| 73 | { |
| 74 | /* Cleanup of self->ob_itself goes here */ |
| 75 | PyMem_DEL(self); |
| 76 | } |
| 77 | |
| 78 | static PyObject *MenuObj_DisposeMenu(_self, _args) |
| 79 | MenuObject *_self; |
| 80 | PyObject *_args; |
| 81 | { |
| 82 | PyObject *_res = NULL; |
| 83 | if (!PyArg_ParseTuple(_args, "")) |
| 84 | return NULL; |
| 85 | DisposeMenu(_self->ob_itself); |
| 86 | Py_INCREF(Py_None); |
| 87 | _res = Py_None; |
| 88 | return _res; |
| 89 | } |
| 90 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 91 | static PyObject *MenuObj_CalcMenuSize(_self, _args) |
| 92 | MenuObject *_self; |
| 93 | PyObject *_args; |
| 94 | { |
| 95 | PyObject *_res = NULL; |
| 96 | if (!PyArg_ParseTuple(_args, "")) |
| 97 | return NULL; |
| 98 | CalcMenuSize(_self->ob_itself); |
| 99 | Py_INCREF(Py_None); |
| 100 | _res = Py_None; |
| 101 | return _res; |
| 102 | } |
| 103 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 104 | static PyObject *MenuObj_CountMenuItems(_self, _args) |
| 105 | MenuObject *_self; |
| 106 | PyObject *_args; |
| 107 | { |
| 108 | PyObject *_res = NULL; |
| 109 | short _rv; |
| 110 | if (!PyArg_ParseTuple(_args, "")) |
| 111 | return NULL; |
| 112 | _rv = CountMenuItems(_self->ob_itself); |
| 113 | _res = Py_BuildValue("h", |
| 114 | _rv); |
| 115 | return _res; |
| 116 | } |
| 117 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 118 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 119 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 120 | static PyObject *MenuObj_CountMItems(_self, _args) |
| 121 | MenuObject *_self; |
| 122 | PyObject *_args; |
| 123 | { |
| 124 | PyObject *_res = NULL; |
| 125 | short _rv; |
| 126 | if (!PyArg_ParseTuple(_args, "")) |
| 127 | return NULL; |
| 128 | _rv = CountMItems(_self->ob_itself); |
| 129 | _res = Py_BuildValue("h", |
| 130 | _rv); |
| 131 | return _res; |
| 132 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 133 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 134 | |
| 135 | static PyObject *MenuObj_GetMenuFont(_self, _args) |
| 136 | MenuObject *_self; |
| 137 | PyObject *_args; |
| 138 | { |
| 139 | PyObject *_res = NULL; |
| 140 | OSStatus _err; |
| 141 | SInt16 outFontID; |
| 142 | UInt16 outFontSize; |
| 143 | if (!PyArg_ParseTuple(_args, "")) |
| 144 | return NULL; |
| 145 | _err = GetMenuFont(_self->ob_itself, |
| 146 | &outFontID, |
| 147 | &outFontSize); |
| 148 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 149 | _res = Py_BuildValue("hH", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 150 | outFontID, |
| 151 | outFontSize); |
| 152 | return _res; |
| 153 | } |
| 154 | |
| 155 | static PyObject *MenuObj_SetMenuFont(_self, _args) |
| 156 | MenuObject *_self; |
| 157 | PyObject *_args; |
| 158 | { |
| 159 | PyObject *_res = NULL; |
| 160 | OSStatus _err; |
| 161 | SInt16 inFontID; |
| 162 | UInt16 inFontSize; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 163 | if (!PyArg_ParseTuple(_args, "hH", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 164 | &inFontID, |
| 165 | &inFontSize)) |
| 166 | return NULL; |
| 167 | _err = SetMenuFont(_self->ob_itself, |
| 168 | inFontID, |
| 169 | inFontSize); |
| 170 | if (_err != noErr) return PyMac_Error(_err); |
| 171 | Py_INCREF(Py_None); |
| 172 | _res = Py_None; |
| 173 | return _res; |
| 174 | } |
| 175 | |
| 176 | static PyObject *MenuObj_GetMenuExcludesMarkColumn(_self, _args) |
| 177 | MenuObject *_self; |
| 178 | PyObject *_args; |
| 179 | { |
| 180 | PyObject *_res = NULL; |
| 181 | Boolean _rv; |
| 182 | if (!PyArg_ParseTuple(_args, "")) |
| 183 | return NULL; |
| 184 | _rv = GetMenuExcludesMarkColumn(_self->ob_itself); |
| 185 | _res = Py_BuildValue("b", |
| 186 | _rv); |
| 187 | return _res; |
| 188 | } |
| 189 | |
| 190 | static PyObject *MenuObj_SetMenuExcludesMarkColumn(_self, _args) |
| 191 | MenuObject *_self; |
| 192 | PyObject *_args; |
| 193 | { |
| 194 | PyObject *_res = NULL; |
| 195 | OSStatus _err; |
| 196 | Boolean excludesMark; |
| 197 | if (!PyArg_ParseTuple(_args, "b", |
| 198 | &excludesMark)) |
| 199 | return NULL; |
| 200 | _err = SetMenuExcludesMarkColumn(_self->ob_itself, |
| 201 | excludesMark); |
| 202 | if (_err != noErr) return PyMac_Error(_err); |
| 203 | Py_INCREF(Py_None); |
| 204 | _res = Py_None; |
| 205 | return _res; |
| 206 | } |
| 207 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 208 | static PyObject *MenuObj_MacAppendMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 209 | MenuObject *_self; |
| 210 | PyObject *_args; |
| 211 | { |
| 212 | PyObject *_res = NULL; |
| 213 | Str255 data; |
| 214 | if (!PyArg_ParseTuple(_args, "O&", |
| 215 | PyMac_GetStr255, data)) |
| 216 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 217 | MacAppendMenu(_self->ob_itself, |
| 218 | data); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 219 | Py_INCREF(Py_None); |
| 220 | _res = Py_None; |
| 221 | return _res; |
| 222 | } |
| 223 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 224 | static PyObject *MenuObj_InsertResMenu(_self, _args) |
| 225 | MenuObject *_self; |
| 226 | PyObject *_args; |
| 227 | { |
| 228 | PyObject *_res = NULL; |
| 229 | ResType theType; |
| 230 | short afterItem; |
| 231 | if (!PyArg_ParseTuple(_args, "O&h", |
| 232 | PyMac_GetOSType, &theType, |
| 233 | &afterItem)) |
| 234 | return NULL; |
| 235 | InsertResMenu(_self->ob_itself, |
| 236 | theType, |
| 237 | afterItem); |
| 238 | Py_INCREF(Py_None); |
| 239 | _res = Py_None; |
| 240 | return _res; |
| 241 | } |
| 242 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 243 | static PyObject *MenuObj_AppendResMenu(_self, _args) |
| 244 | MenuObject *_self; |
| 245 | PyObject *_args; |
| 246 | { |
| 247 | PyObject *_res = NULL; |
| 248 | ResType theType; |
| 249 | if (!PyArg_ParseTuple(_args, "O&", |
| 250 | PyMac_GetOSType, &theType)) |
| 251 | return NULL; |
| 252 | AppendResMenu(_self->ob_itself, |
| 253 | theType); |
| 254 | Py_INCREF(Py_None); |
| 255 | _res = Py_None; |
| 256 | return _res; |
| 257 | } |
| 258 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 259 | static PyObject *MenuObj_MacInsertMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 260 | MenuObject *_self; |
| 261 | PyObject *_args; |
| 262 | { |
| 263 | PyObject *_res = NULL; |
| 264 | Str255 itemString; |
| 265 | short afterItem; |
| 266 | if (!PyArg_ParseTuple(_args, "O&h", |
| 267 | PyMac_GetStr255, itemString, |
| 268 | &afterItem)) |
| 269 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 270 | MacInsertMenuItem(_self->ob_itself, |
| 271 | itemString, |
| 272 | afterItem); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 273 | Py_INCREF(Py_None); |
| 274 | _res = Py_None; |
| 275 | return _res; |
| 276 | } |
| 277 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 278 | static PyObject *MenuObj_DeleteMenuItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 279 | MenuObject *_self; |
| 280 | PyObject *_args; |
| 281 | { |
| 282 | PyObject *_res = NULL; |
| 283 | short item; |
| 284 | if (!PyArg_ParseTuple(_args, "h", |
| 285 | &item)) |
| 286 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 287 | DeleteMenuItem(_self->ob_itself, |
| 288 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 289 | Py_INCREF(Py_None); |
| 290 | _res = Py_None; |
| 291 | return _res; |
| 292 | } |
| 293 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 294 | static PyObject *MenuObj_InsertFontResMenu(_self, _args) |
| 295 | MenuObject *_self; |
| 296 | PyObject *_args; |
| 297 | { |
| 298 | PyObject *_res = NULL; |
| 299 | short afterItem; |
| 300 | short scriptFilter; |
| 301 | if (!PyArg_ParseTuple(_args, "hh", |
| 302 | &afterItem, |
| 303 | &scriptFilter)) |
| 304 | return NULL; |
| 305 | InsertFontResMenu(_self->ob_itself, |
| 306 | afterItem, |
| 307 | scriptFilter); |
| 308 | Py_INCREF(Py_None); |
| 309 | _res = Py_None; |
| 310 | return _res; |
| 311 | } |
| 312 | |
| 313 | static PyObject *MenuObj_InsertIntlResMenu(_self, _args) |
| 314 | MenuObject *_self; |
| 315 | PyObject *_args; |
| 316 | { |
| 317 | PyObject *_res = NULL; |
| 318 | ResType theType; |
| 319 | short afterItem; |
| 320 | short scriptFilter; |
| 321 | if (!PyArg_ParseTuple(_args, "O&hh", |
| 322 | PyMac_GetOSType, &theType, |
| 323 | &afterItem, |
| 324 | &scriptFilter)) |
| 325 | return NULL; |
| 326 | InsertIntlResMenu(_self->ob_itself, |
| 327 | theType, |
| 328 | afterItem, |
| 329 | scriptFilter); |
| 330 | Py_INCREF(Py_None); |
| 331 | _res = Py_None; |
| 332 | return _res; |
| 333 | } |
| 334 | |
| 335 | static PyObject *MenuObj_AppendMenuItemText(_self, _args) |
| 336 | MenuObject *_self; |
| 337 | PyObject *_args; |
| 338 | { |
| 339 | PyObject *_res = NULL; |
| 340 | OSStatus _err; |
| 341 | Str255 inString; |
| 342 | if (!PyArg_ParseTuple(_args, "O&", |
| 343 | PyMac_GetStr255, inString)) |
| 344 | return NULL; |
| 345 | _err = AppendMenuItemText(_self->ob_itself, |
| 346 | inString); |
| 347 | if (_err != noErr) return PyMac_Error(_err); |
| 348 | Py_INCREF(Py_None); |
| 349 | _res = Py_None; |
| 350 | return _res; |
| 351 | } |
| 352 | |
| 353 | static PyObject *MenuObj_InsertMenuItemText(_self, _args) |
| 354 | MenuObject *_self; |
| 355 | PyObject *_args; |
| 356 | { |
| 357 | PyObject *_res = NULL; |
| 358 | OSStatus _err; |
| 359 | Str255 inString; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 360 | MenuItemIndex afterItem; |
| 361 | if (!PyArg_ParseTuple(_args, "O&h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 362 | PyMac_GetStr255, inString, |
| 363 | &afterItem)) |
| 364 | return NULL; |
| 365 | _err = InsertMenuItemText(_self->ob_itself, |
| 366 | inString, |
| 367 | afterItem); |
| 368 | if (_err != noErr) return PyMac_Error(_err); |
| 369 | Py_INCREF(Py_None); |
| 370 | _res = Py_None; |
| 371 | return _res; |
| 372 | } |
| 373 | |
| 374 | static PyObject *MenuObj_PopUpMenuSelect(_self, _args) |
| 375 | MenuObject *_self; |
| 376 | PyObject *_args; |
| 377 | { |
| 378 | PyObject *_res = NULL; |
| 379 | long _rv; |
| 380 | short top; |
| 381 | short left; |
| 382 | short popUpItem; |
| 383 | if (!PyArg_ParseTuple(_args, "hhh", |
| 384 | &top, |
| 385 | &left, |
| 386 | &popUpItem)) |
| 387 | return NULL; |
| 388 | _rv = PopUpMenuSelect(_self->ob_itself, |
| 389 | top, |
| 390 | left, |
| 391 | popUpItem); |
| 392 | _res = Py_BuildValue("l", |
| 393 | _rv); |
| 394 | return _res; |
| 395 | } |
| 396 | |
| 397 | static PyObject *MenuObj_MacInsertMenu(_self, _args) |
| 398 | MenuObject *_self; |
| 399 | PyObject *_args; |
| 400 | { |
| 401 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 402 | MenuID beforeID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 403 | if (!PyArg_ParseTuple(_args, "h", |
| 404 | &beforeID)) |
| 405 | return NULL; |
| 406 | MacInsertMenu(_self->ob_itself, |
| 407 | beforeID); |
| 408 | Py_INCREF(Py_None); |
| 409 | _res = Py_None; |
| 410 | return _res; |
| 411 | } |
| 412 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 413 | static PyObject *MenuObj_MacCheckMenuItem(_self, _args) |
| 414 | MenuObject *_self; |
| 415 | PyObject *_args; |
| 416 | { |
| 417 | PyObject *_res = NULL; |
| 418 | short item; |
| 419 | Boolean checked; |
| 420 | if (!PyArg_ParseTuple(_args, "hb", |
| 421 | &item, |
| 422 | &checked)) |
| 423 | return NULL; |
| 424 | MacCheckMenuItem(_self->ob_itself, |
| 425 | item, |
| 426 | checked); |
| 427 | Py_INCREF(Py_None); |
| 428 | _res = Py_None; |
| 429 | return _res; |
| 430 | } |
| 431 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 432 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 433 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 434 | static PyObject *MenuObj_CheckItem(_self, _args) |
| 435 | MenuObject *_self; |
| 436 | PyObject *_args; |
| 437 | { |
| 438 | PyObject *_res = NULL; |
| 439 | short item; |
| 440 | Boolean checked; |
| 441 | if (!PyArg_ParseTuple(_args, "hb", |
| 442 | &item, |
| 443 | &checked)) |
| 444 | return NULL; |
| 445 | CheckItem(_self->ob_itself, |
| 446 | item, |
| 447 | checked); |
| 448 | Py_INCREF(Py_None); |
| 449 | _res = Py_None; |
| 450 | return _res; |
| 451 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 452 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 453 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 454 | static PyObject *MenuObj_SetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 455 | MenuObject *_self; |
| 456 | PyObject *_args; |
| 457 | { |
| 458 | PyObject *_res = NULL; |
| 459 | short item; |
| 460 | Str255 itemString; |
| 461 | if (!PyArg_ParseTuple(_args, "hO&", |
| 462 | &item, |
| 463 | PyMac_GetStr255, itemString)) |
| 464 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 465 | SetMenuItemText(_self->ob_itself, |
| 466 | item, |
| 467 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 468 | Py_INCREF(Py_None); |
| 469 | _res = Py_None; |
| 470 | return _res; |
| 471 | } |
| 472 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 473 | static PyObject *MenuObj_GetMenuItemText(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 474 | MenuObject *_self; |
| 475 | PyObject *_args; |
| 476 | { |
| 477 | PyObject *_res = NULL; |
| 478 | short item; |
| 479 | Str255 itemString; |
| 480 | if (!PyArg_ParseTuple(_args, "h", |
| 481 | &item)) |
| 482 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 483 | GetMenuItemText(_self->ob_itself, |
| 484 | item, |
| 485 | itemString); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 486 | _res = Py_BuildValue("O&", |
| 487 | PyMac_BuildStr255, itemString); |
| 488 | return _res; |
| 489 | } |
| 490 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 491 | static PyObject *MenuObj_SetItemMark(_self, _args) |
| 492 | MenuObject *_self; |
| 493 | PyObject *_args; |
| 494 | { |
| 495 | PyObject *_res = NULL; |
| 496 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 497 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 498 | if (!PyArg_ParseTuple(_args, "hh", |
| 499 | &item, |
| 500 | &markChar)) |
| 501 | return NULL; |
| 502 | SetItemMark(_self->ob_itself, |
| 503 | item, |
| 504 | markChar); |
| 505 | Py_INCREF(Py_None); |
| 506 | _res = Py_None; |
| 507 | return _res; |
| 508 | } |
| 509 | |
| 510 | static PyObject *MenuObj_GetItemMark(_self, _args) |
| 511 | MenuObject *_self; |
| 512 | PyObject *_args; |
| 513 | { |
| 514 | PyObject *_res = NULL; |
| 515 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 516 | CharParameter markChar; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 517 | if (!PyArg_ParseTuple(_args, "h", |
| 518 | &item)) |
| 519 | return NULL; |
| 520 | GetItemMark(_self->ob_itself, |
| 521 | item, |
| 522 | &markChar); |
| 523 | _res = Py_BuildValue("h", |
| 524 | markChar); |
| 525 | return _res; |
| 526 | } |
| 527 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 528 | static PyObject *MenuObj_SetItemCmd(_self, _args) |
| 529 | MenuObject *_self; |
| 530 | PyObject *_args; |
| 531 | { |
| 532 | PyObject *_res = NULL; |
| 533 | short item; |
| 534 | CharParameter cmdChar; |
| 535 | if (!PyArg_ParseTuple(_args, "hh", |
| 536 | &item, |
| 537 | &cmdChar)) |
| 538 | return NULL; |
| 539 | SetItemCmd(_self->ob_itself, |
| 540 | item, |
| 541 | cmdChar); |
| 542 | Py_INCREF(Py_None); |
| 543 | _res = Py_None; |
| 544 | return _res; |
| 545 | } |
| 546 | |
| 547 | static PyObject *MenuObj_GetItemCmd(_self, _args) |
| 548 | MenuObject *_self; |
| 549 | PyObject *_args; |
| 550 | { |
| 551 | PyObject *_res = NULL; |
| 552 | short item; |
| 553 | CharParameter cmdChar; |
| 554 | if (!PyArg_ParseTuple(_args, "h", |
| 555 | &item)) |
| 556 | return NULL; |
| 557 | GetItemCmd(_self->ob_itself, |
| 558 | item, |
| 559 | &cmdChar); |
| 560 | _res = Py_BuildValue("h", |
| 561 | cmdChar); |
| 562 | return _res; |
| 563 | } |
| 564 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 565 | static PyObject *MenuObj_SetItemIcon(_self, _args) |
| 566 | MenuObject *_self; |
| 567 | PyObject *_args; |
| 568 | { |
| 569 | PyObject *_res = NULL; |
| 570 | short item; |
| 571 | short iconIndex; |
| 572 | if (!PyArg_ParseTuple(_args, "hh", |
| 573 | &item, |
| 574 | &iconIndex)) |
| 575 | return NULL; |
| 576 | SetItemIcon(_self->ob_itself, |
| 577 | item, |
| 578 | iconIndex); |
| 579 | Py_INCREF(Py_None); |
| 580 | _res = Py_None; |
| 581 | return _res; |
| 582 | } |
| 583 | |
| 584 | static PyObject *MenuObj_GetItemIcon(_self, _args) |
| 585 | MenuObject *_self; |
| 586 | PyObject *_args; |
| 587 | { |
| 588 | PyObject *_res = NULL; |
| 589 | short item; |
| 590 | short iconIndex; |
| 591 | if (!PyArg_ParseTuple(_args, "h", |
| 592 | &item)) |
| 593 | return NULL; |
| 594 | GetItemIcon(_self->ob_itself, |
| 595 | item, |
| 596 | &iconIndex); |
| 597 | _res = Py_BuildValue("h", |
| 598 | iconIndex); |
| 599 | return _res; |
| 600 | } |
| 601 | |
| 602 | static PyObject *MenuObj_SetItemStyle(_self, _args) |
| 603 | MenuObject *_self; |
| 604 | PyObject *_args; |
| 605 | { |
| 606 | PyObject *_res = NULL; |
| 607 | short item; |
Jack Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 608 | StyleParameter chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 609 | if (!PyArg_ParseTuple(_args, "hh", |
| 610 | &item, |
| 611 | &chStyle)) |
| 612 | return NULL; |
| 613 | SetItemStyle(_self->ob_itself, |
| 614 | item, |
| 615 | chStyle); |
| 616 | Py_INCREF(Py_None); |
| 617 | _res = Py_None; |
| 618 | return _res; |
| 619 | } |
| 620 | |
| 621 | static PyObject *MenuObj_GetItemStyle(_self, _args) |
| 622 | MenuObject *_self; |
| 623 | PyObject *_args; |
| 624 | { |
| 625 | PyObject *_res = NULL; |
| 626 | short item; |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 627 | Style chStyle; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 628 | if (!PyArg_ParseTuple(_args, "h", |
| 629 | &item)) |
| 630 | return NULL; |
| 631 | GetItemStyle(_self->ob_itself, |
| 632 | item, |
| 633 | &chStyle); |
| 634 | _res = Py_BuildValue("b", |
| 635 | chStyle); |
| 636 | return _res; |
| 637 | } |
| 638 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 639 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 640 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 641 | static PyObject *MenuObj_DisableItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 642 | MenuObject *_self; |
| 643 | PyObject *_args; |
| 644 | { |
| 645 | PyObject *_res = NULL; |
| 646 | short item; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 647 | if (!PyArg_ParseTuple(_args, "h", |
| 648 | &item)) |
| 649 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 650 | DisableItem(_self->ob_itself, |
| 651 | item); |
| 652 | Py_INCREF(Py_None); |
| 653 | _res = Py_None; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 654 | return _res; |
| 655 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 656 | #endif |
| 657 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 658 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 659 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 660 | static PyObject *MenuObj_EnableItem(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 661 | MenuObject *_self; |
| 662 | PyObject *_args; |
| 663 | { |
| 664 | PyObject *_res = NULL; |
| 665 | short item; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 666 | if (!PyArg_ParseTuple(_args, "h", |
| 667 | &item)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 668 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 669 | EnableItem(_self->ob_itself, |
| 670 | item); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 671 | Py_INCREF(Py_None); |
| 672 | _res = Py_None; |
| 673 | return _res; |
| 674 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 675 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 676 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 677 | static PyObject *MenuObj_SetMenuItemCommandID(_self, _args) |
| 678 | MenuObject *_self; |
| 679 | PyObject *_args; |
| 680 | { |
| 681 | PyObject *_res = NULL; |
| 682 | OSErr _err; |
| 683 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 684 | MenuCommand inCommandID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 685 | if (!PyArg_ParseTuple(_args, "hl", |
| 686 | &inItem, |
| 687 | &inCommandID)) |
| 688 | return NULL; |
| 689 | _err = SetMenuItemCommandID(_self->ob_itself, |
| 690 | inItem, |
| 691 | inCommandID); |
| 692 | if (_err != noErr) return PyMac_Error(_err); |
| 693 | Py_INCREF(Py_None); |
| 694 | _res = Py_None; |
| 695 | return _res; |
| 696 | } |
| 697 | |
| 698 | static PyObject *MenuObj_GetMenuItemCommandID(_self, _args) |
| 699 | MenuObject *_self; |
| 700 | PyObject *_args; |
| 701 | { |
| 702 | PyObject *_res = NULL; |
| 703 | OSErr _err; |
| 704 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 705 | MenuCommand outCommandID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 706 | if (!PyArg_ParseTuple(_args, "h", |
| 707 | &inItem)) |
| 708 | return NULL; |
| 709 | _err = GetMenuItemCommandID(_self->ob_itself, |
| 710 | inItem, |
| 711 | &outCommandID); |
| 712 | if (_err != noErr) return PyMac_Error(_err); |
| 713 | _res = Py_BuildValue("l", |
| 714 | outCommandID); |
| 715 | return _res; |
| 716 | } |
| 717 | |
| 718 | static PyObject *MenuObj_SetMenuItemModifiers(_self, _args) |
| 719 | MenuObject *_self; |
| 720 | PyObject *_args; |
| 721 | { |
| 722 | PyObject *_res = NULL; |
| 723 | OSErr _err; |
| 724 | SInt16 inItem; |
| 725 | UInt8 inModifiers; |
| 726 | if (!PyArg_ParseTuple(_args, "hb", |
| 727 | &inItem, |
| 728 | &inModifiers)) |
| 729 | return NULL; |
| 730 | _err = SetMenuItemModifiers(_self->ob_itself, |
| 731 | inItem, |
| 732 | inModifiers); |
| 733 | if (_err != noErr) return PyMac_Error(_err); |
| 734 | Py_INCREF(Py_None); |
| 735 | _res = Py_None; |
| 736 | return _res; |
| 737 | } |
| 738 | |
| 739 | static PyObject *MenuObj_GetMenuItemModifiers(_self, _args) |
| 740 | MenuObject *_self; |
| 741 | PyObject *_args; |
| 742 | { |
| 743 | PyObject *_res = NULL; |
| 744 | OSErr _err; |
| 745 | SInt16 inItem; |
| 746 | UInt8 outModifiers; |
| 747 | if (!PyArg_ParseTuple(_args, "h", |
| 748 | &inItem)) |
| 749 | return NULL; |
| 750 | _err = GetMenuItemModifiers(_self->ob_itself, |
| 751 | inItem, |
| 752 | &outModifiers); |
| 753 | if (_err != noErr) return PyMac_Error(_err); |
| 754 | _res = Py_BuildValue("b", |
| 755 | outModifiers); |
| 756 | return _res; |
| 757 | } |
| 758 | |
| 759 | static PyObject *MenuObj_SetMenuItemIconHandle(_self, _args) |
| 760 | MenuObject *_self; |
| 761 | PyObject *_args; |
| 762 | { |
| 763 | PyObject *_res = NULL; |
| 764 | OSErr _err; |
| 765 | SInt16 inItem; |
| 766 | UInt8 inIconType; |
| 767 | Handle inIconHandle; |
| 768 | if (!PyArg_ParseTuple(_args, "hbO&", |
| 769 | &inItem, |
| 770 | &inIconType, |
| 771 | ResObj_Convert, &inIconHandle)) |
| 772 | return NULL; |
| 773 | _err = SetMenuItemIconHandle(_self->ob_itself, |
| 774 | inItem, |
| 775 | inIconType, |
| 776 | inIconHandle); |
| 777 | if (_err != noErr) return PyMac_Error(_err); |
| 778 | Py_INCREF(Py_None); |
| 779 | _res = Py_None; |
| 780 | return _res; |
| 781 | } |
| 782 | |
| 783 | static PyObject *MenuObj_GetMenuItemIconHandle(_self, _args) |
| 784 | MenuObject *_self; |
| 785 | PyObject *_args; |
| 786 | { |
| 787 | PyObject *_res = NULL; |
| 788 | OSErr _err; |
| 789 | SInt16 inItem; |
| 790 | UInt8 outIconType; |
| 791 | Handle outIconHandle; |
| 792 | if (!PyArg_ParseTuple(_args, "h", |
| 793 | &inItem)) |
| 794 | return NULL; |
| 795 | _err = GetMenuItemIconHandle(_self->ob_itself, |
| 796 | inItem, |
| 797 | &outIconType, |
| 798 | &outIconHandle); |
| 799 | if (_err != noErr) return PyMac_Error(_err); |
| 800 | _res = Py_BuildValue("bO&", |
| 801 | outIconType, |
| 802 | ResObj_New, outIconHandle); |
| 803 | return _res; |
| 804 | } |
| 805 | |
| 806 | static PyObject *MenuObj_SetMenuItemTextEncoding(_self, _args) |
| 807 | MenuObject *_self; |
| 808 | PyObject *_args; |
| 809 | { |
| 810 | PyObject *_res = NULL; |
| 811 | OSErr _err; |
| 812 | SInt16 inItem; |
| 813 | TextEncoding inScriptID; |
| 814 | if (!PyArg_ParseTuple(_args, "hl", |
| 815 | &inItem, |
| 816 | &inScriptID)) |
| 817 | return NULL; |
| 818 | _err = SetMenuItemTextEncoding(_self->ob_itself, |
| 819 | inItem, |
| 820 | inScriptID); |
| 821 | if (_err != noErr) return PyMac_Error(_err); |
| 822 | Py_INCREF(Py_None); |
| 823 | _res = Py_None; |
| 824 | return _res; |
| 825 | } |
| 826 | |
| 827 | static PyObject *MenuObj_GetMenuItemTextEncoding(_self, _args) |
| 828 | MenuObject *_self; |
| 829 | PyObject *_args; |
| 830 | { |
| 831 | PyObject *_res = NULL; |
| 832 | OSErr _err; |
| 833 | SInt16 inItem; |
| 834 | TextEncoding outScriptID; |
| 835 | if (!PyArg_ParseTuple(_args, "h", |
| 836 | &inItem)) |
| 837 | return NULL; |
| 838 | _err = GetMenuItemTextEncoding(_self->ob_itself, |
| 839 | inItem, |
| 840 | &outScriptID); |
| 841 | if (_err != noErr) return PyMac_Error(_err); |
| 842 | _res = Py_BuildValue("l", |
| 843 | outScriptID); |
| 844 | return _res; |
| 845 | } |
| 846 | |
| 847 | static PyObject *MenuObj_SetMenuItemHierarchicalID(_self, _args) |
| 848 | MenuObject *_self; |
| 849 | PyObject *_args; |
| 850 | { |
| 851 | PyObject *_res = NULL; |
| 852 | OSErr _err; |
| 853 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 854 | MenuID inHierID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 855 | if (!PyArg_ParseTuple(_args, "hh", |
| 856 | &inItem, |
| 857 | &inHierID)) |
| 858 | return NULL; |
| 859 | _err = SetMenuItemHierarchicalID(_self->ob_itself, |
| 860 | inItem, |
| 861 | inHierID); |
| 862 | if (_err != noErr) return PyMac_Error(_err); |
| 863 | Py_INCREF(Py_None); |
| 864 | _res = Py_None; |
| 865 | return _res; |
| 866 | } |
| 867 | |
| 868 | static PyObject *MenuObj_GetMenuItemHierarchicalID(_self, _args) |
| 869 | MenuObject *_self; |
| 870 | PyObject *_args; |
| 871 | { |
| 872 | PyObject *_res = NULL; |
| 873 | OSErr _err; |
| 874 | SInt16 inItem; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 875 | MenuID outHierID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 876 | if (!PyArg_ParseTuple(_args, "h", |
| 877 | &inItem)) |
| 878 | return NULL; |
| 879 | _err = GetMenuItemHierarchicalID(_self->ob_itself, |
| 880 | inItem, |
| 881 | &outHierID); |
| 882 | if (_err != noErr) return PyMac_Error(_err); |
| 883 | _res = Py_BuildValue("h", |
| 884 | outHierID); |
| 885 | return _res; |
| 886 | } |
| 887 | |
| 888 | static PyObject *MenuObj_SetMenuItemFontID(_self, _args) |
| 889 | MenuObject *_self; |
| 890 | PyObject *_args; |
| 891 | { |
| 892 | PyObject *_res = NULL; |
| 893 | OSErr _err; |
| 894 | SInt16 inItem; |
| 895 | SInt16 inFontID; |
| 896 | if (!PyArg_ParseTuple(_args, "hh", |
| 897 | &inItem, |
| 898 | &inFontID)) |
| 899 | return NULL; |
| 900 | _err = SetMenuItemFontID(_self->ob_itself, |
| 901 | inItem, |
| 902 | inFontID); |
| 903 | if (_err != noErr) return PyMac_Error(_err); |
| 904 | Py_INCREF(Py_None); |
| 905 | _res = Py_None; |
| 906 | return _res; |
| 907 | } |
| 908 | |
| 909 | static PyObject *MenuObj_GetMenuItemFontID(_self, _args) |
| 910 | MenuObject *_self; |
| 911 | PyObject *_args; |
| 912 | { |
| 913 | PyObject *_res = NULL; |
| 914 | OSErr _err; |
| 915 | SInt16 inItem; |
| 916 | SInt16 outFontID; |
| 917 | if (!PyArg_ParseTuple(_args, "h", |
| 918 | &inItem)) |
| 919 | return NULL; |
| 920 | _err = GetMenuItemFontID(_self->ob_itself, |
| 921 | inItem, |
| 922 | &outFontID); |
| 923 | if (_err != noErr) return PyMac_Error(_err); |
| 924 | _res = Py_BuildValue("h", |
| 925 | outFontID); |
| 926 | return _res; |
| 927 | } |
| 928 | |
| 929 | static PyObject *MenuObj_SetMenuItemRefCon(_self, _args) |
| 930 | MenuObject *_self; |
| 931 | PyObject *_args; |
| 932 | { |
| 933 | PyObject *_res = NULL; |
| 934 | OSErr _err; |
| 935 | SInt16 inItem; |
| 936 | UInt32 inRefCon; |
| 937 | if (!PyArg_ParseTuple(_args, "hl", |
| 938 | &inItem, |
| 939 | &inRefCon)) |
| 940 | return NULL; |
| 941 | _err = SetMenuItemRefCon(_self->ob_itself, |
| 942 | inItem, |
| 943 | inRefCon); |
| 944 | if (_err != noErr) return PyMac_Error(_err); |
| 945 | Py_INCREF(Py_None); |
| 946 | _res = Py_None; |
| 947 | return _res; |
| 948 | } |
| 949 | |
| 950 | static PyObject *MenuObj_GetMenuItemRefCon(_self, _args) |
| 951 | MenuObject *_self; |
| 952 | PyObject *_args; |
| 953 | { |
| 954 | PyObject *_res = NULL; |
| 955 | OSErr _err; |
| 956 | SInt16 inItem; |
| 957 | UInt32 outRefCon; |
| 958 | if (!PyArg_ParseTuple(_args, "h", |
| 959 | &inItem)) |
| 960 | return NULL; |
| 961 | _err = GetMenuItemRefCon(_self->ob_itself, |
| 962 | inItem, |
| 963 | &outRefCon); |
| 964 | if (_err != noErr) return PyMac_Error(_err); |
| 965 | _res = Py_BuildValue("l", |
| 966 | outRefCon); |
| 967 | return _res; |
| 968 | } |
| 969 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 970 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 971 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 972 | static PyObject *MenuObj_SetMenuItemRefCon2(_self, _args) |
| 973 | MenuObject *_self; |
| 974 | PyObject *_args; |
| 975 | { |
| 976 | PyObject *_res = NULL; |
| 977 | OSErr _err; |
| 978 | SInt16 inItem; |
| 979 | UInt32 inRefCon2; |
| 980 | if (!PyArg_ParseTuple(_args, "hl", |
| 981 | &inItem, |
| 982 | &inRefCon2)) |
| 983 | return NULL; |
| 984 | _err = SetMenuItemRefCon2(_self->ob_itself, |
| 985 | inItem, |
| 986 | inRefCon2); |
| 987 | if (_err != noErr) return PyMac_Error(_err); |
| 988 | Py_INCREF(Py_None); |
| 989 | _res = Py_None; |
| 990 | return _res; |
| 991 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 992 | #endif |
| 993 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 994 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 995 | |
| 996 | static PyObject *MenuObj_GetMenuItemRefCon2(_self, _args) |
| 997 | MenuObject *_self; |
| 998 | PyObject *_args; |
| 999 | { |
| 1000 | PyObject *_res = NULL; |
| 1001 | OSErr _err; |
| 1002 | SInt16 inItem; |
| 1003 | UInt32 outRefCon2; |
| 1004 | if (!PyArg_ParseTuple(_args, "h", |
| 1005 | &inItem)) |
| 1006 | return NULL; |
| 1007 | _err = GetMenuItemRefCon2(_self->ob_itself, |
| 1008 | inItem, |
| 1009 | &outRefCon2); |
| 1010 | if (_err != noErr) return PyMac_Error(_err); |
| 1011 | _res = Py_BuildValue("l", |
| 1012 | outRefCon2); |
| 1013 | return _res; |
| 1014 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1015 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1016 | |
| 1017 | static PyObject *MenuObj_SetMenuItemKeyGlyph(_self, _args) |
| 1018 | MenuObject *_self; |
| 1019 | PyObject *_args; |
| 1020 | { |
| 1021 | PyObject *_res = NULL; |
| 1022 | OSErr _err; |
| 1023 | SInt16 inItem; |
| 1024 | SInt16 inGlyph; |
| 1025 | if (!PyArg_ParseTuple(_args, "hh", |
| 1026 | &inItem, |
| 1027 | &inGlyph)) |
| 1028 | return NULL; |
| 1029 | _err = SetMenuItemKeyGlyph(_self->ob_itself, |
| 1030 | inItem, |
| 1031 | inGlyph); |
| 1032 | if (_err != noErr) return PyMac_Error(_err); |
| 1033 | Py_INCREF(Py_None); |
| 1034 | _res = Py_None; |
| 1035 | return _res; |
| 1036 | } |
| 1037 | |
| 1038 | static PyObject *MenuObj_GetMenuItemKeyGlyph(_self, _args) |
| 1039 | MenuObject *_self; |
| 1040 | PyObject *_args; |
| 1041 | { |
| 1042 | PyObject *_res = NULL; |
| 1043 | OSErr _err; |
| 1044 | SInt16 inItem; |
| 1045 | SInt16 outGlyph; |
| 1046 | if (!PyArg_ParseTuple(_args, "h", |
| 1047 | &inItem)) |
| 1048 | return NULL; |
| 1049 | _err = GetMenuItemKeyGlyph(_self->ob_itself, |
| 1050 | inItem, |
| 1051 | &outGlyph); |
| 1052 | if (_err != noErr) return PyMac_Error(_err); |
| 1053 | _res = Py_BuildValue("h", |
| 1054 | outGlyph); |
| 1055 | return _res; |
| 1056 | } |
| 1057 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1058 | static PyObject *MenuObj_MacEnableMenuItem(_self, _args) |
| 1059 | MenuObject *_self; |
| 1060 | PyObject *_args; |
| 1061 | { |
| 1062 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1063 | MenuItemIndex item; |
| 1064 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1065 | &item)) |
| 1066 | return NULL; |
| 1067 | MacEnableMenuItem(_self->ob_itself, |
| 1068 | item); |
| 1069 | Py_INCREF(Py_None); |
| 1070 | _res = Py_None; |
| 1071 | return _res; |
| 1072 | } |
| 1073 | |
| 1074 | static PyObject *MenuObj_DisableMenuItem(_self, _args) |
| 1075 | MenuObject *_self; |
| 1076 | PyObject *_args; |
| 1077 | { |
| 1078 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1079 | MenuItemIndex item; |
| 1080 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1081 | &item)) |
| 1082 | return NULL; |
| 1083 | DisableMenuItem(_self->ob_itself, |
| 1084 | item); |
| 1085 | Py_INCREF(Py_None); |
| 1086 | _res = Py_None; |
| 1087 | return _res; |
| 1088 | } |
| 1089 | |
| 1090 | static PyObject *MenuObj_IsMenuItemEnabled(_self, _args) |
| 1091 | MenuObject *_self; |
| 1092 | PyObject *_args; |
| 1093 | { |
| 1094 | PyObject *_res = NULL; |
| 1095 | Boolean _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1096 | MenuItemIndex item; |
| 1097 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1098 | &item)) |
| 1099 | return NULL; |
| 1100 | _rv = IsMenuItemEnabled(_self->ob_itself, |
| 1101 | item); |
| 1102 | _res = Py_BuildValue("b", |
| 1103 | _rv); |
| 1104 | return _res; |
| 1105 | } |
| 1106 | |
| 1107 | static PyObject *MenuObj_EnableMenuItemIcon(_self, _args) |
| 1108 | MenuObject *_self; |
| 1109 | PyObject *_args; |
| 1110 | { |
| 1111 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1112 | MenuItemIndex item; |
| 1113 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1114 | &item)) |
| 1115 | return NULL; |
| 1116 | EnableMenuItemIcon(_self->ob_itself, |
| 1117 | item); |
| 1118 | Py_INCREF(Py_None); |
| 1119 | _res = Py_None; |
| 1120 | return _res; |
| 1121 | } |
| 1122 | |
| 1123 | static PyObject *MenuObj_DisableMenuItemIcon(_self, _args) |
| 1124 | MenuObject *_self; |
| 1125 | PyObject *_args; |
| 1126 | { |
| 1127 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1128 | MenuItemIndex item; |
| 1129 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1130 | &item)) |
| 1131 | return NULL; |
| 1132 | DisableMenuItemIcon(_self->ob_itself, |
| 1133 | item); |
| 1134 | Py_INCREF(Py_None); |
| 1135 | _res = Py_None; |
| 1136 | return _res; |
| 1137 | } |
| 1138 | |
| 1139 | static PyObject *MenuObj_IsMenuItemIconEnabled(_self, _args) |
| 1140 | MenuObject *_self; |
| 1141 | PyObject *_args; |
| 1142 | { |
| 1143 | PyObject *_res = NULL; |
| 1144 | Boolean _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1145 | MenuItemIndex item; |
| 1146 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1147 | &item)) |
| 1148 | return NULL; |
| 1149 | _rv = IsMenuItemIconEnabled(_self->ob_itself, |
| 1150 | item); |
| 1151 | _res = Py_BuildValue("b", |
| 1152 | _rv); |
| 1153 | return _res; |
| 1154 | } |
| 1155 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1156 | #if TARGET_API_MAC_CARBON |
| 1157 | |
| 1158 | static PyObject *MenuObj_GetMenuItemPropertyAttributes(_self, _args) |
| 1159 | MenuObject *_self; |
| 1160 | PyObject *_args; |
| 1161 | { |
| 1162 | PyObject *_res = NULL; |
| 1163 | OSStatus _err; |
| 1164 | MenuItemIndex item; |
| 1165 | OSType propertyCreator; |
| 1166 | OSType propertyTag; |
| 1167 | UInt32 attributes; |
| 1168 | if (!PyArg_ParseTuple(_args, "hO&O&", |
| 1169 | &item, |
| 1170 | PyMac_GetOSType, &propertyCreator, |
| 1171 | PyMac_GetOSType, &propertyTag)) |
| 1172 | return NULL; |
| 1173 | _err = GetMenuItemPropertyAttributes(_self->ob_itself, |
| 1174 | item, |
| 1175 | propertyCreator, |
| 1176 | propertyTag, |
| 1177 | &attributes); |
| 1178 | if (_err != noErr) return PyMac_Error(_err); |
| 1179 | _res = Py_BuildValue("l", |
| 1180 | attributes); |
| 1181 | return _res; |
| 1182 | } |
| 1183 | #endif |
| 1184 | |
| 1185 | #if TARGET_API_MAC_CARBON |
| 1186 | |
| 1187 | static PyObject *MenuObj_ChangeMenuItemPropertyAttributes(_self, _args) |
| 1188 | MenuObject *_self; |
| 1189 | PyObject *_args; |
| 1190 | { |
| 1191 | PyObject *_res = NULL; |
| 1192 | OSStatus _err; |
| 1193 | MenuItemIndex item; |
| 1194 | OSType propertyCreator; |
| 1195 | OSType propertyTag; |
| 1196 | UInt32 attributesToSet; |
| 1197 | UInt32 attributesToClear; |
| 1198 | if (!PyArg_ParseTuple(_args, "hO&O&ll", |
| 1199 | &item, |
| 1200 | PyMac_GetOSType, &propertyCreator, |
| 1201 | PyMac_GetOSType, &propertyTag, |
| 1202 | &attributesToSet, |
| 1203 | &attributesToClear)) |
| 1204 | return NULL; |
| 1205 | _err = ChangeMenuItemPropertyAttributes(_self->ob_itself, |
| 1206 | item, |
| 1207 | propertyCreator, |
| 1208 | propertyTag, |
| 1209 | attributesToSet, |
| 1210 | attributesToClear); |
| 1211 | if (_err != noErr) return PyMac_Error(_err); |
| 1212 | Py_INCREF(Py_None); |
| 1213 | _res = Py_None; |
| 1214 | return _res; |
| 1215 | } |
| 1216 | #endif |
| 1217 | |
| 1218 | #if TARGET_API_MAC_CARBON |
| 1219 | |
| 1220 | static PyObject *MenuObj_GetMenuAttributes(_self, _args) |
| 1221 | MenuObject *_self; |
| 1222 | PyObject *_args; |
| 1223 | { |
| 1224 | PyObject *_res = NULL; |
| 1225 | OSStatus _err; |
| 1226 | MenuAttributes outAttributes; |
| 1227 | if (!PyArg_ParseTuple(_args, "")) |
| 1228 | return NULL; |
| 1229 | _err = GetMenuAttributes(_self->ob_itself, |
| 1230 | &outAttributes); |
| 1231 | if (_err != noErr) return PyMac_Error(_err); |
| 1232 | _res = Py_BuildValue("l", |
| 1233 | outAttributes); |
| 1234 | return _res; |
| 1235 | } |
| 1236 | #endif |
| 1237 | |
| 1238 | #if TARGET_API_MAC_CARBON |
| 1239 | |
| 1240 | static PyObject *MenuObj_ChangeMenuAttributes(_self, _args) |
| 1241 | MenuObject *_self; |
| 1242 | PyObject *_args; |
| 1243 | { |
| 1244 | PyObject *_res = NULL; |
| 1245 | OSStatus _err; |
| 1246 | MenuAttributes setTheseAttributes; |
| 1247 | MenuAttributes clearTheseAttributes; |
| 1248 | if (!PyArg_ParseTuple(_args, "ll", |
| 1249 | &setTheseAttributes, |
| 1250 | &clearTheseAttributes)) |
| 1251 | return NULL; |
| 1252 | _err = ChangeMenuAttributes(_self->ob_itself, |
| 1253 | setTheseAttributes, |
| 1254 | clearTheseAttributes); |
| 1255 | if (_err != noErr) return PyMac_Error(_err); |
| 1256 | Py_INCREF(Py_None); |
| 1257 | _res = Py_None; |
| 1258 | return _res; |
| 1259 | } |
| 1260 | #endif |
| 1261 | |
| 1262 | #if TARGET_API_MAC_CARBON |
| 1263 | |
| 1264 | static PyObject *MenuObj_GetMenuItemAttributes(_self, _args) |
| 1265 | MenuObject *_self; |
| 1266 | PyObject *_args; |
| 1267 | { |
| 1268 | PyObject *_res = NULL; |
| 1269 | OSStatus _err; |
| 1270 | MenuItemIndex item; |
| 1271 | MenuItemAttributes outAttributes; |
| 1272 | if (!PyArg_ParseTuple(_args, "h", |
| 1273 | &item)) |
| 1274 | return NULL; |
| 1275 | _err = GetMenuItemAttributes(_self->ob_itself, |
| 1276 | item, |
| 1277 | &outAttributes); |
| 1278 | if (_err != noErr) return PyMac_Error(_err); |
| 1279 | _res = Py_BuildValue("l", |
| 1280 | outAttributes); |
| 1281 | return _res; |
| 1282 | } |
| 1283 | #endif |
| 1284 | |
| 1285 | #if TARGET_API_MAC_CARBON |
| 1286 | |
| 1287 | static PyObject *MenuObj_ChangeMenuItemAttributes(_self, _args) |
| 1288 | MenuObject *_self; |
| 1289 | PyObject *_args; |
| 1290 | { |
| 1291 | PyObject *_res = NULL; |
| 1292 | OSStatus _err; |
| 1293 | MenuItemIndex item; |
| 1294 | MenuItemAttributes setTheseAttributes; |
| 1295 | MenuItemAttributes clearTheseAttributes; |
| 1296 | if (!PyArg_ParseTuple(_args, "hll", |
| 1297 | &item, |
| 1298 | &setTheseAttributes, |
| 1299 | &clearTheseAttributes)) |
| 1300 | return NULL; |
| 1301 | _err = ChangeMenuItemAttributes(_self->ob_itself, |
| 1302 | item, |
| 1303 | setTheseAttributes, |
| 1304 | clearTheseAttributes); |
| 1305 | if (_err != noErr) return PyMac_Error(_err); |
| 1306 | Py_INCREF(Py_None); |
| 1307 | _res = Py_None; |
| 1308 | return _res; |
| 1309 | } |
| 1310 | #endif |
| 1311 | |
| 1312 | #if TARGET_API_MAC_CARBON |
| 1313 | |
| 1314 | static PyObject *MenuObj_DisableAllMenuItems(_self, _args) |
| 1315 | MenuObject *_self; |
| 1316 | PyObject *_args; |
| 1317 | { |
| 1318 | PyObject *_res = NULL; |
| 1319 | if (!PyArg_ParseTuple(_args, "")) |
| 1320 | return NULL; |
| 1321 | DisableAllMenuItems(_self->ob_itself); |
| 1322 | Py_INCREF(Py_None); |
| 1323 | _res = Py_None; |
| 1324 | return _res; |
| 1325 | } |
| 1326 | #endif |
| 1327 | |
| 1328 | #if TARGET_API_MAC_CARBON |
| 1329 | |
| 1330 | static PyObject *MenuObj_EnableAllMenuItems(_self, _args) |
| 1331 | MenuObject *_self; |
| 1332 | PyObject *_args; |
| 1333 | { |
| 1334 | PyObject *_res = NULL; |
| 1335 | if (!PyArg_ParseTuple(_args, "")) |
| 1336 | return NULL; |
| 1337 | EnableAllMenuItems(_self->ob_itself); |
| 1338 | Py_INCREF(Py_None); |
| 1339 | _res = Py_None; |
| 1340 | return _res; |
| 1341 | } |
| 1342 | #endif |
| 1343 | |
| 1344 | #if TARGET_API_MAC_CARBON |
| 1345 | |
| 1346 | static PyObject *MenuObj_MenuHasEnabledItems(_self, _args) |
| 1347 | MenuObject *_self; |
| 1348 | PyObject *_args; |
| 1349 | { |
| 1350 | PyObject *_res = NULL; |
| 1351 | Boolean _rv; |
| 1352 | if (!PyArg_ParseTuple(_args, "")) |
| 1353 | return NULL; |
| 1354 | _rv = MenuHasEnabledItems(_self->ob_itself); |
| 1355 | _res = Py_BuildValue("b", |
| 1356 | _rv); |
| 1357 | return _res; |
| 1358 | } |
| 1359 | #endif |
| 1360 | |
| 1361 | #if TARGET_API_MAC_CARBON |
| 1362 | |
| 1363 | static PyObject *MenuObj_CountMenuItemsWithCommandID(_self, _args) |
| 1364 | MenuObject *_self; |
| 1365 | PyObject *_args; |
| 1366 | { |
| 1367 | PyObject *_res = NULL; |
| 1368 | ItemCount _rv; |
| 1369 | MenuCommand commandID; |
| 1370 | if (!PyArg_ParseTuple(_args, "l", |
| 1371 | &commandID)) |
| 1372 | return NULL; |
| 1373 | _rv = CountMenuItemsWithCommandID(_self->ob_itself, |
| 1374 | commandID); |
| 1375 | _res = Py_BuildValue("l", |
| 1376 | _rv); |
| 1377 | return _res; |
| 1378 | } |
| 1379 | #endif |
| 1380 | |
| 1381 | #if TARGET_API_MAC_CARBON |
| 1382 | |
| 1383 | static PyObject *MenuObj_GetIndMenuItemWithCommandID(_self, _args) |
| 1384 | MenuObject *_self; |
| 1385 | PyObject *_args; |
| 1386 | { |
| 1387 | PyObject *_res = NULL; |
| 1388 | OSStatus _err; |
| 1389 | MenuCommand commandID; |
| 1390 | UInt32 itemIndex; |
| 1391 | MenuHandle outMenu; |
| 1392 | MenuItemIndex outIndex; |
| 1393 | if (!PyArg_ParseTuple(_args, "ll", |
| 1394 | &commandID, |
| 1395 | &itemIndex)) |
| 1396 | return NULL; |
| 1397 | _err = GetIndMenuItemWithCommandID(_self->ob_itself, |
| 1398 | commandID, |
| 1399 | itemIndex, |
| 1400 | &outMenu, |
| 1401 | &outIndex); |
| 1402 | if (_err != noErr) return PyMac_Error(_err); |
| 1403 | _res = Py_BuildValue("O&h", |
| 1404 | MenuObj_New, outMenu, |
| 1405 | outIndex); |
| 1406 | return _res; |
| 1407 | } |
| 1408 | #endif |
| 1409 | |
| 1410 | #if TARGET_API_MAC_CARBON |
| 1411 | |
| 1412 | static PyObject *MenuObj_EnableMenuCommand(_self, _args) |
| 1413 | MenuObject *_self; |
| 1414 | PyObject *_args; |
| 1415 | { |
| 1416 | PyObject *_res = NULL; |
| 1417 | MenuCommand commandID; |
| 1418 | if (!PyArg_ParseTuple(_args, "l", |
| 1419 | &commandID)) |
| 1420 | return NULL; |
| 1421 | EnableMenuCommand(_self->ob_itself, |
| 1422 | commandID); |
| 1423 | Py_INCREF(Py_None); |
| 1424 | _res = Py_None; |
| 1425 | return _res; |
| 1426 | } |
| 1427 | #endif |
| 1428 | |
| 1429 | #if TARGET_API_MAC_CARBON |
| 1430 | |
| 1431 | static PyObject *MenuObj_DisableMenuCommand(_self, _args) |
| 1432 | MenuObject *_self; |
| 1433 | PyObject *_args; |
| 1434 | { |
| 1435 | PyObject *_res = NULL; |
| 1436 | MenuCommand commandID; |
| 1437 | if (!PyArg_ParseTuple(_args, "l", |
| 1438 | &commandID)) |
| 1439 | return NULL; |
| 1440 | DisableMenuCommand(_self->ob_itself, |
| 1441 | commandID); |
| 1442 | Py_INCREF(Py_None); |
| 1443 | _res = Py_None; |
| 1444 | return _res; |
| 1445 | } |
| 1446 | #endif |
| 1447 | |
| 1448 | #if TARGET_API_MAC_CARBON |
| 1449 | |
| 1450 | static PyObject *MenuObj_IsMenuCommandEnabled(_self, _args) |
| 1451 | MenuObject *_self; |
| 1452 | PyObject *_args; |
| 1453 | { |
| 1454 | PyObject *_res = NULL; |
| 1455 | Boolean _rv; |
| 1456 | MenuCommand commandID; |
| 1457 | if (!PyArg_ParseTuple(_args, "l", |
| 1458 | &commandID)) |
| 1459 | return NULL; |
| 1460 | _rv = IsMenuCommandEnabled(_self->ob_itself, |
| 1461 | commandID); |
| 1462 | _res = Py_BuildValue("b", |
| 1463 | _rv); |
| 1464 | return _res; |
| 1465 | } |
| 1466 | #endif |
| 1467 | |
| 1468 | #if TARGET_API_MAC_CARBON |
| 1469 | |
| 1470 | static PyObject *MenuObj_GetMenuCommandPropertySize(_self, _args) |
| 1471 | MenuObject *_self; |
| 1472 | PyObject *_args; |
| 1473 | { |
| 1474 | PyObject *_res = NULL; |
| 1475 | OSStatus _err; |
| 1476 | MenuCommand commandID; |
| 1477 | OSType propertyCreator; |
| 1478 | OSType propertyTag; |
| 1479 | ByteCount size; |
| 1480 | if (!PyArg_ParseTuple(_args, "lO&O&", |
| 1481 | &commandID, |
| 1482 | PyMac_GetOSType, &propertyCreator, |
| 1483 | PyMac_GetOSType, &propertyTag)) |
| 1484 | return NULL; |
| 1485 | _err = GetMenuCommandPropertySize(_self->ob_itself, |
| 1486 | commandID, |
| 1487 | propertyCreator, |
| 1488 | propertyTag, |
| 1489 | &size); |
| 1490 | if (_err != noErr) return PyMac_Error(_err); |
| 1491 | _res = Py_BuildValue("l", |
| 1492 | size); |
| 1493 | return _res; |
| 1494 | } |
| 1495 | #endif |
| 1496 | |
| 1497 | #if TARGET_API_MAC_CARBON |
| 1498 | |
| 1499 | static PyObject *MenuObj_RemoveMenuCommandProperty(_self, _args) |
| 1500 | MenuObject *_self; |
| 1501 | PyObject *_args; |
| 1502 | { |
| 1503 | PyObject *_res = NULL; |
| 1504 | OSStatus _err; |
| 1505 | MenuCommand commandID; |
| 1506 | OSType propertyCreator; |
| 1507 | OSType propertyTag; |
| 1508 | if (!PyArg_ParseTuple(_args, "lO&O&", |
| 1509 | &commandID, |
| 1510 | PyMac_GetOSType, &propertyCreator, |
| 1511 | PyMac_GetOSType, &propertyTag)) |
| 1512 | return NULL; |
| 1513 | _err = RemoveMenuCommandProperty(_self->ob_itself, |
| 1514 | commandID, |
| 1515 | propertyCreator, |
| 1516 | propertyTag); |
| 1517 | if (_err != noErr) return PyMac_Error(_err); |
| 1518 | Py_INCREF(Py_None); |
| 1519 | _res = Py_None; |
| 1520 | return _res; |
| 1521 | } |
| 1522 | #endif |
| 1523 | |
| 1524 | #if TARGET_API_MAC_CARBON |
| 1525 | |
| 1526 | static PyObject *MenuObj_CreateStandardFontMenu(_self, _args) |
| 1527 | MenuObject *_self; |
| 1528 | PyObject *_args; |
| 1529 | { |
| 1530 | PyObject *_res = NULL; |
| 1531 | OSStatus _err; |
| 1532 | MenuItemIndex afterItem; |
| 1533 | MenuID firstHierMenuID; |
| 1534 | OptionBits options; |
| 1535 | ItemCount outHierMenuCount; |
| 1536 | if (!PyArg_ParseTuple(_args, "hhl", |
| 1537 | &afterItem, |
| 1538 | &firstHierMenuID, |
| 1539 | &options)) |
| 1540 | return NULL; |
| 1541 | _err = CreateStandardFontMenu(_self->ob_itself, |
| 1542 | afterItem, |
| 1543 | firstHierMenuID, |
| 1544 | options, |
| 1545 | &outHierMenuCount); |
| 1546 | if (_err != noErr) return PyMac_Error(_err); |
| 1547 | _res = Py_BuildValue("l", |
| 1548 | outHierMenuCount); |
| 1549 | return _res; |
| 1550 | } |
| 1551 | #endif |
| 1552 | |
| 1553 | #if TARGET_API_MAC_CARBON |
| 1554 | |
| 1555 | static PyObject *MenuObj_UpdateStandardFontMenu(_self, _args) |
| 1556 | MenuObject *_self; |
| 1557 | PyObject *_args; |
| 1558 | { |
| 1559 | PyObject *_res = NULL; |
| 1560 | OSStatus _err; |
| 1561 | ItemCount outHierMenuCount; |
| 1562 | if (!PyArg_ParseTuple(_args, "")) |
| 1563 | return NULL; |
| 1564 | _err = UpdateStandardFontMenu(_self->ob_itself, |
| 1565 | &outHierMenuCount); |
| 1566 | if (_err != noErr) return PyMac_Error(_err); |
| 1567 | _res = Py_BuildValue("l", |
| 1568 | outHierMenuCount); |
| 1569 | return _res; |
| 1570 | } |
| 1571 | #endif |
| 1572 | |
| 1573 | #if TARGET_API_MAC_CARBON |
| 1574 | |
| 1575 | static PyObject *MenuObj_GetFontFamilyFromMenuSelection(_self, _args) |
| 1576 | MenuObject *_self; |
| 1577 | PyObject *_args; |
| 1578 | { |
| 1579 | PyObject *_res = NULL; |
| 1580 | OSStatus _err; |
| 1581 | MenuItemIndex item; |
| 1582 | FMFontFamily outFontFamily; |
| 1583 | FMFontStyle outStyle; |
| 1584 | if (!PyArg_ParseTuple(_args, "h", |
| 1585 | &item)) |
| 1586 | return NULL; |
| 1587 | _err = GetFontFamilyFromMenuSelection(_self->ob_itself, |
| 1588 | item, |
| 1589 | &outFontFamily, |
| 1590 | &outStyle); |
| 1591 | if (_err != noErr) return PyMac_Error(_err); |
| 1592 | _res = Py_BuildValue("hh", |
| 1593 | outFontFamily, |
| 1594 | outStyle); |
| 1595 | return _res; |
| 1596 | } |
| 1597 | #endif |
| 1598 | |
| 1599 | static PyObject *MenuObj_GetMenuID(_self, _args) |
| 1600 | MenuObject *_self; |
| 1601 | PyObject *_args; |
| 1602 | { |
| 1603 | PyObject *_res = NULL; |
| 1604 | MenuID _rv; |
| 1605 | if (!PyArg_ParseTuple(_args, "")) |
| 1606 | return NULL; |
| 1607 | _rv = GetMenuID(_self->ob_itself); |
| 1608 | _res = Py_BuildValue("h", |
| 1609 | _rv); |
| 1610 | return _res; |
| 1611 | } |
| 1612 | |
| 1613 | static PyObject *MenuObj_GetMenuWidth(_self, _args) |
| 1614 | MenuObject *_self; |
| 1615 | PyObject *_args; |
| 1616 | { |
| 1617 | PyObject *_res = NULL; |
| 1618 | SInt16 _rv; |
| 1619 | if (!PyArg_ParseTuple(_args, "")) |
| 1620 | return NULL; |
| 1621 | _rv = GetMenuWidth(_self->ob_itself); |
| 1622 | _res = Py_BuildValue("h", |
| 1623 | _rv); |
| 1624 | return _res; |
| 1625 | } |
| 1626 | |
| 1627 | static PyObject *MenuObj_GetMenuHeight(_self, _args) |
| 1628 | MenuObject *_self; |
| 1629 | PyObject *_args; |
| 1630 | { |
| 1631 | PyObject *_res = NULL; |
| 1632 | SInt16 _rv; |
| 1633 | if (!PyArg_ParseTuple(_args, "")) |
| 1634 | return NULL; |
| 1635 | _rv = GetMenuHeight(_self->ob_itself); |
| 1636 | _res = Py_BuildValue("h", |
| 1637 | _rv); |
| 1638 | return _res; |
| 1639 | } |
| 1640 | |
| 1641 | static PyObject *MenuObj_SetMenuID(_self, _args) |
| 1642 | MenuObject *_self; |
| 1643 | PyObject *_args; |
| 1644 | { |
| 1645 | PyObject *_res = NULL; |
| 1646 | MenuID menuID; |
| 1647 | if (!PyArg_ParseTuple(_args, "h", |
| 1648 | &menuID)) |
| 1649 | return NULL; |
| 1650 | SetMenuID(_self->ob_itself, |
| 1651 | menuID); |
| 1652 | Py_INCREF(Py_None); |
| 1653 | _res = Py_None; |
| 1654 | return _res; |
| 1655 | } |
| 1656 | |
| 1657 | static PyObject *MenuObj_SetMenuWidth(_self, _args) |
| 1658 | MenuObject *_self; |
| 1659 | PyObject *_args; |
| 1660 | { |
| 1661 | PyObject *_res = NULL; |
| 1662 | SInt16 width; |
| 1663 | if (!PyArg_ParseTuple(_args, "h", |
| 1664 | &width)) |
| 1665 | return NULL; |
| 1666 | SetMenuWidth(_self->ob_itself, |
| 1667 | width); |
| 1668 | Py_INCREF(Py_None); |
| 1669 | _res = Py_None; |
| 1670 | return _res; |
| 1671 | } |
| 1672 | |
| 1673 | static PyObject *MenuObj_SetMenuHeight(_self, _args) |
| 1674 | MenuObject *_self; |
| 1675 | PyObject *_args; |
| 1676 | { |
| 1677 | PyObject *_res = NULL; |
| 1678 | SInt16 height; |
| 1679 | if (!PyArg_ParseTuple(_args, "h", |
| 1680 | &height)) |
| 1681 | return NULL; |
| 1682 | SetMenuHeight(_self->ob_itself, |
| 1683 | height); |
| 1684 | Py_INCREF(Py_None); |
| 1685 | _res = Py_None; |
| 1686 | return _res; |
| 1687 | } |
| 1688 | |
Jack Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1689 | static PyObject *MenuObj_as_Resource(_self, _args) |
| 1690 | MenuObject *_self; |
| 1691 | PyObject *_args; |
| 1692 | { |
| 1693 | PyObject *_res = NULL; |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 1694 | Handle _rv; |
| 1695 | if (!PyArg_ParseTuple(_args, "")) |
| 1696 | return NULL; |
| 1697 | _rv = as_Resource(_self->ob_itself); |
| 1698 | _res = Py_BuildValue("O&", |
| 1699 | ResObj_New, _rv); |
| 1700 | return _res; |
Jack Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 1701 | } |
| 1702 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1703 | static PyObject *MenuObj_AppendMenu(_self, _args) |
| 1704 | MenuObject *_self; |
| 1705 | PyObject *_args; |
| 1706 | { |
| 1707 | PyObject *_res = NULL; |
| 1708 | Str255 data; |
| 1709 | if (!PyArg_ParseTuple(_args, "O&", |
| 1710 | PyMac_GetStr255, data)) |
| 1711 | return NULL; |
| 1712 | AppendMenu(_self->ob_itself, |
| 1713 | data); |
| 1714 | Py_INCREF(Py_None); |
| 1715 | _res = Py_None; |
| 1716 | return _res; |
| 1717 | } |
| 1718 | |
| 1719 | static PyObject *MenuObj_InsertMenu(_self, _args) |
| 1720 | MenuObject *_self; |
| 1721 | PyObject *_args; |
| 1722 | { |
| 1723 | PyObject *_res = NULL; |
| 1724 | short beforeID; |
| 1725 | if (!PyArg_ParseTuple(_args, "h", |
| 1726 | &beforeID)) |
| 1727 | return NULL; |
| 1728 | InsertMenu(_self->ob_itself, |
| 1729 | beforeID); |
| 1730 | Py_INCREF(Py_None); |
| 1731 | _res = Py_None; |
| 1732 | return _res; |
| 1733 | } |
| 1734 | |
| 1735 | static PyObject *MenuObj_InsertMenuItem(_self, _args) |
| 1736 | MenuObject *_self; |
| 1737 | PyObject *_args; |
| 1738 | { |
| 1739 | PyObject *_res = NULL; |
| 1740 | Str255 itemString; |
| 1741 | short afterItem; |
| 1742 | if (!PyArg_ParseTuple(_args, "O&h", |
| 1743 | PyMac_GetStr255, itemString, |
| 1744 | &afterItem)) |
| 1745 | return NULL; |
| 1746 | InsertMenuItem(_self->ob_itself, |
| 1747 | itemString, |
| 1748 | afterItem); |
| 1749 | Py_INCREF(Py_None); |
| 1750 | _res = Py_None; |
| 1751 | return _res; |
| 1752 | } |
| 1753 | |
Jack Jansen | 54c0787 | 2001-01-29 13:32:10 +0000 | [diff] [blame] | 1754 | static PyObject *MenuObj_EnableMenuItem(_self, _args) |
| 1755 | MenuObject *_self; |
| 1756 | PyObject *_args; |
| 1757 | { |
| 1758 | PyObject *_res = NULL; |
| 1759 | UInt16 item; |
| 1760 | if (!PyArg_ParseTuple(_args, "H", |
| 1761 | &item)) |
| 1762 | return NULL; |
| 1763 | EnableMenuItem(_self->ob_itself, |
| 1764 | item); |
| 1765 | Py_INCREF(Py_None); |
| 1766 | _res = Py_None; |
| 1767 | return _res; |
| 1768 | } |
| 1769 | |
| 1770 | static PyObject *MenuObj_CheckMenuItem(_self, _args) |
| 1771 | MenuObject *_self; |
| 1772 | PyObject *_args; |
| 1773 | { |
| 1774 | PyObject *_res = NULL; |
| 1775 | short item; |
| 1776 | Boolean checked; |
| 1777 | if (!PyArg_ParseTuple(_args, "hb", |
| 1778 | &item, |
| 1779 | &checked)) |
| 1780 | return NULL; |
| 1781 | CheckMenuItem(_self->ob_itself, |
| 1782 | item, |
| 1783 | checked); |
| 1784 | Py_INCREF(Py_None); |
| 1785 | _res = Py_None; |
| 1786 | return _res; |
| 1787 | } |
| 1788 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1789 | static PyMethodDef MenuObj_methods[] = { |
| 1790 | {"DisposeMenu", (PyCFunction)MenuObj_DisposeMenu, 1, |
| 1791 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1792 | {"CalcMenuSize", (PyCFunction)MenuObj_CalcMenuSize, 1, |
| 1793 | "() -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1794 | {"CountMenuItems", (PyCFunction)MenuObj_CountMenuItems, 1, |
| 1795 | "() -> (short _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1796 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1797 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1798 | {"CountMItems", (PyCFunction)MenuObj_CountMItems, 1, |
| 1799 | "() -> (short _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1800 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1801 | {"GetMenuFont", (PyCFunction)MenuObj_GetMenuFont, 1, |
| 1802 | "() -> (SInt16 outFontID, UInt16 outFontSize)"}, |
| 1803 | {"SetMenuFont", (PyCFunction)MenuObj_SetMenuFont, 1, |
| 1804 | "(SInt16 inFontID, UInt16 inFontSize) -> None"}, |
| 1805 | {"GetMenuExcludesMarkColumn", (PyCFunction)MenuObj_GetMenuExcludesMarkColumn, 1, |
| 1806 | "() -> (Boolean _rv)"}, |
| 1807 | {"SetMenuExcludesMarkColumn", (PyCFunction)MenuObj_SetMenuExcludesMarkColumn, 1, |
| 1808 | "(Boolean excludesMark) -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1809 | {"MacAppendMenu", (PyCFunction)MenuObj_MacAppendMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1810 | "(Str255 data) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1811 | {"InsertResMenu", (PyCFunction)MenuObj_InsertResMenu, 1, |
| 1812 | "(ResType theType, short afterItem) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1813 | {"AppendResMenu", (PyCFunction)MenuObj_AppendResMenu, 1, |
| 1814 | "(ResType theType) -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1815 | {"MacInsertMenuItem", (PyCFunction)MenuObj_MacInsertMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1816 | "(Str255 itemString, short afterItem) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1817 | {"DeleteMenuItem", (PyCFunction)MenuObj_DeleteMenuItem, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1818 | "(short item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1819 | {"InsertFontResMenu", (PyCFunction)MenuObj_InsertFontResMenu, 1, |
| 1820 | "(short afterItem, short scriptFilter) -> None"}, |
| 1821 | {"InsertIntlResMenu", (PyCFunction)MenuObj_InsertIntlResMenu, 1, |
| 1822 | "(ResType theType, short afterItem, short scriptFilter) -> None"}, |
| 1823 | {"AppendMenuItemText", (PyCFunction)MenuObj_AppendMenuItemText, 1, |
| 1824 | "(Str255 inString) -> None"}, |
| 1825 | {"InsertMenuItemText", (PyCFunction)MenuObj_InsertMenuItemText, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1826 | "(Str255 inString, MenuItemIndex afterItem) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1827 | {"PopUpMenuSelect", (PyCFunction)MenuObj_PopUpMenuSelect, 1, |
| 1828 | "(short top, short left, short popUpItem) -> (long _rv)"}, |
| 1829 | {"MacInsertMenu", (PyCFunction)MenuObj_MacInsertMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1830 | "(MenuID beforeID) -> None"}, |
| 1831 | {"MacCheckMenuItem", (PyCFunction)MenuObj_MacCheckMenuItem, 1, |
| 1832 | "(short item, Boolean checked) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1833 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1834 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1835 | {"CheckItem", (PyCFunction)MenuObj_CheckItem, 1, |
| 1836 | "(short item, Boolean checked) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1837 | #endif |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1838 | {"SetMenuItemText", (PyCFunction)MenuObj_SetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1839 | "(short item, Str255 itemString) -> None"}, |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 1840 | {"GetMenuItemText", (PyCFunction)MenuObj_GetMenuItemText, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1841 | "(short item) -> (Str255 itemString)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1842 | {"SetItemMark", (PyCFunction)MenuObj_SetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1843 | "(short item, CharParameter markChar) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1844 | {"GetItemMark", (PyCFunction)MenuObj_GetItemMark, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1845 | "(short item) -> (CharParameter markChar)"}, |
| 1846 | {"SetItemCmd", (PyCFunction)MenuObj_SetItemCmd, 1, |
| 1847 | "(short item, CharParameter cmdChar) -> None"}, |
| 1848 | {"GetItemCmd", (PyCFunction)MenuObj_GetItemCmd, 1, |
| 1849 | "(short item) -> (CharParameter cmdChar)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1850 | {"SetItemIcon", (PyCFunction)MenuObj_SetItemIcon, 1, |
| 1851 | "(short item, short iconIndex) -> None"}, |
| 1852 | {"GetItemIcon", (PyCFunction)MenuObj_GetItemIcon, 1, |
| 1853 | "(short item) -> (short iconIndex)"}, |
| 1854 | {"SetItemStyle", (PyCFunction)MenuObj_SetItemStyle, 1, |
Jack Jansen | d6b6d88 | 1998-02-25 15:45:21 +0000 | [diff] [blame] | 1855 | "(short item, StyleParameter chStyle) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1856 | {"GetItemStyle", (PyCFunction)MenuObj_GetItemStyle, 1, |
Jack Jansen | 7d0bc83 | 1995-06-09 20:56:31 +0000 | [diff] [blame] | 1857 | "(short item) -> (Style chStyle)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1858 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1859 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1860 | {"DisableItem", (PyCFunction)MenuObj_DisableItem, 1, |
| 1861 | "(short item) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1862 | #endif |
| 1863 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1864 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1865 | {"EnableItem", (PyCFunction)MenuObj_EnableItem, 1, |
| 1866 | "(short item) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1867 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1868 | {"SetMenuItemCommandID", (PyCFunction)MenuObj_SetMenuItemCommandID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1869 | "(SInt16 inItem, MenuCommand inCommandID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1870 | {"GetMenuItemCommandID", (PyCFunction)MenuObj_GetMenuItemCommandID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1871 | "(SInt16 inItem) -> (MenuCommand outCommandID)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1872 | {"SetMenuItemModifiers", (PyCFunction)MenuObj_SetMenuItemModifiers, 1, |
| 1873 | "(SInt16 inItem, UInt8 inModifiers) -> None"}, |
| 1874 | {"GetMenuItemModifiers", (PyCFunction)MenuObj_GetMenuItemModifiers, 1, |
| 1875 | "(SInt16 inItem) -> (UInt8 outModifiers)"}, |
| 1876 | {"SetMenuItemIconHandle", (PyCFunction)MenuObj_SetMenuItemIconHandle, 1, |
| 1877 | "(SInt16 inItem, UInt8 inIconType, Handle inIconHandle) -> None"}, |
| 1878 | {"GetMenuItemIconHandle", (PyCFunction)MenuObj_GetMenuItemIconHandle, 1, |
| 1879 | "(SInt16 inItem) -> (UInt8 outIconType, Handle outIconHandle)"}, |
| 1880 | {"SetMenuItemTextEncoding", (PyCFunction)MenuObj_SetMenuItemTextEncoding, 1, |
| 1881 | "(SInt16 inItem, TextEncoding inScriptID) -> None"}, |
| 1882 | {"GetMenuItemTextEncoding", (PyCFunction)MenuObj_GetMenuItemTextEncoding, 1, |
| 1883 | "(SInt16 inItem) -> (TextEncoding outScriptID)"}, |
| 1884 | {"SetMenuItemHierarchicalID", (PyCFunction)MenuObj_SetMenuItemHierarchicalID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1885 | "(SInt16 inItem, MenuID inHierID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1886 | {"GetMenuItemHierarchicalID", (PyCFunction)MenuObj_GetMenuItemHierarchicalID, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1887 | "(SInt16 inItem) -> (MenuID outHierID)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1888 | {"SetMenuItemFontID", (PyCFunction)MenuObj_SetMenuItemFontID, 1, |
| 1889 | "(SInt16 inItem, SInt16 inFontID) -> None"}, |
| 1890 | {"GetMenuItemFontID", (PyCFunction)MenuObj_GetMenuItemFontID, 1, |
| 1891 | "(SInt16 inItem) -> (SInt16 outFontID)"}, |
| 1892 | {"SetMenuItemRefCon", (PyCFunction)MenuObj_SetMenuItemRefCon, 1, |
| 1893 | "(SInt16 inItem, UInt32 inRefCon) -> None"}, |
| 1894 | {"GetMenuItemRefCon", (PyCFunction)MenuObj_GetMenuItemRefCon, 1, |
| 1895 | "(SInt16 inItem) -> (UInt32 outRefCon)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1896 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1897 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1898 | {"SetMenuItemRefCon2", (PyCFunction)MenuObj_SetMenuItemRefCon2, 1, |
| 1899 | "(SInt16 inItem, UInt32 inRefCon2) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1900 | #endif |
| 1901 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1902 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1903 | {"GetMenuItemRefCon2", (PyCFunction)MenuObj_GetMenuItemRefCon2, 1, |
| 1904 | "(SInt16 inItem) -> (UInt32 outRefCon2)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1905 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1906 | {"SetMenuItemKeyGlyph", (PyCFunction)MenuObj_SetMenuItemKeyGlyph, 1, |
| 1907 | "(SInt16 inItem, SInt16 inGlyph) -> None"}, |
| 1908 | {"GetMenuItemKeyGlyph", (PyCFunction)MenuObj_GetMenuItemKeyGlyph, 1, |
| 1909 | "(SInt16 inItem) -> (SInt16 outGlyph)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1910 | {"MacEnableMenuItem", (PyCFunction)MenuObj_MacEnableMenuItem, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1911 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1912 | {"DisableMenuItem", (PyCFunction)MenuObj_DisableMenuItem, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1913 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1914 | {"IsMenuItemEnabled", (PyCFunction)MenuObj_IsMenuItemEnabled, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1915 | "(MenuItemIndex item) -> (Boolean _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1916 | {"EnableMenuItemIcon", (PyCFunction)MenuObj_EnableMenuItemIcon, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1917 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1918 | {"DisableMenuItemIcon", (PyCFunction)MenuObj_DisableMenuItemIcon, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1919 | "(MenuItemIndex item) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1920 | {"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 1921 | "(MenuItemIndex item) -> (Boolean _rv)"}, |
| 1922 | |
| 1923 | #if TARGET_API_MAC_CARBON |
| 1924 | {"GetMenuItemPropertyAttributes", (PyCFunction)MenuObj_GetMenuItemPropertyAttributes, 1, |
| 1925 | "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"}, |
| 1926 | #endif |
| 1927 | |
| 1928 | #if TARGET_API_MAC_CARBON |
| 1929 | {"ChangeMenuItemPropertyAttributes", (PyCFunction)MenuObj_ChangeMenuItemPropertyAttributes, 1, |
| 1930 | "(MenuItemIndex item, OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"}, |
| 1931 | #endif |
| 1932 | |
| 1933 | #if TARGET_API_MAC_CARBON |
| 1934 | {"GetMenuAttributes", (PyCFunction)MenuObj_GetMenuAttributes, 1, |
| 1935 | "() -> (MenuAttributes outAttributes)"}, |
| 1936 | #endif |
| 1937 | |
| 1938 | #if TARGET_API_MAC_CARBON |
| 1939 | {"ChangeMenuAttributes", (PyCFunction)MenuObj_ChangeMenuAttributes, 1, |
| 1940 | "(MenuAttributes setTheseAttributes, MenuAttributes clearTheseAttributes) -> None"}, |
| 1941 | #endif |
| 1942 | |
| 1943 | #if TARGET_API_MAC_CARBON |
| 1944 | {"GetMenuItemAttributes", (PyCFunction)MenuObj_GetMenuItemAttributes, 1, |
| 1945 | "(MenuItemIndex item) -> (MenuItemAttributes outAttributes)"}, |
| 1946 | #endif |
| 1947 | |
| 1948 | #if TARGET_API_MAC_CARBON |
| 1949 | {"ChangeMenuItemAttributes", (PyCFunction)MenuObj_ChangeMenuItemAttributes, 1, |
| 1950 | "(MenuItemIndex item, MenuItemAttributes setTheseAttributes, MenuItemAttributes clearTheseAttributes) -> None"}, |
| 1951 | #endif |
| 1952 | |
| 1953 | #if TARGET_API_MAC_CARBON |
| 1954 | {"DisableAllMenuItems", (PyCFunction)MenuObj_DisableAllMenuItems, 1, |
| 1955 | "() -> None"}, |
| 1956 | #endif |
| 1957 | |
| 1958 | #if TARGET_API_MAC_CARBON |
| 1959 | {"EnableAllMenuItems", (PyCFunction)MenuObj_EnableAllMenuItems, 1, |
| 1960 | "() -> None"}, |
| 1961 | #endif |
| 1962 | |
| 1963 | #if TARGET_API_MAC_CARBON |
| 1964 | {"MenuHasEnabledItems", (PyCFunction)MenuObj_MenuHasEnabledItems, 1, |
| 1965 | "() -> (Boolean _rv)"}, |
| 1966 | #endif |
| 1967 | |
| 1968 | #if TARGET_API_MAC_CARBON |
| 1969 | {"CountMenuItemsWithCommandID", (PyCFunction)MenuObj_CountMenuItemsWithCommandID, 1, |
| 1970 | "(MenuCommand commandID) -> (ItemCount _rv)"}, |
| 1971 | #endif |
| 1972 | |
| 1973 | #if TARGET_API_MAC_CARBON |
| 1974 | {"GetIndMenuItemWithCommandID", (PyCFunction)MenuObj_GetIndMenuItemWithCommandID, 1, |
| 1975 | "(MenuCommand commandID, UInt32 itemIndex) -> (MenuHandle outMenu, MenuItemIndex outIndex)"}, |
| 1976 | #endif |
| 1977 | |
| 1978 | #if TARGET_API_MAC_CARBON |
| 1979 | {"EnableMenuCommand", (PyCFunction)MenuObj_EnableMenuCommand, 1, |
| 1980 | "(MenuCommand commandID) -> None"}, |
| 1981 | #endif |
| 1982 | |
| 1983 | #if TARGET_API_MAC_CARBON |
| 1984 | {"DisableMenuCommand", (PyCFunction)MenuObj_DisableMenuCommand, 1, |
| 1985 | "(MenuCommand commandID) -> None"}, |
| 1986 | #endif |
| 1987 | |
| 1988 | #if TARGET_API_MAC_CARBON |
| 1989 | {"IsMenuCommandEnabled", (PyCFunction)MenuObj_IsMenuCommandEnabled, 1, |
| 1990 | "(MenuCommand commandID) -> (Boolean _rv)"}, |
| 1991 | #endif |
| 1992 | |
| 1993 | #if TARGET_API_MAC_CARBON |
| 1994 | {"GetMenuCommandPropertySize", (PyCFunction)MenuObj_GetMenuCommandPropertySize, 1, |
| 1995 | "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> (ByteCount size)"}, |
| 1996 | #endif |
| 1997 | |
| 1998 | #if TARGET_API_MAC_CARBON |
| 1999 | {"RemoveMenuCommandProperty", (PyCFunction)MenuObj_RemoveMenuCommandProperty, 1, |
| 2000 | "(MenuCommand commandID, OSType propertyCreator, OSType propertyTag) -> None"}, |
| 2001 | #endif |
| 2002 | |
| 2003 | #if TARGET_API_MAC_CARBON |
| 2004 | {"CreateStandardFontMenu", (PyCFunction)MenuObj_CreateStandardFontMenu, 1, |
| 2005 | "(MenuItemIndex afterItem, MenuID firstHierMenuID, OptionBits options) -> (ItemCount outHierMenuCount)"}, |
| 2006 | #endif |
| 2007 | |
| 2008 | #if TARGET_API_MAC_CARBON |
| 2009 | {"UpdateStandardFontMenu", (PyCFunction)MenuObj_UpdateStandardFontMenu, 1, |
| 2010 | "() -> (ItemCount outHierMenuCount)"}, |
| 2011 | #endif |
| 2012 | |
| 2013 | #if TARGET_API_MAC_CARBON |
| 2014 | {"GetFontFamilyFromMenuSelection", (PyCFunction)MenuObj_GetFontFamilyFromMenuSelection, 1, |
| 2015 | "(MenuItemIndex item) -> (FMFontFamily outFontFamily, FMFontStyle outStyle)"}, |
| 2016 | #endif |
| 2017 | {"GetMenuID", (PyCFunction)MenuObj_GetMenuID, 1, |
| 2018 | "() -> (MenuID _rv)"}, |
| 2019 | {"GetMenuWidth", (PyCFunction)MenuObj_GetMenuWidth, 1, |
| 2020 | "() -> (SInt16 _rv)"}, |
| 2021 | {"GetMenuHeight", (PyCFunction)MenuObj_GetMenuHeight, 1, |
| 2022 | "() -> (SInt16 _rv)"}, |
| 2023 | {"SetMenuID", (PyCFunction)MenuObj_SetMenuID, 1, |
| 2024 | "(MenuID menuID) -> None"}, |
| 2025 | {"SetMenuWidth", (PyCFunction)MenuObj_SetMenuWidth, 1, |
| 2026 | "(SInt16 width) -> None"}, |
| 2027 | {"SetMenuHeight", (PyCFunction)MenuObj_SetMenuHeight, 1, |
| 2028 | "(SInt16 height) -> None"}, |
Jack Jansen | a177228 | 1995-06-18 20:17:27 +0000 | [diff] [blame] | 2029 | {"as_Resource", (PyCFunction)MenuObj_as_Resource, 1, |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 2030 | "() -> (Handle _rv)"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2031 | {"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1, |
| 2032 | "(Str255 data) -> None"}, |
| 2033 | {"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1, |
| 2034 | "(short beforeID) -> None"}, |
| 2035 | {"InsertMenuItem", (PyCFunction)MenuObj_InsertMenuItem, 1, |
| 2036 | "(Str255 itemString, short afterItem) -> None"}, |
Jack Jansen | 54c0787 | 2001-01-29 13:32:10 +0000 | [diff] [blame] | 2037 | {"EnableMenuItem", (PyCFunction)MenuObj_EnableMenuItem, 1, |
| 2038 | "(UInt16 item) -> None"}, |
| 2039 | {"CheckMenuItem", (PyCFunction)MenuObj_CheckMenuItem, 1, |
| 2040 | "(short item, Boolean checked) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2041 | {NULL, NULL, 0} |
| 2042 | }; |
| 2043 | |
| 2044 | PyMethodChain MenuObj_chain = { MenuObj_methods, NULL }; |
| 2045 | |
| 2046 | static PyObject *MenuObj_getattr(self, name) |
| 2047 | MenuObject *self; |
| 2048 | char *name; |
| 2049 | { |
| 2050 | return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name); |
| 2051 | } |
| 2052 | |
| 2053 | #define MenuObj_setattr NULL |
| 2054 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2055 | #define MenuObj_compare NULL |
| 2056 | |
| 2057 | #define MenuObj_repr NULL |
| 2058 | |
| 2059 | #define MenuObj_hash NULL |
| 2060 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2061 | PyTypeObject Menu_Type = { |
| 2062 | PyObject_HEAD_INIT(&PyType_Type) |
| 2063 | 0, /*ob_size*/ |
| 2064 | "Menu", /*tp_name*/ |
| 2065 | sizeof(MenuObject), /*tp_basicsize*/ |
| 2066 | 0, /*tp_itemsize*/ |
| 2067 | /* methods */ |
| 2068 | (destructor) MenuObj_dealloc, /*tp_dealloc*/ |
| 2069 | 0, /*tp_print*/ |
| 2070 | (getattrfunc) MenuObj_getattr, /*tp_getattr*/ |
| 2071 | (setattrfunc) MenuObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2072 | (cmpfunc) MenuObj_compare, /*tp_compare*/ |
| 2073 | (reprfunc) MenuObj_repr, /*tp_repr*/ |
| 2074 | (PyNumberMethods *)0, /* tp_as_number */ |
| 2075 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 2076 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 2077 | (hashfunc) MenuObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2078 | }; |
| 2079 | |
| 2080 | /* ---------------------- End object type Menu ---------------------- */ |
| 2081 | |
| 2082 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2083 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2084 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2085 | static PyObject *Menu_InitProcMenu(_self, _args) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2086 | PyObject *_self; |
| 2087 | PyObject *_args; |
| 2088 | { |
| 2089 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2090 | short resID; |
| 2091 | if (!PyArg_ParseTuple(_args, "h", |
| 2092 | &resID)) |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2093 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2094 | InitProcMenu(resID); |
| 2095 | Py_INCREF(Py_None); |
| 2096 | _res = Py_None; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2097 | return _res; |
| 2098 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2099 | #endif |
| 2100 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2101 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2102 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2103 | static PyObject *Menu_InitMenus(_self, _args) |
| 2104 | PyObject *_self; |
| 2105 | PyObject *_args; |
| 2106 | { |
| 2107 | PyObject *_res = NULL; |
| 2108 | if (!PyArg_ParseTuple(_args, "")) |
| 2109 | return NULL; |
| 2110 | InitMenus(); |
| 2111 | Py_INCREF(Py_None); |
| 2112 | _res = Py_None; |
| 2113 | return _res; |
| 2114 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2115 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2116 | |
| 2117 | static PyObject *Menu_NewMenu(_self, _args) |
| 2118 | PyObject *_self; |
| 2119 | PyObject *_args; |
| 2120 | { |
| 2121 | PyObject *_res = NULL; |
| 2122 | MenuHandle _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2123 | MenuID menuID; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2124 | Str255 menuTitle; |
| 2125 | if (!PyArg_ParseTuple(_args, "hO&", |
| 2126 | &menuID, |
| 2127 | PyMac_GetStr255, menuTitle)) |
| 2128 | return NULL; |
| 2129 | _rv = NewMenu(menuID, |
| 2130 | menuTitle); |
| 2131 | _res = Py_BuildValue("O&", |
| 2132 | MenuObj_New, _rv); |
| 2133 | return _res; |
| 2134 | } |
| 2135 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2136 | static PyObject *Menu_MacGetMenu(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2137 | PyObject *_self; |
| 2138 | PyObject *_args; |
| 2139 | { |
| 2140 | PyObject *_res = NULL; |
| 2141 | MenuHandle _rv; |
| 2142 | short resourceID; |
| 2143 | if (!PyArg_ParseTuple(_args, "h", |
| 2144 | &resourceID)) |
| 2145 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2146 | _rv = MacGetMenu(resourceID); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2147 | _res = Py_BuildValue("O&", |
| 2148 | MenuObj_New, _rv); |
| 2149 | return _res; |
| 2150 | } |
| 2151 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2152 | #if TARGET_API_MAC_CARBON |
| 2153 | |
| 2154 | static PyObject *Menu_CreateNewMenu(_self, _args) |
| 2155 | PyObject *_self; |
| 2156 | PyObject *_args; |
| 2157 | { |
| 2158 | PyObject *_res = NULL; |
| 2159 | OSStatus _err; |
| 2160 | MenuID menuID; |
| 2161 | MenuAttributes menuAttributes; |
| 2162 | MenuHandle outMenuRef; |
| 2163 | if (!PyArg_ParseTuple(_args, "hl", |
| 2164 | &menuID, |
| 2165 | &menuAttributes)) |
| 2166 | return NULL; |
| 2167 | _err = CreateNewMenu(menuID, |
| 2168 | menuAttributes, |
| 2169 | &outMenuRef); |
| 2170 | if (_err != noErr) return PyMac_Error(_err); |
| 2171 | _res = Py_BuildValue("O&", |
| 2172 | MenuObj_New, outMenuRef); |
| 2173 | return _res; |
| 2174 | } |
| 2175 | #endif |
| 2176 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2177 | static PyObject *Menu_MenuKey(_self, _args) |
| 2178 | PyObject *_self; |
| 2179 | PyObject *_args; |
| 2180 | { |
| 2181 | PyObject *_res = NULL; |
| 2182 | long _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2183 | CharParameter ch; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2184 | if (!PyArg_ParseTuple(_args, "h", |
| 2185 | &ch)) |
| 2186 | return NULL; |
| 2187 | _rv = MenuKey(ch); |
| 2188 | _res = Py_BuildValue("l", |
| 2189 | _rv); |
| 2190 | return _res; |
| 2191 | } |
| 2192 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2193 | static PyObject *Menu_MenuSelect(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2194 | PyObject *_self; |
| 2195 | PyObject *_args; |
| 2196 | { |
| 2197 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2198 | long _rv; |
| 2199 | Point startPt; |
| 2200 | if (!PyArg_ParseTuple(_args, "O&", |
| 2201 | PyMac_GetPoint, &startPt)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2202 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2203 | _rv = MenuSelect(startPt); |
| 2204 | _res = Py_BuildValue("l", |
| 2205 | _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2206 | return _res; |
| 2207 | } |
| 2208 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2209 | static PyObject *Menu_MenuChoice(_self, _args) |
| 2210 | PyObject *_self; |
| 2211 | PyObject *_args; |
| 2212 | { |
| 2213 | PyObject *_res = NULL; |
| 2214 | long _rv; |
| 2215 | if (!PyArg_ParseTuple(_args, "")) |
| 2216 | return NULL; |
| 2217 | _rv = MenuChoice(); |
| 2218 | _res = Py_BuildValue("l", |
| 2219 | _rv); |
| 2220 | return _res; |
| 2221 | } |
| 2222 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2223 | static PyObject *Menu_MenuEvent(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2224 | PyObject *_self; |
| 2225 | PyObject *_args; |
| 2226 | { |
| 2227 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2228 | UInt32 _rv; |
| 2229 | EventRecord inEvent; |
| 2230 | if (!PyArg_ParseTuple(_args, "O&", |
| 2231 | PyMac_GetEventRecord, &inEvent)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2232 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2233 | _rv = MenuEvent(&inEvent); |
| 2234 | _res = Py_BuildValue("l", |
| 2235 | _rv); |
| 2236 | return _res; |
| 2237 | } |
| 2238 | |
| 2239 | static PyObject *Menu_GetMBarHeight(_self, _args) |
| 2240 | PyObject *_self; |
| 2241 | PyObject *_args; |
| 2242 | { |
| 2243 | PyObject *_res = NULL; |
| 2244 | short _rv; |
| 2245 | if (!PyArg_ParseTuple(_args, "")) |
| 2246 | return NULL; |
| 2247 | _rv = GetMBarHeight(); |
| 2248 | _res = Py_BuildValue("h", |
| 2249 | _rv); |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2250 | return _res; |
| 2251 | } |
| 2252 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2253 | static PyObject *Menu_MacDrawMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2254 | PyObject *_self; |
| 2255 | PyObject *_args; |
| 2256 | { |
| 2257 | PyObject *_res = NULL; |
| 2258 | if (!PyArg_ParseTuple(_args, "")) |
| 2259 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2260 | MacDrawMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2261 | Py_INCREF(Py_None); |
| 2262 | _res = Py_None; |
| 2263 | return _res; |
| 2264 | } |
| 2265 | |
| 2266 | static PyObject *Menu_InvalMenuBar(_self, _args) |
| 2267 | PyObject *_self; |
| 2268 | PyObject *_args; |
| 2269 | { |
| 2270 | PyObject *_res = NULL; |
| 2271 | if (!PyArg_ParseTuple(_args, "")) |
| 2272 | return NULL; |
| 2273 | InvalMenuBar(); |
| 2274 | Py_INCREF(Py_None); |
| 2275 | _res = Py_None; |
| 2276 | return _res; |
| 2277 | } |
| 2278 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2279 | static PyObject *Menu_HiliteMenu(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2280 | PyObject *_self; |
| 2281 | PyObject *_args; |
| 2282 | { |
| 2283 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2284 | MenuID menuID; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2285 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2286 | &menuID)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2287 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2288 | HiliteMenu(menuID); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2289 | Py_INCREF(Py_None); |
| 2290 | _res = Py_None; |
| 2291 | return _res; |
| 2292 | } |
| 2293 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2294 | static PyObject *Menu_GetNewMBar(_self, _args) |
| 2295 | PyObject *_self; |
| 2296 | PyObject *_args; |
| 2297 | { |
| 2298 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2299 | MenuBarHandle _rv; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2300 | short menuBarID; |
| 2301 | if (!PyArg_ParseTuple(_args, "h", |
| 2302 | &menuBarID)) |
| 2303 | return NULL; |
| 2304 | _rv = GetNewMBar(menuBarID); |
| 2305 | _res = Py_BuildValue("O&", |
| 2306 | ResObj_New, _rv); |
| 2307 | return _res; |
| 2308 | } |
| 2309 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2310 | static PyObject *Menu_GetMenuBar(_self, _args) |
| 2311 | PyObject *_self; |
| 2312 | PyObject *_args; |
| 2313 | { |
| 2314 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2315 | MenuBarHandle _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2316 | if (!PyArg_ParseTuple(_args, "")) |
| 2317 | return NULL; |
| 2318 | _rv = GetMenuBar(); |
| 2319 | _res = Py_BuildValue("O&", |
| 2320 | ResObj_New, _rv); |
| 2321 | return _res; |
| 2322 | } |
| 2323 | |
| 2324 | static PyObject *Menu_SetMenuBar(_self, _args) |
| 2325 | PyObject *_self; |
| 2326 | PyObject *_args; |
| 2327 | { |
| 2328 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2329 | MenuBarHandle mbar; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2330 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2331 | ResObj_Convert, &mbar)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2332 | return NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2333 | SetMenuBar(mbar); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2334 | Py_INCREF(Py_None); |
| 2335 | _res = Py_None; |
| 2336 | return _res; |
| 2337 | } |
| 2338 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2339 | #if TARGET_API_MAC_CARBON |
| 2340 | |
| 2341 | static PyObject *Menu_DuplicateMenuBar(_self, _args) |
| 2342 | PyObject *_self; |
| 2343 | PyObject *_args; |
| 2344 | { |
| 2345 | PyObject *_res = NULL; |
| 2346 | OSStatus _err; |
| 2347 | MenuBarHandle mbar; |
| 2348 | MenuBarHandle outBar; |
| 2349 | if (!PyArg_ParseTuple(_args, "O&", |
| 2350 | ResObj_Convert, &mbar)) |
| 2351 | return NULL; |
| 2352 | _err = DuplicateMenuBar(mbar, |
| 2353 | &outBar); |
| 2354 | if (_err != noErr) return PyMac_Error(_err); |
| 2355 | _res = Py_BuildValue("O&", |
| 2356 | ResObj_New, outBar); |
| 2357 | return _res; |
| 2358 | } |
| 2359 | #endif |
| 2360 | |
| 2361 | #if TARGET_API_MAC_CARBON |
| 2362 | |
| 2363 | static PyObject *Menu_DisposeMenuBar(_self, _args) |
| 2364 | PyObject *_self; |
| 2365 | PyObject *_args; |
| 2366 | { |
| 2367 | PyObject *_res = NULL; |
| 2368 | OSStatus _err; |
| 2369 | MenuBarHandle mbar; |
| 2370 | if (!PyArg_ParseTuple(_args, "O&", |
| 2371 | ResObj_Convert, &mbar)) |
| 2372 | return NULL; |
| 2373 | _err = DisposeMenuBar(mbar); |
| 2374 | if (_err != noErr) return PyMac_Error(_err); |
| 2375 | Py_INCREF(Py_None); |
| 2376 | _res = Py_None; |
| 2377 | return _res; |
| 2378 | } |
| 2379 | #endif |
| 2380 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2381 | static PyObject *Menu_GetMenuHandle(_self, _args) |
| 2382 | PyObject *_self; |
| 2383 | PyObject *_args; |
| 2384 | { |
| 2385 | PyObject *_res = NULL; |
| 2386 | MenuHandle _rv; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2387 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2388 | if (!PyArg_ParseTuple(_args, "h", |
| 2389 | &menuID)) |
| 2390 | return NULL; |
| 2391 | _rv = GetMenuHandle(menuID); |
| 2392 | _res = Py_BuildValue("O&", |
| 2393 | MenuObj_New, _rv); |
| 2394 | return _res; |
| 2395 | } |
| 2396 | |
| 2397 | static PyObject *Menu_MacDeleteMenu(_self, _args) |
| 2398 | PyObject *_self; |
| 2399 | PyObject *_args; |
| 2400 | { |
| 2401 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2402 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2403 | if (!PyArg_ParseTuple(_args, "h", |
| 2404 | &menuID)) |
| 2405 | return NULL; |
| 2406 | MacDeleteMenu(menuID); |
| 2407 | Py_INCREF(Py_None); |
| 2408 | _res = Py_None; |
| 2409 | return _res; |
| 2410 | } |
| 2411 | |
| 2412 | static PyObject *Menu_ClearMenuBar(_self, _args) |
| 2413 | PyObject *_self; |
| 2414 | PyObject *_args; |
| 2415 | { |
| 2416 | PyObject *_res = NULL; |
| 2417 | if (!PyArg_ParseTuple(_args, "")) |
| 2418 | return NULL; |
| 2419 | ClearMenuBar(); |
| 2420 | Py_INCREF(Py_None); |
| 2421 | _res = Py_None; |
| 2422 | return _res; |
| 2423 | } |
| 2424 | |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2425 | static PyObject *Menu_SetMenuFlashCount(_self, _args) |
| 2426 | PyObject *_self; |
| 2427 | PyObject *_args; |
| 2428 | { |
| 2429 | PyObject *_res = NULL; |
| 2430 | short count; |
| 2431 | if (!PyArg_ParseTuple(_args, "h", |
| 2432 | &count)) |
| 2433 | return NULL; |
| 2434 | SetMenuFlashCount(count); |
| 2435 | Py_INCREF(Py_None); |
| 2436 | _res = Py_None; |
| 2437 | return _res; |
| 2438 | } |
| 2439 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2440 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2441 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2442 | static PyObject *Menu_SetMenuFlash(_self, _args) |
| 2443 | PyObject *_self; |
| 2444 | PyObject *_args; |
| 2445 | { |
| 2446 | PyObject *_res = NULL; |
| 2447 | short count; |
| 2448 | if (!PyArg_ParseTuple(_args, "h", |
| 2449 | &count)) |
| 2450 | return NULL; |
| 2451 | SetMenuFlash(count); |
| 2452 | Py_INCREF(Py_None); |
| 2453 | _res = Py_None; |
| 2454 | return _res; |
| 2455 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2456 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2457 | |
| 2458 | static PyObject *Menu_FlashMenuBar(_self, _args) |
| 2459 | PyObject *_self; |
| 2460 | PyObject *_args; |
| 2461 | { |
| 2462 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2463 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2464 | if (!PyArg_ParseTuple(_args, "h", |
| 2465 | &menuID)) |
| 2466 | return NULL; |
| 2467 | FlashMenuBar(menuID); |
| 2468 | Py_INCREF(Py_None); |
| 2469 | _res = Py_None; |
| 2470 | return _res; |
| 2471 | } |
| 2472 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2473 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2474 | |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2475 | static PyObject *Menu_SystemEdit(_self, _args) |
| 2476 | PyObject *_self; |
| 2477 | PyObject *_args; |
| 2478 | { |
| 2479 | PyObject *_res = NULL; |
| 2480 | Boolean _rv; |
| 2481 | short editCmd; |
| 2482 | if (!PyArg_ParseTuple(_args, "h", |
| 2483 | &editCmd)) |
| 2484 | return NULL; |
| 2485 | _rv = SystemEdit(editCmd); |
| 2486 | _res = Py_BuildValue("b", |
| 2487 | _rv); |
| 2488 | return _res; |
| 2489 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2490 | #endif |
| 2491 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2492 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 2493 | |
| 2494 | static PyObject *Menu_SystemMenu(_self, _args) |
| 2495 | PyObject *_self; |
| 2496 | PyObject *_args; |
| 2497 | { |
| 2498 | PyObject *_res = NULL; |
| 2499 | long menuResult; |
| 2500 | if (!PyArg_ParseTuple(_args, "l", |
| 2501 | &menuResult)) |
| 2502 | return NULL; |
| 2503 | SystemMenu(menuResult); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2504 | Py_INCREF(Py_None); |
| 2505 | _res = Py_None; |
| 2506 | return _res; |
| 2507 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2508 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2509 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2510 | static PyObject *Menu_IsMenuBarVisible(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2511 | PyObject *_self; |
| 2512 | PyObject *_args; |
| 2513 | { |
| 2514 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2515 | Boolean _rv; |
| 2516 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2517 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2518 | _rv = IsMenuBarVisible(); |
| 2519 | _res = Py_BuildValue("b", |
| 2520 | _rv); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2521 | return _res; |
| 2522 | } |
| 2523 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2524 | static PyObject *Menu_ShowMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2525 | PyObject *_self; |
| 2526 | PyObject *_args; |
| 2527 | { |
| 2528 | PyObject *_res = NULL; |
| 2529 | if (!PyArg_ParseTuple(_args, "")) |
| 2530 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2531 | ShowMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2532 | Py_INCREF(Py_None); |
| 2533 | _res = Py_None; |
| 2534 | return _res; |
| 2535 | } |
| 2536 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2537 | static PyObject *Menu_HideMenuBar(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2538 | PyObject *_self; |
| 2539 | PyObject *_args; |
| 2540 | { |
| 2541 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2542 | if (!PyArg_ParseTuple(_args, "")) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2543 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2544 | HideMenuBar(); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2545 | Py_INCREF(Py_None); |
| 2546 | _res = Py_None; |
| 2547 | return _res; |
| 2548 | } |
| 2549 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2550 | static PyObject *Menu_DeleteMCEntries(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2551 | PyObject *_self; |
| 2552 | PyObject *_args; |
| 2553 | { |
| 2554 | PyObject *_res = NULL; |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2555 | MenuID menuID; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2556 | short menuItem; |
| 2557 | if (!PyArg_ParseTuple(_args, "hh", |
| 2558 | &menuID, |
| 2559 | &menuItem)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2560 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2561 | DeleteMCEntries(menuID, |
| 2562 | menuItem); |
| 2563 | Py_INCREF(Py_None); |
| 2564 | _res = Py_None; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2565 | return _res; |
| 2566 | } |
| 2567 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2568 | static PyObject *Menu_InitContextualMenus(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2569 | PyObject *_self; |
| 2570 | PyObject *_args; |
| 2571 | { |
| 2572 | PyObject *_res = NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2573 | OSStatus _err; |
| 2574 | if (!PyArg_ParseTuple(_args, "")) |
| 2575 | return NULL; |
| 2576 | _err = InitContextualMenus(); |
| 2577 | if (_err != noErr) return PyMac_Error(_err); |
| 2578 | Py_INCREF(Py_None); |
| 2579 | _res = Py_None; |
| 2580 | return _res; |
| 2581 | } |
| 2582 | |
| 2583 | static PyObject *Menu_IsShowContextualMenuClick(_self, _args) |
| 2584 | PyObject *_self; |
| 2585 | PyObject *_args; |
| 2586 | { |
| 2587 | PyObject *_res = NULL; |
| 2588 | Boolean _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2589 | EventRecord inEvent; |
| 2590 | if (!PyArg_ParseTuple(_args, "O&", |
| 2591 | PyMac_GetEventRecord, &inEvent)) |
| 2592 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2593 | _rv = IsShowContextualMenuClick(&inEvent); |
| 2594 | _res = Py_BuildValue("b", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2595 | _rv); |
| 2596 | return _res; |
| 2597 | } |
| 2598 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2599 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2600 | |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2601 | static PyObject *Menu_OpenDeskAcc(_self, _args) |
| 2602 | PyObject *_self; |
| 2603 | PyObject *_args; |
| 2604 | { |
| 2605 | PyObject *_res = NULL; |
| 2606 | Str255 name; |
| 2607 | if (!PyArg_ParseTuple(_args, "O&", |
| 2608 | PyMac_GetStr255, name)) |
| 2609 | return NULL; |
| 2610 | OpenDeskAcc(name); |
| 2611 | Py_INCREF(Py_None); |
| 2612 | _res = Py_None; |
| 2613 | return _res; |
| 2614 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2615 | #endif |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2616 | |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2617 | static PyObject *Menu_as_Menu(_self, _args) |
| 2618 | PyObject *_self; |
| 2619 | PyObject *_args; |
| 2620 | { |
| 2621 | PyObject *_res = NULL; |
| 2622 | MenuHandle _rv; |
| 2623 | Handle h; |
| 2624 | if (!PyArg_ParseTuple(_args, "O&", |
| 2625 | ResObj_Convert, &h)) |
| 2626 | return NULL; |
| 2627 | _rv = as_Menu(h); |
| 2628 | _res = Py_BuildValue("O&", |
| 2629 | MenuObj_New, _rv); |
| 2630 | return _res; |
| 2631 | } |
| 2632 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2633 | static PyObject *Menu_GetMenu(_self, _args) |
| 2634 | PyObject *_self; |
| 2635 | PyObject *_args; |
| 2636 | { |
| 2637 | PyObject *_res = NULL; |
| 2638 | MenuHandle _rv; |
| 2639 | short resourceID; |
| 2640 | if (!PyArg_ParseTuple(_args, "h", |
| 2641 | &resourceID)) |
| 2642 | return NULL; |
| 2643 | _rv = GetMenu(resourceID); |
| 2644 | _res = Py_BuildValue("O&", |
| 2645 | MenuObj_New, _rv); |
| 2646 | return _res; |
| 2647 | } |
| 2648 | |
| 2649 | static PyObject *Menu_DeleteMenu(_self, _args) |
| 2650 | PyObject *_self; |
| 2651 | PyObject *_args; |
| 2652 | { |
| 2653 | PyObject *_res = NULL; |
| 2654 | short menuID; |
| 2655 | if (!PyArg_ParseTuple(_args, "h", |
| 2656 | &menuID)) |
| 2657 | return NULL; |
| 2658 | DeleteMenu(menuID); |
| 2659 | Py_INCREF(Py_None); |
| 2660 | _res = Py_None; |
| 2661 | return _res; |
| 2662 | } |
| 2663 | |
| 2664 | static PyObject *Menu_DrawMenuBar(_self, _args) |
| 2665 | PyObject *_self; |
| 2666 | PyObject *_args; |
| 2667 | { |
| 2668 | PyObject *_res = NULL; |
| 2669 | if (!PyArg_ParseTuple(_args, "")) |
| 2670 | return NULL; |
| 2671 | DrawMenuBar(); |
| 2672 | Py_INCREF(Py_None); |
| 2673 | _res = Py_None; |
| 2674 | return _res; |
| 2675 | } |
| 2676 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2677 | static PyMethodDef Menu_methods[] = { |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2678 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2679 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2680 | {"InitProcMenu", (PyCFunction)Menu_InitProcMenu, 1, |
| 2681 | "(short resID) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2682 | #endif |
| 2683 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2684 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2685 | {"InitMenus", (PyCFunction)Menu_InitMenus, 1, |
| 2686 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2687 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2688 | {"NewMenu", (PyCFunction)Menu_NewMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2689 | "(MenuID menuID, Str255 menuTitle) -> (MenuHandle _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2690 | {"MacGetMenu", (PyCFunction)Menu_MacGetMenu, 1, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2691 | "(short resourceID) -> (MenuHandle _rv)"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2692 | |
| 2693 | #if TARGET_API_MAC_CARBON |
| 2694 | {"CreateNewMenu", (PyCFunction)Menu_CreateNewMenu, 1, |
| 2695 | "(MenuID menuID, MenuAttributes menuAttributes) -> (MenuHandle outMenuRef)"}, |
| 2696 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2697 | {"MenuKey", (PyCFunction)Menu_MenuKey, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2698 | "(CharParameter ch) -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2699 | {"MenuSelect", (PyCFunction)Menu_MenuSelect, 1, |
| 2700 | "(Point startPt) -> (long _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2701 | {"MenuChoice", (PyCFunction)Menu_MenuChoice, 1, |
| 2702 | "() -> (long _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2703 | {"MenuEvent", (PyCFunction)Menu_MenuEvent, 1, |
| 2704 | "(EventRecord inEvent) -> (UInt32 _rv)"}, |
| 2705 | {"GetMBarHeight", (PyCFunction)Menu_GetMBarHeight, 1, |
| 2706 | "() -> (short _rv)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2707 | {"MacDrawMenuBar", (PyCFunction)Menu_MacDrawMenuBar, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2708 | "() -> None"}, |
| 2709 | {"InvalMenuBar", (PyCFunction)Menu_InvalMenuBar, 1, |
| 2710 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2711 | {"HiliteMenu", (PyCFunction)Menu_HiliteMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2712 | "(MenuID menuID) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2713 | {"GetNewMBar", (PyCFunction)Menu_GetNewMBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2714 | "(short menuBarID) -> (MenuBarHandle _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2715 | {"GetMenuBar", (PyCFunction)Menu_GetMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2716 | "() -> (MenuBarHandle _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2717 | {"SetMenuBar", (PyCFunction)Menu_SetMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2718 | "(MenuBarHandle mbar) -> None"}, |
| 2719 | |
| 2720 | #if TARGET_API_MAC_CARBON |
| 2721 | {"DuplicateMenuBar", (PyCFunction)Menu_DuplicateMenuBar, 1, |
| 2722 | "(MenuBarHandle mbar) -> (MenuBarHandle outBar)"}, |
| 2723 | #endif |
| 2724 | |
| 2725 | #if TARGET_API_MAC_CARBON |
| 2726 | {"DisposeMenuBar", (PyCFunction)Menu_DisposeMenuBar, 1, |
| 2727 | "(MenuBarHandle mbar) -> None"}, |
| 2728 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2729 | {"GetMenuHandle", (PyCFunction)Menu_GetMenuHandle, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2730 | "(MenuID menuID) -> (MenuHandle _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2731 | {"MacDeleteMenu", (PyCFunction)Menu_MacDeleteMenu, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2732 | "(MenuID menuID) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2733 | {"ClearMenuBar", (PyCFunction)Menu_ClearMenuBar, 1, |
| 2734 | "() -> None"}, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2735 | {"SetMenuFlashCount", (PyCFunction)Menu_SetMenuFlashCount, 1, |
| 2736 | "(short count) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2737 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2738 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2739 | {"SetMenuFlash", (PyCFunction)Menu_SetMenuFlash, 1, |
| 2740 | "(short count) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2741 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2742 | {"FlashMenuBar", (PyCFunction)Menu_FlashMenuBar, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2743 | "(MenuID menuID) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2744 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2745 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2746 | {"SystemEdit", (PyCFunction)Menu_SystemEdit, 1, |
| 2747 | "(short editCmd) -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2748 | #endif |
| 2749 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2750 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2751 | {"SystemMenu", (PyCFunction)Menu_SystemMenu, 1, |
| 2752 | "(long menuResult) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2753 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2754 | {"IsMenuBarVisible", (PyCFunction)Menu_IsMenuBarVisible, 1, |
| 2755 | "() -> (Boolean _rv)"}, |
| 2756 | {"ShowMenuBar", (PyCFunction)Menu_ShowMenuBar, 1, |
| 2757 | "() -> None"}, |
| 2758 | {"HideMenuBar", (PyCFunction)Menu_HideMenuBar, 1, |
| 2759 | "() -> None"}, |
| 2760 | {"DeleteMCEntries", (PyCFunction)Menu_DeleteMCEntries, 1, |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2761 | "(MenuID menuID, short menuItem) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2762 | {"InitContextualMenus", (PyCFunction)Menu_InitContextualMenus, 1, |
| 2763 | "() -> None"}, |
| 2764 | {"IsShowContextualMenuClick", (PyCFunction)Menu_IsShowContextualMenuClick, 1, |
| 2765 | "(EventRecord inEvent) -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2766 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2767 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 86c3af7 | 1995-03-19 22:42:51 +0000 | [diff] [blame] | 2768 | {"OpenDeskAcc", (PyCFunction)Menu_OpenDeskAcc, 1, |
| 2769 | "(Str255 name) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2770 | #endif |
Jack Jansen | e058189 | 1999-02-07 14:02:03 +0000 | [diff] [blame] | 2771 | {"as_Menu", (PyCFunction)Menu_as_Menu, 1, |
| 2772 | "(Handle h) -> (MenuHandle _rv)"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2773 | {"GetMenu", (PyCFunction)Menu_GetMenu, 1, |
| 2774 | "(short resourceID) -> (MenuHandle _rv)"}, |
| 2775 | {"DeleteMenu", (PyCFunction)Menu_DeleteMenu, 1, |
| 2776 | "(short menuID) -> None"}, |
| 2777 | {"DrawMenuBar", (PyCFunction)Menu_DrawMenuBar, 1, |
| 2778 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2779 | {NULL, NULL, 0} |
| 2780 | }; |
| 2781 | |
| 2782 | |
| 2783 | |
| 2784 | |
| 2785 | void initMenu() |
| 2786 | { |
| 2787 | PyObject *m; |
| 2788 | PyObject *d; |
| 2789 | |
| 2790 | |
| 2791 | |
Jack Jansen | 0e04eec | 2001-05-17 21:58:34 +0000 | [diff] [blame^] | 2792 | PyMac_INIT_TOOLBOX_OBJECT_NEW(MenuObj_New); |
| 2793 | PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuObj_Convert); |
| 2794 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2795 | |
| 2796 | m = Py_InitModule("Menu", Menu_methods); |
| 2797 | d = PyModule_GetDict(m); |
| 2798 | Menu_Error = PyMac_GetOSErrException(); |
| 2799 | if (Menu_Error == NULL || |
| 2800 | PyDict_SetItemString(d, "Error", Menu_Error) != 0) |
Jack Jansen | f7d5aa6 | 2000-12-10 23:43:49 +0000 | [diff] [blame] | 2801 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 2802 | Menu_Type.ob_type = &PyType_Type; |
| 2803 | Py_INCREF(&Menu_Type); |
| 2804 | if (PyDict_SetItemString(d, "MenuType", (PyObject *)&Menu_Type) != 0) |
| 2805 | Py_FatalError("can't initialize MenuType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2806 | } |
| 2807 | |
| 2808 | /* ======================== End module Menu ========================= */ |
| 2809 | |