/Mac/Modules/ctl/_Ctlmodule.c

http://unladen-swallow.googlecode.com/ · C · 5815 lines · 5442 code · 345 blank · 28 comment · 654 complexity · c92a74b5bb99169d9775d91ee2505c09 MD5 · raw file

Large files are truncated click here to view the full file

  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. r