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