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