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