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 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 10 | |
| 11 | #include <Windows.h> |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 12 | |
| 13 | #if !ACCESSOR_CALLS_ARE_FUNCTIONS |
| 14 | #define GetWindowSpareFlag(win) (((CWindowPeek)(win))->spareFlag) |
| 15 | #define GetWindowFromPort(port) ((WindowRef)(port)) |
| 16 | #define GetWindowPortBounds(win, rectp) (*(rectp) = ((CWindowPeek)(win))->port.portRect) |
| 17 | #endif |
| 18 | |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 19 | /* Function to dispose a window, with a "normal" calling sequence */ |
| 20 | static void |
| 21 | PyMac_AutoDisposeWindow(WindowPtr w) |
| 22 | { |
| 23 | DisposeWindow(w); |
| 24 | } |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 25 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 26 | static PyObject *Win_Error; |
| 27 | |
| 28 | /* ----------------------- Object type Window ----------------------- */ |
| 29 | |
| 30 | PyTypeObject Window_Type; |
| 31 | |
| 32 | #define WinObj_Check(x) ((x)->ob_type == &Window_Type) |
| 33 | |
| 34 | typedef struct WindowObject { |
| 35 | PyObject_HEAD |
| 36 | WindowPtr ob_itself; |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 37 | void (*ob_freeit)(WindowPtr ptr); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 38 | } WindowObject; |
| 39 | |
| 40 | PyObject *WinObj_New(itself) |
Guido van Rossum | 9784295 | 1995-02-19 15:59:49 +0000 | [diff] [blame] | 41 | WindowPtr itself; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 42 | { |
| 43 | WindowObject *it; |
| 44 | if (itself == NULL) return PyMac_Error(resNotFound); |
| 45 | it = PyObject_NEW(WindowObject, &Window_Type); |
| 46 | if (it == NULL) return NULL; |
| 47 | it->ob_itself = itself; |
| 48 | SetWRefCon(itself, (long)it); |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 49 | it->ob_freeit = PyMac_AutoDisposeWindow; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 50 | return (PyObject *)it; |
| 51 | } |
| 52 | WinObj_Convert(v, p_itself) |
| 53 | PyObject *v; |
| 54 | WindowPtr *p_itself; |
| 55 | { |
| 56 | if (DlgObj_Check(v)) { |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 57 | *p_itself = DlgObj_ConvertToWindow(v); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 58 | return 1; |
| 59 | } |
| 60 | |
| 61 | if (v == Py_None) { *p_itself = NULL; return 1; } |
| 62 | if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } |
| 63 | |
| 64 | if (!WinObj_Check(v)) |
| 65 | { |
| 66 | PyErr_SetString(PyExc_TypeError, "Window required"); |
| 67 | return 0; |
| 68 | } |
| 69 | *p_itself = ((WindowObject *)v)->ob_itself; |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | static void WinObj_dealloc(self) |
| 74 | WindowObject *self; |
| 75 | { |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 76 | if (self->ob_itself) SetWRefCon(self->ob_itself, 0); |
| 77 | if (self->ob_freeit && self->ob_itself) |
| 78 | { |
| 79 | self->ob_freeit(self->ob_itself); |
| 80 | } |
| 81 | self->ob_itself = NULL; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 82 | PyMem_DEL(self); |
| 83 | } |
| 84 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 85 | static PyObject *WinObj_GetWindowOwnerCount(_self, _args) |
| 86 | WindowObject *_self; |
| 87 | PyObject *_args; |
| 88 | { |
| 89 | PyObject *_res = NULL; |
| 90 | OSStatus _err; |
| 91 | UInt32 outCount; |
| 92 | if (!PyArg_ParseTuple(_args, "")) |
| 93 | return NULL; |
| 94 | _err = GetWindowOwnerCount(_self->ob_itself, |
| 95 | &outCount); |
| 96 | if (_err != noErr) return PyMac_Error(_err); |
| 97 | _res = Py_BuildValue("l", |
| 98 | outCount); |
| 99 | return _res; |
| 100 | } |
| 101 | |
| 102 | static PyObject *WinObj_CloneWindow(_self, _args) |
| 103 | WindowObject *_self; |
| 104 | PyObject *_args; |
| 105 | { |
| 106 | PyObject *_res = NULL; |
| 107 | OSStatus _err; |
| 108 | if (!PyArg_ParseTuple(_args, "")) |
| 109 | return NULL; |
| 110 | _err = CloneWindow(_self->ob_itself); |
| 111 | if (_err != noErr) return PyMac_Error(_err); |
| 112 | Py_INCREF(Py_None); |
| 113 | _res = Py_None; |
| 114 | return _res; |
| 115 | } |
| 116 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 117 | #if TARGET_API_MAC_CARBON |
| 118 | |
| 119 | static PyObject *WinObj_ReshapeCustomWindow(_self, _args) |
| 120 | WindowObject *_self; |
| 121 | PyObject *_args; |
| 122 | { |
| 123 | PyObject *_res = NULL; |
| 124 | OSStatus _err; |
| 125 | if (!PyArg_ParseTuple(_args, "")) |
| 126 | return NULL; |
| 127 | _err = ReshapeCustomWindow(_self->ob_itself); |
| 128 | if (_err != noErr) return PyMac_Error(_err); |
| 129 | Py_INCREF(Py_None); |
| 130 | _res = Py_None; |
| 131 | return _res; |
| 132 | } |
| 133 | #endif |
| 134 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 135 | static PyObject *WinObj_GetWindowClass(_self, _args) |
| 136 | WindowObject *_self; |
| 137 | PyObject *_args; |
| 138 | { |
| 139 | PyObject *_res = NULL; |
| 140 | OSStatus _err; |
| 141 | WindowClass outClass; |
| 142 | if (!PyArg_ParseTuple(_args, "")) |
| 143 | return NULL; |
| 144 | _err = GetWindowClass(_self->ob_itself, |
| 145 | &outClass); |
| 146 | if (_err != noErr) return PyMac_Error(_err); |
| 147 | _res = Py_BuildValue("l", |
| 148 | outClass); |
| 149 | return _res; |
| 150 | } |
| 151 | |
| 152 | static PyObject *WinObj_GetWindowAttributes(_self, _args) |
| 153 | WindowObject *_self; |
| 154 | PyObject *_args; |
| 155 | { |
| 156 | PyObject *_res = NULL; |
| 157 | OSStatus _err; |
| 158 | WindowAttributes outAttributes; |
| 159 | if (!PyArg_ParseTuple(_args, "")) |
| 160 | return NULL; |
| 161 | _err = GetWindowAttributes(_self->ob_itself, |
| 162 | &outAttributes); |
| 163 | if (_err != noErr) return PyMac_Error(_err); |
| 164 | _res = Py_BuildValue("l", |
| 165 | outAttributes); |
| 166 | return _res; |
| 167 | } |
| 168 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 169 | #if TARGET_API_MAC_CARBON |
| 170 | |
| 171 | static PyObject *WinObj_ChangeWindowAttributes(_self, _args) |
| 172 | WindowObject *_self; |
| 173 | PyObject *_args; |
| 174 | { |
| 175 | PyObject *_res = NULL; |
| 176 | OSStatus _err; |
| 177 | WindowAttributes setTheseAttributes; |
| 178 | WindowAttributes clearTheseAttributes; |
| 179 | if (!PyArg_ParseTuple(_args, "ll", |
| 180 | &setTheseAttributes, |
| 181 | &clearTheseAttributes)) |
| 182 | return NULL; |
| 183 | _err = ChangeWindowAttributes(_self->ob_itself, |
| 184 | setTheseAttributes, |
| 185 | clearTheseAttributes); |
| 186 | if (_err != noErr) return PyMac_Error(_err); |
| 187 | Py_INCREF(Py_None); |
| 188 | _res = Py_None; |
| 189 | return _res; |
| 190 | } |
| 191 | #endif |
| 192 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 193 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 194 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 195 | static PyObject *WinObj_SetWinColor(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 196 | WindowObject *_self; |
| 197 | PyObject *_args; |
| 198 | { |
| 199 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 200 | WCTabHandle newColorTable; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 201 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 202 | ResObj_Convert, &newColorTable)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 203 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 204 | SetWinColor(_self->ob_itself, |
| 205 | newColorTable); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 206 | Py_INCREF(Py_None); |
| 207 | _res = Py_None; |
| 208 | return _res; |
| 209 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 210 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 211 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 212 | static PyObject *WinObj_SetWindowContentColor(_self, _args) |
| 213 | WindowObject *_self; |
| 214 | PyObject *_args; |
| 215 | { |
| 216 | PyObject *_res = NULL; |
| 217 | OSStatus _err; |
| 218 | RGBColor color; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 219 | if (!PyArg_ParseTuple(_args, "O&", |
| 220 | QdRGB_Convert, &color)) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 221 | return NULL; |
| 222 | _err = SetWindowContentColor(_self->ob_itself, |
| 223 | &color); |
| 224 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 225 | Py_INCREF(Py_None); |
| 226 | _res = Py_None; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 227 | return _res; |
| 228 | } |
| 229 | |
| 230 | static PyObject *WinObj_GetWindowContentColor(_self, _args) |
| 231 | WindowObject *_self; |
| 232 | PyObject *_args; |
| 233 | { |
| 234 | PyObject *_res = NULL; |
| 235 | OSStatus _err; |
| 236 | RGBColor color; |
| 237 | if (!PyArg_ParseTuple(_args, "")) |
| 238 | return NULL; |
| 239 | _err = GetWindowContentColor(_self->ob_itself, |
| 240 | &color); |
| 241 | if (_err != noErr) return PyMac_Error(_err); |
| 242 | _res = Py_BuildValue("O&", |
| 243 | QdRGB_New, &color); |
| 244 | return _res; |
| 245 | } |
| 246 | |
| 247 | static PyObject *WinObj_GetWindowContentPattern(_self, _args) |
| 248 | WindowObject *_self; |
| 249 | PyObject *_args; |
| 250 | { |
| 251 | PyObject *_res = NULL; |
| 252 | OSStatus _err; |
| 253 | PixPatHandle outPixPat; |
| 254 | if (!PyArg_ParseTuple(_args, "O&", |
| 255 | ResObj_Convert, &outPixPat)) |
| 256 | return NULL; |
| 257 | _err = GetWindowContentPattern(_self->ob_itself, |
| 258 | outPixPat); |
| 259 | if (_err != noErr) return PyMac_Error(_err); |
| 260 | Py_INCREF(Py_None); |
| 261 | _res = Py_None; |
| 262 | return _res; |
| 263 | } |
| 264 | |
| 265 | static PyObject *WinObj_SetWindowContentPattern(_self, _args) |
| 266 | WindowObject *_self; |
| 267 | PyObject *_args; |
| 268 | { |
| 269 | PyObject *_res = NULL; |
| 270 | OSStatus _err; |
| 271 | PixPatHandle pixPat; |
| 272 | if (!PyArg_ParseTuple(_args, "O&", |
| 273 | ResObj_Convert, &pixPat)) |
| 274 | return NULL; |
| 275 | _err = SetWindowContentPattern(_self->ob_itself, |
| 276 | pixPat); |
| 277 | if (_err != noErr) return PyMac_Error(_err); |
| 278 | Py_INCREF(Py_None); |
| 279 | _res = Py_None; |
| 280 | return _res; |
| 281 | } |
| 282 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 283 | #if TARGET_API_MAC_CARBON |
| 284 | |
| 285 | static PyObject *WinObj_ScrollWindowRect(_self, _args) |
| 286 | WindowObject *_self; |
| 287 | PyObject *_args; |
| 288 | { |
| 289 | PyObject *_res = NULL; |
| 290 | OSStatus _err; |
| 291 | Rect inScrollRect; |
| 292 | SInt16 inHPixels; |
| 293 | SInt16 inVPixels; |
| 294 | ScrollWindowOptions inOptions; |
| 295 | RgnHandle outExposedRgn; |
| 296 | if (!PyArg_ParseTuple(_args, "O&hhlO&", |
| 297 | PyMac_GetRect, &inScrollRect, |
| 298 | &inHPixels, |
| 299 | &inVPixels, |
| 300 | &inOptions, |
| 301 | ResObj_Convert, &outExposedRgn)) |
| 302 | return NULL; |
| 303 | _err = ScrollWindowRect(_self->ob_itself, |
| 304 | &inScrollRect, |
| 305 | inHPixels, |
| 306 | inVPixels, |
| 307 | inOptions, |
| 308 | outExposedRgn); |
| 309 | if (_err != noErr) return PyMac_Error(_err); |
| 310 | Py_INCREF(Py_None); |
| 311 | _res = Py_None; |
| 312 | return _res; |
| 313 | } |
| 314 | #endif |
| 315 | |
| 316 | #if TARGET_API_MAC_CARBON |
| 317 | |
| 318 | static PyObject *WinObj_ScrollWindowRegion(_self, _args) |
| 319 | WindowObject *_self; |
| 320 | PyObject *_args; |
| 321 | { |
| 322 | PyObject *_res = NULL; |
| 323 | OSStatus _err; |
| 324 | RgnHandle inScrollRgn; |
| 325 | SInt16 inHPixels; |
| 326 | SInt16 inVPixels; |
| 327 | ScrollWindowOptions inOptions; |
| 328 | RgnHandle outExposedRgn; |
| 329 | if (!PyArg_ParseTuple(_args, "O&hhlO&", |
| 330 | ResObj_Convert, &inScrollRgn, |
| 331 | &inHPixels, |
| 332 | &inVPixels, |
| 333 | &inOptions, |
| 334 | ResObj_Convert, &outExposedRgn)) |
| 335 | return NULL; |
| 336 | _err = ScrollWindowRegion(_self->ob_itself, |
| 337 | inScrollRgn, |
| 338 | inHPixels, |
| 339 | inVPixels, |
| 340 | inOptions, |
| 341 | outExposedRgn); |
| 342 | if (_err != noErr) return PyMac_Error(_err); |
| 343 | Py_INCREF(Py_None); |
| 344 | _res = Py_None; |
| 345 | return _res; |
| 346 | } |
| 347 | #endif |
| 348 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 349 | static PyObject *WinObj_ClipAbove(_self, _args) |
| 350 | WindowObject *_self; |
| 351 | PyObject *_args; |
| 352 | { |
| 353 | PyObject *_res = NULL; |
| 354 | if (!PyArg_ParseTuple(_args, "")) |
| 355 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 356 | ClipAbove(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 357 | Py_INCREF(Py_None); |
| 358 | _res = Py_None; |
| 359 | return _res; |
| 360 | } |
| 361 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 362 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 363 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 364 | static PyObject *WinObj_SaveOld(_self, _args) |
| 365 | WindowObject *_self; |
| 366 | PyObject *_args; |
| 367 | { |
| 368 | PyObject *_res = NULL; |
| 369 | if (!PyArg_ParseTuple(_args, "")) |
| 370 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 371 | SaveOld(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 372 | Py_INCREF(Py_None); |
| 373 | _res = Py_None; |
| 374 | return _res; |
| 375 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 376 | #endif |
| 377 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 378 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 379 | |
| 380 | static PyObject *WinObj_DrawNew(_self, _args) |
| 381 | WindowObject *_self; |
| 382 | PyObject *_args; |
| 383 | { |
| 384 | PyObject *_res = NULL; |
| 385 | Boolean update; |
| 386 | if (!PyArg_ParseTuple(_args, "b", |
| 387 | &update)) |
| 388 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 389 | DrawNew(_self->ob_itself, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 390 | update); |
| 391 | Py_INCREF(Py_None); |
| 392 | _res = Py_None; |
| 393 | return _res; |
| 394 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 395 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 396 | |
| 397 | static PyObject *WinObj_CalcVis(_self, _args) |
| 398 | WindowObject *_self; |
| 399 | PyObject *_args; |
| 400 | { |
| 401 | PyObject *_res = NULL; |
| 402 | if (!PyArg_ParseTuple(_args, "")) |
| 403 | return NULL; |
Jack Jansen | b81cf9d | 1995-06-06 13:08:40 +0000 | [diff] [blame] | 404 | CalcVis(_self->ob_itself); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 405 | Py_INCREF(Py_None); |
| 406 | _res = Py_None; |
| 407 | return _res; |
| 408 | } |
| 409 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 410 | static PyObject *WinObj_BringToFront(_self, _args) |
| 411 | WindowObject *_self; |
| 412 | PyObject *_args; |
| 413 | { |
| 414 | PyObject *_res = NULL; |
| 415 | if (!PyArg_ParseTuple(_args, "")) |
| 416 | return NULL; |
| 417 | BringToFront(_self->ob_itself); |
| 418 | Py_INCREF(Py_None); |
| 419 | _res = Py_None; |
| 420 | return _res; |
| 421 | } |
| 422 | |
| 423 | static PyObject *WinObj_SendBehind(_self, _args) |
| 424 | WindowObject *_self; |
| 425 | PyObject *_args; |
| 426 | { |
| 427 | PyObject *_res = NULL; |
| 428 | WindowPtr behindWindow; |
| 429 | if (!PyArg_ParseTuple(_args, "O&", |
| 430 | WinObj_Convert, &behindWindow)) |
| 431 | return NULL; |
| 432 | SendBehind(_self->ob_itself, |
| 433 | behindWindow); |
| 434 | Py_INCREF(Py_None); |
| 435 | _res = Py_None; |
| 436 | return _res; |
| 437 | } |
| 438 | |
| 439 | static PyObject *WinObj_SelectWindow(_self, _args) |
| 440 | WindowObject *_self; |
| 441 | PyObject *_args; |
| 442 | { |
| 443 | PyObject *_res = NULL; |
| 444 | if (!PyArg_ParseTuple(_args, "")) |
| 445 | return NULL; |
| 446 | SelectWindow(_self->ob_itself); |
| 447 | Py_INCREF(Py_None); |
| 448 | _res = Py_None; |
| 449 | return _res; |
| 450 | } |
| 451 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 452 | #if TARGET_API_MAC_CARBON |
| 453 | |
| 454 | static PyObject *WinObj_GetNextWindowOfClass(_self, _args) |
| 455 | WindowObject *_self; |
| 456 | PyObject *_args; |
| 457 | { |
| 458 | PyObject *_res = NULL; |
| 459 | WindowPtr _rv; |
| 460 | WindowClass inWindowClass; |
| 461 | Boolean mustBeVisible; |
| 462 | if (!PyArg_ParseTuple(_args, "lb", |
| 463 | &inWindowClass, |
| 464 | &mustBeVisible)) |
| 465 | return NULL; |
| 466 | _rv = GetNextWindowOfClass(_self->ob_itself, |
| 467 | inWindowClass, |
| 468 | mustBeVisible); |
| 469 | _res = Py_BuildValue("O&", |
| 470 | WinObj_New, _rv); |
| 471 | return _res; |
| 472 | } |
| 473 | #endif |
| 474 | |
| 475 | #if !TARGET_API_MAC_CARBON |
| 476 | |
| 477 | static PyObject *WinObj_IsValidWindowPtr(_self, _args) |
| 478 | WindowObject *_self; |
| 479 | PyObject *_args; |
| 480 | { |
| 481 | PyObject *_res = NULL; |
| 482 | Boolean _rv; |
| 483 | if (!PyArg_ParseTuple(_args, "")) |
| 484 | return NULL; |
| 485 | _rv = IsValidWindowPtr(_self->ob_itself); |
| 486 | _res = Py_BuildValue("b", |
| 487 | _rv); |
| 488 | return _res; |
| 489 | } |
| 490 | #endif |
| 491 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 492 | static PyObject *WinObj_HiliteWindow(_self, _args) |
| 493 | WindowObject *_self; |
| 494 | PyObject *_args; |
| 495 | { |
| 496 | PyObject *_res = NULL; |
| 497 | Boolean fHilite; |
| 498 | if (!PyArg_ParseTuple(_args, "b", |
| 499 | &fHilite)) |
| 500 | return NULL; |
| 501 | HiliteWindow(_self->ob_itself, |
| 502 | fHilite); |
| 503 | Py_INCREF(Py_None); |
| 504 | _res = Py_None; |
| 505 | return _res; |
| 506 | } |
| 507 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 508 | static PyObject *WinObj_SetWRefCon(_self, _args) |
| 509 | WindowObject *_self; |
| 510 | PyObject *_args; |
| 511 | { |
| 512 | PyObject *_res = NULL; |
| 513 | long data; |
| 514 | if (!PyArg_ParseTuple(_args, "l", |
| 515 | &data)) |
| 516 | return NULL; |
| 517 | SetWRefCon(_self->ob_itself, |
| 518 | data); |
| 519 | Py_INCREF(Py_None); |
| 520 | _res = Py_None; |
| 521 | return _res; |
| 522 | } |
| 523 | |
| 524 | static PyObject *WinObj_GetWRefCon(_self, _args) |
| 525 | WindowObject *_self; |
| 526 | PyObject *_args; |
| 527 | { |
| 528 | PyObject *_res = NULL; |
| 529 | long _rv; |
| 530 | if (!PyArg_ParseTuple(_args, "")) |
| 531 | return NULL; |
| 532 | _rv = GetWRefCon(_self->ob_itself); |
| 533 | _res = Py_BuildValue("l", |
| 534 | _rv); |
| 535 | return _res; |
| 536 | } |
| 537 | |
| 538 | static PyObject *WinObj_SetWindowPic(_self, _args) |
| 539 | WindowObject *_self; |
| 540 | PyObject *_args; |
| 541 | { |
| 542 | PyObject *_res = NULL; |
| 543 | PicHandle pic; |
| 544 | if (!PyArg_ParseTuple(_args, "O&", |
| 545 | ResObj_Convert, &pic)) |
| 546 | return NULL; |
| 547 | SetWindowPic(_self->ob_itself, |
| 548 | pic); |
| 549 | Py_INCREF(Py_None); |
| 550 | _res = Py_None; |
| 551 | return _res; |
| 552 | } |
| 553 | |
| 554 | static PyObject *WinObj_GetWindowPic(_self, _args) |
| 555 | WindowObject *_self; |
| 556 | PyObject *_args; |
| 557 | { |
| 558 | PyObject *_res = NULL; |
| 559 | PicHandle _rv; |
| 560 | if (!PyArg_ParseTuple(_args, "")) |
| 561 | return NULL; |
| 562 | _rv = GetWindowPic(_self->ob_itself); |
| 563 | _res = Py_BuildValue("O&", |
| 564 | ResObj_New, _rv); |
| 565 | return _res; |
| 566 | } |
| 567 | |
| 568 | static PyObject *WinObj_GetWVariant(_self, _args) |
| 569 | WindowObject *_self; |
| 570 | PyObject *_args; |
| 571 | { |
| 572 | PyObject *_res = NULL; |
| 573 | short _rv; |
| 574 | if (!PyArg_ParseTuple(_args, "")) |
| 575 | return NULL; |
| 576 | _rv = GetWVariant(_self->ob_itself); |
| 577 | _res = Py_BuildValue("h", |
| 578 | _rv); |
| 579 | return _res; |
| 580 | } |
| 581 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 582 | static PyObject *WinObj_GetWindowFeatures(_self, _args) |
| 583 | WindowObject *_self; |
| 584 | PyObject *_args; |
| 585 | { |
| 586 | PyObject *_res = NULL; |
| 587 | OSStatus _err; |
| 588 | UInt32 outFeatures; |
| 589 | if (!PyArg_ParseTuple(_args, "")) |
| 590 | return NULL; |
| 591 | _err = GetWindowFeatures(_self->ob_itself, |
| 592 | &outFeatures); |
| 593 | if (_err != noErr) return PyMac_Error(_err); |
| 594 | _res = Py_BuildValue("l", |
| 595 | outFeatures); |
| 596 | return _res; |
| 597 | } |
| 598 | |
| 599 | static PyObject *WinObj_GetWindowRegion(_self, _args) |
| 600 | WindowObject *_self; |
| 601 | PyObject *_args; |
| 602 | { |
| 603 | PyObject *_res = NULL; |
| 604 | OSStatus _err; |
| 605 | WindowRegionCode inRegionCode; |
| 606 | RgnHandle ioWinRgn; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 607 | if (!PyArg_ParseTuple(_args, "HO&", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 608 | &inRegionCode, |
| 609 | ResObj_Convert, &ioWinRgn)) |
| 610 | return NULL; |
| 611 | _err = GetWindowRegion(_self->ob_itself, |
| 612 | inRegionCode, |
| 613 | ioWinRgn); |
| 614 | if (_err != noErr) return PyMac_Error(_err); |
| 615 | Py_INCREF(Py_None); |
| 616 | _res = Py_None; |
| 617 | return _res; |
| 618 | } |
| 619 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 620 | static PyObject *WinObj_BeginUpdate(_self, _args) |
| 621 | WindowObject *_self; |
| 622 | PyObject *_args; |
| 623 | { |
| 624 | PyObject *_res = NULL; |
| 625 | if (!PyArg_ParseTuple(_args, "")) |
| 626 | return NULL; |
| 627 | BeginUpdate(_self->ob_itself); |
| 628 | Py_INCREF(Py_None); |
| 629 | _res = Py_None; |
| 630 | return _res; |
| 631 | } |
| 632 | |
| 633 | static PyObject *WinObj_EndUpdate(_self, _args) |
| 634 | WindowObject *_self; |
| 635 | PyObject *_args; |
| 636 | { |
| 637 | PyObject *_res = NULL; |
| 638 | if (!PyArg_ParseTuple(_args, "")) |
| 639 | return NULL; |
| 640 | EndUpdate(_self->ob_itself); |
| 641 | Py_INCREF(Py_None); |
| 642 | _res = Py_None; |
| 643 | return _res; |
| 644 | } |
| 645 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 646 | static PyObject *WinObj_InvalWindowRgn(_self, _args) |
| 647 | WindowObject *_self; |
| 648 | PyObject *_args; |
| 649 | { |
| 650 | PyObject *_res = NULL; |
| 651 | OSStatus _err; |
| 652 | RgnHandle region; |
| 653 | if (!PyArg_ParseTuple(_args, "O&", |
| 654 | ResObj_Convert, ®ion)) |
| 655 | return NULL; |
| 656 | _err = InvalWindowRgn(_self->ob_itself, |
| 657 | region); |
| 658 | if (_err != noErr) return PyMac_Error(_err); |
| 659 | Py_INCREF(Py_None); |
| 660 | _res = Py_None; |
| 661 | return _res; |
| 662 | } |
| 663 | |
| 664 | static PyObject *WinObj_InvalWindowRect(_self, _args) |
| 665 | WindowObject *_self; |
| 666 | PyObject *_args; |
| 667 | { |
| 668 | PyObject *_res = NULL; |
| 669 | OSStatus _err; |
| 670 | Rect bounds; |
| 671 | if (!PyArg_ParseTuple(_args, "O&", |
| 672 | PyMac_GetRect, &bounds)) |
| 673 | return NULL; |
| 674 | _err = InvalWindowRect(_self->ob_itself, |
| 675 | &bounds); |
| 676 | if (_err != noErr) return PyMac_Error(_err); |
| 677 | Py_INCREF(Py_None); |
| 678 | _res = Py_None; |
| 679 | return _res; |
| 680 | } |
| 681 | |
| 682 | static PyObject *WinObj_ValidWindowRgn(_self, _args) |
| 683 | WindowObject *_self; |
| 684 | PyObject *_args; |
| 685 | { |
| 686 | PyObject *_res = NULL; |
| 687 | OSStatus _err; |
| 688 | RgnHandle region; |
| 689 | if (!PyArg_ParseTuple(_args, "O&", |
| 690 | ResObj_Convert, ®ion)) |
| 691 | return NULL; |
| 692 | _err = ValidWindowRgn(_self->ob_itself, |
| 693 | region); |
| 694 | if (_err != noErr) return PyMac_Error(_err); |
| 695 | Py_INCREF(Py_None); |
| 696 | _res = Py_None; |
| 697 | return _res; |
| 698 | } |
| 699 | |
| 700 | static PyObject *WinObj_ValidWindowRect(_self, _args) |
| 701 | WindowObject *_self; |
| 702 | PyObject *_args; |
| 703 | { |
| 704 | PyObject *_res = NULL; |
| 705 | OSStatus _err; |
| 706 | Rect bounds; |
| 707 | if (!PyArg_ParseTuple(_args, "O&", |
| 708 | PyMac_GetRect, &bounds)) |
| 709 | return NULL; |
| 710 | _err = ValidWindowRect(_self->ob_itself, |
| 711 | &bounds); |
| 712 | if (_err != noErr) return PyMac_Error(_err); |
| 713 | Py_INCREF(Py_None); |
| 714 | _res = Py_None; |
| 715 | return _res; |
| 716 | } |
| 717 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 718 | static PyObject *WinObj_DrawGrowIcon(_self, _args) |
| 719 | WindowObject *_self; |
| 720 | PyObject *_args; |
| 721 | { |
| 722 | PyObject *_res = NULL; |
| 723 | if (!PyArg_ParseTuple(_args, "")) |
| 724 | return NULL; |
| 725 | DrawGrowIcon(_self->ob_itself); |
| 726 | Py_INCREF(Py_None); |
| 727 | _res = Py_None; |
| 728 | return _res; |
| 729 | } |
| 730 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 731 | static PyObject *WinObj_SetWTitle(_self, _args) |
| 732 | WindowObject *_self; |
| 733 | PyObject *_args; |
| 734 | { |
| 735 | PyObject *_res = NULL; |
| 736 | Str255 title; |
| 737 | if (!PyArg_ParseTuple(_args, "O&", |
| 738 | PyMac_GetStr255, title)) |
| 739 | return NULL; |
| 740 | SetWTitle(_self->ob_itself, |
| 741 | title); |
| 742 | Py_INCREF(Py_None); |
| 743 | _res = Py_None; |
| 744 | return _res; |
| 745 | } |
| 746 | |
| 747 | static PyObject *WinObj_GetWTitle(_self, _args) |
| 748 | WindowObject *_self; |
| 749 | PyObject *_args; |
| 750 | { |
| 751 | PyObject *_res = NULL; |
| 752 | Str255 title; |
| 753 | if (!PyArg_ParseTuple(_args, "")) |
| 754 | return NULL; |
| 755 | GetWTitle(_self->ob_itself, |
| 756 | title); |
| 757 | _res = Py_BuildValue("O&", |
| 758 | PyMac_BuildStr255, title); |
| 759 | return _res; |
| 760 | } |
| 761 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 762 | static PyObject *WinObj_SetWindowProxyFSSpec(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 763 | WindowObject *_self; |
| 764 | PyObject *_args; |
| 765 | { |
| 766 | PyObject *_res = NULL; |
Jack Jansen | e4349e8 | 1999-03-04 22:53:24 +0000 | [diff] [blame] | 767 | OSStatus _err; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 768 | FSSpec inFile; |
| 769 | if (!PyArg_ParseTuple(_args, "O&", |
| 770 | PyMac_GetFSSpec, &inFile)) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 771 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 772 | _err = SetWindowProxyFSSpec(_self->ob_itself, |
| 773 | &inFile); |
| 774 | if (_err != noErr) return PyMac_Error(_err); |
| 775 | Py_INCREF(Py_None); |
| 776 | _res = Py_None; |
| 777 | return _res; |
| 778 | } |
| 779 | |
| 780 | static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args) |
| 781 | WindowObject *_self; |
| 782 | PyObject *_args; |
| 783 | { |
| 784 | PyObject *_res = NULL; |
| 785 | OSStatus _err; |
| 786 | FSSpec outFile; |
| 787 | if (!PyArg_ParseTuple(_args, "")) |
| 788 | return NULL; |
| 789 | _err = GetWindowProxyFSSpec(_self->ob_itself, |
| 790 | &outFile); |
| 791 | if (_err != noErr) return PyMac_Error(_err); |
| 792 | _res = Py_BuildValue("O&", |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 793 | PyMac_BuildFSSpec, outFile); |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 794 | return _res; |
| 795 | } |
| 796 | |
| 797 | static PyObject *WinObj_SetWindowProxyAlias(_self, _args) |
| 798 | WindowObject *_self; |
| 799 | PyObject *_args; |
| 800 | { |
| 801 | PyObject *_res = NULL; |
| 802 | OSStatus _err; |
| 803 | AliasHandle alias; |
| 804 | if (!PyArg_ParseTuple(_args, "O&", |
| 805 | ResObj_Convert, &alias)) |
| 806 | return NULL; |
| 807 | _err = SetWindowProxyAlias(_self->ob_itself, |
| 808 | alias); |
| 809 | if (_err != noErr) return PyMac_Error(_err); |
| 810 | Py_INCREF(Py_None); |
| 811 | _res = Py_None; |
| 812 | return _res; |
| 813 | } |
| 814 | |
| 815 | static PyObject *WinObj_GetWindowProxyAlias(_self, _args) |
| 816 | WindowObject *_self; |
| 817 | PyObject *_args; |
| 818 | { |
| 819 | PyObject *_res = NULL; |
| 820 | OSStatus _err; |
| 821 | AliasHandle alias; |
| 822 | if (!PyArg_ParseTuple(_args, "")) |
| 823 | return NULL; |
| 824 | _err = GetWindowProxyAlias(_self->ob_itself, |
| 825 | &alias); |
| 826 | if (_err != noErr) return PyMac_Error(_err); |
| 827 | _res = Py_BuildValue("O&", |
| 828 | ResObj_New, alias); |
| 829 | return _res; |
| 830 | } |
| 831 | |
| 832 | static PyObject *WinObj_SetWindowProxyCreatorAndType(_self, _args) |
| 833 | WindowObject *_self; |
| 834 | PyObject *_args; |
| 835 | { |
| 836 | PyObject *_res = NULL; |
| 837 | OSStatus _err; |
| 838 | OSType fileCreator; |
| 839 | OSType fileType; |
| 840 | SInt16 vRefNum; |
| 841 | if (!PyArg_ParseTuple(_args, "O&O&h", |
| 842 | PyMac_GetOSType, &fileCreator, |
| 843 | PyMac_GetOSType, &fileType, |
| 844 | &vRefNum)) |
| 845 | return NULL; |
| 846 | _err = SetWindowProxyCreatorAndType(_self->ob_itself, |
| 847 | fileCreator, |
| 848 | fileType, |
| 849 | vRefNum); |
| 850 | if (_err != noErr) return PyMac_Error(_err); |
| 851 | Py_INCREF(Py_None); |
| 852 | _res = Py_None; |
| 853 | return _res; |
| 854 | } |
| 855 | |
| 856 | static PyObject *WinObj_GetWindowProxyIcon(_self, _args) |
| 857 | WindowObject *_self; |
| 858 | PyObject *_args; |
| 859 | { |
| 860 | PyObject *_res = NULL; |
| 861 | OSStatus _err; |
| 862 | IconRef outIcon; |
| 863 | if (!PyArg_ParseTuple(_args, "")) |
| 864 | return NULL; |
| 865 | _err = GetWindowProxyIcon(_self->ob_itself, |
| 866 | &outIcon); |
| 867 | if (_err != noErr) return PyMac_Error(_err); |
| 868 | _res = Py_BuildValue("O&", |
| 869 | ResObj_New, outIcon); |
| 870 | return _res; |
| 871 | } |
| 872 | |
| 873 | static PyObject *WinObj_SetWindowProxyIcon(_self, _args) |
| 874 | WindowObject *_self; |
| 875 | PyObject *_args; |
| 876 | { |
| 877 | PyObject *_res = NULL; |
| 878 | OSStatus _err; |
| 879 | IconRef icon; |
| 880 | if (!PyArg_ParseTuple(_args, "O&", |
| 881 | ResObj_Convert, &icon)) |
| 882 | return NULL; |
| 883 | _err = SetWindowProxyIcon(_self->ob_itself, |
| 884 | icon); |
| 885 | if (_err != noErr) return PyMac_Error(_err); |
| 886 | Py_INCREF(Py_None); |
| 887 | _res = Py_None; |
| 888 | return _res; |
| 889 | } |
| 890 | |
| 891 | static PyObject *WinObj_RemoveWindowProxy(_self, _args) |
| 892 | WindowObject *_self; |
| 893 | PyObject *_args; |
| 894 | { |
| 895 | PyObject *_res = NULL; |
| 896 | OSStatus _err; |
| 897 | if (!PyArg_ParseTuple(_args, "")) |
| 898 | return NULL; |
| 899 | _err = RemoveWindowProxy(_self->ob_itself); |
| 900 | if (_err != noErr) return PyMac_Error(_err); |
| 901 | Py_INCREF(Py_None); |
| 902 | _res = Py_None; |
| 903 | return _res; |
| 904 | } |
| 905 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 906 | static PyObject *WinObj_BeginWindowProxyDrag(_self, _args) |
| 907 | WindowObject *_self; |
| 908 | PyObject *_args; |
| 909 | { |
| 910 | PyObject *_res = NULL; |
| 911 | OSStatus _err; |
| 912 | DragReference outNewDrag; |
| 913 | RgnHandle outDragOutlineRgn; |
| 914 | if (!PyArg_ParseTuple(_args, "O&", |
| 915 | ResObj_Convert, &outDragOutlineRgn)) |
| 916 | return NULL; |
| 917 | _err = BeginWindowProxyDrag(_self->ob_itself, |
| 918 | &outNewDrag, |
| 919 | outDragOutlineRgn); |
| 920 | if (_err != noErr) return PyMac_Error(_err); |
| 921 | _res = Py_BuildValue("O&", |
| 922 | DragObj_New, outNewDrag); |
| 923 | return _res; |
| 924 | } |
| 925 | |
| 926 | static PyObject *WinObj_EndWindowProxyDrag(_self, _args) |
| 927 | WindowObject *_self; |
| 928 | PyObject *_args; |
| 929 | { |
| 930 | PyObject *_res = NULL; |
| 931 | OSStatus _err; |
| 932 | DragReference theDrag; |
| 933 | if (!PyArg_ParseTuple(_args, "O&", |
| 934 | DragObj_Convert, &theDrag)) |
| 935 | return NULL; |
| 936 | _err = EndWindowProxyDrag(_self->ob_itself, |
| 937 | theDrag); |
| 938 | if (_err != noErr) return PyMac_Error(_err); |
| 939 | Py_INCREF(Py_None); |
| 940 | _res = Py_None; |
| 941 | return _res; |
| 942 | } |
| 943 | |
| 944 | static PyObject *WinObj_TrackWindowProxyFromExistingDrag(_self, _args) |
| 945 | WindowObject *_self; |
| 946 | PyObject *_args; |
| 947 | { |
| 948 | PyObject *_res = NULL; |
| 949 | OSStatus _err; |
| 950 | Point startPt; |
| 951 | DragReference drag; |
| 952 | RgnHandle inDragOutlineRgn; |
| 953 | if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 954 | PyMac_GetPoint, &startPt, |
| 955 | DragObj_Convert, &drag, |
| 956 | ResObj_Convert, &inDragOutlineRgn)) |
| 957 | return NULL; |
| 958 | _err = TrackWindowProxyFromExistingDrag(_self->ob_itself, |
| 959 | startPt, |
| 960 | drag, |
| 961 | inDragOutlineRgn); |
| 962 | if (_err != noErr) return PyMac_Error(_err); |
| 963 | Py_INCREF(Py_None); |
| 964 | _res = Py_None; |
| 965 | return _res; |
| 966 | } |
| 967 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 968 | static PyObject *WinObj_TrackWindowProxyDrag(_self, _args) |
| 969 | WindowObject *_self; |
| 970 | PyObject *_args; |
| 971 | { |
| 972 | PyObject *_res = NULL; |
| 973 | OSStatus _err; |
| 974 | Point startPt; |
| 975 | if (!PyArg_ParseTuple(_args, "O&", |
| 976 | PyMac_GetPoint, &startPt)) |
| 977 | return NULL; |
| 978 | _err = TrackWindowProxyDrag(_self->ob_itself, |
| 979 | startPt); |
| 980 | if (_err != noErr) return PyMac_Error(_err); |
| 981 | Py_INCREF(Py_None); |
| 982 | _res = Py_None; |
| 983 | return _res; |
| 984 | } |
| 985 | |
| 986 | static PyObject *WinObj_IsWindowModified(_self, _args) |
| 987 | WindowObject *_self; |
| 988 | PyObject *_args; |
| 989 | { |
| 990 | PyObject *_res = NULL; |
| 991 | Boolean _rv; |
| 992 | if (!PyArg_ParseTuple(_args, "")) |
| 993 | return NULL; |
| 994 | _rv = IsWindowModified(_self->ob_itself); |
| 995 | _res = Py_BuildValue("b", |
| 996 | _rv); |
| 997 | return _res; |
| 998 | } |
| 999 | |
| 1000 | static PyObject *WinObj_SetWindowModified(_self, _args) |
| 1001 | WindowObject *_self; |
| 1002 | PyObject *_args; |
| 1003 | { |
| 1004 | PyObject *_res = NULL; |
| 1005 | OSStatus _err; |
| 1006 | Boolean modified; |
| 1007 | if (!PyArg_ParseTuple(_args, "b", |
| 1008 | &modified)) |
| 1009 | return NULL; |
| 1010 | _err = SetWindowModified(_self->ob_itself, |
| 1011 | modified); |
| 1012 | if (_err != noErr) return PyMac_Error(_err); |
| 1013 | Py_INCREF(Py_None); |
| 1014 | _res = Py_None; |
| 1015 | return _res; |
| 1016 | } |
| 1017 | |
| 1018 | static PyObject *WinObj_IsWindowPathSelectClick(_self, _args) |
| 1019 | WindowObject *_self; |
| 1020 | PyObject *_args; |
| 1021 | { |
| 1022 | PyObject *_res = NULL; |
| 1023 | Boolean _rv; |
| 1024 | EventRecord event; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1025 | if (!PyArg_ParseTuple(_args, "O&", |
| 1026 | PyMac_GetEventRecord, &event)) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1027 | return NULL; |
| 1028 | _rv = IsWindowPathSelectClick(_self->ob_itself, |
| 1029 | &event); |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1030 | _res = Py_BuildValue("b", |
| 1031 | _rv); |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1032 | return _res; |
| 1033 | } |
| 1034 | |
| 1035 | static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args) |
| 1036 | WindowObject *_self; |
| 1037 | PyObject *_args; |
| 1038 | { |
| 1039 | PyObject *_res = NULL; |
| 1040 | OSStatus _err; |
| 1041 | Boolean hilited; |
| 1042 | if (!PyArg_ParseTuple(_args, "b", |
| 1043 | &hilited)) |
| 1044 | return NULL; |
| 1045 | _err = HiliteWindowFrameForDrag(_self->ob_itself, |
| 1046 | hilited); |
| 1047 | if (_err != noErr) return PyMac_Error(_err); |
| 1048 | Py_INCREF(Py_None); |
| 1049 | _res = Py_None; |
| 1050 | return _res; |
| 1051 | } |
| 1052 | |
| 1053 | static PyObject *WinObj_TransitionWindow(_self, _args) |
| 1054 | WindowObject *_self; |
| 1055 | PyObject *_args; |
| 1056 | { |
| 1057 | PyObject *_res = NULL; |
| 1058 | OSStatus _err; |
| 1059 | WindowTransitionEffect effect; |
| 1060 | WindowTransitionAction action; |
| 1061 | Rect rect; |
| 1062 | if (!PyArg_ParseTuple(_args, "llO&", |
| 1063 | &effect, |
| 1064 | &action, |
| 1065 | PyMac_GetRect, &rect)) |
| 1066 | return NULL; |
| 1067 | _err = TransitionWindow(_self->ob_itself, |
| 1068 | effect, |
| 1069 | action, |
| 1070 | &rect); |
Jack Jansen | e4349e8 | 1999-03-04 22:53:24 +0000 | [diff] [blame] | 1071 | if (_err != noErr) return PyMac_Error(_err); |
| 1072 | Py_INCREF(Py_None); |
| 1073 | _res = Py_None; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1074 | return _res; |
| 1075 | } |
| 1076 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1077 | static PyObject *WinObj_MacMoveWindow(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1078 | WindowObject *_self; |
| 1079 | PyObject *_args; |
| 1080 | { |
| 1081 | PyObject *_res = NULL; |
| 1082 | short hGlobal; |
| 1083 | short vGlobal; |
| 1084 | Boolean front; |
| 1085 | if (!PyArg_ParseTuple(_args, "hhb", |
| 1086 | &hGlobal, |
| 1087 | &vGlobal, |
| 1088 | &front)) |
| 1089 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1090 | MacMoveWindow(_self->ob_itself, |
| 1091 | hGlobal, |
| 1092 | vGlobal, |
| 1093 | front); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1094 | Py_INCREF(Py_None); |
| 1095 | _res = Py_None; |
| 1096 | return _res; |
| 1097 | } |
| 1098 | |
| 1099 | static PyObject *WinObj_SizeWindow(_self, _args) |
| 1100 | WindowObject *_self; |
| 1101 | PyObject *_args; |
| 1102 | { |
| 1103 | PyObject *_res = NULL; |
| 1104 | short w; |
| 1105 | short h; |
| 1106 | Boolean fUpdate; |
| 1107 | if (!PyArg_ParseTuple(_args, "hhb", |
| 1108 | &w, |
| 1109 | &h, |
| 1110 | &fUpdate)) |
| 1111 | return NULL; |
| 1112 | SizeWindow(_self->ob_itself, |
| 1113 | w, |
| 1114 | h, |
| 1115 | fUpdate); |
| 1116 | Py_INCREF(Py_None); |
| 1117 | _res = Py_None; |
| 1118 | return _res; |
| 1119 | } |
| 1120 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1121 | static PyObject *WinObj_GrowWindow(_self, _args) |
| 1122 | WindowObject *_self; |
| 1123 | PyObject *_args; |
| 1124 | { |
| 1125 | PyObject *_res = NULL; |
| 1126 | long _rv; |
| 1127 | Point startPt; |
| 1128 | Rect bBox; |
| 1129 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1130 | PyMac_GetPoint, &startPt, |
| 1131 | PyMac_GetRect, &bBox)) |
| 1132 | return NULL; |
| 1133 | _rv = GrowWindow(_self->ob_itself, |
| 1134 | startPt, |
| 1135 | &bBox); |
| 1136 | _res = Py_BuildValue("l", |
| 1137 | _rv); |
| 1138 | return _res; |
| 1139 | } |
| 1140 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1141 | static PyObject *WinObj_DragWindow(_self, _args) |
| 1142 | WindowObject *_self; |
| 1143 | PyObject *_args; |
| 1144 | { |
| 1145 | PyObject *_res = NULL; |
| 1146 | Point startPt; |
| 1147 | Rect boundsRect; |
| 1148 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1149 | PyMac_GetPoint, &startPt, |
| 1150 | PyMac_GetRect, &boundsRect)) |
| 1151 | return NULL; |
| 1152 | DragWindow(_self->ob_itself, |
| 1153 | startPt, |
| 1154 | &boundsRect); |
| 1155 | Py_INCREF(Py_None); |
| 1156 | _res = Py_None; |
| 1157 | return _res; |
| 1158 | } |
| 1159 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1160 | static PyObject *WinObj_ZoomWindow(_self, _args) |
| 1161 | WindowObject *_self; |
| 1162 | PyObject *_args; |
| 1163 | { |
| 1164 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1165 | WindowPartCode partCode; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1166 | Boolean front; |
| 1167 | if (!PyArg_ParseTuple(_args, "hb", |
| 1168 | &partCode, |
| 1169 | &front)) |
| 1170 | return NULL; |
| 1171 | ZoomWindow(_self->ob_itself, |
| 1172 | partCode, |
| 1173 | front); |
| 1174 | Py_INCREF(Py_None); |
| 1175 | _res = Py_None; |
| 1176 | return _res; |
| 1177 | } |
| 1178 | |
| 1179 | static PyObject *WinObj_IsWindowCollapsable(_self, _args) |
| 1180 | WindowObject *_self; |
| 1181 | PyObject *_args; |
| 1182 | { |
| 1183 | PyObject *_res = NULL; |
| 1184 | Boolean _rv; |
| 1185 | if (!PyArg_ParseTuple(_args, "")) |
| 1186 | return NULL; |
| 1187 | _rv = IsWindowCollapsable(_self->ob_itself); |
| 1188 | _res = Py_BuildValue("b", |
| 1189 | _rv); |
| 1190 | return _res; |
| 1191 | } |
| 1192 | |
| 1193 | static PyObject *WinObj_IsWindowCollapsed(_self, _args) |
| 1194 | WindowObject *_self; |
| 1195 | PyObject *_args; |
| 1196 | { |
| 1197 | PyObject *_res = NULL; |
| 1198 | Boolean _rv; |
| 1199 | if (!PyArg_ParseTuple(_args, "")) |
| 1200 | return NULL; |
| 1201 | _rv = IsWindowCollapsed(_self->ob_itself); |
| 1202 | _res = Py_BuildValue("b", |
| 1203 | _rv); |
| 1204 | return _res; |
| 1205 | } |
| 1206 | |
| 1207 | static PyObject *WinObj_CollapseWindow(_self, _args) |
| 1208 | WindowObject *_self; |
| 1209 | PyObject *_args; |
| 1210 | { |
| 1211 | PyObject *_res = NULL; |
| 1212 | OSStatus _err; |
| 1213 | Boolean collapse; |
| 1214 | if (!PyArg_ParseTuple(_args, "b", |
| 1215 | &collapse)) |
| 1216 | return NULL; |
| 1217 | _err = CollapseWindow(_self->ob_itself, |
| 1218 | collapse); |
| 1219 | if (_err != noErr) return PyMac_Error(_err); |
| 1220 | Py_INCREF(Py_None); |
| 1221 | _res = Py_None; |
| 1222 | return _res; |
| 1223 | } |
| 1224 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1225 | static PyObject *WinObj_GetWindowBounds(_self, _args) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1226 | WindowObject *_self; |
| 1227 | PyObject *_args; |
| 1228 | { |
| 1229 | PyObject *_res = NULL; |
| 1230 | OSStatus _err; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1231 | WindowRegionCode regionCode; |
| 1232 | Rect globalBounds; |
| 1233 | if (!PyArg_ParseTuple(_args, "H", |
| 1234 | ®ionCode)) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1235 | return NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1236 | _err = GetWindowBounds(_self->ob_itself, |
| 1237 | regionCode, |
| 1238 | &globalBounds); |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1239 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1240 | _res = Py_BuildValue("O&", |
| 1241 | PyMac_BuildRect, &globalBounds); |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1242 | return _res; |
| 1243 | } |
| 1244 | |
| 1245 | static PyObject *WinObj_SetWindowBounds(_self, _args) |
| 1246 | WindowObject *_self; |
| 1247 | PyObject *_args; |
| 1248 | { |
| 1249 | PyObject *_res = NULL; |
| 1250 | OSStatus _err; |
| 1251 | WindowRegionCode regionCode; |
| 1252 | Rect globalBounds; |
Jack Jansen | 0b13e7c | 2000-07-07 13:09:35 +0000 | [diff] [blame] | 1253 | if (!PyArg_ParseTuple(_args, "HO&", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1254 | ®ionCode, |
| 1255 | PyMac_GetRect, &globalBounds)) |
| 1256 | return NULL; |
| 1257 | _err = SetWindowBounds(_self->ob_itself, |
| 1258 | regionCode, |
| 1259 | &globalBounds); |
| 1260 | if (_err != noErr) return PyMac_Error(_err); |
| 1261 | Py_INCREF(Py_None); |
| 1262 | _res = Py_None; |
| 1263 | return _res; |
| 1264 | } |
| 1265 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1266 | static PyObject *WinObj_RepositionWindow(_self, _args) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1267 | WindowObject *_self; |
| 1268 | PyObject *_args; |
| 1269 | { |
| 1270 | PyObject *_res = NULL; |
| 1271 | OSStatus _err; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1272 | WindowPtr parentWindow; |
| 1273 | WindowPositionMethod method; |
| 1274 | if (!PyArg_ParseTuple(_args, "O&l", |
| 1275 | WinObj_Convert, &parentWindow, |
| 1276 | &method)) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1277 | return NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1278 | _err = RepositionWindow(_self->ob_itself, |
| 1279 | parentWindow, |
| 1280 | method); |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1281 | if (_err != noErr) return PyMac_Error(_err); |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1282 | Py_INCREF(Py_None); |
| 1283 | _res = Py_None; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1284 | return _res; |
| 1285 | } |
| 1286 | |
| 1287 | static PyObject *WinObj_MoveWindowStructure(_self, _args) |
| 1288 | WindowObject *_self; |
| 1289 | PyObject *_args; |
| 1290 | { |
| 1291 | PyObject *_res = NULL; |
| 1292 | OSStatus _err; |
| 1293 | short hGlobal; |
| 1294 | short vGlobal; |
| 1295 | if (!PyArg_ParseTuple(_args, "hh", |
| 1296 | &hGlobal, |
| 1297 | &vGlobal)) |
| 1298 | return NULL; |
| 1299 | _err = MoveWindowStructure(_self->ob_itself, |
| 1300 | hGlobal, |
| 1301 | vGlobal); |
| 1302 | if (_err != noErr) return PyMac_Error(_err); |
| 1303 | Py_INCREF(Py_None); |
| 1304 | _res = Py_None; |
| 1305 | return _res; |
| 1306 | } |
| 1307 | |
| 1308 | static PyObject *WinObj_IsWindowInStandardState(_self, _args) |
| 1309 | WindowObject *_self; |
| 1310 | PyObject *_args; |
| 1311 | { |
| 1312 | PyObject *_res = NULL; |
| 1313 | Boolean _rv; |
| 1314 | Point idealSize; |
| 1315 | Rect idealStandardState; |
| 1316 | if (!PyArg_ParseTuple(_args, "")) |
| 1317 | return NULL; |
| 1318 | _rv = IsWindowInStandardState(_self->ob_itself, |
| 1319 | &idealSize, |
| 1320 | &idealStandardState); |
| 1321 | _res = Py_BuildValue("bO&O&", |
| 1322 | _rv, |
| 1323 | PyMac_BuildPoint, idealSize, |
| 1324 | PyMac_BuildRect, &idealStandardState); |
| 1325 | return _res; |
| 1326 | } |
| 1327 | |
| 1328 | static PyObject *WinObj_ZoomWindowIdeal(_self, _args) |
| 1329 | WindowObject *_self; |
| 1330 | PyObject *_args; |
| 1331 | { |
| 1332 | PyObject *_res = NULL; |
| 1333 | OSStatus _err; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1334 | WindowPartCode partCode; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1335 | Point ioIdealSize; |
| 1336 | if (!PyArg_ParseTuple(_args, "h", |
| 1337 | &partCode)) |
| 1338 | return NULL; |
| 1339 | _err = ZoomWindowIdeal(_self->ob_itself, |
| 1340 | partCode, |
| 1341 | &ioIdealSize); |
| 1342 | if (_err != noErr) return PyMac_Error(_err); |
| 1343 | _res = Py_BuildValue("O&", |
| 1344 | PyMac_BuildPoint, ioIdealSize); |
| 1345 | return _res; |
| 1346 | } |
| 1347 | |
| 1348 | static PyObject *WinObj_GetWindowIdealUserState(_self, _args) |
| 1349 | WindowObject *_self; |
| 1350 | PyObject *_args; |
| 1351 | { |
| 1352 | PyObject *_res = NULL; |
| 1353 | OSStatus _err; |
| 1354 | Rect userState; |
| 1355 | if (!PyArg_ParseTuple(_args, "")) |
| 1356 | return NULL; |
| 1357 | _err = GetWindowIdealUserState(_self->ob_itself, |
| 1358 | &userState); |
| 1359 | if (_err != noErr) return PyMac_Error(_err); |
| 1360 | _res = Py_BuildValue("O&", |
| 1361 | PyMac_BuildRect, &userState); |
| 1362 | return _res; |
| 1363 | } |
| 1364 | |
| 1365 | static PyObject *WinObj_SetWindowIdealUserState(_self, _args) |
| 1366 | WindowObject *_self; |
| 1367 | PyObject *_args; |
| 1368 | { |
| 1369 | PyObject *_res = NULL; |
| 1370 | OSStatus _err; |
| 1371 | Rect userState; |
| 1372 | if (!PyArg_ParseTuple(_args, "")) |
| 1373 | return NULL; |
| 1374 | _err = SetWindowIdealUserState(_self->ob_itself, |
| 1375 | &userState); |
| 1376 | if (_err != noErr) return PyMac_Error(_err); |
| 1377 | _res = Py_BuildValue("O&", |
| 1378 | PyMac_BuildRect, &userState); |
| 1379 | return _res; |
| 1380 | } |
| 1381 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1382 | static PyObject *WinObj_HideWindow(_self, _args) |
| 1383 | WindowObject *_self; |
| 1384 | PyObject *_args; |
| 1385 | { |
| 1386 | PyObject *_res = NULL; |
| 1387 | if (!PyArg_ParseTuple(_args, "")) |
| 1388 | return NULL; |
| 1389 | HideWindow(_self->ob_itself); |
| 1390 | Py_INCREF(Py_None); |
| 1391 | _res = Py_None; |
| 1392 | return _res; |
| 1393 | } |
| 1394 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1395 | static PyObject *WinObj_MacShowWindow(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1396 | WindowObject *_self; |
| 1397 | PyObject *_args; |
| 1398 | { |
| 1399 | PyObject *_res = NULL; |
| 1400 | if (!PyArg_ParseTuple(_args, "")) |
| 1401 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1402 | MacShowWindow(_self->ob_itself); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1403 | Py_INCREF(Py_None); |
| 1404 | _res = Py_None; |
| 1405 | return _res; |
| 1406 | } |
| 1407 | |
| 1408 | static PyObject *WinObj_ShowHide(_self, _args) |
| 1409 | WindowObject *_self; |
| 1410 | PyObject *_args; |
| 1411 | { |
| 1412 | PyObject *_res = NULL; |
| 1413 | Boolean showFlag; |
| 1414 | if (!PyArg_ParseTuple(_args, "b", |
| 1415 | &showFlag)) |
| 1416 | return NULL; |
| 1417 | ShowHide(_self->ob_itself, |
| 1418 | showFlag); |
| 1419 | Py_INCREF(Py_None); |
| 1420 | _res = Py_None; |
| 1421 | return _res; |
| 1422 | } |
| 1423 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1424 | #if TARGET_API_MAC_CARBON |
| 1425 | |
| 1426 | static PyObject *WinObj_GetWindowPropertyAttributes(_self, _args) |
| 1427 | WindowObject *_self; |
| 1428 | PyObject *_args; |
| 1429 | { |
| 1430 | PyObject *_res = NULL; |
| 1431 | OSStatus _err; |
| 1432 | OSType propertyCreator; |
| 1433 | OSType propertyTag; |
| 1434 | UInt32 attributes; |
| 1435 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 1436 | PyMac_GetOSType, &propertyCreator, |
| 1437 | PyMac_GetOSType, &propertyTag)) |
| 1438 | return NULL; |
| 1439 | _err = GetWindowPropertyAttributes(_self->ob_itself, |
| 1440 | propertyCreator, |
| 1441 | propertyTag, |
| 1442 | &attributes); |
| 1443 | if (_err != noErr) return PyMac_Error(_err); |
| 1444 | _res = Py_BuildValue("l", |
| 1445 | attributes); |
| 1446 | return _res; |
| 1447 | } |
| 1448 | #endif |
| 1449 | |
| 1450 | #if TARGET_API_MAC_CARBON |
| 1451 | |
| 1452 | static PyObject *WinObj_ChangeWindowPropertyAttributes(_self, _args) |
| 1453 | WindowObject *_self; |
| 1454 | PyObject *_args; |
| 1455 | { |
| 1456 | PyObject *_res = NULL; |
| 1457 | OSStatus _err; |
| 1458 | OSType propertyCreator; |
| 1459 | OSType propertyTag; |
| 1460 | UInt32 attributesToSet; |
| 1461 | UInt32 attributesToClear; |
| 1462 | if (!PyArg_ParseTuple(_args, "O&O&ll", |
| 1463 | PyMac_GetOSType, &propertyCreator, |
| 1464 | PyMac_GetOSType, &propertyTag, |
| 1465 | &attributesToSet, |
| 1466 | &attributesToClear)) |
| 1467 | return NULL; |
| 1468 | _err = ChangeWindowPropertyAttributes(_self->ob_itself, |
| 1469 | propertyCreator, |
| 1470 | propertyTag, |
| 1471 | attributesToSet, |
| 1472 | attributesToClear); |
| 1473 | if (_err != noErr) return PyMac_Error(_err); |
| 1474 | Py_INCREF(Py_None); |
| 1475 | _res = Py_None; |
| 1476 | return _res; |
| 1477 | } |
| 1478 | #endif |
| 1479 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1480 | static PyObject *WinObj_TrackBox(_self, _args) |
| 1481 | WindowObject *_self; |
| 1482 | PyObject *_args; |
| 1483 | { |
| 1484 | PyObject *_res = NULL; |
| 1485 | Boolean _rv; |
| 1486 | Point thePt; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1487 | WindowPartCode partCode; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1488 | if (!PyArg_ParseTuple(_args, "O&h", |
| 1489 | PyMac_GetPoint, &thePt, |
| 1490 | &partCode)) |
| 1491 | return NULL; |
| 1492 | _rv = TrackBox(_self->ob_itself, |
| 1493 | thePt, |
| 1494 | partCode); |
| 1495 | _res = Py_BuildValue("b", |
| 1496 | _rv); |
| 1497 | return _res; |
| 1498 | } |
| 1499 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1500 | static PyObject *WinObj_TrackGoAway(_self, _args) |
| 1501 | WindowObject *_self; |
| 1502 | PyObject *_args; |
| 1503 | { |
| 1504 | PyObject *_res = NULL; |
| 1505 | Boolean _rv; |
| 1506 | Point thePt; |
| 1507 | if (!PyArg_ParseTuple(_args, "O&", |
| 1508 | PyMac_GetPoint, &thePt)) |
| 1509 | return NULL; |
| 1510 | _rv = TrackGoAway(_self->ob_itself, |
| 1511 | thePt); |
| 1512 | _res = Py_BuildValue("b", |
| 1513 | _rv); |
| 1514 | return _res; |
| 1515 | } |
| 1516 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1517 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1518 | |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 1519 | static PyObject *WinObj_GetAuxWin(_self, _args) |
| 1520 | WindowObject *_self; |
| 1521 | PyObject *_args; |
| 1522 | { |
| 1523 | PyObject *_res = NULL; |
| 1524 | Boolean _rv; |
| 1525 | AuxWinHandle awHndl; |
| 1526 | if (!PyArg_ParseTuple(_args, "")) |
| 1527 | return NULL; |
| 1528 | _rv = GetAuxWin(_self->ob_itself, |
| 1529 | &awHndl); |
| 1530 | _res = Py_BuildValue("bO&", |
| 1531 | _rv, |
| 1532 | ResObj_New, awHndl); |
| 1533 | return _res; |
| 1534 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1535 | #endif |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 1536 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1537 | static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args) |
| 1538 | WindowObject *_self; |
| 1539 | PyObject *_args; |
| 1540 | { |
| 1541 | PyObject *_res = NULL; |
| 1542 | Boolean _rv; |
| 1543 | if (!PyArg_ParseTuple(_args, "")) |
| 1544 | return NULL; |
| 1545 | _rv = GetWindowGoAwayFlag(_self->ob_itself); |
| 1546 | _res = Py_BuildValue("b", |
| 1547 | _rv); |
| 1548 | return _res; |
| 1549 | } |
| 1550 | |
| 1551 | static PyObject *WinObj_GetWindowSpareFlag(_self, _args) |
| 1552 | WindowObject *_self; |
| 1553 | PyObject *_args; |
| 1554 | { |
| 1555 | PyObject *_res = NULL; |
| 1556 | Boolean _rv; |
| 1557 | if (!PyArg_ParseTuple(_args, "")) |
| 1558 | return NULL; |
| 1559 | _rv = GetWindowSpareFlag(_self->ob_itself); |
| 1560 | _res = Py_BuildValue("b", |
| 1561 | _rv); |
| 1562 | return _res; |
| 1563 | } |
| 1564 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 1565 | static PyObject *WinObj_GetWindowPort(_self, _args) |
| 1566 | WindowObject *_self; |
| 1567 | PyObject *_args; |
| 1568 | { |
| 1569 | PyObject *_res = NULL; |
| 1570 | CGrafPtr _rv; |
| 1571 | if (!PyArg_ParseTuple(_args, "")) |
| 1572 | return NULL; |
| 1573 | _rv = GetWindowPort(_self->ob_itself); |
| 1574 | _res = Py_BuildValue("O&", |
| 1575 | GrafObj_New, _rv); |
| 1576 | return _res; |
| 1577 | } |
| 1578 | |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1579 | static PyObject *WinObj_GetWindowKind(_self, _args) |
| 1580 | WindowObject *_self; |
| 1581 | PyObject *_args; |
| 1582 | { |
| 1583 | PyObject *_res = NULL; |
| 1584 | short _rv; |
| 1585 | if (!PyArg_ParseTuple(_args, "")) |
| 1586 | return NULL; |
| 1587 | _rv = GetWindowKind(_self->ob_itself); |
| 1588 | _res = Py_BuildValue("h", |
| 1589 | _rv); |
| 1590 | return _res; |
| 1591 | } |
| 1592 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1593 | static PyObject *WinObj_MacIsWindowVisible(_self, _args) |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1594 | WindowObject *_self; |
| 1595 | PyObject *_args; |
| 1596 | { |
| 1597 | PyObject *_res = NULL; |
| 1598 | Boolean _rv; |
| 1599 | if (!PyArg_ParseTuple(_args, "")) |
| 1600 | return NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1601 | _rv = MacIsWindowVisible(_self->ob_itself); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1602 | _res = Py_BuildValue("b", |
| 1603 | _rv); |
| 1604 | return _res; |
| 1605 | } |
| 1606 | |
| 1607 | static PyObject *WinObj_IsWindowHilited(_self, _args) |
| 1608 | WindowObject *_self; |
| 1609 | PyObject *_args; |
| 1610 | { |
| 1611 | PyObject *_res = NULL; |
| 1612 | Boolean _rv; |
| 1613 | if (!PyArg_ParseTuple(_args, "")) |
| 1614 | return NULL; |
| 1615 | _rv = IsWindowHilited(_self->ob_itself); |
| 1616 | _res = Py_BuildValue("b", |
| 1617 | _rv); |
| 1618 | return _res; |
| 1619 | } |
| 1620 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1621 | #if TARGET_API_MAC_CARBON |
| 1622 | |
| 1623 | static PyObject *WinObj_IsWindowUpdatePending(_self, _args) |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1624 | WindowObject *_self; |
| 1625 | PyObject *_args; |
| 1626 | { |
| 1627 | PyObject *_res = NULL; |
| 1628 | Boolean _rv; |
| 1629 | if (!PyArg_ParseTuple(_args, "")) |
| 1630 | return NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1631 | _rv = IsWindowUpdatePending(_self->ob_itself); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1632 | _res = Py_BuildValue("b", |
| 1633 | _rv); |
| 1634 | return _res; |
| 1635 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1636 | #endif |
| 1637 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1638 | static PyObject *WinObj_MacGetNextWindow(_self, _args) |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1639 | WindowObject *_self; |
| 1640 | PyObject *_args; |
| 1641 | { |
| 1642 | PyObject *_res = NULL; |
| 1643 | WindowPtr _rv; |
| 1644 | if (!PyArg_ParseTuple(_args, "")) |
| 1645 | return NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1646 | _rv = MacGetNextWindow(_self->ob_itself); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1647 | _res = Py_BuildValue("O&", |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1648 | WinObj_New, _rv); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1649 | return _res; |
| 1650 | } |
| 1651 | |
| 1652 | static PyObject *WinObj_GetWindowStandardState(_self, _args) |
| 1653 | WindowObject *_self; |
| 1654 | PyObject *_args; |
| 1655 | { |
| 1656 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1657 | Rect rect; |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1658 | if (!PyArg_ParseTuple(_args, "")) |
| 1659 | return NULL; |
| 1660 | GetWindowStandardState(_self->ob_itself, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1661 | &rect); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1662 | _res = Py_BuildValue("O&", |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1663 | PyMac_BuildRect, &rect); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1664 | return _res; |
| 1665 | } |
| 1666 | |
| 1667 | static PyObject *WinObj_GetWindowUserState(_self, _args) |
| 1668 | WindowObject *_self; |
| 1669 | PyObject *_args; |
| 1670 | { |
| 1671 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1672 | Rect rect; |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1673 | if (!PyArg_ParseTuple(_args, "")) |
| 1674 | return NULL; |
| 1675 | GetWindowUserState(_self->ob_itself, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1676 | &rect); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1677 | _res = Py_BuildValue("O&", |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1678 | PyMac_BuildRect, &rect); |
| 1679 | return _res; |
| 1680 | } |
| 1681 | |
| 1682 | static PyObject *WinObj_SetWindowKind(_self, _args) |
| 1683 | WindowObject *_self; |
| 1684 | PyObject *_args; |
| 1685 | { |
| 1686 | PyObject *_res = NULL; |
| 1687 | short kind; |
| 1688 | if (!PyArg_ParseTuple(_args, "h", |
| 1689 | &kind)) |
| 1690 | return NULL; |
| 1691 | SetWindowKind(_self->ob_itself, |
| 1692 | kind); |
| 1693 | Py_INCREF(Py_None); |
| 1694 | _res = Py_None; |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1695 | return _res; |
| 1696 | } |
| 1697 | |
| 1698 | static PyObject *WinObj_SetWindowStandardState(_self, _args) |
| 1699 | WindowObject *_self; |
| 1700 | PyObject *_args; |
| 1701 | { |
| 1702 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1703 | Rect rect; |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1704 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1705 | PyMac_GetRect, &rect)) |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1706 | return NULL; |
| 1707 | SetWindowStandardState(_self->ob_itself, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1708 | &rect); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1709 | Py_INCREF(Py_None); |
| 1710 | _res = Py_None; |
| 1711 | return _res; |
| 1712 | } |
| 1713 | |
| 1714 | static PyObject *WinObj_SetWindowUserState(_self, _args) |
| 1715 | WindowObject *_self; |
| 1716 | PyObject *_args; |
| 1717 | { |
| 1718 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1719 | Rect rect; |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1720 | if (!PyArg_ParseTuple(_args, "O&", |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1721 | PyMac_GetRect, &rect)) |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1722 | return NULL; |
| 1723 | SetWindowUserState(_self->ob_itself, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1724 | &rect); |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 1725 | Py_INCREF(Py_None); |
| 1726 | _res = Py_None; |
| 1727 | return _res; |
| 1728 | } |
| 1729 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1730 | static PyObject *WinObj_SetPortWindowPort(_self, _args) |
| 1731 | WindowObject *_self; |
| 1732 | PyObject *_args; |
| 1733 | { |
| 1734 | PyObject *_res = NULL; |
| 1735 | if (!PyArg_ParseTuple(_args, "")) |
| 1736 | return NULL; |
| 1737 | SetPortWindowPort(_self->ob_itself); |
| 1738 | Py_INCREF(Py_None); |
| 1739 | _res = Py_None; |
| 1740 | return _res; |
| 1741 | } |
| 1742 | |
| 1743 | static PyObject *WinObj_GetWindowPortBounds(_self, _args) |
| 1744 | WindowObject *_self; |
| 1745 | PyObject *_args; |
| 1746 | { |
| 1747 | PyObject *_res = NULL; |
| 1748 | Rect bounds; |
| 1749 | if (!PyArg_ParseTuple(_args, "")) |
| 1750 | return NULL; |
| 1751 | GetWindowPortBounds(_self->ob_itself, |
| 1752 | &bounds); |
| 1753 | _res = Py_BuildValue("O&", |
| 1754 | PyMac_BuildRect, &bounds); |
| 1755 | return _res; |
| 1756 | } |
| 1757 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1758 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | cdcbd1f | 1998-10-22 15:08:00 +0000 | [diff] [blame] | 1759 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1760 | static PyObject *WinObj_CloseWindow(_self, _args) |
| 1761 | WindowObject *_self; |
| 1762 | PyObject *_args; |
| 1763 | { |
| 1764 | PyObject *_res = NULL; |
| 1765 | if (!PyArg_ParseTuple(_args, "")) |
| 1766 | return NULL; |
| 1767 | CloseWindow(_self->ob_itself); |
| 1768 | Py_INCREF(Py_None); |
| 1769 | _res = Py_None; |
| 1770 | return _res; |
| 1771 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1772 | #endif |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 1773 | |
| 1774 | static PyObject *WinObj_MoveWindow(_self, _args) |
| 1775 | WindowObject *_self; |
| 1776 | PyObject *_args; |
| 1777 | { |
| 1778 | PyObject *_res = NULL; |
| 1779 | short hGlobal; |
| 1780 | short vGlobal; |
| 1781 | Boolean front; |
| 1782 | if (!PyArg_ParseTuple(_args, "hhb", |
| 1783 | &hGlobal, |
| 1784 | &vGlobal, |
| 1785 | &front)) |
| 1786 | return NULL; |
| 1787 | MoveWindow(_self->ob_itself, |
| 1788 | hGlobal, |
| 1789 | vGlobal, |
| 1790 | front); |
| 1791 | Py_INCREF(Py_None); |
| 1792 | _res = Py_None; |
| 1793 | return _res; |
| 1794 | } |
| 1795 | |
| 1796 | static PyObject *WinObj_ShowWindow(_self, _args) |
| 1797 | WindowObject *_self; |
| 1798 | PyObject *_args; |
| 1799 | { |
| 1800 | PyObject *_res = NULL; |
| 1801 | if (!PyArg_ParseTuple(_args, "")) |
| 1802 | return NULL; |
| 1803 | ShowWindow(_self->ob_itself); |
| 1804 | Py_INCREF(Py_None); |
| 1805 | _res = Py_None; |
| 1806 | return _res; |
| 1807 | } |
| 1808 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1809 | static PyMethodDef WinObj_methods[] = { |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1810 | {"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1, |
| 1811 | "() -> (UInt32 outCount)"}, |
| 1812 | {"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1, |
| 1813 | "() -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1814 | |
| 1815 | #if TARGET_API_MAC_CARBON |
| 1816 | {"ReshapeCustomWindow", (PyCFunction)WinObj_ReshapeCustomWindow, 1, |
| 1817 | "() -> None"}, |
| 1818 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1819 | {"GetWindowClass", (PyCFunction)WinObj_GetWindowClass, 1, |
| 1820 | "() -> (WindowClass outClass)"}, |
| 1821 | {"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1, |
| 1822 | "() -> (WindowAttributes outAttributes)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1823 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1824 | #if TARGET_API_MAC_CARBON |
| 1825 | {"ChangeWindowAttributes", (PyCFunction)WinObj_ChangeWindowAttributes, 1, |
| 1826 | "(WindowAttributes setTheseAttributes, WindowAttributes clearTheseAttributes) -> None"}, |
| 1827 | #endif |
| 1828 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1829 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1830 | {"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1, |
| 1831 | "(WCTabHandle newColorTable) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1832 | #endif |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1833 | {"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1834 | "(RGBColor color) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1835 | {"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1, |
| 1836 | "() -> (RGBColor color)"}, |
| 1837 | {"GetWindowContentPattern", (PyCFunction)WinObj_GetWindowContentPattern, 1, |
| 1838 | "(PixPatHandle outPixPat) -> None"}, |
| 1839 | {"SetWindowContentPattern", (PyCFunction)WinObj_SetWindowContentPattern, 1, |
| 1840 | "(PixPatHandle pixPat) -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1841 | |
| 1842 | #if TARGET_API_MAC_CARBON |
| 1843 | {"ScrollWindowRect", (PyCFunction)WinObj_ScrollWindowRect, 1, |
| 1844 | "(Rect inScrollRect, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"}, |
| 1845 | #endif |
| 1846 | |
| 1847 | #if TARGET_API_MAC_CARBON |
| 1848 | {"ScrollWindowRegion", (PyCFunction)WinObj_ScrollWindowRegion, 1, |
| 1849 | "(RgnHandle inScrollRgn, SInt16 inHPixels, SInt16 inVPixels, ScrollWindowOptions inOptions, RgnHandle outExposedRgn) -> None"}, |
| 1850 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1851 | {"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1, |
| 1852 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1853 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1854 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1855 | {"SaveOld", (PyCFunction)WinObj_SaveOld, 1, |
| 1856 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1857 | #endif |
| 1858 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 1859 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1860 | {"DrawNew", (PyCFunction)WinObj_DrawNew, 1, |
| 1861 | "(Boolean update) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 1862 | #endif |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1863 | {"CalcVis", (PyCFunction)WinObj_CalcVis, 1, |
| 1864 | "() -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1865 | {"BringToFront", (PyCFunction)WinObj_BringToFront, 1, |
| 1866 | "() -> None"}, |
| 1867 | {"SendBehind", (PyCFunction)WinObj_SendBehind, 1, |
| 1868 | "(WindowPtr behindWindow) -> None"}, |
| 1869 | {"SelectWindow", (PyCFunction)WinObj_SelectWindow, 1, |
| 1870 | "() -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1871 | |
| 1872 | #if TARGET_API_MAC_CARBON |
| 1873 | {"GetNextWindowOfClass", (PyCFunction)WinObj_GetNextWindowOfClass, 1, |
| 1874 | "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"}, |
| 1875 | #endif |
| 1876 | |
| 1877 | #if !TARGET_API_MAC_CARBON |
| 1878 | {"IsValidWindowPtr", (PyCFunction)WinObj_IsValidWindowPtr, 1, |
| 1879 | "() -> (Boolean _rv)"}, |
| 1880 | #endif |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1881 | {"HiliteWindow", (PyCFunction)WinObj_HiliteWindow, 1, |
| 1882 | "(Boolean fHilite) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1883 | {"SetWRefCon", (PyCFunction)WinObj_SetWRefCon, 1, |
| 1884 | "(long data) -> None"}, |
| 1885 | {"GetWRefCon", (PyCFunction)WinObj_GetWRefCon, 1, |
| 1886 | "() -> (long _rv)"}, |
| 1887 | {"SetWindowPic", (PyCFunction)WinObj_SetWindowPic, 1, |
| 1888 | "(PicHandle pic) -> None"}, |
| 1889 | {"GetWindowPic", (PyCFunction)WinObj_GetWindowPic, 1, |
| 1890 | "() -> (PicHandle _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1891 | {"GetWVariant", (PyCFunction)WinObj_GetWVariant, 1, |
| 1892 | "() -> (short _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1893 | {"GetWindowFeatures", (PyCFunction)WinObj_GetWindowFeatures, 1, |
| 1894 | "() -> (UInt32 outFeatures)"}, |
| 1895 | {"GetWindowRegion", (PyCFunction)WinObj_GetWindowRegion, 1, |
| 1896 | "(WindowRegionCode inRegionCode, RgnHandle ioWinRgn) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1897 | {"BeginUpdate", (PyCFunction)WinObj_BeginUpdate, 1, |
| 1898 | "() -> None"}, |
| 1899 | {"EndUpdate", (PyCFunction)WinObj_EndUpdate, 1, |
| 1900 | "() -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1901 | {"InvalWindowRgn", (PyCFunction)WinObj_InvalWindowRgn, 1, |
| 1902 | "(RgnHandle region) -> None"}, |
| 1903 | {"InvalWindowRect", (PyCFunction)WinObj_InvalWindowRect, 1, |
| 1904 | "(Rect bounds) -> None"}, |
| 1905 | {"ValidWindowRgn", (PyCFunction)WinObj_ValidWindowRgn, 1, |
| 1906 | "(RgnHandle region) -> None"}, |
| 1907 | {"ValidWindowRect", (PyCFunction)WinObj_ValidWindowRect, 1, |
| 1908 | "(Rect bounds) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1909 | {"DrawGrowIcon", (PyCFunction)WinObj_DrawGrowIcon, 1, |
| 1910 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 1911 | {"SetWTitle", (PyCFunction)WinObj_SetWTitle, 1, |
| 1912 | "(Str255 title) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1913 | {"GetWTitle", (PyCFunction)WinObj_GetWTitle, 1, |
| 1914 | "() -> (Str255 title)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1915 | {"SetWindowProxyFSSpec", (PyCFunction)WinObj_SetWindowProxyFSSpec, 1, |
| 1916 | "(FSSpec inFile) -> None"}, |
| 1917 | {"GetWindowProxyFSSpec", (PyCFunction)WinObj_GetWindowProxyFSSpec, 1, |
| 1918 | "() -> (FSSpec outFile)"}, |
| 1919 | {"SetWindowProxyAlias", (PyCFunction)WinObj_SetWindowProxyAlias, 1, |
| 1920 | "(AliasHandle alias) -> None"}, |
| 1921 | {"GetWindowProxyAlias", (PyCFunction)WinObj_GetWindowProxyAlias, 1, |
| 1922 | "() -> (AliasHandle alias)"}, |
| 1923 | {"SetWindowProxyCreatorAndType", (PyCFunction)WinObj_SetWindowProxyCreatorAndType, 1, |
| 1924 | "(OSType fileCreator, OSType fileType, SInt16 vRefNum) -> None"}, |
| 1925 | {"GetWindowProxyIcon", (PyCFunction)WinObj_GetWindowProxyIcon, 1, |
| 1926 | "() -> (IconRef outIcon)"}, |
| 1927 | {"SetWindowProxyIcon", (PyCFunction)WinObj_SetWindowProxyIcon, 1, |
| 1928 | "(IconRef icon) -> None"}, |
| 1929 | {"RemoveWindowProxy", (PyCFunction)WinObj_RemoveWindowProxy, 1, |
| 1930 | "() -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1931 | {"BeginWindowProxyDrag", (PyCFunction)WinObj_BeginWindowProxyDrag, 1, |
| 1932 | "(RgnHandle outDragOutlineRgn) -> (DragReference outNewDrag)"}, |
| 1933 | {"EndWindowProxyDrag", (PyCFunction)WinObj_EndWindowProxyDrag, 1, |
| 1934 | "(DragReference theDrag) -> None"}, |
| 1935 | {"TrackWindowProxyFromExistingDrag", (PyCFunction)WinObj_TrackWindowProxyFromExistingDrag, 1, |
| 1936 | "(Point startPt, DragReference drag, RgnHandle inDragOutlineRgn) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1937 | {"TrackWindowProxyDrag", (PyCFunction)WinObj_TrackWindowProxyDrag, 1, |
| 1938 | "(Point startPt) -> None"}, |
| 1939 | {"IsWindowModified", (PyCFunction)WinObj_IsWindowModified, 1, |
| 1940 | "() -> (Boolean _rv)"}, |
| 1941 | {"SetWindowModified", (PyCFunction)WinObj_SetWindowModified, 1, |
| 1942 | "(Boolean modified) -> None"}, |
| 1943 | {"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1944 | "(EventRecord event) -> (Boolean _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1945 | {"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1, |
| 1946 | "(Boolean hilited) -> None"}, |
| 1947 | {"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1, |
| 1948 | "(WindowTransitionEffect effect, WindowTransitionAction action, Rect rect) -> None"}, |
| 1949 | {"MacMoveWindow", (PyCFunction)WinObj_MacMoveWindow, 1, |
| 1950 | "(short hGlobal, short vGlobal, Boolean front) -> None"}, |
| 1951 | {"SizeWindow", (PyCFunction)WinObj_SizeWindow, 1, |
| 1952 | "(short w, short h, Boolean fUpdate) -> None"}, |
| 1953 | {"GrowWindow", (PyCFunction)WinObj_GrowWindow, 1, |
| 1954 | "(Point startPt, Rect bBox) -> (long _rv)"}, |
| 1955 | {"DragWindow", (PyCFunction)WinObj_DragWindow, 1, |
| 1956 | "(Point startPt, Rect boundsRect) -> None"}, |
| 1957 | {"ZoomWindow", (PyCFunction)WinObj_ZoomWindow, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1958 | "(WindowPartCode partCode, Boolean front) -> None"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1959 | {"IsWindowCollapsable", (PyCFunction)WinObj_IsWindowCollapsable, 1, |
| 1960 | "() -> (Boolean _rv)"}, |
| 1961 | {"IsWindowCollapsed", (PyCFunction)WinObj_IsWindowCollapsed, 1, |
| 1962 | "() -> (Boolean _rv)"}, |
| 1963 | {"CollapseWindow", (PyCFunction)WinObj_CollapseWindow, 1, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1964 | "(Boolean collapse) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1965 | {"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1, |
| 1966 | "(WindowRegionCode regionCode) -> (Rect globalBounds)"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1967 | {"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1, |
| 1968 | "(WindowRegionCode regionCode, Rect globalBounds) -> None"}, |
| 1969 | {"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1, |
| 1970 | "(WindowPtr parentWindow, WindowPositionMethod method) -> None"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1971 | {"MoveWindowStructure", (PyCFunction)WinObj_MoveWindowStructure, 1, |
| 1972 | "(short hGlobal, short vGlobal) -> None"}, |
| 1973 | {"IsWindowInStandardState", (PyCFunction)WinObj_IsWindowInStandardState, 1, |
| 1974 | "() -> (Boolean _rv, Point idealSize, Rect idealStandardState)"}, |
| 1975 | {"ZoomWindowIdeal", (PyCFunction)WinObj_ZoomWindowIdeal, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1976 | "(WindowPartCode partCode) -> (Point ioIdealSize)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 1977 | {"GetWindowIdealUserState", (PyCFunction)WinObj_GetWindowIdealUserState, 1, |
| 1978 | "() -> (Rect userState)"}, |
| 1979 | {"SetWindowIdealUserState", (PyCFunction)WinObj_SetWindowIdealUserState, 1, |
| 1980 | "() -> (Rect userState)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1981 | {"HideWindow", (PyCFunction)WinObj_HideWindow, 1, |
| 1982 | "() -> None"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 1983 | {"MacShowWindow", (PyCFunction)WinObj_MacShowWindow, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1984 | "() -> None"}, |
| 1985 | {"ShowHide", (PyCFunction)WinObj_ShowHide, 1, |
| 1986 | "(Boolean showFlag) -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1987 | |
| 1988 | #if TARGET_API_MAC_CARBON |
| 1989 | {"GetWindowPropertyAttributes", (PyCFunction)WinObj_GetWindowPropertyAttributes, 1, |
| 1990 | "(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)"}, |
| 1991 | #endif |
| 1992 | |
| 1993 | #if TARGET_API_MAC_CARBON |
| 1994 | {"ChangeWindowPropertyAttributes", (PyCFunction)WinObj_ChangeWindowPropertyAttributes, 1, |
| 1995 | "(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None"}, |
| 1996 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1997 | {"TrackBox", (PyCFunction)WinObj_TrackBox, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 1998 | "(Point thePt, WindowPartCode partCode) -> (Boolean _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 1999 | {"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1, |
| 2000 | "(Point thePt) -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2001 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2002 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 8f0fab7 | 1997-08-15 14:38:05 +0000 | [diff] [blame] | 2003 | {"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1, |
| 2004 | "() -> (Boolean _rv, AuxWinHandle awHndl)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2005 | #endif |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2006 | {"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1, |
| 2007 | "() -> (Boolean _rv)"}, |
| 2008 | {"GetWindowSpareFlag", (PyCFunction)WinObj_GetWindowSpareFlag, 1, |
| 2009 | "() -> (Boolean _rv)"}, |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2010 | {"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1, |
| 2011 | "() -> (CGrafPtr _rv)"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2012 | {"GetWindowKind", (PyCFunction)WinObj_GetWindowKind, 1, |
| 2013 | "() -> (short _rv)"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2014 | {"MacIsWindowVisible", (PyCFunction)WinObj_MacIsWindowVisible, 1, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2015 | "() -> (Boolean _rv)"}, |
| 2016 | {"IsWindowHilited", (PyCFunction)WinObj_IsWindowHilited, 1, |
| 2017 | "() -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2018 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2019 | #if TARGET_API_MAC_CARBON |
| 2020 | {"IsWindowUpdatePending", (PyCFunction)WinObj_IsWindowUpdatePending, 1, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2021 | "() -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2022 | #endif |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2023 | {"MacGetNextWindow", (PyCFunction)WinObj_MacGetNextWindow, 1, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2024 | "() -> (WindowPtr _rv)"}, |
| 2025 | {"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2026 | "() -> (Rect rect)"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2027 | {"GetWindowUserState", (PyCFunction)WinObj_GetWindowUserState, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2028 | "() -> (Rect rect)"}, |
| 2029 | {"SetWindowKind", (PyCFunction)WinObj_SetWindowKind, 1, |
| 2030 | "(short kind) -> None"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2031 | {"SetWindowStandardState", (PyCFunction)WinObj_SetWindowStandardState, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2032 | "(Rect rect) -> None"}, |
Jack Jansen | 330f576 | 1995-11-14 10:48:54 +0000 | [diff] [blame] | 2033 | {"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2034 | "(Rect rect) -> None"}, |
| 2035 | {"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1, |
| 2036 | "() -> None"}, |
| 2037 | {"GetWindowPortBounds", (PyCFunction)WinObj_GetWindowPortBounds, 1, |
| 2038 | "() -> (Rect bounds)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2039 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2040 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2041 | {"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1, |
| 2042 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2043 | #endif |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2044 | {"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1, |
| 2045 | "(short hGlobal, short vGlobal, Boolean front) -> None"}, |
| 2046 | {"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1, |
| 2047 | "() -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2048 | {NULL, NULL, 0} |
| 2049 | }; |
| 2050 | |
| 2051 | PyMethodChain WinObj_chain = { WinObj_methods, NULL }; |
| 2052 | |
| 2053 | static PyObject *WinObj_getattr(self, name) |
| 2054 | WindowObject *self; |
| 2055 | char *name; |
| 2056 | { |
| 2057 | return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name); |
| 2058 | } |
| 2059 | |
| 2060 | #define WinObj_setattr NULL |
| 2061 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2062 | #define WinObj_compare NULL |
| 2063 | |
| 2064 | #define WinObj_repr NULL |
| 2065 | |
| 2066 | #define WinObj_hash NULL |
| 2067 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2068 | PyTypeObject Window_Type = { |
| 2069 | PyObject_HEAD_INIT(&PyType_Type) |
| 2070 | 0, /*ob_size*/ |
| 2071 | "Window", /*tp_name*/ |
| 2072 | sizeof(WindowObject), /*tp_basicsize*/ |
| 2073 | 0, /*tp_itemsize*/ |
| 2074 | /* methods */ |
| 2075 | (destructor) WinObj_dealloc, /*tp_dealloc*/ |
| 2076 | 0, /*tp_print*/ |
| 2077 | (getattrfunc) WinObj_getattr, /*tp_getattr*/ |
| 2078 | (setattrfunc) WinObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2079 | (cmpfunc) WinObj_compare, /*tp_compare*/ |
| 2080 | (reprfunc) WinObj_repr, /*tp_repr*/ |
| 2081 | (PyNumberMethods *)0, /* tp_as_number */ |
| 2082 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 2083 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 2084 | (hashfunc) WinObj_hash, /*tp_hash*/ |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2085 | }; |
| 2086 | |
| 2087 | /* --------------------- End object type Window --------------------- */ |
| 2088 | |
| 2089 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2090 | static PyObject *Win_GetNewCWindow(_self, _args) |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2091 | PyObject *_self; |
| 2092 | PyObject *_args; |
| 2093 | { |
| 2094 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2095 | WindowPtr _rv; |
| 2096 | short windowID; |
| 2097 | WindowPtr behind; |
| 2098 | if (!PyArg_ParseTuple(_args, "hO&", |
| 2099 | &windowID, |
| 2100 | WinObj_Convert, &behind)) |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2101 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2102 | _rv = GetNewCWindow(windowID, |
| 2103 | (void *)0, |
| 2104 | behind); |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2105 | _res = Py_BuildValue("O&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2106 | WinObj_New, _rv); |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2107 | return _res; |
| 2108 | } |
| 2109 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2110 | static PyObject *Win_NewWindow(_self, _args) |
| 2111 | PyObject *_self; |
| 2112 | PyObject *_args; |
| 2113 | { |
| 2114 | PyObject *_res = NULL; |
| 2115 | WindowPtr _rv; |
| 2116 | Rect boundsRect; |
| 2117 | Str255 title; |
| 2118 | Boolean visible; |
| 2119 | short theProc; |
| 2120 | WindowPtr behind; |
| 2121 | Boolean goAwayFlag; |
| 2122 | long refCon; |
| 2123 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 2124 | PyMac_GetRect, &boundsRect, |
| 2125 | PyMac_GetStr255, title, |
| 2126 | &visible, |
| 2127 | &theProc, |
| 2128 | WinObj_Convert, &behind, |
| 2129 | &goAwayFlag, |
| 2130 | &refCon)) |
| 2131 | return NULL; |
| 2132 | _rv = NewWindow((void *)0, |
| 2133 | &boundsRect, |
| 2134 | title, |
| 2135 | visible, |
| 2136 | theProc, |
| 2137 | behind, |
| 2138 | goAwayFlag, |
| 2139 | refCon); |
| 2140 | _res = Py_BuildValue("O&", |
| 2141 | WinObj_New, _rv); |
| 2142 | return _res; |
| 2143 | } |
| 2144 | |
| 2145 | static PyObject *Win_GetNewWindow(_self, _args) |
| 2146 | PyObject *_self; |
| 2147 | PyObject *_args; |
| 2148 | { |
| 2149 | PyObject *_res = NULL; |
| 2150 | WindowPtr _rv; |
| 2151 | short windowID; |
| 2152 | WindowPtr behind; |
| 2153 | if (!PyArg_ParseTuple(_args, "hO&", |
| 2154 | &windowID, |
| 2155 | WinObj_Convert, &behind)) |
| 2156 | return NULL; |
| 2157 | _rv = GetNewWindow(windowID, |
| 2158 | (void *)0, |
| 2159 | behind); |
| 2160 | _res = Py_BuildValue("O&", |
| 2161 | WinObj_New, _rv); |
| 2162 | return _res; |
| 2163 | } |
| 2164 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2165 | static PyObject *Win_NewCWindow(_self, _args) |
| 2166 | PyObject *_self; |
| 2167 | PyObject *_args; |
| 2168 | { |
| 2169 | PyObject *_res = NULL; |
| 2170 | WindowPtr _rv; |
| 2171 | Rect boundsRect; |
| 2172 | Str255 title; |
| 2173 | Boolean visible; |
| 2174 | short procID; |
| 2175 | WindowPtr behind; |
| 2176 | Boolean goAwayFlag; |
| 2177 | long refCon; |
| 2178 | if (!PyArg_ParseTuple(_args, "O&O&bhO&bl", |
| 2179 | PyMac_GetRect, &boundsRect, |
| 2180 | PyMac_GetStr255, title, |
| 2181 | &visible, |
| 2182 | &procID, |
| 2183 | WinObj_Convert, &behind, |
| 2184 | &goAwayFlag, |
| 2185 | &refCon)) |
| 2186 | return NULL; |
| 2187 | _rv = NewCWindow((void *)0, |
| 2188 | &boundsRect, |
| 2189 | title, |
| 2190 | visible, |
| 2191 | procID, |
| 2192 | behind, |
| 2193 | goAwayFlag, |
| 2194 | refCon); |
| 2195 | _res = Py_BuildValue("O&", |
| 2196 | WinObj_New, _rv); |
| 2197 | return _res; |
| 2198 | } |
| 2199 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2200 | static PyObject *Win_CreateNewWindow(_self, _args) |
| 2201 | PyObject *_self; |
| 2202 | PyObject *_args; |
| 2203 | { |
| 2204 | PyObject *_res = NULL; |
| 2205 | OSStatus _err; |
| 2206 | WindowClass windowClass; |
| 2207 | WindowAttributes attributes; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2208 | Rect contentBounds; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2209 | WindowPtr outWindow; |
| 2210 | if (!PyArg_ParseTuple(_args, "llO&", |
| 2211 | &windowClass, |
| 2212 | &attributes, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2213 | PyMac_GetRect, &contentBounds)) |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2214 | return NULL; |
| 2215 | _err = CreateNewWindow(windowClass, |
| 2216 | attributes, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2217 | &contentBounds, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2218 | &outWindow); |
| 2219 | if (_err != noErr) return PyMac_Error(_err); |
| 2220 | _res = Py_BuildValue("O&", |
| 2221 | WinObj_WhichWindow, outWindow); |
| 2222 | return _res; |
| 2223 | } |
| 2224 | |
| 2225 | static PyObject *Win_CreateWindowFromResource(_self, _args) |
| 2226 | PyObject *_self; |
| 2227 | PyObject *_args; |
| 2228 | { |
| 2229 | PyObject *_res = NULL; |
| 2230 | OSStatus _err; |
| 2231 | SInt16 resID; |
| 2232 | WindowPtr outWindow; |
| 2233 | if (!PyArg_ParseTuple(_args, "h", |
| 2234 | &resID)) |
| 2235 | return NULL; |
| 2236 | _err = CreateWindowFromResource(resID, |
| 2237 | &outWindow); |
| 2238 | if (_err != noErr) return PyMac_Error(_err); |
| 2239 | _res = Py_BuildValue("O&", |
| 2240 | WinObj_WhichWindow, outWindow); |
| 2241 | return _res; |
| 2242 | } |
| 2243 | |
| 2244 | static PyObject *Win_ShowFloatingWindows(_self, _args) |
| 2245 | PyObject *_self; |
| 2246 | PyObject *_args; |
| 2247 | { |
| 2248 | PyObject *_res = NULL; |
| 2249 | OSStatus _err; |
| 2250 | if (!PyArg_ParseTuple(_args, "")) |
| 2251 | return NULL; |
| 2252 | _err = ShowFloatingWindows(); |
| 2253 | if (_err != noErr) return PyMac_Error(_err); |
| 2254 | Py_INCREF(Py_None); |
| 2255 | _res = Py_None; |
| 2256 | return _res; |
| 2257 | } |
| 2258 | |
| 2259 | static PyObject *Win_HideFloatingWindows(_self, _args) |
| 2260 | PyObject *_self; |
| 2261 | PyObject *_args; |
| 2262 | { |
| 2263 | PyObject *_res = NULL; |
| 2264 | OSStatus _err; |
| 2265 | if (!PyArg_ParseTuple(_args, "")) |
| 2266 | return NULL; |
| 2267 | _err = HideFloatingWindows(); |
| 2268 | if (_err != noErr) return PyMac_Error(_err); |
| 2269 | Py_INCREF(Py_None); |
| 2270 | _res = Py_None; |
| 2271 | return _res; |
| 2272 | } |
| 2273 | |
| 2274 | static PyObject *Win_AreFloatingWindowsVisible(_self, _args) |
| 2275 | PyObject *_self; |
| 2276 | PyObject *_args; |
| 2277 | { |
| 2278 | PyObject *_res = NULL; |
| 2279 | Boolean _rv; |
| 2280 | if (!PyArg_ParseTuple(_args, "")) |
| 2281 | return NULL; |
| 2282 | _rv = AreFloatingWindowsVisible(); |
| 2283 | _res = Py_BuildValue("b", |
| 2284 | _rv); |
| 2285 | return _res; |
| 2286 | } |
| 2287 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2288 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2289 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2290 | static PyObject *Win_SetDeskCPat(_self, _args) |
| 2291 | PyObject *_self; |
| 2292 | PyObject *_args; |
| 2293 | { |
| 2294 | PyObject *_res = NULL; |
| 2295 | PixPatHandle deskPixPat; |
| 2296 | if (!PyArg_ParseTuple(_args, "O&", |
| 2297 | ResObj_Convert, &deskPixPat)) |
| 2298 | return NULL; |
| 2299 | SetDeskCPat(deskPixPat); |
| 2300 | Py_INCREF(Py_None); |
| 2301 | _res = Py_None; |
| 2302 | return _res; |
| 2303 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2304 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2305 | |
| 2306 | static PyObject *Win_CheckUpdate(_self, _args) |
| 2307 | PyObject *_self; |
| 2308 | PyObject *_args; |
| 2309 | { |
| 2310 | PyObject *_res = NULL; |
| 2311 | Boolean _rv; |
| 2312 | EventRecord theEvent; |
| 2313 | if (!PyArg_ParseTuple(_args, "")) |
| 2314 | return NULL; |
| 2315 | _rv = CheckUpdate(&theEvent); |
| 2316 | _res = Py_BuildValue("bO&", |
| 2317 | _rv, |
| 2318 | PyMac_BuildEventRecord, &theEvent); |
| 2319 | return _res; |
| 2320 | } |
| 2321 | |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2322 | static PyObject *Win_MacFindWindow(_self, _args) |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2323 | PyObject *_self; |
| 2324 | PyObject *_args; |
| 2325 | { |
| 2326 | PyObject *_res = NULL; |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2327 | WindowPartCode _rv; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2328 | Point thePoint; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2329 | WindowPtr window; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2330 | if (!PyArg_ParseTuple(_args, "O&", |
| 2331 | PyMac_GetPoint, &thePoint)) |
| 2332 | return NULL; |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2333 | _rv = MacFindWindow(thePoint, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2334 | &window); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2335 | _res = Py_BuildValue("hO&", |
| 2336 | _rv, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2337 | WinObj_WhichWindow, window); |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2338 | return _res; |
| 2339 | } |
| 2340 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2341 | static PyObject *Win_FrontWindow(_self, _args) |
| 2342 | PyObject *_self; |
| 2343 | PyObject *_args; |
| 2344 | { |
| 2345 | PyObject *_res = NULL; |
| 2346 | WindowPtr _rv; |
| 2347 | if (!PyArg_ParseTuple(_args, "")) |
| 2348 | return NULL; |
| 2349 | _rv = FrontWindow(); |
| 2350 | _res = Py_BuildValue("O&", |
Guido van Rossum | ea39abd | 1995-02-28 09:49:02 +0000 | [diff] [blame] | 2351 | WinObj_WhichWindow, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2352 | return _res; |
| 2353 | } |
| 2354 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2355 | static PyObject *Win_FrontNonFloatingWindow(_self, _args) |
| 2356 | PyObject *_self; |
| 2357 | PyObject *_args; |
| 2358 | { |
| 2359 | PyObject *_res = NULL; |
| 2360 | WindowPtr _rv; |
| 2361 | if (!PyArg_ParseTuple(_args, "")) |
| 2362 | return NULL; |
| 2363 | _rv = FrontNonFloatingWindow(); |
| 2364 | _res = Py_BuildValue("O&", |
| 2365 | WinObj_WhichWindow, _rv); |
| 2366 | return _res; |
| 2367 | } |
| 2368 | |
| 2369 | #if TARGET_API_MAC_CARBON |
| 2370 | |
| 2371 | static PyObject *Win_GetFrontWindowOfClass(_self, _args) |
| 2372 | PyObject *_self; |
| 2373 | PyObject *_args; |
| 2374 | { |
| 2375 | PyObject *_res = NULL; |
| 2376 | WindowPtr _rv; |
| 2377 | WindowClass inWindowClass; |
| 2378 | Boolean mustBeVisible; |
| 2379 | if (!PyArg_ParseTuple(_args, "lb", |
| 2380 | &inWindowClass, |
| 2381 | &mustBeVisible)) |
| 2382 | return NULL; |
| 2383 | _rv = GetFrontWindowOfClass(inWindowClass, |
| 2384 | mustBeVisible); |
| 2385 | _res = Py_BuildValue("O&", |
| 2386 | WinObj_New, _rv); |
| 2387 | return _res; |
| 2388 | } |
| 2389 | #endif |
| 2390 | |
| 2391 | #if TARGET_API_MAC_CARBON |
| 2392 | |
| 2393 | static PyObject *Win_FindWindowOfClass(_self, _args) |
| 2394 | PyObject *_self; |
| 2395 | PyObject *_args; |
| 2396 | { |
| 2397 | PyObject *_res = NULL; |
| 2398 | OSStatus _err; |
| 2399 | Point where; |
| 2400 | WindowClass inWindowClass; |
| 2401 | WindowPtr outWindow; |
| 2402 | WindowPartCode outWindowPart; |
| 2403 | if (!PyArg_ParseTuple(_args, "O&l", |
| 2404 | PyMac_GetPoint, &where, |
| 2405 | &inWindowClass)) |
| 2406 | return NULL; |
| 2407 | _err = FindWindowOfClass(&where, |
| 2408 | inWindowClass, |
| 2409 | &outWindow, |
| 2410 | &outWindowPart); |
| 2411 | if (_err != noErr) return PyMac_Error(_err); |
| 2412 | _res = Py_BuildValue("O&h", |
| 2413 | WinObj_WhichWindow, outWindow, |
| 2414 | outWindowPart); |
| 2415 | return _res; |
| 2416 | } |
| 2417 | #endif |
| 2418 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2419 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2420 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2421 | static PyObject *Win_InitWindows(_self, _args) |
| 2422 | PyObject *_self; |
| 2423 | PyObject *_args; |
| 2424 | { |
| 2425 | PyObject *_res = NULL; |
| 2426 | if (!PyArg_ParseTuple(_args, "")) |
| 2427 | return NULL; |
| 2428 | InitWindows(); |
| 2429 | Py_INCREF(Py_None); |
| 2430 | _res = Py_None; |
| 2431 | return _res; |
| 2432 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2433 | #endif |
| 2434 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2435 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2436 | |
| 2437 | static PyObject *Win_GetWMgrPort(_self, _args) |
| 2438 | PyObject *_self; |
| 2439 | PyObject *_args; |
| 2440 | { |
| 2441 | PyObject *_res = NULL; |
| 2442 | GrafPtr wPort; |
| 2443 | if (!PyArg_ParseTuple(_args, "")) |
| 2444 | return NULL; |
| 2445 | GetWMgrPort(&wPort); |
| 2446 | _res = Py_BuildValue("O&", |
| 2447 | GrafObj_New, wPort); |
| 2448 | return _res; |
| 2449 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2450 | #endif |
| 2451 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2452 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2453 | |
| 2454 | static PyObject *Win_GetCWMgrPort(_self, _args) |
| 2455 | PyObject *_self; |
| 2456 | PyObject *_args; |
| 2457 | { |
| 2458 | PyObject *_res = NULL; |
| 2459 | CGrafPtr wMgrCPort; |
| 2460 | if (!PyArg_ParseTuple(_args, "")) |
| 2461 | return NULL; |
| 2462 | GetCWMgrPort(&wMgrCPort); |
| 2463 | _res = Py_BuildValue("O&", |
| 2464 | GrafObj_New, wMgrCPort); |
| 2465 | return _res; |
| 2466 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2467 | #endif |
| 2468 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2469 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2470 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2471 | static PyObject *Win_InitFloatingWindows(_self, _args) |
| 2472 | PyObject *_self; |
| 2473 | PyObject *_args; |
| 2474 | { |
| 2475 | PyObject *_res = NULL; |
| 2476 | OSStatus _err; |
| 2477 | if (!PyArg_ParseTuple(_args, "")) |
| 2478 | return NULL; |
| 2479 | _err = InitFloatingWindows(); |
| 2480 | if (_err != noErr) return PyMac_Error(_err); |
| 2481 | Py_INCREF(Py_None); |
| 2482 | _res = Py_None; |
| 2483 | return _res; |
| 2484 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2485 | #endif |
| 2486 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2487 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2488 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2489 | static PyObject *Win_InvalRect(_self, _args) |
| 2490 | PyObject *_self; |
| 2491 | PyObject *_args; |
| 2492 | { |
| 2493 | PyObject *_res = NULL; |
| 2494 | Rect badRect; |
| 2495 | if (!PyArg_ParseTuple(_args, "O&", |
| 2496 | PyMac_GetRect, &badRect)) |
| 2497 | return NULL; |
| 2498 | InvalRect(&badRect); |
| 2499 | Py_INCREF(Py_None); |
| 2500 | _res = Py_None; |
| 2501 | return _res; |
| 2502 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2503 | #endif |
| 2504 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2505 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2506 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2507 | static PyObject *Win_InvalRgn(_self, _args) |
| 2508 | PyObject *_self; |
| 2509 | PyObject *_args; |
| 2510 | { |
| 2511 | PyObject *_res = NULL; |
| 2512 | RgnHandle badRgn; |
| 2513 | if (!PyArg_ParseTuple(_args, "O&", |
| 2514 | ResObj_Convert, &badRgn)) |
| 2515 | return NULL; |
| 2516 | InvalRgn(badRgn); |
| 2517 | Py_INCREF(Py_None); |
| 2518 | _res = Py_None; |
| 2519 | return _res; |
| 2520 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2521 | #endif |
| 2522 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2523 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2524 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2525 | static PyObject *Win_ValidRect(_self, _args) |
| 2526 | PyObject *_self; |
| 2527 | PyObject *_args; |
| 2528 | { |
| 2529 | PyObject *_res = NULL; |
| 2530 | Rect goodRect; |
| 2531 | if (!PyArg_ParseTuple(_args, "O&", |
| 2532 | PyMac_GetRect, &goodRect)) |
| 2533 | return NULL; |
| 2534 | ValidRect(&goodRect); |
| 2535 | Py_INCREF(Py_None); |
| 2536 | _res = Py_None; |
| 2537 | return _res; |
| 2538 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2539 | #endif |
| 2540 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2541 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2542 | |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2543 | static PyObject *Win_ValidRgn(_self, _args) |
| 2544 | PyObject *_self; |
| 2545 | PyObject *_args; |
| 2546 | { |
| 2547 | PyObject *_res = NULL; |
| 2548 | RgnHandle goodRgn; |
| 2549 | if (!PyArg_ParseTuple(_args, "O&", |
| 2550 | ResObj_Convert, &goodRgn)) |
| 2551 | return NULL; |
| 2552 | ValidRgn(goodRgn); |
| 2553 | Py_INCREF(Py_None); |
| 2554 | _res = Py_None; |
| 2555 | return _res; |
| 2556 | } |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2557 | #endif |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2558 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2559 | static PyObject *Win_CollapseAllWindows(_self, _args) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2560 | PyObject *_self; |
| 2561 | PyObject *_args; |
| 2562 | { |
| 2563 | PyObject *_res = NULL; |
Jack Jansen | e4349e8 | 1999-03-04 22:53:24 +0000 | [diff] [blame] | 2564 | OSStatus _err; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2565 | Boolean collapse; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2566 | if (!PyArg_ParseTuple(_args, "b", |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2567 | &collapse)) |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2568 | return NULL; |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2569 | _err = CollapseAllWindows(collapse); |
Jack Jansen | e4349e8 | 1999-03-04 22:53:24 +0000 | [diff] [blame] | 2570 | if (_err != noErr) return PyMac_Error(_err); |
| 2571 | Py_INCREF(Py_None); |
| 2572 | _res = Py_None; |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2573 | return _res; |
| 2574 | } |
| 2575 | |
| 2576 | static PyObject *Win_PinRect(_self, _args) |
| 2577 | PyObject *_self; |
| 2578 | PyObject *_args; |
| 2579 | { |
| 2580 | PyObject *_res = NULL; |
| 2581 | long _rv; |
| 2582 | Rect theRect; |
| 2583 | Point thePt; |
| 2584 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 2585 | PyMac_GetRect, &theRect, |
| 2586 | PyMac_GetPoint, &thePt)) |
| 2587 | return NULL; |
| 2588 | _rv = PinRect(&theRect, |
| 2589 | thePt); |
| 2590 | _res = Py_BuildValue("l", |
| 2591 | _rv); |
| 2592 | return _res; |
| 2593 | } |
| 2594 | |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2595 | static PyObject *Win_GetGrayRgn(_self, _args) |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2596 | PyObject *_self; |
| 2597 | PyObject *_args; |
| 2598 | { |
| 2599 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2600 | RgnHandle _rv; |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2601 | if (!PyArg_ParseTuple(_args, "")) |
| 2602 | return NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2603 | _rv = GetGrayRgn(); |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2604 | _res = Py_BuildValue("O&", |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2605 | ResObj_New, _rv); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2606 | return _res; |
| 2607 | } |
| 2608 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2609 | static PyObject *Win_GetWindowFromPort(_self, _args) |
| 2610 | PyObject *_self; |
| 2611 | PyObject *_args; |
| 2612 | { |
| 2613 | PyObject *_res = NULL; |
| 2614 | WindowPtr _rv; |
| 2615 | CGrafPtr port; |
| 2616 | if (!PyArg_ParseTuple(_args, "O&", |
| 2617 | GrafObj_Convert, &port)) |
| 2618 | return NULL; |
| 2619 | _rv = GetWindowFromPort(port); |
| 2620 | _res = Py_BuildValue("O&", |
| 2621 | WinObj_New, _rv); |
| 2622 | return _res; |
| 2623 | } |
| 2624 | |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 2625 | static PyObject *Win_WhichWindow(_self, _args) |
| 2626 | PyObject *_self; |
| 2627 | PyObject *_args; |
| 2628 | { |
| 2629 | PyObject *_res = NULL; |
| 2630 | |
| 2631 | long ptr; |
| 2632 | |
| 2633 | if ( !PyArg_ParseTuple(_args, "i", &ptr) ) |
| 2634 | return NULL; |
| 2635 | return WinObj_WhichWindow((WindowPtr)ptr); |
| 2636 | |
| 2637 | } |
| 2638 | |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2639 | static PyObject *Win_FindWindow(_self, _args) |
| 2640 | PyObject *_self; |
| 2641 | PyObject *_args; |
| 2642 | { |
| 2643 | PyObject *_res = NULL; |
| 2644 | short _rv; |
| 2645 | Point thePoint; |
| 2646 | WindowPtr theWindow; |
| 2647 | if (!PyArg_ParseTuple(_args, "O&", |
| 2648 | PyMac_GetPoint, &thePoint)) |
| 2649 | return NULL; |
| 2650 | _rv = FindWindow(thePoint, |
| 2651 | &theWindow); |
| 2652 | _res = Py_BuildValue("hO&", |
| 2653 | _rv, |
| 2654 | WinObj_WhichWindow, theWindow); |
| 2655 | return _res; |
| 2656 | } |
| 2657 | |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2658 | static PyMethodDef Win_methods[] = { |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2659 | {"GetNewCWindow", (PyCFunction)Win_GetNewCWindow, 1, |
| 2660 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2661 | {"NewWindow", (PyCFunction)Win_NewWindow, 1, |
| 2662 | "(Rect boundsRect, Str255 title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
| 2663 | {"GetNewWindow", (PyCFunction)Win_GetNewWindow, 1, |
| 2664 | "(short windowID, WindowPtr behind) -> (WindowPtr _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2665 | {"NewCWindow", (PyCFunction)Win_NewCWindow, 1, |
| 2666 | "(Rect boundsRect, Str255 title, Boolean visible, short procID, WindowPtr behind, Boolean goAwayFlag, long refCon) -> (WindowPtr _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2667 | {"CreateNewWindow", (PyCFunction)Win_CreateNewWindow, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2668 | "(WindowClass windowClass, WindowAttributes attributes, Rect contentBounds) -> (WindowPtr outWindow)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2669 | {"CreateWindowFromResource", (PyCFunction)Win_CreateWindowFromResource, 1, |
| 2670 | "(SInt16 resID) -> (WindowPtr outWindow)"}, |
| 2671 | {"ShowFloatingWindows", (PyCFunction)Win_ShowFloatingWindows, 1, |
| 2672 | "() -> None"}, |
| 2673 | {"HideFloatingWindows", (PyCFunction)Win_HideFloatingWindows, 1, |
| 2674 | "() -> None"}, |
| 2675 | {"AreFloatingWindowsVisible", (PyCFunction)Win_AreFloatingWindowsVisible, 1, |
| 2676 | "() -> (Boolean _rv)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2677 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2678 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2679 | {"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1, |
| 2680 | "(PixPatHandle deskPixPat) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2681 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2682 | {"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1, |
| 2683 | "() -> (Boolean _rv, EventRecord theEvent)"}, |
Jack Jansen | 1c4e614 | 1998-04-21 15:23:55 +0000 | [diff] [blame] | 2684 | {"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2685 | "(Point thePoint) -> (WindowPartCode _rv, WindowPtr window)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2686 | {"FrontWindow", (PyCFunction)Win_FrontWindow, 1, |
| 2687 | "() -> (WindowPtr _rv)"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2688 | {"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1, |
| 2689 | "() -> (WindowPtr _rv)"}, |
| 2690 | |
| 2691 | #if TARGET_API_MAC_CARBON |
| 2692 | {"GetFrontWindowOfClass", (PyCFunction)Win_GetFrontWindowOfClass, 1, |
| 2693 | "(WindowClass inWindowClass, Boolean mustBeVisible) -> (WindowPtr _rv)"}, |
| 2694 | #endif |
| 2695 | |
| 2696 | #if TARGET_API_MAC_CARBON |
| 2697 | {"FindWindowOfClass", (PyCFunction)Win_FindWindowOfClass, 1, |
| 2698 | "(Point where, WindowClass inWindowClass) -> (WindowPtr outWindow, WindowPartCode outWindowPart)"}, |
| 2699 | #endif |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2700 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2701 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2702 | {"InitWindows", (PyCFunction)Win_InitWindows, 1, |
| 2703 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2704 | #endif |
| 2705 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2706 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2707 | {"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1, |
| 2708 | "() -> (GrafPtr wPort)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2709 | #endif |
| 2710 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2711 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2712 | {"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1, |
| 2713 | "() -> (CGrafPtr wMgrCPort)"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2714 | #endif |
| 2715 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2716 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2717 | {"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1, |
| 2718 | "() -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2719 | #endif |
| 2720 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2721 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2722 | {"InvalRect", (PyCFunction)Win_InvalRect, 1, |
| 2723 | "(Rect badRect) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2724 | #endif |
| 2725 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2726 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2727 | {"InvalRgn", (PyCFunction)Win_InvalRgn, 1, |
| 2728 | "(RgnHandle badRgn) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2729 | #endif |
| 2730 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2731 | #if !TARGET_API_MAC_CARBON |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2732 | {"ValidRect", (PyCFunction)Win_ValidRect, 1, |
| 2733 | "(Rect goodRect) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2734 | #endif |
| 2735 | |
Jack Jansen | 74a1e63 | 2000-07-14 22:37:27 +0000 | [diff] [blame] | 2736 | #if !TARGET_API_MAC_CARBON |
Jack Jansen | b7abb18 | 1995-11-15 15:18:47 +0000 | [diff] [blame] | 2737 | {"ValidRgn", (PyCFunction)Win_ValidRgn, 1, |
| 2738 | "(RgnHandle goodRgn) -> None"}, |
Jack Jansen | e79dc76 | 2000-06-02 21:35:07 +0000 | [diff] [blame] | 2739 | #endif |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2740 | {"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 2741 | "(Boolean collapse) -> None"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2742 | {"PinRect", (PyCFunction)Win_PinRect, 1, |
| 2743 | "(Rect theRect, Point thePt) -> (long _rv)"}, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 2744 | {"GetGrayRgn", (PyCFunction)Win_GetGrayRgn, 1, |
| 2745 | "() -> (RgnHandle _rv)"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2746 | {"GetWindowFromPort", (PyCFunction)Win_GetWindowFromPort, 1, |
| 2747 | "(CGrafPtr port) -> (WindowPtr _rv)"}, |
Jack Jansen | d4c2646 | 1995-08-17 14:35:56 +0000 | [diff] [blame] | 2748 | {"WhichWindow", (PyCFunction)Win_WhichWindow, 1, |
| 2749 | "Resolve an integer WindowPtr address to a Window object"}, |
Jack Jansen | e180d99 | 1998-04-24 10:28:20 +0000 | [diff] [blame] | 2750 | {"FindWindow", (PyCFunction)Win_FindWindow, 1, |
| 2751 | "(Point thePoint) -> (short _rv, WindowPtr theWindow)"}, |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2752 | {NULL, NULL, 0} |
| 2753 | }; |
| 2754 | |
| 2755 | |
| 2756 | |
| 2757 | /* Return the object corresponding to the window, or NULL */ |
| 2758 | |
| 2759 | PyObject * |
| 2760 | WinObj_WhichWindow(w) |
| 2761 | WindowPtr w; |
| 2762 | { |
| 2763 | PyObject *it; |
| 2764 | |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 2765 | if (w == NULL) { |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2766 | it = Py_None; |
Jack Jansen | 0aee0e6 | 2000-08-25 22:17:51 +0000 | [diff] [blame] | 2767 | Py_INCREF(it); |
| 2768 | } else { |
| 2769 | it = (PyObject *) GetWRefCon(w); |
| 2770 | if (it == NULL || ((WindowObject *)it)->ob_itself != w) { |
| 2771 | it = WinObj_New(w); |
| 2772 | ((WindowObject *)it)->ob_freeit = NULL; |
| 2773 | } else { |
| 2774 | Py_INCREF(it); |
| 2775 | } |
| 2776 | } |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2777 | return it; |
| 2778 | } |
| 2779 | |
| 2780 | |
| 2781 | void initWin() |
| 2782 | { |
| 2783 | PyObject *m; |
| 2784 | PyObject *d; |
| 2785 | |
| 2786 | |
| 2787 | |
| 2788 | |
| 2789 | m = Py_InitModule("Win", Win_methods); |
| 2790 | d = PyModule_GetDict(m); |
| 2791 | Win_Error = PyMac_GetOSErrException(); |
| 2792 | if (Win_Error == NULL || |
| 2793 | PyDict_SetItemString(d, "Error", Win_Error) != 0) |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame] | 2794 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 2795 | Window_Type.ob_type = &PyType_Type; |
| 2796 | Py_INCREF(&Window_Type); |
| 2797 | if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0) |
| 2798 | Py_FatalError("can't initialize WindowType"); |
Guido van Rossum | 17448e2 | 1995-01-30 11:53:55 +0000 | [diff] [blame] | 2799 | } |
| 2800 | |
| 2801 | /* ========================= End module Win ========================= */ |
| 2802 | |