PageRenderTime 80ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/Mac/Modules/win/_Winmodule.c

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