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

/Mac/Modules/ctl/_Ctlmodule.c

http://unladen-swallow.googlecode.com/
C | 5815 lines | 5442 code | 345 blank | 28 comment | 653 complexity | c92a74b5bb99169d9775d91ee2505c09 MD5 | raw file
Possible License(s): 0BSD, BSD-3-Clause
  1. /* ========================== Module _Ctl =========================== */
  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 *_CtlObj_New(ControlHandle);
  14. extern int _CtlObj_Convert(PyObject *, ControlHandle *);
  15. #define CtlObj_New _CtlObj_New
  16. #define CtlObj_Convert _CtlObj_Convert
  17. #endif
  18. static PyObject *CtlObj_WhichControl(ControlHandle);
  19. #define as_Control(h) ((ControlHandle)h)
  20. #define as_Resource(ctl) ((Handle)ctl)
  21. #define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp)
  22. #define MAXTABS 32 /* maximum number of tabs that we support in a tabs control */
  23. /*
  24. ** Parse/generate ControlFontStyleRec records
  25. */
  26. #if 0 /* Not needed */
  27. static PyObject *
  28. ControlFontStyle_New(ControlFontStyleRec *itself)
  29. {
  30. return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
  31. itself->size, itself->style, itself->mode, itself->just,
  32. QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
  33. }
  34. #endif
  35. static int
  36. ControlFontStyle_Convert(PyObject *v, ControlFontStyleRec *itself)
  37. {
  38. return PyArg_Parse(v, "(hhhhhhO&O&)", &itself->flags,
  39. &itself->font, &itself->size, &itself->style, &itself->mode,
  40. &itself->just, QdRGB_Convert, &itself->foreColor,
  41. QdRGB_Convert, &itself->backColor);
  42. }
  43. /*
  44. ** Parse/generate ControlID records
  45. */
  46. static PyObject *
  47. PyControlID_New(ControlID *itself)
  48. {
  49. return Py_BuildValue("O&l", PyMac_BuildOSType, itself->signature, itself->id);
  50. }
  51. static int
  52. PyControlID_Convert(PyObject *v, ControlID *itself)
  53. {
  54. return PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &itself->signature, &itself->id);
  55. }
  56. /*
  57. ** generate DataBrowserListViewColumnDesc records
  58. */
  59. static int
  60. DataBrowserTableViewColumnDesc_Convert(PyObject *v, DataBrowserTableViewColumnDesc *itself)
  61. {
  62. return PyArg_Parse(v, "(lO&l)",
  63. &itself->propertyID,
  64. PyMac_GetOSType, &itself->propertyType,
  65. &itself->propertyFlags);
  66. }
  67. static int
  68. ControlButtonContentInfo_Convert(PyObject *v, ControlButtonContentInfo *itself)
  69. {
  70. return PyArg_Parse(v, "(hO&)",
  71. &itself->contentType,
  72. OptResObj_Convert, &itself->u.iconSuite);
  73. }
  74. static int
  75. DataBrowserListViewHeaderDesc_Convert(PyObject *v, DataBrowserListViewHeaderDesc *itself)
  76. {
  77. itself->version = kDataBrowserListViewLatestHeaderDesc;
  78. return PyArg_Parse(v, "(HHhO&HO&O&)",
  79. &itself->minimumWidth,
  80. &itself->maximumWidth,
  81. &itself->titleOffset,
  82. CFStringRefObj_Convert, &itself->titleString,
  83. &itself->initialOrder,
  84. ControlFontStyle_Convert, &itself->btnFontStyle,
  85. ControlButtonContentInfo_Convert, &itself->btnContentInfo);
  86. }
  87. static int
  88. DataBrowserListViewColumnDesc_Convert(PyObject *v, DataBrowserListViewColumnDesc *itself)
  89. {
  90. return PyArg_Parse(v, "(O&O&)",
  91. DataBrowserTableViewColumnDesc_Convert, &itself->propertyDesc,
  92. DataBrowserListViewHeaderDesc_Convert, &itself->headerBtnDesc);
  93. }
  94. /* TrackControl and HandleControlClick callback support */
  95. #define kMyControlActionProcTag 'ACTN' /* not an official tag, only for internal use */
  96. static PyObject *tracker;
  97. static ControlActionUPP mytracker_upp;
  98. static ControlActionUPP myactionproc_upp;
  99. static ControlUserPaneKeyDownUPP mykeydownproc_upp;
  100. static ControlUserPaneFocusUPP myfocusproc_upp;
  101. static ControlUserPaneDrawUPP mydrawproc_upp;
  102. static ControlUserPaneIdleUPP myidleproc_upp;
  103. static ControlUserPaneHitTestUPP myhittestproc_upp;
  104. static ControlUserPaneTrackingUPP mytrackingproc_upp;
  105. static int settrackfunc(PyObject *); /* forward */
  106. static void clrtrackfunc(void); /* forward */
  107. static int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *);
  108. static PyObject *Ctl_Error;
  109. /* ---------------------- Object type Control ----------------------- */
  110. PyTypeObject Control_Type;
  111. #define CtlObj_Check(x) ((x)->ob_type == &Control_Type || PyObject_TypeCheck((x), &Control_Type))
  112. typedef struct ControlObject {
  113. PyObject_HEAD
  114. ControlHandle ob_itself;
  115. PyObject *ob_callbackdict;
  116. } ControlObject;
  117. PyObject *CtlObj_New(ControlHandle itself)
  118. {
  119. ControlObject *it;
  120. if (itself == NULL) return PyMac_Error(resNotFound);
  121. it = PyObject_NEW(ControlObject, &Control_Type);
  122. if (it == NULL) return NULL;
  123. it->ob_itself = itself;
  124. SetControlReference(itself, (long)it);
  125. it->ob_callbackdict = NULL;
  126. return (PyObject *)it;
  127. }
  128. int CtlObj_Convert(PyObject *v, ControlHandle *p_itself)
  129. {
  130. if (!CtlObj_Check(v))
  131. {
  132. PyErr_SetString(PyExc_TypeError, "Control required");
  133. return 0;
  134. }
  135. *p_itself = ((ControlObject *)v)->ob_itself;
  136. return 1;
  137. }
  138. static void CtlObj_dealloc(ControlObject *self)
  139. {
  140. Py_XDECREF(self->ob_callbackdict);
  141. if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */
  142. self->ob_type->tp_free((PyObject *)self);
  143. }
  144. static PyObject *CtlObj_HiliteControl(ControlObject *_self, PyObject *_args)
  145. {
  146. PyObject *_res = NULL;
  147. ControlPartCode hiliteState;
  148. #ifndef HiliteControl
  149. PyMac_PRECHECK(HiliteControl);
  150. #endif
  151. if (!PyArg_ParseTuple(_args, "h",
  152. &hiliteState))
  153. return NULL;
  154. HiliteControl(_self->ob_itself,
  155. hiliteState);
  156. Py_INCREF(Py_None);
  157. _res = Py_None;
  158. return _res;
  159. }
  160. static PyObject *CtlObj_ShowControl(ControlObject *_self, PyObject *_args)
  161. {
  162. PyObject *_res = NULL;
  163. #ifndef ShowControl
  164. PyMac_PRECHECK(ShowControl);
  165. #endif
  166. if (!PyArg_ParseTuple(_args, ""))
  167. return NULL;
  168. ShowControl(_self->ob_itself);
  169. Py_INCREF(Py_None);
  170. _res = Py_None;
  171. return _res;
  172. }
  173. static PyObject *CtlObj_HideControl(ControlObject *_self, PyObject *_args)
  174. {
  175. PyObject *_res = NULL;
  176. #ifndef HideControl
  177. PyMac_PRECHECK(HideControl);
  178. #endif
  179. if (!PyArg_ParseTuple(_args, ""))
  180. return NULL;
  181. HideControl(_self->ob_itself);
  182. Py_INCREF(Py_None);
  183. _res = Py_None;
  184. return _res;
  185. }
  186. static PyObject *CtlObj_IsControlActive(ControlObject *_self, PyObject *_args)
  187. {
  188. PyObject *_res = NULL;
  189. Boolean _rv;
  190. #ifndef IsControlActive
  191. PyMac_PRECHECK(IsControlActive);
  192. #endif
  193. if (!PyArg_ParseTuple(_args, ""))
  194. return NULL;
  195. _rv = IsControlActive(_self->ob_itself);
  196. _res = Py_BuildValue("b",
  197. _rv);
  198. return _res;
  199. }
  200. static PyObject *CtlObj_IsControlVisible(ControlObject *_self, PyObject *_args)
  201. {
  202. PyObject *_res = NULL;
  203. Boolean _rv;
  204. #ifndef IsControlVisible
  205. PyMac_PRECHECK(IsControlVisible);
  206. #endif
  207. if (!PyArg_ParseTuple(_args, ""))
  208. return NULL;
  209. _rv = IsControlVisible(_self->ob_itself);
  210. _res = Py_BuildValue("b",
  211. _rv);
  212. return _res;
  213. }
  214. static PyObject *CtlObj_ActivateControl(ControlObject *_self, PyObject *_args)
  215. {
  216. PyObject *_res = NULL;
  217. OSErr _err;
  218. #ifndef ActivateControl
  219. PyMac_PRECHECK(ActivateControl);
  220. #endif
  221. if (!PyArg_ParseTuple(_args, ""))
  222. return NULL;
  223. _err = ActivateControl(_self->ob_itself);
  224. if (_err != noErr) return PyMac_Error(_err);
  225. Py_INCREF(Py_None);
  226. _res = Py_None;
  227. return _res;
  228. }
  229. static PyObject *CtlObj_DeactivateControl(ControlObject *_self, PyObject *_args)
  230. {
  231. PyObject *_res = NULL;
  232. OSErr _err;
  233. #ifndef DeactivateControl
  234. PyMac_PRECHECK(DeactivateControl);
  235. #endif
  236. if (!PyArg_ParseTuple(_args, ""))
  237. return NULL;
  238. _err = DeactivateControl(_self->ob_itself);
  239. if (_err != noErr) return PyMac_Error(_err);
  240. Py_INCREF(Py_None);
  241. _res = Py_None;
  242. return _res;
  243. }
  244. static PyObject *CtlObj_SetControlVisibility(ControlObject *_self, PyObject *_args)
  245. {
  246. PyObject *_res = NULL;
  247. OSErr _err;
  248. Boolean inIsVisible;
  249. Boolean inDoDraw;
  250. #ifndef SetControlVisibility
  251. PyMac_PRECHECK(SetControlVisibility);
  252. #endif
  253. if (!PyArg_ParseTuple(_args, "bb",
  254. &inIsVisible,
  255. &inDoDraw))
  256. return NULL;
  257. _err = SetControlVisibility(_self->ob_itself,
  258. inIsVisible,
  259. inDoDraw);
  260. if (_err != noErr) return PyMac_Error(_err);
  261. Py_INCREF(Py_None);
  262. _res = Py_None;
  263. return _res;
  264. }
  265. static PyObject *CtlObj_IsControlEnabled(ControlObject *_self, PyObject *_args)
  266. {
  267. PyObject *_res = NULL;
  268. Boolean _rv;
  269. #ifndef IsControlEnabled
  270. PyMac_PRECHECK(IsControlEnabled);
  271. #endif
  272. if (!PyArg_ParseTuple(_args, ""))
  273. return NULL;
  274. _rv = IsControlEnabled(_self->ob_itself);
  275. _res = Py_BuildValue("b",
  276. _rv);
  277. return _res;
  278. }
  279. static PyObject *CtlObj_EnableControl(ControlObject *_self, PyObject *_args)
  280. {
  281. PyObject *_res = NULL;
  282. OSStatus _err;
  283. #ifndef EnableControl
  284. PyMac_PRECHECK(EnableControl);
  285. #endif
  286. if (!PyArg_ParseTuple(_args, ""))
  287. return NULL;
  288. _err = EnableControl(_self->ob_itself);
  289. if (_err != noErr) return PyMac_Error(_err);
  290. Py_INCREF(Py_None);
  291. _res = Py_None;
  292. return _res;
  293. }
  294. static PyObject *CtlObj_DisableControl(ControlObject *_self, PyObject *_args)
  295. {
  296. PyObject *_res = NULL;
  297. OSStatus _err;
  298. #ifndef DisableControl
  299. PyMac_PRECHECK(DisableControl);
  300. #endif
  301. if (!PyArg_ParseTuple(_args, ""))
  302. return NULL;
  303. _err = DisableControl(_self->ob_itself);
  304. if (_err != noErr) return PyMac_Error(_err);
  305. Py_INCREF(Py_None);
  306. _res = Py_None;
  307. return _res;
  308. }
  309. static PyObject *CtlObj_Draw1Control(ControlObject *_self, PyObject *_args)
  310. {
  311. PyObject *_res = NULL;
  312. #ifndef Draw1Control
  313. PyMac_PRECHECK(Draw1Control);
  314. #endif
  315. if (!PyArg_ParseTuple(_args, ""))
  316. return NULL;
  317. Draw1Control(_self->ob_itself);
  318. Py_INCREF(Py_None);
  319. _res = Py_None;
  320. return _res;
  321. }
  322. static PyObject *CtlObj_GetBestControlRect(ControlObject *_self, PyObject *_args)
  323. {
  324. PyObject *_res = NULL;
  325. OSErr _err;
  326. Rect outRect;
  327. SInt16 outBaseLineOffset;
  328. #ifndef GetBestControlRect
  329. PyMac_PRECHECK(GetBestControlRect);
  330. #endif
  331. if (!PyArg_ParseTuple(_args, ""))
  332. return NULL;
  333. _err = GetBestControlRect(_self->ob_itself,
  334. &outRect,
  335. &outBaseLineOffset);
  336. if (_err != noErr) return PyMac_Error(_err);
  337. _res = Py_BuildValue("O&h",
  338. PyMac_BuildRect, &outRect,
  339. outBaseLineOffset);
  340. return _res;
  341. }
  342. static PyObject *CtlObj_SetControlFontStyle(ControlObject *_self, PyObject *_args)
  343. {
  344. PyObject *_res = NULL;
  345. OSErr _err;
  346. ControlFontStyleRec inStyle;
  347. #ifndef SetControlFontStyle
  348. PyMac_PRECHECK(SetControlFontStyle);
  349. #endif
  350. if (!PyArg_ParseTuple(_args, "O&",
  351. ControlFontStyle_Convert, &inStyle))
  352. return NULL;
  353. _err = SetControlFontStyle(_self->ob_itself,
  354. &inStyle);
  355. if (_err != noErr) return PyMac_Error(_err);
  356. Py_INCREF(Py_None);
  357. _res = Py_None;
  358. return _res;
  359. }
  360. static PyObject *CtlObj_DrawControlInCurrentPort(ControlObject *_self, PyObject *_args)
  361. {
  362. PyObject *_res = NULL;
  363. #ifndef DrawControlInCurrentPort
  364. PyMac_PRECHECK(DrawControlInCurrentPort);
  365. #endif
  366. if (!PyArg_ParseTuple(_args, ""))
  367. return NULL;
  368. DrawControlInCurrentPort(_self->ob_itself);
  369. Py_INCREF(Py_None);
  370. _res = Py_None;
  371. return _res;
  372. }
  373. static PyObject *CtlObj_SetUpControlBackground(ControlObject *_self, PyObject *_args)
  374. {
  375. PyObject *_res = NULL;
  376. OSErr _err;
  377. SInt16 inDepth;
  378. Boolean inIsColorDevice;
  379. #ifndef SetUpControlBackground
  380. PyMac_PRECHECK(SetUpControlBackground);
  381. #endif
  382. if (!PyArg_ParseTuple(_args, "hb",
  383. &inDepth,
  384. &inIsColorDevice))
  385. return NULL;
  386. _err = SetUpControlBackground(_self->ob_itself,
  387. inDepth,
  388. inIsColorDevice);
  389. if (_err != noErr) return PyMac_Error(_err);
  390. Py_INCREF(Py_None);
  391. _res = Py_None;
  392. return _res;
  393. }
  394. static PyObject *CtlObj_SetUpControlTextColor(ControlObject *_self, PyObject *_args)
  395. {
  396. PyObject *_res = NULL;
  397. OSErr _err;
  398. SInt16 inDepth;
  399. Boolean inIsColorDevice;
  400. #ifndef SetUpControlTextColor
  401. PyMac_PRECHECK(SetUpControlTextColor);
  402. #endif
  403. if (!PyArg_ParseTuple(_args, "hb",
  404. &inDepth,
  405. &inIsColorDevice))
  406. return NULL;
  407. _err = SetUpControlTextColor(_self->ob_itself,
  408. inDepth,
  409. inIsColorDevice);
  410. if (_err != noErr) return PyMac_Error(_err);
  411. Py_INCREF(Py_None);
  412. _res = Py_None;
  413. return _res;
  414. }
  415. static PyObject *CtlObj_DragControl(ControlObject *_self, PyObject *_args)
  416. {
  417. PyObject *_res = NULL;
  418. Point startPoint;
  419. Rect limitRect;
  420. Rect slopRect;
  421. DragConstraint axis;
  422. #ifndef DragControl
  423. PyMac_PRECHECK(DragControl);
  424. #endif
  425. if (!PyArg_ParseTuple(_args, "O&O&O&H",
  426. PyMac_GetPoint, &startPoint,
  427. PyMac_GetRect, &limitRect,
  428. PyMac_GetRect, &slopRect,
  429. &axis))
  430. return NULL;
  431. DragControl(_self->ob_itself,
  432. startPoint,
  433. &limitRect,
  434. &slopRect,
  435. axis);
  436. Py_INCREF(Py_None);
  437. _res = Py_None;
  438. return _res;
  439. }
  440. static PyObject *CtlObj_TestControl(ControlObject *_self, PyObject *_args)
  441. {
  442. PyObject *_res = NULL;
  443. ControlPartCode _rv;
  444. Point testPoint;
  445. #ifndef TestControl
  446. PyMac_PRECHECK(TestControl);
  447. #endif
  448. if (!PyArg_ParseTuple(_args, "O&",
  449. PyMac_GetPoint, &testPoint))
  450. return NULL;
  451. _rv = TestControl(_self->ob_itself,
  452. testPoint);
  453. _res = Py_BuildValue("h",
  454. _rv);
  455. return _res;
  456. }
  457. static PyObject *CtlObj_HandleControlContextualMenuClick(ControlObject *_self, PyObject *_args)
  458. {
  459. PyObject *_res = NULL;
  460. OSStatus _err;
  461. Point inWhere;
  462. Boolean menuDisplayed;
  463. #ifndef HandleControlContextualMenuClick
  464. PyMac_PRECHECK(HandleControlContextualMenuClick);
  465. #endif
  466. if (!PyArg_ParseTuple(_args, "O&",
  467. PyMac_GetPoint, &inWhere))
  468. return NULL;
  469. _err = HandleControlContextualMenuClick(_self->ob_itself,
  470. inWhere,
  471. &menuDisplayed);
  472. if (_err != noErr) return PyMac_Error(_err);
  473. _res = Py_BuildValue("b",
  474. menuDisplayed);
  475. return _res;
  476. }
  477. static PyObject *CtlObj_GetControlClickActivation(ControlObject *_self, PyObject *_args)
  478. {
  479. PyObject *_res = NULL;
  480. OSStatus _err;
  481. Point inWhere;
  482. EventModifiers inModifiers;
  483. ClickActivationResult outResult;
  484. #ifndef GetControlClickActivation
  485. PyMac_PRECHECK(GetControlClickActivation);
  486. #endif
  487. if (!PyArg_ParseTuple(_args, "O&H",
  488. PyMac_GetPoint, &inWhere,
  489. &inModifiers))
  490. return NULL;
  491. _err = GetControlClickActivation(_self->ob_itself,
  492. inWhere,
  493. inModifiers,
  494. &outResult);
  495. if (_err != noErr) return PyMac_Error(_err);
  496. _res = Py_BuildValue("l",
  497. outResult);
  498. return _res;
  499. }
  500. static PyObject *CtlObj_HandleControlKey(ControlObject *_self, PyObject *_args)
  501. {
  502. PyObject *_res = NULL;
  503. ControlPartCode _rv;
  504. SInt16 inKeyCode;
  505. SInt16 inCharCode;
  506. EventModifiers inModifiers;
  507. #ifndef HandleControlKey
  508. PyMac_PRECHECK(HandleControlKey);
  509. #endif
  510. if (!PyArg_ParseTuple(_args, "hhH",
  511. &inKeyCode,
  512. &inCharCode,
  513. &inModifiers))
  514. return NULL;
  515. _rv = HandleControlKey(_self->ob_itself,
  516. inKeyCode,
  517. inCharCode,
  518. inModifiers);
  519. _res = Py_BuildValue("h",
  520. _rv);
  521. return _res;
  522. }
  523. static PyObject *CtlObj_HandleControlSetCursor(ControlObject *_self, PyObject *_args)
  524. {
  525. PyObject *_res = NULL;
  526. OSStatus _err;
  527. Point localPoint;
  528. EventModifiers modifiers;
  529. Boolean cursorWasSet;
  530. #ifndef HandleControlSetCursor
  531. PyMac_PRECHECK(HandleControlSetCursor);
  532. #endif
  533. if (!PyArg_ParseTuple(_args, "O&H",
  534. PyMac_GetPoint, &localPoint,
  535. &modifiers))
  536. return NULL;
  537. _err = HandleControlSetCursor(_self->ob_itself,
  538. localPoint,
  539. modifiers,
  540. &cursorWasSet);
  541. if (_err != noErr) return PyMac_Error(_err);
  542. _res = Py_BuildValue("b",
  543. cursorWasSet);
  544. return _res;
  545. }
  546. static PyObject *CtlObj_MoveControl(ControlObject *_self, PyObject *_args)
  547. {
  548. PyObject *_res = NULL;
  549. SInt16 h;
  550. SInt16 v;
  551. #ifndef MoveControl
  552. PyMac_PRECHECK(MoveControl);
  553. #endif
  554. if (!PyArg_ParseTuple(_args, "hh",
  555. &h,
  556. &v))
  557. return NULL;
  558. MoveControl(_self->ob_itself,
  559. h,
  560. v);
  561. Py_INCREF(Py_None);
  562. _res = Py_None;
  563. return _res;
  564. }
  565. static PyObject *CtlObj_SizeControl(ControlObject *_self, PyObject *_args)
  566. {
  567. PyObject *_res = NULL;
  568. SInt16 w;
  569. SInt16 h;
  570. #ifndef SizeControl
  571. PyMac_PRECHECK(SizeControl);
  572. #endif
  573. if (!PyArg_ParseTuple(_args, "hh",
  574. &w,
  575. &h))
  576. return NULL;
  577. SizeControl(_self->ob_itself,
  578. w,
  579. h);
  580. Py_INCREF(Py_None);
  581. _res = Py_None;
  582. return _res;
  583. }
  584. static PyObject *CtlObj_SetControlTitle(ControlObject *_self, PyObject *_args)
  585. {
  586. PyObject *_res = NULL;
  587. Str255 title;
  588. #ifndef SetControlTitle
  589. PyMac_PRECHECK(SetControlTitle);
  590. #endif
  591. if (!PyArg_ParseTuple(_args, "O&",
  592. PyMac_GetStr255, title))
  593. return NULL;
  594. SetControlTitle(_self->ob_itself,
  595. title);
  596. Py_INCREF(Py_None);
  597. _res = Py_None;
  598. return _res;
  599. }
  600. static PyObject *CtlObj_GetControlTitle(ControlObject *_self, PyObject *_args)
  601. {
  602. PyObject *_res = NULL;
  603. Str255 title;
  604. #ifndef GetControlTitle
  605. PyMac_PRECHECK(GetControlTitle);
  606. #endif
  607. if (!PyArg_ParseTuple(_args, ""))
  608. return NULL;
  609. GetControlTitle(_self->ob_itself,
  610. title);
  611. _res = Py_BuildValue("O&",
  612. PyMac_BuildStr255, title);
  613. return _res;
  614. }
  615. static PyObject *CtlObj_SetControlTitleWithCFString(ControlObject *_self, PyObject *_args)
  616. {
  617. PyObject *_res = NULL;
  618. OSStatus _err;
  619. CFStringRef inString;
  620. #ifndef SetControlTitleWithCFString
  621. PyMac_PRECHECK(SetControlTitleWithCFString);
  622. #endif
  623. if (!PyArg_ParseTuple(_args, "O&",
  624. CFStringRefObj_Convert, &inString))
  625. return NULL;
  626. _err = SetControlTitleWithCFString(_self->ob_itself,
  627. inString);
  628. if (_err != noErr) return PyMac_Error(_err);
  629. Py_INCREF(Py_None);
  630. _res = Py_None;
  631. return _res;
  632. }
  633. static PyObject *CtlObj_CopyControlTitleAsCFString(ControlObject *_self, PyObject *_args)
  634. {
  635. PyObject *_res = NULL;
  636. OSStatus _err;
  637. CFStringRef outString;
  638. #ifndef CopyControlTitleAsCFString
  639. PyMac_PRECHECK(CopyControlTitleAsCFString);
  640. #endif
  641. if (!PyArg_ParseTuple(_args, ""))
  642. return NULL;
  643. _err = CopyControlTitleAsCFString(_self->ob_itself,
  644. &outString);
  645. if (_err != noErr) return PyMac_Error(_err);
  646. _res = Py_BuildValue("O&",
  647. CFStringRefObj_New, outString);
  648. return _res;
  649. }
  650. static PyObject *CtlObj_GetControlValue(ControlObject *_self, PyObject *_args)
  651. {
  652. PyObject *_res = NULL;
  653. SInt16 _rv;
  654. #ifndef GetControlValue
  655. PyMac_PRECHECK(GetControlValue);
  656. #endif
  657. if (!PyArg_ParseTuple(_args, ""))
  658. return NULL;
  659. _rv = GetControlValue(_self->ob_itself);
  660. _res = Py_BuildValue("h",
  661. _rv);
  662. return _res;
  663. }
  664. static PyObject *CtlObj_SetControlValue(ControlObject *_self, PyObject *_args)
  665. {
  666. PyObject *_res = NULL;
  667. SInt16 newValue;
  668. #ifndef SetControlValue
  669. PyMac_PRECHECK(SetControlValue);
  670. #endif
  671. if (!PyArg_ParseTuple(_args, "h",
  672. &newValue))
  673. return NULL;
  674. SetControlValue(_self->ob_itself,
  675. newValue);
  676. Py_INCREF(Py_None);
  677. _res = Py_None;
  678. return _res;
  679. }
  680. static PyObject *CtlObj_GetControlMinimum(ControlObject *_self, PyObject *_args)
  681. {
  682. PyObject *_res = NULL;
  683. SInt16 _rv;
  684. #ifndef GetControlMinimum
  685. PyMac_PRECHECK(GetControlMinimum);
  686. #endif
  687. if (!PyArg_ParseTuple(_args, ""))
  688. return NULL;
  689. _rv = GetControlMinimum(_self->ob_itself);
  690. _res = Py_BuildValue("h",
  691. _rv);
  692. return _res;
  693. }
  694. static PyObject *CtlObj_SetControlMinimum(ControlObject *_self, PyObject *_args)
  695. {
  696. PyObject *_res = NULL;
  697. SInt16 newMinimum;
  698. #ifndef SetControlMinimum
  699. PyMac_PRECHECK(SetControlMinimum);
  700. #endif
  701. if (!PyArg_ParseTuple(_args, "h",
  702. &newMinimum))
  703. return NULL;
  704. SetControlMinimum(_self->ob_itself,
  705. newMinimum);
  706. Py_INCREF(Py_None);
  707. _res = Py_None;
  708. return _res;
  709. }
  710. static PyObject *CtlObj_GetControlMaximum(ControlObject *_self, PyObject *_args)
  711. {
  712. PyObject *_res = NULL;
  713. SInt16 _rv;
  714. #ifndef GetControlMaximum
  715. PyMac_PRECHECK(GetControlMaximum);
  716. #endif
  717. if (!PyArg_ParseTuple(_args, ""))
  718. return NULL;
  719. _rv = GetControlMaximum(_self->ob_itself);
  720. _res = Py_BuildValue("h",
  721. _rv);
  722. return _res;
  723. }
  724. static PyObject *CtlObj_SetControlMaximum(ControlObject *_self, PyObject *_args)
  725. {
  726. PyObject *_res = NULL;
  727. SInt16 newMaximum;
  728. #ifndef SetControlMaximum
  729. PyMac_PRECHECK(SetControlMaximum);
  730. #endif
  731. if (!PyArg_ParseTuple(_args, "h",
  732. &newMaximum))
  733. return NULL;
  734. SetControlMaximum(_self->ob_itself,
  735. newMaximum);
  736. Py_INCREF(Py_None);
  737. _res = Py_None;
  738. return _res;
  739. }
  740. static PyObject *CtlObj_GetControlViewSize(ControlObject *_self, PyObject *_args)
  741. {
  742. PyObject *_res = NULL;
  743. SInt32 _rv;
  744. #ifndef GetControlViewSize
  745. PyMac_PRECHECK(GetControlViewSize);
  746. #endif
  747. if (!PyArg_ParseTuple(_args, ""))
  748. return NULL;
  749. _rv = GetControlViewSize(_self->ob_itself);
  750. _res = Py_BuildValue("l",
  751. _rv);
  752. return _res;
  753. }
  754. static PyObject *CtlObj_SetControlViewSize(ControlObject *_self, PyObject *_args)
  755. {
  756. PyObject *_res = NULL;
  757. SInt32 newViewSize;
  758. #ifndef SetControlViewSize
  759. PyMac_PRECHECK(SetControlViewSize);
  760. #endif
  761. if (!PyArg_ParseTuple(_args, "l",
  762. &newViewSize))
  763. return NULL;
  764. SetControlViewSize(_self->ob_itself,
  765. newViewSize);
  766. Py_INCREF(Py_None);
  767. _res = Py_None;
  768. return _res;
  769. }
  770. static PyObject *CtlObj_GetControl32BitValue(ControlObject *_self, PyObject *_args)
  771. {
  772. PyObject *_res = NULL;
  773. SInt32 _rv;
  774. #ifndef GetControl32BitValue
  775. PyMac_PRECHECK(GetControl32BitValue);
  776. #endif
  777. if (!PyArg_ParseTuple(_args, ""))
  778. return NULL;
  779. _rv = GetControl32BitValue(_self->ob_itself);
  780. _res = Py_BuildValue("l",
  781. _rv);
  782. return _res;
  783. }
  784. static PyObject *CtlObj_SetControl32BitValue(ControlObject *_self, PyObject *_args)
  785. {
  786. PyObject *_res = NULL;
  787. SInt32 newValue;
  788. #ifndef SetControl32BitValue
  789. PyMac_PRECHECK(SetControl32BitValue);
  790. #endif
  791. if (!PyArg_ParseTuple(_args, "l",
  792. &newValue))
  793. return NULL;
  794. SetControl32BitValue(_self->ob_itself,
  795. newValue);
  796. Py_INCREF(Py_None);
  797. _res = Py_None;
  798. return _res;
  799. }
  800. static PyObject *CtlObj_GetControl32BitMaximum(ControlObject *_self, PyObject *_args)
  801. {
  802. PyObject *_res = NULL;
  803. SInt32 _rv;
  804. #ifndef GetControl32BitMaximum
  805. PyMac_PRECHECK(GetControl32BitMaximum);
  806. #endif
  807. if (!PyArg_ParseTuple(_args, ""))
  808. return NULL;
  809. _rv = GetControl32BitMaximum(_self->ob_itself);
  810. _res = Py_BuildValue("l",
  811. _rv);
  812. return _res;
  813. }
  814. static PyObject *CtlObj_SetControl32BitMaximum(ControlObject *_self, PyObject *_args)
  815. {
  816. PyObject *_res = NULL;
  817. SInt32 newMaximum;
  818. #ifndef SetControl32BitMaximum
  819. PyMac_PRECHECK(SetControl32BitMaximum);
  820. #endif
  821. if (!PyArg_ParseTuple(_args, "l",
  822. &newMaximum))
  823. return NULL;
  824. SetControl32BitMaximum(_self->ob_itself,
  825. newMaximum);
  826. Py_INCREF(Py_None);
  827. _res = Py_None;
  828. return _res;
  829. }
  830. static PyObject *CtlObj_GetControl32BitMinimum(ControlObject *_self, PyObject *_args)
  831. {
  832. PyObject *_res = NULL;
  833. SInt32 _rv;
  834. #ifndef GetControl32BitMinimum
  835. PyMac_PRECHECK(GetControl32BitMinimum);
  836. #endif
  837. if (!PyArg_ParseTuple(_args, ""))
  838. return NULL;
  839. _rv = GetControl32BitMinimum(_self->ob_itself);
  840. _res = Py_BuildValue("l",
  841. _rv);
  842. return _res;
  843. }
  844. static PyObject *CtlObj_SetControl32BitMinimum(ControlObject *_self, PyObject *_args)
  845. {
  846. PyObject *_res = NULL;
  847. SInt32 newMinimum;
  848. #ifndef SetControl32BitMinimum
  849. PyMac_PRECHECK(SetControl32BitMinimum);
  850. #endif
  851. if (!PyArg_ParseTuple(_args, "l",
  852. &newMinimum))
  853. return NULL;
  854. SetControl32BitMinimum(_self->ob_itself,
  855. newMinimum);
  856. Py_INCREF(Py_None);
  857. _res = Py_None;
  858. return _res;
  859. }
  860. static PyObject *CtlObj_IsValidControlHandle(ControlObject *_self, PyObject *_args)
  861. {
  862. PyObject *_res = NULL;
  863. Boolean _rv;
  864. #ifndef IsValidControlHandle
  865. PyMac_PRECHECK(IsValidControlHandle);
  866. #endif
  867. if (!PyArg_ParseTuple(_args, ""))
  868. return NULL;
  869. _rv = IsValidControlHandle(_self->ob_itself);
  870. _res = Py_BuildValue("b",
  871. _rv);
  872. return _res;
  873. }
  874. static PyObject *CtlObj_SetControlID(ControlObject *_self, PyObject *_args)
  875. {
  876. PyObject *_res = NULL;
  877. OSStatus _err;
  878. ControlID inID;
  879. #ifndef SetControlID
  880. PyMac_PRECHECK(SetControlID);
  881. #endif
  882. if (!PyArg_ParseTuple(_args, "O&",
  883. PyControlID_Convert, &inID))
  884. return NULL;
  885. _err = SetControlID(_self->ob_itself,
  886. &inID);
  887. if (_err != noErr) return PyMac_Error(_err);
  888. Py_INCREF(Py_None);
  889. _res = Py_None;
  890. return _res;
  891. }
  892. static PyObject *CtlObj_GetControlID(ControlObject *_self, PyObject *_args)
  893. {
  894. PyObject *_res = NULL;
  895. OSStatus _err;
  896. ControlID outID;
  897. #ifndef GetControlID
  898. PyMac_PRECHECK(GetControlID);
  899. #endif
  900. if (!PyArg_ParseTuple(_args, ""))
  901. return NULL;
  902. _err = GetControlID(_self->ob_itself,
  903. &outID);
  904. if (_err != noErr) return PyMac_Error(_err);
  905. _res = Py_BuildValue("O&",
  906. PyControlID_New, &outID);
  907. return _res;
  908. }
  909. static PyObject *CtlObj_SetControlCommandID(ControlObject *_self, PyObject *_args)
  910. {
  911. PyObject *_res = NULL;
  912. OSStatus _err;
  913. UInt32 inCommandID;
  914. #ifndef SetControlCommandID
  915. PyMac_PRECHECK(SetControlCommandID);
  916. #endif
  917. if (!PyArg_ParseTuple(_args, "l",
  918. &inCommandID))
  919. return NULL;
  920. _err = SetControlCommandID(_self->ob_itself,
  921. inCommandID);
  922. if (_err != noErr) return PyMac_Error(_err);
  923. Py_INCREF(Py_None);
  924. _res = Py_None;
  925. return _res;
  926. }
  927. static PyObject *CtlObj_GetControlCommandID(ControlObject *_self, PyObject *_args)
  928. {
  929. PyObject *_res = NULL;
  930. OSStatus _err;
  931. UInt32 outCommandID;
  932. #ifndef GetControlCommandID
  933. PyMac_PRECHECK(GetControlCommandID);
  934. #endif
  935. if (!PyArg_ParseTuple(_args, ""))
  936. return NULL;
  937. _err = GetControlCommandID(_self->ob_itself,
  938. &outCommandID);
  939. if (_err != noErr) return PyMac_Error(_err);
  940. _res = Py_BuildValue("l",
  941. outCommandID);
  942. return _res;
  943. }
  944. static PyObject *CtlObj_RemoveControlProperty(ControlObject *_self, PyObject *_args)
  945. {
  946. PyObject *_res = NULL;
  947. OSStatus _err;
  948. OSType propertyCreator;
  949. OSType propertyTag;
  950. #ifndef RemoveControlProperty
  951. PyMac_PRECHECK(RemoveControlProperty);
  952. #endif
  953. if (!PyArg_ParseTuple(_args, "O&O&",
  954. PyMac_GetOSType, &propertyCreator,
  955. PyMac_GetOSType, &propertyTag))
  956. return NULL;
  957. _err = RemoveControlProperty(_self->ob_itself,
  958. propertyCreator,
  959. propertyTag);
  960. if (_err != noErr) return PyMac_Error(_err);
  961. Py_INCREF(Py_None);
  962. _res = Py_None;
  963. return _res;
  964. }
  965. static PyObject *CtlObj_GetControlPropertyAttributes(ControlObject *_self, PyObject *_args)
  966. {
  967. PyObject *_res = NULL;
  968. OSStatus _err;
  969. OSType propertyCreator;
  970. OSType propertyTag;
  971. UInt32 attributes;
  972. #ifndef GetControlPropertyAttributes
  973. PyMac_PRECHECK(GetControlPropertyAttributes);
  974. #endif
  975. if (!PyArg_ParseTuple(_args, "O&O&",
  976. PyMac_GetOSType, &propertyCreator,
  977. PyMac_GetOSType, &propertyTag))
  978. return NULL;
  979. _err = GetControlPropertyAttributes(_self->ob_itself,
  980. propertyCreator,
  981. propertyTag,
  982. &attributes);
  983. if (_err != noErr) return PyMac_Error(_err);
  984. _res = Py_BuildValue("l",
  985. attributes);
  986. return _res;
  987. }
  988. static PyObject *CtlObj_ChangeControlPropertyAttributes(ControlObject *_self, PyObject *_args)
  989. {
  990. PyObject *_res = NULL;
  991. OSStatus _err;
  992. OSType propertyCreator;
  993. OSType propertyTag;
  994. UInt32 attributesToSet;
  995. UInt32 attributesToClear;
  996. #ifndef ChangeControlPropertyAttributes
  997. PyMac_PRECHECK(ChangeControlPropertyAttributes);
  998. #endif
  999. if (!PyArg_ParseTuple(_args, "O&O&ll",
  1000. PyMac_GetOSType, &propertyCreator,
  1001. PyMac_GetOSType, &propertyTag,
  1002. &attributesToSet,
  1003. &attributesToClear))
  1004. return NULL;
  1005. _err = ChangeControlPropertyAttributes(_self->ob_itself,
  1006. propertyCreator,
  1007. propertyTag,
  1008. attributesToSet,
  1009. attributesToClear);
  1010. if (_err != noErr) return PyMac_Error(_err);
  1011. Py_INCREF(Py_None);
  1012. _res = Py_None;
  1013. return _res;
  1014. }
  1015. static PyObject *CtlObj_GetControlRegion(ControlObject *_self, PyObject *_args)
  1016. {
  1017. PyObject *_res = NULL;
  1018. OSStatus _err;
  1019. ControlPartCode inPart;
  1020. RgnHandle outRegion;
  1021. #ifndef GetControlRegion
  1022. PyMac_PRECHECK(GetControlRegion);
  1023. #endif
  1024. if (!PyArg_ParseTuple(_args, "hO&",
  1025. &inPart,
  1026. ResObj_Convert, &outRegion))
  1027. return NULL;
  1028. _err = GetControlRegion(_self->ob_itself,
  1029. inPart,
  1030. outRegion);
  1031. if (_err != noErr) return PyMac_Error(_err);
  1032. Py_INCREF(Py_None);
  1033. _res = Py_None;
  1034. return _res;
  1035. }
  1036. static PyObject *CtlObj_GetControlVariant(ControlObject *_self, PyObject *_args)
  1037. {
  1038. PyObject *_res = NULL;
  1039. ControlVariant _rv;
  1040. #ifndef GetControlVariant
  1041. PyMac_PRECHECK(GetControlVariant);
  1042. #endif
  1043. if (!PyArg_ParseTuple(_args, ""))
  1044. return NULL;
  1045. _rv = GetControlVariant(_self->ob_itself);
  1046. _res = Py_BuildValue("h",
  1047. _rv);
  1048. return _res;
  1049. }
  1050. static PyObject *CtlObj_SetControlAction(ControlObject *_self, PyObject *_args)
  1051. {
  1052. PyObject *_res = NULL;
  1053. PyObject* actionProc;
  1054. UniversalProcPtr c_callback;
  1055. #ifndef SetControlAction
  1056. PyMac_PRECHECK(SetControlAction);
  1057. #endif
  1058. if (!PyArg_ParseTuple(_args, "O",
  1059. &actionProc))
  1060. return NULL;
  1061. SetControlAction(_self->ob_itself,
  1062. myactionproc_upp);
  1063. Py_INCREF(Py_None);
  1064. _res = Py_None;
  1065. setcallback((PyObject*)_self, kMyControlActionProcTag, actionProc, &c_callback);
  1066. return _res;
  1067. }
  1068. static PyObject *CtlObj_SetControlReference(ControlObject *_self, PyObject *_args)
  1069. {
  1070. PyObject *_res = NULL;
  1071. SInt32 data;
  1072. #ifndef SetControlReference
  1073. PyMac_PRECHECK(SetControlReference);
  1074. #endif
  1075. if (!PyArg_ParseTuple(_args, "l",
  1076. &data))
  1077. return NULL;
  1078. SetControlReference(_self->ob_itself,
  1079. data);
  1080. Py_INCREF(Py_None);
  1081. _res = Py_None;
  1082. return _res;
  1083. }
  1084. static PyObject *CtlObj_GetControlReference(ControlObject *_self, PyObject *_args)
  1085. {
  1086. PyObject *_res = NULL;
  1087. SInt32 _rv;
  1088. #ifndef GetControlReference
  1089. PyMac_PRECHECK(GetControlReference);
  1090. #endif
  1091. if (!PyArg_ParseTuple(_args, ""))
  1092. return NULL;
  1093. _rv = GetControlReference(_self->ob_itself);
  1094. _res = Py_BuildValue("l",
  1095. _rv);
  1096. return _res;
  1097. }
  1098. static PyObject *CtlObj_EmbedControl(ControlObject *_self, PyObject *_args)
  1099. {
  1100. PyObject *_res = NULL;
  1101. OSErr _err;
  1102. ControlHandle inContainer;
  1103. #ifndef EmbedControl
  1104. PyMac_PRECHECK(EmbedControl);
  1105. #endif
  1106. if (!PyArg_ParseTuple(_args, "O&",
  1107. CtlObj_Convert, &inContainer))
  1108. return NULL;
  1109. _err = EmbedControl(_self->ob_itself,
  1110. inContainer);
  1111. if (_err != noErr) return PyMac_Error(_err);
  1112. Py_INCREF(Py_None);
  1113. _res = Py_None;
  1114. return _res;
  1115. }
  1116. static PyObject *CtlObj_AutoEmbedControl(ControlObject *_self, PyObject *_args)
  1117. {
  1118. PyObject *_res = NULL;
  1119. OSErr _err;
  1120. WindowPtr inWindow;
  1121. #ifndef AutoEmbedControl
  1122. PyMac_PRECHECK(AutoEmbedControl);
  1123. #endif
  1124. if (!PyArg_ParseTuple(_args, "O&",
  1125. WinObj_Convert, &inWindow))
  1126. return NULL;
  1127. _err = AutoEmbedControl(_self->ob_itself,
  1128. inWindow);
  1129. if (_err != noErr) return PyMac_Error(_err);
  1130. Py_INCREF(Py_None);
  1131. _res = Py_None;
  1132. return _res;
  1133. }
  1134. static PyObject *CtlObj_GetSuperControl(ControlObject *_self, PyObject *_args)
  1135. {
  1136. PyObject *_res = NULL;
  1137. OSErr _err;
  1138. ControlHandle outParent;
  1139. #ifndef GetSuperControl
  1140. PyMac_PRECHECK(GetSuperControl);
  1141. #endif
  1142. if (!PyArg_ParseTuple(_args, ""))
  1143. return NULL;
  1144. _err = GetSuperControl(_self->ob_itself,
  1145. &outParent);
  1146. if (_err != noErr) return PyMac_Error(_err);
  1147. _res = Py_BuildValue("O&",
  1148. CtlObj_WhichControl, outParent);
  1149. return _res;
  1150. }
  1151. static PyObject *CtlObj_CountSubControls(ControlObject *_self, PyObject *_args)
  1152. {
  1153. PyObject *_res = NULL;
  1154. OSErr _err;
  1155. UInt16 outNumChildren;
  1156. #ifndef CountSubControls
  1157. PyMac_PRECHECK(CountSubControls);
  1158. #endif
  1159. if (!PyArg_ParseTuple(_args, ""))
  1160. return NULL;
  1161. _err = CountSubControls(_self->ob_itself,
  1162. &outNumChildren);
  1163. if (_err != noErr) return PyMac_Error(_err);
  1164. _res = Py_BuildValue("H",
  1165. outNumChildren);
  1166. return _res;
  1167. }
  1168. static PyObject *CtlObj_GetIndexedSubControl(ControlObject *_self, PyObject *_args)
  1169. {
  1170. PyObject *_res = NULL;
  1171. OSErr _err;
  1172. UInt16 inIndex;
  1173. ControlHandle outSubControl;
  1174. #ifndef GetIndexedSubControl
  1175. PyMac_PRECHECK(GetIndexedSubControl);
  1176. #endif
  1177. if (!PyArg_ParseTuple(_args, "H",
  1178. &inIndex))
  1179. return NULL;
  1180. _err = GetIndexedSubControl(_self->ob_itself,
  1181. inIndex,
  1182. &outSubControl);
  1183. if (_err != noErr) return PyMac_Error(_err);
  1184. _res = Py_BuildValue("O&",
  1185. CtlObj_WhichControl, outSubControl);
  1186. return _res;
  1187. }
  1188. static PyObject *CtlObj_SetControlSupervisor(ControlObject *_self, PyObject *_args)
  1189. {
  1190. PyObject *_res = NULL;
  1191. OSErr _err;
  1192. ControlHandle inBoss;
  1193. #ifndef SetControlSupervisor
  1194. PyMac_PRECHECK(SetControlSupervisor);
  1195. #endif
  1196. if (!PyArg_ParseTuple(_args, "O&",
  1197. CtlObj_Convert, &inBoss))
  1198. return NULL;
  1199. _err = SetControlSupervisor(_self->ob_itself,
  1200. inBoss);
  1201. if (_err != noErr) return PyMac_Error(_err);
  1202. Py_INCREF(Py_None);
  1203. _res = Py_None;
  1204. return _res;
  1205. }
  1206. static PyObject *CtlObj_GetControlFeatures(ControlObject *_self, PyObject *_args)
  1207. {
  1208. PyObject *_res = NULL;
  1209. OSErr _err;
  1210. UInt32 outFeatures;
  1211. #ifndef GetControlFeatures
  1212. PyMac_PRECHECK(GetControlFeatures);
  1213. #endif
  1214. if (!PyArg_ParseTuple(_args, ""))
  1215. return NULL;
  1216. _err = GetControlFeatures(_self->ob_itself,
  1217. &outFeatures);
  1218. if (_err != noErr) return PyMac_Error(_err);
  1219. _res = Py_BuildValue("l",
  1220. outFeatures);
  1221. return _res;
  1222. }
  1223. static PyObject *CtlObj_GetControlDataSize(ControlObject *_self, PyObject *_args)
  1224. {
  1225. PyObject *_res = NULL;
  1226. OSErr _err;
  1227. ControlPartCode inPart;
  1228. ResType inTagName;
  1229. Size outMaxSize;
  1230. #ifndef GetControlDataSize
  1231. PyMac_PRECHECK(GetControlDataSize);
  1232. #endif
  1233. if (!PyArg_ParseTuple(_args, "hO&",
  1234. &inPart,
  1235. PyMac_GetOSType, &inTagName))
  1236. return NULL;
  1237. _err = GetControlDataSize(_self->ob_itself,
  1238. inPart,
  1239. inTagName,
  1240. &outMaxSize);
  1241. if (_err != noErr) return PyMac_Error(_err);
  1242. _res = Py_BuildValue("l",
  1243. outMaxSize);
  1244. return _res;
  1245. }
  1246. static PyObject *CtlObj_HandleControlDragTracking(ControlObject *_self, PyObject *_args)
  1247. {
  1248. PyObject *_res = NULL;
  1249. OSStatus _err;
  1250. DragTrackingMessage inMessage;
  1251. DragReference inDrag;
  1252. Boolean outLikesDrag;
  1253. #ifndef HandleControlDragTracking
  1254. PyMac_PRECHECK(HandleControlDragTracking);
  1255. #endif
  1256. if (!PyArg_ParseTuple(_args, "hO&",
  1257. &inMessage,
  1258. DragObj_Convert, &inDrag))
  1259. return NULL;
  1260. _err = HandleControlDragTracking(_self->ob_itself,
  1261. inMessage,
  1262. inDrag,
  1263. &outLikesDrag);
  1264. if (_err != noErr) return PyMac_Error(_err);
  1265. _res = Py_BuildValue("b",
  1266. outLikesDrag);
  1267. return _res;
  1268. }
  1269. static PyObject *CtlObj_HandleControlDragReceive(ControlObject *_self, PyObject *_args)
  1270. {
  1271. PyObject *_res = NULL;
  1272. OSStatus _err;
  1273. DragReference inDrag;
  1274. #ifndef HandleControlDragReceive
  1275. PyMac_PRECHECK(HandleControlDragReceive);
  1276. #endif
  1277. if (!PyArg_ParseTuple(_args, "O&",
  1278. DragObj_Convert, &inDrag))
  1279. return NULL;
  1280. _err = HandleControlDragReceive(_self->ob_itself,
  1281. inDrag);
  1282. if (_err != noErr) return PyMac_Error(_err);
  1283. Py_INCREF(Py_None);
  1284. _res = Py_None;
  1285. return _res;
  1286. }
  1287. static PyObject *CtlObj_SetControlDragTrackingEnabled(ControlObject *_self, PyObject *_args)
  1288. {
  1289. PyObject *_res = NULL;
  1290. OSStatus _err;
  1291. Boolean inTracks;
  1292. #ifndef SetControlDragTrackingEnabled
  1293. PyMac_PRECHECK(SetControlDragTrackingEnabled);
  1294. #endif
  1295. if (!PyArg_ParseTuple(_args, "b",
  1296. &inTracks))
  1297. return NULL;
  1298. _err = SetControlDragTrackingEnabled(_self->ob_itself,
  1299. inTracks);
  1300. if (_err != noErr) return PyMac_Error(_err);
  1301. Py_INCREF(Py_None);
  1302. _res = Py_None;
  1303. return _res;
  1304. }
  1305. static PyObject *CtlObj_IsControlDragTrackingEnabled(ControlObject *_self, PyObject *_args)
  1306. {
  1307. PyObject *_res = NULL;
  1308. OSStatus _err;
  1309. Boolean outTracks;
  1310. #ifndef IsControlDragTrackingEnabled
  1311. PyMac_PRECHECK(IsControlDragTrackingEnabled);
  1312. #endif
  1313. if (!PyArg_ParseTuple(_args, ""))
  1314. return NULL;
  1315. _err = IsControlDragTrackingEnabled(_self->ob_itself,
  1316. &outTracks);
  1317. if (_err != noErr) return PyMac_Error(_err);
  1318. _res = Py_BuildValue("b",
  1319. outTracks);
  1320. return _res;
  1321. }
  1322. static PyObject *CtlObj_GetControlBounds(ControlObject *_self, PyObject *_args)
  1323. {
  1324. PyObject *_res = NULL;
  1325. Rect bounds;
  1326. #ifndef GetControlBounds
  1327. PyMac_PRECHECK(GetControlBounds);
  1328. #endif
  1329. if (!PyArg_ParseTuple(_args, ""))
  1330. return NULL;
  1331. GetControlBounds(_self->ob_itself,
  1332. &bounds);
  1333. _res = Py_BuildValue("O&",
  1334. PyMac_BuildRect, &bounds);
  1335. return _res;
  1336. }
  1337. static PyObject *CtlObj_IsControlHilited(ControlObject *_self, PyObject *_args)
  1338. {
  1339. PyObject *_res = NULL;
  1340. Boolean _rv;
  1341. #ifndef IsControlHilited
  1342. PyMac_PRECHECK(IsControlHilited);
  1343. #endif
  1344. if (!PyArg_ParseTuple(_args, ""))
  1345. return NULL;
  1346. _rv = IsControlHilited(_self->ob_itself);
  1347. _res = Py_BuildValue("b",
  1348. _rv);
  1349. return _res;
  1350. }
  1351. static PyObject *CtlObj_GetControlHilite(ControlObject *_self, PyObject *_args)
  1352. {
  1353. PyObject *_res = NULL;
  1354. UInt16 _rv;
  1355. #ifndef GetControlHilite
  1356. PyMac_PRECHECK(GetControlHilite);
  1357. #endif
  1358. if (!PyArg_ParseTuple(_args, ""))
  1359. return NULL;
  1360. _rv = GetControlHilite(_self->ob_itself);
  1361. _res = Py_BuildValue("H",
  1362. _rv);
  1363. return _res;
  1364. }
  1365. static PyObject *CtlObj_GetControlOwner(ControlObject *_self, PyObject *_args)
  1366. {
  1367. PyObject *_res = NULL;
  1368. WindowPtr _rv;
  1369. #ifndef GetControlOwner
  1370. PyMac_PRECHECK(GetControlOwner);
  1371. #endif
  1372. if (!PyArg_ParseTuple(_args, ""))
  1373. return NULL;
  1374. _rv = GetControlOwner(_self->ob_itself);
  1375. _res = Py_BuildValue("O&",
  1376. WinObj_New, _rv);
  1377. return _res;
  1378. }
  1379. static PyObject *CtlObj_GetControlDataHandle(ControlObject *_self, PyObject *_args)
  1380. {
  1381. PyObject *_res = NULL;
  1382. Handle _rv;
  1383. #ifndef GetControlDataHandle
  1384. PyMac_PRECHECK(GetControlDataHandle);
  1385. #endif
  1386. if (!PyArg_ParseTuple(_args, ""))
  1387. return NULL;
  1388. _rv = GetControlDataHandle(_self->ob_itself);
  1389. _res = Py_BuildValue("O&",
  1390. ResObj_New, _rv);
  1391. return _res;
  1392. }
  1393. static PyObject *CtlObj_GetControlPopupMenuHandle(ControlObject *_self, PyObject *_args)
  1394. {
  1395. PyObject *_res = NULL;
  1396. MenuHandle _rv;
  1397. #ifndef GetControlPopupMenuHandle
  1398. PyMac_PRECHECK(GetControlPopupMenuHandle);
  1399. #endif
  1400. if (!PyArg_ParseTuple(_args, ""))
  1401. return NULL;
  1402. _rv = GetControlPopupMenuHandle(_self->ob_itself);
  1403. _res = Py_BuildValue("O&",
  1404. MenuObj_New, _rv);
  1405. return _res;
  1406. }
  1407. static PyObject *CtlObj_GetControlPopupMenuID(ControlObject *_self, PyObject *_args)
  1408. {
  1409. PyObject *_res = NULL;
  1410. short _rv;
  1411. #ifndef GetControlPopupMenuID
  1412. PyMac_PRECHECK(GetControlPopupMenuID);
  1413. #endif
  1414. if (!PyArg_ParseTuple(_args, ""))
  1415. return NULL;
  1416. _rv = GetControlPopupMenuID(_self->ob_itself);
  1417. _res = Py_BuildValue("h",
  1418. _rv);
  1419. return _res;
  1420. }
  1421. static PyObject *CtlObj_SetControlDataHandle(ControlObject *_self, PyObject *_args)
  1422. {
  1423. PyObject *_res = NULL;
  1424. Handle dataHandle;
  1425. #ifndef SetControlDataHandle
  1426. PyMac_PRECHECK(SetControlDataHandle);
  1427. #endif
  1428. if (!PyArg_ParseTuple(_args, "O&",
  1429. ResObj_Convert, &dataHandle))
  1430. return NULL;
  1431. SetControlDataHandle(_self->ob_itself,
  1432. dataHandle);
  1433. Py_INCREF(Py_None);
  1434. _res = Py_None;
  1435. return _res;
  1436. }
  1437. static PyObject *CtlObj_SetControlBounds(ControlObject *_self, PyObject *_args)
  1438. {
  1439. PyObject *_res = NULL;
  1440. Rect bounds;
  1441. #ifndef SetControlBounds
  1442. PyMac_PRECHECK(SetControlBounds);
  1443. #endif
  1444. if (!PyArg_ParseTuple(_args, "O&",
  1445. PyMac_GetRect, &bounds))
  1446. return NULL;
  1447. SetControlBounds(_self->ob_itself,
  1448. &bounds);
  1449. Py_INCREF(Py_None);
  1450. _res = Py_None;
  1451. return _res;
  1452. }
  1453. static PyObject *CtlObj_SetControlPopupMenuHandle(ControlObject *_self, PyObject *_args)
  1454. {
  1455. PyObject *_res = NULL;
  1456. MenuHandle popupMenu;
  1457. #ifndef SetControlPopupMenuHandle
  1458. PyMac_PRECHECK(SetControlPopupMenuHandle);
  1459. #endif
  1460. if (!PyArg_ParseTuple(_args, "O&",
  1461. MenuObj_Convert, &popupMenu))
  1462. return NULL;
  1463. SetControlPopupMenuHandle(_self->ob_itself,
  1464. popupMenu);
  1465. Py_INCREF(Py_None);
  1466. _res = Py_None;
  1467. return _res;
  1468. }
  1469. static PyObject *CtlObj_SetControlPopupMenuID(ControlObject *_self, PyObject *_args)
  1470. {
  1471. PyObject *_res = NULL;
  1472. short menuID;
  1473. #ifndef SetControlPopupMenuID
  1474. PyMac_PRECHECK(SetControlPopupMenuID);
  1475. #endif
  1476. if (!PyArg_ParseTuple(_args, "h",
  1477. &menuID))
  1478. return NULL;
  1479. SetControlPopupMenuID(_self->ob_itself,
  1480. menuID);
  1481. Py_INCREF(Py_None);
  1482. _res = Py_None;
  1483. return _res;
  1484. }
  1485. static PyObject *CtlObj_GetBevelButtonMenuValue(ControlObject *_self, PyObject *_args)
  1486. {
  1487. PyObject *_res = NULL;
  1488. OSErr _err;
  1489. SInt16 outValue;
  1490. #ifndef GetBevelButtonMenuValue
  1491. PyMac_PRECHECK(GetBevelButtonMenuValue);
  1492. #endif
  1493. if (!PyArg_ParseTuple(_args, ""))
  1494. return NULL;
  1495. _err = GetBevelButtonMenuValue(_self->ob_itself,
  1496. &outValue);
  1497. if (_err != noErr) return PyMac_Error(_err);
  1498. _res = Py_BuildValue("h",
  1499. outValue);
  1500. return _res;
  1501. }
  1502. static PyObject *CtlObj_SetBevelButtonMenuValue(ControlObject *_self, PyObject *_args)
  1503. {
  1504. PyObject *_res = NULL;
  1505. OSErr _err;
  1506. SInt16 inValue;
  1507. #ifndef SetBevelButtonMenuValue
  1508. PyMac_PRECHECK(SetBevelButtonMenuValue);
  1509. #endif
  1510. if (!PyArg_ParseTuple(_args, "h",
  1511. &inValue))
  1512. return NULL;
  1513. _err = SetBevelButtonMenuValue(_self->ob_itself,
  1514. inValue);
  1515. if (_err != noErr) return PyMac_Error(_err);
  1516. Py_INCREF(Py_None);
  1517. _res = Py_None;
  1518. return _res;
  1519. }
  1520. static PyObject *CtlObj_GetBevelButtonMenuHandle(ControlObject *_self, PyObject *_args)
  1521. {
  1522. PyObject *_res = NULL;
  1523. OSErr _err;
  1524. MenuHandle outHandle;
  1525. #ifndef GetBevelButtonMenuHandle
  1526. PyMac_PRECHECK(GetBevelButtonMenuHandle);
  1527. #endif
  1528. if (!PyArg_ParseTuple(_args, ""))
  1529. return NULL;
  1530. _err = GetBevelButtonMenuHandle(_self->ob_itself,
  1531. &outHandle);
  1532. if (_err != noErr) return PyMac_Error(_err);
  1533. _res = Py_BuildValue("O&",
  1534. MenuObj_New, outHandle);
  1535. return _res;
  1536. }
  1537. static PyObject *CtlObj_SetBevelButtonContentInfo(ControlObject *_self, PyObject *_args)
  1538. {
  1539. PyObject *_res = NULL;
  1540. OSErr _err;
  1541. ControlButtonContentInfo inContent;
  1542. #ifndef SetBevelButtonContentInfo
  1543. PyMac_PRECHECK(SetBevelButtonContentInfo);
  1544. #endif
  1545. if (!PyArg_ParseTuple(_args, "O&",
  1546. ControlButtonContentInfo_Convert, &inContent))
  1547. return NULL;
  1548. _err = SetBevelButtonContentInfo(_self->ob_itself,
  1549. &inContent);
  1550. if (_err != noErr) return PyMac_Error(_err);
  1551. Py_INCREF(Py_None);
  1552. _res = Py_None;
  1553. return _res;
  1554. }
  1555. static PyObject *CtlObj_SetBevelButtonTransform(ControlObject *_self, PyObject *_args)
  1556. {
  1557. PyObject *_res = NULL;
  1558. OSErr _err;
  1559. IconTransformType transform;
  1560. #ifndef SetBevelButtonTransform
  1561. PyMac_PRECHECK(SetBevelButtonTransform);
  1562. #endif
  1563. if (!PyArg_ParseTuple(_args, "h",
  1564. &transform))
  1565. return NULL;
  1566. _err = SetBevelButtonTransform(_self->ob_itself,
  1567. transform);
  1568. if (_err != noErr) return PyMac_Error(_err);
  1569. Py_INCREF(Py_None);
  1570. _res = Py_None;
  1571. return _res;
  1572. }
  1573. static PyObject *CtlObj_SetDisclosureTriangleLastValue(ControlObject *_self, PyObject *_args)
  1574. {
  1575. PyObject *_res = NULL;
  1576. OSErr _err;
  1577. SInt16 inValue;
  1578. #ifndef SetDisclosureTriangleLastValue
  1579. PyMac_PRECHECK(SetDisclosureTriangleLastValue);
  1580. #endif
  1581. if (!PyArg_ParseTuple(_args, "h",
  1582. &inValue))
  1583. return NULL;
  1584. _err = SetDisclosureTriangleLastValue(_self->ob_itself,
  1585. inValue);
  1586. if (_err != noErr) return PyMac_Error(_err);
  1587. Py_INCREF(Py_None);
  1588. _res = Py_None;
  1589. return _res;
  1590. }
  1591. static PyObject *CtlObj_GetTabContentRect(ControlObject *_self, PyObject *_args)
  1592. {
  1593. PyObject *_res = NULL;
  1594. OSErr _err;
  1595. Rect outContentRect;
  1596. #ifndef GetTabContentRect
  1597. PyMac_PRECHECK(GetTabContentRect);
  1598. #endif
  1599. if (!PyArg_ParseTuple(_args, ""))
  1600. return NULL;
  1601. _err = GetTabContentRect(_self->ob_itself,
  1602. &outContentRect);
  1603. if (_err != noErr) return PyMac_Error(_err);
  1604. _res = Py_BuildValue("O&",
  1605. PyMac_BuildRect, &outContentRect);
  1606. return _res;
  1607. }
  1608. static PyObject *CtlObj_SetTabEnabled(ControlObject *_self, PyObject *_args)
  1609. {
  1610. PyObject *_res = NULL;
  1611. OSErr _err;
  1612. SInt16 inTabToHilite;
  1613. Boolean inEnabled;
  1614. #ifndef SetTabEnabled
  1615. PyMac_PRECHECK(SetTabEnabled);
  1616. #endif
  1617. if (!PyArg_ParseTuple(_args, "hb",
  1618. &inTabToHilite,
  1619. &inEnabled))
  1620. return NULL;
  1621. _err = SetTabEnabled(_self->ob_itself,
  1622. inTabToHilite,
  1623. inEnabled);
  1624. if (_err != noErr) return PyMac_Error(_err);
  1625. Py_INCREF(Py_None);
  1626. _res = Py_None;
  1627. return _res;
  1628. }
  1629. static PyObject *CtlObj_SetImageWellContentInfo(ControlObject *_self, PyObject *_args)
  1630. {
  1631. PyObject *_res = NULL;
  1632. OSErr _err;
  1633. ControlButtonContentInfo inContent;
  1634. #ifndef SetImageWellContentInfo
  1635. PyMac_PRECHECK(SetImageWellContentInfo);
  1636. #endif
  1637. if (!PyArg_ParseTuple(_args, "O&",
  1638. ControlButtonContentInfo_Convert, &inContent))
  1639. return NULL;
  1640. _err = SetImageWellContentInfo(_self->ob_itself,
  1641. &inContent);
  1642. if (_err != noErr) return PyMac_Error(_err);
  1643. Py_INCREF(Py_None);
  1644. _res = Py_None;
  1645. return _res;
  1646. }
  1647. static PyObject *CtlObj_SetImageWellTransform(ControlObject *_self, PyObject *_args)
  1648. {
  1649. PyObject *_res = NULL;
  1650. OSErr _err;
  1651. IconTransformType inTransform;
  1652. #ifndef SetImageWellTransform
  1653. PyMac_PRECHECK(SetImageWellTransform);
  1654. #endif
  1655. if (!PyArg_ParseTuple(_args, "h",
  1656. &inTransform))
  1657. return NULL;
  1658. _err = SetImageWellTransform(_self->ob_itself,
  1659. inTransform);
  1660. if (_err != noErr) return PyMac_Error(_err);
  1661. Py_INCREF(Py_None);
  1662. _res = Py_None;
  1663. return _res;
  1664. }
  1665. static PyObject *CtlObj_GetDataBrowserViewStyle(ControlObject *_self, PyObject *_args)
  1666. {
  1667. PyObject *_res = NULL;
  1668. OSStatus _err;
  1669. OSType style;
  1670. #ifndef GetDataBrowserViewStyle
  1671. PyMac_PRECHECK(GetDataBrowserViewStyle);
  1672. #endif
  1673. if (!PyArg_ParseTuple(_args, ""))
  1674. return NULL;
  1675. _err = GetDataBrowserViewStyle(_self->ob_itself,
  1676. &style);
  1677. if (_err != noErr) return PyMac_Error(_err);
  1678. _res = Py_BuildValue("O&",
  1679. PyMac_BuildOSType, style);
  1680. return _res;
  1681. }
  1682. static PyObject *CtlObj_SetDataBrowserViewStyle(ControlObject *_self, PyObject *_args)
  1683. {
  1684. PyObject *_res = NULL;
  1685. OSStatus _err;
  1686. OSType style;
  1687. #ifndef SetDataBrowserViewStyle
  1688. PyMac_PRECHECK(SetDataBrowserViewStyle);
  1689. #endif
  1690. if (!PyArg_ParseTuple(_args, "O&",
  1691. PyMac_GetOSType, &style))
  1692. return NULL;
  1693. _err = SetDataBrowserViewStyle(_self->ob_itself,
  1694. style);
  1695. if (_err != noErr) return PyMac_Error(_err);
  1696. Py_INCREF(Py_None);
  1697. _res = Py_None;
  1698. return _res;
  1699. }
  1700. static PyObject *CtlObj_EnableDataBrowserEditCommand(ControlObject *_self, PyObject *_args)
  1701. {
  1702. PyObject *_res = NULL;
  1703. Boolean _rv;
  1704. UInt32 command;
  1705. #ifndef EnableDataBrowserEditCommand
  1706. PyMac_PRECHECK(EnableDataBrowserEditCommand);
  1707. #endif
  1708. if (!PyArg_ParseTuple(_args, "l",
  1709. &command))
  1710. return NULL;
  1711. _rv = EnableDataBrowserEditCommand(_self->ob_itself,
  1712. command);
  1713. _res = Py_BuildValue("b",
  1714. _rv);
  1715. return _res;
  1716. }
  1717. static PyObject *CtlObj_ExecuteDataBrowserEditCommand(ControlObject *_self, PyObject *_args)
  1718. {
  1719. PyObject *_res = NULL;
  1720. OSStatus _err;
  1721. UInt32 command;
  1722. #ifndef ExecuteDataBrowserEditCommand
  1723. PyMac_PRECHECK(ExecuteDataBrowserEditCommand);
  1724. #endif
  1725. if (!PyArg_ParseTuple(_args, "l",
  1726. &command))
  1727. return NULL;
  1728. _err = ExecuteDataBrowserEditCommand(_self->ob_itself,
  1729. command);
  1730. if (_err != noErr) return PyMac_Error(_err);
  1731. Py_INCREF(Py_None);
  1732. _res = Py_None;
  1733. return _res;
  1734. }
  1735. static PyObject *CtlObj_GetDataBrowserSelectionAnchor(ControlObject *_self, PyObject *_args)
  1736. {
  1737. PyObject *_res = NULL;
  1738. OSStatus _err;
  1739. UInt32 first;
  1740. UInt32 last;
  1741. #ifndef GetDataBrowserSelectionAnchor
  1742. PyMac_PRECHECK(GetDataBrowserSelectionAnchor);
  1743. #endif
  1744. if (!PyArg_ParseTuple(_args, ""))
  1745. return NULL;
  1746. _err = GetDataBrowserSelectionAnchor(_self->ob_itself,
  1747. &first,
  1748. &last);
  1749. if (_err != noErr) return PyMac_Error(_err);
  1750. _res = Py_BuildValue("ll",
  1751. first,
  1752. last);
  1753. return _res;
  1754. }
  1755. static PyObject *CtlObj_MoveDataBrowserSelectionAnchor(ControlObject *_self, PyObject *_args)
  1756. {
  1757. PyObject *_res = NULL;
  1758. OSStatus _err;
  1759. UInt32 direction;
  1760. Boolean extendSelection;
  1761. #ifndef MoveDataBrowserSelectionAnchor
  1762. PyMac_PRECHECK(MoveDataBrowserSelectionAnchor);
  1763. #endif
  1764. if (!PyArg_ParseTuple(_args, "lb",
  1765. &direction,
  1766. &extendSelection))
  1767. return NULL;
  1768. _err = MoveDataBrowserSelectionAnchor(_self->ob_itself,
  1769. direction,
  1770. extendSelection);
  1771. if (_err != noErr) return PyMac_Error(_err);
  1772. Py_INCREF(Py_None);
  1773. _res = Py_None;
  1774. return _res;
  1775. }
  1776. static PyObject *CtlObj_OpenDataBrowserContainer(ControlObject *_self, PyObject *_args)
  1777. {
  1778. PyObject *_res = NULL;
  1779. OSStatus _err;
  1780. UInt32 container;
  1781. #ifndef OpenDataBrowserContainer
  1782. PyMac_PRECHECK(OpenDataBrowserContainer);
  1783. #endif
  1784. if (!PyArg_ParseTuple(_args, "l",
  1785. &container))
  1786. return NULL;
  1787. _err = OpenDataBrowserContainer(_self->ob_itself,
  1788. container);
  1789. if (_err != noErr) return PyMac_Error(_err);
  1790. Py_INCREF(Py_None);
  1791. _res = Py_None;
  1792. return _res;
  1793. }
  1794. static PyObject *CtlObj_CloseDataBrowserContainer(ControlObject *_self, PyObject *_args)
  1795. {
  1796. PyObject *_res = NULL;
  1797. OSStatus _err;
  1798. UInt32 container;
  1799. #ifndef CloseDataBrowserContainer
  1800. PyMac_PRECHECK(CloseDataBrowserContainer);
  1801. #endif
  1802. if (!PyArg_ParseTuple(_args, "l",
  1803. &container))
  1804. return NULL;
  1805. _err = CloseDataBrowserContainer(_self->ob_itself,
  1806. container);
  1807. if (_err != noErr) return PyMac_Error(_err);
  1808. Py_INCREF(Py_None);
  1809. _res = Py_None;
  1810. return _res;
  1811. }
  1812. static PyObject *CtlObj_SortDataBrowserContainer(ControlObject *_self, PyObject *_args)
  1813. {
  1814. PyObject *_res = NULL;
  1815. OSStatus _err;
  1816. UInt32 container;
  1817. Boolean sortChildren;
  1818. #ifndef SortDataBrowserContainer
  1819. PyMac_PRECHECK(SortDataBrowserContainer);
  1820. #endif
  1821. if (!PyArg_ParseTuple(_args, "lb",
  1822. &container,
  1823. &sortChildren))
  1824. return NULL;
  1825. _err = SortDataBrowserContainer(_self->ob_itself,
  1826. container,
  1827. sortChildren);
  1828. if (_err != noErr) return PyMac_Error(_err);
  1829. Py_INCREF(Py_None);
  1830. _res = Py_None;
  1831. return _res;
  1832. }
  1833. static PyObject *CtlObj_GetDataBrowserItems(ControlObject *_self, PyObject *_args)
  1834. {
  1835. PyObject *_res = NULL;
  1836. OSStatus _err;
  1837. UInt32 container;
  1838. Boolean recurse;
  1839. UInt32 state;
  1840. Handle items;
  1841. #ifndef GetDataBrowserItems
  1842. PyMac_PRECHECK(GetDataBrowserItems);
  1843. #endif
  1844. if (!PyArg_ParseTuple(_args, "lblO&",
  1845. &container,
  1846. &recurse,
  1847. &state,
  1848. ResObj_Convert, &items))
  1849. return NULL;
  1850. _err = GetDataBrowserItems(_self->ob_itself,
  1851. container,
  1852. recurse,
  1853. state,
  1854. items);
  1855. if (_err != noErr) return PyMac_Error(_err);
  1856. Py_INCREF(Py_None);
  1857. _res = Py_None;
  1858. return _res;
  1859. }
  1860. static PyObject *CtlObj_GetDataBrowserItemCount(ControlObject *_self, PyObject *_args)
  1861. {
  1862. PyObject *_res = NULL;
  1863. OSStatus _err;
  1864. UInt32 container;
  1865. Boolean recurse;
  1866. UInt32 state;
  1867. UInt32 numItems;
  1868. #ifndef GetDataBrowserItemCount
  1869. PyMac_PRECHECK(GetDataBrowserItemCount);
  1870. #endif
  1871. if (!PyArg_ParseTuple(_args, "lbl",
  1872. &container,
  1873. &recurse,
  1874. &state))
  1875. return NULL;
  1876. _err = GetDataBrowserItemCount(_self->ob_itself,
  1877. container,
  1878. recurse,
  1879. state,
  1880. &numItems);
  1881. if (_err != noErr) return PyMac_Error(_err);
  1882. _res = Py_BuildValue("l",
  1883. numItems);
  1884. return _res;
  1885. }
  1886. static PyObject *CtlObj_IsDataBrowserItemSelected(ControlObject *_self, PyObject *_args)
  1887. {
  1888. PyObject *_res = NULL;
  1889. Boolean _rv;
  1890. UInt32 item;
  1891. #ifndef IsDataBrowserItemSelected
  1892. PyMac_PRECHECK(IsDataBrowserItemSelected);
  1893. #endif
  1894. if (!PyArg_ParseTuple(_args, "l",
  1895. &item))
  1896. return NULL;
  1897. _rv = IsDataBrowserItemSelected(_self->ob_itself,
  1898. item);
  1899. _res = Py_BuildValue("b",
  1900. _rv);
  1901. return _res;
  1902. }
  1903. static PyObject *CtlObj_GetDataBrowserItemState(ControlObject *_self, PyObject *_args)
  1904. {
  1905. PyObject *_res = NULL;
  1906. OSStatus _err;
  1907. UInt32 item;
  1908. UInt32 state;
  1909. #ifndef GetDataBrowserItemState
  1910. PyMac_PRECHECK(GetDataBrowserItemState);
  1911. #endif
  1912. if (!PyArg_ParseTuple(_args, "l",
  1913. &item))
  1914. return NULL;
  1915. _err = GetDataBrowserItemState(_self->ob_itself,
  1916. item,
  1917. &state);
  1918. if (_err != noErr) return PyMac_Error(_err);
  1919. _res = Py_BuildValue("l",
  1920. state);
  1921. return _res;
  1922. }
  1923. static PyObject *CtlObj_RevealDataBrowserItem(ControlObject *_self, PyObject *_args)
  1924. {
  1925. PyObject *_res = NULL;
  1926. OSStatus _err;
  1927. UInt32 item;
  1928. UInt32 propertyID;
  1929. UInt8 options;
  1930. #ifndef RevealDataBrowserItem
  1931. PyMac_PRECHECK(RevealDataBrowserItem);
  1932. #endif
  1933. if (!PyArg_ParseTuple(_args, "llb",
  1934. &item,
  1935. &propertyID,
  1936. &options))
  1937. return NULL;
  1938. _err = RevealDataBrowserItem(_self->ob_itself,
  1939. item,
  1940. propertyID,
  1941. options);
  1942. if (_err != noErr) return PyMac_Error(_err);
  1943. Py_INCREF(Py_None);
  1944. _res = Py_None;
  1945. return _res;
  1946. }
  1947. static PyObject *CtlObj_SetDataBrowserActiveItems(ControlObject *_self, PyObject *_args)
  1948. {
  1949. PyObject *_res = NULL;
  1950. OSStatus _err;
  1951. Boolean active;
  1952. #ifndef SetDataBrowserActiveItems
  1953. PyMac_PRECHECK(SetDataBrowserActiveItems);
  1954. #endif
  1955. if (!PyArg_ParseTuple(_args, "b",
  1956. &active))
  1957. return NULL;
  1958. _err = SetDataBrowserActiveItems(_self->ob_itself,
  1959. active);
  1960. if (_err != noErr) return PyMac_Error(_err);
  1961. Py_INCREF(Py_None);
  1962. _res = Py_None;
  1963. return _res;
  1964. }
  1965. static PyObject *CtlObj_GetDataBrowserActiveItems(ControlObject *_self, PyObject *_args)
  1966. {
  1967. PyObject *_res = NULL;
  1968. OSStatus _err;
  1969. Boolean active;
  1970. #ifndef GetDataBrowserActiveItems
  1971. PyMac_PRECHECK(GetDataBrowserActiveItems);
  1972. #endif
  1973. if (!PyArg_ParseTuple(_args, ""))
  1974. return NULL;
  1975. _err = GetDataBrowserActiveItems(_self->ob_itself,
  1976. &active);
  1977. if (_err != noErr) return PyMac_Error(_err);
  1978. _res = Py_BuildValue("b",
  1979. active);
  1980. return _res;
  1981. }
  1982. static PyObject *CtlObj_SetDataBrowserScrollBarInset(ControlObject *_self, PyObject *_args)
  1983. {
  1984. PyObject *_res = NULL;
  1985. OSStatus _err;
  1986. Rect insetRect;
  1987. #ifndef SetDataBrowserScrollBarInset
  1988. PyMac_PRECHECK(SetDataBrowserScrollBarInset);
  1989. #endif
  1990. if (!PyArg_ParseTuple(_args, ""))
  1991. return NULL;
  1992. _err = SetDataBrowserScrollBarInset(_self->ob_itself,
  1993. &insetRect);
  1994. if (_err != noErr) return PyMac_Error(_err);
  1995. _res = Py_BuildValue("O&",
  1996. PyMac_BuildRect, &insetRect);
  1997. return _res;
  1998. }
  1999. static PyObject *CtlObj_GetDataBrowserScrollBarInset(ControlObject *_self, PyObject *_args)
  2000. {
  2001. PyObject *_res = NULL;
  2002. OSStatus _err;
  2003. Rect insetRect;
  2004. #ifndef GetDataBrowserScrollBarInset
  2005. PyMac_PRECHECK(GetDataBrowserScrollBarInset);
  2006. #endif
  2007. if (!PyArg_ParseTuple(_args, ""))
  2008. return NULL;
  2009. _err = GetDataBrowserScrollBarInset(_self->ob_itself,
  2010. &insetRect);
  2011. if (_err != noErr) return PyMac_Error(_err);
  2012. _res = Py_BuildValue("O&",
  2013. PyMac_BuildRect, &insetRect);
  2014. return _res;
  2015. }
  2016. static PyObject *CtlObj_SetDataBrowserTarget(ControlObject *_self, PyObject *_args)
  2017. {
  2018. PyObject *_res = NULL;
  2019. OSStatus _err;
  2020. UInt32 target;
  2021. #ifndef SetDataBrowserTarget
  2022. PyMac_PRECHECK(SetDataBrowserTarget);
  2023. #endif
  2024. if (!PyArg_ParseTuple(_args, "l",
  2025. &target))
  2026. return NULL;
  2027. _err = SetDataBrowserTarget(_self->ob_itself,
  2028. target);
  2029. if (_err != noErr) return PyMac_Error(_err);
  2030. Py_INCREF(Py_None);
  2031. _res = Py_None;
  2032. return _res;
  2033. }
  2034. static PyObject *CtlObj_GetDataBrowserTarget(ControlObject *_self, PyObject *_args)
  2035. {
  2036. PyObject *_res = NULL;
  2037. OSStatus _err;
  2038. UInt32 target;
  2039. #ifndef GetDataBrowserTarget
  2040. PyMac_PRECHECK(GetDataBrowserTarget);
  2041. #endif
  2042. if (!PyArg_ParseTuple(_args, ""))
  2043. return NULL;
  2044. _err = GetDataBrowserTarget(_self->ob_itself,
  2045. &target);
  2046. if (_err != noErr) return PyMac_Error(_err);
  2047. _res = Py_BuildValue("l",
  2048. target);
  2049. return _res;
  2050. }
  2051. static PyObject *CtlObj_SetDataBrowserSortOrder(ControlObject *_self, PyObject *_args)
  2052. {
  2053. PyObject *_res = NULL;
  2054. OSStatus _err;
  2055. UInt16 order;
  2056. #ifndef SetDataBrowserSortOrder
  2057. PyMac_PRECHECK(SetDataBrowserSortOrder);
  2058. #endif
  2059. if (!PyArg_ParseTuple(_args, "H",
  2060. &order))
  2061. return NULL;
  2062. _err = SetDataBrowserSortOrder(_self->ob_itself,
  2063. order);
  2064. if (_err != noErr) return PyMac_Error(_err);
  2065. Py_INCREF(Py_None);
  2066. _res = Py_None;
  2067. return _res;
  2068. }
  2069. static PyObject *CtlObj_GetDataBrowserSortOrder(ControlObject *_self, PyObject *_args)
  2070. {
  2071. PyObject *_res = NULL;
  2072. OSStatus _err;
  2073. UInt16 order;
  2074. #ifndef GetDataBrowserSortOrder
  2075. PyMac_PRECHECK(GetDataBrowserSortOrder);
  2076. #endif
  2077. if (!PyArg_ParseTuple(_args, ""))
  2078. return NULL;
  2079. _err = GetDataBrowserSortOrder(_self->ob_itself,
  2080. &order);
  2081. if (_err != noErr) return PyMac_Error(_err);
  2082. _res = Py_BuildValue("H",
  2083. order);
  2084. return _res;
  2085. }
  2086. static PyObject *CtlObj_SetDataBrowserScrollPosition(ControlObject *_self, PyObject *_args)
  2087. {
  2088. PyObject *_res = NULL;
  2089. OSStatus _err;
  2090. UInt32 top;
  2091. UInt32 left;
  2092. #ifndef SetDataBrowserScrollPosition
  2093. PyMac_PRECHECK(SetDataBrowserScrollPosition);
  2094. #endif
  2095. if (!PyArg_ParseTuple(_args, "ll",
  2096. &top,
  2097. &left))
  2098. return NULL;
  2099. _err = SetDataBrowserScrollPosition(_self->ob_itself,
  2100. top,
  2101. left);
  2102. if (_err != noErr) return PyMac_Error(_err);
  2103. Py_INCREF(Py_None);
  2104. _res = Py_None;
  2105. return _res;
  2106. }
  2107. static PyObject *CtlObj_GetDataBrowserScrollPosition(ControlObject *_self, PyObject *_args)
  2108. {
  2109. PyObject *_res = NULL;
  2110. OSStatus _err;
  2111. UInt32 top;
  2112. UInt32 left;
  2113. #ifndef GetDataBrowserScrollPosition
  2114. PyMac_PRECHECK(GetDataBrowserScrollPosition);
  2115. #endif
  2116. if (!PyArg_ParseTuple(_args, ""))
  2117. return NULL;
  2118. _err = GetDataBrowserScrollPosition(_self->ob_itself,
  2119. &top,
  2120. &left);
  2121. if (_err != noErr) return PyMac_Error(_err);
  2122. _res = Py_BuildValue("ll",
  2123. top,
  2124. left);
  2125. return _res;
  2126. }
  2127. static PyObject *CtlObj_SetDataBrowserHasScrollBars(ControlObject *_self, PyObject *_args)
  2128. {
  2129. PyObject *_res = NULL;
  2130. OSStatus _err;
  2131. Boolean horiz;
  2132. Boolean vert;
  2133. #ifndef SetDataBrowserHasScrollBars
  2134. PyMac_PRECHECK(SetDataBrowserHasScrollBars);
  2135. #endif
  2136. if (!PyArg_ParseTuple(_args, "bb",
  2137. &horiz,
  2138. &vert))
  2139. return NULL;
  2140. _err = SetDataBrowserHasScrollBars(_self->ob_itself,
  2141. horiz,
  2142. vert);
  2143. if (_err != noErr) return PyMac_Error(_err);
  2144. Py_INCREF(Py_None);
  2145. _res = Py_None;
  2146. return _res;
  2147. }
  2148. static PyObject *CtlObj_GetDataBrowserHasScrollBars(ControlObject *_self, PyObject *_args)
  2149. {
  2150. PyObject *_res = NULL;
  2151. OSStatus _err;
  2152. Boolean horiz;
  2153. Boolean vert;
  2154. #ifndef GetDataBrowserHasScrollBars
  2155. PyMac_PRECHECK(GetDataBrowserHasScrollBars);
  2156. #endif
  2157. if (!PyArg_ParseTuple(_args, ""))
  2158. return NULL;
  2159. _err = GetDataBrowserHasScrollBars(_self->ob_itself,
  2160. &horiz,
  2161. &vert);
  2162. if (_err != noErr) return PyMac_Error(_err);
  2163. _res = Py_BuildValue("bb",
  2164. horiz,
  2165. vert);
  2166. return _res;
  2167. }
  2168. static PyObject *CtlObj_SetDataBrowserSortProperty(ControlObject *_self, PyObject *_args)
  2169. {
  2170. PyObject *_res = NULL;
  2171. OSStatus _err;
  2172. UInt32 property;
  2173. #ifndef SetDataBrowserSortProperty
  2174. PyMac_PRECHECK(SetDataBrowserSortProperty);
  2175. #endif
  2176. if (!PyArg_ParseTuple(_args, "l",
  2177. &property))
  2178. return NULL;
  2179. _err = SetDataBrowserSortProperty(_self->ob_itself,
  2180. property);
  2181. if (_err != noErr) return PyMac_Error(_err);
  2182. Py_INCREF(Py_None);
  2183. _res = Py_None;
  2184. return _res;
  2185. }
  2186. static PyObject *CtlObj_GetDataBrowserSortProperty(ControlObject *_self, PyObject *_args)
  2187. {
  2188. PyObject *_res = NULL;
  2189. OSStatus _err;
  2190. UInt32 property;
  2191. #ifndef GetDataBrowserSortProperty
  2192. PyMac_PRECHECK(GetDataBrowserSortProperty);
  2193. #endif
  2194. if (!PyArg_ParseTuple(_args, ""))
  2195. return NULL;
  2196. _err = GetDataBrowserSortProperty(_self->ob_itself,
  2197. &property);
  2198. if (_err != noErr) return PyMac_Error(_err);
  2199. _res = Py_BuildValue("l",
  2200. property);
  2201. return _res;
  2202. }
  2203. static PyObject *CtlObj_SetDataBrowserSelectionFlags(ControlObject *_self, PyObject *_args)
  2204. {
  2205. PyObject *_res = NULL;
  2206. OSStatus _err;
  2207. UInt32 selectionFlags;
  2208. #ifndef SetDataBrowserSelectionFlags
  2209. PyMac_PRECHECK(SetDataBrowserSelectionFlags);
  2210. #endif
  2211. if (!PyArg_ParseTuple(_args, "l",
  2212. &selectionFlags))
  2213. return NULL;
  2214. _err = SetDataBrowserSelectionFlags(_self->ob_itself,
  2215. selectionFlags);
  2216. if (_err != noErr) return PyMac_Error(_err);
  2217. Py_INCREF(Py_None);
  2218. _res = Py_None;
  2219. return _res;
  2220. }
  2221. static PyObject *CtlObj_GetDataBrowserSelectionFlags(ControlObject *_self, PyObject *_args)
  2222. {
  2223. PyObject *_res = NULL;
  2224. OSStatus _err;
  2225. UInt32 selectionFlags;
  2226. #ifndef GetDataBrowserSelectionFlags
  2227. PyMac_PRECHECK(GetDataBrowserSelectionFlags);
  2228. #endif
  2229. if (!PyArg_ParseTuple(_args, ""))
  2230. return NULL;
  2231. _err = GetDataBrowserSelectionFlags(_self->ob_itself,
  2232. &selectionFlags);
  2233. if (_err != noErr) return PyMac_Error(_err);
  2234. _res = Py_BuildValue("l",
  2235. selectionFlags);
  2236. return _res;
  2237. }
  2238. static PyObject *CtlObj_SetDataBrowserPropertyFlags(ControlObject *_self, PyObject *_args)
  2239. {
  2240. PyObject *_res = NULL;
  2241. OSStatus _err;
  2242. UInt32 property;
  2243. UInt32 flags;
  2244. #ifndef SetDataBrowserPropertyFlags
  2245. PyMac_PRECHECK(SetDataBrowserPropertyFlags);
  2246. #endif
  2247. if (!PyArg_ParseTuple(_args, "ll",
  2248. &property,
  2249. &flags))
  2250. return NULL;
  2251. _err = SetDataBrowserPropertyFlags(_self->ob_itself,
  2252. property,
  2253. flags);
  2254. if (_err != noErr) return PyMac_Error(_err);
  2255. Py_INCREF(Py_None);
  2256. _res = Py_None;
  2257. return _res;
  2258. }
  2259. static PyObject *CtlObj_GetDataBrowserPropertyFlags(ControlObject *_self, PyObject *_args)
  2260. {
  2261. PyObject *_res = NULL;
  2262. OSStatus _err;
  2263. UInt32 property;
  2264. UInt32 flags;
  2265. #ifndef GetDataBrowserPropertyFlags
  2266. PyMac_PRECHECK(GetDataBrowserPropertyFlags);
  2267. #endif
  2268. if (!PyArg_ParseTuple(_args, "l",
  2269. &property))
  2270. return NULL;
  2271. _err = GetDataBrowserPropertyFlags(_self->ob_itself,
  2272. property,
  2273. &flags);
  2274. if (_err != noErr) return PyMac_Error(_err);
  2275. _res = Py_BuildValue("l",
  2276. flags);
  2277. return _res;
  2278. }
  2279. static PyObject *CtlObj_SetDataBrowserEditText(ControlObject *_self, PyObject *_args)
  2280. {
  2281. PyObject *_res = NULL;
  2282. OSStatus _err;
  2283. CFStringRef text;
  2284. #ifndef SetDataBrowserEditText
  2285. PyMac_PRECHECK(SetDataBrowserEditText);
  2286. #endif
  2287. if (!PyArg_ParseTuple(_args, "O&",
  2288. CFStringRefObj_Convert, &text))
  2289. return NULL;
  2290. _err = SetDataBrowserEditText(_self->ob_itself,
  2291. text);
  2292. if (_err != noErr) return PyMac_Error(_err);
  2293. Py_INCREF(Py_None);
  2294. _res = Py_None;
  2295. return _res;
  2296. }
  2297. static PyObject *CtlObj_CopyDataBrowserEditText(ControlObject *_self, PyObject *_args)
  2298. {
  2299. PyObject *_res = NULL;
  2300. OSStatus _err;
  2301. CFStringRef text;
  2302. #ifndef CopyDataBrowserEditText
  2303. PyMac_PRECHECK(CopyDataBrowserEditText);
  2304. #endif
  2305. if (!PyArg_ParseTuple(_args, ""))
  2306. return NULL;
  2307. _err = CopyDataBrowserEditText(_self->ob_itself,
  2308. &text);
  2309. if (_err != noErr) return PyMac_Error(_err);
  2310. _res = Py_BuildValue("O&",
  2311. CFStringRefObj_New, text);
  2312. return _res;
  2313. }
  2314. static PyObject *CtlObj_GetDataBrowserEditText(ControlObject *_self, PyObject *_args)
  2315. {
  2316. PyObject *_res = NULL;
  2317. OSStatus _err;
  2318. CFMutableStringRef text;
  2319. #ifndef GetDataBrowserEditText
  2320. PyMac_PRECHECK(GetDataBrowserEditText);
  2321. #endif
  2322. if (!PyArg_ParseTuple(_args, "O&",
  2323. CFMutableStringRefObj_Convert, &text))
  2324. return NULL;
  2325. _err = GetDataBrowserEditText(_self->ob_itself,
  2326. text);
  2327. if (_err != noErr) return PyMac_Error(_err);
  2328. Py_INCREF(Py_None);
  2329. _res = Py_None;
  2330. return _res;
  2331. }
  2332. static PyObject *CtlObj_SetDataBrowserEditItem(ControlObject *_self, PyObject *_args)
  2333. {
  2334. PyObject *_res = NULL;
  2335. OSStatus _err;
  2336. UInt32 item;
  2337. UInt32 property;
  2338. #ifndef SetDataBrowserEditItem
  2339. PyMac_PRECHECK(SetDataBrowserEditItem);
  2340. #endif
  2341. if (!PyArg_ParseTuple(_args, "ll",
  2342. &item,
  2343. &property))
  2344. return NULL;
  2345. _err = SetDataBrowserEditItem(_self->ob_itself,
  2346. item,
  2347. property);
  2348. if (_err != noErr) return PyMac_Error(_err);
  2349. Py_INCREF(Py_None);
  2350. _res = Py_None;
  2351. return _res;
  2352. }
  2353. static PyObject *CtlObj_GetDataBrowserEditItem(ControlObject *_self, PyObject *_args)
  2354. {
  2355. PyObject *_res = NULL;
  2356. OSStatus _err;
  2357. UInt32 item;
  2358. UInt32 property;
  2359. #ifndef GetDataBrowserEditItem
  2360. PyMac_PRECHECK(GetDataBrowserEditItem);
  2361. #endif
  2362. if (!PyArg_ParseTuple(_args, ""))
  2363. return NULL;
  2364. _err = GetDataBrowserEditItem(_self->ob_itself,
  2365. &item,
  2366. &property);
  2367. if (_err != noErr) return PyMac_Error(_err);
  2368. _res = Py_BuildValue("ll",
  2369. item,
  2370. property);
  2371. return _res;
  2372. }
  2373. static PyObject *CtlObj_GetDataBrowserItemPartBounds(ControlObject *_self, PyObject *_args)
  2374. {
  2375. PyObject *_res = NULL;
  2376. OSStatus _err;
  2377. UInt32 item;
  2378. UInt32 property;
  2379. OSType part;
  2380. Rect bounds;
  2381. #ifndef GetDataBrowserItemPartBounds
  2382. PyMac_PRECHECK(GetDataBrowserItemPartBounds);
  2383. #endif
  2384. if (!PyArg_ParseTuple(_args, "llO&",
  2385. &item,
  2386. &property,
  2387. PyMac_GetOSType, &part))
  2388. return NULL;
  2389. _err = GetDataBrowserItemPartBounds(_self->ob_itself,
  2390. item,
  2391. property,
  2392. part,
  2393. &bounds);
  2394. if (_err != noErr) return PyMac_Error(_err);
  2395. _res = Py_BuildValue("O&",
  2396. PyMac_BuildRect, &bounds);
  2397. return _res;
  2398. }
  2399. static PyObject *CtlObj_RemoveDataBrowserTableViewColumn(ControlObject *_self, PyObject *_args)
  2400. {
  2401. PyObject *_res = NULL;
  2402. OSStatus _err;
  2403. UInt32 column;
  2404. #ifndef RemoveDataBrowserTableViewColumn
  2405. PyMac_PRECHECK(RemoveDataBrowserTableViewColumn);
  2406. #endif
  2407. if (!PyArg_ParseTuple(_args, "l",
  2408. &column))
  2409. return NULL;
  2410. _err = RemoveDataBrowserTableViewColumn(_self->ob_itself,
  2411. column);
  2412. if (_err != noErr) return PyMac_Error(_err);
  2413. Py_INCREF(Py_None);
  2414. _res = Py_None;
  2415. return _res;
  2416. }
  2417. static PyObject *CtlObj_GetDataBrowserTableViewColumnCount(ControlObject *_self, PyObject *_args)
  2418. {
  2419. PyObject *_res = NULL;
  2420. OSStatus _err;
  2421. UInt32 numColumns;
  2422. #ifndef GetDataBrowserTableViewColumnCount
  2423. PyMac_PRECHECK(GetDataBrowserTableViewColumnCount);
  2424. #endif
  2425. if (!PyArg_ParseTuple(_args, ""))
  2426. return NULL;
  2427. _err = GetDataBrowserTableViewColumnCount(_self->ob_itself,
  2428. &numColumns);
  2429. if (_err != noErr) return PyMac_Error(_err);
  2430. _res = Py_BuildValue("l",
  2431. numColumns);
  2432. return _res;
  2433. }
  2434. static PyObject *CtlObj_SetDataBrowserTableViewHiliteStyle(ControlObject *_self, PyObject *_args)
  2435. {
  2436. PyObject *_res = NULL;
  2437. OSStatus _err;
  2438. UInt32 hiliteStyle;
  2439. #ifndef SetDataBrowserTableViewHiliteStyle
  2440. PyMac_PRECHECK(SetDataBrowserTableViewHiliteStyle);
  2441. #endif
  2442. if (!PyArg_ParseTuple(_args, "l",
  2443. &hiliteStyle))
  2444. return NULL;
  2445. _err = SetDataBrowserTableViewHiliteStyle(_self->ob_itself,
  2446. hiliteStyle);
  2447. if (_err != noErr) return PyMac_Error(_err);
  2448. Py_INCREF(Py_None);
  2449. _res = Py_None;
  2450. return _res;
  2451. }
  2452. static PyObject *CtlObj_GetDataBrowserTableViewHiliteStyle(ControlObject *_self, PyObject *_args)
  2453. {
  2454. PyObject *_res = NULL;
  2455. OSStatus _err;
  2456. UInt32 hiliteStyle;
  2457. #ifndef GetDataBrowserTableViewHiliteStyle
  2458. PyMac_PRECHECK(GetDataBrowserTableViewHiliteStyle);
  2459. #endif
  2460. if (!PyArg_ParseTuple(_args, ""))
  2461. return NULL;
  2462. _err = GetDataBrowserTableViewHiliteStyle(_self->ob_itself,
  2463. &hiliteStyle);
  2464. if (_err != noErr) return PyMac_Error(_err);
  2465. _res = Py_BuildValue("l",
  2466. hiliteStyle);
  2467. return _res;
  2468. }
  2469. static PyObject *CtlObj_SetDataBrowserTableViewRowHeight(ControlObject *_self, PyObject *_args)
  2470. {
  2471. PyObject *_res = NULL;
  2472. OSStatus _err;
  2473. UInt16 height;
  2474. #ifndef SetDataBrowserTableViewRowHeight
  2475. PyMac_PRECHECK(SetDataBrowserTableViewRowHeight);
  2476. #endif
  2477. if (!PyArg_ParseTuple(_args, "H",
  2478. &height))
  2479. return NULL;
  2480. _err = SetDataBrowserTableViewRowHeight(_self->ob_itself,
  2481. height);
  2482. if (_err != noErr) return PyMac_Error(_err);
  2483. Py_INCREF(Py_None);
  2484. _res = Py_None;
  2485. return _res;
  2486. }
  2487. static PyObject *CtlObj_GetDataBrowserTableViewRowHeight(ControlObject *_self, PyObject *_args)
  2488. {
  2489. PyObject *_res = NULL;
  2490. OSStatus _err;
  2491. UInt16 height;
  2492. #ifndef GetDataBrowserTableViewRowHeight
  2493. PyMac_PRECHECK(GetDataBrowserTableViewRowHeight);
  2494. #endif
  2495. if (!PyArg_ParseTuple(_args, ""))
  2496. return NULL;
  2497. _err = GetDataBrowserTableViewRowHeight(_self->ob_itself,
  2498. &height);
  2499. if (_err != noErr) return PyMac_Error(_err);
  2500. _res = Py_BuildValue("H",
  2501. height);
  2502. return _res;
  2503. }
  2504. static PyObject *CtlObj_SetDataBrowserTableViewColumnWidth(ControlObject *_self, PyObject *_args)
  2505. {
  2506. PyObject *_res = NULL;
  2507. OSStatus _err;
  2508. UInt16 width;
  2509. #ifndef SetDataBrowserTableViewColumnWidth
  2510. PyMac_PRECHECK(SetDataBrowserTableViewColumnWidth);
  2511. #endif
  2512. if (!PyArg_ParseTuple(_args, "H",
  2513. &width))
  2514. return NULL;
  2515. _err = SetDataBrowserTableViewColumnWidth(_self->ob_itself,
  2516. width);
  2517. if (_err != noErr) return PyMac_Error(_err);
  2518. Py_INCREF(Py_None);
  2519. _res = Py_None;
  2520. return _res;
  2521. }
  2522. static PyObject *CtlObj_GetDataBrowserTableViewColumnWidth(ControlObject *_self, PyObject *_args)
  2523. {
  2524. PyObject *_res = NULL;
  2525. OSStatus _err;
  2526. UInt16 width;
  2527. #ifndef GetDataBrowserTableViewColumnWidth
  2528. PyMac_PRECHECK(GetDataBrowserTableViewColumnWidth);
  2529. #endif
  2530. if (!PyArg_ParseTuple(_args, ""))
  2531. return NULL;
  2532. _err = GetDataBrowserTableViewColumnWidth(_self->ob_itself,
  2533. &width);
  2534. if (_err != noErr) return PyMac_Error(_err);
  2535. _res = Py_BuildValue("H",
  2536. width);
  2537. return _res;
  2538. }
  2539. static PyObject *CtlObj_SetDataBrowserTableViewItemRowHeight(ControlObject *_self, PyObject *_args)
  2540. {
  2541. PyObject *_res = NULL;
  2542. OSStatus _err;
  2543. UInt32 item;
  2544. UInt16 height;
  2545. #ifndef SetDataBrowserTableViewItemRowHeight
  2546. PyMac_PRECHECK(SetDataBrowserTableViewItemRowHeight);
  2547. #endif
  2548. if (!PyArg_ParseTuple(_args, "lH",
  2549. &item,
  2550. &height))
  2551. return NULL;
  2552. _err = SetDataBrowserTableViewItemRowHeight(_self->ob_itself,
  2553. item,
  2554. height);
  2555. if (_err != noErr) return PyMac_Error(_err);
  2556. Py_INCREF(Py_None);
  2557. _res = Py_None;
  2558. return _res;
  2559. }
  2560. static PyObject *CtlObj_GetDataBrowserTableViewItemRowHeight(ControlObject *_self, PyObject *_args)
  2561. {
  2562. PyObject *_res = NULL;
  2563. OSStatus _err;
  2564. UInt32 item;
  2565. UInt16 height;
  2566. #ifndef GetDataBrowserTableViewItemRowHeight
  2567. PyMac_PRECHECK(GetDataBrowserTableViewItemRowHeight);
  2568. #endif
  2569. if (!PyArg_ParseTuple(_args, "l",
  2570. &item))
  2571. return NULL;
  2572. _err = GetDataBrowserTableViewItemRowHeight(_self->ob_itself,
  2573. item,
  2574. &height);
  2575. if (_err != noErr) return PyMac_Error(_err);
  2576. _res = Py_BuildValue("H",
  2577. height);
  2578. return _res;
  2579. }
  2580. static PyObject *CtlObj_SetDataBrowserTableViewNamedColumnWidth(ControlObject *_self, PyObject *_args)
  2581. {
  2582. PyObject *_res = NULL;
  2583. OSStatus _err;
  2584. UInt32 column;
  2585. UInt16 width;
  2586. #ifndef SetDataBrowserTableViewNamedColumnWidth
  2587. PyMac_PRECHECK(SetDataBrowserTableViewNamedColumnWidth);
  2588. #endif
  2589. if (!PyArg_ParseTuple(_args, "lH",
  2590. &column,
  2591. &width))
  2592. return NULL;
  2593. _err = SetDataBrowserTableViewNamedColumnWidth(_self->ob_itself,
  2594. column,
  2595. width);
  2596. if (_err != noErr) return PyMac_Error(_err);
  2597. Py_INCREF(Py_None);
  2598. _res = Py_None;
  2599. return _res;
  2600. }
  2601. static PyObject *CtlObj_GetDataBrowserTableViewNamedColumnWidth(ControlObject *_self, PyObject *_args)
  2602. {
  2603. PyObject *_res = NULL;
  2604. OSStatus _err;
  2605. UInt32 column;
  2606. UInt16 width;
  2607. #ifndef GetDataBrowserTableViewNamedColumnWidth
  2608. PyMac_PRECHECK(GetDataBrowserTableViewNamedColumnWidth);
  2609. #endif
  2610. if (!PyArg_ParseTuple(_args, "l",
  2611. &column))
  2612. return NULL;
  2613. _err = GetDataBrowserTableViewNamedColumnWidth(_self->ob_itself,
  2614. column,
  2615. &width);
  2616. if (_err != noErr) return PyMac_Error(_err);
  2617. _res = Py_BuildValue("H",
  2618. width);
  2619. return _res;
  2620. }
  2621. static PyObject *CtlObj_SetDataBrowserTableViewGeometry(ControlObject *_self, PyObject *_args)
  2622. {
  2623. PyObject *_res = NULL;
  2624. OSStatus _err;
  2625. Boolean variableWidthColumns;
  2626. Boolean variableHeightRows;
  2627. #ifndef SetDataBrowserTableViewGeometry
  2628. PyMac_PRECHECK(SetDataBrowserTableViewGeometry);
  2629. #endif
  2630. if (!PyArg_ParseTuple(_args, "bb",
  2631. &variableWidthColumns,
  2632. &variableHeightRows))
  2633. return NULL;
  2634. _err = SetDataBrowserTableViewGeometry(_self->ob_itself,
  2635. variableWidthColumns,
  2636. variableHeightRows);
  2637. if (_err != noErr) return PyMac_Error(_err);
  2638. Py_INCREF(Py_None);
  2639. _res = Py_None;
  2640. return _res;
  2641. }
  2642. static PyObject *CtlObj_GetDataBrowserTableViewGeometry(ControlObject *_self, PyObject *_args)
  2643. {
  2644. PyObject *_res = NULL;
  2645. OSStatus _err;
  2646. Boolean variableWidthColumns;
  2647. Boolean variableHeightRows;
  2648. #ifndef GetDataBrowserTableViewGeometry
  2649. PyMac_PRECHECK(GetDataBrowserTableViewGeometry);
  2650. #endif
  2651. if (!PyArg_ParseTuple(_args, ""))
  2652. return NULL;
  2653. _err = GetDataBrowserTableViewGeometry(_self->ob_itself,
  2654. &variableWidthColumns,
  2655. &variableHeightRows);
  2656. if (_err != noErr) return PyMac_Error(_err);
  2657. _res = Py_BuildValue("bb",
  2658. variableWidthColumns,
  2659. variableHeightRows);
  2660. return _res;
  2661. }
  2662. static PyObject *CtlObj_GetDataBrowserTableViewItemID(ControlObject *_self, PyObject *_args)
  2663. {
  2664. PyObject *_res = NULL;
  2665. OSStatus _err;
  2666. UInt32 row;
  2667. UInt32 item;
  2668. #ifndef GetDataBrowserTableViewItemID
  2669. PyMac_PRECHECK(GetDataBrowserTableViewItemID);
  2670. #endif
  2671. if (!PyArg_ParseTuple(_args, "l",
  2672. &row))
  2673. return NULL;
  2674. _err = GetDataBrowserTableViewItemID(_self->ob_itself,
  2675. row,
  2676. &item);
  2677. if (_err != noErr) return PyMac_Error(_err);
  2678. _res = Py_BuildValue("l",
  2679. item);
  2680. return _res;
  2681. }
  2682. static PyObject *CtlObj_SetDataBrowserTableViewItemRow(ControlObject *_self, PyObject *_args)
  2683. {
  2684. PyObject *_res = NULL;
  2685. OSStatus _err;
  2686. UInt32 item;
  2687. UInt32 row;
  2688. #ifndef SetDataBrowserTableViewItemRow
  2689. PyMac_PRECHECK(SetDataBrowserTableViewItemRow);
  2690. #endif
  2691. if (!PyArg_ParseTuple(_args, "ll",
  2692. &item,
  2693. &row))
  2694. return NULL;
  2695. _err = SetDataBrowserTableViewItemRow(_self->ob_itself,
  2696. item,
  2697. row);
  2698. if (_err != noErr) return PyMac_Error(_err);
  2699. Py_INCREF(Py_None);
  2700. _res = Py_None;
  2701. return _res;
  2702. }
  2703. static PyObject *CtlObj_GetDataBrowserTableViewItemRow(ControlObject *_self, PyObject *_args)
  2704. {
  2705. PyObject *_res = NULL;
  2706. OSStatus _err;
  2707. UInt32 item;
  2708. UInt32 row;
  2709. #ifndef GetDataBrowserTableViewItemRow
  2710. PyMac_PRECHECK(GetDataBrowserTableViewItemRow);
  2711. #endif
  2712. if (!PyArg_ParseTuple(_args, "l",
  2713. &item))
  2714. return NULL;
  2715. _err = GetDataBrowserTableViewItemRow(_self->ob_itself,
  2716. item,
  2717. &row);
  2718. if (_err != noErr) return PyMac_Error(_err);
  2719. _res = Py_BuildValue("l",
  2720. row);
  2721. return _res;
  2722. }
  2723. static PyObject *CtlObj_SetDataBrowserTableViewColumnPosition(ControlObject *_self, PyObject *_args)
  2724. {
  2725. PyObject *_res = NULL;
  2726. OSStatus _err;
  2727. UInt32 column;
  2728. UInt32 position;
  2729. #ifndef SetDataBrowserTableViewColumnPosition
  2730. PyMac_PRECHECK(SetDataBrowserTableViewColumnPosition);
  2731. #endif
  2732. if (!PyArg_ParseTuple(_args, "ll",
  2733. &column,
  2734. &position))
  2735. return NULL;
  2736. _err = SetDataBrowserTableViewColumnPosition(_self->ob_itself,
  2737. column,
  2738. position);
  2739. if (_err != noErr) return PyMac_Error(_err);
  2740. Py_INCREF(Py_None);
  2741. _res = Py_None;
  2742. return _res;
  2743. }
  2744. static PyObject *CtlObj_GetDataBrowserTableViewColumnPosition(ControlObject *_self, PyObject *_args)
  2745. {
  2746. PyObject *_res = NULL;
  2747. OSStatus _err;
  2748. UInt32 column;
  2749. UInt32 position;
  2750. #ifndef GetDataBrowserTableViewColumnPosition
  2751. PyMac_PRECHECK(GetDataBrowserTableViewColumnPosition);
  2752. #endif
  2753. if (!PyArg_ParseTuple(_args, "l",
  2754. &column))
  2755. return NULL;
  2756. _err = GetDataBrowserTableViewColumnPosition(_self->ob_itself,
  2757. column,
  2758. &position);
  2759. if (_err != noErr) return PyMac_Error(_err);
  2760. _res = Py_BuildValue("l",
  2761. position);
  2762. return _res;
  2763. }
  2764. static PyObject *CtlObj_GetDataBrowserTableViewColumnProperty(ControlObject *_self, PyObject *_args)
  2765. {
  2766. PyObject *_res = NULL;
  2767. OSStatus _err;
  2768. UInt32 column;
  2769. UInt32 property;
  2770. #ifndef GetDataBrowserTableViewColumnProperty
  2771. PyMac_PRECHECK(GetDataBrowserTableViewColumnProperty);
  2772. #endif
  2773. if (!PyArg_ParseTuple(_args, "l",
  2774. &column))
  2775. return NULL;
  2776. _err = GetDataBrowserTableViewColumnProperty(_self->ob_itself,
  2777. column,
  2778. &property);
  2779. if (_err != noErr) return PyMac_Error(_err);
  2780. _res = Py_BuildValue("l",
  2781. property);
  2782. return _res;
  2783. }
  2784. static PyObject *CtlObj_AutoSizeDataBrowserListViewColumns(ControlObject *_self, PyObject *_args)
  2785. {
  2786. PyObject *_res = NULL;
  2787. OSStatus _err;
  2788. #ifndef AutoSizeDataBrowserListViewColumns
  2789. PyMac_PRECHECK(AutoSizeDataBrowserListViewColumns);
  2790. #endif
  2791. if (!PyArg_ParseTuple(_args, ""))
  2792. return NULL;
  2793. _err = AutoSizeDataBrowserListViewColumns(_self->ob_itself);
  2794. if (_err != noErr) return PyMac_Error(_err);
  2795. Py_INCREF(Py_None);
  2796. _res = Py_None;
  2797. return _res;
  2798. }
  2799. static PyObject *CtlObj_AddDataBrowserListViewColumn(ControlObject *_self, PyObject *_args)
  2800. {
  2801. PyObject *_res = NULL;
  2802. OSStatus _err;
  2803. DataBrowserListViewColumnDesc columnDesc;
  2804. UInt32 position;
  2805. #ifndef AddDataBrowserListViewColumn
  2806. PyMac_PRECHECK(AddDataBrowserListViewColumn);
  2807. #endif
  2808. if (!PyArg_ParseTuple(_args, "O&l",
  2809. DataBrowserListViewColumnDesc_Convert, &columnDesc,
  2810. &position))
  2811. return NULL;
  2812. _err = AddDataBrowserListViewColumn(_self->ob_itself,
  2813. &columnDesc,
  2814. position);
  2815. if (_err != noErr) return PyMac_Error(_err);
  2816. Py_INCREF(Py_None);
  2817. _res = Py_None;
  2818. return _res;
  2819. }
  2820. static PyObject *CtlObj_SetDataBrowserListViewHeaderBtnHeight(ControlObject *_self, PyObject *_args)
  2821. {
  2822. PyObject *_res = NULL;
  2823. OSStatus _err;
  2824. UInt16 height;
  2825. #ifndef SetDataBrowserListViewHeaderBtnHeight
  2826. PyMac_PRECHECK(SetDataBrowserListViewHeaderBtnHeight);
  2827. #endif
  2828. if (!PyArg_ParseTuple(_args, "H",
  2829. &height))
  2830. return NULL;
  2831. _err = SetDataBrowserListViewHeaderBtnHeight(_self->ob_itself,
  2832. height);
  2833. if (_err != noErr) return PyMac_Error(_err);
  2834. Py_INCREF(Py_None);
  2835. _res = Py_None;
  2836. return _res;
  2837. }
  2838. static PyObject *CtlObj_GetDataBrowserListViewHeaderBtnHeight(ControlObject *_self, PyObject *_args)
  2839. {
  2840. PyObject *_res = NULL;
  2841. OSStatus _err;
  2842. UInt16 height;
  2843. #ifndef GetDataBrowserListViewHeaderBtnHeight
  2844. PyMac_PRECHECK(GetDataBrowserListViewHeaderBtnHeight);
  2845. #endif
  2846. if (!PyArg_ParseTuple(_args, ""))
  2847. return NULL;
  2848. _err = GetDataBrowserListViewHeaderBtnHeight(_self->ob_itself,
  2849. &height);
  2850. if (_err != noErr) return PyMac_Error(_err);
  2851. _res = Py_BuildValue("H",
  2852. height);
  2853. return _res;
  2854. }
  2855. static PyObject *CtlObj_SetDataBrowserListViewUsePlainBackground(ControlObject *_self, PyObject *_args)
  2856. {
  2857. PyObject *_res = NULL;
  2858. OSStatus _err;
  2859. Boolean usePlainBackground;
  2860. #ifndef SetDataBrowserListViewUsePlainBackground
  2861. PyMac_PRECHECK(SetDataBrowserListViewUsePlainBackground);
  2862. #endif
  2863. if (!PyArg_ParseTuple(_args, "b",
  2864. &usePlainBackground))
  2865. return NULL;
  2866. _err = SetDataBrowserListViewUsePlainBackground(_self->ob_itself,
  2867. usePlainBackground);
  2868. if (_err != noErr) return PyMac_Error(_err);
  2869. Py_INCREF(Py_None);
  2870. _res = Py_None;
  2871. return _res;
  2872. }
  2873. static PyObject *CtlObj_GetDataBrowserListViewUsePlainBackground(ControlObject *_self, PyObject *_args)
  2874. {
  2875. PyObject *_res = NULL;
  2876. OSStatus _err;
  2877. Boolean usePlainBackground;
  2878. #ifndef GetDataBrowserListViewUsePlainBackground
  2879. PyMac_PRECHECK(GetDataBrowserListViewUsePlainBackground);
  2880. #endif
  2881. if (!PyArg_ParseTuple(_args, ""))
  2882. return NULL;
  2883. _err = GetDataBrowserListViewUsePlainBackground(_self->ob_itself,
  2884. &usePlainBackground);
  2885. if (_err != noErr) return PyMac_Error(_err);
  2886. _res = Py_BuildValue("b",
  2887. usePlainBackground);
  2888. return _res;
  2889. }
  2890. static PyObject *CtlObj_SetDataBrowserListViewDisclosureColumn(ControlObject *_self, PyObject *_args)
  2891. {
  2892. PyObject *_res = NULL;
  2893. OSStatus _err;
  2894. UInt32 column;
  2895. Boolean expandableRows;
  2896. #ifndef SetDataBrowserListViewDisclosureColumn
  2897. PyMac_PRECHECK(SetDataBrowserListViewDisclosureColumn);
  2898. #endif
  2899. if (!PyArg_ParseTuple(_args, "lb",
  2900. &column,
  2901. &expandableRows))
  2902. return NULL;
  2903. _err = SetDataBrowserListViewDisclosureColumn(_self->ob_itself,
  2904. column,
  2905. expandableRows);
  2906. if (_err != noErr) return PyMac_Error(_err);
  2907. Py_INCREF(Py_None);
  2908. _res = Py_None;
  2909. return _res;
  2910. }
  2911. static PyObject *CtlObj_GetDataBrowserListViewDisclosureColumn(ControlObject *_self, PyObject *_args)
  2912. {
  2913. PyObject *_res = NULL;
  2914. OSStatus _err;
  2915. UInt32 column;
  2916. Boolean expandableRows;
  2917. #ifndef GetDataBrowserListViewDisclosureColumn
  2918. PyMac_PRECHECK(GetDataBrowserListViewDisclosureColumn);
  2919. #endif
  2920. if (!PyArg_ParseTuple(_args, ""))
  2921. return NULL;
  2922. _err = GetDataBrowserListViewDisclosureColumn(_self->ob_itself,
  2923. &column,
  2924. &expandableRows);
  2925. if (_err != noErr) return PyMac_Error(_err);
  2926. _res = Py_BuildValue("lb",
  2927. column,
  2928. expandableRows);
  2929. return _res;
  2930. }
  2931. static PyObject *CtlObj_GetDataBrowserColumnViewPath(ControlObject *_self, PyObject *_args)
  2932. {
  2933. PyObject *_res = NULL;
  2934. OSStatus _err;
  2935. Handle path;
  2936. #ifndef GetDataBrowserColumnViewPath
  2937. PyMac_PRECHECK(GetDataBrowserColumnViewPath);
  2938. #endif
  2939. if (!PyArg_ParseTuple(_args, "O&",
  2940. ResObj_Convert, &path))
  2941. return NULL;
  2942. _err = GetDataBrowserColumnViewPath(_self->ob_itself,
  2943. path);
  2944. if (_err != noErr) return PyMac_Error(_err);
  2945. Py_INCREF(Py_None);
  2946. _res = Py_None;
  2947. return _res;
  2948. }
  2949. static PyObject *CtlObj_GetDataBrowserColumnViewPathLength(ControlObject *_self, PyObject *_args)
  2950. {
  2951. PyObject *_res = NULL;
  2952. OSStatus _err;
  2953. UInt32 pathLength;
  2954. #ifndef GetDataBrowserColumnViewPathLength
  2955. PyMac_PRECHECK(GetDataBrowserColumnViewPathLength);
  2956. #endif
  2957. if (!PyArg_ParseTuple(_args, ""))
  2958. return NULL;
  2959. _err = GetDataBrowserColumnViewPathLength(_self->ob_itself,
  2960. &pathLength);
  2961. if (_err != noErr) return PyMac_Error(_err);
  2962. _res = Py_BuildValue("l",
  2963. pathLength);
  2964. return _res;
  2965. }
  2966. static PyObject *CtlObj_SetDataBrowserColumnViewDisplayType(ControlObject *_self, PyObject *_args)
  2967. {
  2968. PyObject *_res = NULL;
  2969. OSStatus _err;
  2970. OSType propertyType;
  2971. #ifndef SetDataBrowserColumnViewDisplayType
  2972. PyMac_PRECHECK(SetDataBrowserColumnViewDisplayType);
  2973. #endif
  2974. if (!PyArg_ParseTuple(_args, "O&",
  2975. PyMac_GetOSType, &propertyType))
  2976. return NULL;
  2977. _err = SetDataBrowserColumnViewDisplayType(_self->ob_itself,
  2978. propertyType);
  2979. if (_err != noErr) return PyMac_Error(_err);
  2980. Py_INCREF(Py_None);
  2981. _res = Py_None;
  2982. return _res;
  2983. }
  2984. static PyObject *CtlObj_GetDataBrowserColumnViewDisplayType(ControlObject *_self, PyObject *_args)
  2985. {
  2986. PyObject *_res = NULL;
  2987. OSStatus _err;
  2988. OSType propertyType;
  2989. #ifndef GetDataBrowserColumnViewDisplayType
  2990. PyMac_PRECHECK(GetDataBrowserColumnViewDisplayType);
  2991. #endif
  2992. if (!PyArg_ParseTuple(_args, ""))
  2993. return NULL;
  2994. _err = GetDataBrowserColumnViewDisplayType(_self->ob_itself,
  2995. &propertyType);
  2996. if (_err != noErr) return PyMac_Error(_err);
  2997. _res = Py_BuildValue("O&",
  2998. PyMac_BuildOSType, propertyType);
  2999. return _res;
  3000. }
  3001. static PyObject *CtlObj_as_Resource(ControlObject *_self, PyObject *_args)
  3002. {
  3003. PyObject *_res = NULL;
  3004. Handle _rv;
  3005. #ifndef as_Resource
  3006. PyMac_PRECHECK(as_Resource);
  3007. #endif
  3008. if (!PyArg_ParseTuple(_args, ""))
  3009. return NULL;
  3010. _rv = as_Resource(_self->ob_itself);
  3011. _res = Py_BuildValue("O&",
  3012. ResObj_New, _rv);
  3013. return _res;
  3014. }
  3015. static PyObject *CtlObj_GetControlRect(ControlObject *_self, PyObject *_args)
  3016. {
  3017. PyObject *_res = NULL;
  3018. Rect rect;
  3019. #ifndef GetControlRect
  3020. PyMac_PRECHECK(GetControlRect);
  3021. #endif
  3022. if (!PyArg_ParseTuple(_args, ""))
  3023. return NULL;
  3024. GetControlRect(_self->ob_itself,
  3025. &rect);
  3026. _res = Py_BuildValue("O&",
  3027. PyMac_BuildRect, &rect);
  3028. return _res;
  3029. }
  3030. static PyObject *CtlObj_DisposeControl(ControlObject *_self, PyObject *_args)
  3031. {
  3032. PyObject *_res = NULL;
  3033. if (!PyArg_ParseTuple(_args, ""))
  3034. return NULL;
  3035. if ( _self->ob_itself ) {
  3036. SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
  3037. DisposeControl(_self->ob_itself);
  3038. _self->ob_itself = NULL;
  3039. }
  3040. Py_INCREF(Py_None);
  3041. _res = Py_None;
  3042. return _res;
  3043. }
  3044. static PyObject *CtlObj_TrackControl(ControlObject *_self, PyObject *_args)
  3045. {
  3046. PyObject *_res = NULL;
  3047. ControlPartCode _rv;
  3048. Point startPoint;
  3049. ControlActionUPP upp = 0;
  3050. PyObject *callback = 0;
  3051. if (!PyArg_ParseTuple(_args, "O&|O",
  3052. PyMac_GetPoint, &startPoint, &callback))
  3053. return NULL;
  3054. if (callback && callback != Py_None) {
  3055. if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
  3056. upp = (ControlActionUPP)-1;
  3057. else {
  3058. settrackfunc(callback);
  3059. upp = mytracker_upp;
  3060. }
  3061. }
  3062. _rv = TrackControl(_self->ob_itself,
  3063. startPoint,
  3064. upp);
  3065. clrtrackfunc();
  3066. _res = Py_BuildValue("h",
  3067. _rv);
  3068. return _res;
  3069. }
  3070. static PyObject *CtlObj_HandleControlClick(ControlObject *_self, PyObject *_args)
  3071. {
  3072. PyObject *_res = NULL;
  3073. ControlPartCode _rv;
  3074. Point startPoint;
  3075. SInt16 modifiers;
  3076. ControlActionUPP upp = 0;
  3077. PyObject *callback = 0;
  3078. if (!PyArg_ParseTuple(_args, "O&h|O",
  3079. PyMac_GetPoint, &startPoint,
  3080. &modifiers,
  3081. &callback))
  3082. return NULL;
  3083. if (callback && callback != Py_None) {
  3084. if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
  3085. upp = (ControlActionUPP)-1;
  3086. else {
  3087. settrackfunc(callback);
  3088. upp = mytracker_upp;
  3089. }
  3090. }
  3091. _rv = HandleControlClick(_self->ob_itself,
  3092. startPoint,
  3093. modifiers,
  3094. upp);
  3095. clrtrackfunc();
  3096. _res = Py_BuildValue("h",
  3097. _rv);
  3098. return _res;
  3099. }
  3100. static PyObject *CtlObj_SetControlData(ControlObject *_self, PyObject *_args)
  3101. {
  3102. PyObject *_res = NULL;
  3103. OSErr _err;
  3104. ControlPartCode inPart;
  3105. ResType inTagName;
  3106. Size bufferSize;
  3107. Ptr buffer;
  3108. if (!PyArg_ParseTuple(_args, "hO&s#",
  3109. &inPart,
  3110. PyMac_GetOSType, &inTagName,
  3111. &buffer, &bufferSize))
  3112. return NULL;
  3113. _err = SetControlData(_self->ob_itself,
  3114. inPart,
  3115. inTagName,
  3116. bufferSize,
  3117. buffer);
  3118. if (_err != noErr)
  3119. return PyMac_Error(_err);
  3120. _res = Py_None;
  3121. return _res;
  3122. }
  3123. static PyObject *CtlObj_GetControlData(ControlObject *_self, PyObject *_args)
  3124. {
  3125. PyObject *_res = NULL;
  3126. OSErr _err;
  3127. ControlPartCode inPart;
  3128. ResType inTagName;
  3129. Size bufferSize;
  3130. Ptr buffer;
  3131. Size outSize;
  3132. if (!PyArg_ParseTuple(_args, "hO&",
  3133. &inPart,
  3134. PyMac_GetOSType, &inTagName))
  3135. return NULL;
  3136. /* allocate a buffer for the data */
  3137. _err = GetControlDataSize(_self->ob_itself,
  3138. inPart,
  3139. inTagName,
  3140. &bufferSize);
  3141. if (_err != noErr)
  3142. return PyMac_Error(_err);
  3143. buffer = PyMem_NEW(char, bufferSize);
  3144. if (buffer == NULL)
  3145. return PyErr_NoMemory();
  3146. _err = GetControlData(_self->ob_itself,
  3147. inPart,
  3148. inTagName,
  3149. bufferSize,
  3150. buffer,
  3151. &outSize);
  3152. if (_err != noErr) {
  3153. PyMem_DEL(buffer);
  3154. return PyMac_Error(_err);
  3155. }
  3156. _res = Py_BuildValue("s#", buffer, outSize);
  3157. PyMem_DEL(buffer);
  3158. return _res;
  3159. }
  3160. static PyObject *CtlObj_SetControlData_Handle(ControlObject *_self, PyObject *_args)
  3161. {
  3162. PyObject *_res = NULL;
  3163. OSErr _err;
  3164. ControlPartCode inPart;
  3165. ResType inTagName;
  3166. Handle buffer;
  3167. if (!PyArg_ParseTuple(_args, "hO&O&",
  3168. &inPart,
  3169. PyMac_GetOSType, &inTagName,
  3170. OptResObj_Convert, &buffer))
  3171. return NULL;
  3172. _err = SetControlData(_self->ob_itself,
  3173. inPart,
  3174. inTagName,
  3175. sizeof(buffer),
  3176. (Ptr)&buffer);
  3177. if (_err != noErr)
  3178. return PyMac_Error(_err);
  3179. _res = Py_None;
  3180. return _res;
  3181. }
  3182. static PyObject *CtlObj_GetControlData_Handle(ControlObject *_self, PyObject *_args)
  3183. {
  3184. PyObject *_res = NULL;
  3185. OSErr _err;
  3186. ControlPartCode inPart;
  3187. ResType inTagName;
  3188. Size bufferSize;
  3189. Handle hdl;
  3190. if (!PyArg_ParseTuple(_args, "hO&",
  3191. &inPart,
  3192. PyMac_GetOSType, &inTagName))
  3193. return NULL;
  3194. /* Check it is handle-sized */
  3195. _err = GetControlDataSize(_self->ob_itself,
  3196. inPart,
  3197. inTagName,
  3198. &bufferSize);
  3199. if (_err != noErr)
  3200. return PyMac_Error(_err);
  3201. if (bufferSize != sizeof(Handle)) {
  3202. PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
  3203. return NULL;
  3204. }
  3205. _err = GetControlData(_self->ob_itself,
  3206. inPart,
  3207. inTagName,
  3208. sizeof(Handle),
  3209. (Ptr)&hdl,
  3210. &bufferSize);
  3211. if (_err != noErr) {
  3212. return PyMac_Error(_err);
  3213. }
  3214. _res = Py_BuildValue("O&", OptResObj_New, hdl);
  3215. return _res;
  3216. }
  3217. static PyObject *CtlObj_SetControlData_Callback(ControlObject *_self, PyObject *_args)
  3218. {
  3219. PyObject *_res = NULL;
  3220. OSErr _err;
  3221. ControlPartCode inPart;
  3222. ResType inTagName;
  3223. PyObject *callback;
  3224. UniversalProcPtr c_callback;
  3225. if (!PyArg_ParseTuple(_args, "hO&O",
  3226. &inPart,
  3227. PyMac_GetOSType, &inTagName,
  3228. &callback))
  3229. return NULL;
  3230. if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
  3231. return NULL;
  3232. _err = SetControlData(_self->ob_itself,
  3233. inPart,
  3234. inTagName,
  3235. sizeof(c_callback),
  3236. (Ptr)&c_callback);
  3237. if (_err != noErr)
  3238. return PyMac_Error(_err);
  3239. _res = Py_None;
  3240. return _res;
  3241. }
  3242. static PyMethodDef CtlObj_methods[] = {
  3243. {"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1,
  3244. PyDoc_STR("(ControlPartCode hiliteState) -> None")},
  3245. {"ShowControl", (PyCFunction)CtlObj_ShowControl, 1,
  3246. PyDoc_STR("() -> None")},
  3247. {"HideControl", (PyCFunction)CtlObj_HideControl, 1,
  3248. PyDoc_STR("() -> None")},
  3249. {"IsControlActive", (PyCFunction)CtlObj_IsControlActive, 1,
  3250. PyDoc_STR("() -> (Boolean _rv)")},
  3251. {"IsControlVisible", (PyCFunction)CtlObj_IsControlVisible, 1,
  3252. PyDoc_STR("() -> (Boolean _rv)")},
  3253. {"ActivateControl", (PyCFunction)CtlObj_ActivateControl, 1,
  3254. PyDoc_STR("() -> None")},
  3255. {"DeactivateControl", (PyCFunction)CtlObj_DeactivateControl, 1,
  3256. PyDoc_STR("() -> None")},
  3257. {"SetControlVisibility", (PyCFunction)CtlObj_SetControlVisibility, 1,
  3258. PyDoc_STR("(Boolean inIsVisible, Boolean inDoDraw) -> None")},
  3259. {"IsControlEnabled", (PyCFunction)CtlObj_IsControlEnabled, 1,
  3260. PyDoc_STR("() -> (Boolean _rv)")},
  3261. {"EnableControl", (PyCFunction)CtlObj_EnableControl, 1,
  3262. PyDoc_STR("() -> None")},
  3263. {"DisableControl", (PyCFunction)CtlObj_DisableControl, 1,
  3264. PyDoc_STR("() -> None")},
  3265. {"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1,
  3266. PyDoc_STR("() -> None")},
  3267. {"GetBestControlRect", (PyCFunction)CtlObj_GetBestControlRect, 1,
  3268. PyDoc_STR("() -> (Rect outRect, SInt16 outBaseLineOffset)")},
  3269. {"SetControlFontStyle", (PyCFunction)CtlObj_SetControlFontStyle, 1,
  3270. PyDoc_STR("(ControlFontStyleRec inStyle) -> None")},
  3271. {"DrawControlInCurrentPort", (PyCFunction)CtlObj_DrawControlInCurrentPort, 1,
  3272. PyDoc_STR("() -> None")},
  3273. {"SetUpControlBackground", (PyCFunction)CtlObj_SetUpControlBackground, 1,
  3274. PyDoc_STR("(SInt16 inDepth, Boolean inIsColorDevice) -> None")},
  3275. {"SetUpControlTextColor", (PyCFunction)CtlObj_SetUpControlTextColor, 1,
  3276. PyDoc_STR("(SInt16 inDepth, Boolean inIsColorDevice) -> None")},
  3277. {"DragControl", (PyCFunction)CtlObj_DragControl, 1,
  3278. PyDoc_STR("(Point startPoint, Rect limitRect, Rect slopRect, DragConstraint axis) -> None")},
  3279. {"TestControl", (PyCFunction)CtlObj_TestControl, 1,
  3280. PyDoc_STR("(Point testPoint) -> (ControlPartCode _rv)")},
  3281. {"HandleControlContextualMenuClick", (PyCFunction)CtlObj_HandleControlContextualMenuClick, 1,
  3282. PyDoc_STR("(Point inWhere) -> (Boolean menuDisplayed)")},
  3283. {"GetControlClickActivation", (PyCFunction)CtlObj_GetControlClickActivation, 1,
  3284. PyDoc_STR("(Point inWhere, EventModifiers inModifiers) -> (ClickActivationResult outResult)")},
  3285. {"HandleControlKey", (PyCFunction)CtlObj_HandleControlKey, 1,
  3286. PyDoc_STR("(SInt16 inKeyCode, SInt16 inCharCode, EventModifiers inModifiers) -> (ControlPartCode _rv)")},
  3287. {"HandleControlSetCursor", (PyCFunction)CtlObj_HandleControlSetCursor, 1,
  3288. PyDoc_STR("(Point localPoint, EventModifiers modifiers) -> (Boolean cursorWasSet)")},
  3289. {"MoveControl", (PyCFunction)CtlObj_MoveControl, 1,
  3290. PyDoc_STR("(SInt16 h, SInt16 v) -> None")},
  3291. {"SizeControl", (PyCFunction)CtlObj_SizeControl, 1,
  3292. PyDoc_STR("(SInt16 w, SInt16 h) -> None")},
  3293. {"SetControlTitle", (PyCFunction)CtlObj_SetControlTitle, 1,
  3294. PyDoc_STR("(Str255 title) -> None")},
  3295. {"GetControlTitle", (PyCFunction)CtlObj_GetControlTitle, 1,
  3296. PyDoc_STR("() -> (Str255 title)")},
  3297. {"SetControlTitleWithCFString", (PyCFunction)CtlObj_SetControlTitleWithCFString, 1,
  3298. PyDoc_STR("(CFStringRef inString) -> None")},
  3299. {"CopyControlTitleAsCFString", (PyCFunction)CtlObj_CopyControlTitleAsCFString, 1,
  3300. PyDoc_STR("() -> (CFStringRef outString)")},
  3301. {"GetControlValue", (PyCFunction)CtlObj_GetControlValue, 1,
  3302. PyDoc_STR("() -> (SInt16 _rv)")},
  3303. {"SetControlValue", (PyCFunction)CtlObj_SetControlValue, 1,
  3304. PyDoc_STR("(SInt16 newValue) -> None")},
  3305. {"GetControlMinimum", (PyCFunction)CtlObj_GetControlMinimum, 1,
  3306. PyDoc_STR("() -> (SInt16 _rv)")},
  3307. {"SetControlMinimum", (PyCFunction)CtlObj_SetControlMinimum, 1,
  3308. PyDoc_STR("(SInt16 newMinimum) -> None")},
  3309. {"GetControlMaximum", (PyCFunction)CtlObj_GetControlMaximum, 1,
  3310. PyDoc_STR("() -> (SInt16 _rv)")},
  3311. {"SetControlMaximum", (PyCFunction)CtlObj_SetControlMaximum, 1,
  3312. PyDoc_STR("(SInt16 newMaximum) -> None")},
  3313. {"GetControlViewSize", (PyCFunction)CtlObj_GetControlViewSize, 1,
  3314. PyDoc_STR("() -> (SInt32 _rv)")},
  3315. {"SetControlViewSize", (PyCFunction)CtlObj_SetControlViewSize, 1,
  3316. PyDoc_STR("(SInt32 newViewSize) -> None")},
  3317. {"GetControl32BitValue", (PyCFunction)CtlObj_GetControl32BitValue, 1,
  3318. PyDoc_STR("() -> (SInt32 _rv)")},
  3319. {"SetControl32BitValue", (PyCFunction)CtlObj_SetControl32BitValue, 1,
  3320. PyDoc_STR("(SInt32 newValue) -> None")},
  3321. {"GetControl32BitMaximum", (PyCFunction)CtlObj_GetControl32BitMaximum, 1,
  3322. PyDoc_STR("() -> (SInt32 _rv)")},
  3323. {"SetControl32BitMaximum", (PyCFunction)CtlObj_SetControl32BitMaximum, 1,
  3324. PyDoc_STR("(SInt32 newMaximum) -> None")},
  3325. {"GetControl32BitMinimum", (PyCFunction)CtlObj_GetControl32BitMinimum, 1,
  3326. PyDoc_STR("() -> (SInt32 _rv)")},
  3327. {"SetControl32BitMinimum", (PyCFunction)CtlObj_SetControl32BitMinimum, 1,
  3328. PyDoc_STR("(SInt32 newMinimum) -> None")},
  3329. {"IsValidControlHandle", (PyCFunction)CtlObj_IsValidControlHandle, 1,
  3330. PyDoc_STR("() -> (Boolean _rv)")},
  3331. {"SetControlID", (PyCFunction)CtlObj_SetControlID, 1,
  3332. PyDoc_STR("(ControlID inID) -> None")},
  3333. {"GetControlID", (PyCFunction)CtlObj_GetControlID, 1,
  3334. PyDoc_STR("() -> (ControlID outID)")},
  3335. {"SetControlCommandID", (PyCFunction)CtlObj_SetControlCommandID, 1,
  3336. PyDoc_STR("(UInt32 inCommandID) -> None")},
  3337. {"GetControlCommandID", (PyCFunction)CtlObj_GetControlCommandID, 1,
  3338. PyDoc_STR("() -> (UInt32 outCommandID)")},
  3339. {"RemoveControlProperty", (PyCFunction)CtlObj_RemoveControlProperty, 1,
  3340. PyDoc_STR("(OSType propertyCreator, OSType propertyTag) -> None")},
  3341. {"GetControlPropertyAttributes", (PyCFunction)CtlObj_GetControlPropertyAttributes, 1,
  3342. PyDoc_STR("(OSType propertyCreator, OSType propertyTag) -> (UInt32 attributes)")},
  3343. {"ChangeControlPropertyAttributes", (PyCFunction)CtlObj_ChangeControlPropertyAttributes, 1,
  3344. PyDoc_STR("(OSType propertyCreator, OSType propertyTag, UInt32 attributesToSet, UInt32 attributesToClear) -> None")},
  3345. {"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1,
  3346. PyDoc_STR("(ControlPartCode inPart, RgnHandle outRegion) -> None")},
  3347. {"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1,
  3348. PyDoc_STR("() -> (ControlVariant _rv)")},
  3349. {"SetControlAction", (PyCFunction)CtlObj_SetControlAction, 1,
  3350. PyDoc_STR("(PyObject* actionProc) -> None")},
  3351. {"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1,
  3352. PyDoc_STR("(SInt32 data) -> None")},
  3353. {"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1,
  3354. PyDoc_STR("() -> (SInt32 _rv)")},
  3355. {"EmbedControl", (PyCFunction)CtlObj_EmbedControl, 1,
  3356. PyDoc_STR("(ControlHandle inContainer) -> None")},
  3357. {"AutoEmbedControl", (PyCFunction)CtlObj_AutoEmbedControl, 1,
  3358. PyDoc_STR("(WindowPtr inWindow) -> None")},
  3359. {"GetSuperControl", (PyCFunction)CtlObj_GetSuperControl, 1,
  3360. PyDoc_STR("() -> (ControlHandle outParent)")},
  3361. {"CountSubControls", (PyCFunction)CtlObj_CountSubControls, 1,
  3362. PyDoc_STR("() -> (UInt16 outNumChildren)")},
  3363. {"GetIndexedSubControl", (PyCFunction)CtlObj_GetIndexedSubControl, 1,
  3364. PyDoc_STR("(UInt16 inIndex) -> (ControlHandle outSubControl)")},
  3365. {"SetControlSupervisor", (PyCFunction)CtlObj_SetControlSupervisor, 1,
  3366. PyDoc_STR("(ControlHandle inBoss) -> None")},
  3367. {"GetControlFeatures", (PyCFunction)CtlObj_GetControlFeatures, 1,
  3368. PyDoc_STR("() -> (UInt32 outFeatures)")},
  3369. {"GetControlDataSize", (PyCFunction)CtlObj_GetControlDataSize, 1,
  3370. PyDoc_STR("(ControlPartCode inPart, ResType inTagName) -> (Size outMaxSize)")},
  3371. {"HandleControlDragTracking", (PyCFunction)CtlObj_HandleControlDragTracking, 1,
  3372. PyDoc_STR("(DragTrackingMessage inMessage, DragReference inDrag) -> (Boolean outLikesDrag)")},
  3373. {"HandleControlDragReceive", (PyCFunction)CtlObj_HandleControlDragReceive, 1,
  3374. PyDoc_STR("(DragReference inDrag) -> None")},
  3375. {"SetControlDragTrackingEnabled", (PyCFunction)CtlObj_SetControlDragTrackingEnabled, 1,
  3376. PyDoc_STR("(Boolean inTracks) -> None")},
  3377. {"IsControlDragTrackingEnabled", (PyCFunction)CtlObj_IsControlDragTrackingEnabled, 1,
  3378. PyDoc_STR("() -> (Boolean outTracks)")},
  3379. {"GetControlBounds", (PyCFunction)CtlObj_GetControlBounds, 1,
  3380. PyDoc_STR("() -> (Rect bounds)")},
  3381. {"IsControlHilited", (PyCFunction)CtlObj_IsControlHilited, 1,
  3382. PyDoc_STR("() -> (Boolean _rv)")},
  3383. {"GetControlHilite", (PyCFunction)CtlObj_GetControlHilite, 1,
  3384. PyDoc_STR("() -> (UInt16 _rv)")},
  3385. {"GetControlOwner", (PyCFunction)CtlObj_GetControlOwner, 1,
  3386. PyDoc_STR("() -> (WindowPtr _rv)")},
  3387. {"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1,
  3388. PyDoc_STR("() -> (Handle _rv)")},
  3389. {"GetControlPopupMenuHandle", (PyCFunction)CtlObj_GetControlPopupMenuHandle, 1,
  3390. PyDoc_STR("() -> (MenuHandle _rv)")},
  3391. {"GetControlPopupMenuID", (PyCFunction)CtlObj_GetControlPopupMenuID, 1,
  3392. PyDoc_STR("() -> (short _rv)")},
  3393. {"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1,
  3394. PyDoc_STR("(Handle dataHandle) -> None")},
  3395. {"SetControlBounds", (PyCFunction)CtlObj_SetControlBounds, 1,
  3396. PyDoc_STR("(Rect bounds) -> None")},
  3397. {"SetControlPopupMenuHandle", (PyCFunction)CtlObj_SetControlPopupMenuHandle, 1,
  3398. PyDoc_STR("(MenuHandle popupMenu) -> None")},
  3399. {"SetControlPopupMenuID", (PyCFunction)CtlObj_SetControlPopupMenuID, 1,
  3400. PyDoc_STR("(short menuID) -> None")},
  3401. {"GetBevelButtonMenuValue", (PyCFunction)CtlObj_GetBevelButtonMenuValue, 1,
  3402. PyDoc_STR("() -> (SInt16 outValue)")},
  3403. {"SetBevelButtonMenuValue", (PyCFunction)CtlObj_SetBevelButtonMenuValue, 1,
  3404. PyDoc_STR("(SInt16 inValue) -> None")},
  3405. {"GetBevelButtonMenuHandle", (PyCFunction)CtlObj_GetBevelButtonMenuHandle, 1,
  3406. PyDoc_STR("() -> (MenuHandle outHandle)")},
  3407. {"SetBevelButtonContentInfo", (PyCFunction)CtlObj_SetBevelButtonContentInfo, 1,
  3408. PyDoc_STR("(ControlButtonContentInfo inContent) -> None")},
  3409. {"SetBevelButtonTransform", (PyCFunction)CtlObj_SetBevelButtonTransform, 1,
  3410. PyDoc_STR("(IconTransformType transform) -> None")},
  3411. {"SetDisclosureTriangleLastValue", (PyCFunction)CtlObj_SetDisclosureTriangleLastValue, 1,
  3412. PyDoc_STR("(SInt16 inValue) -> None")},
  3413. {"GetTabContentRect", (PyCFunction)CtlObj_GetTabContentRect, 1,
  3414. PyDoc_STR("() -> (Rect outContentRect)")},
  3415. {"SetTabEnabled", (PyCFunction)CtlObj_SetTabEnabled, 1,
  3416. PyDoc_STR("(SInt16 inTabToHilite, Boolean inEnabled) -> None")},
  3417. {"SetImageWellContentInfo", (PyCFunction)CtlObj_SetImageWellContentInfo, 1,
  3418. PyDoc_STR("(ControlButtonContentInfo inContent) -> None")},
  3419. {"SetImageWellTransform", (PyCFunction)CtlObj_SetImageWellTransform, 1,
  3420. PyDoc_STR("(IconTransformType inTransform) -> None")},
  3421. {"GetDataBrowserViewStyle", (PyCFunction)CtlObj_GetDataBrowserViewStyle, 1,
  3422. PyDoc_STR("() -> (OSType style)")},
  3423. {"SetDataBrowserViewStyle", (PyCFunction)CtlObj_SetDataBrowserViewStyle, 1,
  3424. PyDoc_STR("(OSType style) -> None")},
  3425. {"EnableDataBrowserEditCommand", (PyCFunction)CtlObj_EnableDataBrowserEditCommand, 1,
  3426. PyDoc_STR("(UInt32 command) -> (Boolean _rv)")},
  3427. {"ExecuteDataBrowserEditCommand", (PyCFunction)CtlObj_ExecuteDataBrowserEditCommand, 1,
  3428. PyDoc_STR("(UInt32 command) -> None")},
  3429. {"GetDataBrowserSelectionAnchor", (PyCFunction)CtlObj_GetDataBrowserSelectionAnchor, 1,
  3430. PyDoc_STR("() -> (UInt32 first, UInt32 last)")},
  3431. {"MoveDataBrowserSelectionAnchor", (PyCFunction)CtlObj_MoveDataBrowserSelectionAnchor, 1,
  3432. PyDoc_STR("(UInt32 direction, Boolean extendSelection) -> None")},
  3433. {"OpenDataBrowserContainer", (PyCFunction)CtlObj_OpenDataBrowserContainer, 1,
  3434. PyDoc_STR("(UInt32 container) -> None")},
  3435. {"CloseDataBrowserContainer", (PyCFunction)CtlObj_CloseDataBrowserContainer, 1,
  3436. PyDoc_STR("(UInt32 container) -> None")},
  3437. {"SortDataBrowserContainer", (PyCFunction)CtlObj_SortDataBrowserContainer, 1,
  3438. PyDoc_STR("(UInt32 container, Boolean sortChildren) -> None")},
  3439. {"GetDataBrowserItems", (PyCFunction)CtlObj_GetDataBrowserItems, 1,
  3440. PyDoc_STR("(UInt32 container, Boolean recurse, UInt32 state, Handle items) -> None")},
  3441. {"GetDataBrowserItemCount", (PyCFunction)CtlObj_GetDataBrowserItemCount, 1,
  3442. PyDoc_STR("(UInt32 container, Boolean recurse, UInt32 state) -> (UInt32 numItems)")},
  3443. {"IsDataBrowserItemSelected", (PyCFunction)CtlObj_IsDataBrowserItemSelected, 1,
  3444. PyDoc_STR("(UInt32 item) -> (Boolean _rv)")},
  3445. {"GetDataBrowserItemState", (PyCFunction)CtlObj_GetDataBrowserItemState, 1,
  3446. PyDoc_STR("(UInt32 item) -> (UInt32 state)")},
  3447. {"RevealDataBrowserItem", (PyCFunction)CtlObj_RevealDataBrowserItem, 1,
  3448. PyDoc_STR("(UInt32 item, UInt32 propertyID, UInt8 options) -> None")},
  3449. {"SetDataBrowserActiveItems", (PyCFunction)CtlObj_SetDataBrowserActiveItems, 1,
  3450. PyDoc_STR("(Boolean active) -> None")},
  3451. {"GetDataBrowserActiveItems", (PyCFunction)CtlObj_GetDataBrowserActiveItems, 1,
  3452. PyDoc_STR("() -> (Boolean active)")},
  3453. {"SetDataBrowserScrollBarInset", (PyCFunction)CtlObj_SetDataBrowserScrollBarInset, 1,
  3454. PyDoc_STR("() -> (Rect insetRect)")},
  3455. {"GetDataBrowserScrollBarInset", (PyCFunction)CtlObj_GetDataBrowserScrollBarInset, 1,
  3456. PyDoc_STR("() -> (Rect insetRect)")},
  3457. {"SetDataBrowserTarget", (PyCFunction)CtlObj_SetDataBrowserTarget, 1,
  3458. PyDoc_STR("(UInt32 target) -> None")},
  3459. {"GetDataBrowserTarget", (PyCFunction)CtlObj_GetDataBrowserTarget, 1,
  3460. PyDoc_STR("() -> (UInt32 target)")},
  3461. {"SetDataBrowserSortOrder", (PyCFunction)CtlObj_SetDataBrowserSortOrder, 1,
  3462. PyDoc_STR("(UInt16 order) -> None")},
  3463. {"GetDataBrowserSortOrder", (PyCFunction)CtlObj_GetDataBrowserSortOrder, 1,
  3464. PyDoc_STR("() -> (UInt16 order)")},
  3465. {"SetDataBrowserScrollPosition", (PyCFunction)CtlObj_SetDataBrowserScrollPosition, 1,
  3466. PyDoc_STR("(UInt32 top, UInt32 left) -> None")},
  3467. {"GetDataBrowserScrollPosition", (PyCFunction)CtlObj_GetDataBrowserScrollPosition, 1,
  3468. PyDoc_STR("() -> (UInt32 top, UInt32 left)")},
  3469. {"SetDataBrowserHasScrollBars", (PyCFunction)CtlObj_SetDataBrowserHasScrollBars, 1,
  3470. PyDoc_STR("(Boolean horiz, Boolean vert) -> None")},
  3471. {"GetDataBrowserHasScrollBars", (PyCFunction)CtlObj_GetDataBrowserHasScrollBars, 1,
  3472. PyDoc_STR("() -> (Boolean horiz, Boolean vert)")},
  3473. {"SetDataBrowserSortProperty", (PyCFunction)CtlObj_SetDataBrowserSortProperty, 1,
  3474. PyDoc_STR("(UInt32 property) -> None")},
  3475. {"GetDataBrowserSortProperty", (PyCFunction)CtlObj_GetDataBrowserSortProperty, 1,
  3476. PyDoc_STR("() -> (UInt32 property)")},
  3477. {"SetDataBrowserSelectionFlags", (PyCFunction)CtlObj_SetDataBrowserSelectionFlags, 1,
  3478. PyDoc_STR("(UInt32 selectionFlags) -> None")},
  3479. {"GetDataBrowserSelectionFlags", (PyCFunction)CtlObj_GetDataBrowserSelectionFlags, 1,
  3480. PyDoc_STR("() -> (UInt32 selectionFlags)")},
  3481. {"SetDataBrowserPropertyFlags", (PyCFunction)CtlObj_SetDataBrowserPropertyFlags, 1,
  3482. PyDoc_STR("(UInt32 property, UInt32 flags) -> None")},
  3483. {"GetDataBrowserPropertyFlags", (PyCFunction)CtlObj_GetDataBrowserPropertyFlags, 1,
  3484. PyDoc_STR("(UInt32 property) -> (UInt32 flags)")},
  3485. {"SetDataBrowserEditText", (PyCFunction)CtlObj_SetDataBrowserEditText, 1,
  3486. PyDoc_STR("(CFStringRef text) -> None")},
  3487. {"CopyDataBrowserEditText", (PyCFunction)CtlObj_CopyDataBrowserEditText, 1,
  3488. PyDoc_STR("() -> (CFStringRef text)")},
  3489. {"GetDataBrowserEditText", (PyCFunction)CtlObj_GetDataBrowserEditText, 1,
  3490. PyDoc_STR("(CFMutableStringRef text) -> None")},
  3491. {"SetDataBrowserEditItem", (PyCFunction)CtlObj_SetDataBrowserEditItem, 1,
  3492. PyDoc_STR("(UInt32 item, UInt32 property) -> None")},
  3493. {"GetDataBrowserEditItem", (PyCFunction)CtlObj_GetDataBrowserEditItem, 1,
  3494. PyDoc_STR("() -> (UInt32 item, UInt32 property)")},
  3495. {"GetDataBrowserItemPartBounds", (PyCFunction)CtlObj_GetDataBrowserItemPartBounds, 1,
  3496. PyDoc_STR("(UInt32 item, UInt32 property, OSType part) -> (Rect bounds)")},
  3497. {"RemoveDataBrowserTableViewColumn", (PyCFunction)CtlObj_RemoveDataBrowserTableViewColumn, 1,
  3498. PyDoc_STR("(UInt32 column) -> None")},
  3499. {"GetDataBrowserTableViewColumnCount", (PyCFunction)CtlObj_GetDataBrowserTableViewColumnCount, 1,
  3500. PyDoc_STR("() -> (UInt32 numColumns)")},
  3501. {"SetDataBrowserTableViewHiliteStyle", (PyCFunction)CtlObj_SetDataBrowserTableViewHiliteStyle, 1,
  3502. PyDoc_STR("(UInt32 hiliteStyle) -> None")},
  3503. {"GetDataBrowserTableViewHiliteStyle", (PyCFunction)CtlObj_GetDataBrowserTableViewHiliteStyle, 1,
  3504. PyDoc_STR("() -> (UInt32 hiliteStyle)")},
  3505. {"SetDataBrowserTableViewRowHeight", (PyCFunction)CtlObj_SetDataBrowserTableViewRowHeight, 1,
  3506. PyDoc_STR("(UInt16 height) -> None")},
  3507. {"GetDataBrowserTableViewRowHeight", (PyCFunction)CtlObj_GetDataBrowserTableViewRowHeight, 1,
  3508. PyDoc_STR("() -> (UInt16 height)")},
  3509. {"SetDataBrowserTableViewColumnWidth", (PyCFunction)CtlObj_SetDataBrowserTableViewColumnWidth, 1,
  3510. PyDoc_STR("(UInt16 width) -> None")},
  3511. {"GetDataBrowserTableViewColumnWidth", (PyCFunction)CtlObj_GetDataBrowserTableViewColumnWidth, 1,
  3512. PyDoc_STR("() -> (UInt16 width)")},
  3513. {"SetDataBrowserTableViewItemRowHeight", (PyCFunction)CtlObj_SetDataBrowserTableViewItemRowHeight, 1,
  3514. PyDoc_STR("(UInt32 item, UInt16 height) -> None")},
  3515. {"GetDataBrowserTableViewItemRowHeight", (PyCFunction)CtlObj_GetDataBrowserTableViewItemRowHeight, 1,
  3516. PyDoc_STR("(UInt32 item) -> (UInt16 height)")},
  3517. {"SetDataBrowserTableViewNamedColumnWidth", (PyCFunction)CtlObj_SetDataBrowserTableViewNamedColumnWidth, 1,
  3518. PyDoc_STR("(UInt32 column, UInt16 width) -> None")},
  3519. {"GetDataBrowserTableViewNamedColumnWidth", (PyCFunction)CtlObj_GetDataBrowserTableViewNamedColumnWidth, 1,
  3520. PyDoc_STR("(UInt32 column) -> (UInt16 width)")},
  3521. {"SetDataBrowserTableViewGeometry", (PyCFunction)CtlObj_SetDataBrowserTableViewGeometry, 1,
  3522. PyDoc_STR("(Boolean variableWidthColumns, Boolean variableHeightRows) -> None")},
  3523. {"GetDataBrowserTableViewGeometry", (PyCFunction)CtlObj_GetDataBrowserTableViewGeometry, 1,
  3524. PyDoc_STR("() -> (Boolean variableWidthColumns, Boolean variableHeightRows)")},
  3525. {"GetDataBrowserTableViewItemID", (PyCFunction)CtlObj_GetDataBrowserTableViewItemID, 1,
  3526. PyDoc_STR("(UInt32 row) -> (UInt32 item)")},
  3527. {"SetDataBrowserTableViewItemRow", (PyCFunction)CtlObj_SetDataBrowserTableViewItemRow, 1,
  3528. PyDoc_STR("(UInt32 item, UInt32 row) -> None")},
  3529. {"GetDataBrowserTableViewItemRow", (PyCFunction)CtlObj_GetDataBrowserTableViewItemRow, 1,
  3530. PyDoc_STR("(UInt32 item) -> (UInt32 row)")},
  3531. {"SetDataBrowserTableViewColumnPosition", (PyCFunction)CtlObj_SetDataBrowserTableViewColumnPosition, 1,
  3532. PyDoc_STR("(UInt32 column, UInt32 position) -> None")},
  3533. {"GetDataBrowserTableViewColumnPosition", (PyCFunction)CtlObj_GetDataBrowserTableViewColumnPosition, 1,
  3534. PyDoc_STR("(UInt32 column) -> (UInt32 position)")},
  3535. {"GetDataBrowserTableViewColumnProperty", (PyCFunction)CtlObj_GetDataBrowserTableViewColumnProperty, 1,
  3536. PyDoc_STR("(UInt32 column) -> (UInt32 property)")},
  3537. {"AutoSizeDataBrowserListViewColumns", (PyCFunction)CtlObj_AutoSizeDataBrowserListViewColumns, 1,
  3538. PyDoc_STR("() -> None")},
  3539. {"AddDataBrowserListViewColumn", (PyCFunction)CtlObj_AddDataBrowserListViewColumn, 1,
  3540. PyDoc_STR("(DataBrowserListViewColumnDesc columnDesc, UInt32 position) -> None")},
  3541. {"SetDataBrowserListViewHeaderBtnHeight", (PyCFunction)CtlObj_SetDataBrowserListViewHeaderBtnHeight, 1,
  3542. PyDoc_STR("(UInt16 height) -> None")},
  3543. {"GetDataBrowserListViewHeaderBtnHeight", (PyCFunction)CtlObj_GetDataBrowserListViewHeaderBtnHeight, 1,
  3544. PyDoc_STR("() -> (UInt16 height)")},
  3545. {"SetDataBrowserListViewUsePlainBackground", (PyCFunction)CtlObj_SetDataBrowserListViewUsePlainBackground, 1,
  3546. PyDoc_STR("(Boolean usePlainBackground) -> None")},
  3547. {"GetDataBrowserListViewUsePlainBackground", (PyCFunction)CtlObj_GetDataBrowserListViewUsePlainBackground, 1,
  3548. PyDoc_STR("() -> (Boolean usePlainBackground)")},
  3549. {"SetDataBrowserListViewDisclosureColumn", (PyCFunction)CtlObj_SetDataBrowserListViewDisclosureColumn, 1,
  3550. PyDoc_STR("(UInt32 column, Boolean expandableRows) -> None")},
  3551. {"GetDataBrowserListViewDisclosureColumn", (PyCFunction)CtlObj_GetDataBrowserListViewDisclosureColumn, 1,
  3552. PyDoc_STR("() -> (UInt32 column, Boolean expandableRows)")},
  3553. {"GetDataBrowserColumnViewPath", (PyCFunction)CtlObj_GetDataBrowserColumnViewPath, 1,
  3554. PyDoc_STR("(Handle path) -> None")},
  3555. {"GetDataBrowserColumnViewPathLength", (PyCFunction)CtlObj_GetDataBrowserColumnViewPathLength, 1,
  3556. PyDoc_STR("() -> (UInt32 pathLength)")},
  3557. {"SetDataBrowserColumnViewDisplayType", (PyCFunction)CtlObj_SetDataBrowserColumnViewDisplayType, 1,
  3558. PyDoc_STR("(OSType propertyType) -> None")},
  3559. {"GetDataBrowserColumnViewDisplayType", (PyCFunction)CtlObj_GetDataBrowserColumnViewDisplayType, 1,
  3560. PyDoc_STR("() -> (OSType propertyType)")},
  3561. {"as_Resource", (PyCFunction)CtlObj_as_Resource, 1,
  3562. PyDoc_STR("() -> (Handle _rv)")},
  3563. {"GetControlRect", (PyCFunction)CtlObj_GetControlRect, 1,
  3564. PyDoc_STR("() -> (Rect rect)")},
  3565. {"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
  3566. PyDoc_STR("() -> None")},
  3567. {"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
  3568. PyDoc_STR("(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)")},
  3569. {"HandleControlClick", (PyCFunction)CtlObj_HandleControlClick, 1,
  3570. PyDoc_STR("(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)")},
  3571. {"SetControlData", (PyCFunction)CtlObj_SetControlData, 1,
  3572. PyDoc_STR("(stuff) -> None")},
  3573. {"GetControlData", (PyCFunction)CtlObj_GetControlData, 1,
  3574. PyDoc_STR("(part, type) -> String")},
  3575. {"SetControlData_Handle", (PyCFunction)CtlObj_SetControlData_Handle, 1,
  3576. PyDoc_STR("(ResObj) -> None")},
  3577. {"GetControlData_Handle", (PyCFunction)CtlObj_GetControlData_Handle, 1,
  3578. PyDoc_STR("(part, type) -> ResObj")},
  3579. {"SetControlData_Callback", (PyCFunction)CtlObj_SetControlData_Callback, 1,
  3580. PyDoc_STR("(callbackfunc) -> None")},
  3581. {NULL, NULL, 0}
  3582. };
  3583. #define CtlObj_getsetlist NULL
  3584. static int CtlObj_compare(ControlObject *self, ControlObject *other)
  3585. {
  3586. unsigned long v, w;
  3587. if (!CtlObj_Check((PyObject *)other))
  3588. {
  3589. v=(unsigned long)self;
  3590. w=(unsigned long)other;
  3591. }
  3592. else
  3593. {
  3594. v=(unsigned long)self->ob_itself;
  3595. w=(unsigned long)other->ob_itself;
  3596. }
  3597. if( v < w ) return -1;
  3598. if( v > w ) return 1;
  3599. return 0;
  3600. }
  3601. #define CtlObj_repr NULL
  3602. static long CtlObj_hash(ControlObject *self)
  3603. {
  3604. return (long)self->ob_itself;
  3605. }
  3606. #define CtlObj_tp_init 0
  3607. #define CtlObj_tp_alloc PyType_GenericAlloc
  3608. static PyObject *CtlObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
  3609. {
  3610. PyObject *_self;
  3611. ControlHandle itself;
  3612. char *kw[] = {"itself", 0};
  3613. if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CtlObj_Convert, &itself)) return NULL;
  3614. if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
  3615. ((ControlObject *)_self)->ob_itself = itself;
  3616. return _self;
  3617. }
  3618. #define CtlObj_tp_free PyObject_Del
  3619. PyTypeObject Control_Type = {
  3620. PyObject_HEAD_INIT(NULL)
  3621. 0, /*ob_size*/
  3622. "_Ctl.Control", /*tp_name*/
  3623. sizeof(ControlObject), /*tp_basicsize*/
  3624. 0, /*tp_itemsize*/
  3625. /* methods */
  3626. (destructor) CtlObj_dealloc, /*tp_dealloc*/
  3627. 0, /*tp_print*/
  3628. (getattrfunc)0, /*tp_getattr*/
  3629. (setattrfunc)0, /*tp_setattr*/
  3630. (cmpfunc) CtlObj_compare, /*tp_compare*/
  3631. (reprfunc) CtlObj_repr, /*tp_repr*/
  3632. (PyNumberMethods *)0, /* tp_as_number */
  3633. (PySequenceMethods *)0, /* tp_as_sequence */
  3634. (PyMappingMethods *)0, /* tp_as_mapping */
  3635. (hashfunc) CtlObj_hash, /*tp_hash*/
  3636. 0, /*tp_call*/
  3637. 0, /*tp_str*/
  3638. PyObject_GenericGetAttr, /*tp_getattro*/
  3639. PyObject_GenericSetAttr, /*tp_setattro */
  3640. 0, /*tp_as_buffer*/
  3641. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
  3642. 0, /*tp_doc*/
  3643. 0, /*tp_traverse*/
  3644. 0, /*tp_clear*/
  3645. 0, /*tp_richcompare*/
  3646. 0, /*tp_weaklistoffset*/
  3647. 0, /*tp_iter*/
  3648. 0, /*tp_iternext*/
  3649. CtlObj_methods, /* tp_methods */
  3650. 0, /*tp_members*/
  3651. CtlObj_getsetlist, /*tp_getset*/
  3652. 0, /*tp_base*/
  3653. 0, /*tp_dict*/
  3654. 0, /*tp_descr_get*/
  3655. 0, /*tp_descr_set*/
  3656. 0, /*tp_dictoffset*/
  3657. CtlObj_tp_init, /* tp_init */
  3658. CtlObj_tp_alloc, /* tp_alloc */
  3659. CtlObj_tp_new, /* tp_new */
  3660. CtlObj_tp_free, /* tp_free */
  3661. };
  3662. /* -------------------- End object type Control --------------------- */
  3663. static PyObject *Ctl_NewControl(PyObject *_self, PyObject *_args)
  3664. {
  3665. PyObject *_res = NULL;
  3666. ControlHandle _rv;
  3667. WindowPtr owningWindow;
  3668. Rect boundsRect;
  3669. Str255 controlTitle;
  3670. Boolean initiallyVisible;
  3671. SInt16 initialValue;
  3672. SInt16 minimumValue;
  3673. SInt16 maximumValue;
  3674. SInt16 procID;
  3675. SInt32 controlReference;
  3676. #ifndef NewControl
  3677. PyMac_PRECHECK(NewControl);
  3678. #endif
  3679. if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl",
  3680. WinObj_Convert, &owningWindow,
  3681. PyMac_GetRect, &boundsRect,
  3682. PyMac_GetStr255, controlTitle,
  3683. &initiallyVisible,
  3684. &initialValue,
  3685. &minimumValue,
  3686. &maximumValue,
  3687. &procID,
  3688. &controlReference))
  3689. return NULL;
  3690. _rv = NewControl(owningWindow,
  3691. &boundsRect,
  3692. controlTitle,
  3693. initiallyVisible,
  3694. initialValue,
  3695. minimumValue,
  3696. maximumValue,
  3697. procID,
  3698. controlReference);
  3699. _res = Py_BuildValue("O&",
  3700. CtlObj_New, _rv);
  3701. return _res;
  3702. }
  3703. static PyObject *Ctl_GetNewControl(PyObject *_self, PyObject *_args)
  3704. {
  3705. PyObject *_res = NULL;
  3706. ControlHandle _rv;
  3707. SInt16 resourceID;
  3708. WindowPtr owningWindow;
  3709. #ifndef GetNewControl
  3710. PyMac_PRECHECK(GetNewControl);
  3711. #endif
  3712. if (!PyArg_ParseTuple(_args, "hO&",
  3713. &resourceID,
  3714. WinObj_Convert, &owningWindow))
  3715. return NULL;
  3716. _rv = GetNewControl(resourceID,
  3717. owningWindow);
  3718. _res = Py_BuildValue("O&",
  3719. CtlObj_New, _rv);
  3720. return _res;
  3721. }
  3722. static PyObject *Ctl_DrawControls(PyObject *_self, PyObject *_args)
  3723. {
  3724. PyObject *_res = NULL;
  3725. WindowPtr theWindow;
  3726. #ifndef DrawControls
  3727. PyMac_PRECHECK(DrawControls);
  3728. #endif
  3729. if (!PyArg_ParseTuple(_args, "O&",
  3730. WinObj_Convert, &theWindow))
  3731. return NULL;
  3732. DrawControls(theWindow);
  3733. Py_INCREF(Py_None);
  3734. _res = Py_None;
  3735. return _res;
  3736. }
  3737. static PyObject *Ctl_UpdateControls(PyObject *_self, PyObject *_args)
  3738. {
  3739. PyObject *_res = NULL;
  3740. WindowPtr inWindow;
  3741. RgnHandle inUpdateRegion;
  3742. #ifndef UpdateControls
  3743. PyMac_PRECHECK(UpdateControls);
  3744. #endif
  3745. if (!PyArg_ParseTuple(_args, "O&O&",
  3746. WinObj_Convert, &inWindow,
  3747. ResObj_Convert, &inUpdateRegion))
  3748. return NULL;
  3749. UpdateControls(inWindow,
  3750. inUpdateRegion);
  3751. Py_INCREF(Py_None);
  3752. _res = Py_None;
  3753. return _res;
  3754. }
  3755. static PyObject *Ctl_FindControl(PyObject *_self, PyObject *_args)
  3756. {
  3757. PyObject *_res = NULL;
  3758. ControlPartCode _rv;
  3759. Point testPoint;
  3760. WindowPtr theWindow;
  3761. ControlHandle theControl;
  3762. #ifndef FindControl
  3763. PyMac_PRECHECK(FindControl);
  3764. #endif
  3765. if (!PyArg_ParseTuple(_args, "O&O&",
  3766. PyMac_GetPoint, &testPoint,
  3767. WinObj_Convert, &theWindow))
  3768. return NULL;
  3769. _rv = FindControl(testPoint,
  3770. theWindow,
  3771. &theControl);
  3772. _res = Py_BuildValue("hO&",
  3773. _rv,
  3774. CtlObj_WhichControl, theControl);
  3775. return _res;
  3776. }
  3777. static PyObject *Ctl_IdleControls(PyObject *_self, PyObject *_args)
  3778. {
  3779. PyObject *_res = NULL;
  3780. WindowPtr inWindow;
  3781. #ifndef IdleControls
  3782. PyMac_PRECHECK(IdleControls);
  3783. #endif
  3784. if (!PyArg_ParseTuple(_args, "O&",
  3785. WinObj_Convert, &inWindow))
  3786. return NULL;
  3787. IdleControls(inWindow);
  3788. Py_INCREF(Py_None);
  3789. _res = Py_None;
  3790. return _res;
  3791. }
  3792. static PyObject *Ctl_GetControlByID(PyObject *_self, PyObject *_args)
  3793. {
  3794. PyObject *_res = NULL;
  3795. OSStatus _err;
  3796. WindowPtr inWindow;
  3797. ControlID inID;
  3798. ControlHandle outControl;
  3799. #ifndef GetControlByID
  3800. PyMac_PRECHECK(GetControlByID);
  3801. #endif
  3802. if (!PyArg_ParseTuple(_args, "O&O&",
  3803. WinObj_Convert, &inWindow,
  3804. PyControlID_Convert, &inID))
  3805. return NULL;
  3806. _err = GetControlByID(inWindow,
  3807. &inID,
  3808. &outControl);
  3809. if (_err != noErr) return PyMac_Error(_err);
  3810. _res = Py_BuildValue("O&",
  3811. CtlObj_WhichControl, outControl);
  3812. return _res;
  3813. }
  3814. static PyObject *Ctl_DumpControlHierarchy(PyObject *_self, PyObject *_args)
  3815. {
  3816. PyObject *_res = NULL;
  3817. OSErr _err;
  3818. WindowPtr inWindow;
  3819. FSSpec inDumpFile;
  3820. #ifndef DumpControlHierarchy
  3821. PyMac_PRECHECK(DumpControlHierarchy);
  3822. #endif
  3823. if (!PyArg_ParseTuple(_args, "O&O&",
  3824. WinObj_Convert, &inWindow,
  3825. PyMac_GetFSSpec, &inDumpFile))
  3826. return NULL;
  3827. _err = DumpControlHierarchy(inWindow,
  3828. &inDumpFile);
  3829. if (_err != noErr) return PyMac_Error(_err);
  3830. Py_INCREF(Py_None);
  3831. _res = Py_None;
  3832. return _res;
  3833. }
  3834. static PyObject *Ctl_CreateRootControl(PyObject *_self, PyObject *_args)
  3835. {
  3836. PyObject *_res = NULL;
  3837. OSErr _err;
  3838. WindowPtr inWindow;
  3839. ControlHandle outControl;
  3840. #ifndef CreateRootControl
  3841. PyMac_PRECHECK(CreateRootControl);
  3842. #endif
  3843. if (!PyArg_ParseTuple(_args, "O&",
  3844. WinObj_Convert, &inWindow))
  3845. return NULL;
  3846. _err = CreateRootControl(inWindow,
  3847. &outControl);
  3848. if (_err != noErr) return PyMac_Error(_err);
  3849. _res = Py_BuildValue("O&",
  3850. CtlObj_New, outControl);
  3851. return _res;
  3852. }
  3853. static PyObject *Ctl_GetRootControl(PyObject *_self, PyObject *_args)
  3854. {
  3855. PyObject *_res = NULL;
  3856. OSErr _err;
  3857. WindowPtr inWindow;
  3858. ControlHandle outControl;
  3859. #ifndef GetRootControl
  3860. PyMac_PRECHECK(GetRootControl);
  3861. #endif
  3862. if (!PyArg_ParseTuple(_args, "O&",
  3863. WinObj_Convert, &inWindow))
  3864. return NULL;
  3865. _err = GetRootControl(inWindow,
  3866. &outControl);
  3867. if (_err != noErr) return PyMac_Error(_err);
  3868. _res = Py_BuildValue("O&",
  3869. CtlObj_WhichControl, outControl);
  3870. return _res;
  3871. }
  3872. static PyObject *Ctl_GetKeyboardFocus(PyObject *_self, PyObject *_args)
  3873. {
  3874. PyObject *_res = NULL;
  3875. OSErr _err;
  3876. WindowPtr inWindow;
  3877. ControlHandle outControl;
  3878. #ifndef GetKeyboardFocus
  3879. PyMac_PRECHECK(GetKeyboardFocus);
  3880. #endif
  3881. if (!PyArg_ParseTuple(_args, "O&",
  3882. WinObj_Convert, &inWindow))
  3883. return NULL;
  3884. _err = GetKeyboardFocus(inWindow,
  3885. &outControl);
  3886. if (_err != noErr) return PyMac_Error(_err);
  3887. _res = Py_BuildValue("O&",
  3888. CtlObj_WhichControl, outControl);
  3889. return _res;
  3890. }
  3891. static PyObject *Ctl_SetKeyboardFocus(PyObject *_self, PyObject *_args)
  3892. {
  3893. PyObject *_res = NULL;
  3894. OSErr _err;
  3895. WindowPtr inWindow;
  3896. ControlHandle inControl;
  3897. ControlFocusPart inPart;
  3898. #ifndef SetKeyboardFocus
  3899. PyMac_PRECHECK(SetKeyboardFocus);
  3900. #endif
  3901. if (!PyArg_ParseTuple(_args, "O&O&h",
  3902. WinObj_Convert, &inWindow,
  3903. CtlObj_Convert, &inControl,
  3904. &inPart))
  3905. return NULL;
  3906. _err = SetKeyboardFocus(inWindow,
  3907. inControl,
  3908. inPart);
  3909. if (_err != noErr) return PyMac_Error(_err);
  3910. Py_INCREF(Py_None);
  3911. _res = Py_None;
  3912. return _res;
  3913. }
  3914. static PyObject *Ctl_AdvanceKeyboardFocus(PyObject *_self, PyObject *_args)
  3915. {
  3916. PyObject *_res = NULL;
  3917. OSErr _err;
  3918. WindowPtr inWindow;
  3919. #ifndef AdvanceKeyboardFocus
  3920. PyMac_PRECHECK(AdvanceKeyboardFocus);
  3921. #endif
  3922. if (!PyArg_ParseTuple(_args, "O&",
  3923. WinObj_Convert, &inWindow))
  3924. return NULL;
  3925. _err = AdvanceKeyboardFocus(inWindow);
  3926. if (_err != noErr) return PyMac_Error(_err);
  3927. Py_INCREF(Py_None);
  3928. _res = Py_None;
  3929. return _res;
  3930. }
  3931. static PyObject *Ctl_ReverseKeyboardFocus(PyObject *_self, PyObject *_args)
  3932. {
  3933. PyObject *_res = NULL;
  3934. OSErr _err;
  3935. WindowPtr inWindow;
  3936. #ifndef ReverseKeyboardFocus
  3937. PyMac_PRECHECK(ReverseKeyboardFocus);
  3938. #endif
  3939. if (!PyArg_ParseTuple(_args, "O&",
  3940. WinObj_Convert, &inWindow))
  3941. return NULL;
  3942. _err = ReverseKeyboardFocus(inWindow);
  3943. if (_err != noErr) return PyMac_Error(_err);
  3944. Py_INCREF(Py_None);
  3945. _res = Py_None;
  3946. return _res;
  3947. }
  3948. static PyObject *Ctl_ClearKeyboardFocus(PyObject *_self, PyObject *_args)
  3949. {
  3950. PyObject *_res = NULL;
  3951. OSErr _err;
  3952. WindowPtr inWindow;
  3953. #ifndef ClearKeyboardFocus
  3954. PyMac_PRECHECK(ClearKeyboardFocus);
  3955. #endif
  3956. if (!PyArg_ParseTuple(_args, "O&",
  3957. WinObj_Convert, &inWindow))
  3958. return NULL;
  3959. _err = ClearKeyboardFocus(inWindow);
  3960. if (_err != noErr) return PyMac_Error(_err);
  3961. Py_INCREF(Py_None);
  3962. _res = Py_None;
  3963. return _res;
  3964. }
  3965. static PyObject *Ctl_SetAutomaticControlDragTrackingEnabledForWindow(PyObject *_self, PyObject *_args)
  3966. {
  3967. PyObject *_res = NULL;
  3968. OSStatus _err;
  3969. WindowPtr inWindow;
  3970. Boolean inTracks;
  3971. #ifndef SetAutomaticControlDragTrackingEnabledForWindow
  3972. PyMac_PRECHECK(SetAutomaticControlDragTrackingEnabledForWindow);
  3973. #endif
  3974. if (!PyArg_ParseTuple(_args, "O&b",
  3975. WinObj_Convert, &inWindow,
  3976. &inTracks))
  3977. return NULL;
  3978. _err = SetAutomaticControlDragTrackingEnabledForWindow(inWindow,
  3979. inTracks);
  3980. if (_err != noErr) return PyMac_Error(_err);
  3981. Py_INCREF(Py_None);
  3982. _res = Py_None;
  3983. return _res;
  3984. }
  3985. static PyObject *Ctl_IsAutomaticControlDragTrackingEnabledForWindow(PyObject *_self, PyObject *_args)
  3986. {
  3987. PyObject *_res = NULL;
  3988. OSStatus _err;
  3989. WindowPtr inWindow;
  3990. Boolean outTracks;
  3991. #ifndef IsAutomaticControlDragTrackingEnabledForWindow
  3992. PyMac_PRECHECK(IsAutomaticControlDragTrackingEnabledForWindow);
  3993. #endif
  3994. if (!PyArg_ParseTuple(_args, "O&",
  3995. WinObj_Convert, &inWindow))
  3996. return NULL;
  3997. _err = IsAutomaticControlDragTrackingEnabledForWindow(inWindow,
  3998. &outTracks);
  3999. if (_err != noErr) return PyMac_Error(_err);
  4000. _res = Py_BuildValue("b",
  4001. outTracks);
  4002. return _res;
  4003. }
  4004. static PyObject *Ctl_CreateBevelButtonControl(PyObject *_self, PyObject *_args)
  4005. {
  4006. PyObject *_res = NULL;
  4007. OSStatus _err;
  4008. WindowPtr window;
  4009. Rect boundsRect;
  4010. CFStringRef title;
  4011. UInt16 thickness;
  4012. UInt16 behavior;
  4013. ControlButtonContentInfo info;
  4014. SInt16 menuID;
  4015. UInt16 menuBehavior;
  4016. UInt16 menuPlacement;
  4017. ControlHandle outControl;
  4018. #ifndef CreateBevelButtonControl
  4019. PyMac_PRECHECK(CreateBevelButtonControl);
  4020. #endif
  4021. if (!PyArg_ParseTuple(_args, "O&O&O&HHO&hHH",
  4022. WinObj_Convert, &window,
  4023. PyMac_GetRect, &boundsRect,
  4024. CFStringRefObj_Convert, &title,
  4025. &thickness,
  4026. &behavior,
  4027. ControlButtonContentInfo_Convert, &info,
  4028. &menuID,
  4029. &menuBehavior,
  4030. &menuPlacement))
  4031. return NULL;
  4032. _err = CreateBevelButtonControl(window,
  4033. &boundsRect,
  4034. title,
  4035. thickness,
  4036. behavior,
  4037. &info,
  4038. menuID,
  4039. menuBehavior,
  4040. menuPlacement,
  4041. &outControl);
  4042. if (_err != noErr) return PyMac_Error(_err);
  4043. _res = Py_BuildValue("O&",
  4044. CtlObj_New, outControl);
  4045. return _res;
  4046. }
  4047. static PyObject *Ctl_CreateSliderControl(PyObject *_self, PyObject *_args)
  4048. {
  4049. PyObject *_res = NULL;
  4050. OSStatus _err;
  4051. WindowPtr window;
  4052. Rect boundsRect;
  4053. SInt32 value;
  4054. SInt32 minimum;
  4055. SInt32 maximum;
  4056. UInt16 orientation;
  4057. UInt16 numTickMarks;
  4058. Boolean liveTracking;
  4059. PyObject* liveTrackingProc;
  4060. UniversalProcPtr c_callback;
  4061. ControlHandle outControl;
  4062. #ifndef CreateSliderControl
  4063. PyMac_PRECHECK(CreateSliderControl);
  4064. #endif
  4065. if (!PyArg_ParseTuple(_args, "O&O&lllHHbO",
  4066. WinObj_Convert, &window,
  4067. PyMac_GetRect, &boundsRect,
  4068. &value,
  4069. &minimum,
  4070. &maximum,
  4071. &orientation,
  4072. &numTickMarks,
  4073. &liveTracking,
  4074. &liveTrackingProc))
  4075. return NULL;
  4076. _err = CreateSliderControl(window,
  4077. &boundsRect,
  4078. value,
  4079. minimum,
  4080. maximum,
  4081. orientation,
  4082. numTickMarks,
  4083. liveTracking,
  4084. myactionproc_upp,
  4085. &outControl);
  4086. if (_err != noErr) return PyMac_Error(_err);
  4087. _res = Py_BuildValue("O&",
  4088. CtlObj_New, outControl);
  4089. setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);
  4090. return _res;
  4091. }
  4092. static PyObject *Ctl_CreateDisclosureTriangleControl(PyObject *_self, PyObject *_args)
  4093. {
  4094. PyObject *_res = NULL;
  4095. OSStatus _err;
  4096. WindowPtr inWindow;
  4097. Rect inBoundsRect;
  4098. UInt16 inOrientation;
  4099. CFStringRef inTitle;
  4100. SInt32 inInitialValue;
  4101. Boolean inDrawTitle;
  4102. Boolean inAutoToggles;
  4103. ControlHandle outControl;
  4104. #ifndef CreateDisclosureTriangleControl
  4105. PyMac_PRECHECK(CreateDisclosureTriangleControl);
  4106. #endif
  4107. if (!PyArg_ParseTuple(_args, "O&O&HO&lbb",
  4108. WinObj_Convert, &inWindow,
  4109. PyMac_GetRect, &inBoundsRect,
  4110. &inOrientation,
  4111. CFStringRefObj_Convert, &inTitle,
  4112. &inInitialValue,
  4113. &inDrawTitle,
  4114. &inAutoToggles))
  4115. return NULL;
  4116. _err = CreateDisclosureTriangleControl(inWindow,
  4117. &inBoundsRect,
  4118. inOrientation,
  4119. inTitle,
  4120. inInitialValue,
  4121. inDrawTitle,
  4122. inAutoToggles,
  4123. &outControl);
  4124. if (_err != noErr) return PyMac_Error(_err);
  4125. _res = Py_BuildValue("O&",
  4126. CtlObj_New, outControl);
  4127. return _res;
  4128. }
  4129. static PyObject *Ctl_CreateProgressBarControl(PyObject *_self, PyObject *_args)
  4130. {
  4131. PyObject *_res = NULL;
  4132. OSStatus _err;
  4133. WindowPtr window;
  4134. Rect boundsRect;
  4135. SInt32 value;
  4136. SInt32 minimum;
  4137. SInt32 maximum;
  4138. Boolean indeterminate;
  4139. ControlHandle outControl;
  4140. #ifndef CreateProgressBarControl
  4141. PyMac_PRECHECK(CreateProgressBarControl);
  4142. #endif
  4143. if (!PyArg_ParseTuple(_args, "O&O&lllb",
  4144. WinObj_Convert, &window,
  4145. PyMac_GetRect, &boundsRect,
  4146. &value,
  4147. &minimum,
  4148. &maximum,
  4149. &indeterminate))
  4150. return NULL;
  4151. _err = CreateProgressBarControl(window,
  4152. &boundsRect,
  4153. value,
  4154. minimum,
  4155. maximum,
  4156. indeterminate,
  4157. &outControl);
  4158. if (_err != noErr) return PyMac_Error(_err);
  4159. _res = Py_BuildValue("O&",
  4160. CtlObj_New, outControl);
  4161. return _res;
  4162. }
  4163. static PyObject *Ctl_CreateRelevanceBarControl(PyObject *_self, PyObject *_args)
  4164. {
  4165. PyObject *_res = NULL;
  4166. OSStatus _err;
  4167. WindowPtr window;
  4168. Rect boundsRect;
  4169. SInt32 value;
  4170. SInt32 minimum;
  4171. SInt32 maximum;
  4172. ControlHandle outControl;
  4173. #ifndef CreateRelevanceBarControl
  4174. PyMac_PRECHECK(CreateRelevanceBarControl);
  4175. #endif
  4176. if (!PyArg_ParseTuple(_args, "O&O&lll",
  4177. WinObj_Convert, &window,
  4178. PyMac_GetRect, &boundsRect,
  4179. &value,
  4180. &minimum,
  4181. &maximum))
  4182. return NULL;
  4183. _err = CreateRelevanceBarControl(window,
  4184. &boundsRect,
  4185. value,
  4186. minimum,
  4187. maximum,
  4188. &outControl);
  4189. if (_err != noErr) return PyMac_Error(_err);
  4190. _res = Py_BuildValue("O&",
  4191. CtlObj_New, outControl);
  4192. return _res;
  4193. }
  4194. static PyObject *Ctl_CreateLittleArrowsControl(PyObject *_self, PyObject *_args)
  4195. {
  4196. PyObject *_res = NULL;
  4197. OSStatus _err;
  4198. WindowPtr window;
  4199. Rect boundsRect;
  4200. SInt32 value;
  4201. SInt32 minimum;
  4202. SInt32 maximum;
  4203. SInt32 increment;
  4204. ControlHandle outControl;
  4205. #ifndef CreateLittleArrowsControl
  4206. PyMac_PRECHECK(CreateLittleArrowsControl);
  4207. #endif
  4208. if (!PyArg_ParseTuple(_args, "O&O&llll",
  4209. WinObj_Convert, &window,
  4210. PyMac_GetRect, &boundsRect,
  4211. &value,
  4212. &minimum,
  4213. &maximum,
  4214. &increment))
  4215. return NULL;
  4216. _err = CreateLittleArrowsControl(window,
  4217. &boundsRect,
  4218. value,
  4219. minimum,
  4220. maximum,
  4221. increment,
  4222. &outControl);
  4223. if (_err != noErr) return PyMac_Error(_err);
  4224. _res = Py_BuildValue("O&",
  4225. CtlObj_New, outControl);
  4226. return _res;
  4227. }
  4228. static PyObject *Ctl_CreateChasingArrowsControl(PyObject *_self, PyObject *_args)
  4229. {
  4230. PyObject *_res = NULL;
  4231. OSStatus _err;
  4232. WindowPtr window;
  4233. Rect boundsRect;
  4234. ControlHandle outControl;
  4235. #ifndef CreateChasingArrowsControl
  4236. PyMac_PRECHECK(CreateChasingArrowsControl);
  4237. #endif
  4238. if (!PyArg_ParseTuple(_args, "O&O&",
  4239. WinObj_Convert, &window,
  4240. PyMac_GetRect, &boundsRect))
  4241. return NULL;
  4242. _err = CreateChasingArrowsControl(window,
  4243. &boundsRect,
  4244. &outControl);
  4245. if (_err != noErr) return PyMac_Error(_err);
  4246. _res = Py_BuildValue("O&",
  4247. CtlObj_New, outControl);
  4248. return _res;
  4249. }
  4250. static PyObject *Ctl_CreateSeparatorControl(PyObject *_self, PyObject *_args)
  4251. {
  4252. PyObject *_res = NULL;
  4253. OSStatus _err;
  4254. WindowPtr window;
  4255. Rect boundsRect;
  4256. ControlHandle outControl;
  4257. #ifndef CreateSeparatorControl
  4258. PyMac_PRECHECK(CreateSeparatorControl);
  4259. #endif
  4260. if (!PyArg_ParseTuple(_args, "O&O&",
  4261. WinObj_Convert, &window,
  4262. PyMac_GetRect, &boundsRect))
  4263. return NULL;
  4264. _err = CreateSeparatorControl(window,
  4265. &boundsRect,
  4266. &outControl);
  4267. if (_err != noErr) return PyMac_Error(_err);
  4268. _res = Py_BuildValue("O&",
  4269. CtlObj_New, outControl);
  4270. return _res;
  4271. }
  4272. static PyObject *Ctl_CreateGroupBoxControl(PyObject *_self, PyObject *_args)
  4273. {
  4274. PyObject *_res = NULL;
  4275. OSStatus _err;
  4276. WindowPtr window;
  4277. Rect boundsRect;
  4278. CFStringRef title;
  4279. Boolean primary;
  4280. ControlHandle outControl;
  4281. #ifndef CreateGroupBoxControl
  4282. PyMac_PRECHECK(CreateGroupBoxControl);
  4283. #endif
  4284. if (!PyArg_ParseTuple(_args, "O&O&O&b",
  4285. WinObj_Convert, &window,
  4286. PyMac_GetRect, &boundsRect,
  4287. CFStringRefObj_Convert, &title,
  4288. &primary))
  4289. return NULL;
  4290. _err = CreateGroupBoxControl(window,
  4291. &boundsRect,
  4292. title,
  4293. primary,
  4294. &outControl);
  4295. if (_err != noErr) return PyMac_Error(_err);
  4296. _res = Py_BuildValue("O&",
  4297. CtlObj_New, outControl);
  4298. return _res;
  4299. }
  4300. static PyObject *Ctl_CreateCheckGroupBoxControl(PyObject *_self, PyObject *_args)
  4301. {
  4302. PyObject *_res = NULL;
  4303. OSStatus _err;
  4304. WindowPtr window;
  4305. Rect boundsRect;
  4306. CFStringRef title;
  4307. SInt32 initialValue;
  4308. Boolean primary;
  4309. Boolean autoToggle;
  4310. ControlHandle outControl;
  4311. #ifndef CreateCheckGroupBoxControl
  4312. PyMac_PRECHECK(CreateCheckGroupBoxControl);
  4313. #endif
  4314. if (!PyArg_ParseTuple(_args, "O&O&O&lbb",
  4315. WinObj_Convert, &window,
  4316. PyMac_GetRect, &boundsRect,
  4317. CFStringRefObj_Convert, &title,
  4318. &initialValue,
  4319. &primary,
  4320. &autoToggle))
  4321. return NULL;
  4322. _err = CreateCheckGroupBoxControl(window,
  4323. &boundsRect,
  4324. title,
  4325. initialValue,
  4326. primary,
  4327. autoToggle,
  4328. &outControl);
  4329. if (_err != noErr) return PyMac_Error(_err);
  4330. _res = Py_BuildValue("O&",
  4331. CtlObj_New, outControl);
  4332. return _res;
  4333. }
  4334. static PyObject *Ctl_CreatePopupGroupBoxControl(PyObject *_self, PyObject *_args)
  4335. {
  4336. PyObject *_res = NULL;
  4337. OSStatus _err;
  4338. WindowPtr window;
  4339. Rect boundsRect;
  4340. CFStringRef title;
  4341. Boolean primary;
  4342. SInt16 menuID;
  4343. Boolean variableWidth;
  4344. SInt16 titleWidth;
  4345. SInt16 titleJustification;
  4346. Style titleStyle;
  4347. ControlHandle outControl;
  4348. #ifndef CreatePopupGroupBoxControl
  4349. PyMac_PRECHECK(CreatePopupGroupBoxControl);
  4350. #endif
  4351. if (!PyArg_ParseTuple(_args, "O&O&O&bhbhhb",
  4352. WinObj_Convert, &window,
  4353. PyMac_GetRect, &boundsRect,
  4354. CFStringRefObj_Convert, &title,
  4355. &primary,
  4356. &menuID,
  4357. &variableWidth,
  4358. &titleWidth,
  4359. &titleJustification,
  4360. &titleStyle))
  4361. return NULL;
  4362. _err = CreatePopupGroupBoxControl(window,
  4363. &boundsRect,
  4364. title,
  4365. primary,
  4366. menuID,
  4367. variableWidth,
  4368. titleWidth,
  4369. titleJustification,
  4370. titleStyle,
  4371. &outControl);
  4372. if (_err != noErr) return PyMac_Error(_err);
  4373. _res = Py_BuildValue("O&",
  4374. CtlObj_New, outControl);
  4375. return _res;
  4376. }
  4377. static PyObject *Ctl_CreateImageWellControl(PyObject *_self, PyObject *_args)
  4378. {
  4379. PyObject *_res = NULL;
  4380. OSStatus _err;
  4381. WindowPtr window;
  4382. Rect boundsRect;
  4383. ControlButtonContentInfo info;
  4384. ControlHandle outControl;
  4385. #ifndef CreateImageWellControl
  4386. PyMac_PRECHECK(CreateImageWellControl);
  4387. #endif
  4388. if (!PyArg_ParseTuple(_args, "O&O&O&",
  4389. WinObj_Convert, &window,
  4390. PyMac_GetRect, &boundsRect,
  4391. ControlButtonContentInfo_Convert, &info))
  4392. return NULL;
  4393. _err = CreateImageWellControl(window,
  4394. &boundsRect,
  4395. &info,
  4396. &outControl);
  4397. if (_err != noErr) return PyMac_Error(_err);
  4398. _res = Py_BuildValue("O&",
  4399. CtlObj_New, outControl);
  4400. return _res;
  4401. }
  4402. static PyObject *Ctl_CreatePopupArrowControl(PyObject *_self, PyObject *_args)
  4403. {
  4404. PyObject *_res = NULL;
  4405. OSStatus _err;
  4406. WindowPtr window;
  4407. Rect boundsRect;
  4408. UInt16 orientation;
  4409. UInt16 size;
  4410. ControlHandle outControl;
  4411. #ifndef CreatePopupArrowControl
  4412. PyMac_PRECHECK(CreatePopupArrowControl);
  4413. #endif
  4414. if (!PyArg_ParseTuple(_args, "O&O&HH",
  4415. WinObj_Convert, &window,
  4416. PyMac_GetRect, &boundsRect,
  4417. &orientation,
  4418. &size))
  4419. return NULL;
  4420. _err = CreatePopupArrowControl(window,
  4421. &boundsRect,
  4422. orientation,
  4423. size,
  4424. &outControl);
  4425. if (_err != noErr) return PyMac_Error(_err);
  4426. _res = Py_BuildValue("O&",
  4427. CtlObj_New, outControl);
  4428. return _res;
  4429. }
  4430. static PyObject *Ctl_CreatePlacardControl(PyObject *_self, PyObject *_args)
  4431. {
  4432. PyObject *_res = NULL;
  4433. OSStatus _err;
  4434. WindowPtr window;
  4435. Rect boundsRect;
  4436. ControlHandle outControl;
  4437. #ifndef CreatePlacardControl
  4438. PyMac_PRECHECK(CreatePlacardControl);
  4439. #endif
  4440. if (!PyArg_ParseTuple(_args, "O&O&",
  4441. WinObj_Convert, &window,
  4442. PyMac_GetRect, &boundsRect))
  4443. return NULL;
  4444. _err = CreatePlacardControl(window,
  4445. &boundsRect,
  4446. &outControl);
  4447. if (_err != noErr) return PyMac_Error(_err);
  4448. _res = Py_BuildValue("O&",
  4449. CtlObj_New, outControl);
  4450. return _res;
  4451. }
  4452. static PyObject *Ctl_CreateClockControl(PyObject *_self, PyObject *_args)
  4453. {
  4454. PyObject *_res = NULL;
  4455. OSStatus _err;
  4456. WindowPtr window;
  4457. Rect boundsRect;
  4458. UInt16 clockType;
  4459. UInt32 clockFlags;
  4460. ControlHandle outControl;
  4461. #ifndef CreateClockControl
  4462. PyMac_PRECHECK(CreateClockControl);
  4463. #endif
  4464. if (!PyArg_ParseTuple(_args, "O&O&Hl",
  4465. WinObj_Convert, &window,
  4466. PyMac_GetRect, &boundsRect,
  4467. &clockType,
  4468. &clockFlags))
  4469. return NULL;
  4470. _err = CreateClockControl(window,
  4471. &boundsRect,
  4472. clockType,
  4473. clockFlags,
  4474. &outControl);
  4475. if (_err != noErr) return PyMac_Error(_err);
  4476. _res = Py_BuildValue("O&",
  4477. CtlObj_New, outControl);
  4478. return _res;
  4479. }
  4480. static PyObject *Ctl_CreateUserPaneControl(PyObject *_self, PyObject *_args)
  4481. {
  4482. PyObject *_res = NULL;
  4483. OSStatus _err;
  4484. WindowPtr window;
  4485. Rect boundsRect;
  4486. UInt32 features;
  4487. ControlHandle outControl;
  4488. #ifndef CreateUserPaneControl
  4489. PyMac_PRECHECK(CreateUserPaneControl);
  4490. #endif
  4491. if (!PyArg_ParseTuple(_args, "O&O&l",
  4492. WinObj_Convert, &window,
  4493. PyMac_GetRect, &boundsRect,
  4494. &features))
  4495. return NULL;
  4496. _err = CreateUserPaneControl(window,
  4497. &boundsRect,
  4498. features,
  4499. &outControl);
  4500. if (_err != noErr) return PyMac_Error(_err);
  4501. _res = Py_BuildValue("O&",
  4502. CtlObj_New, outControl);
  4503. return _res;
  4504. }
  4505. static PyObject *Ctl_CreateEditTextControl(PyObject *_self, PyObject *_args)
  4506. {
  4507. PyObject *_res = NULL;
  4508. OSStatus _err;
  4509. WindowPtr window;
  4510. Rect boundsRect;
  4511. CFStringRef text;
  4512. Boolean isPassword;
  4513. Boolean useInlineInput;
  4514. ControlFontStyleRec style;
  4515. ControlHandle outControl;
  4516. #ifndef CreateEditTextControl
  4517. PyMac_PRECHECK(CreateEditTextControl);
  4518. #endif
  4519. if (!PyArg_ParseTuple(_args, "O&O&O&bbO&",
  4520. WinObj_Convert, &window,
  4521. PyMac_GetRect, &boundsRect,
  4522. CFStringRefObj_Convert, &text,
  4523. &isPassword,
  4524. &useInlineInput,
  4525. ControlFontStyle_Convert, &style))
  4526. return NULL;
  4527. _err = CreateEditTextControl(window,
  4528. &boundsRect,
  4529. text,
  4530. isPassword,
  4531. useInlineInput,
  4532. &style,
  4533. &outControl);
  4534. if (_err != noErr) return PyMac_Error(_err);
  4535. _res = Py_BuildValue("O&",
  4536. CtlObj_New, outControl);
  4537. return _res;
  4538. }
  4539. static PyObject *Ctl_CreateStaticTextControl(PyObject *_self, PyObject *_args)
  4540. {
  4541. PyObject *_res = NULL;
  4542. OSStatus _err;
  4543. WindowPtr window;
  4544. Rect boundsRect;
  4545. CFStringRef text;
  4546. ControlFontStyleRec style;
  4547. ControlHandle outControl;
  4548. #ifndef CreateStaticTextControl
  4549. PyMac_PRECHECK(CreateStaticTextControl);
  4550. #endif
  4551. if (!PyArg_ParseTuple(_args, "O&O&O&O&",
  4552. WinObj_Convert, &window,
  4553. PyMac_GetRect, &boundsRect,
  4554. CFStringRefObj_Convert, &text,
  4555. ControlFontStyle_Convert, &style))
  4556. return NULL;
  4557. _err = CreateStaticTextControl(window,
  4558. &boundsRect,
  4559. text,
  4560. &style,
  4561. &outControl);
  4562. if (_err != noErr) return PyMac_Error(_err);
  4563. _res = Py_BuildValue("O&",
  4564. CtlObj_New, outControl);
  4565. return _res;
  4566. }
  4567. static PyObject *Ctl_CreatePictureControl(PyObject *_self, PyObject *_args)
  4568. {
  4569. PyObject *_res = NULL;
  4570. OSStatus _err;
  4571. WindowPtr window;
  4572. Rect boundsRect;
  4573. ControlButtonContentInfo content;
  4574. Boolean dontTrack;
  4575. ControlHandle outControl;
  4576. #ifndef CreatePictureControl
  4577. PyMac_PRECHECK(CreatePictureControl);
  4578. #endif
  4579. if (!PyArg_ParseTuple(_args, "O&O&O&b",
  4580. WinObj_Convert, &window,
  4581. PyMac_GetRect, &boundsRect,
  4582. ControlButtonContentInfo_Convert, &content,
  4583. &dontTrack))
  4584. return NULL;
  4585. _err = CreatePictureControl(window,
  4586. &boundsRect,
  4587. &content,
  4588. dontTrack,
  4589. &outControl);
  4590. if (_err != noErr) return PyMac_Error(_err);
  4591. _res = Py_BuildValue("O&",
  4592. CtlObj_New, outControl);
  4593. return _res;
  4594. }
  4595. static PyObject *Ctl_CreateIconControl(PyObject *_self, PyObject *_args)
  4596. {
  4597. PyObject *_res = NULL;
  4598. OSStatus _err;
  4599. WindowPtr inWindow;
  4600. Rect inBoundsRect;
  4601. ControlButtonContentInfo inIconContent;
  4602. Boolean inDontTrack;
  4603. ControlHandle outControl;
  4604. #ifndef CreateIconControl
  4605. PyMac_PRECHECK(CreateIconControl);
  4606. #endif
  4607. if (!PyArg_ParseTuple(_args, "O&O&O&b",
  4608. WinObj_Convert, &inWindow,
  4609. PyMac_GetRect, &inBoundsRect,
  4610. ControlButtonContentInfo_Convert, &inIconContent,
  4611. &inDontTrack))
  4612. return NULL;
  4613. _err = CreateIconControl(inWindow,
  4614. &inBoundsRect,
  4615. &inIconContent,
  4616. inDontTrack,
  4617. &outControl);
  4618. if (_err != noErr) return PyMac_Error(_err);
  4619. _res = Py_BuildValue("O&",
  4620. CtlObj_New, outControl);
  4621. return _res;
  4622. }
  4623. static PyObject *Ctl_CreateWindowHeaderControl(PyObject *_self, PyObject *_args)
  4624. {
  4625. PyObject *_res = NULL;
  4626. OSStatus _err;
  4627. WindowPtr window;
  4628. Rect boundsRect;
  4629. Boolean isListHeader;
  4630. ControlHandle outControl;
  4631. #ifndef CreateWindowHeaderControl
  4632. PyMac_PRECHECK(CreateWindowHeaderControl);
  4633. #endif
  4634. if (!PyArg_ParseTuple(_args, "O&O&b",
  4635. WinObj_Convert, &window,
  4636. PyMac_GetRect, &boundsRect,
  4637. &isListHeader))
  4638. return NULL;
  4639. _err = CreateWindowHeaderControl(window,
  4640. &boundsRect,
  4641. isListHeader,
  4642. &outControl);
  4643. if (_err != noErr) return PyMac_Error(_err);
  4644. _res = Py_BuildValue("O&",
  4645. CtlObj_New, outControl);
  4646. return _res;
  4647. }
  4648. static PyObject *Ctl_CreatePushButtonControl(PyObject *_self, PyObject *_args)
  4649. {
  4650. PyObject *_res = NULL;
  4651. OSStatus _err;
  4652. WindowPtr window;
  4653. Rect boundsRect;
  4654. CFStringRef title;
  4655. ControlHandle outControl;
  4656. #ifndef CreatePushButtonControl
  4657. PyMac_PRECHECK(CreatePushButtonControl);
  4658. #endif
  4659. if (!PyArg_ParseTuple(_args, "O&O&O&",
  4660. WinObj_Convert, &window,
  4661. PyMac_GetRect, &boundsRect,
  4662. CFStringRefObj_Convert, &title))
  4663. return NULL;
  4664. _err = CreatePushButtonControl(window,
  4665. &boundsRect,
  4666. title,
  4667. &outControl);
  4668. if (_err != noErr) return PyMac_Error(_err);
  4669. _res = Py_BuildValue("O&",
  4670. CtlObj_New, outControl);
  4671. return _res;
  4672. }
  4673. static PyObject *Ctl_CreatePushButtonWithIconControl(PyObject *_self, PyObject *_args)
  4674. {
  4675. PyObject *_res = NULL;
  4676. OSStatus _err;
  4677. WindowPtr window;
  4678. Rect boundsRect;
  4679. CFStringRef title;
  4680. ControlButtonContentInfo icon;
  4681. UInt16 iconAlignment;
  4682. ControlHandle outControl;
  4683. #ifndef CreatePushButtonWithIconControl
  4684. PyMac_PRECHECK(CreatePushButtonWithIconControl);
  4685. #endif
  4686. if (!PyArg_ParseTuple(_args, "O&O&O&O&H",
  4687. WinObj_Convert, &window,
  4688. PyMac_GetRect, &boundsRect,
  4689. CFStringRefObj_Convert, &title,
  4690. ControlButtonContentInfo_Convert, &icon,
  4691. &iconAlignment))
  4692. return NULL;
  4693. _err = CreatePushButtonWithIconControl(window,
  4694. &boundsRect,
  4695. title,
  4696. &icon,
  4697. iconAlignment,
  4698. &outControl);
  4699. if (_err != noErr) return PyMac_Error(_err);
  4700. _res = Py_BuildValue("O&",
  4701. CtlObj_New, outControl);
  4702. return _res;
  4703. }
  4704. static PyObject *Ctl_CreateRadioButtonControl(PyObject *_self, PyObject *_args)
  4705. {
  4706. PyObject *_res = NULL;
  4707. OSStatus _err;
  4708. WindowPtr window;
  4709. Rect boundsRect;
  4710. CFStringRef title;
  4711. SInt32 initialValue;
  4712. Boolean autoToggle;
  4713. ControlHandle outControl;
  4714. #ifndef CreateRadioButtonControl
  4715. PyMac_PRECHECK(CreateRadioButtonControl);
  4716. #endif
  4717. if (!PyArg_ParseTuple(_args, "O&O&O&lb",
  4718. WinObj_Convert, &window,
  4719. PyMac_GetRect, &boundsRect,
  4720. CFStringRefObj_Convert, &title,
  4721. &initialValue,
  4722. &autoToggle))
  4723. return NULL;
  4724. _err = CreateRadioButtonControl(window,
  4725. &boundsRect,
  4726. title,
  4727. initialValue,
  4728. autoToggle,
  4729. &outControl);
  4730. if (_err != noErr) return PyMac_Error(_err);
  4731. _res = Py_BuildValue("O&",
  4732. CtlObj_New, outControl);
  4733. return _res;
  4734. }
  4735. static PyObject *Ctl_CreateCheckBoxControl(PyObject *_self, PyObject *_args)
  4736. {
  4737. PyObject *_res = NULL;
  4738. OSStatus _err;
  4739. WindowPtr window;
  4740. Rect boundsRect;
  4741. CFStringRef title;
  4742. SInt32 initialValue;
  4743. Boolean autoToggle;
  4744. ControlHandle outControl;
  4745. #ifndef CreateCheckBoxControl
  4746. PyMac_PRECHECK(CreateCheckBoxControl);
  4747. #endif
  4748. if (!PyArg_ParseTuple(_args, "O&O&O&lb",
  4749. WinObj_Convert, &window,
  4750. PyMac_GetRect, &boundsRect,
  4751. CFStringRefObj_Convert, &title,
  4752. &initialValue,
  4753. &autoToggle))
  4754. return NULL;
  4755. _err = CreateCheckBoxControl(window,
  4756. &boundsRect,
  4757. title,
  4758. initialValue,
  4759. autoToggle,
  4760. &outControl);
  4761. if (_err != noErr) return PyMac_Error(_err);
  4762. _res = Py_BuildValue("O&",
  4763. CtlObj_New, outControl);
  4764. return _res;
  4765. }
  4766. static PyObject *Ctl_CreateScrollBarControl(PyObject *_self, PyObject *_args)
  4767. {
  4768. PyObject *_res = NULL;
  4769. OSStatus _err;
  4770. WindowPtr window;
  4771. Rect boundsRect;
  4772. SInt32 value;
  4773. SInt32 minimum;
  4774. SInt32 maximum;
  4775. SInt32 viewSize;
  4776. Boolean liveTracking;
  4777. PyObject* liveTrackingProc;
  4778. UniversalProcPtr c_callback;
  4779. ControlHandle outControl;
  4780. #ifndef CreateScrollBarControl
  4781. PyMac_PRECHECK(CreateScrollBarControl);
  4782. #endif
  4783. if (!PyArg_ParseTuple(_args, "O&O&llllbO",
  4784. WinObj_Convert, &window,
  4785. PyMac_GetRect, &boundsRect,
  4786. &value,
  4787. &minimum,
  4788. &maximum,
  4789. &viewSize,
  4790. &liveTracking,
  4791. &liveTrackingProc))
  4792. return NULL;
  4793. _err = CreateScrollBarControl(window,
  4794. &boundsRect,
  4795. value,
  4796. minimum,
  4797. maximum,
  4798. viewSize,
  4799. liveTracking,
  4800. myactionproc_upp,
  4801. &outControl);
  4802. if (_err != noErr) return PyMac_Error(_err);
  4803. _res = Py_BuildValue("O&",
  4804. CtlObj_New, outControl);
  4805. setcallback(_res, kMyControlActionProcTag, liveTrackingProc, &c_callback);
  4806. return _res;
  4807. }
  4808. static PyObject *Ctl_CreatePopupButtonControl(PyObject *_self, PyObject *_args)
  4809. {
  4810. PyObject *_res = NULL;
  4811. OSStatus _err;
  4812. WindowPtr window;
  4813. Rect boundsRect;
  4814. CFStringRef title;
  4815. SInt16 menuID;
  4816. Boolean variableWidth;
  4817. SInt16 titleWidth;
  4818. SInt16 titleJustification;
  4819. Style titleStyle;
  4820. ControlHandle outControl;
  4821. #ifndef CreatePopupButtonControl
  4822. PyMac_PRECHECK(CreatePopupButtonControl);
  4823. #endif
  4824. if (!PyArg_ParseTuple(_args, "O&O&O&hbhhb",
  4825. WinObj_Convert, &window,
  4826. PyMac_GetRect, &boundsRect,
  4827. CFStringRefObj_Convert, &title,
  4828. &menuID,
  4829. &variableWidth,
  4830. &titleWidth,
  4831. &titleJustification,
  4832. &titleStyle))
  4833. return NULL;
  4834. _err = CreatePopupButtonControl(window,
  4835. &boundsRect,
  4836. title,
  4837. menuID,
  4838. variableWidth,
  4839. titleWidth,
  4840. titleJustification,
  4841. titleStyle,
  4842. &outControl);
  4843. if (_err != noErr) return PyMac_Error(_err);
  4844. _res = Py_BuildValue("O&",
  4845. CtlObj_New, outControl);
  4846. return _res;
  4847. }
  4848. static PyObject *Ctl_CreateRadioGroupControl(PyObject *_self, PyObject *_args)
  4849. {
  4850. PyObject *_res = NULL;
  4851. OSStatus _err;
  4852. WindowPtr window;
  4853. Rect boundsRect;
  4854. ControlHandle outControl;
  4855. #ifndef CreateRadioGroupControl
  4856. PyMac_PRECHECK(CreateRadioGroupControl);
  4857. #endif
  4858. if (!PyArg_ParseTuple(_args, "O&O&",
  4859. WinObj_Convert, &window,
  4860. PyMac_GetRect, &boundsRect))
  4861. return NULL;
  4862. _err = CreateRadioGroupControl(window,
  4863. &boundsRect,
  4864. &outControl);
  4865. if (_err != noErr) return PyMac_Error(_err);
  4866. _res = Py_BuildValue("O&",
  4867. CtlObj_New, outControl);
  4868. return _res;
  4869. }
  4870. static PyObject *Ctl_CreateScrollingTextBoxControl(PyObject *_self, PyObject *_args)
  4871. {
  4872. PyObject *_res = NULL;
  4873. OSStatus _err;
  4874. WindowPtr window;
  4875. Rect boundsRect;
  4876. SInt16 contentResID;
  4877. Boolean autoScroll;
  4878. UInt32 delayBeforeAutoScroll;
  4879. UInt32 delayBetweenAutoScroll;
  4880. UInt16 autoScrollAmount;
  4881. ControlHandle outControl;
  4882. #ifndef CreateScrollingTextBoxControl
  4883. PyMac_PRECHECK(CreateScrollingTextBoxControl);
  4884. #endif
  4885. if (!PyArg_ParseTuple(_args, "O&O&hbllH",
  4886. WinObj_Convert, &window,
  4887. PyMac_GetRect, &boundsRect,
  4888. &contentResID,
  4889. &autoScroll,
  4890. &delayBeforeAutoScroll,
  4891. &delayBetweenAutoScroll,
  4892. &autoScrollAmount))
  4893. return NULL;
  4894. _err = CreateScrollingTextBoxControl(window,
  4895. &boundsRect,
  4896. contentResID,
  4897. autoScroll,
  4898. delayBeforeAutoScroll,
  4899. delayBetweenAutoScroll,
  4900. autoScrollAmount,
  4901. &outControl);
  4902. if (_err != noErr) return PyMac_Error(_err);
  4903. _res = Py_BuildValue("O&",
  4904. CtlObj_New, outControl);
  4905. return _res;
  4906. }
  4907. static PyObject *Ctl_CreateDisclosureButtonControl(PyObject *_self, PyObject *_args)
  4908. {
  4909. PyObject *_res = NULL;
  4910. OSStatus _err;
  4911. WindowPtr inWindow;
  4912. Rect inBoundsRect;
  4913. SInt32 inValue;
  4914. Boolean inAutoToggles;
  4915. ControlHandle outControl;
  4916. #ifndef CreateDisclosureButtonControl
  4917. PyMac_PRECHECK(CreateDisclosureButtonControl);
  4918. #endif
  4919. if (!PyArg_ParseTuple(_args, "O&O&lb",
  4920. WinObj_Convert, &inWindow,
  4921. PyMac_GetRect, &inBoundsRect,
  4922. &inValue,
  4923. &inAutoToggles))
  4924. return NULL;
  4925. _err = CreateDisclosureButtonControl(inWindow,
  4926. &inBoundsRect,
  4927. inValue,
  4928. inAutoToggles,
  4929. &outControl);
  4930. if (_err != noErr) return PyMac_Error(_err);
  4931. _res = Py_BuildValue("O&",
  4932. CtlObj_New, outControl);
  4933. return _res;
  4934. }
  4935. static PyObject *Ctl_CreateRoundButtonControl(PyObject *_self, PyObject *_args)
  4936. {
  4937. PyObject *_res = NULL;
  4938. OSStatus _err;
  4939. WindowPtr inWindow;
  4940. Rect inBoundsRect;
  4941. SInt16 inSize;
  4942. ControlButtonContentInfo inContent;
  4943. ControlHandle outControl;
  4944. #ifndef CreateRoundButtonControl
  4945. PyMac_PRECHECK(CreateRoundButtonControl);
  4946. #endif
  4947. if (!PyArg_ParseTuple(_args, "O&O&hO&",
  4948. WinObj_Convert, &inWindow,
  4949. PyMac_GetRect, &inBoundsRect,
  4950. &inSize,
  4951. ControlButtonContentInfo_Convert, &inContent))
  4952. return NULL;
  4953. _err = CreateRoundButtonControl(inWindow,
  4954. &inBoundsRect,
  4955. inSize,
  4956. &inContent,
  4957. &outControl);
  4958. if (_err != noErr) return PyMac_Error(_err);
  4959. _res = Py_BuildValue("O&",
  4960. CtlObj_New, outControl);
  4961. return _res;
  4962. }
  4963. static PyObject *Ctl_CreateDataBrowserControl(PyObject *_self, PyObject *_args)
  4964. {
  4965. PyObject *_res = NULL;
  4966. OSStatus _err;
  4967. WindowPtr window;
  4968. Rect boundsRect;
  4969. OSType style;
  4970. ControlHandle outControl;
  4971. #ifndef CreateDataBrowserControl
  4972. PyMac_PRECHECK(CreateDataBrowserControl);
  4973. #endif
  4974. if (!PyArg_ParseTuple(_args, "O&O&O&",
  4975. WinObj_Convert, &window,
  4976. PyMac_GetRect, &boundsRect,
  4977. PyMac_GetOSType, &style))
  4978. return NULL;
  4979. _err = CreateDataBrowserControl(window,
  4980. &boundsRect,
  4981. style,
  4982. &outControl);
  4983. if (_err != noErr) return PyMac_Error(_err);
  4984. _res = Py_BuildValue("O&",
  4985. CtlObj_New, outControl);
  4986. return _res;
  4987. }
  4988. static PyObject *Ctl_CreateEditUnicodeTextControl(PyObject *_self, PyObject *_args)
  4989. {
  4990. PyObject *_res = NULL;
  4991. OSStatus _err;
  4992. WindowPtr window;
  4993. Rect boundsRect;
  4994. CFStringRef text;
  4995. Boolean isPassword;
  4996. ControlFontStyleRec style;
  4997. ControlHandle outControl;
  4998. #ifndef CreateEditUnicodeTextControl
  4999. PyMac_PRECHECK(CreateEditUnicodeTextControl);
  5000. #endif
  5001. if (!PyArg_ParseTuple(_args, "O&O&O&bO&",
  5002. WinObj_Convert, &window,
  5003. PyMac_GetRect, &boundsRect,
  5004. CFStringRefObj_Convert, &text,
  5005. &isPassword,
  5006. ControlFontStyle_Convert, &style))
  5007. return NULL;
  5008. _err = CreateEditUnicodeTextControl(window,
  5009. &boundsRect,
  5010. text,
  5011. isPassword,
  5012. &style,
  5013. &outControl);
  5014. if (_err != noErr) return PyMac_Error(_err);
  5015. _res = Py_BuildValue("O&",
  5016. CtlObj_New, outControl);
  5017. return _res;
  5018. }
  5019. static PyObject *Ctl_FindControlUnderMouse(PyObject *_self, PyObject *_args)
  5020. {
  5021. PyObject *_res = NULL;
  5022. ControlHandle _rv;
  5023. Point inWhere;
  5024. WindowPtr inWindow;
  5025. SInt16 outPart;
  5026. #ifndef FindControlUnderMouse
  5027. PyMac_PRECHECK(FindControlUnderMouse);
  5028. #endif
  5029. if (!PyArg_ParseTuple(_args, "O&O&",
  5030. PyMac_GetPoint, &inWhere,
  5031. WinObj_Convert, &inWindow))
  5032. return NULL;
  5033. _rv = FindControlUnderMouse(inWhere,
  5034. inWindow,
  5035. &outPart);
  5036. _res = Py_BuildValue("O&h",
  5037. CtlObj_WhichControl, _rv,
  5038. outPart);
  5039. return _res;
  5040. }
  5041. static PyObject *Ctl_as_Control(PyObject *_self, PyObject *_args)
  5042. {
  5043. PyObject *_res = NULL;
  5044. ControlHandle _rv;
  5045. Handle h;
  5046. #ifndef as_Control
  5047. PyMac_PRECHECK(as_Control);
  5048. #endif
  5049. if (!PyArg_ParseTuple(_args, "O&",
  5050. ResObj_Convert, &h))
  5051. return NULL;
  5052. _rv = as_Control(h);
  5053. _res = Py_BuildValue("O&",
  5054. CtlObj_New, _rv);
  5055. return _res;
  5056. }
  5057. static PyObject *Ctl_CreateTabsControl(PyObject *_self, PyObject *_args)
  5058. {
  5059. PyObject *_res = NULL;
  5060. OSStatus _err;
  5061. WindowPtr window;
  5062. Rect boundsRect;
  5063. UInt16 size;
  5064. UInt16 direction;
  5065. int i;
  5066. UInt16 numTabs;
  5067. ControlTabEntry tabArray[MAXTABS];
  5068. ControlHandle outControl;
  5069. PyObject *tabArrayObj, *tabEntry;
  5070. #ifndef CreateTabsControl
  5071. PyMac_PRECHECK(CreateTabsControl);
  5072. #endif
  5073. if (!PyArg_ParseTuple(_args, "O&O&HHO",
  5074. WinObj_Convert, &window,
  5075. PyMac_GetRect, &boundsRect,
  5076. &size,
  5077. &direction,
  5078. &tabArrayObj))
  5079. return NULL;
  5080. i = PySequence_Length(tabArrayObj);
  5081. if (i == -1)
  5082. return NULL;
  5083. if (i > MAXTABS) {
  5084. PyErr_SetString(Ctl_Error, "Too many tabs");
  5085. return NULL;
  5086. }
  5087. numTabs = i;
  5088. for (i=0; i<numTabs; i++) {
  5089. tabEntry = PySequence_GetItem(tabArrayObj, i);
  5090. if (tabEntry == NULL)
  5091. return NULL;
  5092. if (!PyArg_Parse(tabEntry, "(O&O&B)",
  5093. ControlButtonContentInfo_Convert, &tabArray[i].icon,
  5094. CFStringRefObj_Convert, &tabArray[i].name,
  5095. &tabArray[i].enabled
  5096. ))
  5097. return NULL;
  5098. }
  5099. _err = CreateTabsControl(window,
  5100. &boundsRect,
  5101. size,
  5102. direction,
  5103. numTabs,
  5104. tabArray,
  5105. &outControl);
  5106. if (_err != noErr) return PyMac_Error(_err);
  5107. _res = Py_BuildValue("O&",
  5108. CtlObj_New, outControl);
  5109. return _res;
  5110. }
  5111. static PyMethodDef Ctl_methods[] = {
  5112. {"NewControl", (PyCFunction)Ctl_NewControl, 1,
  5113. PyDoc_STR("(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)")},
  5114. {"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1,
  5115. PyDoc_STR("(SInt16 resourceID, WindowPtr owningWindow) -> (ControlHandle _rv)")},
  5116. {"DrawControls", (PyCFunction)Ctl_DrawControls, 1,
  5117. PyDoc_STR("(WindowPtr theWindow) -> None")},
  5118. {"UpdateControls", (PyCFunction)Ctl_UpdateControls, 1,
  5119. PyDoc_STR("(WindowPtr inWindow, RgnHandle inUpdateRegion) -> None")},
  5120. {"FindControl", (PyCFunction)Ctl_FindControl, 1,
  5121. PyDoc_STR("(Point testPoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)")},
  5122. {"IdleControls", (PyCFunction)Ctl_IdleControls, 1,
  5123. PyDoc_STR("(WindowPtr inWindow) -> None")},
  5124. {"GetControlByID", (PyCFunction)Ctl_GetControlByID, 1,
  5125. PyDoc_STR("(WindowPtr inWindow, ControlID inID) -> (ControlHandle outControl)")},
  5126. {"DumpControlHierarchy", (PyCFunction)Ctl_DumpControlHierarchy, 1,
  5127. PyDoc_STR("(WindowPtr inWindow, FSSpec inDumpFile) -> None")},
  5128. {"CreateRootControl", (PyCFunction)Ctl_CreateRootControl, 1,
  5129. PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
  5130. {"GetRootControl", (PyCFunction)Ctl_GetRootControl, 1,
  5131. PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
  5132. {"GetKeyboardFocus", (PyCFunction)Ctl_GetKeyboardFocus, 1,
  5133. PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")},
  5134. {"SetKeyboardFocus", (PyCFunction)Ctl_SetKeyboardFocus, 1,
  5135. PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl, ControlFocusPart inPart) -> None")},
  5136. {"AdvanceKeyboardFocus", (PyCFunction)Ctl_AdvanceKeyboardFocus, 1,
  5137. PyDoc_STR("(WindowPtr inWindow) -> None")},
  5138. {"ReverseKeyboardFocus", (PyCFunction)Ctl_ReverseKeyboardFocus, 1,
  5139. PyDoc_STR("(WindowPtr inWindow) -> None")},
  5140. {"ClearKeyboardFocus", (PyCFunction)Ctl_ClearKeyboardFocus, 1,
  5141. PyDoc_STR("(WindowPtr inWindow) -> None")},
  5142. {"SetAutomaticControlDragTrackingEnabledForWindow", (PyCFunction)Ctl_SetAutomaticControlDragTrackingEnabledForWindow, 1,
  5143. PyDoc_STR("(WindowPtr inWindow, Boolean inTracks) -> None")},
  5144. {"IsAutomaticControlDragTrackingEnabledForWindow", (PyCFunction)Ctl_IsAutomaticControlDragTrackingEnabledForWindow, 1,
  5145. PyDoc_STR("(WindowPtr inWindow) -> (Boolean outTracks)")},
  5146. {"CreateBevelButtonControl", (PyCFunction)Ctl_CreateBevelButtonControl, 1,
  5147. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, UInt16 thickness, UInt16 behavior, ControlButtonContentInfo info, SInt16 menuID, UInt16 menuBehavior, UInt16 menuPlacement) -> (ControlHandle outControl)")},
  5148. {"CreateSliderControl", (PyCFunction)Ctl_CreateSliderControl, 1,
  5149. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, UInt16 orientation, UInt16 numTickMarks, Boolean liveTracking, PyObject* liveTrackingProc) -> (ControlHandle outControl)")},
  5150. {"CreateDisclosureTriangleControl", (PyCFunction)Ctl_CreateDisclosureTriangleControl, 1,
  5151. PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, UInt16 inOrientation, CFStringRef inTitle, SInt32 inInitialValue, Boolean inDrawTitle, Boolean inAutoToggles) -> (ControlHandle outControl)")},
  5152. {"CreateProgressBarControl", (PyCFunction)Ctl_CreateProgressBarControl, 1,
  5153. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, Boolean indeterminate) -> (ControlHandle outControl)")},
  5154. {"CreateRelevanceBarControl", (PyCFunction)Ctl_CreateRelevanceBarControl, 1,
  5155. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum) -> (ControlHandle outControl)")},
  5156. {"CreateLittleArrowsControl", (PyCFunction)Ctl_CreateLittleArrowsControl, 1,
  5157. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, SInt32 increment) -> (ControlHandle outControl)")},
  5158. {"CreateChasingArrowsControl", (PyCFunction)Ctl_CreateChasingArrowsControl, 1,
  5159. PyDoc_STR("(WindowPtr window, Rect boundsRect) -> (ControlHandle outControl)")},
  5160. {"CreateSeparatorControl", (PyCFunction)Ctl_CreateSeparatorControl, 1,
  5161. PyDoc_STR("(WindowPtr window, Rect boundsRect) -> (ControlHandle outControl)")},
  5162. {"CreateGroupBoxControl", (PyCFunction)Ctl_CreateGroupBoxControl, 1,
  5163. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, Boolean primary) -> (ControlHandle outControl)")},
  5164. {"CreateCheckGroupBoxControl", (PyCFunction)Ctl_CreateCheckGroupBoxControl, 1,
  5165. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, SInt32 initialValue, Boolean primary, Boolean autoToggle) -> (ControlHandle outControl)")},
  5166. {"CreatePopupGroupBoxControl", (PyCFunction)Ctl_CreatePopupGroupBoxControl, 1,
  5167. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, Boolean primary, SInt16 menuID, Boolean variableWidth, SInt16 titleWidth, SInt16 titleJustification, Style titleStyle) -> (ControlHandle outControl)")},
  5168. {"CreateImageWellControl", (PyCFunction)Ctl_CreateImageWellControl, 1,
  5169. PyDoc_STR("(WindowPtr window, Rect boundsRect, ControlButtonContentInfo info) -> (ControlHandle outControl)")},
  5170. {"CreatePopupArrowControl", (PyCFunction)Ctl_CreatePopupArrowControl, 1,
  5171. PyDoc_STR("(WindowPtr window, Rect boundsRect, UInt16 orientation, UInt16 size) -> (ControlHandle outControl)")},
  5172. {"CreatePlacardControl", (PyCFunction)Ctl_CreatePlacardControl, 1,
  5173. PyDoc_STR("(WindowPtr window, Rect boundsRect) -> (ControlHandle outControl)")},
  5174. {"CreateClockControl", (PyCFunction)Ctl_CreateClockControl, 1,
  5175. PyDoc_STR("(WindowPtr window, Rect boundsRect, UInt16 clockType, UInt32 clockFlags) -> (ControlHandle outControl)")},
  5176. {"CreateUserPaneControl", (PyCFunction)Ctl_CreateUserPaneControl, 1,
  5177. PyDoc_STR("(WindowPtr window, Rect boundsRect, UInt32 features) -> (ControlHandle outControl)")},
  5178. {"CreateEditTextControl", (PyCFunction)Ctl_CreateEditTextControl, 1,
  5179. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef text, Boolean isPassword, Boolean useInlineInput, ControlFontStyleRec style) -> (ControlHandle outControl)")},
  5180. {"CreateStaticTextControl", (PyCFunction)Ctl_CreateStaticTextControl, 1,
  5181. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef text, ControlFontStyleRec style) -> (ControlHandle outControl)")},
  5182. {"CreatePictureControl", (PyCFunction)Ctl_CreatePictureControl, 1,
  5183. PyDoc_STR("(WindowPtr window, Rect boundsRect, ControlButtonContentInfo content, Boolean dontTrack) -> (ControlHandle outControl)")},
  5184. {"CreateIconControl", (PyCFunction)Ctl_CreateIconControl, 1,
  5185. PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, ControlButtonContentInfo inIconContent, Boolean inDontTrack) -> (ControlHandle outControl)")},
  5186. {"CreateWindowHeaderControl", (PyCFunction)Ctl_CreateWindowHeaderControl, 1,
  5187. PyDoc_STR("(WindowPtr window, Rect boundsRect, Boolean isListHeader) -> (ControlHandle outControl)")},
  5188. {"CreatePushButtonControl", (PyCFunction)Ctl_CreatePushButtonControl, 1,
  5189. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title) -> (ControlHandle outControl)")},
  5190. {"CreatePushButtonWithIconControl", (PyCFunction)Ctl_CreatePushButtonWithIconControl, 1,
  5191. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, ControlButtonContentInfo icon, UInt16 iconAlignment) -> (ControlHandle outControl)")},
  5192. {"CreateRadioButtonControl", (PyCFunction)Ctl_CreateRadioButtonControl, 1,
  5193. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, SInt32 initialValue, Boolean autoToggle) -> (ControlHandle outControl)")},
  5194. {"CreateCheckBoxControl", (PyCFunction)Ctl_CreateCheckBoxControl, 1,
  5195. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, SInt32 initialValue, Boolean autoToggle) -> (ControlHandle outControl)")},
  5196. {"CreateScrollBarControl", (PyCFunction)Ctl_CreateScrollBarControl, 1,
  5197. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt32 value, SInt32 minimum, SInt32 maximum, SInt32 viewSize, Boolean liveTracking, PyObject* liveTrackingProc) -> (ControlHandle outControl)")},
  5198. {"CreatePopupButtonControl", (PyCFunction)Ctl_CreatePopupButtonControl, 1,
  5199. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef title, SInt16 menuID, Boolean variableWidth, SInt16 titleWidth, SInt16 titleJustification, Style titleStyle) -> (ControlHandle outControl)")},
  5200. {"CreateRadioGroupControl", (PyCFunction)Ctl_CreateRadioGroupControl, 1,
  5201. PyDoc_STR("(WindowPtr window, Rect boundsRect) -> (ControlHandle outControl)")},
  5202. {"CreateScrollingTextBoxControl", (PyCFunction)Ctl_CreateScrollingTextBoxControl, 1,
  5203. PyDoc_STR("(WindowPtr window, Rect boundsRect, SInt16 contentResID, Boolean autoScroll, UInt32 delayBeforeAutoScroll, UInt32 delayBetweenAutoScroll, UInt16 autoScrollAmount) -> (ControlHandle outControl)")},
  5204. {"CreateDisclosureButtonControl", (PyCFunction)Ctl_CreateDisclosureButtonControl, 1,
  5205. PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, SInt32 inValue, Boolean inAutoToggles) -> (ControlHandle outControl)")},
  5206. {"CreateRoundButtonControl", (PyCFunction)Ctl_CreateRoundButtonControl, 1,
  5207. PyDoc_STR("(WindowPtr inWindow, Rect inBoundsRect, SInt16 inSize, ControlButtonContentInfo inContent) -> (ControlHandle outControl)")},
  5208. {"CreateDataBrowserControl", (PyCFunction)Ctl_CreateDataBrowserControl, 1,
  5209. PyDoc_STR("(WindowPtr window, Rect boundsRect, OSType style) -> (ControlHandle outControl)")},
  5210. {"CreateEditUnicodeTextControl", (PyCFunction)Ctl_CreateEditUnicodeTextControl, 1,
  5211. PyDoc_STR("(WindowPtr window, Rect boundsRect, CFStringRef text, Boolean isPassword, ControlFontStyleRec style) -> (ControlHandle outControl)")},
  5212. {"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1,
  5213. PyDoc_STR("(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)")},
  5214. {"as_Control", (PyCFunction)Ctl_as_Control, 1,
  5215. PyDoc_STR("(Handle h) -> (ControlHandle _rv)")},
  5216. {"CreateTabsControl", (PyCFunction)Ctl_CreateTabsControl, 1,
  5217. PyDoc_STR("(WindowPtr window, Rect boundsRect, UInt16 size, UInt16 direction, ControlTabEntry tabArray) -> (ControlHandle outControl)")},
  5218. {NULL, NULL, 0}
  5219. };
  5220. static PyObject *
  5221. CtlObj_NewUnmanaged(ControlHandle itself)
  5222. {
  5223. ControlObject *it;
  5224. if (itself == NULL) return PyMac_Error(resNotFound);
  5225. it = PyObject_NEW(ControlObject, &Control_Type);
  5226. if (it == NULL) return NULL;
  5227. it->ob_itself = itself;
  5228. it->ob_callbackdict = NULL;
  5229. return (PyObject *)it;
  5230. }
  5231. static PyObject *
  5232. CtlObj_WhichControl(ControlHandle c)
  5233. {
  5234. PyObject *it;
  5235. if (c == NULL)
  5236. it = Py_None;
  5237. else {
  5238. it = (PyObject *) GetControlReference(c);
  5239. /*
  5240. ** If the refcon is zero or doesn't point back to the Python object
  5241. ** the control is not ours. Return a temporary object.
  5242. */
  5243. if (it == NULL || ((ControlObject *)it)->ob_itself != c)
  5244. return CtlObj_NewUnmanaged(c);
  5245. }
  5246. Py_INCREF(it);
  5247. return it;
  5248. }
  5249. static int
  5250. settrackfunc(PyObject *obj)
  5251. {
  5252. if (tracker) {
  5253. PyErr_SetString(Ctl_Error, "Tracker function in use");
  5254. return 0;
  5255. }
  5256. tracker = obj;
  5257. Py_INCREF(tracker);
  5258. return 1;
  5259. }
  5260. static void
  5261. clrtrackfunc(void)
  5262. {
  5263. Py_XDECREF(tracker);
  5264. tracker = 0;
  5265. }
  5266. static pascal void
  5267. mytracker(ControlHandle ctl, short part)
  5268. {
  5269. PyObject *args, *rv=0;
  5270. args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
  5271. if (args && tracker) {
  5272. rv = PyEval_CallObject(tracker, args);
  5273. Py_DECREF(args);
  5274. }
  5275. if (rv)
  5276. Py_DECREF(rv);
  5277. else {
  5278. PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n");
  5279. PyErr_Print();
  5280. }
  5281. }
  5282. static int
  5283. setcallback(PyObject *myself, OSType which, PyObject *callback, UniversalProcPtr *uppp)
  5284. {
  5285. ControlObject *self = (ControlObject *)myself;
  5286. char keybuf[9];
  5287. if ( which == kMyControlActionProcTag )
  5288. *uppp = (UniversalProcPtr)myactionproc_upp;
  5289. else if ( which == kControlUserPaneKeyDownProcTag )
  5290. *uppp = (UniversalProcPtr)mykeydownproc_upp;
  5291. else if ( which == kControlUserPaneFocusProcTag )
  5292. *uppp = (UniversalProcPtr)myfocusproc_upp;
  5293. else if ( which == kControlUserPaneDrawProcTag )
  5294. *uppp = (UniversalProcPtr)mydrawproc_upp;
  5295. else if ( which == kControlUserPaneIdleProcTag )
  5296. *uppp = (UniversalProcPtr)myidleproc_upp;
  5297. else if ( which == kControlUserPaneHitTestProcTag )
  5298. *uppp = (UniversalProcPtr)myhittestproc_upp;
  5299. else if ( which == kControlUserPaneTrackingProcTag )
  5300. *uppp = (UniversalProcPtr)mytrackingproc_upp;
  5301. else
  5302. return -1;
  5303. /* Only now do we test for clearing of the callback: */
  5304. if ( callback == Py_None )
  5305. *uppp = NULL;
  5306. /* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
  5307. if ( self->ob_callbackdict == NULL )
  5308. if ( (self->ob_callbackdict = PyDict_New()) == NULL )
  5309. return -1;
  5310. /* And store the Python callback */
  5311. sprintf(keybuf, "%x", (unsigned)which);
  5312. if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
  5313. return -1;
  5314. return 0;
  5315. }
  5316. static PyObject *
  5317. callcallback(ControlObject *self, OSType which, PyObject *arglist)
  5318. {
  5319. char keybuf[9];
  5320. PyObject *func, *rv;
  5321. sprintf(keybuf, "%x", (unsigned)which);
  5322. if ( self->ob_callbackdict == NULL ||
  5323. (func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
  5324. PySys_WriteStderr("Control callback %x without callback object\n", (unsigned)which);
  5325. return NULL;
  5326. }
  5327. rv = PyEval_CallObject(func, arglist);
  5328. if ( rv == NULL ) {
  5329. PySys_WriteStderr("Exception in control callback %x handler\n", (unsigned)which);
  5330. PyErr_Print();
  5331. }
  5332. return rv;
  5333. }
  5334. static pascal void
  5335. myactionproc(ControlHandle control, SInt16 part)
  5336. {
  5337. ControlObject *ctl_obj;
  5338. PyObject *arglist, *rv;
  5339. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5340. arglist = Py_BuildValue("Oh", ctl_obj, part);
  5341. rv = callcallback(ctl_obj, kMyControlActionProcTag, arglist);
  5342. Py_XDECREF(arglist);
  5343. Py_XDECREF(rv);
  5344. }
  5345. static pascal ControlPartCode
  5346. mykeydownproc(ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
  5347. {
  5348. ControlObject *ctl_obj;
  5349. PyObject *arglist, *rv;
  5350. short c_rv = 0;
  5351. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5352. arglist = Py_BuildValue("Ohhh", ctl_obj, keyCode, charCode, modifiers);
  5353. rv = callcallback(ctl_obj, kControlUserPaneKeyDownProcTag, arglist);
  5354. Py_XDECREF(arglist);
  5355. if ( rv )
  5356. if (!PyArg_Parse(rv, "h", &c_rv))
  5357. PyErr_Clear();
  5358. Py_XDECREF(rv);
  5359. return (ControlPartCode)c_rv;
  5360. }
  5361. static pascal ControlPartCode
  5362. myfocusproc(ControlHandle control, ControlPartCode part)
  5363. {
  5364. ControlObject *ctl_obj;
  5365. PyObject *arglist, *rv;
  5366. short c_rv = kControlFocusNoPart;
  5367. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5368. arglist = Py_BuildValue("Oh", ctl_obj, part);
  5369. rv = callcallback(ctl_obj, kControlUserPaneFocusProcTag, arglist);
  5370. Py_XDECREF(arglist);
  5371. if ( rv )
  5372. if (!PyArg_Parse(rv, "h", &c_rv))
  5373. PyErr_Clear();
  5374. Py_XDECREF(rv);
  5375. return (ControlPartCode)c_rv;
  5376. }
  5377. static pascal void
  5378. mydrawproc(ControlHandle control, SInt16 part)
  5379. {
  5380. ControlObject *ctl_obj;
  5381. PyObject *arglist, *rv;
  5382. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5383. arglist = Py_BuildValue("Oh", ctl_obj, part);
  5384. rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
  5385. Py_XDECREF(arglist);
  5386. Py_XDECREF(rv);
  5387. }
  5388. static pascal void
  5389. myidleproc(ControlHandle control)
  5390. {
  5391. ControlObject *ctl_obj;
  5392. PyObject *arglist, *rv;
  5393. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5394. arglist = Py_BuildValue("O", ctl_obj);
  5395. rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
  5396. Py_XDECREF(arglist);
  5397. Py_XDECREF(rv);
  5398. }
  5399. static pascal ControlPartCode
  5400. myhittestproc(ControlHandle control, Point where)
  5401. {
  5402. ControlObject *ctl_obj;
  5403. PyObject *arglist, *rv;
  5404. short c_rv = -1;
  5405. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5406. arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
  5407. rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
  5408. Py_XDECREF(arglist);
  5409. /* Ignore errors, nothing we can do about them */
  5410. if ( rv )
  5411. if (!PyArg_Parse(rv, "h", &c_rv))
  5412. PyErr_Clear();
  5413. Py_XDECREF(rv);
  5414. return (ControlPartCode)c_rv;
  5415. }
  5416. static pascal ControlPartCode
  5417. mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc)
  5418. {
  5419. ControlObject *ctl_obj;
  5420. PyObject *arglist, *rv;
  5421. short c_rv = -1;
  5422. ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
  5423. /* We cannot pass the actionProc without lots of work */
  5424. arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
  5425. rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
  5426. Py_XDECREF(arglist);
  5427. if ( rv )
  5428. if (!PyArg_Parse(rv, "h", &c_rv))
  5429. PyErr_Clear();
  5430. Py_XDECREF(rv);
  5431. return (ControlPartCode)c_rv;
  5432. }
  5433. #else /* __LP64__ */
  5434. static PyMethodDef Ctl_methods[] = {
  5435. {NULL, NULL, 0}
  5436. };
  5437. #endif /* __LP64__ */
  5438. void init_Ctl(void)
  5439. {
  5440. PyObject *m;
  5441. #ifndef __LP64__
  5442. PyObject *d;
  5443. mytracker_upp = NewControlActionUPP(mytracker);
  5444. myactionproc_upp = NewControlActionUPP(myactionproc);
  5445. mykeydownproc_upp = NewControlUserPaneKeyDownUPP(mykeydownproc);
  5446. myfocusproc_upp = NewControlUserPaneFocusUPP(myfocusproc);
  5447. mydrawproc_upp = NewControlUserPaneDrawUPP(mydrawproc);
  5448. myidleproc_upp = NewControlUserPaneIdleUPP(myidleproc);
  5449. myhittestproc_upp = NewControlUserPaneHitTestUPP(myhittestproc);
  5450. mytrackingproc_upp = NewControlUserPaneTrackingUPP(mytrackingproc);
  5451. PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New);
  5452. PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
  5453. #endif /* !__LP64__ */
  5454. m = Py_InitModule("_Ctl", Ctl_methods);
  5455. #ifndef __LP64__
  5456. d = PyModule_GetDict(m);
  5457. Ctl_Error = PyMac_GetOSErrException();
  5458. if (Ctl_Error == NULL ||
  5459. PyDict_SetItemString(d, "Error", Ctl_Error) != 0)
  5460. return;
  5461. Control_Type.ob_type = &PyType_Type;
  5462. if (PyType_Ready(&Control_Type) < 0) return;
  5463. Py_INCREF(&Control_Type);
  5464. PyModule_AddObject(m, "Control", (PyObject *)&Control_Type);
  5465. /* Backward-compatible name */
  5466. Py_INCREF(&Control_Type);
  5467. PyModule_AddObject(m, "ControlType", (PyObject *)&Control_Type);
  5468. #endif /* !__LP64__ */
  5469. }
  5470. /* ======================== End module _Ctl ========================= */