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