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