1995-01-30 11:53:55 +00:00
|
|
|
|
|
|
|
/* =========================== Module Ctl =========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "macglue.h"
|
2000-07-14 22:16:45 +00:00
|
|
|
#include "pymactoolbox.h"
|
1995-01-30 11:53:55 +00:00
|
|
|
|
|
|
|
#include <Controls.h>
|
|
|
|
|
2000-07-14 22:16:45 +00:00
|
|
|
staticforward PyObject *CtlObj_WhichControl(ControlHandle);
|
|
|
|
|
1999-02-07 14:02:03 +00:00
|
|
|
#define as_Control(h) ((ControlHandle)h)
|
1999-12-23 14:32:06 +00:00
|
|
|
#define as_Resource(ctl) ((Handle)ctl)
|
2000-07-14 22:37:27 +00:00
|
|
|
#if TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
#define GetControlRect(ctl, rectp) GetControlBounds(ctl, rectp)
|
|
|
|
#else
|
2000-03-21 16:25:23 +00:00
|
|
|
#define GetControlRect(ctl, rectp) (*(rectp) = ((*(ctl))->contrlRect))
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
1995-01-30 11:53:55 +00:00
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
/*
|
|
|
|
** Parse/generate ControlFontStyleRec records
|
|
|
|
*/
|
|
|
|
#if 0 /* Not needed */
|
2000-07-14 22:16:45 +00:00
|
|
|
static PyObject *
|
|
|
|
ControlFontStyle_New(itself)
|
1998-02-20 16:02:09 +00:00
|
|
|
ControlFontStyleRec *itself;
|
|
|
|
{
|
|
|
|
|
|
|
|
return Py_BuildValue("hhhhhhO&O&", itself->flags, itself->font,
|
|
|
|
itself->size, itself->style, itself->mode, itself->just,
|
|
|
|
QdRGB_New, &itself->foreColor, QdRGB_New, &itself->backColor);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:16:45 +00:00
|
|
|
static int
|
1998-02-20 16:02:09 +00:00
|
|
|
ControlFontStyle_Convert(v, itself)
|
|
|
|
PyObject *v;
|
|
|
|
ControlFontStyleRec *itself;
|
|
|
|
{
|
|
|
|
return PyArg_ParseTuple(v, "hhhhhhO&O&", &itself->flags,
|
1999-12-09 22:49:51 +00:00
|
|
|
&itself->font, &itself->size, &itself->style, &itself->mode,
|
|
|
|
&itself->just, QdRGB_Convert, &itself->foreColor,
|
1998-02-20 16:02:09 +00:00
|
|
|
QdRGB_Convert, &itself->backColor);
|
|
|
|
}
|
|
|
|
|
1999-12-09 22:49:51 +00:00
|
|
|
/* TrackControl and HandleControlClick callback support */
|
1998-05-28 14:20:09 +00:00
|
|
|
static PyObject *tracker;
|
|
|
|
static ControlActionUPP mytracker_upp;
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-03-20 16:09:09 +00:00
|
|
|
static ControlUserPaneDrawUPP mydrawproc_upp;
|
|
|
|
static ControlUserPaneIdleUPP myidleproc_upp;
|
2000-03-21 23:03:02 +00:00
|
|
|
static ControlUserPaneHitTestUPP myhittestproc_upp;
|
|
|
|
static ControlUserPaneTrackingUPP mytrackingproc_upp;
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
1998-05-28 14:20:09 +00:00
|
|
|
|
|
|
|
extern int settrackfunc(PyObject *); /* forward */
|
|
|
|
extern void clrtrackfunc(void); /* forward */
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-07-11 21:12:55 +00:00
|
|
|
staticforward int setcallback(PyObject *, OSType, PyObject *, UniversalProcPtr *);
|
|
|
|
#endif
|
1998-05-28 14:20:09 +00:00
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
static PyObject *Ctl_Error;
|
|
|
|
|
|
|
|
/* ---------------------- Object type Control ----------------------- */
|
|
|
|
|
|
|
|
PyTypeObject Control_Type;
|
|
|
|
|
|
|
|
#define CtlObj_Check(x) ((x)->ob_type == &Control_Type)
|
|
|
|
|
|
|
|
typedef struct ControlObject {
|
|
|
|
PyObject_HEAD
|
|
|
|
ControlHandle ob_itself;
|
2000-03-20 16:09:09 +00:00
|
|
|
PyObject *ob_callbackdict;
|
1995-01-30 11:53:55 +00:00
|
|
|
} ControlObject;
|
|
|
|
|
|
|
|
PyObject *CtlObj_New(itself)
|
1995-06-06 12:55:40 +00:00
|
|
|
ControlHandle itself;
|
1995-01-30 11:53:55 +00:00
|
|
|
{
|
|
|
|
ControlObject *it;
|
|
|
|
if (itself == NULL) return PyMac_Error(resNotFound);
|
|
|
|
it = PyObject_NEW(ControlObject, &Control_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
1997-04-08 15:26:03 +00:00
|
|
|
SetControlReference(itself, (long)it);
|
2000-03-20 16:09:09 +00:00
|
|
|
it->ob_callbackdict = NULL;
|
1995-01-30 11:53:55 +00:00
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
|
|
|
CtlObj_Convert(v, p_itself)
|
|
|
|
PyObject *v;
|
|
|
|
ControlHandle *p_itself;
|
|
|
|
{
|
|
|
|
if (!CtlObj_Check(v))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "Control required");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*p_itself = ((ControlObject *)v)->ob_itself;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CtlObj_dealloc(self)
|
|
|
|
ControlObject *self;
|
|
|
|
{
|
2000-03-20 16:09:09 +00:00
|
|
|
Py_XDECREF(self->ob_callbackdict);
|
1999-12-09 22:49:51 +00:00
|
|
|
if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */
|
1995-01-30 11:53:55 +00:00
|
|
|
PyMem_DEL(self);
|
|
|
|
}
|
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
static PyObject *CtlObj_HiliteControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlPartCode hiliteState;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&hiliteState))
|
|
|
|
return NULL;
|
|
|
|
HiliteControl(_self->ob_itself,
|
|
|
|
hiliteState);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_ShowControl(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
ShowControl(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_HideControl(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
HideControl(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
static PyObject *CtlObj_IsControlActive(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = IsControlActive(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_IsControlVisible(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = IsControlVisible(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_ActivateControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = ActivateControl(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_DeactivateControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = DeactivateControl(_self->ob_itself);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlVisibility(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Boolean inIsVisible;
|
|
|
|
Boolean inDoDraw;
|
|
|
|
if (!PyArg_ParseTuple(_args, "bb",
|
|
|
|
&inIsVisible,
|
|
|
|
&inDoDraw))
|
|
|
|
return NULL;
|
|
|
|
_err = SetControlVisibility(_self->ob_itself,
|
|
|
|
inIsVisible,
|
|
|
|
inDoDraw);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_Draw1Control(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
Draw1Control(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
static PyObject *CtlObj_GetBestControlRect(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
OSErr _err;
|
|
|
|
Rect outRect;
|
|
|
|
SInt16 outBaseLineOffset;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
_err = GetBestControlRect(_self->ob_itself,
|
|
|
|
&outRect,
|
|
|
|
&outBaseLineOffset);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&h",
|
|
|
|
PyMac_BuildRect, &outRect,
|
|
|
|
outBaseLineOffset);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlFontStyle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ControlFontStyleRec inStyle;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ControlFontStyle_Convert, &inStyle))
|
|
|
|
return NULL;
|
|
|
|
_err = SetControlFontStyle(_self->ob_itself,
|
|
|
|
&inStyle);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_DrawControlInCurrentPort(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
DrawControlInCurrentPort(_self->ob_itself);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetUpControlBackground(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inDepth;
|
|
|
|
Boolean inIsColorDevice;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hb",
|
|
|
|
&inDepth,
|
|
|
|
&inIsColorDevice))
|
|
|
|
return NULL;
|
|
|
|
_err = SetUpControlBackground(_self->ob_itself,
|
|
|
|
inDepth,
|
|
|
|
inIsColorDevice);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1999-12-12 21:41:51 +00:00
|
|
|
static PyObject *CtlObj_SetUpControlTextColor(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inDepth;
|
|
|
|
Boolean inIsColorDevice;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hb",
|
|
|
|
&inDepth,
|
|
|
|
&inIsColorDevice))
|
|
|
|
return NULL;
|
|
|
|
_err = SetUpControlTextColor(_self->ob_itself,
|
|
|
|
inDepth,
|
|
|
|
inIsColorDevice);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_DragControl(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-11-14 10:41:55 +00:00
|
|
|
Point startPoint;
|
1995-06-09 20:56:31 +00:00
|
|
|
Rect limitRect;
|
|
|
|
Rect slopRect;
|
|
|
|
DragConstraint axis;
|
2000-07-07 13:09:35 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&H",
|
1995-11-14 10:41:55 +00:00
|
|
|
PyMac_GetPoint, &startPoint,
|
1995-06-09 20:56:31 +00:00
|
|
|
PyMac_GetRect, &limitRect,
|
|
|
|
PyMac_GetRect, &slopRect,
|
|
|
|
&axis))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
DragControl(_self->ob_itself,
|
1995-11-14 10:41:55 +00:00
|
|
|
startPoint,
|
1995-06-09 20:56:31 +00:00
|
|
|
&limitRect,
|
|
|
|
&slopRect,
|
|
|
|
axis);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_TestControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlPartCode _rv;
|
1998-02-20 16:02:09 +00:00
|
|
|
Point testPoint;
|
1995-06-09 20:56:31 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
1998-02-20 16:02:09 +00:00
|
|
|
PyMac_GetPoint, &testPoint))
|
1995-06-09 20:56:31 +00:00
|
|
|
return NULL;
|
|
|
|
_rv = TestControl(_self->ob_itself,
|
1998-02-20 16:02:09 +00:00
|
|
|
testPoint);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_HandleControlKey(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt16 _rv;
|
|
|
|
SInt16 inKeyCode;
|
|
|
|
SInt16 inCharCode;
|
|
|
|
SInt16 inModifiers;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hhh",
|
|
|
|
&inKeyCode,
|
|
|
|
&inCharCode,
|
|
|
|
&inModifiers))
|
|
|
|
return NULL;
|
|
|
|
_rv = HandleControlKey(_self->ob_itself,
|
|
|
|
inKeyCode,
|
|
|
|
inCharCode,
|
|
|
|
inModifiers);
|
1995-06-09 20:56:31 +00:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
static PyObject *CtlObj_MoveControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 h;
|
|
|
|
SInt16 v;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "hh",
|
|
|
|
&h,
|
|
|
|
&v))
|
|
|
|
return NULL;
|
|
|
|
MoveControl(_self->ob_itself,
|
|
|
|
h,
|
|
|
|
v);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SizeControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 w;
|
|
|
|
SInt16 h;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "hh",
|
|
|
|
&w,
|
|
|
|
&h))
|
|
|
|
return NULL;
|
|
|
|
SizeControl(_self->ob_itself,
|
|
|
|
w,
|
|
|
|
h);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_SetControlTitle(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
Str255 title;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetStr255, title))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SetControlTitle(_self->ob_itself,
|
|
|
|
title);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlTitle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Str255 title;
|
1999-03-07 20:05:20 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-06-09 20:56:31 +00:00
|
|
|
return NULL;
|
|
|
|
GetControlTitle(_self->ob_itself,
|
|
|
|
title);
|
1999-03-07 20:05:20 +00:00
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildStr255, title);
|
1995-01-30 11:53:55 +00:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 12:55:40 +00:00
|
|
|
static PyObject *CtlObj_GetControlValue(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 _rv;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 12:55:40 +00:00
|
|
|
_rv = GetControlValue(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_SetControlValue(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 newValue;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
1995-06-09 20:56:31 +00:00
|
|
|
&newValue))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SetControlValue(_self->ob_itself,
|
|
|
|
newValue);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 12:55:40 +00:00
|
|
|
static PyObject *CtlObj_GetControlMinimum(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 _rv;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 12:55:40 +00:00
|
|
|
_rv = GetControlMinimum(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_SetControlMinimum(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 newMinimum;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
1995-06-09 20:56:31 +00:00
|
|
|
&newMinimum))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SetControlMinimum(_self->ob_itself,
|
|
|
|
newMinimum);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 12:55:40 +00:00
|
|
|
static PyObject *CtlObj_GetControlMaximum(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 _rv;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 12:55:40 +00:00
|
|
|
_rv = GetControlMaximum(_self->ob_itself);
|
1995-01-30 11:53:55 +00:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_SetControlMaximum(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 newMaximum;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&newMaximum))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SetControlMaximum(_self->ob_itself,
|
|
|
|
newMaximum);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1999-12-12 21:41:51 +00:00
|
|
|
static PyObject *CtlObj_GetControlViewSize(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetControlViewSize(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlViewSize(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 newViewSize;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&newViewSize))
|
|
|
|
return NULL;
|
|
|
|
SetControlViewSize(_self->ob_itself,
|
|
|
|
newViewSize);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControl32BitValue(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetControl32BitValue(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControl32BitValue(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 newValue;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&newValue))
|
|
|
|
return NULL;
|
|
|
|
SetControl32BitValue(_self->ob_itself,
|
|
|
|
newValue);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControl32BitMaximum(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetControl32BitMaximum(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControl32BitMaximum(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 newMaximum;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&newMaximum))
|
|
|
|
return NULL;
|
|
|
|
SetControl32BitMaximum(_self->ob_itself,
|
|
|
|
newMaximum);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControl32BitMinimum(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetControl32BitMinimum(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControl32BitMinimum(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 newMinimum;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&newMinimum))
|
|
|
|
return NULL;
|
|
|
|
SetControl32BitMinimum(_self->ob_itself,
|
|
|
|
newMinimum);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_IsValidControlHandle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = IsValidControlHandle(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_RemoveControlProperty(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2000-06-02 21:35:07 +00:00
|
|
|
OSStatus _err;
|
1999-12-12 21:41:51 +00:00
|
|
|
OSType propertyCreator;
|
|
|
|
OSType propertyTag;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
PyMac_GetOSType, &propertyCreator,
|
|
|
|
PyMac_GetOSType, &propertyTag))
|
|
|
|
return NULL;
|
2000-06-02 21:35:07 +00:00
|
|
|
_err = RemoveControlProperty(_self->ob_itself,
|
|
|
|
propertyCreator,
|
|
|
|
propertyTag);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
1999-12-12 21:41:51 +00:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlRegion(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2000-06-02 21:35:07 +00:00
|
|
|
OSStatus _err;
|
1999-12-12 21:41:51 +00:00
|
|
|
ControlPartCode inPart;
|
|
|
|
RgnHandle outRegion;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&inPart,
|
|
|
|
ResObj_Convert, &outRegion))
|
|
|
|
return NULL;
|
2000-06-02 21:35:07 +00:00
|
|
|
_err = GetControlRegion(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
outRegion);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
1999-12-12 21:41:51 +00:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_GetControlVariant(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
ControlVariant _rv;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
_rv = GetControlVariant(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
1995-01-30 11:53:55 +00:00
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_SetControlReference(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt32 data;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&data))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SetControlReference(_self->ob_itself,
|
|
|
|
data);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 20:56:31 +00:00
|
|
|
static PyObject *CtlObj_GetControlReference(_self, _args)
|
1995-01-30 11:53:55 +00:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt32 _rv;
|
1995-06-06 12:55:40 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
_rv = GetControlReference(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
1995-01-30 11:53:55 +00:00
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
1997-08-15 14:32:18 +00:00
|
|
|
static PyObject *CtlObj_GetAuxiliaryControlRecord(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
AuxCtlHandle acHndl;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetAuxiliaryControlRecord(_self->ob_itself,
|
|
|
|
&acHndl);
|
|
|
|
_res = Py_BuildValue("bO&",
|
|
|
|
_rv,
|
|
|
|
ResObj_New, acHndl);
|
|
|
|
return _res;
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
1997-08-15 14:32:18 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlColor(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
CCTabHandle newColorTable;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &newColorTable))
|
|
|
|
return NULL;
|
|
|
|
SetControlColor(_self->ob_itself,
|
|
|
|
newColorTable);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-07-14 22:16:45 +00:00
|
|
|
|
2000-06-02 21:35:07 +00:00
|
|
|
static PyObject *CtlObj_GetBevelButtonMenuValue(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 outValue;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetBevelButtonMenuValue(_self->ob_itself,
|
|
|
|
&outValue);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
outValue);
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetBevelButtonMenuValue(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inValue;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&inValue))
|
|
|
|
return NULL;
|
|
|
|
_err = SetBevelButtonMenuValue(_self->ob_itself,
|
|
|
|
inValue);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_GetBevelButtonMenuHandle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
MenuHandle outHandle;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetBevelButtonMenuHandle(_self->ob_itself,
|
|
|
|
&outHandle);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
MenuObj_New, outHandle);
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetBevelButtonTransform(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
IconTransformType transform;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&transform))
|
|
|
|
return NULL;
|
|
|
|
_err = SetBevelButtonTransform(_self->ob_itself,
|
|
|
|
transform);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetImageWellTransform(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
IconTransformType inTransform;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&inTransform))
|
|
|
|
return NULL;
|
|
|
|
_err = SetImageWellTransform(_self->ob_itself,
|
|
|
|
inTransform);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_GetTabContentRect(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
Rect outContentRect;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetTabContentRect(_self->ob_itself,
|
|
|
|
&outContentRect);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildRect, &outContentRect);
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetTabEnabled(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inTabToHilite;
|
|
|
|
Boolean inEnabled;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hb",
|
|
|
|
&inTabToHilite,
|
|
|
|
&inEnabled))
|
|
|
|
return NULL;
|
|
|
|
_err = SetTabEnabled(_self->ob_itself,
|
|
|
|
inTabToHilite,
|
|
|
|
inEnabled);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetDisclosureTriangleLastValue(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
SInt16 inValue;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&inValue))
|
|
|
|
return NULL;
|
|
|
|
_err = SetDisclosureTriangleLastValue(_self->ob_itself,
|
|
|
|
inValue);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
1997-08-15 14:32:18 +00:00
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
static PyObject *CtlObj_SendControlMessage(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
SInt32 _rv;
|
|
|
|
SInt16 inMessage;
|
|
|
|
SInt32 inParam;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hl",
|
|
|
|
&inMessage,
|
|
|
|
&inParam))
|
|
|
|
return NULL;
|
|
|
|
_rv = SendControlMessage(_self->ob_itself,
|
|
|
|
inMessage,
|
|
|
|
inParam);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_EmbedControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ControlHandle inContainer;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
CtlObj_Convert, &inContainer))
|
|
|
|
return NULL;
|
|
|
|
_err = EmbedControl(_self->ob_itself,
|
|
|
|
inContainer);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_AutoEmbedControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = AutoEmbedControl(_self->ob_itself,
|
|
|
|
inWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetSuperControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ControlHandle outParent;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetSuperControl(_self->ob_itself,
|
|
|
|
&outParent);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_WhichControl, outParent);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_CountSubControls(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
1999-12-09 22:49:51 +00:00
|
|
|
UInt16 outNumChildren;
|
1998-02-20 16:02:09 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = CountSubControls(_self->ob_itself,
|
|
|
|
&outNumChildren);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
2000-07-07 13:09:35 +00:00
|
|
|
_res = Py_BuildValue("H",
|
1998-02-20 16:02:09 +00:00
|
|
|
outNumChildren);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetIndexedSubControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
1999-12-09 22:49:51 +00:00
|
|
|
UInt16 inIndex;
|
1998-02-20 16:02:09 +00:00
|
|
|
ControlHandle outSubControl;
|
2000-07-07 13:09:35 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "H",
|
1998-02-20 16:02:09 +00:00
|
|
|
&inIndex))
|
|
|
|
return NULL;
|
|
|
|
_err = GetIndexedSubControl(_self->ob_itself,
|
|
|
|
inIndex,
|
|
|
|
&outSubControl);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_WhichControl, outSubControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlSupervisor(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ControlHandle inBoss;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
CtlObj_Convert, &inBoss))
|
|
|
|
return NULL;
|
|
|
|
_err = SetControlSupervisor(_self->ob_itself,
|
|
|
|
inBoss);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlFeatures(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
UInt32 outFeatures;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = GetControlFeatures(_self->ob_itself,
|
|
|
|
&outFeatures);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
outFeatures);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlDataSize(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
Size outMaxSize;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName))
|
|
|
|
return NULL;
|
|
|
|
_err = GetControlDataSize(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
&outMaxSize);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
outMaxSize);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-18 20:16:33 +00:00
|
|
|
static PyObject *CtlObj_as_Resource(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1999-12-23 14:32:06 +00:00
|
|
|
Handle _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = as_Resource(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
ResObj_New, _rv);
|
|
|
|
return _res;
|
1995-06-18 20:16:33 +00:00
|
|
|
}
|
|
|
|
|
2000-03-21 16:25:23 +00:00
|
|
|
static PyObject *CtlObj_GetControlRect(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
Rect rect;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
GetControlRect(_self->ob_itself,
|
|
|
|
&rect);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildRect, &rect);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1996-10-01 10:46:46 +00:00
|
|
|
static PyObject *CtlObj_DisposeControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
if ( _self->ob_itself ) {
|
1997-04-08 15:26:03 +00:00
|
|
|
SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
|
1996-10-01 10:46:46 +00:00
|
|
|
DisposeControl(_self->ob_itself);
|
|
|
|
_self->ob_itself = NULL;
|
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-05-28 14:20:09 +00:00
|
|
|
static PyObject *CtlObj_TrackControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
ControlPartCode _rv;
|
|
|
|
Point startPoint;
|
|
|
|
ControlActionUPP upp = 0;
|
|
|
|
PyObject *callback = 0;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&|O",
|
|
|
|
PyMac_GetPoint, &startPoint, &callback))
|
|
|
|
return NULL;
|
|
|
|
if (callback && callback != Py_None) {
|
|
|
|
if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
|
|
|
|
upp = (ControlActionUPP)-1;
|
|
|
|
else {
|
|
|
|
settrackfunc(callback);
|
|
|
|
upp = mytracker_upp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_rv = TrackControl(_self->ob_itself,
|
|
|
|
startPoint,
|
|
|
|
upp);
|
|
|
|
clrtrackfunc();
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-12-09 22:49:51 +00:00
|
|
|
static PyObject *CtlObj_HandleControlClick(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
ControlPartCode _rv;
|
|
|
|
Point startPoint;
|
|
|
|
SInt16 modifiers;
|
|
|
|
ControlActionUPP upp = 0;
|
|
|
|
PyObject *callback = 0;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&h|O",
|
|
|
|
PyMac_GetPoint, &startPoint,
|
|
|
|
&modifiers,
|
|
|
|
&callback))
|
|
|
|
return NULL;
|
|
|
|
if (callback && callback != Py_None) {
|
|
|
|
if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1)
|
|
|
|
upp = (ControlActionUPP)-1;
|
|
|
|
else {
|
|
|
|
settrackfunc(callback);
|
|
|
|
upp = mytracker_upp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_rv = HandleControlClick(_self->ob_itself,
|
|
|
|
startPoint,
|
|
|
|
modifiers,
|
|
|
|
upp);
|
|
|
|
clrtrackfunc();
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_SetControlData(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
Size bufferSize;
|
|
|
|
Ptr buffer;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&s#",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName,
|
|
|
|
&buffer, &bufferSize))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
_err = SetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
bufferSize,
|
|
|
|
buffer);
|
|
|
|
|
|
|
|
if (_err != noErr)
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlData(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
Size bufferSize;
|
|
|
|
Ptr buffer;
|
|
|
|
Size outSize;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* allocate a buffer for the data */
|
|
|
|
_err = GetControlDataSize(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
&bufferSize);
|
|
|
|
if (_err != noErr)
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
buffer = PyMem_NEW(char, bufferSize);
|
|
|
|
if (buffer == NULL)
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
|
|
|
|
_err = GetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
bufferSize,
|
|
|
|
buffer,
|
|
|
|
&outSize);
|
|
|
|
|
|
|
|
if (_err != noErr) {
|
|
|
|
PyMem_DEL(buffer);
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
}
|
|
|
|
_res = Py_BuildValue("s#", buffer, outSize);
|
|
|
|
PyMem_DEL(buffer);
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-12-19 00:05:50 +00:00
|
|
|
static PyObject *CtlObj_SetControlDataHandle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
Handle buffer;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&O&",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName,
|
1999-12-23 23:06:07 +00:00
|
|
|
OptResObj_Convert, &buffer))
|
1999-12-19 00:05:50 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
_err = SetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
sizeof(buffer),
|
1999-12-29 12:37:22 +00:00
|
|
|
(Ptr)&buffer);
|
1999-12-19 00:05:50 +00:00
|
|
|
|
|
|
|
if (_err != noErr)
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlDataHandle(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
Size bufferSize;
|
|
|
|
Handle hdl;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Check it is handle-sized */
|
|
|
|
_err = GetControlDataSize(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
&bufferSize);
|
|
|
|
if (_err != noErr)
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
if (bufferSize != sizeof(Handle)) {
|
|
|
|
PyErr_SetString(Ctl_Error, "GetControlDataSize() != sizeof(Handle)");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_err = GetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
sizeof(Handle),
|
|
|
|
(Ptr)&hdl,
|
|
|
|
&bufferSize);
|
|
|
|
|
|
|
|
if (_err != noErr) {
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
}
|
|
|
|
return Py_BuildValue("O&", OptResObj_New, hdl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-06-02 21:35:07 +00:00
|
|
|
|
2000-03-20 16:09:09 +00:00
|
|
|
static PyObject *CtlObj_SetControlDataCallback(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
PyObject *callback;
|
2000-07-11 21:12:55 +00:00
|
|
|
UniversalProcPtr c_callback;
|
2000-03-20 16:09:09 +00:00
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&O",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName,
|
|
|
|
&callback))
|
|
|
|
return NULL;
|
|
|
|
|
2000-07-11 21:12:55 +00:00
|
|
|
if ( setcallback((PyObject *)_self, inTagName, callback, &c_callback) < 0 )
|
2000-03-20 16:09:09 +00:00
|
|
|
return NULL;
|
|
|
|
_err = SetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
sizeof(c_callback),
|
|
|
|
(Ptr)&c_callback);
|
|
|
|
|
|
|
|
if (_err != noErr)
|
|
|
|
return PyMac_Error(_err);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-03-20 16:09:09 +00:00
|
|
|
|
1998-06-19 13:35:14 +00:00
|
|
|
static PyObject *CtlObj_GetPopupData(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PopupPrivateDataHandle hdl;
|
|
|
|
|
|
|
|
if ( (*_self->ob_itself)->contrlData == NULL ) {
|
|
|
|
PyErr_SetString(Ctl_Error, "No contrlData handle in control");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
|
|
|
|
HLock((Handle)hdl);
|
|
|
|
_res = Py_BuildValue("O&i", MenuObj_New, (*hdl)->mHandle, (int)(*hdl)->mID);
|
|
|
|
HUnlock((Handle)hdl);
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
1998-06-19 13:35:14 +00:00
|
|
|
|
|
|
|
static PyObject *CtlObj_SetPopupData(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
PopupPrivateDataHandle hdl;
|
|
|
|
MenuHandle mHandle;
|
|
|
|
short mID;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&h", MenuObj_Convert, &mHandle, &mID) )
|
|
|
|
return 0;
|
|
|
|
if ( (*_self->ob_itself)->contrlData == NULL ) {
|
|
|
|
PyErr_SetString(Ctl_Error, "No contrlData handle in control");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hdl = (PopupPrivateDataHandle)(*_self->ob_itself)->contrlData;
|
|
|
|
(*hdl)->mHandle = mHandle;
|
|
|
|
(*hdl)->mID = mID;
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
1998-06-19 13:35:14 +00:00
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
static PyMethodDef CtlObj_methods[] = {
|
1998-02-20 16:02:09 +00:00
|
|
|
{"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1,
|
|
|
|
"(ControlPartCode hiliteState) -> None"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"ShowControl", (PyCFunction)CtlObj_ShowControl, 1,
|
|
|
|
"() -> None"},
|
1995-06-09 20:56:31 +00:00
|
|
|
{"HideControl", (PyCFunction)CtlObj_HideControl, 1,
|
|
|
|
"() -> None"},
|
1998-02-20 16:02:09 +00:00
|
|
|
{"IsControlActive", (PyCFunction)CtlObj_IsControlActive, 1,
|
|
|
|
"() -> (Boolean _rv)"},
|
|
|
|
{"IsControlVisible", (PyCFunction)CtlObj_IsControlVisible, 1,
|
|
|
|
"() -> (Boolean _rv)"},
|
|
|
|
{"ActivateControl", (PyCFunction)CtlObj_ActivateControl, 1,
|
|
|
|
"() -> None"},
|
|
|
|
{"DeactivateControl", (PyCFunction)CtlObj_DeactivateControl, 1,
|
|
|
|
"() -> None"},
|
|
|
|
{"SetControlVisibility", (PyCFunction)CtlObj_SetControlVisibility, 1,
|
|
|
|
"(Boolean inIsVisible, Boolean inDoDraw) -> None"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1,
|
|
|
|
"() -> None"},
|
1998-02-20 16:02:09 +00:00
|
|
|
{"GetBestControlRect", (PyCFunction)CtlObj_GetBestControlRect, 1,
|
|
|
|
"() -> (Rect outRect, SInt16 outBaseLineOffset)"},
|
|
|
|
{"SetControlFontStyle", (PyCFunction)CtlObj_SetControlFontStyle, 1,
|
|
|
|
"(ControlFontStyleRec inStyle) -> None"},
|
|
|
|
{"DrawControlInCurrentPort", (PyCFunction)CtlObj_DrawControlInCurrentPort, 1,
|
|
|
|
"() -> None"},
|
|
|
|
{"SetUpControlBackground", (PyCFunction)CtlObj_SetUpControlBackground, 1,
|
|
|
|
"(SInt16 inDepth, Boolean inIsColorDevice) -> None"},
|
1999-12-12 21:41:51 +00:00
|
|
|
{"SetUpControlTextColor", (PyCFunction)CtlObj_SetUpControlTextColor, 1,
|
|
|
|
"(SInt16 inDepth, Boolean inIsColorDevice) -> None"},
|
1995-06-09 20:56:31 +00:00
|
|
|
{"DragControl", (PyCFunction)CtlObj_DragControl, 1,
|
1995-11-14 10:41:55 +00:00
|
|
|
"(Point startPoint, Rect limitRect, Rect slopRect, DragConstraint axis) -> None"},
|
1995-06-09 20:56:31 +00:00
|
|
|
{"TestControl", (PyCFunction)CtlObj_TestControl, 1,
|
1998-02-20 16:02:09 +00:00
|
|
|
"(Point testPoint) -> (ControlPartCode _rv)"},
|
|
|
|
{"HandleControlKey", (PyCFunction)CtlObj_HandleControlKey, 1,
|
|
|
|
"(SInt16 inKeyCode, SInt16 inCharCode, SInt16 inModifiers) -> (SInt16 _rv)"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"MoveControl", (PyCFunction)CtlObj_MoveControl, 1,
|
1995-06-09 20:56:31 +00:00
|
|
|
"(SInt16 h, SInt16 v) -> None"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"SizeControl", (PyCFunction)CtlObj_SizeControl, 1,
|
1995-06-09 20:56:31 +00:00
|
|
|
"(SInt16 w, SInt16 h) -> None"},
|
|
|
|
{"SetControlTitle", (PyCFunction)CtlObj_SetControlTitle, 1,
|
|
|
|
"(Str255 title) -> None"},
|
|
|
|
{"GetControlTitle", (PyCFunction)CtlObj_GetControlTitle, 1,
|
1999-03-07 20:05:20 +00:00
|
|
|
"() -> (Str255 title)"},
|
1995-06-06 12:55:40 +00:00
|
|
|
{"GetControlValue", (PyCFunction)CtlObj_GetControlValue, 1,
|
1995-06-09 20:56:31 +00:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlValue", (PyCFunction)CtlObj_SetControlValue, 1,
|
|
|
|
"(SInt16 newValue) -> None"},
|
1995-06-06 12:55:40 +00:00
|
|
|
{"GetControlMinimum", (PyCFunction)CtlObj_GetControlMinimum, 1,
|
1995-06-09 20:56:31 +00:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlMinimum", (PyCFunction)CtlObj_SetControlMinimum, 1,
|
|
|
|
"(SInt16 newMinimum) -> None"},
|
1995-06-06 12:55:40 +00:00
|
|
|
{"GetControlMaximum", (PyCFunction)CtlObj_GetControlMaximum, 1,
|
1995-06-09 20:56:31 +00:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlMaximum", (PyCFunction)CtlObj_SetControlMaximum, 1,
|
|
|
|
"(SInt16 newMaximum) -> None"},
|
1999-12-12 21:41:51 +00:00
|
|
|
{"GetControlViewSize", (PyCFunction)CtlObj_GetControlViewSize, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
|
|
|
{"SetControlViewSize", (PyCFunction)CtlObj_SetControlViewSize, 1,
|
|
|
|
"(SInt32 newViewSize) -> None"},
|
|
|
|
{"GetControl32BitValue", (PyCFunction)CtlObj_GetControl32BitValue, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
|
|
|
{"SetControl32BitValue", (PyCFunction)CtlObj_SetControl32BitValue, 1,
|
|
|
|
"(SInt32 newValue) -> None"},
|
|
|
|
{"GetControl32BitMaximum", (PyCFunction)CtlObj_GetControl32BitMaximum, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
|
|
|
{"SetControl32BitMaximum", (PyCFunction)CtlObj_SetControl32BitMaximum, 1,
|
|
|
|
"(SInt32 newMaximum) -> None"},
|
|
|
|
{"GetControl32BitMinimum", (PyCFunction)CtlObj_GetControl32BitMinimum, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
|
|
|
{"SetControl32BitMinimum", (PyCFunction)CtlObj_SetControl32BitMinimum, 1,
|
|
|
|
"(SInt32 newMinimum) -> None"},
|
|
|
|
{"IsValidControlHandle", (PyCFunction)CtlObj_IsValidControlHandle, 1,
|
|
|
|
"() -> (Boolean _rv)"},
|
|
|
|
{"RemoveControlProperty", (PyCFunction)CtlObj_RemoveControlProperty, 1,
|
2000-06-02 21:35:07 +00:00
|
|
|
"(OSType propertyCreator, OSType propertyTag) -> None"},
|
1999-12-12 21:41:51 +00:00
|
|
|
{"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1,
|
2000-06-02 21:35:07 +00:00
|
|
|
"(ControlPartCode inPart, RgnHandle outRegion) -> None"},
|
1995-06-09 20:56:31 +00:00
|
|
|
{"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1,
|
1998-02-20 16:02:09 +00:00
|
|
|
"() -> (ControlVariant _rv)"},
|
1995-06-09 20:56:31 +00:00
|
|
|
{"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1,
|
|
|
|
"(SInt32 data) -> None"},
|
|
|
|
{"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
2000-06-02 21:35:07 +00:00
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
1997-08-15 14:32:18 +00:00
|
|
|
{"GetAuxiliaryControlRecord", (PyCFunction)CtlObj_GetAuxiliaryControlRecord, 1,
|
|
|
|
"() -> (Boolean _rv, AuxCtlHandle acHndl)"},
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
1997-08-15 14:32:18 +00:00
|
|
|
{"SetControlColor", (PyCFunction)CtlObj_SetControlColor, 1,
|
|
|
|
"(CCTabHandle newColorTable) -> None"},
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
2000-07-14 22:16:45 +00:00
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"GetBevelButtonMenuValue", (PyCFunction)CtlObj_GetBevelButtonMenuValue, 1,
|
|
|
|
"() -> (SInt16 outValue)"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"SetBevelButtonMenuValue", (PyCFunction)CtlObj_SetBevelButtonMenuValue, 1,
|
|
|
|
"(SInt16 inValue) -> None"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"GetBevelButtonMenuHandle", (PyCFunction)CtlObj_GetBevelButtonMenuHandle, 1,
|
|
|
|
"() -> (MenuHandle outHandle)"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"SetBevelButtonTransform", (PyCFunction)CtlObj_SetBevelButtonTransform, 1,
|
|
|
|
"(IconTransformType transform) -> None"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"SetImageWellTransform", (PyCFunction)CtlObj_SetImageWellTransform, 1,
|
|
|
|
"(IconTransformType inTransform) -> None"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"GetTabContentRect", (PyCFunction)CtlObj_GetTabContentRect, 1,
|
|
|
|
"() -> (Rect outContentRect)"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"SetTabEnabled", (PyCFunction)CtlObj_SetTabEnabled, 1,
|
|
|
|
"(SInt16 inTabToHilite, Boolean inEnabled) -> None"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON
|
2000-06-02 21:35:07 +00:00
|
|
|
{"SetDisclosureTriangleLastValue", (PyCFunction)CtlObj_SetDisclosureTriangleLastValue, 1,
|
|
|
|
"(SInt16 inValue) -> None"},
|
2000-07-14 22:16:45 +00:00
|
|
|
#endif
|
1998-02-20 16:02:09 +00:00
|
|
|
{"SendControlMessage", (PyCFunction)CtlObj_SendControlMessage, 1,
|
|
|
|
"(SInt16 inMessage, SInt32 inParam) -> (SInt32 _rv)"},
|
|
|
|
{"EmbedControl", (PyCFunction)CtlObj_EmbedControl, 1,
|
|
|
|
"(ControlHandle inContainer) -> None"},
|
|
|
|
{"AutoEmbedControl", (PyCFunction)CtlObj_AutoEmbedControl, 1,
|
|
|
|
"(WindowPtr inWindow) -> None"},
|
|
|
|
{"GetSuperControl", (PyCFunction)CtlObj_GetSuperControl, 1,
|
|
|
|
"() -> (ControlHandle outParent)"},
|
|
|
|
{"CountSubControls", (PyCFunction)CtlObj_CountSubControls, 1,
|
1999-12-09 22:49:51 +00:00
|
|
|
"() -> (UInt16 outNumChildren)"},
|
1998-02-20 16:02:09 +00:00
|
|
|
{"GetIndexedSubControl", (PyCFunction)CtlObj_GetIndexedSubControl, 1,
|
1999-12-09 22:49:51 +00:00
|
|
|
"(UInt16 inIndex) -> (ControlHandle outSubControl)"},
|
1998-02-20 16:02:09 +00:00
|
|
|
{"SetControlSupervisor", (PyCFunction)CtlObj_SetControlSupervisor, 1,
|
|
|
|
"(ControlHandle inBoss) -> None"},
|
|
|
|
{"GetControlFeatures", (PyCFunction)CtlObj_GetControlFeatures, 1,
|
|
|
|
"() -> (UInt32 outFeatures)"},
|
|
|
|
{"GetControlDataSize", (PyCFunction)CtlObj_GetControlDataSize, 1,
|
|
|
|
"(ControlPartCode inPart, ResType inTagName) -> (Size outMaxSize)"},
|
1995-06-18 20:16:33 +00:00
|
|
|
{"as_Resource", (PyCFunction)CtlObj_as_Resource, 1,
|
1999-12-23 14:32:06 +00:00
|
|
|
"() -> (Handle _rv)"},
|
2000-03-21 16:25:23 +00:00
|
|
|
{"GetControlRect", (PyCFunction)CtlObj_GetControlRect, 1,
|
|
|
|
"() -> (Rect rect)"},
|
1996-10-01 10:46:46 +00:00
|
|
|
{"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
|
|
|
|
"() -> None"},
|
1998-05-28 14:20:09 +00:00
|
|
|
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
|
1999-12-09 22:49:51 +00:00
|
|
|
"(Point startPoint [,trackercallback]) -> (ControlPartCode _rv)"},
|
|
|
|
{"HandleControlClick", (PyCFunction)CtlObj_HandleControlClick, 1,
|
|
|
|
"(Point startPoint, Integer modifiers, [,trackercallback]) -> (ControlPartCode _rv)"},
|
|
|
|
{"SetControlData", (PyCFunction)CtlObj_SetControlData, 1,
|
|
|
|
"(stuff) -> None"},
|
|
|
|
{"GetControlData", (PyCFunction)CtlObj_GetControlData, 1,
|
|
|
|
"(part, type) -> String"},
|
1999-12-19 00:05:50 +00:00
|
|
|
{"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1,
|
|
|
|
"(ResObj) -> None"},
|
|
|
|
{"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1,
|
|
|
|
"(part, type) -> ResObj"},
|
2000-06-02 21:35:07 +00:00
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-03-20 16:09:09 +00:00
|
|
|
{"SetControlDataCallback", (PyCFunction)CtlObj_SetControlDataCallback, 1,
|
|
|
|
"(callbackfunc) -> None"},
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
1998-06-19 13:35:14 +00:00
|
|
|
{"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1,
|
|
|
|
NULL},
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
1998-06-19 13:35:14 +00:00
|
|
|
{"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1,
|
|
|
|
NULL},
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
1995-01-30 11:53:55 +00:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodChain CtlObj_chain = { CtlObj_methods, NULL };
|
|
|
|
|
|
|
|
static PyObject *CtlObj_getattr(self, name)
|
|
|
|
ControlObject *self;
|
|
|
|
char *name;
|
|
|
|
{
|
|
|
|
return Py_FindMethodInChain(&CtlObj_chain, (PyObject *)self, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CtlObj_setattr NULL
|
|
|
|
|
1999-03-13 23:07:32 +00:00
|
|
|
static int CtlObj_compare(self, other)
|
|
|
|
ControlObject *self, *other;
|
|
|
|
{
|
|
|
|
unsigned long v, w;
|
|
|
|
|
|
|
|
if (!CtlObj_Check((PyObject *)other))
|
|
|
|
{
|
|
|
|
v=(unsigned long)self;
|
|
|
|
w=(unsigned long)other;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v=(unsigned long)self->ob_itself;
|
|
|
|
w=(unsigned long)other->ob_itself;
|
|
|
|
}
|
|
|
|
if( v < w ) return -1;
|
|
|
|
if( v > w ) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CtlObj_repr NULL
|
|
|
|
|
|
|
|
static long CtlObj_hash(self)
|
|
|
|
ControlObject *self;
|
|
|
|
{
|
|
|
|
return (long)self->ob_itself;
|
|
|
|
}
|
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
PyTypeObject Control_Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0, /*ob_size*/
|
|
|
|
"Control", /*tp_name*/
|
|
|
|
sizeof(ControlObject), /*tp_basicsize*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
|
|
|
(destructor) CtlObj_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
|
|
|
(getattrfunc) CtlObj_getattr, /*tp_getattr*/
|
|
|
|
(setattrfunc) CtlObj_setattr, /*tp_setattr*/
|
1999-03-13 23:07:32 +00:00
|
|
|
(cmpfunc) CtlObj_compare, /*tp_compare*/
|
|
|
|
(reprfunc) CtlObj_repr, /*tp_repr*/
|
|
|
|
(PyNumberMethods *)0, /* tp_as_number */
|
|
|
|
(PySequenceMethods *)0, /* tp_as_sequence */
|
|
|
|
(PyMappingMethods *)0, /* tp_as_mapping */
|
|
|
|
(hashfunc) CtlObj_hash, /*tp_hash*/
|
1995-01-30 11:53:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------- End object type Control --------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Ctl_NewControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
1998-02-20 16:02:09 +00:00
|
|
|
WindowPtr owningWindow;
|
1995-01-30 11:53:55 +00:00
|
|
|
Rect boundsRect;
|
1998-02-20 16:02:09 +00:00
|
|
|
Str255 controlTitle;
|
|
|
|
Boolean initiallyVisible;
|
|
|
|
SInt16 initialValue;
|
|
|
|
SInt16 minimumValue;
|
|
|
|
SInt16 maximumValue;
|
1995-06-09 20:56:31 +00:00
|
|
|
SInt16 procID;
|
1998-02-20 16:02:09 +00:00
|
|
|
SInt32 controlReference;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl",
|
1998-02-20 16:02:09 +00:00
|
|
|
WinObj_Convert, &owningWindow,
|
1995-01-30 11:53:55 +00:00
|
|
|
PyMac_GetRect, &boundsRect,
|
1998-02-20 16:02:09 +00:00
|
|
|
PyMac_GetStr255, controlTitle,
|
|
|
|
&initiallyVisible,
|
|
|
|
&initialValue,
|
|
|
|
&minimumValue,
|
|
|
|
&maximumValue,
|
1995-01-30 11:53:55 +00:00
|
|
|
&procID,
|
1998-02-20 16:02:09 +00:00
|
|
|
&controlReference))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
_rv = NewControl(owningWindow,
|
1995-01-30 11:53:55 +00:00
|
|
|
&boundsRect,
|
1998-02-20 16:02:09 +00:00
|
|
|
controlTitle,
|
|
|
|
initiallyVisible,
|
|
|
|
initialValue,
|
|
|
|
minimumValue,
|
|
|
|
maximumValue,
|
1995-01-30 11:53:55 +00:00
|
|
|
procID,
|
1998-02-20 16:02:09 +00:00
|
|
|
controlReference);
|
1995-01-30 11:53:55 +00:00
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_GetNewControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
1998-02-20 16:02:09 +00:00
|
|
|
SInt16 resourceID;
|
|
|
|
WindowPtr owningWindow;
|
1995-01-30 11:53:55 +00:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
1998-02-20 16:02:09 +00:00
|
|
|
&resourceID,
|
|
|
|
WinObj_Convert, &owningWindow))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
_rv = GetNewControl(resourceID,
|
|
|
|
owningWindow);
|
1995-01-30 11:53:55 +00:00
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_DrawControls(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
WindowPtr theWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &theWindow))
|
|
|
|
return NULL;
|
|
|
|
DrawControls(theWindow);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_UpdateControls(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
WindowPtr theWindow;
|
1996-04-10 14:48:19 +00:00
|
|
|
RgnHandle updateRegion;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
WinObj_Convert, &theWindow,
|
|
|
|
ResObj_Convert, &updateRegion))
|
1995-01-30 11:53:55 +00:00
|
|
|
return NULL;
|
|
|
|
UpdateControls(theWindow,
|
1996-04-10 14:48:19 +00:00
|
|
|
updateRegion);
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_FindControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 20:56:31 +00:00
|
|
|
ControlPartCode _rv;
|
1998-02-20 16:02:09 +00:00
|
|
|
Point testPoint;
|
1995-01-30 11:53:55 +00:00
|
|
|
WindowPtr theWindow;
|
|
|
|
ControlHandle theControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
1998-02-20 16:02:09 +00:00
|
|
|
PyMac_GetPoint, &testPoint,
|
1995-01-30 11:53:55 +00:00
|
|
|
WinObj_Convert, &theWindow))
|
|
|
|
return NULL;
|
1998-02-20 16:02:09 +00:00
|
|
|
_rv = FindControl(testPoint,
|
1995-01-30 11:53:55 +00:00
|
|
|
theWindow,
|
|
|
|
&theControl);
|
|
|
|
_res = Py_BuildValue("hO&",
|
|
|
|
_rv,
|
|
|
|
CtlObj_WhichControl, theControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 16:02:09 +00:00
|
|
|
static PyObject *Ctl_FindControlUnderMouse(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
|
|
|
Point inWhere;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
SInt16 outPart;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
PyMac_GetPoint, &inWhere,
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_rv = FindControlUnderMouse(inWhere,
|
|
|
|
inWindow,
|
|
|
|
&outPart);
|
|
|
|
_res = Py_BuildValue("O&h",
|
|
|
|
CtlObj_New, _rv,
|
|
|
|
outPart);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_IdleControls(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
IdleControls(inWindow);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_DumpControlHierarchy(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
FSSpec inDumpFile;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
WinObj_Convert, &inWindow,
|
|
|
|
PyMac_GetFSSpec, &inDumpFile))
|
|
|
|
return NULL;
|
|
|
|
_err = DumpControlHierarchy(inWindow,
|
|
|
|
&inDumpFile);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_CreateRootControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
ControlHandle outControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = CreateRootControl(inWindow,
|
|
|
|
&outControl);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_WhichControl, outControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_GetRootControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
ControlHandle outControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = GetRootControl(inWindow,
|
|
|
|
&outControl);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_WhichControl, outControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_GetKeyboardFocus(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
ControlHandle outControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = GetKeyboardFocus(inWindow,
|
|
|
|
&outControl);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_WhichControl, outControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_SetKeyboardFocus(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
ControlHandle inControl;
|
|
|
|
ControlFocusPart inPart;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&h",
|
|
|
|
WinObj_Convert, &inWindow,
|
|
|
|
CtlObj_Convert, &inControl,
|
|
|
|
&inPart))
|
|
|
|
return NULL;
|
|
|
|
_err = SetKeyboardFocus(inWindow,
|
|
|
|
inControl,
|
|
|
|
inPart);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_AdvanceKeyboardFocus(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = AdvanceKeyboardFocus(inWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_ReverseKeyboardFocus(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = ReverseKeyboardFocus(inWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_ClearKeyboardFocus(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
|
|
|
WindowPtr inWindow;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
WinObj_Convert, &inWindow))
|
|
|
|
return NULL;
|
|
|
|
_err = ClearKeyboardFocus(inWindow);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1999-02-07 14:02:03 +00:00
|
|
|
static PyObject *Ctl_as_Control(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
|
|
|
Handle h;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
ResObj_Convert, &h))
|
|
|
|
return NULL;
|
|
|
|
_rv = as_Control(h);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
static PyMethodDef Ctl_methods[] = {
|
|
|
|
{"NewControl", (PyCFunction)Ctl_NewControl, 1,
|
1998-02-20 16:02:09 +00:00
|
|
|
"(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1,
|
1998-02-20 16:02:09 +00:00
|
|
|
"(SInt16 resourceID, WindowPtr owningWindow) -> (ControlHandle _rv)"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"DrawControls", (PyCFunction)Ctl_DrawControls, 1,
|
|
|
|
"(WindowPtr theWindow) -> None"},
|
|
|
|
{"UpdateControls", (PyCFunction)Ctl_UpdateControls, 1,
|
1996-04-10 14:48:19 +00:00
|
|
|
"(WindowPtr theWindow, RgnHandle updateRegion) -> None"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{"FindControl", (PyCFunction)Ctl_FindControl, 1,
|
1998-02-20 16:02:09 +00:00
|
|
|
"(Point testPoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)"},
|
|
|
|
{"FindControlUnderMouse", (PyCFunction)Ctl_FindControlUnderMouse, 1,
|
|
|
|
"(Point inWhere, WindowPtr inWindow) -> (ControlHandle _rv, SInt16 outPart)"},
|
|
|
|
{"IdleControls", (PyCFunction)Ctl_IdleControls, 1,
|
|
|
|
"(WindowPtr inWindow) -> None"},
|
|
|
|
{"DumpControlHierarchy", (PyCFunction)Ctl_DumpControlHierarchy, 1,
|
|
|
|
"(WindowPtr inWindow, FSSpec inDumpFile) -> None"},
|
|
|
|
{"CreateRootControl", (PyCFunction)Ctl_CreateRootControl, 1,
|
|
|
|
"(WindowPtr inWindow) -> (ControlHandle outControl)"},
|
|
|
|
{"GetRootControl", (PyCFunction)Ctl_GetRootControl, 1,
|
|
|
|
"(WindowPtr inWindow) -> (ControlHandle outControl)"},
|
|
|
|
{"GetKeyboardFocus", (PyCFunction)Ctl_GetKeyboardFocus, 1,
|
|
|
|
"(WindowPtr inWindow) -> (ControlHandle outControl)"},
|
|
|
|
{"SetKeyboardFocus", (PyCFunction)Ctl_SetKeyboardFocus, 1,
|
|
|
|
"(WindowPtr inWindow, ControlHandle inControl, ControlFocusPart inPart) -> None"},
|
|
|
|
{"AdvanceKeyboardFocus", (PyCFunction)Ctl_AdvanceKeyboardFocus, 1,
|
|
|
|
"(WindowPtr inWindow) -> None"},
|
|
|
|
{"ReverseKeyboardFocus", (PyCFunction)Ctl_ReverseKeyboardFocus, 1,
|
|
|
|
"(WindowPtr inWindow) -> None"},
|
|
|
|
{"ClearKeyboardFocus", (PyCFunction)Ctl_ClearKeyboardFocus, 1,
|
|
|
|
"(WindowPtr inWindow) -> None"},
|
1999-02-07 14:02:03 +00:00
|
|
|
{"as_Control", (PyCFunction)Ctl_as_Control, 1,
|
|
|
|
"(Handle h) -> (ControlHandle _rv)"},
|
1995-01-30 11:53:55 +00:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-14 22:16:45 +00:00
|
|
|
static PyObject *
|
|
|
|
CtlObj_NewUnmanaged(itself)
|
1999-03-13 23:07:32 +00:00
|
|
|
ControlHandle itself;
|
|
|
|
{
|
|
|
|
ControlObject *it;
|
|
|
|
if (itself == NULL) return PyMac_Error(resNotFound);
|
|
|
|
it = PyObject_NEW(ControlObject, &Control_Type);
|
|
|
|
if (it == NULL) return NULL;
|
|
|
|
it->ob_itself = itself;
|
2000-03-21 16:25:23 +00:00
|
|
|
it->ob_callbackdict = NULL;
|
1999-03-13 23:07:32 +00:00
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
|
|
|
|
2000-07-14 22:16:45 +00:00
|
|
|
static PyObject *
|
1995-01-30 11:53:55 +00:00
|
|
|
CtlObj_WhichControl(ControlHandle c)
|
|
|
|
{
|
|
|
|
PyObject *it;
|
1999-12-09 22:49:51 +00:00
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
if (c == NULL)
|
|
|
|
it = Py_None;
|
1999-03-13 23:07:32 +00:00
|
|
|
else {
|
|
|
|
it = (PyObject *) GetControlReference(c);
|
|
|
|
/*
|
|
|
|
** If the refcon is zero or doesn't point back to the Python object
|
|
|
|
** the control is not ours. Return a temporary object.
|
|
|
|
*/
|
|
|
|
if (it == NULL || ((ControlObject *)it)->ob_itself != c)
|
|
|
|
return CtlObj_NewUnmanaged(c);
|
|
|
|
}
|
1995-01-30 11:53:55 +00:00
|
|
|
Py_INCREF(it);
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
1998-05-28 14:20:09 +00:00
|
|
|
static int
|
|
|
|
settrackfunc(obj)
|
|
|
|
PyObject *obj;
|
|
|
|
{
|
|
|
|
if (tracker) {
|
|
|
|
PyErr_SetString(Ctl_Error, "Tracker function in use");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
tracker = obj;
|
|
|
|
Py_INCREF(tracker);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clrtrackfunc()
|
|
|
|
{
|
|
|
|
Py_XDECREF(tracker);
|
|
|
|
tracker = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal void
|
2000-06-02 21:35:07 +00:00
|
|
|
mytracker(ControlHandle ctl, short part)
|
1998-05-28 14:20:09 +00:00
|
|
|
{
|
|
|
|
PyObject *args, *rv=0;
|
1999-12-09 22:49:51 +00:00
|
|
|
|
1998-05-28 14:20:09 +00:00
|
|
|
args = Py_BuildValue("(O&i)", CtlObj_WhichControl, ctl, (int)part);
|
|
|
|
if (args && tracker) {
|
|
|
|
rv = PyEval_CallObject(tracker, args);
|
|
|
|
Py_DECREF(args);
|
|
|
|
}
|
|
|
|
if (rv)
|
|
|
|
Py_DECREF(rv);
|
|
|
|
else
|
1999-12-09 22:49:51 +00:00
|
|
|
PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n");
|
1998-05-28 14:20:09 +00:00
|
|
|
}
|
|
|
|
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-03-20 16:09:09 +00:00
|
|
|
static int
|
2000-07-11 21:12:55 +00:00
|
|
|
setcallback(myself, which, callback, uppp)
|
|
|
|
PyObject *myself;
|
2000-03-20 16:09:09 +00:00
|
|
|
OSType which;
|
|
|
|
PyObject *callback;
|
|
|
|
UniversalProcPtr *uppp;
|
|
|
|
{
|
2000-07-11 21:12:55 +00:00
|
|
|
ControlObject *self = (ControlObject *)myself;
|
2000-03-20 16:09:09 +00:00
|
|
|
char keybuf[9];
|
|
|
|
|
|
|
|
if ( which == kControlUserPaneDrawProcTag )
|
2000-04-05 21:30:57 +00:00
|
|
|
*uppp = (UniversalProcPtr)mydrawproc_upp;
|
2000-03-20 16:09:09 +00:00
|
|
|
else if ( which == kControlUserPaneIdleProcTag )
|
2000-04-05 21:30:57 +00:00
|
|
|
*uppp = (UniversalProcPtr)myidleproc_upp;
|
2000-03-21 23:03:02 +00:00
|
|
|
else if ( which == kControlUserPaneHitTestProcTag )
|
2000-04-05 21:30:57 +00:00
|
|
|
*uppp = (UniversalProcPtr)myhittestproc_upp;
|
2000-03-21 23:03:02 +00:00
|
|
|
else if ( which == kControlUserPaneTrackingProcTag )
|
2000-04-05 21:30:57 +00:00
|
|
|
*uppp = (UniversalProcPtr)mytrackingproc_upp;
|
2000-03-20 16:09:09 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
/* Only now do we test for clearing of the callback: */
|
|
|
|
if ( callback == Py_None )
|
|
|
|
*uppp = NULL;
|
|
|
|
/* Create the dict if it doesn't exist yet (so we don't get such a dict for every control) */
|
|
|
|
if ( self->ob_callbackdict == NULL )
|
|
|
|
if ( (self->ob_callbackdict = PyDict_New()) == NULL )
|
|
|
|
return -1;
|
|
|
|
/* And store the Python callback */
|
|
|
|
sprintf(keybuf, "%x", which);
|
|
|
|
if (PyDict_SetItemString(self->ob_callbackdict, keybuf, callback) < 0)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
callcallback(self, which, arglist)
|
|
|
|
ControlObject *self;
|
|
|
|
OSType which;
|
|
|
|
PyObject *arglist;
|
|
|
|
{
|
|
|
|
char keybuf[9];
|
|
|
|
PyObject *func, *rv;
|
|
|
|
|
|
|
|
sprintf(keybuf, "%x", which);
|
|
|
|
if ( self->ob_callbackdict == NULL ||
|
|
|
|
(func = PyDict_GetItemString(self->ob_callbackdict, keybuf)) == NULL ) {
|
2000-03-21 23:03:02 +00:00
|
|
|
PySys_WriteStderr("Control callback %x without callback object\n", which);
|
2000-03-20 16:09:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rv = PyEval_CallObject(func, arglist);
|
|
|
|
if ( rv == NULL )
|
2000-03-21 23:03:02 +00:00
|
|
|
PySys_WriteStderr("Exception in control callback %x handler\n", which);
|
2000-03-20 16:09:09 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal void
|
|
|
|
mydrawproc(ControlHandle control, SInt16 part)
|
|
|
|
{
|
|
|
|
ControlObject *ctl_obj;
|
|
|
|
PyObject *arglist, *rv;
|
|
|
|
|
|
|
|
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
|
|
|
|
arglist = Py_BuildValue("Oh", ctl_obj, part);
|
|
|
|
rv = callcallback(ctl_obj, kControlUserPaneDrawProcTag, arglist);
|
|
|
|
Py_XDECREF(arglist);
|
|
|
|
Py_XDECREF(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal void
|
|
|
|
myidleproc(ControlHandle control)
|
|
|
|
{
|
|
|
|
ControlObject *ctl_obj;
|
|
|
|
PyObject *arglist, *rv;
|
|
|
|
|
|
|
|
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
|
|
|
|
arglist = Py_BuildValue("O", ctl_obj);
|
|
|
|
rv = callcallback(ctl_obj, kControlUserPaneIdleProcTag, arglist);
|
|
|
|
Py_XDECREF(arglist);
|
|
|
|
Py_XDECREF(rv);
|
|
|
|
}
|
|
|
|
|
2000-03-21 23:03:02 +00:00
|
|
|
static pascal ControlPartCode
|
|
|
|
myhittestproc(ControlHandle control, Point where)
|
|
|
|
{
|
|
|
|
ControlObject *ctl_obj;
|
|
|
|
PyObject *arglist, *rv;
|
|
|
|
short c_rv = -1;
|
|
|
|
|
|
|
|
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
|
2000-03-22 15:35:24 +00:00
|
|
|
arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, where);
|
2000-03-21 23:03:02 +00:00
|
|
|
rv = callcallback(ctl_obj, kControlUserPaneHitTestProcTag, arglist);
|
|
|
|
Py_XDECREF(arglist);
|
|
|
|
/* Ignore errors, nothing we can do about them */
|
|
|
|
if ( rv )
|
|
|
|
PyArg_Parse(rv, "h", &c_rv);
|
|
|
|
Py_XDECREF(rv);
|
|
|
|
return (ControlPartCode)c_rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static pascal ControlPartCode
|
|
|
|
mytrackingproc(ControlHandle control, Point startPt, ControlActionUPP actionProc)
|
|
|
|
{
|
|
|
|
ControlObject *ctl_obj;
|
|
|
|
PyObject *arglist, *rv;
|
|
|
|
short c_rv = -1;
|
|
|
|
|
|
|
|
ctl_obj = (ControlObject *)CtlObj_WhichControl(control);
|
|
|
|
/* We cannot pass the actionProc without lots of work */
|
2000-03-22 15:35:24 +00:00
|
|
|
arglist = Py_BuildValue("OO&", ctl_obj, PyMac_BuildPoint, startPt);
|
2000-03-21 23:03:02 +00:00
|
|
|
rv = callcallback(ctl_obj, kControlUserPaneTrackingProcTag, arglist);
|
|
|
|
Py_XDECREF(arglist);
|
|
|
|
if ( rv )
|
|
|
|
PyArg_Parse(rv, "h", &c_rv);
|
|
|
|
Py_XDECREF(rv);
|
|
|
|
return (ControlPartCode)c_rv;
|
|
|
|
}
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
2000-03-20 16:09:09 +00:00
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
|
|
|
|
void initCtl()
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-05-28 14:20:09 +00:00
|
|
|
mytracker_upp = NewControlActionProc(mytracker);
|
2000-07-14 22:37:27 +00:00
|
|
|
#if !TARGET_API_MAC_CARBON_NOTYET
|
2000-03-20 16:09:09 +00:00
|
|
|
mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc);
|
2000-04-05 21:30:57 +00:00
|
|
|
myidleproc_upp = NewControlUserPaneIdleProc(myidleproc);
|
2000-03-21 23:03:02 +00:00
|
|
|
myhittestproc_upp = NewControlUserPaneHitTestProc(myhittestproc);
|
|
|
|
mytrackingproc_upp = NewControlUserPaneTrackingProc(mytrackingproc);
|
2000-06-02 21:35:07 +00:00
|
|
|
#endif
|
1998-05-28 14:20:09 +00:00
|
|
|
|
1995-01-30 11:53:55 +00:00
|
|
|
|
|
|
|
m = Py_InitModule("Ctl", Ctl_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Ctl_Error = PyMac_GetOSErrException();
|
|
|
|
if (Ctl_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Ctl_Error) != 0)
|
|
|
|
Py_FatalError("can't initialize Ctl.Error");
|
1997-09-20 17:40:22 +00:00
|
|
|
Control_Type.ob_type = &PyType_Type;
|
|
|
|
Py_INCREF(&Control_Type);
|
|
|
|
if (PyDict_SetItemString(d, "ControlType", (PyObject *)&Control_Type) != 0)
|
|
|
|
Py_FatalError("can't initialize ControlType");
|
1995-01-30 11:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================= End module Ctl ========================= */
|
|
|
|
|