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