/Mac/Modules/win/_Winmodule.c

http://unladen-swallow.googlecode.com/ · C · 3265 lines · 3056 code · 198 blank · 11 comment · 327 complexity · c6fb76daca4c71dd4064a7870f571f18 MD5 · raw file

Large files are truncated click here to view the full file

  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,