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