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