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 | |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 525 | static PyObject *WinObj_SetWinColor(_self, _args) |
| 526 | WindowObject *_self; |
| 527 | PyObject *_args; |
| 528 | { |
| 529 | PyObject *_res = NULL; |
| 530 | WCTabHandle newColorTable; |
| 531 | if (!PyArg_ParseTuple(_args, "O&", |
| 532 | ResObj_Convert, &newColorTable)) |
| 533 | return NULL; |
| 534 | SetWinColor(_self->ob_itself, |
| 535 | newColorTable); |
| 536 | Py_INCREF(Py_None); |
| 537 | _res = Py_None; |
| 538 | return _res; |
| 539 | } |
| 540 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 541 | static PyObject *WinObj_GetWVariant(_self, _args) |
| 542 | WindowObject *_self; |
| 543 | PyObject *_args; |
| 544 | { |
| 545 | PyObject *_res = NULL; |
| 546 | short _rv; |
| 547 | if (!PyArg_ParseTuple(_args, "")) |
| 548 | return NULL; |
| 549 | _rv = GetWVariant(_self->ob_itself); |
| 550 | _res = Py_BuildValue("h", |
| 551 | _rv); |
| 552 | return _res; |
| 553 | } |
| 554 | |
| 555 | static PyObject *WinObj_SetWTitle(_self, _args) |
| 556 | WindowObject *_self; |
| 557 | PyObject *_args; |
| 558 | { |
| 559 | PyObject *_res = NULL; |
| 560 | Str255 title; |
| 561 | if (!PyArg_ParseTuple(_args, "O&", |
| 562 | PyMac_GetStr255, title)) |
| 563 | return NULL; |
| 564 | SetWTitle(_self->ob_itself, |
| 565 | title); |
| 566 | Py_INCREF(Py_None); |
| 567 | _res = Py_None; |
| 568 | return _res; |
| 569 | } |
| 570 | |
| 571 | static PyObject *WinObj_TrackGoAway(_self, _args) |
| 572 | WindowObject *_self; |
| 573 | PyObject *_args; |
| 574 | { |
| 575 | PyObject *_res = NULL; |
| 576 | Boolean _rv; |
| 577 | Point thePt; |
| 578 | if (!PyArg_ParseTuple(_args, "O&", |
| 579 | PyMac_GetPoint, &thePt)) |
| 580 | return NULL; |
| 581 | _rv = TrackGoAway(_self->ob_itself, |
| 582 | thePt); |
| 583 | _res = Py_BuildValue("b", |
| 584 | _rv); |
| 585 | return _res; |
| 586 | } |
| 587 | |
| 588 | static PyObject *WinObj_DragWindow(_self, _args) |
| 589 | WindowObject *_self; |
| 590 | PyObject *_args; |
| 591 | { |
| 592 | PyObject *_res = NULL; |
| 593 | Point startPt; |
| 594 | Rect boundsRect; |
| 595 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 596 | PyMac_GetPoint, &startPt, |
| 597 | PyMac_GetRect, &boundsRect)) |
| 598 | return NULL; |
| 599 | DragWindow(_self->ob_itself, |
| 600 | startPt, |
| 601 | &boundsRect); |
| 602 | Py_INCREF(Py_None); |
| 603 | _res = Py_None; |
| 604 | return _res; |
| 605 | } |
| 606 | |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 607 | static PyObject *WinObj_GetAuxWin(_self, _args) |
| 608 | WindowObject *_self; |
| 609 | PyObject *_args; |
| 610 | { |
| 611 | PyObject *_res = NULL; |
| 612 | Boolean _rv; |
| 613 | AuxWinHandle awHndl; |
| 614 | if (!PyArg_ParseTuple(_args, "")) |
| 615 | return NULL; |
| 616 | _rv = GetAuxWin(_self->ob_itself, |
| 617 | &awHndl); |
| 618 | _res = Py_BuildValue("bO&", |
| 619 | _rv, |
| 620 | ResObj_New, awHndl); |
| 621 | return _res; |
| 622 | } |
| 623 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 624 | static PyObject *WinObj_GetWindowPort(_self, _args) |
| 625 | WindowObject *_self; |
| 626 | PyObject *_args; |
| 627 | { |
| 628 | PyObject *_res = NULL; |
| 629 | CGrafPtr _rv; |
| 630 | if (!PyArg_ParseTuple(_args, "")) |
| 631 | return NULL; |
| 632 | _rv = GetWindowPort(_self->ob_itself); |
| 633 | _res = Py_BuildValue("O&", |
| 634 | GrafObj_New, _rv); |
| 635 | return _res; |
| 636 | } |
| 637 | |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 638 | static PyObject *WinObj_SetPortWindowPort(_self, _args) |
| 639 | WindowObject *_self; |
| 640 | PyObject *_args; |
| 641 | { |
| 642 | PyObject *_res = NULL; |
| 643 | if (!PyArg_ParseTuple(_args, "")) |
| 644 | return NULL; |
| 645 | SetPortWindowPort(_self->ob_itself); |
| 646 | Py_INCREF(Py_None); |
| 647 | _res = Py_None; |
| 648 | return _res; |
| 649 | } |
| 650 | |
| 651 | static PyObject *WinObj_GetWindowKind(_self, _args) |
| 652 | WindowObject *_self; |
| 653 | PyObject *_args; |
| 654 | { |
| 655 | PyObject *_res = NULL; |
| 656 | short _rv; |
| 657 | if (!PyArg_ParseTuple(_args, "")) |
| 658 | return NULL; |
| 659 | _rv = GetWindowKind(_self->ob_itself); |
| 660 | _res = Py_BuildValue("h", |
| 661 | _rv); |
| 662 | return _res; |
| 663 | } |
| 664 | |
| 665 | static PyObject *WinObj_SetWindowKind(_self, _args) |
| 666 | WindowObject *_self; |
| 667 | PyObject *_args; |
| 668 | { |
| 669 | PyObject *_res = NULL; |
| 670 | short wKind; |
| 671 | if (!PyArg_ParseTuple(_args, "h", |
| 672 | &wKind)) |
| 673 | return NULL; |
| 674 | SetWindowKind(_self->ob_itself, |
| 675 | wKind); |
| 676 | Py_INCREF(Py_None); |
| 677 | _res = Py_None; |
| 678 | return _res; |
| 679 | } |
| 680 | |
| 681 | static PyObject *WinObj_IsWindowVisible(_self, _args) |
| 682 | WindowObject *_self; |
| 683 | PyObject *_args; |
| 684 | { |
| 685 | PyObject *_res = NULL; |
| 686 | Boolean _rv; |
| 687 | if (!PyArg_ParseTuple(_args, "")) |
| 688 | return NULL; |
| 689 | _rv = IsWindowVisible(_self->ob_itself); |
| 690 | _res = Py_BuildValue("b", |
| 691 | _rv); |
| 692 | return _res; |
| 693 | } |
| 694 | |
| 695 | static PyObject *WinObj_IsWindowHilited(_self, _args) |
| 696 | WindowObject *_self; |
| 697 | PyObject *_args; |
| 698 | { |
| 699 | PyObject *_res = NULL; |
| 700 | Boolean _rv; |
| 701 | if (!PyArg_ParseTuple(_args, "")) |
| 702 | return NULL; |
| 703 | _rv = IsWindowHilited(_self->ob_itself); |
| 704 | _res = Py_BuildValue("b", |
| 705 | _rv); |
| 706 | return _res; |
| 707 | } |
| 708 | |
| 709 | static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args) |
| 710 | WindowObject *_self; |
| 711 | PyObject *_args; |
| 712 | { |
| 713 | PyObject *_res = NULL; |
| 714 | Boolean _rv; |
| 715 | if (!PyArg_ParseTuple(_args, "")) |
| 716 | return NULL; |
| 717 | _rv = GetWindowGoAwayFlag(_self->ob_itself); |
| 718 | _res = Py_BuildValue("b", |
| 719 | _rv); |
| 720 | return _res; |
| 721 | } |
| 722 | |
| 723 | static PyObject *WinObj_GetWindowZoomFlag(_self, _args) |
| 724 | WindowObject *_self; |
| 725 | PyObject *_args; |
| 726 | { |
| 727 | PyObject *_res = NULL; |
| 728 | Boolean _rv; |
| 729 | if (!PyArg_ParseTuple(_args, "")) |
| 730 | return NULL; |
| 731 | _rv = GetWindowZoomFlag(_self->ob_itself); |
| 732 | _res = Py_BuildValue("b", |
| 733 | _rv); |
| 734 | return _res; |
| 735 | } |
| 736 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 737 | static PyObject *WinObj_GetWindowStructureRgn(_self, _args) |
| 738 | WindowObject *_self; |
| 739 | PyObject *_args; |
| 740 | { |
| 741 | PyObject *_res = NULL; |
| 742 | RgnHandle r; |
| 743 | if (!PyArg_ParseTuple(_args, "O&", |
| 744 | ResObj_Convert, &r)) |
| 745 | return NULL; |
| 746 | GetWindowStructureRgn(_self->ob_itself, |
| 747 | r); |
| 748 | Py_INCREF(Py_None); |
| 749 | _res = Py_None; |
| 750 | return _res; |
| 751 | } |
| 752 | |
| 753 | static PyObject *WinObj_GetWindowContentRgn(_self, _args) |
| 754 | WindowObject *_self; |
| 755 | PyObject *_args; |
| 756 | { |
| 757 | PyObject *_res = NULL; |
| 758 | RgnHandle r; |
| 759 | if (!PyArg_ParseTuple(_args, "O&", |
| 760 | ResObj_Convert, &r)) |
| 761 | return NULL; |
| 762 | GetWindowContentRgn(_self->ob_itself, |
| 763 | r); |
| 764 | Py_INCREF(Py_None); |
| 765 | _res = Py_None; |
| 766 | return _res; |
| 767 | } |
| 768 | |
| 769 | static PyObject *WinObj_GetWindowUpdateRgn(_self, _args) |
| 770 | WindowObject *_self; |
| 771 | PyObject *_args; |
| 772 | { |
| 773 | PyObject *_res = NULL; |
| 774 | RgnHandle r; |
| 775 | if (!PyArg_ParseTuple(_args, "O&", |
| 776 | ResObj_Convert, &r)) |
| 777 | return NULL; |
| 778 | GetWindowUpdateRgn(_self->ob_itself, |
| 779 | r); |
| 780 | Py_INCREF(Py_None); |
| 781 | _res = Py_None; |
| 782 | return _res; |
| 783 | } |
| 784 | |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 785 | static PyObject *WinObj_GetWindowTitleWidth(_self, _args) |
| 786 | WindowObject *_self; |
| 787 | PyObject *_args; |
| 788 | { |
| 789 | PyObject *_res = NULL; |
| 790 | short _rv; |
| 791 | if (!PyArg_ParseTuple(_args, "")) |
| 792 | return NULL; |
| 793 | _rv = GetWindowTitleWidth(_self->ob_itself); |
| 794 | _res = Py_BuildValue("h", |
| 795 | _rv); |
| 796 | return _res; |
| 797 | } |
| 798 | |
| 799 | static PyObject *WinObj_GetNextWindow(_self, _args) |
| 800 | WindowObject *_self; |
| 801 | PyObject *_args; |
| 802 | { |
| 803 | PyObject *_res = NULL; |
| 804 | WindowPtr _rv; |
| 805 | if (!PyArg_ParseTuple(_args, "")) |
| 806 | return NULL; |
| 807 | _rv = GetNextWindow(_self->ob_itself); |
| 808 | _res = Py_BuildValue("O&", |
| 809 | WinObj_WhichWindow, _rv); |
| 810 | return _res; |
| 811 | } |
| 812 | |
| 813 | static PyObject *WinObj_GetWindowStandardState(_self, _args) |
| 814 | WindowObject *_self; |
| 815 | PyObject *_args; |
| 816 | { |
| 817 | PyObject *_res = NULL; |
| 818 | Rect r; |
| 819 | if (!PyArg_ParseTuple(_args, "")) |
| 820 | return NULL; |
| 821 | GetWindowStandardState(_self->ob_itself, |
| 822 | &r); |
| 823 | _res = Py_BuildValue("O&", |
| 824 | PyMac_BuildRect, &r); |
| 825 | return _res; |
| 826 | } |
| 827 | |
| 828 | static PyObject *WinObj_GetWindowUserState(_self, _args) |
| 829 | WindowObject *_self; |
| 830 | PyObject *_args; |
| 831 | { |
| 832 | PyObject *_res = NULL; |
| 833 | Rect r; |
| 834 | if (!PyArg_ParseTuple(_args, "")) |
| 835 | return NULL; |
| 836 | GetWindowUserState(_self->ob_itself, |
| 837 | &r); |
| 838 | _res = Py_BuildValue("O&", |
| 839 | PyMac_BuildRect, &r); |
| 840 | return _res; |
| 841 | } |
| 842 | |
| 843 | static PyObject *WinObj_SetWindowStandardState(_self, _args) |
| 844 | WindowObject *_self; |
| 845 | PyObject *_args; |
| 846 | { |
| 847 | PyObject *_res = NULL; |
| 848 | Rect r; |
| 849 | if (!PyArg_ParseTuple(_args, "O&", |
| 850 | PyMac_GetRect, &r)) |
| 851 | return NULL; |
| 852 | SetWindowStandardState(_self->ob_itself, |
| 853 | &r); |
| 854 | Py_INCREF(Py_None); |
| 855 | _res = Py_None; |
| 856 | return _res; |
| 857 | } |
| 858 | |
| 859 | static PyObject *WinObj_SetWindowUserState(_self, _args) |
| 860 | WindowObject *_self; |
| 861 | PyObject *_args; |
| 862 | { |
| 863 | PyObject *_res = NULL; |
| 864 | Rect r; |
| 865 | if (!PyArg_ParseTuple(_args, "O&", |
| 866 | PyMac_GetRect, &r)) |
| 867 | return NULL; |
| 868 | SetWindowUserState(_self->ob_itself, |
| 869 | &r); |
| 870 | Py_INCREF(Py_None); |
| 871 | _res = Py_None; |
| 872 | return _res; |
| 873 | } |
| 874 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 875 | static PyMethodDef WinObj_methods[] = { |
| 876 | {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1, |
| 877 | "() -> (Str255 title)"}, |
| 878 | {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1, |
| 879 | "() -> None"}, |
| 880 | {"HideWindow", (PyCFunction)WinObj_HideWindow, 1, |
| 881 | "() -> None"}, |
| 882 | {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1, |
| 883 | "() -> None"}, |
| 884 | {"ShowHide", (PyCFunction)WinObj_ShowHide, 1, |
| 885 | "(Boolean showFlag) -> None"}, |
| 886 | {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1, |
| 887 | "(Boolean fHilite) -> None"}, |
| 888 | {"BringToFront", (PyCFunction)WinObj_BringToFront, 1, |
| 889 | "() -> None"}, |
| 890 | {"SendBehind", (PyCFunction)WinObj_SendBehind, 1, |
| 891 | "(WindowPtr behindWindow) -> None"}, |
| 892 | {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1, |
| 893 | "() -> None"}, |
| 894 | {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1, |
| 895 | "(short hGlobal, short vGlobal, Boolean front) -> None"}, |
| 896 | {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1, |
| 897 | "(short w, short h, Boolean fUpdate) -> None"}, |
| 898 | {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1, |
| 899 | "(short partCode, Boolean front) -> None"}, |
| 900 | {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1, |
| 901 | "() -> None"}, |
| 902 | {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1, |
| 903 | "() -> None"}, |
| 904 | {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1, |
| 905 | "(long data) -> None"}, |
| 906 | {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1, |
| 907 | "() -> (long _rv)"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 908 | {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1, |
| 909 | "(PicHandle pic) -> None"}, |
| 910 | {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1, |
| 911 | "() -> (PicHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 912 | {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1, |
| 913 | "() -> None"}, |
| 914 | {"SaveOld", (PyCFunction)WinObj_SaveOld, 1, |
| 915 | "() -> None"}, |
| 916 | {"DrawNew", (PyCFunction)WinObj_DrawNew, 1, |
| 917 | "(Boolean update) -> None"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 918 | {"PaintOne", (PyCFunction)WinObj_PaintOne, 1, |
| 919 | "(RgnHandle clobberedRgn) -> None"}, |
| 920 | {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1, |
| 921 | "(RgnHandle clobberedRgn) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 922 | {"CalcVis", (PyCFunction)WinObj_CalcVis, 1, |
| 923 | "() -> None"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 924 | {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1, |
| 925 | "(RgnHandle clobberedRgn) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 926 | {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1, |
| 927 | "(Point startPt, Rect bBox) -> (long _rv)"}, |
| 928 | {"TrackBox", (PyCFunction)WinObj_TrackBox, 1, |
| 929 | "(Point thePt, short partCode) -> (Boolean _rv)"}, |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 930 | {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1, |
| 931 | "(WCTabHandle newColorTable) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 932 | {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1, |
| 933 | "() -> (short _rv)"}, |
| 934 | {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1, |
| 935 | "(Str255 title) -> None"}, |
| 936 | {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1, |
| 937 | "(Point thePt) -> (Boolean _rv)"}, |
| 938 | {"DragWindow", (PyCFunction)WinObj_DragWindow, 1, |
| 939 | "(Point startPt, Rect boundsRect) -> None"}, |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 940 | {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1, |
| 941 | "() -> (Boolean _rv, AuxWinHandle awHndl)"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 942 | {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1, |
| 943 | "() -> (CGrafPtr _rv)"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 944 | {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1, |
| 945 | "() -> None"}, |
| 946 | {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1, |
| 947 | "() -> (short _rv)"}, |
| 948 | {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1, |
| 949 | "(short wKind) -> None"}, |
| 950 | {"IsWindowVisible", (PyCFunction)WinObj_IsWindowVisible, 1, |
| 951 | "() -> (Boolean _rv)"}, |
| 952 | {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1, |
| 953 | "() -> (Boolean _rv)"}, |
| 954 | {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1, |
| 955 | "() -> (Boolean _rv)"}, |
| 956 | {"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1, |
| 957 | "() -> (Boolean _rv)"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 958 | {"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1, |
| 959 | "(RgnHandle r) -> None"}, |
| 960 | {"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1, |
| 961 | "(RgnHandle r) -> None"}, |
| 962 | {"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1, |
| 963 | "(RgnHandle r) -> None"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 964 | {"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1, |
| 965 | "() -> (short _rv)"}, |
| 966 | {"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1, |
| 967 | "() -> (WindowPtr _rv)"}, |
| 968 | {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1, |
| 969 | "() -> (Rect r)"}, |
| 970 | {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1, |
| 971 | "() -> (Rect r)"}, |
| 972 | {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1, |
| 973 | "(Rect r) -> None"}, |
| 974 | {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1, |
| 975 | "(Rect r) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 976 | {NULL, NULL, 0} |
| 977 | }; |
| 978 | |
| 979 | PyMethodChain WinObj_chain = { WinObj_methods, NULL }; |
| 980 | |
| 981 | static PyObject *WinObj_getattr(self, name) |
| 982 | WindowObject *self; |
| 983 | char *name; |
| 984 | { |
| 985 | return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name); |
| 986 | } |
| 987 | |
| 988 | #define WinObj_setattr NULL |
| 989 | |
| 990 | PyTypeObject Window_Type = { |
| 991 | PyObject_HEAD_INIT(&PyType_Type) |
| 992 | 0, /*ob_size*/ |
| 993 | "Window", /*tp_name*/ |
| 994 | sizeof(WindowObject), /*tp_basicsize*/ |
| 995 | 0, /*tp_itemsize*/ |
| 996 | /* methods */ |
| 997 | (destructor) WinObj_dealloc, /*tp_dealloc*/ |
| 998 | 0, /*tp_print*/ |
| 999 | (getattrfunc) WinObj_getattr, /*tp_getattr*/ |
| 1000 | (setattrfunc) WinObj_setattr, /*tp_setattr*/ |
| 1001 | }; |
| 1002 | |
| 1003 | /* --------------------- End object type Window --------------------- */ |
| 1004 | |
| 1005 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1006 | static PyObject *Win_GetGrayRgn(_self, _args) |
| 1007 | PyObject *_self; |
| 1008 | PyObject *_args; |
| 1009 | { |
| 1010 | PyObject *_res = NULL; |
| 1011 | RgnHandle _rv; |
| 1012 | if (!PyArg_ParseTuple(_args, "")) |
| 1013 | return NULL; |
| 1014 | _rv = GetGrayRgn(); |
| 1015 | _res = Py_BuildValue("O&", |
| 1016 | ResObj_New, _rv); |
| 1017 | return _res; |
| 1018 | } |
| 1019 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1020 | static PyObject *Win_InitWindows(_self, _args) |
| 1021 | PyObject *_self; |
| 1022 | PyObject *_args; |
| 1023 | { |
| 1024 | PyObject *_res = NULL; |
| 1025 | if (!PyArg_ParseTuple(_args, "")) |
| 1026 | return NULL; |
| 1027 | InitWindows(); |
| 1028 | Py_INCREF(Py_None); |
| 1029 | _res = Py_None; |
| 1030 | return _res; |
| 1031 | } |
| 1032 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1033 | static PyObject *Win_GetWMgrPort(_self, _args) |
| 1034 | PyObject *_self; |
| 1035 | PyObject *_args; |
| 1036 | { |
| 1037 | PyObject *_res = NULL; |
| 1038 | GrafPtr wPort; |
| 1039 | if (!PyArg_ParseTuple(_args, "")) |
| 1040 | return NULL; |
| 1041 | GetWMgrPort(&wPort); |
| 1042 | _res = Py_BuildValue("O&", |
| 1043 | GrafObj_New, wPort); |
| 1044 | return _res; |
| 1045 | } |
| 1046 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1047 | static PyObject *Win_NewWindow(_self, _args) |
| 1048 | PyObject *_self; |
| 1049 | PyObject *_args; |
| 1050 | { |
| 1051 | PyObject *_res = NULL; |
| 1052 | WindowPtr _rv; |
| 1053 | Rect boundsRect; |
| 1054 | Str255 title; |
| 1055 | Boolean visible; |
| 1056 | short theProc; |
| 1057 | WindowPtr behind; |
| 1058 | Boolean goAwayFlag; |
| 1059 | long refCon; |
| 1060 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 1061 | PyMac_GetRect, &boundsRect, |
| 1062 | PyMac_GetStr255, title, |
| 1063 | &visible, |
| 1064 | &theProc, |
| 1065 | WinObj_Convert, &behind, |
| 1066 | &goAwayFlag, |
| 1067 | &refCon)) |
| 1068 | return NULL; |
| 1069 | _rv = NewWindow((void *)0, |
| 1070 | &boundsRect, |
| 1071 | title, |
| 1072 | visible, |
| 1073 | theProc, |
| 1074 | behind, |
| 1075 | goAwayFlag, |
| 1076 | refCon); |
| 1077 | _res = Py_BuildValue("O&", |
| 1078 | WinObj_New, _rv); |
| 1079 | return _res; |
| 1080 | } |
| 1081 | |
| 1082 | static PyObject *Win_GetNewWindow(_self, _args) |
| 1083 | PyObject *_self; |
| 1084 | PyObject *_args; |
| 1085 | { |
| 1086 | PyObject *_res = NULL; |
| 1087 | WindowPtr _rv; |
| 1088 | short windowID; |
| 1089 | WindowPtr behind; |
| 1090 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1091 | &windowID, |
| 1092 | WinObj_Convert, &behind)) |
| 1093 | return NULL; |
| 1094 | _rv = GetNewWindow(windowID, |
| 1095 | (void *)0, |
| 1096 | behind); |
| 1097 | _res = Py_BuildValue("O&", |
| 1098 | WinObj_New, _rv); |
| 1099 | return _res; |
| 1100 | } |
| 1101 | |
| 1102 | static PyObject *Win_FrontWindow(_self, _args) |
| 1103 | PyObject *_self; |
| 1104 | PyObject *_args; |
| 1105 | { |
| 1106 | PyObject *_res = NULL; |
| 1107 | WindowPtr _rv; |
| 1108 | if (!PyArg_ParseTuple(_args, "")) |
| 1109 | return NULL; |
| 1110 | _rv = FrontWindow(); |
| 1111 | _res = Py_BuildValue("O&", |
Guido van Rossum | ea39abd | 1995-02-28 09:49:02 +0000 | [diff] [blame] | 1112 | WinObj_WhichWindow, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1113 | return _res; |
| 1114 | } |
| 1115 | |
| 1116 | static PyObject *Win_InvalRect(_self, _args) |
| 1117 | PyObject *_self; |
| 1118 | PyObject *_args; |
| 1119 | { |
| 1120 | PyObject *_res = NULL; |
| 1121 | Rect badRect; |
| 1122 | if (!PyArg_ParseTuple(_args, "O&", |
| 1123 | PyMac_GetRect, &badRect)) |
| 1124 | return NULL; |
| 1125 | InvalRect(&badRect); |
| 1126 | Py_INCREF(Py_None); |
| 1127 | _res = Py_None; |
| 1128 | return _res; |
| 1129 | } |
| 1130 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1131 | static PyObject *Win_InvalRgn(_self, _args) |
| 1132 | PyObject *_self; |
| 1133 | PyObject *_args; |
| 1134 | { |
| 1135 | PyObject *_res = NULL; |
| 1136 | RgnHandle badRgn; |
| 1137 | if (!PyArg_ParseTuple(_args, "O&", |
| 1138 | ResObj_Convert, &badRgn)) |
| 1139 | return NULL; |
| 1140 | InvalRgn(badRgn); |
| 1141 | Py_INCREF(Py_None); |
| 1142 | _res = Py_None; |
| 1143 | return _res; |
| 1144 | } |
| 1145 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1146 | static PyObject *Win_ValidRect(_self, _args) |
| 1147 | PyObject *_self; |
| 1148 | PyObject *_args; |
| 1149 | { |
| 1150 | PyObject *_res = NULL; |
| 1151 | Rect goodRect; |
| 1152 | if (!PyArg_ParseTuple(_args, "O&", |
| 1153 | PyMac_GetRect, &goodRect)) |
| 1154 | return NULL; |
| 1155 | ValidRect(&goodRect); |
| 1156 | Py_INCREF(Py_None); |
| 1157 | _res = Py_None; |
| 1158 | return _res; |
| 1159 | } |
| 1160 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1161 | static PyObject *Win_ValidRgn(_self, _args) |
| 1162 | PyObject *_self; |
| 1163 | PyObject *_args; |
| 1164 | { |
| 1165 | PyObject *_res = NULL; |
| 1166 | RgnHandle goodRgn; |
| 1167 | if (!PyArg_ParseTuple(_args, "O&", |
| 1168 | ResObj_Convert, &goodRgn)) |
| 1169 | return NULL; |
| 1170 | ValidRgn(goodRgn); |
| 1171 | Py_INCREF(Py_None); |
| 1172 | _res = Py_None; |
| 1173 | return _res; |
| 1174 | } |
| 1175 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1176 | static PyObject *Win_CheckUpdate(_self, _args) |
| 1177 | PyObject *_self; |
| 1178 | PyObject *_args; |
| 1179 | { |
| 1180 | PyObject *_res = NULL; |
| 1181 | Boolean _rv; |
| 1182 | EventRecord theEvent; |
| 1183 | if (!PyArg_ParseTuple(_args, "")) |
| 1184 | return NULL; |
| 1185 | _rv = CheckUpdate(&theEvent); |
| 1186 | _res = Py_BuildValue("bO&", |
| 1187 | _rv, |
| 1188 | PyMac_BuildEventRecord, &theEvent); |
| 1189 | return _res; |
| 1190 | } |
| 1191 | |
| 1192 | static PyObject *Win_FindWindow(_self, _args) |
| 1193 | PyObject *_self; |
| 1194 | PyObject *_args; |
| 1195 | { |
| 1196 | PyObject *_res = NULL; |
| 1197 | short _rv; |
| 1198 | Point thePoint; |
| 1199 | WindowPtr theWindow; |
| 1200 | if (!PyArg_ParseTuple(_args, "O&", |
| 1201 | PyMac_GetPoint, &thePoint)) |
| 1202 | return NULL; |
| 1203 | _rv = FindWindow(thePoint, |
| 1204 | &theWindow); |
| 1205 | _res = Py_BuildValue("hO&", |
| 1206 | _rv, |
| 1207 | WinObj_WhichWindow, theWindow); |
| 1208 | return _res; |
| 1209 | } |
| 1210 | |
| 1211 | static PyObject *Win_PinRect(_self, _args) |
| 1212 | PyObject *_self; |
| 1213 | PyObject *_args; |
| 1214 | { |
| 1215 | PyObject *_res = NULL; |
| 1216 | long _rv; |
| 1217 | Rect theRect; |
| 1218 | Point thePt; |
| 1219 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1220 | PyMac_GetRect, &theRect, |
| 1221 | PyMac_GetPoint, &thePt)) |
| 1222 | return NULL; |
| 1223 | _rv = PinRect(&theRect, |
| 1224 | thePt); |
| 1225 | _res = Py_BuildValue("l", |
| 1226 | _rv); |
| 1227 | return _res; |
| 1228 | } |
| 1229 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1230 | static PyObject *Win_GetCWMgrPort(_self, _args) |
| 1231 | PyObject *_self; |
| 1232 | PyObject *_args; |
| 1233 | { |
| 1234 | PyObject *_res = NULL; |
| 1235 | CGrafPtr wMgrCPort; |
| 1236 | if (!PyArg_ParseTuple(_args, "")) |
| 1237 | return NULL; |
| 1238 | GetCWMgrPort(&wMgrCPort); |
| 1239 | _res = Py_BuildValue("O&", |
| 1240 | GrafObj_New, wMgrCPort); |
| 1241 | return _res; |
| 1242 | } |
| 1243 | |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 1244 | static PyObject *Win_SetDeskCPat(_self, _args) |
| 1245 | PyObject *_self; |
| 1246 | PyObject *_args; |
| 1247 | { |
| 1248 | PyObject *_res = NULL; |
| 1249 | PixPatHandle deskPixPat; |
| 1250 | if (!PyArg_ParseTuple(_args, "O&", |
| 1251 | ResObj_Convert, &deskPixPat)) |
| 1252 | return NULL; |
| 1253 | SetDeskCPat(deskPixPat); |
| 1254 | Py_INCREF(Py_None); |
| 1255 | _res = Py_None; |
| 1256 | return _res; |
| 1257 | } |
| 1258 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1259 | static PyObject *Win_NewCWindow(_self, _args) |
| 1260 | PyObject *_self; |
| 1261 | PyObject *_args; |
| 1262 | { |
| 1263 | PyObject *_res = NULL; |
| 1264 | WindowPtr _rv; |
| 1265 | Rect boundsRect; |
| 1266 | Str255 title; |
| 1267 | Boolean visible; |
| 1268 | short procID; |
| 1269 | WindowPtr behind; |
| 1270 | Boolean goAwayFlag; |
| 1271 | long refCon; |
| 1272 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 1273 | PyMac_GetRect, &boundsRect, |
| 1274 | PyMac_GetStr255, title, |
| 1275 | &visible, |
| 1276 | &procID, |
| 1277 | WinObj_Convert, &behind, |
| 1278 | &goAwayFlag, |
| 1279 | &refCon)) |
| 1280 | return NULL; |
| 1281 | _rv = NewCWindow((void *)0, |
| 1282 | &boundsRect, |
| 1283 | title, |
| 1284 | visible, |
| 1285 | procID, |
| 1286 | behind, |
| 1287 | goAwayFlag, |
| 1288 | refCon); |
| 1289 | _res = Py_BuildValue("O&", |
| 1290 | WinObj_New, _rv); |
| 1291 | return _res; |
| 1292 | } |
| 1293 | |
| 1294 | static PyObject *Win_GetNewCWindow(_self, _args) |
| 1295 | PyObject *_self; |
| 1296 | PyObject *_args; |
| 1297 | { |
| 1298 | PyObject *_res = NULL; |
| 1299 | WindowPtr _rv; |
| 1300 | short windowID; |
| 1301 | WindowPtr behind; |
| 1302 | if (!PyArg_ParseTuple(_args, "hO&", |
| 1303 | &windowID, |
| 1304 | WinObj_Convert, &behind)) |
| 1305 | return NULL; |
| 1306 | _rv = GetNewCWindow(windowID, |
| 1307 | (void *)0, |
| 1308 | behind); |
| 1309 | _res = Py_BuildValue("O&", |
| 1310 | WinObj_New, _rv); |
| 1311 | return _res; |
| 1312 | } |
| 1313 | |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1314 | static PyObject *Win_WhichWindow(_self, _args) |
| 1315 | PyObject *_self; |
| 1316 | PyObject *_args; |
| 1317 | { |
| 1318 | PyObject *_res = NULL; |
| 1319 | |
| 1320 | long ptr; |
| 1321 | |
| 1322 | if ( !PyArg_ParseTuple(_args, "i", &ptr) ) |
| 1323 | return NULL; |
| 1324 | return WinObj_WhichWindow((WindowPtr)ptr); |
| 1325 | |
| 1326 | } |
| 1327 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1328 | static PyMethodDef Win_methods[] = { |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1329 | {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1, |
| 1330 | "() -> (RgnHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1331 | {"InitWindows", (PyCFunction)Win_InitWindows, 1, |
| 1332 | "() -> None"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1333 | {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1, |
| 1334 | "() -> (GrafPtr wPort)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1335 | {"NewWindow", (PyCFunction)Win_NewWindow, 1, |
| 1336 | "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
| 1337 | {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1, |
| 1338 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
| 1339 | {"FrontWindow", (PyCFunction)Win_FrontWindow, 1, |
| 1340 | "() -> (WindowPtr _rv)"}, |
| 1341 | {"InvalRect", (PyCFunction)Win_InvalRect, 1, |
| 1342 | "(Rect badRect) -> None"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1343 | {"InvalRgn", (PyCFunction)Win_InvalRgn, 1, |
| 1344 | "(RgnHandle badRgn) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1345 | {"ValidRect", (PyCFunction)Win_ValidRect, 1, |
| 1346 | "(Rect goodRect) -> None"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1347 | {"ValidRgn", (PyCFunction)Win_ValidRgn, 1, |
| 1348 | "(RgnHandle goodRgn) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1349 | {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1, |
| 1350 | "() -> (Boolean _rv, EventRecord theEvent)"}, |
| 1351 | {"FindWindow", (PyCFunction)Win_FindWindow, 1, |
| 1352 | "(Point thePoint) -> (short _rv, WindowPtr theWindow)"}, |
| 1353 | {"PinRect", (PyCFunction)Win_PinRect, 1, |
| 1354 | "(Rect theRect, Point thePt) -> (long _rv)"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1355 | {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1, |
| 1356 | "() -> (CGrafPtr wMgrCPort)"}, |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 1357 | {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1, |
| 1358 | "(PixPatHandle deskPixPat) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1359 | {"NewCWindow", (PyCFunction)Win_NewCWindow, 1, |
| 1360 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
| 1361 | {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1, |
| 1362 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 1363 | {"WhichWindow", (PyCFunction)Win_WhichWindow, 1, |
| 1364 | "Resolve an integer WindowPtr address to a Window object"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1365 | {NULL, NULL, 0} |
| 1366 | }; |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | /* Return the object corresponding to the window, or NULL */ |
| 1371 | |
| 1372 | PyObject * |
| 1373 | WinObj_WhichWindow(w) |
| 1374 | WindowPtr w; |
| 1375 | { |
| 1376 | PyObject *it; |
| 1377 | |
| 1378 | /* XXX What if we find a stdwin window or a window belonging |
| 1379 | to some other package? */ |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 1380 | if (w == NULL) |
| 1381 | it = NULL; |
| 1382 | else |
| 1383 | it = (PyObject *) GetWRefCon(w); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1384 | if (it == NULL || ((WindowObject *)it)->ob_itself != w) |
| 1385 | it = Py_None; |
| 1386 | Py_INCREF(it); |
| 1387 | return it; |
| 1388 | } |
| 1389 | |
| 1390 | |
| 1391 | void initWin() |
| 1392 | { |
| 1393 | PyObject *m; |
| 1394 | PyObject *d; |
| 1395 | |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | m = Py_InitModule("Win", Win_methods); |
| 1400 | d = PyModule_GetDict(m); |
| 1401 | Win_Error = PyMac_GetOSErrException(); |
| 1402 | if (Win_Error == NULL || |
| 1403 | PyDict_SetItemString(d, "Error", Win_Error) != 0) |
| 1404 | Py_FatalError("can't initialize Win.Error"); |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame^] | 1405 | Window_Type.ob_type = &PyType_Type; |
| 1406 | Py_INCREF(&Window_Type); |
| 1407 | if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0) |
| 1408 | Py_FatalError("can't initialize WindowType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1409 | } |
| 1410 | |
| 1411 | /* ========================= End module Win ========================= */ |
| 1412 | |