Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module Win =========================== */ |
| 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); |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 17 | extern PyObject *ResObj_OptNew(Handle); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 18 | extern int ResObj_Convert(PyObject *, Handle *); |
| 19 | |
| 20 | extern PyObject *WinObj_New(WindowPtr); |
| 21 | extern int WinObj_Convert(PyObject *, WindowPtr *); |
| 22 | |
| 23 | extern PyObject *DlgObj_New(DialogPtr); |
| 24 | extern int DlgObj_Convert(PyObject *, DialogPtr *); |
| 25 | extern PyTypeObject Dialog_Type; |
| 26 | #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type) |
| 27 | |
| 28 | extern PyObject *MenuObj_New(MenuHandle); |
| 29 | extern int MenuObj_Convert(PyObject *, MenuHandle *); |
| 30 | |
| 31 | extern PyObject *CtlObj_New(ControlHandle); |
| 32 | extern int CtlObj_Convert(PyObject *, ControlHandle *); |
| 33 | |
| 34 | extern PyObject *WinObj_WhichWindow(WindowPtr); |
| 35 | |
| 36 | #include <Windows.h> |
| 37 | |
| 38 | #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |
| 39 | |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 40 | #ifdef HAVE_UNIVERSAL_HEADERS |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 41 | #define WindowPeek WindowPtr |
| 42 | #endif |
| 43 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 44 | static PyObject *Win_Error; |
| 45 | |
| 46 | /* ----------------------- Object type Window ----------------------- */ |
| 47 | |
| 48 | PyTypeObject Window_Type; |
| 49 | |
| 50 | #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
| 51 | |
| 52 | typedef struct WindowObject { |
| 53 | PyObject_HEAD |
| 54 | WindowPtr ob_itself; |
| 55 | } WindowObject; |
| 56 | |
| 57 | PyObject *WinObj_New(itself) |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 58 | WindowPtr itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 59 | { |
| 60 | WindowObject *it; |
| 61 | if (itself == NULL) return PyMac_Error(resNotFound); |
| 62 | it = PyObject_NEW(WindowObject, &Window_Type); |
| 63 | if (it == NULL) return NULL; |
| 64 | it->ob_itself = itself; |
| 65 | SetWRefCon(itself, (long)it); |
| 66 | return (PyObject *)it; |
| 67 | } |
| 68 | WinObj_Convert(v, p_itself) |
| 69 | PyObject *v; |
| 70 | WindowPtr *p_itself; |
| 71 | { |
| 72 | if (DlgObj_Check(v)) { |
| 73 | *p_itself = ((WindowObject *)v)->ob_itself; |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | if (v == Py_None) { *p_itself = NULL; return 1; } |
| 78 | if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } |
| 79 | |
| 80 | if (!WinObj_Check(v)) |
| 81 | { |
| 82 | PyErr_SetString(PyExc_TypeError, "Window required"); |
| 83 | return 0; |
| 84 | } |
| 85 | *p_itself = ((WindowObject *)v)->ob_itself; |
| 86 | return 1; |
| 87 | } |
| 88 | |
| 89 | static void WinObj_dealloc(self) |
| 90 | WindowObject *self; |
| 91 | { |
| 92 | DisposeWindow(self->ob_itself); |
| 93 | PyMem_DEL(self); |
| 94 | } |
| 95 | |
| 96 | static PyObject *WinObj_GetWTitle(_self, _args) |
| 97 | WindowObject *_self; |
| 98 | PyObject *_args; |
| 99 | { |
| 100 | PyObject *_res = NULL; |
| 101 | Str255 title; |
| 102 | if (!PyArg_ParseTuple(_args, "")) |
| 103 | return NULL; |
| 104 | GetWTitle(_self->ob_itself, |
| 105 | title); |
| 106 | _res = Py_BuildValue("O&", |
| 107 | PyMac_BuildStr255, title); |
| 108 | return _res; |
| 109 | } |
| 110 | |
| 111 | static PyObject *WinObj_SelectWindow(_self, _args) |
| 112 | WindowObject *_self; |
| 113 | PyObject *_args; |
| 114 | { |
| 115 | PyObject *_res = NULL; |
| 116 | if (!PyArg_ParseTuple(_args, "")) |
| 117 | return NULL; |
| 118 | SelectWindow(_self->ob_itself); |
| 119 | Py_INCREF(Py_None); |
| 120 | _res = Py_None; |
| 121 | return _res; |
| 122 | } |
| 123 | |
| 124 | static PyObject *WinObj_HideWindow(_self, _args) |
| 125 | WindowObject *_self; |
| 126 | PyObject *_args; |
| 127 | { |
| 128 | PyObject *_res = NULL; |
| 129 | if (!PyArg_ParseTuple(_args, "")) |
| 130 | return NULL; |
| 131 | HideWindow(_self->ob_itself); |
| 132 | Py_INCREF(Py_None); |
| 133 | _res = Py_None; |
| 134 | return _res; |
| 135 | } |
| 136 | |
| 137 | static PyObject *WinObj_ShowWindow(_self, _args) |
| 138 | WindowObject *_self; |
| 139 | PyObject *_args; |
| 140 | { |
| 141 | PyObject *_res = NULL; |
| 142 | if (!PyArg_ParseTuple(_args, "")) |
| 143 | return NULL; |
| 144 | ShowWindow(_self->ob_itself); |
| 145 | Py_INCREF(Py_None); |
| 146 | _res = Py_None; |
| 147 | return _res; |
| 148 | } |
| 149 | |
| 150 | static PyObject *WinObj_ShowHide(_self, _args) |
| 151 | WindowObject *_self; |
| 152 | PyObject *_args; |
| 153 | { |
| 154 | PyObject *_res = NULL; |
| 155 | Boolean showFlag; |
| 156 | if (!PyArg_ParseTuple(_args, "b", |
| 157 | &showFlag)) |
| 158 | return NULL; |
| 159 | ShowHide(_self->ob_itself, |
| 160 | showFlag); |
| 161 | Py_INCREF(Py_None); |
| 162 | _res = Py_None; |
| 163 | return _res; |
| 164 | } |
| 165 | |
| 166 | static PyObject *WinObj_HiliteWindow(_self, _args) |
| 167 | WindowObject *_self; |
| 168 | PyObject *_args; |
| 169 | { |
| 170 | PyObject *_res = NULL; |
| 171 | Boolean fHilite; |
| 172 | if (!PyArg_ParseTuple(_args, "b", |
| 173 | &fHilite)) |
| 174 | return NULL; |
| 175 | HiliteWindow(_self->ob_itself, |
| 176 | fHilite); |
| 177 | Py_INCREF(Py_None); |
| 178 | _res = Py_None; |
| 179 | return _res; |
| 180 | } |
| 181 | |
| 182 | static PyObject *WinObj_BringToFront(_self, _args) |
| 183 | WindowObject *_self; |
| 184 | PyObject *_args; |
| 185 | { |
| 186 | PyObject *_res = NULL; |
| 187 | if (!PyArg_ParseTuple(_args, "")) |
| 188 | return NULL; |
| 189 | BringToFront(_self->ob_itself); |
| 190 | Py_INCREF(Py_None); |
| 191 | _res = Py_None; |
| 192 | return _res; |
| 193 | } |
| 194 | |
| 195 | static PyObject *WinObj_SendBehind(_self, _args) |
| 196 | WindowObject *_self; |
| 197 | PyObject *_args; |
| 198 | { |
| 199 | PyObject *_res = NULL; |
| 200 | WindowPtr behindWindow; |
| 201 | if (!PyArg_ParseTuple(_args, "O&", |
| 202 | WinObj_Convert, &behindWindow)) |
| 203 | return NULL; |
| 204 | SendBehind(_self->ob_itself, |
| 205 | behindWindow); |
| 206 | Py_INCREF(Py_None); |
| 207 | _res = Py_None; |
| 208 | return _res; |
| 209 | } |
| 210 | |
| 211 | static PyObject *WinObj_DrawGrowIcon(_self, _args) |
| 212 | WindowObject *_self; |
| 213 | PyObject *_args; |
| 214 | { |
| 215 | PyObject *_res = NULL; |
| 216 | if (!PyArg_ParseTuple(_args, "")) |
| 217 | return NULL; |
| 218 | DrawGrowIcon(_self->ob_itself); |
| 219 | Py_INCREF(Py_None); |
| 220 | _res = Py_None; |
| 221 | return _res; |
| 222 | } |
| 223 | |
| 224 | static PyObject *WinObj_MoveWindow(_self, _args) |
| 225 | WindowObject *_self; |
| 226 | PyObject *_args; |
| 227 | { |
| 228 | PyObject *_res = NULL; |
| 229 | short hGlobal; |
| 230 | short vGlobal; |
| 231 | Boolean front; |
| 232 | if (!PyArg_ParseTuple(_args, "hhb", |
| 233 | &hGlobal, |
| 234 | &vGlobal, |
| 235 | &front)) |
| 236 | return NULL; |
| 237 | MoveWindow(_self->ob_itself, |
| 238 | hGlobal, |
| 239 | vGlobal, |
| 240 | front); |
| 241 | Py_INCREF(Py_None); |
| 242 | _res = Py_None; |
| 243 | return _res; |
| 244 | } |
| 245 | |
| 246 | static PyObject *WinObj_SizeWindow(_self, _args) |
| 247 | WindowObject *_self; |
| 248 | PyObject *_args; |
| 249 | { |
| 250 | PyObject *_res = NULL; |
| 251 | short w; |
| 252 | short h; |
| 253 | Boolean fUpdate; |
| 254 | if (!PyArg_ParseTuple(_args, "hhb", |
| 255 | &w, |
| 256 | &h, |
| 257 | &fUpdate)) |
| 258 | return NULL; |
| 259 | SizeWindow(_self->ob_itself, |
| 260 | w, |
| 261 | h, |
| 262 | fUpdate); |
| 263 | Py_INCREF(Py_None); |
| 264 | _res = Py_None; |
| 265 | return _res; |
| 266 | } |
| 267 | |
| 268 | static PyObject *WinObj_ZoomWindow(_self, _args) |
| 269 | WindowObject *_self; |
| 270 | PyObject *_args; |
| 271 | { |
| 272 | PyObject *_res = NULL; |
| 273 | short partCode; |
| 274 | Boolean front; |
| 275 | if (!PyArg_ParseTuple(_args, "hb", |
| 276 | &partCode, |
| 277 | &front)) |
| 278 | return NULL; |
| 279 | ZoomWindow(_self->ob_itself, |
| 280 | partCode, |
| 281 | front); |
| 282 | Py_INCREF(Py_None); |
| 283 | _res = Py_None; |
| 284 | return _res; |
| 285 | } |
| 286 | |
| 287 | static PyObject *WinObj_BeginUpdate(_self, _args) |
| 288 | WindowObject *_self; |
| 289 | PyObject *_args; |
| 290 | { |
| 291 | PyObject *_res = NULL; |
| 292 | if (!PyArg_ParseTuple(_args, "")) |
| 293 | return NULL; |
| 294 | BeginUpdate(_self->ob_itself); |
| 295 | Py_INCREF(Py_None); |
| 296 | _res = Py_None; |
| 297 | return _res; |
| 298 | } |
| 299 | |
| 300 | static PyObject *WinObj_EndUpdate(_self, _args) |
| 301 | WindowObject *_self; |
| 302 | PyObject *_args; |
| 303 | { |
| 304 | PyObject *_res = NULL; |
| 305 | if (!PyArg_ParseTuple(_args, "")) |
| 306 | return NULL; |
| 307 | EndUpdate(_self->ob_itself); |
| 308 | Py_INCREF(Py_None); |
| 309 | _res = Py_None; |
| 310 | return _res; |
| 311 | } |
| 312 | |
| 313 | static PyObject *WinObj_SetWRefCon(_self, _args) |
| 314 | WindowObject *_self; |
| 315 | PyObject *_args; |
| 316 | { |
| 317 | PyObject *_res = NULL; |
| 318 | long data; |
| 319 | if (!PyArg_ParseTuple(_args, "l", |
| 320 | &data)) |
| 321 | return NULL; |
| 322 | SetWRefCon(_self->ob_itself, |
| 323 | data); |
| 324 | Py_INCREF(Py_None); |
| 325 | _res = Py_None; |
| 326 | return _res; |
| 327 | } |
| 328 | |
| 329 | static PyObject *WinObj_GetWRefCon(_self, _args) |
| 330 | WindowObject *_self; |
| 331 | PyObject *_args; |
| 332 | { |
| 333 | PyObject *_res = NULL; |
| 334 | long _rv; |
| 335 | if (!PyArg_ParseTuple(_args, "")) |
| 336 | return NULL; |
| 337 | _rv = GetWRefCon(_self->ob_itself); |
| 338 | _res = Py_BuildValue("l", |
| 339 | _rv); |
| 340 | return _res; |
| 341 | } |
| 342 | |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame^] | 343 | static PyObject *WinObj_SetWindowPic(_self, _args) |
| 344 | WindowObject *_self; |
| 345 | PyObject *_args; |
| 346 | { |
| 347 | PyObject *_res = NULL; |
| 348 | PicHandle pic; |
| 349 | if (!PyArg_ParseTuple(_args, "O&", |
| 350 | ResObj_Convert, &pic)) |
| 351 | return NULL; |
| 352 | SetWindowPic(_self->ob_itself, |
| 353 | pic); |
| 354 | Py_INCREF(Py_None); |
| 355 | _res = Py_None; |
| 356 | return _res; |
| 357 | } |
| 358 | |
| 359 | static PyObject *WinObj_GetWindowPic(_self, _args) |
| 360 | WindowObject *_self; |
| 361 | PyObject *_args; |
| 362 | { |
| 363 | PyObject *_res = NULL; |
| 364 | PicHandle _rv; |
| 365 | if (!PyArg_ParseTuple(_args, "")) |
| 366 | return NULL; |
| 367 | _rv = GetWindowPic(_self->ob_itself); |
| 368 | _res = Py_BuildValue("O&", |
| 369 | ResObj_New, _rv); |
| 370 | return _res; |
| 371 | } |
| 372 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 373 | static PyObject *WinObj_ClipAbove(_self, _args) |
| 374 | WindowObject *_self; |
| 375 | PyObject *_args; |
| 376 | { |
| 377 | PyObject *_res = NULL; |
| 378 | if (!PyArg_ParseTuple(_args, "")) |
| 379 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 380 | ClipAbove(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 381 | Py_INCREF(Py_None); |
| 382 | _res = Py_None; |
| 383 | return _res; |
| 384 | } |
| 385 | |
| 386 | static PyObject *WinObj_SaveOld(_self, _args) |
| 387 | WindowObject *_self; |
| 388 | PyObject *_args; |
| 389 | { |
| 390 | PyObject *_res = NULL; |
| 391 | if (!PyArg_ParseTuple(_args, "")) |
| 392 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 393 | SaveOld(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 394 | Py_INCREF(Py_None); |
| 395 | _res = Py_None; |
| 396 | return _res; |
| 397 | } |
| 398 | |
| 399 | static PyObject *WinObj_DrawNew(_self, _args) |
| 400 | WindowObject *_self; |
| 401 | PyObject *_args; |
| 402 | { |
| 403 | PyObject *_res = NULL; |
| 404 | Boolean update; |
| 405 | if (!PyArg_ParseTuple(_args, "b", |
| 406 | &update)) |
| 407 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 408 | DrawNew(_self->ob_itself, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 409 | update); |
| 410 | Py_INCREF(Py_None); |
| 411 | _res = Py_None; |
| 412 | return _res; |
| 413 | } |
| 414 | |
| 415 | static PyObject *WinObj_CalcVis(_self, _args) |
| 416 | WindowObject *_self; |
| 417 | PyObject *_args; |
| 418 | { |
| 419 | PyObject *_res = NULL; |
| 420 | if (!PyArg_ParseTuple(_args, "")) |
| 421 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 422 | CalcVis(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 423 | Py_INCREF(Py_None); |
| 424 | _res = Py_None; |
| 425 | return _res; |
| 426 | } |
| 427 | |
| 428 | static PyObject *WinObj_GrowWindow(_self, _args) |
| 429 | WindowObject *_self; |
| 430 | PyObject *_args; |
| 431 | { |
| 432 | PyObject *_res = NULL; |
| 433 | long _rv; |
| 434 | Point startPt; |
| 435 | Rect bBox; |
| 436 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 437 | PyMac_GetPoint, &startPt, |
| 438 | PyMac_GetRect, &bBox)) |
| 439 | return NULL; |
| 440 | _rv = GrowWindow(_self->ob_itself, |
| 441 | startPt, |
| 442 | &bBox); |
| 443 | _res = Py_BuildValue("l", |
| 444 | _rv); |
| 445 | return _res; |
| 446 | } |
| 447 | |
| 448 | static PyObject *WinObj_TrackBox(_self, _args) |
| 449 | WindowObject *_self; |
| 450 | PyObject *_args; |
| 451 | { |
| 452 | PyObject *_res = NULL; |
| 453 | Boolean _rv; |
| 454 | Point thePt; |
| 455 | short partCode; |
| 456 | if (!PyArg_ParseTuple(_args, "O&h", |
| 457 | PyMac_GetPoint, &thePt, |
| 458 | &partCode)) |
| 459 | return NULL; |
| 460 | _rv = TrackBox(_self->ob_itself, |
| 461 | thePt, |
| 462 | partCode); |
| 463 | _res = Py_BuildValue("b", |
| 464 | _rv); |
| 465 | return _res; |
| 466 | } |
| 467 | |
| 468 | static PyObject *WinObj_GetWVariant(_self, _args) |
| 469 | WindowObject *_self; |
| 470 | PyObject *_args; |
| 471 | { |
| 472 | PyObject *_res = NULL; |
| 473 | short _rv; |
| 474 | if (!PyArg_ParseTuple(_args, "")) |
| 475 | return NULL; |
| 476 | _rv = GetWVariant(_self->ob_itself); |
| 477 | _res = Py_BuildValue("h", |
| 478 | _rv); |
| 479 | return _res; |
| 480 | } |
| 481 | |
| 482 | static PyObject *WinObj_SetWTitle(_self, _args) |
| 483 | WindowObject *_self; |
| 484 | PyObject *_args; |
| 485 | { |
| 486 | PyObject *_res = NULL; |
| 487 | Str255 title; |
| 488 | if (!PyArg_ParseTuple(_args, "O&", |
| 489 | PyMac_GetStr255, title)) |
| 490 | return NULL; |
| 491 | SetWTitle(_self->ob_itself, |
| 492 | title); |
| 493 | Py_INCREF(Py_None); |
| 494 | _res = Py_None; |
| 495 | return _res; |
| 496 | } |
| 497 | |
| 498 | static PyObject *WinObj_TrackGoAway(_self, _args) |
| 499 | WindowObject *_self; |
| 500 | PyObject *_args; |
| 501 | { |
| 502 | PyObject *_res = NULL; |
| 503 | Boolean _rv; |
| 504 | Point thePt; |
| 505 | if (!PyArg_ParseTuple(_args, "O&", |
| 506 | PyMac_GetPoint, &thePt)) |
| 507 | return NULL; |
| 508 | _rv = TrackGoAway(_self->ob_itself, |
| 509 | thePt); |
| 510 | _res = Py_BuildValue("b", |
| 511 | _rv); |
| 512 | return _res; |
| 513 | } |
| 514 | |
| 515 | static PyObject *WinObj_DragWindow(_self, _args) |
| 516 | WindowObject *_self; |
| 517 | PyObject *_args; |
| 518 | { |
| 519 | PyObject *_res = NULL; |
| 520 | Point startPt; |
| 521 | Rect boundsRect; |
| 522 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 523 | PyMac_GetPoint, &startPt, |
| 524 | PyMac_GetRect, &boundsRect)) |
| 525 | return NULL; |
| 526 | DragWindow(_self->ob_itself, |
| 527 | startPt, |
| 528 | &boundsRect); |
| 529 | Py_INCREF(Py_None); |
| 530 | _res = Py_None; |
| 531 | return _res; |
| 532 | } |
| 533 | |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame^] | 534 | static PyObject *WinObj_SetPortWindowPort(_self, _args) |
| 535 | WindowObject *_self; |
| 536 | PyObject *_args; |
| 537 | { |
| 538 | PyObject *_res = NULL; |
| 539 | if (!PyArg_ParseTuple(_args, "")) |
| 540 | return NULL; |
| 541 | SetPortWindowPort(_self->ob_itself); |
| 542 | Py_INCREF(Py_None); |
| 543 | _res = Py_None; |
| 544 | return _res; |
| 545 | } |
| 546 | |
| 547 | static PyObject *WinObj_GetWindowKind(_self, _args) |
| 548 | WindowObject *_self; |
| 549 | PyObject *_args; |
| 550 | { |
| 551 | PyObject *_res = NULL; |
| 552 | short _rv; |
| 553 | if (!PyArg_ParseTuple(_args, "")) |
| 554 | return NULL; |
| 555 | _rv = GetWindowKind(_self->ob_itself); |
| 556 | _res = Py_BuildValue("h", |
| 557 | _rv); |
| 558 | return _res; |
| 559 | } |
| 560 | |
| 561 | static PyObject *WinObj_SetWindowKind(_self, _args) |
| 562 | WindowObject *_self; |
| 563 | PyObject *_args; |
| 564 | { |
| 565 | PyObject *_res = NULL; |
| 566 | short wKind; |
| 567 | if (!PyArg_ParseTuple(_args, "h", |
| 568 | &wKind)) |
| 569 | return NULL; |
| 570 | SetWindowKind(_self->ob_itself, |
| 571 | wKind); |
| 572 | Py_INCREF(Py_None); |
| 573 | _res = Py_None; |
| 574 | return _res; |
| 575 | } |
| 576 | |
| 577 | static PyObject *WinObj_IsWindowVisible(_self, _args) |
| 578 | WindowObject *_self; |
| 579 | PyObject *_args; |
| 580 | { |
| 581 | PyObject *_res = NULL; |
| 582 | Boolean _rv; |
| 583 | if (!PyArg_ParseTuple(_args, "")) |
| 584 | return NULL; |
| 585 | _rv = IsWindowVisible(_self->ob_itself); |
| 586 | _res = Py_BuildValue("b", |
| 587 | _rv); |
| 588 | return _res; |
| 589 | } |
| 590 | |
| 591 | static PyObject *WinObj_IsWindowHilited(_self, _args) |
| 592 | WindowObject *_self; |
| 593 | PyObject *_args; |
| 594 | { |
| 595 | PyObject *_res = NULL; |
| 596 | Boolean _rv; |
| 597 | if (!PyArg_ParseTuple(_args, "")) |
| 598 | return NULL; |
| 599 | _rv = IsWindowHilited(_self->ob_itself); |
| 600 | _res = Py_BuildValue("b", |
| 601 | _rv); |
| 602 | return _res; |
| 603 | } |
| 604 | |
| 605 | static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args) |
| 606 | WindowObject *_self; |
| 607 | PyObject *_args; |
| 608 | { |
| 609 | PyObject *_res = NULL; |
| 610 | Boolean _rv; |
| 611 | if (!PyArg_ParseTuple(_args, "")) |
| 612 | return NULL; |
| 613 | _rv = GetWindowGoAwayFlag(_self->ob_itself); |
| 614 | _res = Py_BuildValue("b", |
| 615 | _rv); |
| 616 | return _res; |
| 617 | } |
| 618 | |
| 619 | static PyObject *WinObj_GetWindowZoomFlag(_self, _args) |
| 620 | WindowObject *_self; |
| 621 | PyObject *_args; |
| 622 | { |
| 623 | PyObject *_res = NULL; |
| 624 | Boolean _rv; |
| 625 | if (!PyArg_ParseTuple(_args, "")) |
| 626 | return NULL; |
| 627 | _rv = GetWindowZoomFlag(_self->ob_itself); |
| 628 | _res = Py_BuildValue("b", |
| 629 | _rv); |
| 630 | return _res; |
| 631 | } |
| 632 | |
| 633 | static PyObject *WinObj_GetWindowTitleWidth(_self, _args) |
| 634 | WindowObject *_self; |
| 635 | PyObject *_args; |
| 636 | { |
| 637 | PyObject *_res = NULL; |
| 638 | short _rv; |
| 639 | if (!PyArg_ParseTuple(_args, "")) |
| 640 | return NULL; |
| 641 | _rv = GetWindowTitleWidth(_self->ob_itself); |
| 642 | _res = Py_BuildValue("h", |
| 643 | _rv); |
| 644 | return _res; |
| 645 | } |
| 646 | |
| 647 | static PyObject *WinObj_GetNextWindow(_self, _args) |
| 648 | WindowObject *_self; |
| 649 | PyObject *_args; |
| 650 | { |
| 651 | PyObject *_res = NULL; |
| 652 | WindowPtr _rv; |
| 653 | if (!PyArg_ParseTuple(_args, "")) |
| 654 | return NULL; |
| 655 | _rv = GetNextWindow(_self->ob_itself); |
| 656 | _res = Py_BuildValue("O&", |
| 657 | WinObj_WhichWindow, _rv); |
| 658 | return _res; |
| 659 | } |
| 660 | |
| 661 | static PyObject *WinObj_GetWindowStandardState(_self, _args) |
| 662 | WindowObject *_self; |
| 663 | PyObject *_args; |
| 664 | { |
| 665 | PyObject *_res = NULL; |
| 666 | Rect r; |
| 667 | if (!PyArg_ParseTuple(_args, "")) |
| 668 | return NULL; |
| 669 | GetWindowStandardState(_self->ob_itself, |
| 670 | &r); |
| 671 | _res = Py_BuildValue("O&", |
| 672 | PyMac_BuildRect, &r); |
| 673 | return _res; |
| 674 | } |
| 675 | |
| 676 | static PyObject *WinObj_GetWindowUserState(_self, _args) |
| 677 | WindowObject *_self; |
| 678 | PyObject *_args; |
| 679 | { |
| 680 | PyObject *_res = NULL; |
| 681 | Rect r; |
| 682 | if (!PyArg_ParseTuple(_args, "")) |
| 683 | return NULL; |
| 684 | GetWindowUserState(_self->ob_itself, |
| 685 | &r); |
| 686 | _res = Py_BuildValue("O&", |
| 687 | PyMac_BuildRect, &r); |
| 688 | return _res; |
| 689 | } |
| 690 | |
| 691 | static PyObject *WinObj_SetWindowStandardState(_self, _args) |
| 692 | WindowObject *_self; |
| 693 | PyObject *_args; |
| 694 | { |
| 695 | PyObject *_res = NULL; |
| 696 | Rect r; |
| 697 | if (!PyArg_ParseTuple(_args, "O&", |
| 698 | PyMac_GetRect, &r)) |
| 699 | return NULL; |
| 700 | SetWindowStandardState(_self->ob_itself, |
| 701 | &r); |
| 702 | Py_INCREF(Py_None); |
| 703 | _res = Py_None; |
| 704 | return _res; |
| 705 | } |
| 706 | |
| 707 | static PyObject *WinObj_SetWindowUserState(_self, _args) |
| 708 | WindowObject *_self; |
| 709 | PyObject *_args; |
| 710 | { |
| 711 | PyObject *_res = NULL; |
| 712 | Rect r; |
| 713 | if (!PyArg_ParseTuple(_args, "O&", |
| 714 | PyMac_GetRect, &r)) |
| 715 | return NULL; |
| 716 | SetWindowUserState(_self->ob_itself, |
| 717 | &r); |
| 718 | Py_INCREF(Py_None); |
| 719 | _res = Py_None; |
| 720 | return _res; |
| 721 | } |
| 722 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 723 | static PyMethodDef WinObj_methods[] = { |
| 724 | {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1, |
| 725 | "() -> (Str255 title)"}, |
| 726 | {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1, |
| 727 | "() -> None"}, |
| 728 | {"HideWindow", (PyCFunction)WinObj_HideWindow, 1, |
| 729 | "() -> None"}, |
| 730 | {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1, |
| 731 | "() -> None"}, |
| 732 | {"ShowHide", (PyCFunction)WinObj_ShowHide, 1, |
| 733 | "(Boolean showFlag) -> None"}, |
| 734 | {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1, |
| 735 | "(Boolean fHilite) -> None"}, |
| 736 | {"BringToFront", (PyCFunction)WinObj_BringToFront, 1, |
| 737 | "() -> None"}, |
| 738 | {"SendBehind", (PyCFunction)WinObj_SendBehind, 1, |
| 739 | "(WindowPtr behindWindow) -> None"}, |
| 740 | {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1, |
| 741 | "() -> None"}, |
| 742 | {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1, |
| 743 | "(short hGlobal, short vGlobal, Boolean front) -> None"}, |
| 744 | {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1, |
| 745 | "(short w, short h, Boolean fUpdate) -> None"}, |
| 746 | {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1, |
| 747 | "(short partCode, Boolean front) -> None"}, |
| 748 | {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1, |
| 749 | "() -> None"}, |
| 750 | {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1, |
| 751 | "() -> None"}, |
| 752 | {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1, |
| 753 | "(long data) -> None"}, |
| 754 | {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1, |
| 755 | "() -> (long _rv)"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame^] | 756 | {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1, |
| 757 | "(PicHandle pic) -> None"}, |
| 758 | {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1, |
| 759 | "() -> (PicHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 760 | {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1, |
| 761 | "() -> None"}, |
| 762 | {"SaveOld", (PyCFunction)WinObj_SaveOld, 1, |
| 763 | "() -> None"}, |
| 764 | {"DrawNew", (PyCFunction)WinObj_DrawNew, 1, |
| 765 | "(Boolean update) -> None"}, |
| 766 | {"CalcVis", (PyCFunction)WinObj_CalcVis, 1, |
| 767 | "() -> None"}, |
| 768 | {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1, |
| 769 | "(Point startPt, Rect bBox) -> (long _rv)"}, |
| 770 | {"TrackBox", (PyCFunction)WinObj_TrackBox, 1, |
| 771 | "(Point thePt, short partCode) -> (Boolean _rv)"}, |
| 772 | {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1, |
| 773 | "() -> (short _rv)"}, |
| 774 | {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1, |
| 775 | "(Str255 title) -> None"}, |
| 776 | {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1, |
| 777 | "(Point thePt) -> (Boolean _rv)"}, |
| 778 | {"DragWindow", (PyCFunction)WinObj_DragWindow, 1, |
| 779 | "(Point startPt, Rect boundsRect) -> None"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame^] | 780 | {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1, |
| 781 | "() -> None"}, |
| 782 | {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1, |
| 783 | "() -> (short _rv)"}, |
| 784 | {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1, |
| 785 | "(short wKind) -> None"}, |
| 786 | {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1, |
| 787 | "() -> (Boolean _rv)"}, |
| 788 | {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1, |
| 789 | "() -> (Boolean _rv)"}, |
| 790 | {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1, |
| 791 | "() -> (Boolean _rv)"}, |
| 792 | {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1, |
| 793 | "() -> (Boolean _rv)"}, |
| 794 | {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1, |
| 795 | "() -> (short _rv)"}, |
| 796 | {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1, |
| 797 | "() -> (WindowPtr _rv)"}, |
| 798 | {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1, |
| 799 | "() -> (Rect r)"}, |
| 800 | {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1, |
| 801 | "() -> (Rect r)"}, |
| 802 | {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1, |
| 803 | "(Rect r) -> None"}, |
| 804 | {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1, |
| 805 | "(Rect r) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 806 | {NULL, NULL, 0} |
| 807 | }; |
| 808 | |
| 809 | PyMethodChain WinObj_chain = { WinObj_methods, NULL }; |
| 810 | |
| 811 | static PyObject *WinObj_getattr(self, name) |
| 812 | WindowObject *self; |
| 813 | char *name; |
| 814 | { |
| 815 | return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name); |
| 816 | } |
| 817 | |
| 818 | #define WinObj_setattr NULL |
| 819 | |
| 820 | PyTypeObject Window_Type = { |
| 821 | PyObject_HEAD_INIT(&PyType_Type) |
| 822 | 0, /*ob_size*/ |
| 823 | "Window", /*tp_name*/ |
| 824 | sizeof(WindowObject), /*tp_basicsize*/ |
| 825 | 0, /*tp_itemsize*/ |
| 826 | /* methods */ |
| 827 | (destructor) WinObj_dealloc, /*tp_dealloc*/ |
| 828 | 0, /*tp_print*/ |
| 829 | (getattrfunc) WinObj_getattr, /*tp_getattr*/ |
| 830 | (setattrfunc) WinObj_setattr, /*tp_setattr*/ |
| 831 | }; |
| 832 | |
| 833 | /* --------------------- End object type Window --------------------- */ |
| 834 | |
| 835 | |
| 836 | static PyObject *Win_InitWindows(_self, _args) |
| 837 | PyObject *_self; |
| 838 | PyObject *_args; |
| 839 | { |
| 840 | PyObject *_res = NULL; |
| 841 | if (!PyArg_ParseTuple(_args, "")) |
| 842 | return NULL; |
| 843 | InitWindows(); |
| 844 | Py_INCREF(Py_None); |
| 845 | _res = Py_None; |
| 846 | return _res; |
| 847 | } |
| 848 | |
| 849 | static PyObject *Win_NewWindow(_self, _args) |
| 850 | PyObject *_self; |
| 851 | PyObject *_args; |
| 852 | { |
| 853 | PyObject *_res = NULL; |
| 854 | WindowPtr _rv; |
| 855 | Rect boundsRect; |
| 856 | Str255 title; |
| 857 | Boolean visible; |
| 858 | short theProc; |
| 859 | WindowPtr behind; |
| 860 | Boolean goAwayFlag; |
| 861 | long refCon; |
| 862 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 863 | PyMac_GetRect, &boundsRect, |
| 864 | PyMac_GetStr255, title, |
| 865 | &visible, |
| 866 | &theProc, |
| 867 | WinObj_Convert, &behind, |
| 868 | &goAwayFlag, |
| 869 | &refCon)) |
| 870 | return NULL; |
| 871 | _rv = NewWindow((void *)0, |
| 872 | &boundsRect, |
| 873 | title, |
| 874 | visible, |
| 875 | theProc, |
| 876 | behind, |
| 877 | goAwayFlag, |
| 878 | refCon); |
| 879 | _res = Py_BuildValue("O&", |
| 880 | WinObj_New, _rv); |
| 881 | return _res; |
| 882 | } |
| 883 | |
| 884 | static PyObject *Win_GetNewWindow(_self, _args) |
| 885 | PyObject *_self; |
| 886 | PyObject *_args; |
| 887 | { |
| 888 | PyObject *_res = NULL; |
| 889 | WindowPtr _rv; |
| 890 | short windowID; |
| 891 | WindowPtr behind; |
| 892 | if (!PyArg_ParseTuple(_args, "hO&", |
| 893 | &windowID, |
| 894 | WinObj_Convert, &behind)) |
| 895 | return NULL; |
| 896 | _rv = GetNewWindow(windowID, |
| 897 | (void *)0, |
| 898 | behind); |
| 899 | _res = Py_BuildValue("O&", |
| 900 | WinObj_New, _rv); |
| 901 | return _res; |
| 902 | } |
| 903 | |
| 904 | static PyObject *Win_FrontWindow(_self, _args) |
| 905 | PyObject *_self; |
| 906 | PyObject *_args; |
| 907 | { |
| 908 | PyObject *_res = NULL; |
| 909 | WindowPtr _rv; |
| 910 | if (!PyArg_ParseTuple(_args, "")) |
| 911 | return NULL; |
| 912 | _rv = FrontWindow(); |
| 913 | _res = Py_BuildValue("O&", |
Guido van Rossum | ea39abd | 1995-02-28 09:49:02 +0000 | [diff] [blame] | 914 | WinObj_WhichWindow, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 915 | return _res; |
| 916 | } |
| 917 | |
| 918 | static PyObject *Win_InvalRect(_self, _args) |
| 919 | PyObject *_self; |
| 920 | PyObject *_args; |
| 921 | { |
| 922 | PyObject *_res = NULL; |
| 923 | Rect badRect; |
| 924 | if (!PyArg_ParseTuple(_args, "O&", |
| 925 | PyMac_GetRect, &badRect)) |
| 926 | return NULL; |
| 927 | InvalRect(&badRect); |
| 928 | Py_INCREF(Py_None); |
| 929 | _res = Py_None; |
| 930 | return _res; |
| 931 | } |
| 932 | |
| 933 | static PyObject *Win_ValidRect(_self, _args) |
| 934 | PyObject *_self; |
| 935 | PyObject *_args; |
| 936 | { |
| 937 | PyObject *_res = NULL; |
| 938 | Rect goodRect; |
| 939 | if (!PyArg_ParseTuple(_args, "O&", |
| 940 | PyMac_GetRect, &goodRect)) |
| 941 | return NULL; |
| 942 | ValidRect(&goodRect); |
| 943 | Py_INCREF(Py_None); |
| 944 | _res = Py_None; |
| 945 | return _res; |
| 946 | } |
| 947 | |
| 948 | static PyObject *Win_CheckUpdate(_self, _args) |
| 949 | PyObject *_self; |
| 950 | PyObject *_args; |
| 951 | { |
| 952 | PyObject *_res = NULL; |
| 953 | Boolean _rv; |
| 954 | EventRecord theEvent; |
| 955 | if (!PyArg_ParseTuple(_args, "")) |
| 956 | return NULL; |
| 957 | _rv = CheckUpdate(&theEvent); |
| 958 | _res = Py_BuildValue("bO&", |
| 959 | _rv, |
| 960 | PyMac_BuildEventRecord, &theEvent); |
| 961 | return _res; |
| 962 | } |
| 963 | |
| 964 | static PyObject *Win_FindWindow(_self, _args) |
| 965 | PyObject *_self; |
| 966 | PyObject *_args; |
| 967 | { |
| 968 | PyObject *_res = NULL; |
| 969 | short _rv; |
| 970 | Point thePoint; |
| 971 | WindowPtr theWindow; |
| 972 | if (!PyArg_ParseTuple(_args, "O&", |
| 973 | PyMac_GetPoint, &thePoint)) |
| 974 | return NULL; |
| 975 | _rv = FindWindow(thePoint, |
| 976 | &theWindow); |
| 977 | _res = Py_BuildValue("hO&", |
| 978 | _rv, |
| 979 | WinObj_WhichWindow, theWindow); |
| 980 | return _res; |
| 981 | } |
| 982 | |
| 983 | static PyObject *Win_PinRect(_self, _args) |
| 984 | PyObject *_self; |
| 985 | PyObject *_args; |
| 986 | { |
| 987 | PyObject *_res = NULL; |
| 988 | long _rv; |
| 989 | Rect theRect; |
| 990 | Point thePt; |
| 991 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 992 | PyMac_GetRect, &theRect, |
| 993 | PyMac_GetPoint, &thePt)) |
| 994 | return NULL; |
| 995 | _rv = PinRect(&theRect, |
| 996 | thePt); |
| 997 | _res = Py_BuildValue("l", |
| 998 | _rv); |
| 999 | return _res; |
| 1000 | } |
| 1001 | |
| 1002 | static PyObject *Win_NewCWindow(_self, _args) |
| 1003 | PyObject *_self; |
| 1004 | PyObject *_args; |
| 1005 | { |
| 1006 | PyObject *_res = NULL; |
| 1007 | WindowPtr _rv; |
| 1008 | Rect boundsRect; |
| 1009 | Str255 title; |
| 1010 | Boolean visible; |
| 1011 | short procID; |
| 1012 | WindowPtr behind; |
| 1013 | Boolean goAwayFlag; |
| 1014 | long refCon; |
| 1015 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 1016 | PyMac_GetRect, &boundsRect, |
| 1017 | PyMac_GetStr255, title, |
| 1018 | &visible, |
| 1019 | &procID, |
| 1020 | WinObj_Convert, &behind, |
| 1021 | &goAwayFlag, |
| 1022 | &refCon)) |
| 1023 | return NULL; |
| 1024 | _rv = NewCWindow((void *)0, |
| 1025 | &boundsRect, |
| 1026 | title, |
| 1027 | visible, |
| 1028 | procID, |
| 1029 | behind, |
| 1030 | goAwayFlag, |
| 1031 | refCon); |
| 1032 | _res = Py_BuildValue("O&", |
| 1033 | WinObj_New, _rv); |
| 1034 | return _res; |
| 1035 | } |
| 1036 | |
| 1037 | static PyObject *Win_GetNewCWindow(_self, _args) |
| 1038 | PyObject *_self; |
| 1039 | PyObject *_args; |
| 1040 | { |
| 1041 | PyObject *_res = NULL; |
| 1042 | WindowPtr _rv; |
| 1043 | short windowID; |
| 1044 | WindowPtr behind; |
| 1045 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1046 | &windowID, |
| 1047 | WinObj_Convert, &behind)) |
| 1048 | return NULL; |
| 1049 | _rv = GetNewCWindow(windowID, |
| 1050 | (void *)0, |
| 1051 | behind); |
| 1052 | _res = Py_BuildValue("O&", |
| 1053 | WinObj_New, _rv); |
| 1054 | return _res; |
| 1055 | } |
| 1056 | |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1057 | static PyObject *Win_WhichWindow(_self, _args) |
| 1058 | PyObject *_self; |
| 1059 | PyObject *_args; |
| 1060 | { |
| 1061 | PyObject *_res = NULL; |
| 1062 | |
| 1063 | long ptr; |
| 1064 | |
| 1065 | if ( !PyArg_ParseTuple(_args, "i", &ptr) ) |
| 1066 | return NULL; |
| 1067 | return WinObj_WhichWindow((WindowPtr)ptr); |
| 1068 | |
| 1069 | } |
| 1070 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1071 | static PyMethodDef Win_methods[] = { |
| 1072 | {"InitWindows", (PyCFunction)Win_InitWindows, 1, |
| 1073 | "() -> None"}, |
| 1074 | {"NewWindow", (PyCFunction)Win_NewWindow, 1, |
| 1075 | "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
| 1076 | {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1, |
| 1077 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
| 1078 | {"FrontWindow", (PyCFunction)Win_FrontWindow, 1, |
| 1079 | "() -> (WindowPtr _rv)"}, |
| 1080 | {"InvalRect", (PyCFunction)Win_InvalRect, 1, |
| 1081 | "(Rect badRect) -> None"}, |
| 1082 | {"ValidRect", (PyCFunction)Win_ValidRect, 1, |
| 1083 | "(Rect goodRect) -> None"}, |
| 1084 | {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1, |
| 1085 | "() -> (Boolean _rv, EventRecord theEvent)"}, |
| 1086 | {"FindWindow", (PyCFunction)Win_FindWindow, 1, |
| 1087 | "(Point thePoint) -> (short _rv, WindowPtr theWindow)"}, |
| 1088 | {"PinRect", (PyCFunction)Win_PinRect, 1, |
| 1089 | "(Rect theRect, Point thePt) -> (long _rv)"}, |
| 1090 | {"NewCWindow", (PyCFunction)Win_NewCWindow, 1, |
| 1091 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
| 1092 | {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1, |
| 1093 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1094 | {"WhichWindow", (PyCFunction)Win_WhichWindow, 1, |
| 1095 | "Resolve an integer WindowPtr address to a Window object"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1096 | {NULL, NULL, 0} |
| 1097 | }; |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | /* Return the object corresponding to the window, or NULL */ |
| 1102 | |
| 1103 | PyObject * |
| 1104 | WinObj_WhichWindow(w) |
| 1105 | WindowPtr w; |
| 1106 | { |
| 1107 | PyObject *it; |
| 1108 | |
| 1109 | /* XXX What if we find a stdwin window or a window belonging |
| 1110 | to some other package? */ |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 1111 | if (w == NULL) |
| 1112 | it = NULL; |
| 1113 | else |
| 1114 | it = (PyObject *) GetWRefCon(w); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1115 | if (it == NULL || ((WindowObject *)it)->ob_itself != w) |
| 1116 | it = Py_None; |
| 1117 | Py_INCREF(it); |
| 1118 | return it; |
| 1119 | } |
| 1120 | |
| 1121 | |
| 1122 | void initWin() |
| 1123 | { |
| 1124 | PyObject *m; |
| 1125 | PyObject *d; |
| 1126 | |
| 1127 | |
| 1128 | |
| 1129 | |
| 1130 | m = Py_InitModule("Win", Win_methods); |
| 1131 | d = PyModule_GetDict(m); |
| 1132 | Win_Error = PyMac_GetOSErrException(); |
| 1133 | if (Win_Error == NULL || |
| 1134 | PyDict_SetItemString(d, "Error", Win_Error) != 0) |
| 1135 | Py_FatalError("can't initialize Win.Error"); |
| 1136 | } |
| 1137 | |
| 1138 | /* ========================= End module Win ========================= */ |
| 1139 | |