]> Dogcows Code - chaz/openbox/blob - otk_c/rect.c
add font
[chaz/openbox] / otk_c / rect.c
1 // -*- mode: C; indent-tabs-mode: nil; -*-
2
3 #include "../config.h"
4 #include "rect.h"
5
6 extern PyTypeObject OtkRect_Type;
7
8 PyObject *OtkRect_New(int x, int y, int width, int height)
9 {
10 OtkRect* self = PyObject_New(OtkRect, &OtkRect_Type);
11
12 self->x = x;
13 self->y = y;
14 self->width = width;
15 self->height = height;
16
17 return (PyObject*)self;
18 }
19
20
21
22 static PyObject *otkrect_getx(OtkRect* self, PyObject* args)
23 {
24 if (!PyArg_ParseTuple(args, ":getX"))
25 return NULL;
26 return PyInt_FromLong(self->x);
27 }
28
29 static PyObject *otkrect_gety(OtkRect* self, PyObject* args)
30 {
31 if (!PyArg_ParseTuple(args, ":getY"))
32 return NULL;
33 return PyInt_FromLong(self->y);
34 }
35
36 static PyObject *otkrect_getwidth(OtkRect* self, PyObject* args)
37 {
38 if (!PyArg_ParseTuple(args, ":getWidth"))
39 return NULL;
40 return PyInt_FromLong(self->width);
41 }
42
43 static PyObject *otkrect_getheight(OtkRect* self, PyObject* args)
44 {
45 if (!PyArg_ParseTuple(args, ":getHeight"))
46 return NULL;
47 return PyInt_FromLong(self->height);
48 }
49
50
51 static PyMethodDef get_methods[] = {
52 {"getX", (PyCFunction)otkrect_getx, METH_VARARGS,
53 "Get the X coordinate."},
54 {"getY", (PyCFunction)otkrect_gety, METH_VARARGS,
55 "Get the Y coordinate."},
56 {"getWidth", (PyCFunction)otkrect_getwidth, METH_VARARGS,
57 "Get the width."},
58 {"getHeight", (PyCFunction)otkrect_getheight, METH_VARARGS,
59 "Get the height."},
60 {NULL, NULL, 0, NULL}
61 };
62
63
64
65 static void otkrect_dealloc(PyObject* self)
66 {
67 PyObject_Del(self);
68 }
69
70 static PyObject *otkrect_getattr(PyObject *obj, char *name)
71 {
72 return Py_FindMethod(get_methods, obj, name);
73 }
74
75
76 PyTypeObject OtkRect_Type = {
77 PyObject_HEAD_INIT(NULL)
78 0,
79 "OtkRect",
80 sizeof(OtkRect),
81 0,
82 otkrect_dealloc, /*tp_dealloc*/
83 0, /*tp_print*/
84 otkrect_getattr, /*tp_getattr*/
85 0, /*tp_setattr*/
86 0, /*tp_compare*/
87 0, /*tp_repr*/
88 0, /*tp_as_number*/
89 0, /*tp_as_sequence*/
90 0, /*tp_as_mapping*/
91 0, /*tp_hash */
92 };
This page took 0.035883 seconds and 4 git commands to generate.