2002-12-21 14:55:27 +00:00
|
|
|
// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
2002-12-20 23:26:51 +00:00
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
#include "rect.h"
|
|
|
|
|
|
|
|
PyObject *OtkRect_New(int x, int y, int width, int height)
|
|
|
|
{
|
2002-12-21 12:27:49 +00:00
|
|
|
OtkRect* self = PyObject_New(OtkRect, &OtkRect_Type);
|
2002-12-20 23:26:51 +00:00
|
|
|
|
|
|
|
self->x = x;
|
|
|
|
self->y = y;
|
|
|
|
self->width = width;
|
|
|
|
self->height = height;
|
|
|
|
|
|
|
|
return (PyObject*)self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-21 14:57:07 +00:00
|
|
|
static PyObject *otkrect_getx(OtkRect *self, PyObject *args)
|
2002-12-20 23:26:51 +00:00
|
|
|
{
|
|
|
|
if (!PyArg_ParseTuple(args, ":getX"))
|
|
|
|
return NULL;
|
|
|
|
return PyInt_FromLong(self->x);
|
|
|
|
}
|
|
|
|
|
2002-12-21 14:57:07 +00:00
|
|
|
static PyObject *otkrect_gety(OtkRect *self, PyObject *args)
|
2002-12-20 23:26:51 +00:00
|
|
|
{
|
|
|
|
if (!PyArg_ParseTuple(args, ":getY"))
|
|
|
|
return NULL;
|
|
|
|
return PyInt_FromLong(self->y);
|
|
|
|
}
|
|
|
|
|
2002-12-21 14:57:07 +00:00
|
|
|
static PyObject *otkrect_getwidth(OtkRect *self, PyObject *args)
|
2002-12-20 23:26:51 +00:00
|
|
|
{
|
|
|
|
if (!PyArg_ParseTuple(args, ":getWidth"))
|
|
|
|
return NULL;
|
|
|
|
return PyInt_FromLong(self->width);
|
|
|
|
}
|
|
|
|
|
2002-12-21 14:57:07 +00:00
|
|
|
static PyObject *otkrect_getheight(OtkRect *self, PyObject *args)
|
2002-12-20 23:26:51 +00:00
|
|
|
{
|
|
|
|
if (!PyArg_ParseTuple(args, ":getHeight"))
|
|
|
|
return NULL;
|
|
|
|
return PyInt_FromLong(self->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyMethodDef get_methods[] = {
|
|
|
|
{"getX", (PyCFunction)otkrect_getx, METH_VARARGS,
|
|
|
|
"Get the X coordinate."},
|
|
|
|
{"getY", (PyCFunction)otkrect_gety, METH_VARARGS,
|
|
|
|
"Get the Y coordinate."},
|
|
|
|
{"getWidth", (PyCFunction)otkrect_getwidth, METH_VARARGS,
|
|
|
|
"Get the width."},
|
|
|
|
{"getHeight", (PyCFunction)otkrect_getheight, METH_VARARGS,
|
|
|
|
"Get the height."},
|
|
|
|
{NULL, NULL, 0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-21 14:57:07 +00:00
|
|
|
static void otkrect_dealloc(PyObject *self)
|
2002-12-20 23:26:51 +00:00
|
|
|
{
|
|
|
|
PyObject_Del(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *otkrect_getattr(PyObject *obj, char *name)
|
|
|
|
{
|
|
|
|
return Py_FindMethod(get_methods, obj, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject OtkRect_Type = {
|
|
|
|
PyObject_HEAD_INIT(NULL)
|
|
|
|
0,
|
|
|
|
"OtkRect",
|
|
|
|
sizeof(OtkRect),
|
|
|
|
0,
|
2002-12-21 14:55:27 +00:00
|
|
|
otkrect_dealloc, /*tp_dealloc*/
|
|
|
|
0, /*tp_print*/
|
|
|
|
otkrect_getattr, /*tp_getattr*/
|
|
|
|
0, /*tp_setattr*/
|
|
|
|
0, /*tp_compare*/
|
|
|
|
0, /*tp_repr*/
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
0, /*tp_hash */
|
2002-12-20 23:26:51 +00:00
|
|
|
};
|