1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
/* =========================== Module Ctl =========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SystemSevenOrLater 1
|
|
|
|
|
|
|
|
#include "macglue.h"
|
|
|
|
#include <Memory.h>
|
|
|
|
#include <Dialogs.h>
|
|
|
|
#include <Menus.h>
|
|
|
|
#include <Controls.h>
|
|
|
|
|
|
|
|
extern PyObject *ResObj_New(Handle);
|
|
|
|
extern int ResObj_Convert(PyObject *, Handle *);
|
1995-12-12 11:02:03 -04:00
|
|
|
extern PyObject *OptResObj_New(Handle);
|
|
|
|
extern int OptResObj_Convert(PyObject *, Handle *);
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
extern PyObject *WinObj_New(WindowPtr);
|
|
|
|
extern int WinObj_Convert(PyObject *, WindowPtr *);
|
1995-12-12 11:02:03 -04:00
|
|
|
extern PyTypeObject Window_Type;
|
|
|
|
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
extern PyObject *DlgObj_New(DialogPtr);
|
|
|
|
extern int DlgObj_Convert(PyObject *, DialogPtr *);
|
|
|
|
extern PyTypeObject Dialog_Type;
|
|
|
|
#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
|
|
|
|
|
|
|
|
extern PyObject *MenuObj_New(MenuHandle);
|
|
|
|
extern int MenuObj_Convert(PyObject *, MenuHandle *);
|
|
|
|
|
|
|
|
extern PyObject *CtlObj_New(ControlHandle);
|
|
|
|
extern int CtlObj_Convert(PyObject *, ControlHandle *);
|
|
|
|
|
1995-12-12 11:02:03 -04:00
|
|
|
extern PyObject *GrafObj_New(GrafPtr);
|
|
|
|
extern int GrafObj_Convert(PyObject *, GrafPtr *);
|
|
|
|
|
|
|
|
extern PyObject *BMObj_New(BitMapPtr);
|
|
|
|
extern int BMObj_Convert(PyObject *, BitMapPtr *);
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
extern PyObject *WinObj_WhichWindow(WindowPtr);
|
|
|
|
|
|
|
|
#include <Controls.h>
|
|
|
|
|
1999-02-07 10:02:03 -04:00
|
|
|
#define as_Control(h) ((ControlHandle)h)
|
1999-12-23 10:32:06 -04:00
|
|
|
#define as_Resource(ctl) ((Handle)ctl)
|
1999-02-07 10:02:03 -04:00
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
|
|
|
|
|
|
|
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
1998-02-20 12:02:09 -04:00
|
|
|
extern PyObject *QdRGB_New(RGBColorPtr);
|
|
|
|
extern QdRGB_Convert(PyObject *, RGBColorPtr);
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
#ifdef THINK_C
|
|
|
|
#define ControlActionUPP ProcPtr
|
|
|
|
#endif
|
|
|
|
|
1998-02-20 12:02:09 -04:00
|
|
|
/*
|
|
|
|
** Parse/generate ControlFontStyleRec records
|
|
|
|
*/
|
|
|
|
#if 0 /* Not needed */
|
|
|
|
PyObject *ControlFontStyle_New(itself)
|
|
|
|
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
|
|
|
|
|
|
|
|
ControlFontStyle_Convert(v, itself)
|
|
|
|
PyObject *v;
|
|
|
|
ControlFontStyleRec *itself;
|
|
|
|
{
|
|
|
|
return PyArg_ParseTuple(v, "hhhhhhO&O&", &itself->flags,
|
1999-12-09 18:49:51 -04:00
|
|
|
&itself->font, &itself->size, &itself->style, &itself->mode,
|
|
|
|
&itself->just, QdRGB_Convert, &itself->foreColor,
|
1998-02-20 12:02:09 -04:00
|
|
|
QdRGB_Convert, &itself->backColor);
|
|
|
|
}
|
|
|
|
|
1999-12-09 18:49:51 -04:00
|
|
|
/* TrackControl and HandleControlClick callback support */
|
1998-05-28 11:20:09 -03:00
|
|
|
static PyObject *tracker;
|
|
|
|
static ControlActionUPP mytracker_upp;
|
2000-03-20 12:09:09 -04:00
|
|
|
static ControlUserPaneDrawUPP mydrawproc_upp;
|
|
|
|
static ControlUserPaneIdleUPP myidleproc_upp;
|
1998-05-28 11:20:09 -03:00
|
|
|
|
|
|
|
extern int settrackfunc(PyObject *); /* forward */
|
|
|
|
extern void clrtrackfunc(void); /* forward */
|
|
|
|
|
1995-01-30 07:53:55 -04: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 12:09:09 -04:00
|
|
|
PyObject *ob_callbackdict;
|
1995-01-30 07:53:55 -04:00
|
|
|
} ControlObject;
|
|
|
|
|
|
|
|
PyObject *CtlObj_New(itself)
|
1995-06-06 09:55:40 -03:00
|
|
|
ControlHandle itself;
|
1995-01-30 07:53:55 -04: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 12:26:03 -03:00
|
|
|
SetControlReference(itself, (long)it);
|
2000-03-20 12:09:09 -04:00
|
|
|
it->ob_callbackdict = NULL;
|
1995-01-30 07:53:55 -04: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 12:09:09 -04:00
|
|
|
Py_XDECREF(self->ob_callbackdict);
|
1999-12-09 18:49:51 -04:00
|
|
|
if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */
|
1995-01-30 07:53:55 -04:00
|
|
|
PyMem_DEL(self);
|
|
|
|
}
|
|
|
|
|
1998-02-20 12:02:09 -04: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 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_ShowControl(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
ShowControl(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_HideControl(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
HideControl(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 12:02:09 -04: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 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_Draw1Control(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
Draw1Control(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 12:02:09 -04:00
|
|
|
static PyObject *CtlObj_GetBestControlRect(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1998-02-20 12:02:09 -04:00
|
|
|
OSErr _err;
|
|
|
|
Rect outRect;
|
|
|
|
SInt16 outBaseLineOffset;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1998-02-20 12:02:09 -04: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 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1999-12-12 17:41:51 -04: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 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_DragControl(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-11-14 06:41:55 -04:00
|
|
|
Point startPoint;
|
1995-06-09 17:56:31 -03:00
|
|
|
Rect limitRect;
|
|
|
|
Rect slopRect;
|
|
|
|
DragConstraint axis;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&h",
|
1995-11-14 06:41:55 -04:00
|
|
|
PyMac_GetPoint, &startPoint,
|
1995-06-09 17:56:31 -03:00
|
|
|
PyMac_GetRect, &limitRect,
|
|
|
|
PyMac_GetRect, &slopRect,
|
|
|
|
&axis))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
DragControl(_self->ob_itself,
|
1995-11-14 06:41:55 -04:00
|
|
|
startPoint,
|
1995-06-09 17:56:31 -03:00
|
|
|
&limitRect,
|
|
|
|
&slopRect,
|
|
|
|
axis);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_TestControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlPartCode _rv;
|
1998-02-20 12:02:09 -04:00
|
|
|
Point testPoint;
|
1995-06-09 17:56:31 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
1998-02-20 12:02:09 -04:00
|
|
|
PyMac_GetPoint, &testPoint))
|
1995-06-09 17:56:31 -03:00
|
|
|
return NULL;
|
|
|
|
_rv = TestControl(_self->ob_itself,
|
1998-02-20 12:02:09 -04: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 17:56:31 -03:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
static PyObject *CtlObj_MoveControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 h;
|
|
|
|
SInt16 v;
|
1995-01-30 07:53:55 -04: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 17:56:31 -03:00
|
|
|
SInt16 w;
|
|
|
|
SInt16 h;
|
1995-01-30 07:53:55 -04: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 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_SetControlTitle(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
Str255 title;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetStr255, title))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03: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 16:05:20 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-06-09 17:56:31 -03:00
|
|
|
return NULL;
|
|
|
|
GetControlTitle(_self->ob_itself,
|
|
|
|
title);
|
1999-03-07 16:05:20 -04:00
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
PyMac_BuildStr255, title);
|
1995-01-30 07:53:55 -04:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 09:55:40 -03:00
|
|
|
static PyObject *CtlObj_GetControlValue(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 _rv;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 09:55:40 -03:00
|
|
|
_rv = GetControlValue(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_SetControlValue(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 newValue;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
1995-06-09 17:56:31 -03:00
|
|
|
&newValue))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SetControlValue(_self->ob_itself,
|
|
|
|
newValue);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 09:55:40 -03:00
|
|
|
static PyObject *CtlObj_GetControlMinimum(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 _rv;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 09:55:40 -03:00
|
|
|
_rv = GetControlMinimum(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_SetControlMinimum(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 newMinimum;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
1995-06-09 17:56:31 -03:00
|
|
|
&newMinimum))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SetControlMinimum(_self->ob_itself,
|
|
|
|
newMinimum);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-06 09:55:40 -03:00
|
|
|
static PyObject *CtlObj_GetControlMaximum(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 _rv;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-06 09:55:40 -03:00
|
|
|
_rv = GetControlMaximum(_self->ob_itself);
|
1995-01-30 07:53:55 -04:00
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_SetControlMaximum(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 newMaximum;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&newMaximum))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SetControlMaximum(_self->ob_itself,
|
|
|
|
newMaximum);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1999-12-12 17:41:51 -04: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-03-20 12:09:09 -04:00
|
|
|
OSStatus _rv;
|
1999-12-12 17:41:51 -04:00
|
|
|
OSType propertyCreator;
|
|
|
|
OSType propertyTag;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
PyMac_GetOSType, &propertyCreator,
|
|
|
|
PyMac_GetOSType, &propertyTag))
|
|
|
|
return NULL;
|
2000-03-20 12:09:09 -04:00
|
|
|
_rv = RemoveControlProperty(_self->ob_itself,
|
|
|
|
propertyCreator,
|
|
|
|
propertyTag);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
1999-12-12 17:41:51 -04:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetControlRegion(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
2000-03-20 12:09:09 -04:00
|
|
|
OSStatus _rv;
|
1999-12-12 17:41:51 -04:00
|
|
|
ControlPartCode inPart;
|
|
|
|
RgnHandle outRegion;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&inPart,
|
|
|
|
ResObj_Convert, &outRegion))
|
|
|
|
return NULL;
|
2000-03-20 12:09:09 -04:00
|
|
|
_rv = GetControlRegion(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
outRegion);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
_rv);
|
1999-12-12 17:41:51 -04:00
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_GetControlVariant(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1998-02-20 12:02:09 -04:00
|
|
|
ControlVariant _rv;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
_rv = GetControlVariant(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("h",
|
1995-01-30 07:53:55 -04:00
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_SetControlReference(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt32 data;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&data))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SetControlReference(_self->ob_itself,
|
|
|
|
data);
|
1995-01-30 07:53:55 -04:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_GetControlReference(_self, _args)
|
1995-01-30 07:53:55 -04:00
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt32 _rv;
|
1995-06-06 09:55:40 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
_rv = GetControlReference(_self->ob_itself);
|
|
|
|
_res = Py_BuildValue("l",
|
1995-01-30 07:53:55 -04:00
|
|
|
_rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1997-08-15 11:32:18 -03: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-02-20 12:02:09 -04: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 18:49:51 -04:00
|
|
|
UInt16 outNumChildren;
|
1998-02-20 12:02:09 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = CountSubControls(_self->ob_itself,
|
|
|
|
&outNumChildren);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
outNumChildren);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *CtlObj_GetIndexedSubControl(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSErr _err;
|
1999-12-09 18:49:51 -04:00
|
|
|
UInt16 inIndex;
|
1998-02-20 12:02:09 -04:00
|
|
|
ControlHandle outSubControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&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 17:16:33 -03:00
|
|
|
static PyObject *CtlObj_as_Resource(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
1999-12-23 10:32:06 -04: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 17:16:33 -03:00
|
|
|
}
|
|
|
|
|
1996-10-01 07:46:46 -03: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 12:26:03 -03:00
|
|
|
SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
|
1996-10-01 07:46:46 -03:00
|
|
|
DisposeControl(_self->ob_itself);
|
|
|
|
_self->ob_itself = NULL;
|
|
|
|
}
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-05-28 11:20:09 -03: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 18:49:51 -04: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-18 20:05:50 -04: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 19:06:07 -04:00
|
|
|
OptResObj_Convert, &buffer))
|
1999-12-18 20:05:50 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
_err = SetControlData(_self->ob_itself,
|
|
|
|
inPart,
|
|
|
|
inTagName,
|
|
|
|
sizeof(buffer),
|
1999-12-29 08:37:22 -04:00
|
|
|
(Ptr)&buffer);
|
1999-12-18 20:05:50 -04: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-03-20 12:09:09 -04:00
|
|
|
static PyObject *CtlObj_SetControlDataCallback(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
OSErr _err;
|
|
|
|
ControlPartCode inPart;
|
|
|
|
ResType inTagName;
|
|
|
|
PyObject *callback;
|
|
|
|
UniversalProcPtr *c_callback;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&O",
|
|
|
|
&inPart,
|
|
|
|
PyMac_GetOSType, &inTagName,
|
|
|
|
&callback))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if ( setcallback(_self, inTagName, callback, &c_callback) < 0 )
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-06-19 10:35:14 -03: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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
static PyMethodDef CtlObj_methods[] = {
|
1998-02-20 12:02:09 -04:00
|
|
|
{"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1,
|
|
|
|
"(ControlPartCode hiliteState) -> None"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"ShowControl", (PyCFunction)CtlObj_ShowControl, 1,
|
|
|
|
"() -> None"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"HideControl", (PyCFunction)CtlObj_HideControl, 1,
|
|
|
|
"() -> None"},
|
1998-02-20 12:02:09 -04: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 07:53:55 -04:00
|
|
|
{"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1,
|
|
|
|
"() -> None"},
|
1998-02-20 12:02:09 -04: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 17:41:51 -04:00
|
|
|
{"SetUpControlTextColor", (PyCFunction)CtlObj_SetUpControlTextColor, 1,
|
|
|
|
"(SInt16 inDepth, Boolean inIsColorDevice) -> None"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"DragControl", (PyCFunction)CtlObj_DragControl, 1,
|
1995-11-14 06:41:55 -04:00
|
|
|
"(Point startPoint, Rect limitRect, Rect slopRect, DragConstraint axis) -> None"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"TestControl", (PyCFunction)CtlObj_TestControl, 1,
|
1998-02-20 12:02:09 -04:00
|
|
|
"(Point testPoint) -> (ControlPartCode _rv)"},
|
|
|
|
{"HandleControlKey", (PyCFunction)CtlObj_HandleControlKey, 1,
|
|
|
|
"(SInt16 inKeyCode, SInt16 inCharCode, SInt16 inModifiers) -> (SInt16 _rv)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"MoveControl", (PyCFunction)CtlObj_MoveControl, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(SInt16 h, SInt16 v) -> None"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"SizeControl", (PyCFunction)CtlObj_SizeControl, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(SInt16 w, SInt16 h) -> None"},
|
|
|
|
{"SetControlTitle", (PyCFunction)CtlObj_SetControlTitle, 1,
|
|
|
|
"(Str255 title) -> None"},
|
|
|
|
{"GetControlTitle", (PyCFunction)CtlObj_GetControlTitle, 1,
|
1999-03-07 16:05:20 -04:00
|
|
|
"() -> (Str255 title)"},
|
1995-06-06 09:55:40 -03:00
|
|
|
{"GetControlValue", (PyCFunction)CtlObj_GetControlValue, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlValue", (PyCFunction)CtlObj_SetControlValue, 1,
|
|
|
|
"(SInt16 newValue) -> None"},
|
1995-06-06 09:55:40 -03:00
|
|
|
{"GetControlMinimum", (PyCFunction)CtlObj_GetControlMinimum, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlMinimum", (PyCFunction)CtlObj_SetControlMinimum, 1,
|
|
|
|
"(SInt16 newMinimum) -> None"},
|
1995-06-06 09:55:40 -03:00
|
|
|
{"GetControlMaximum", (PyCFunction)CtlObj_GetControlMaximum, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"() -> (SInt16 _rv)"},
|
|
|
|
{"SetControlMaximum", (PyCFunction)CtlObj_SetControlMaximum, 1,
|
|
|
|
"(SInt16 newMaximum) -> None"},
|
1999-12-12 17:41:51 -04: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-03-20 12:09:09 -04:00
|
|
|
"(OSType propertyCreator, OSType propertyTag) -> (OSStatus _rv)"},
|
1999-12-12 17:41:51 -04:00
|
|
|
{"GetControlRegion", (PyCFunction)CtlObj_GetControlRegion, 1,
|
2000-03-20 12:09:09 -04:00
|
|
|
"(ControlPartCode inPart, RgnHandle outRegion) -> (OSStatus _rv)"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1,
|
1998-02-20 12:02:09 -04:00
|
|
|
"() -> (ControlVariant _rv)"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"SetControlReference", (PyCFunction)CtlObj_SetControlReference, 1,
|
|
|
|
"(SInt32 data) -> None"},
|
|
|
|
{"GetControlReference", (PyCFunction)CtlObj_GetControlReference, 1,
|
|
|
|
"() -> (SInt32 _rv)"},
|
1997-08-15 11:32:18 -03:00
|
|
|
{"GetAuxiliaryControlRecord", (PyCFunction)CtlObj_GetAuxiliaryControlRecord, 1,
|
|
|
|
"() -> (Boolean _rv, AuxCtlHandle acHndl)"},
|
|
|
|
{"SetControlColor", (PyCFunction)CtlObj_SetControlColor, 1,
|
|
|
|
"(CCTabHandle newColorTable) -> None"},
|
1998-02-20 12:02:09 -04: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 18:49:51 -04:00
|
|
|
"() -> (UInt16 outNumChildren)"},
|
1998-02-20 12:02:09 -04:00
|
|
|
{"GetIndexedSubControl", (PyCFunction)CtlObj_GetIndexedSubControl, 1,
|
1999-12-09 18:49:51 -04:00
|
|
|
"(UInt16 inIndex) -> (ControlHandle outSubControl)"},
|
1998-02-20 12:02:09 -04: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 17:16:33 -03:00
|
|
|
{"as_Resource", (PyCFunction)CtlObj_as_Resource, 1,
|
1999-12-23 10:32:06 -04:00
|
|
|
"() -> (Handle _rv)"},
|
1996-10-01 07:46:46 -03:00
|
|
|
{"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
|
|
|
|
"() -> None"},
|
1998-05-28 11:20:09 -03:00
|
|
|
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
|
1999-12-09 18:49:51 -04: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-18 20:05:50 -04:00
|
|
|
{"SetControlDataHandle", (PyCFunction)CtlObj_SetControlDataHandle, 1,
|
|
|
|
"(ResObj) -> None"},
|
|
|
|
{"GetControlDataHandle", (PyCFunction)CtlObj_GetControlDataHandle, 1,
|
|
|
|
"(part, type) -> ResObj"},
|
2000-03-20 12:09:09 -04:00
|
|
|
{"SetControlDataCallback", (PyCFunction)CtlObj_SetControlDataCallback, 1,
|
|
|
|
"(callbackfunc) -> None"},
|
1998-06-19 10:35:14 -03:00
|
|
|
{"GetPopupData", (PyCFunction)CtlObj_GetPopupData, 1,
|
|
|
|
NULL},
|
|
|
|
{"SetPopupData", (PyCFunction)CtlObj_SetPopupData, 1,
|
|
|
|
NULL},
|
1995-01-30 07:53:55 -04: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 19:07:32 -04: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 07:53:55 -04: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 19:07:32 -04: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 07:53:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------- End object type Control --------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Ctl_NewControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
1998-02-20 12:02:09 -04:00
|
|
|
WindowPtr owningWindow;
|
1995-01-30 07:53:55 -04:00
|
|
|
Rect boundsRect;
|
1998-02-20 12:02:09 -04:00
|
|
|
Str255 controlTitle;
|
|
|
|
Boolean initiallyVisible;
|
|
|
|
SInt16 initialValue;
|
|
|
|
SInt16 minimumValue;
|
|
|
|
SInt16 maximumValue;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 procID;
|
1998-02-20 12:02:09 -04:00
|
|
|
SInt32 controlReference;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl",
|
1998-02-20 12:02:09 -04:00
|
|
|
WinObj_Convert, &owningWindow,
|
1995-01-30 07:53:55 -04:00
|
|
|
PyMac_GetRect, &boundsRect,
|
1998-02-20 12:02:09 -04:00
|
|
|
PyMac_GetStr255, controlTitle,
|
|
|
|
&initiallyVisible,
|
|
|
|
&initialValue,
|
|
|
|
&minimumValue,
|
|
|
|
&maximumValue,
|
1995-01-30 07:53:55 -04:00
|
|
|
&procID,
|
1998-02-20 12:02:09 -04:00
|
|
|
&controlReference))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1998-02-20 12:02:09 -04:00
|
|
|
_rv = NewControl(owningWindow,
|
1995-01-30 07:53:55 -04:00
|
|
|
&boundsRect,
|
1998-02-20 12:02:09 -04:00
|
|
|
controlTitle,
|
|
|
|
initiallyVisible,
|
|
|
|
initialValue,
|
|
|
|
minimumValue,
|
|
|
|
maximumValue,
|
1995-01-30 07:53:55 -04:00
|
|
|
procID,
|
1998-02-20 12:02:09 -04:00
|
|
|
controlReference);
|
1995-01-30 07:53:55 -04: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 12:02:09 -04:00
|
|
|
SInt16 resourceID;
|
|
|
|
WindowPtr owningWindow;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
1998-02-20 12:02:09 -04:00
|
|
|
&resourceID,
|
|
|
|
WinObj_Convert, &owningWindow))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1998-02-20 12:02:09 -04:00
|
|
|
_rv = GetNewControl(resourceID,
|
|
|
|
owningWindow);
|
1995-01-30 07:53:55 -04: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 11:48:19 -03:00
|
|
|
RgnHandle updateRegion;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
WinObj_Convert, &theWindow,
|
|
|
|
ResObj_Convert, &updateRegion))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
|
|
|
UpdateControls(theWindow,
|
1996-04-10 11:48:19 -03:00
|
|
|
updateRegion);
|
1995-01-30 07:53:55 -04: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 17:56:31 -03:00
|
|
|
ControlPartCode _rv;
|
1998-02-20 12:02:09 -04:00
|
|
|
Point testPoint;
|
1995-01-30 07:53:55 -04:00
|
|
|
WindowPtr theWindow;
|
|
|
|
ControlHandle theControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
1998-02-20 12:02:09 -04:00
|
|
|
PyMac_GetPoint, &testPoint,
|
1995-01-30 07:53:55 -04:00
|
|
|
WinObj_Convert, &theWindow))
|
|
|
|
return NULL;
|
1998-02-20 12:02:09 -04:00
|
|
|
_rv = FindControl(testPoint,
|
1995-01-30 07:53:55 -04:00
|
|
|
theWindow,
|
|
|
|
&theControl);
|
|
|
|
_res = Py_BuildValue("hO&",
|
|
|
|
_rv,
|
|
|
|
CtlObj_WhichControl, theControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
1998-02-20 12:02:09 -04: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 10:02:03 -04: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 07:53:55 -04:00
|
|
|
static PyMethodDef Ctl_methods[] = {
|
|
|
|
{"NewControl", (PyCFunction)Ctl_NewControl, 1,
|
1998-02-20 12:02:09 -04:00
|
|
|
"(WindowPtr owningWindow, Rect boundsRect, Str255 controlTitle, Boolean initiallyVisible, SInt16 initialValue, SInt16 minimumValue, SInt16 maximumValue, SInt16 procID, SInt32 controlReference) -> (ControlHandle _rv)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1,
|
1998-02-20 12:02:09 -04:00
|
|
|
"(SInt16 resourceID, WindowPtr owningWindow) -> (ControlHandle _rv)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"DrawControls", (PyCFunction)Ctl_DrawControls, 1,
|
|
|
|
"(WindowPtr theWindow) -> None"},
|
|
|
|
{"UpdateControls", (PyCFunction)Ctl_UpdateControls, 1,
|
1996-04-10 11:48:19 -03:00
|
|
|
"(WindowPtr theWindow, RgnHandle updateRegion) -> None"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"FindControl", (PyCFunction)Ctl_FindControl, 1,
|
1998-02-20 12:02:09 -04: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 10:02:03 -04:00
|
|
|
{"as_Control", (PyCFunction)Ctl_as_Control, 1,
|
|
|
|
"(Handle h) -> (ControlHandle _rv)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-13 19:07:32 -04:00
|
|
|
PyObject *CtlObj_NewUnmanaged(itself)
|
|
|
|
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;
|
|
|
|
return (PyObject *)it;
|
|
|
|
}
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
PyObject *
|
|
|
|
CtlObj_WhichControl(ControlHandle c)
|
|
|
|
{
|
|
|
|
PyObject *it;
|
1999-12-09 18:49:51 -04:00
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
if (c == NULL)
|
|
|
|
it = Py_None;
|
1999-03-13 19:07:32 -04: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 07:53:55 -04:00
|
|
|
Py_INCREF(it);
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
1998-05-28 11:20:09 -03: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
|
|
|
|
mytracker(ctl, part)
|
|
|
|
ControlHandle ctl;
|
|
|
|
short part;
|
|
|
|
{
|
|
|
|
PyObject *args, *rv=0;
|
1999-12-09 18:49:51 -04:00
|
|
|
|
1998-05-28 11:20:09 -03: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 18:49:51 -04:00
|
|
|
PySys_WriteStderr("TrackControl or HandleControlClick: exception in tracker function\n");
|
1998-05-28 11:20:09 -03:00
|
|
|
}
|
|
|
|
|
2000-03-20 12:09:09 -04:00
|
|
|
static int
|
|
|
|
setcallback(self, which, callback, uppp)
|
|
|
|
ControlObject *self;
|
|
|
|
OSType which;
|
|
|
|
PyObject *callback;
|
|
|
|
UniversalProcPtr *uppp;
|
|
|
|
{
|
|
|
|
char keybuf[9];
|
|
|
|
|
|
|
|
if ( which == kControlUserPaneDrawProcTag )
|
|
|
|
*uppp = mydrawproc_upp;
|
|
|
|
else if ( which == kControlUserPaneIdleProcTag )
|
|
|
|
*uppp = myidleproc_upp;
|
|
|
|
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 ) {
|
|
|
|
PySys_WriteStderr("Control callback without callback object\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rv = PyEval_CallObject(func, arglist);
|
|
|
|
if ( rv == NULL )
|
|
|
|
PySys_WriteStderr("Exception in control callback handler\n");
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
|
|
|
|
void initCtl()
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-05-28 11:20:09 -03:00
|
|
|
mytracker_upp = NewControlActionProc(mytracker);
|
2000-03-20 12:09:09 -04:00
|
|
|
mydrawproc_upp = NewControlUserPaneDrawProc(mydrawproc);
|
|
|
|
myidleproc_upp = NewControlUserPaneDrawProc(myidleproc);
|
1998-05-28 11:20:09 -03:00
|
|
|
|
1995-01-30 07:53:55 -04: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 14:40:22 -03: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 07:53:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================= End module Ctl ========================= */
|
|
|
|
|