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>
|
|
|
|
|
|
|
|
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
|
|
|
|
|
|
|
|
extern PyObject *CtlObj_WhichControl(ControlHandle); /* Forward */
|
|
|
|
|
|
|
|
#ifdef THINK_C
|
|
|
|
#define ControlActionUPP ProcPtr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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;
|
|
|
|
} 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);
|
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;
|
|
|
|
{
|
1997-04-08 12:26:03 -03: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);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1995-06-09 17:56:31 -03:00
|
|
|
static PyObject *CtlObj_HiliteControl(_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
|
|
|
ControlPartCode hiliteState;
|
|
|
|
if (!PyArg_ParseTuple(_args, "h",
|
|
|
|
&hiliteState))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
HiliteControl(_self->ob_itself,
|
|
|
|
hiliteState);
|
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_TrackControl(_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
|
|
|
ControlPartCode _rv;
|
|
|
|
Point thePoint;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetPoint, &thePoint))
|
1995-01-30 07:53:55 -04:00
|
|
|
return NULL;
|
1995-06-09 17:56:31 -03:00
|
|
|
_rv = TrackControl(_self->ob_itself,
|
|
|
|
thePoint,
|
|
|
|
(ControlActionUPP)0);
|
|
|
|
_res = Py_BuildValue("h",
|
|
|
|
_rv);
|
1995-01-30 07:53:55 -04:00
|
|
|
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;
|
1995-11-14 06:41:55 -04:00
|
|
|
Point thePoint;
|
1995-06-09 17:56:31 -03:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
1995-11-14 06:41:55 -04:00
|
|
|
PyMac_GetPoint, &thePoint))
|
1995-06-09 17:56:31 -03:00
|
|
|
return NULL;
|
|
|
|
_rv = TestControl(_self->ob_itself,
|
1995-11-14 06:41:55 -04:00
|
|
|
thePoint);
|
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;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&",
|
|
|
|
PyMac_GetStr255, title))
|
|
|
|
return NULL;
|
|
|
|
GetControlTitle(_self->ob_itself,
|
|
|
|
title);
|
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_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;
|
|
|
|
}
|
|
|
|
|
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;
|
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-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-06 09:55:40 -03:00
|
|
|
static PyObject *CtlObj_SetControlAction(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
SetControlAction(_self->ob_itself,
|
|
|
|
(ControlActionUPP)0);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1995-06-18 17:16:33 -03:00
|
|
|
static PyObject *CtlObj_as_Resource(_self, _args)
|
|
|
|
ControlObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
|
|
|
|
return ResObj_New((Handle)_self->ob_itself);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1995-01-30 07:53:55 -04:00
|
|
|
static PyMethodDef CtlObj_methods[] = {
|
|
|
|
{"ShowControl", (PyCFunction)CtlObj_ShowControl, 1,
|
|
|
|
"() -> None"},
|
1995-06-09 17:56:31 -03:00
|
|
|
{"HideControl", (PyCFunction)CtlObj_HideControl, 1,
|
|
|
|
"() -> None"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"Draw1Control", (PyCFunction)CtlObj_Draw1Control, 1,
|
|
|
|
"() -> None"},
|
|
|
|
{"HiliteControl", (PyCFunction)CtlObj_HiliteControl, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(ControlPartCode hiliteState) -> None"},
|
|
|
|
{"TrackControl", (PyCFunction)CtlObj_TrackControl, 1,
|
|
|
|
"(Point thePoint) -> (ControlPartCode _rv)"},
|
|
|
|
{"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,
|
1995-11-14 06:41:55 -04:00
|
|
|
"(Point thePoint) -> (ControlPartCode _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,
|
|
|
|
"(Str255 title) -> None"},
|
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"},
|
|
|
|
{"GetControlVariant", (PyCFunction)CtlObj_GetControlVariant, 1,
|
|
|
|
"() -> (SInt16 _rv)"},
|
1995-06-06 09:55:40 -03:00
|
|
|
{"SetControlAction", (PyCFunction)CtlObj_SetControlAction, 1,
|
|
|
|
"() -> None"},
|
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"},
|
1995-06-18 17:16:33 -03:00
|
|
|
{"as_Resource", (PyCFunction)CtlObj_as_Resource, 1,
|
|
|
|
"Return this Control as a Resource"},
|
1996-10-01 07:46:46 -03:00
|
|
|
{"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1,
|
|
|
|
"() -> None"},
|
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
|
|
|
|
|
|
|
|
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*/
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------- End object type Control --------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *Ctl_NewControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
|
|
|
WindowPtr theWindow;
|
|
|
|
Rect boundsRect;
|
|
|
|
Str255 title;
|
|
|
|
Boolean visible;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 value;
|
|
|
|
SInt16 min;
|
|
|
|
SInt16 max;
|
|
|
|
SInt16 procID;
|
|
|
|
SInt32 refCon;
|
1995-01-30 07:53:55 -04:00
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&O&bhhhhl",
|
|
|
|
WinObj_Convert, &theWindow,
|
|
|
|
PyMac_GetRect, &boundsRect,
|
|
|
|
PyMac_GetStr255, title,
|
|
|
|
&visible,
|
|
|
|
&value,
|
|
|
|
&min,
|
|
|
|
&max,
|
|
|
|
&procID,
|
|
|
|
&refCon))
|
|
|
|
return NULL;
|
|
|
|
_rv = NewControl(theWindow,
|
|
|
|
&boundsRect,
|
|
|
|
title,
|
|
|
|
visible,
|
|
|
|
value,
|
|
|
|
min,
|
|
|
|
max,
|
|
|
|
procID,
|
|
|
|
refCon);
|
|
|
|
_res = Py_BuildValue("O&",
|
|
|
|
CtlObj_New, _rv);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *Ctl_GetNewControl(_self, _args)
|
|
|
|
PyObject *_self;
|
|
|
|
PyObject *_args;
|
|
|
|
{
|
|
|
|
PyObject *_res = NULL;
|
|
|
|
ControlHandle _rv;
|
1995-06-09 17:56:31 -03:00
|
|
|
SInt16 controlID;
|
1995-01-30 07:53:55 -04:00
|
|
|
WindowPtr owner;
|
|
|
|
if (!PyArg_ParseTuple(_args, "hO&",
|
|
|
|
&controlID,
|
|
|
|
WinObj_Convert, &owner))
|
|
|
|
return NULL;
|
|
|
|
_rv = GetNewControl(controlID,
|
|
|
|
owner);
|
|
|
|
_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;
|
1995-01-30 07:53:55 -04:00
|
|
|
Point thePoint;
|
|
|
|
WindowPtr theWindow;
|
|
|
|
ControlHandle theControl;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&O&",
|
|
|
|
PyMac_GetPoint, &thePoint,
|
|
|
|
WinObj_Convert, &theWindow))
|
|
|
|
return NULL;
|
|
|
|
_rv = FindControl(thePoint,
|
|
|
|
theWindow,
|
|
|
|
&theControl);
|
|
|
|
_res = Py_BuildValue("hO&",
|
|
|
|
_rv,
|
|
|
|
CtlObj_WhichControl, theControl);
|
|
|
|
return _res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef Ctl_methods[] = {
|
|
|
|
{"NewControl", (PyCFunction)Ctl_NewControl, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(WindowPtr theWindow, Rect boundsRect, Str255 title, Boolean visible, SInt16 value, SInt16 min, SInt16 max, SInt16 procID, SInt32 refCon) -> (ControlHandle _rv)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{"GetNewControl", (PyCFunction)Ctl_GetNewControl, 1,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(SInt16 controlID, WindowPtr owner) -> (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,
|
1995-06-09 17:56:31 -03:00
|
|
|
"(Point thePoint, WindowPtr theWindow) -> (ControlPartCode _rv, ControlHandle theControl)"},
|
1995-01-30 07:53:55 -04:00
|
|
|
{NULL, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
CtlObj_WhichControl(ControlHandle c)
|
|
|
|
{
|
|
|
|
PyObject *it;
|
|
|
|
|
|
|
|
/* XXX What if we find a control belonging to some other package? */
|
|
|
|
if (c == NULL)
|
|
|
|
it = NULL;
|
|
|
|
else
|
1997-04-08 12:26:03 -03:00
|
|
|
it = (PyObject *) GetControlReference(c);
|
1995-01-30 07:53:55 -04:00
|
|
|
if (it == NULL || ((ControlObject *)it)->ob_itself != c)
|
|
|
|
it = Py_None;
|
|
|
|
Py_INCREF(it);
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void initCtl()
|
|
|
|
{
|
|
|
|
PyObject *m;
|
|
|
|
PyObject *d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ========================= */
|
|
|
|
|