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