blob: ef853f5520ed9a76cd69f8b2c3f3cd881c13dbec [file] [log] [blame]
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001/* FL module -- interface to Mark Overmars' FORMS Library. */
2
Roger E. Masse7ba4c071997-01-03 22:17:11 +00003/* This code works with FORMS version 2.2 (if you defined
4 OBSOLETE_FORMS_CALLS), and 2.3.
Guido van Rossumf1dc5661993-07-05 10:31:29 +00005 FORMS can be ftp'ed from ftp.cs.ruu.nl (131.211.80.17), directory
6 /pub/SGI/FORMS. */
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00007
Jack Jansen743db361992-08-13 14:13:11 +00008/* A half-hearted attempt has been made to allow programs using this
9 * module to exploit parallelism (through the threads module). No provisions
10 * have been made for multiple threads to use this module at the same time,
11 * though. So, a program with a forms thread and a non-forms thread will work
12 * fine but a program with two threads using forms will probably crash (unless
13 * the program takes precaution to ensure that only one thread can be in
14 * this module at any time). This will have to be fixed some time.
Thomas Wouters7e474022000-07-16 12:04:32 +000015 * (A fix will probably also have to synchronize with the gl module).
Jack Jansen743db361992-08-13 14:13:11 +000016 */
17
Roger E. Masse7ba4c071997-01-03 22:17:11 +000018#include "Python.h"
Guido van Rossumc7df79e1991-08-07 11:32:58 +000019#include "forms.h"
Guido van Rossumc7df79e1991-08-07 11:32:58 +000020#include "structmember.h"
Guido van Rossumc7df79e1991-08-07 11:32:58 +000021
22/* Generic Forms Objects */
23
24typedef struct {
Roger E. Masse7ba4c071997-01-03 22:17:11 +000025 PyObject_HEAD
Guido van Rossumc7df79e1991-08-07 11:32:58 +000026 FL_OBJECT *ob_generic;
Roger E. Masse7ba4c071997-01-03 22:17:11 +000027 PyMethodDef *ob_methods;
28 PyObject *ob_callback;
29 PyObject *ob_callback_arg;
Guido van Rossumc7df79e1991-08-07 11:32:58 +000030} genericobject;
31
Roger E. Masse7ba4c071997-01-03 22:17:11 +000032staticforward PyTypeObject GenericObjecttype;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000033
34#define is_genericobject(g) ((g)->ob_type == &GenericObjecttype)
35
36/* List of all objects (XXX this should be a hash table on address...) */
Guido van Rossumc7df79e1991-08-07 11:32:58 +000037
Roger E. Masse7ba4c071997-01-03 22:17:11 +000038static PyObject *allgenerics = NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000039static int nfreeslots = 0;
40
41/* Add an object to the list of known objects */
Guido van Rossumc7df79e1991-08-07 11:32:58 +000042
43static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +000044knowgeneric(genericobject *g)
Guido van Rossumc7df79e1991-08-07 11:32:58 +000045{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000046 int i, n;
47 /* Create the list if it doesn't already exist */
Guido van Rossumc7df79e1991-08-07 11:32:58 +000048 if (allgenerics == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +000049 allgenerics = PyList_New(0);
Guido van Rossumc7df79e1991-08-07 11:32:58 +000050 if (allgenerics == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +000051 PyErr_Clear();
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000052 return; /* Too bad, live without allgenerics... */
Guido van Rossumc7df79e1991-08-07 11:32:58 +000053 }
54 }
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000055 if (nfreeslots > 0) {
56 /* Search the list for reusable slots (NULL items) */
57 /* XXX This can be made faster! */
Roger E. Masse7ba4c071997-01-03 22:17:11 +000058 n = PyList_Size(allgenerics);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000059 for (i = 0; i < n; i++) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +000060 if (PyList_GetItem(allgenerics, i) == NULL) {
61 Py_INCREF(g);
62 PyList_SetItem(allgenerics, i, (PyObject *)g);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000063 nfreeslots--;
64 return;
65 }
66 }
67 /* Strange... no free slots found... */
68 nfreeslots = 0;
69 }
70 /* No free entries, append new item to the end */
Roger E. Masse7ba4c071997-01-03 22:17:11 +000071 PyList_Append(allgenerics, (PyObject *)g);
Guido van Rossumc7df79e1991-08-07 11:32:58 +000072}
73
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000074/* Find an object in the list of known objects */
75
Guido van Rossumc7df79e1991-08-07 11:32:58 +000076static genericobject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +000077findgeneric(FL_OBJECT *generic)
Guido van Rossumc7df79e1991-08-07 11:32:58 +000078{
79 int i, n;
80 genericobject *g;
81
82 if (allgenerics == NULL)
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000083 return NULL; /* No objects known yet */
Roger E. Masse7ba4c071997-01-03 22:17:11 +000084 n = PyList_Size(allgenerics);
Guido van Rossumc7df79e1991-08-07 11:32:58 +000085 for (i = 0; i < n; i++) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +000086 g = (genericobject *)PyList_GetItem(allgenerics, i);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +000087 if (g != NULL && g->ob_generic == generic)
Guido van Rossumc7df79e1991-08-07 11:32:58 +000088 return g;
89 }
90 return NULL; /* Unknown object */
91}
92
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +000093/* Remove an object from the list of known objects */
94
95static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +000096forgetgeneric(genericobject *g)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +000097{
98 int i, n;
99
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000100 Py_XDECREF(g->ob_callback);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000101 g->ob_callback = NULL;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000102 Py_XDECREF(g->ob_callback_arg);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000103 g->ob_callback_arg = NULL;
104 if (allgenerics == NULL)
105 return; /* No objects known yet */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000106 n = PyList_Size(allgenerics);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000107 for (i = 0; i < n; i++) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000108 if (g == (genericobject *)PyList_GetItem(allgenerics, i)) {
109 PyList_SetItem(allgenerics, i, (PyObject *)NULL);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000110 nfreeslots++;
111 break;
112 }
113 }
114}
115
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000116/* Called when a form is about to be freed --
117 remove all the objects that we know about from it. */
118
119static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000120releaseobjects(FL_FORM *form)
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000121{
122 int i, n;
123 genericobject *g;
124
125 if (allgenerics == NULL)
126 return; /* No objects known yet */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000127 n = PyList_Size(allgenerics);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000128 for (i = 0; i < n; i++) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000129 g = (genericobject *)PyList_GetItem(allgenerics, i);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000130 if (g != NULL && g->ob_generic->form == form) {
131 fl_delete_object(g->ob_generic);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000132 /* The object is now unreachable for
133 do_forms and check_forms, so
134 delete it from the list of known objects */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000135 Py_XDECREF(g->ob_callback);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000136 g->ob_callback = NULL;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000137 Py_XDECREF(g->ob_callback_arg);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000138 g->ob_callback_arg = NULL;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000139 PyList_SetItem(allgenerics, i, (PyObject *)NULL);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000140 nfreeslots++;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000141 }
142 }
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000143}
144
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000145
146/* Methods of generic objects */
147
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000148static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000149generic_set_call_back(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000150{
151 if (args == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000152 Py_XDECREF(g->ob_callback);
153 Py_XDECREF(g->ob_callback_arg);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000154 g->ob_callback = NULL;
155 g->ob_callback_arg = NULL;
156 }
157 else {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000158 if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) {
159 PyErr_BadArgument();
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000160 return NULL;
161 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000162 Py_XDECREF(g->ob_callback);
163 Py_XDECREF(g->ob_callback_arg);
164 g->ob_callback = PyTuple_GetItem(args, 0);
165 Py_INCREF(g->ob_callback);
166 g->ob_callback_arg = PyTuple_GetItem(args, 1);
167 Py_INCREF(g->ob_callback_arg);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000168 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000169 Py_INCREF(Py_None);
170 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000171}
172
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000173static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000174generic_call(genericobject *g, PyObject *args, void (*func)(FL_OBJECT *))
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000175{
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000176 if (!PyArg_NoArgs(args))
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000177 return NULL;
178 (*func)(g->ob_generic);
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000179 Py_INCREF(Py_None);
180 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000181}
182
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000183static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000184generic_delete_object(genericobject *g, PyObject *args)
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000185{
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000186 PyObject *res;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000187 res = generic_call(g, args, fl_delete_object);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000188 if (res != NULL)
189 forgetgeneric(g);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000190 return res;
191}
192
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000193static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000194generic_show_object(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000195{
196 return generic_call(g, args, fl_show_object);
197}
198
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000199static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000200generic_hide_object(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000201{
202 return generic_call(g, args, fl_hide_object);
203}
204
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000205static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000206generic_redraw_object(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000207{
208 return generic_call(g, args, fl_redraw_object);
209}
210
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000211#ifdef OBSOLETE_FORMS_CALLS
212
213 /* (un)freeze_object() are obsolete in FORMS 2.2 and unsupported
214 in 2.3. Since there's no foolproof way to tell which version we're
215 using, we omit them unconditionally. */
216
217static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000218generic_freeze_object(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000219{
220 return generic_call(g, args, fl_freeze_object);
221}
222
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000223static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000224generic_unfreeze_object(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000225{
226 return generic_call(g, args, fl_unfreeze_object);
227}
228
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000229#endif /* OBSOLETE_FORMS_CALLS */
230
231static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000232generic_activate_object(genericobject *g, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000233{
234 return generic_call(g, args, fl_activate_object);
235}
236
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000237static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000238generic_deactivate_object(genericobject *g, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000239{
240 return generic_call(g, args, fl_deactivate_object);
241}
242
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000243static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000244generic_set_object_shortcut(genericobject *g, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000245{
246 char *str;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000247 if (!PyArg_Parse(args, "s", &str))
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000248 return NULL;
249 fl_set_object_shortcut(g->ob_generic, str);
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000250 Py_INCREF(Py_None);
251 return Py_None;
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000252}
253
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000254static PyMethodDef generic_methods[] = {
255 {"set_call_back", (PyCFunction)generic_set_call_back},
256 {"delete_object", (PyCFunction)generic_delete_object},
257 {"show_object", (PyCFunction)generic_show_object},
258 {"hide_object", (PyCFunction)generic_hide_object},
259 {"redraw_object", (PyCFunction)generic_redraw_object},
260#ifdef OBSOLETE_FORMS_CALLS
261 {"freeze_object", (PyCFunction)generic_freeze_object},
262 {"unfreeze_object", (PyCFunction)generic_unfreeze_object},
263#endif
264 {"activate_object", (PyCFunction)generic_activate_object},
265 {"deactivate_object", (PyCFunction)generic_deactivate_object},
266 {"set_object_shortcut", (PyCFunction)generic_set_object_shortcut},
Guido van Rossum03747111991-08-08 12:10:01 +0000267 {NULL, NULL} /* sentinel */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000268};
269
270static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000271generic_dealloc(genericobject *g)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000272{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000273 fl_free_object(g->ob_generic);
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000274 Py_XDECREF(g->ob_callback);
275 Py_XDECREF(g->ob_callback_arg);
Guido van Rossumb18618d2000-05-03 23:44:39 +0000276 PyObject_Del(g);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000277}
278
279#define OFF(x) offsetof(FL_OBJECT, x)
280
281static struct memberlist generic_memberlist[] = {
282 {"objclass", T_INT, OFF(objclass), RO},
283 {"type", T_INT, OFF(type), RO},
284 {"boxtype", T_INT, OFF(boxtype)},
285 {"x", T_FLOAT, OFF(x)},
286 {"y", T_FLOAT, OFF(y)},
287 {"w", T_FLOAT, OFF(w)},
288 {"h", T_FLOAT, OFF(h)},
289 {"col1", T_INT, OFF(col1)},
290 {"col2", T_INT, OFF(col2)},
291 {"align", T_INT, OFF(align)},
292 {"lcol", T_INT, OFF(lcol)},
293 {"lsize", T_FLOAT, OFF(lsize)},
294 /* "label" is treated specially! */
295 {"lstyle", T_INT, OFF(lstyle)},
296 {"pushed", T_INT, OFF(pushed), RO},
297 {"focus", T_INT, OFF(focus), RO},
298 {"belowmouse", T_INT, OFF(belowmouse),RO},
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000299/* {"frozen", T_INT, OFF(frozen), RO}, */
Guido van Rossum7066dd71992-09-17 17:54:56 +0000300 {"active", T_INT, OFF(active)},
301 {"input", T_INT, OFF(input)},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000302 {"visible", T_INT, OFF(visible), RO},
Guido van Rossum7066dd71992-09-17 17:54:56 +0000303 {"radio", T_INT, OFF(radio)},
304 {"automatic", T_INT, OFF(automatic)},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000305 {NULL} /* Sentinel */
306};
307
Guido van Rossumd97f0481991-11-19 20:26:28 +0000308#undef OFF
309
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000310static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000311generic_getattr(genericobject *g, char *name)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000312{
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000313 PyObject *meth;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000314
315 /* XXX Ought to special-case name "__methods__" */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000316 if (g-> ob_methods) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000317 meth = Py_FindMethod(g->ob_methods, (PyObject *)g, name);
Guido van Rossum03747111991-08-08 12:10:01 +0000318 if (meth != NULL) return meth;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000319 PyErr_Clear();
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000320 }
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000321
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000322 meth = Py_FindMethod(generic_methods, (PyObject *)g, name);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000323 if (meth != NULL)
324 return meth;
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000325 PyErr_Clear();
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000326
327 /* "label" is an exception, getmember only works for char pointers,
328 not for char arrays */
329 if (strcmp(name, "label") == 0)
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000330 return PyString_FromString(g->ob_generic->label);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000331
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000332 return PyMember_Get((char *)g->ob_generic, generic_memberlist, name);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000333}
334
335static int
Sjoerd Mullender0ae52842000-07-12 10:43:11 +0000336generic_setattr(genericobject *g, char *name, PyObject *v)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000337{
338 int ret;
339
340 if (v == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000341 PyErr_SetString(PyExc_TypeError,
342 "can't delete forms object attributes");
Guido van Rossum3dd8c981992-06-03 17:07:49 +0000343 return -1;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000344 }
345
346 /* "label" is an exception: setmember doesn't set strings;
347 and FORMS wants you to call a function to set the label */
348 if (strcmp(name, "label") == 0) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000349 if (!PyString_Check(v)) {
350 PyErr_SetString(PyExc_TypeError,
351 "label attr must be string");
Guido van Rossum3dd8c981992-06-03 17:07:49 +0000352 return -1;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000353 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000354 fl_set_object_label(g->ob_generic, PyString_AsString(v));
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000355 return 0;
356 }
357
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000358 ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000359
360 /* Rather than calling all the various set_object_* functions,
361 we call fl_redraw_object here. This is sometimes redundant
362 but I doubt that's a big problem */
363 if (ret == 0)
364 fl_redraw_object(g->ob_generic);
365
366 return ret;
367}
368
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000369static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000370generic_repr(genericobject *g)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000371{
372 char buf[100];
Fred Drakea44d3532000-06-30 15:01:00 +0000373 sprintf(buf, "<FORMS_object at %p, objclass=%d>",
374 g, g->ob_generic->objclass);
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000375 return PyString_FromString(buf);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000376}
377
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000378static PyTypeObject GenericObjecttype = {
379 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumb6775db1994-08-01 11:34:53 +0000380 0, /*ob_size*/
381 "FORMS_object", /*tp_name*/
382 sizeof(genericobject), /*tp_size*/
383 0, /*tp_itemsize*/
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000384 /* methods */
Guido van Rossumb6775db1994-08-01 11:34:53 +0000385 (destructor)generic_dealloc, /*tp_dealloc*/
386 0, /*tp_print*/
387 (getattrfunc)generic_getattr, /*tp_getattr*/
388 (setattrfunc)generic_setattr, /*tp_setattr*/
389 0, /*tp_compare*/
390 (reprfunc)generic_repr, /*tp_repr*/
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000391};
392
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000393static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000394newgenericobject(FL_OBJECT *generic, PyMethodDef *methods)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000395{
396 genericobject *g;
Guido van Rossumb18618d2000-05-03 23:44:39 +0000397 g = PyObject_New(genericobject, &GenericObjecttype);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000398 if (g == NULL)
399 return NULL;
400 g-> ob_generic = generic;
401 g->ob_methods = methods;
402 g->ob_callback = NULL;
403 g->ob_callback_arg = NULL;
404 knowgeneric(g);
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000405 return (PyObject *)g;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000406}
407
408/**********************************************************************/
409/* Some common calling sequences */
410
411/* void func (object, float) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000412static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000413call_forms_INf (void (*func)(FL_OBJECT *, float), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000414{
Guido van Rossum03747111991-08-08 12:10:01 +0000415 float parameter;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000416
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000417 if (!PyArg_Parse(args, "f", &parameter)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000418
Guido van Rossum03747111991-08-08 12:10:01 +0000419 (*func) (obj, parameter);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000420
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000421 Py_INCREF(Py_None);
422 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000423}
424
425/* void func (object, float) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000426static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000427call_forms_INfINf (void (*func)(FL_OBJECT *, float, float), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000428{
Guido van Rossum03747111991-08-08 12:10:01 +0000429 float par1, par2;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000430
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000431 if (!PyArg_Parse(args, "(ff)", &par1, &par2)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000432
Guido van Rossum03747111991-08-08 12:10:01 +0000433 (*func) (obj, par1, par2);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000434
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000435 Py_INCREF(Py_None);
436 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000437}
438
439/* void func (object, int) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000440static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000441call_forms_INi (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000442{
Guido van Rossum03747111991-08-08 12:10:01 +0000443 int parameter;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000444
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000445 if (!PyArg_Parse(args, "i", &parameter)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000446
Guido van Rossum03747111991-08-08 12:10:01 +0000447 (*func) (obj, parameter);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000448
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000449 Py_INCREF(Py_None);
450 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000451}
452
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000453/* void func (object, char) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000454static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000455call_forms_INc (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000456{
Guido van Rossumfc58e581992-01-27 16:45:55 +0000457 char *a;
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000458
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000459 if (!PyArg_Parse(args, "s", &a)) return NULL;
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000460
Guido van Rossumfc58e581992-01-27 16:45:55 +0000461 (*func) (obj, a[0]);
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000462
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000463 Py_INCREF(Py_None);
464 return Py_None;
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000465}
466
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000467/* void func (object, string) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000468static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000469call_forms_INstr (void (*func)(FL_OBJECT *, char *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000470{
Guido van Rossumfc58e581992-01-27 16:45:55 +0000471 char *a;
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000472
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000473 if (!PyArg_Parse(args, "s", &a)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000474
Guido van Rossumfc58e581992-01-27 16:45:55 +0000475 (*func) (obj, a);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000476
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000477 Py_INCREF(Py_None);
478 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000479}
480
481
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000482/* void func (object, int, string) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000483static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000484call_forms_INiINstr (void (*func)(FL_OBJECT *, int, char *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000485{
Guido van Rossumfc58e581992-01-27 16:45:55 +0000486 char *b;
487 int a;
Guido van Rossum03747111991-08-08 12:10:01 +0000488
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000489 if (!PyArg_Parse(args, "(is)", &a, &b)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000490
Guido van Rossumfc58e581992-01-27 16:45:55 +0000491 (*func) (obj, a, b);
Guido van Rossum03747111991-08-08 12:10:01 +0000492
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000493 Py_INCREF(Py_None);
494 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000495}
496
Guido van Rossum03747111991-08-08 12:10:01 +0000497#ifdef UNUSED
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000498/* void func (object, int, int) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000499static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000500call_forms_INiINi (void (*func)(FL_OBJECT *, int, int), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000501{
Guido van Rossum03747111991-08-08 12:10:01 +0000502 int par1, par2;
503
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000504 if (!PyArg_Parse(args, "(ii)", &par1, &par2)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000505
506 (*func) (obj, par1, par2);
507
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000508 Py_INCREF(Py_None);
509 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000510}
Guido van Rossum03747111991-08-08 12:10:01 +0000511#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000512
513/* int func (object) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000514static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000515call_forms_Ri (int (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000516{
Guido van Rossum03747111991-08-08 12:10:01 +0000517 int retval;
518
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000519 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000520
521 retval = (*func) (obj);
522
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000523 return PyInt_FromLong ((long) retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000524}
525
526/* char * func (object) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000527static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000528call_forms_Rstr (char * (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000529{
Guido van Rossum03747111991-08-08 12:10:01 +0000530 char *str;
531
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000532 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000533
534 str = (*func) (obj);
535
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000536 if (str == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000537 Py_INCREF(Py_None);
538 return Py_None;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000539 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000540 return PyString_FromString (str);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000541}
542
543/* int func (object) */
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000544static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000545call_forms_Rf (float (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000546{
Guido van Rossum03747111991-08-08 12:10:01 +0000547 float retval;
548
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000549 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000550
551 retval = (*func) (obj);
552
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000553 return PyFloat_FromDouble (retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000554}
555
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000556static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000557call_forms_OUTfOUTf (void (*func)(FL_OBJECT *, float *, float *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000558{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000559 float f1, f2;
Guido van Rossum03747111991-08-08 12:10:01 +0000560
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000561 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000562
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000563 (*func) (obj, &f1, &f2);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000564
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000565 return Py_BuildValue("(ff)", f1, f2);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000566}
567
Guido van Rossum03747111991-08-08 12:10:01 +0000568#ifdef UNUSED
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000569static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000570call_forms_OUTf (void (*func)(FL_OBJECT *, float *), FL_OBJECT *obj, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000571{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000572 float f;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000573
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000574 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000575
576 (*func) (obj, &f);
577
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000578 return PyFloat_FromDouble (f);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000579}
Guido van Rossum03747111991-08-08 12:10:01 +0000580#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000581
582/**********************************************************************/
583/* Class : browser */
584
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000585static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000586set_browser_topline(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000587{
Guido van Rossum03747111991-08-08 12:10:01 +0000588 return call_forms_INi (fl_set_browser_topline, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000589}
590
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000591static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000592clear_browser(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000593{
Guido van Rossum03747111991-08-08 12:10:01 +0000594 return generic_call (g, args, fl_clear_browser);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000595}
596
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000597static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000598add_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000599{
Guido van Rossum03747111991-08-08 12:10:01 +0000600 return call_forms_INstr (fl_add_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000601}
602
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000603static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000604addto_browser (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000605{
Guido van Rossum03747111991-08-08 12:10:01 +0000606 return call_forms_INstr (fl_addto_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000607}
608
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000609static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000610insert_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000611{
Guido van Rossum03747111991-08-08 12:10:01 +0000612 return call_forms_INiINstr (fl_insert_browser_line,
613 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000614}
615
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000616static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000617delete_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000618{
Guido van Rossum03747111991-08-08 12:10:01 +0000619 return call_forms_INi (fl_delete_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000620}
621
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000622static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000623replace_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000624{
Guido van Rossum03747111991-08-08 12:10:01 +0000625 return call_forms_INiINstr (fl_replace_browser_line,
626 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000627}
628
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000629static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000630get_browser_line(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000631{
632 int i;
633 char *str;
634
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000635 if (!PyArg_Parse(args, "i", &i))
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000636 return NULL;
637
638 str = fl_get_browser_line (g->ob_generic, i);
639
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000640 if (str == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000641 Py_INCREF(Py_None);
642 return Py_None;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +0000643 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000644 return PyString_FromString (str);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000645}
646
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000647static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000648load_browser (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000649{
Guido van Rossumabe58351991-08-08 12:34:44 +0000650 /* XXX strictly speaking this is wrong since fl_load_browser
651 XXX returns int, not void */
Guido van Rossum03747111991-08-08 12:10:01 +0000652 return call_forms_INstr (fl_load_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000653}
654
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000655static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000656get_browser_maxline(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000657{
Guido van Rossum03747111991-08-08 12:10:01 +0000658 return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000659}
660
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000661static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000662select_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000663{
Guido van Rossum03747111991-08-08 12:10:01 +0000664 return call_forms_INi (fl_select_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000665}
666
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000667static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000668deselect_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000669{
Guido van Rossum03747111991-08-08 12:10:01 +0000670 return call_forms_INi (fl_deselect_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000671}
672
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000673static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000674deselect_browser (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000675{
Guido van Rossum03747111991-08-08 12:10:01 +0000676 return generic_call (g, args, fl_deselect_browser);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000677}
678
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000679static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000680isselected_browser_line (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000681{
682 int i, j;
Guido van Rossum03747111991-08-08 12:10:01 +0000683
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000684 if (!PyArg_Parse(args, "i", &i))
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000685 return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000686
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000687 j = fl_isselected_browser_line (g->ob_generic, i);
Guido van Rossum03747111991-08-08 12:10:01 +0000688
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000689 return PyInt_FromLong (j);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000690}
691
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000692static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000693get_browser (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000694{
Guido van Rossum03747111991-08-08 12:10:01 +0000695 return call_forms_Ri (fl_get_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000696}
697
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000698static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000699set_browser_fontsize (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000700{
Guido van Rossum03747111991-08-08 12:10:01 +0000701 return call_forms_INf (fl_set_browser_fontsize, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000702}
703
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000704static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000705set_browser_fontstyle (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000706{
Guido van Rossum03747111991-08-08 12:10:01 +0000707 return call_forms_INi (fl_set_browser_fontstyle, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000708}
709
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000710static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000711set_browser_specialkey (genericobject *g, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000712{
713 return call_forms_INc(fl_set_browser_specialkey, g-> ob_generic, args);
714}
715
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000716static PyMethodDef browser_methods[] = {
717 {"set_browser_topline", (PyCFunction)set_browser_topline},
718 {"clear_browser", (PyCFunction)clear_browser},
719 {"add_browser_line", (PyCFunction)add_browser_line},
720 {"addto_browser", (PyCFunction)addto_browser},
721 {"insert_browser_line", (PyCFunction)insert_browser_line},
722 {"delete_browser_line", (PyCFunction)delete_browser_line},
723 {"replace_browser_line", (PyCFunction)replace_browser_line},
724 {"get_browser_line", (PyCFunction)get_browser_line},
725 {"load_browser", (PyCFunction)load_browser},
726 {"get_browser_maxline", (PyCFunction)get_browser_maxline},
727 {"select_browser_line", (PyCFunction)select_browser_line},
728 {"deselect_browser_line", (PyCFunction)deselect_browser_line},
729 {"deselect_browser", (PyCFunction)deselect_browser},
730 {"isselected_browser_line", (PyCFunction)isselected_browser_line},
731 {"get_browser", (PyCFunction)get_browser},
732 {"set_browser_fontsize", (PyCFunction)set_browser_fontsize},
733 {"set_browser_fontstyle", (PyCFunction)set_browser_fontstyle},
734 {"set_browser_specialkey", (PyCFunction)set_browser_specialkey},
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000735 {NULL, NULL} /* sentinel */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000736};
737
738/* Class: button */
739
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000740static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000741set_button(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000742{
Guido van Rossum03747111991-08-08 12:10:01 +0000743 return call_forms_INi (fl_set_button, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000744}
745
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000746static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000747get_button(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000748{
Guido van Rossum03747111991-08-08 12:10:01 +0000749 return call_forms_Ri (fl_get_button, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000750}
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000751
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000752static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000753get_button_numb(genericobject *g, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +0000754{
755 return call_forms_Ri (fl_get_button_numb, g-> ob_generic, args);
756}
757
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000758static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000759set_button_shortcut(genericobject *g, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000760{
761 return call_forms_INstr (fl_set_button_shortcut, g-> ob_generic, args);
762}
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000763
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000764static PyMethodDef button_methods[] = {
765 {"set_button", (PyCFunction)set_button},
766 {"get_button", (PyCFunction)get_button},
767 {"get_button_numb", (PyCFunction)get_button_numb},
768 {"set_button_shortcut", (PyCFunction)set_button_shortcut},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000769 {NULL, NULL} /* sentinel */
770};
771
772/* Class: choice */
773
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000774static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000775set_choice(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000776{
Guido van Rossum03747111991-08-08 12:10:01 +0000777 return call_forms_INi (fl_set_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000778}
779
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000780static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000781get_choice(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000782{
Guido van Rossum03747111991-08-08 12:10:01 +0000783 return call_forms_Ri (fl_get_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000784}
785
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000786static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000787clear_choice (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000788{
Guido van Rossum03747111991-08-08 12:10:01 +0000789 return generic_call (g, args, fl_clear_choice);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000790}
791
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000792static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000793addto_choice (genericobject *g, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000794{
Guido van Rossum03747111991-08-08 12:10:01 +0000795 return call_forms_INstr (fl_addto_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000796}
797
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000798static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000799replace_choice (genericobject *g, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000800{
Guido van Rossum03747111991-08-08 12:10:01 +0000801 return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000802}
803
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000804static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000805delete_choice (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000806{
Guido van Rossum03747111991-08-08 12:10:01 +0000807 return call_forms_INi (fl_delete_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000808}
809
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000810static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000811get_choice_text (genericobject *g, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000812{
Guido van Rossum03747111991-08-08 12:10:01 +0000813 return call_forms_Rstr (fl_get_choice_text, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000814}
815
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000816static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000817set_choice_fontsize (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000818{
Guido van Rossum03747111991-08-08 12:10:01 +0000819 return call_forms_INf (fl_set_choice_fontsize, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000820}
821
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000822static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000823set_choice_fontstyle (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000824{
Guido van Rossum03747111991-08-08 12:10:01 +0000825 return call_forms_INi (fl_set_choice_fontstyle, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000826}
827
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000828static PyMethodDef choice_methods[] = {
829 {"set_choice", (PyCFunction)set_choice},
830 {"get_choice", (PyCFunction)get_choice},
831 {"clear_choice", (PyCFunction)clear_choice},
832 {"addto_choice", (PyCFunction)addto_choice},
833 {"replace_choice", (PyCFunction)replace_choice},
834 {"delete_choice", (PyCFunction)delete_choice},
835 {"get_choice_text", (PyCFunction)get_choice_text},
836 {"set_choice_fontsize", (PyCFunction)set_choice_fontsize},
837 {"set_choice_fontstyle",(PyCFunction)set_choice_fontstyle},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000838 {NULL, NULL} /* sentinel */
839};
840
841/* Class : Clock */
842
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000843static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000844get_clock(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000845{
846 int i0, i1, i2;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000847
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000848 if (!PyArg_NoArgs(args))
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000849 return NULL;
850
851 fl_get_clock (g->ob_generic, &i0, &i1, &i2);
852
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000853 return Py_BuildValue("(iii)", i0, i1, i2);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000854}
855
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000856static PyMethodDef clock_methods[] = {
857 {"get_clock", (PyCFunction)get_clock},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000858 {NULL, NULL} /* sentinel */
859};
860
861/* CLass : Counters */
862
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000863static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000864get_counter_value(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000865{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000866 return call_forms_Rf (fl_get_counter_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000867}
868
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000869static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000870set_counter_value (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000871{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000872 return call_forms_INf (fl_set_counter_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000873}
874
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000875static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000876set_counter_precision (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000877{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000878 return call_forms_INi (fl_set_counter_precision, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000879}
880
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000881static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000882set_counter_bounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000883{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000884 return call_forms_INfINf (fl_set_counter_bounds, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000885}
886
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000887static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000888set_counter_step (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000889{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000890 return call_forms_INfINf (fl_set_counter_step, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000891}
892
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000893static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000894set_counter_return (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000895{
Guido van Rossum03747111991-08-08 12:10:01 +0000896 return call_forms_INi (fl_set_counter_return, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000897}
898
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000899static PyMethodDef counter_methods[] = {
900 {"set_counter_value", (PyCFunction)set_counter_value},
901 {"get_counter_value", (PyCFunction)get_counter_value},
902 {"set_counter_bounds", (PyCFunction)set_counter_bounds},
903 {"set_counter_step", (PyCFunction)set_counter_step},
904 {"set_counter_precision", (PyCFunction)set_counter_precision},
905 {"set_counter_return", (PyCFunction)set_counter_return},
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000906 {NULL, NULL} /* sentinel */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000907};
908
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000909
910/* Class: Dials */
911
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000912static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000913get_dial_value(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000914{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000915 return call_forms_Rf (fl_get_dial_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000916}
917
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000918static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000919set_dial_value (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000920{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000921 return call_forms_INf (fl_set_dial_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000922}
923
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000924static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000925set_dial_bounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000926{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000927 return call_forms_INfINf (fl_set_dial_bounds, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000928}
929
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000930static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000931get_dial_bounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000932{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000933 return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000934}
935
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000936static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000937set_dial_step (genericobject *g, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000938{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000939 return call_forms_INf (fl_set_dial_step, g-> ob_generic, args);
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000940}
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000941
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000942static PyMethodDef dial_methods[] = {
943 {"set_dial_value", (PyCFunction)set_dial_value},
944 {"get_dial_value", (PyCFunction)get_dial_value},
945 {"set_dial_bounds", (PyCFunction)set_dial_bounds},
946 {"get_dial_bounds", (PyCFunction)get_dial_bounds},
947 {"set_dial_step", (PyCFunction)set_dial_step},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000948 {NULL, NULL} /* sentinel */
949};
950
951/* Class : Input */
952
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000953static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000954set_input (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000955{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000956 return call_forms_INstr (fl_set_input, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000957}
958
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000959static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000960get_input (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000961{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000962 return call_forms_Rstr (fl_get_input, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000963}
964
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000965static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000966set_input_color (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000967{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000968 return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000969}
970
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000971static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000972set_input_return (genericobject *g, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000973{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +0000974 return call_forms_INi (fl_set_input_return, g-> ob_generic, args);
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000975}
Guido van Rossumddc0d3e1991-12-10 13:56:42 +0000976
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000977static PyMethodDef input_methods[] = {
978 {"set_input", (PyCFunction)set_input},
979 {"get_input", (PyCFunction)get_input},
980 {"set_input_color", (PyCFunction)set_input_color},
981 {"set_input_return", (PyCFunction)set_input_return},
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000982 {NULL, NULL} /* sentinel */
983};
984
985
986/* Class : Menu */
987
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000988static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000989set_menu (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000990{
Guido van Rossumabe58351991-08-08 12:34:44 +0000991 return call_forms_INstr (fl_set_menu, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000992}
993
Roger E. Masse7ba4c071997-01-03 22:17:11 +0000994static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +0000995get_menu (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000996{
Guido van Rossumabe58351991-08-08 12:34:44 +0000997 /* XXX strictly speaking this is wrong since fl_get_menu
998 XXX returns long, not int */
999 return call_forms_Ri (fl_get_menu, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001000}
1001
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001002static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001003get_menu_text (genericobject *g, PyObject *args)
Guido van Rossum8b17d6b1993-03-30 13:18:41 +00001004{
1005 return call_forms_Rstr (fl_get_menu_text, g-> ob_generic, args);
1006}
1007
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001008static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001009addto_menu (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001010{
Guido van Rossumabe58351991-08-08 12:34:44 +00001011 return call_forms_INstr (fl_addto_menu, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001012}
1013
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001014static PyMethodDef menu_methods[] = {
1015 {"set_menu", (PyCFunction)set_menu},
1016 {"get_menu", (PyCFunction)get_menu},
1017 {"get_menu_text", (PyCFunction)get_menu_text},
1018 {"addto_menu", (PyCFunction)addto_menu},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001019 {NULL, NULL} /* sentinel */
1020};
1021
1022
1023/* Class: Sliders */
1024
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001025static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001026get_slider_value(genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001027{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001028 return call_forms_Rf (fl_get_slider_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001029}
1030
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001031static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001032set_slider_value (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001033{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001034 return call_forms_INf (fl_set_slider_value, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001035}
1036
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001037static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001038set_slider_bounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001039{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001040 return call_forms_INfINf (fl_set_slider_bounds, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001041}
1042
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001043static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001044get_slider_bounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001045{
1046 return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic, args);
1047}
1048
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001049static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001050set_slider_return (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001051{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001052 return call_forms_INf (fl_set_slider_return, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001053}
1054
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001055static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001056set_slider_size (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001057{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001058 return call_forms_INf (fl_set_slider_size, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001059}
1060
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001061static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001062set_slider_precision (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001063{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001064 return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001065}
1066
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001067static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001068set_slider_step (genericobject *g, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001069{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001070 return call_forms_INf (fl_set_slider_step, g-> ob_generic, args);
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001071}
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001072
1073
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001074static PyMethodDef slider_methods[] = {
1075 {"set_slider_value", (PyCFunction)set_slider_value},
1076 {"get_slider_value", (PyCFunction)get_slider_value},
1077 {"set_slider_bounds", (PyCFunction)set_slider_bounds},
1078 {"get_slider_bounds", (PyCFunction)get_slider_bounds},
1079 {"set_slider_return", (PyCFunction)set_slider_return},
1080 {"set_slider_size", (PyCFunction)set_slider_size},
1081 {"set_slider_precision",(PyCFunction)set_slider_precision},
1082 {"set_slider_step", (PyCFunction)set_slider_step},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001083 {NULL, NULL} /* sentinel */
1084};
1085
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001086static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001087set_positioner_xvalue (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001088{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001089 return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001090}
1091
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001092static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001093set_positioner_xbounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001094{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001095 return call_forms_INfINf (fl_set_positioner_xbounds,
1096 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001097}
1098
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001099static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001100set_positioner_yvalue (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001101{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001102 return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001103}
1104
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001105static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001106set_positioner_ybounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001107{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001108 return call_forms_INfINf (fl_set_positioner_ybounds,
1109 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001110}
1111
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001112static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001113get_positioner_xvalue (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001114{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001115 return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001116}
1117
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001118static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001119get_positioner_xbounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001120{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001121 return call_forms_OUTfOUTf (fl_get_positioner_xbounds,
1122 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001123}
1124
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001125static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001126get_positioner_yvalue (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001127{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001128 return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001129}
1130
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001131static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001132get_positioner_ybounds (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001133{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001134 return call_forms_OUTfOUTf (fl_get_positioner_ybounds,
1135 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001136}
1137
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001138static PyMethodDef positioner_methods[] = {
1139 {"set_positioner_xvalue", (PyCFunction)set_positioner_xvalue},
1140 {"set_positioner_yvalue", (PyCFunction)set_positioner_yvalue},
1141 {"set_positioner_xbounds", (PyCFunction)set_positioner_xbounds},
1142 {"set_positioner_ybounds", (PyCFunction)set_positioner_ybounds},
1143 {"get_positioner_xvalue", (PyCFunction)get_positioner_xvalue},
1144 {"get_positioner_yvalue", (PyCFunction)get_positioner_yvalue},
1145 {"get_positioner_xbounds", (PyCFunction)get_positioner_xbounds},
1146 {"get_positioner_ybounds", (PyCFunction)get_positioner_ybounds},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001147 {NULL, NULL} /* sentinel */
1148};
1149
1150/* Class timer */
1151
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001152static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001153set_timer (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001154{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001155 return call_forms_INf (fl_set_timer, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001156}
1157
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001158static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001159get_timer (genericobject *g, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001160{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001161 return call_forms_Rf (fl_get_timer, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001162}
1163
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001164static PyMethodDef timer_methods[] = {
1165 {"set_timer", (PyCFunction)set_timer},
1166 {"get_timer", (PyCFunction)get_timer},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001167 {NULL, NULL} /* sentinel */
1168};
1169
1170/* Form objects */
1171
1172typedef struct {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001173 PyObject_HEAD
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001174 FL_FORM *ob_form;
1175} formobject;
1176
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001177staticforward PyTypeObject Formtype;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001178
1179#define is_formobject(v) ((v)->ob_type == &Formtype)
1180
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001181static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001182form_show_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001183{
1184 int place, border;
Guido van Rossumfc58e581992-01-27 16:45:55 +00001185 char *name;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001186 if (!PyArg_Parse(args, "(iis)", &place, &border, &name))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001187 return NULL;
Guido van Rossumfc58e581992-01-27 16:45:55 +00001188 fl_show_form(f->ob_form, place, border, name);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001189 Py_INCREF(Py_None);
1190 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001191}
1192
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001193static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001194form_call(void (*func)(FL_FORM *), FL_FORM *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001195{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001196 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001197
1198 (*func)(f);
1199
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001200 Py_INCREF(Py_None);
1201 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001202}
1203
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001204static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001205form_call_INiINi(void (*func)(FL_FORM *, int, int), FL_FORM *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001206{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001207 int a, b;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001208
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001209 if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001210
1211 (*func)(f, a, b);
1212
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001213 Py_INCREF(Py_None);
1214 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001215}
1216
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001217static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001218form_call_INfINf(void (*func)(FL_FORM *, float, float), FL_FORM *f, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +00001219{
1220 float a, b;
1221
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001222 if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL;
Guido van Rossumf1dc5661993-07-05 10:31:29 +00001223
1224 (*func)(f, a, b);
1225
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001226 Py_INCREF(Py_None);
1227 return Py_None;
Guido van Rossumf1dc5661993-07-05 10:31:29 +00001228}
1229
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001230static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001231form_hide_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001232{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001233 return form_call(fl_hide_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001234}
1235
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001236static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001237form_redraw_form(formobject *f, PyObject *args)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001238{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001239 return form_call(fl_redraw_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001240}
1241
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001242static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001243form_set_form_position(formobject *f, PyObject *args)
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001244{
1245 return form_call_INiINi(fl_set_form_position, f-> ob_form, args);
1246}
1247
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001248static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001249form_set_form_size(formobject *f, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +00001250{
1251 return form_call_INiINi(fl_set_form_size, f-> ob_form, args);
1252}
1253
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001254static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001255form_scale_form(formobject *f, PyObject *args)
Guido van Rossumf1dc5661993-07-05 10:31:29 +00001256{
1257 return form_call_INfINf(fl_scale_form, f-> ob_form, args);
1258}
1259
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001260static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001261generic_add_object(formobject *f, PyObject *args, FL_OBJECT *(*func)(int, float, float, float, float, char*), PyMethodDef *internal_methods)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001262{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001263 int type;
1264 float x, y, w, h;
Guido van Rossumfc58e581992-01-27 16:45:55 +00001265 char *name;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001266 FL_OBJECT *obj;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001267
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001268 if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name))
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001269 return NULL;
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001270
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001271 fl_addto_form (f-> ob_form);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001272
Guido van Rossumfc58e581992-01-27 16:45:55 +00001273 obj = (*func) (type, x, y, w, h, name);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001274
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001275 fl_end_form();
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001276
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001277 if (obj == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001278 PyErr_NoMemory();
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001279 return NULL;
1280 }
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001281
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001282 return newgenericobject (obj, internal_methods);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001283}
1284
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001285static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001286form_add_button(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001287{
1288 return generic_add_object(f, args, fl_add_button, button_methods);
1289}
1290
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001291static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001292form_add_lightbutton(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001293{
1294 return generic_add_object(f, args, fl_add_lightbutton, button_methods);
1295}
1296
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001297static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001298form_add_roundbutton(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001299{
1300 return generic_add_object(f, args, fl_add_roundbutton, button_methods);
1301}
1302
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001303static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001304form_add_menu (formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001305{
1306 return generic_add_object(f, args, fl_add_menu, menu_methods);
1307}
1308
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001309static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001310form_add_slider(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001311{
1312 return generic_add_object(f, args, fl_add_slider, slider_methods);
1313}
1314
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001315static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001316form_add_valslider(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001317{
1318 return generic_add_object(f, args, fl_add_valslider, slider_methods);
1319}
1320
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001321static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001322form_add_dial(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001323{
1324 return generic_add_object(f, args, fl_add_dial, dial_methods);
1325}
1326
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001327static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001328form_add_counter(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001329{
1330 return generic_add_object(f, args, fl_add_counter, counter_methods);
1331}
1332
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001333static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001334form_add_clock(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001335{
1336 return generic_add_object(f, args, fl_add_clock, clock_methods);
1337}
1338
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001339static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001340form_add_box(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001341{
Guido van Rossum03747111991-08-08 12:10:01 +00001342 return generic_add_object(f, args, fl_add_box,
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001343 (PyMethodDef *)NULL);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001344}
1345
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001346static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001347form_add_choice(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001348{
1349 return generic_add_object(f, args, fl_add_choice, choice_methods);
1350}
1351
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001352static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001353form_add_browser(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001354{
1355 return generic_add_object(f, args, fl_add_browser, browser_methods);
1356}
1357
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001358static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001359form_add_positioner(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001360{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001361 return generic_add_object(f, args, fl_add_positioner,
1362 positioner_methods);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001363}
1364
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001365static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001366form_add_input(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001367{
1368 return generic_add_object(f, args, fl_add_input, input_methods);
1369}
1370
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001371static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001372form_add_text(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001373{
Guido van Rossum03747111991-08-08 12:10:01 +00001374 return generic_add_object(f, args, fl_add_text,
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001375 (PyMethodDef *)NULL);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001376}
1377
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001378static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001379form_add_timer(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001380{
1381 return generic_add_object(f, args, fl_add_timer, timer_methods);
1382}
1383
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001384static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001385form_freeze_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001386{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001387 return form_call(fl_freeze_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001388}
1389
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001390static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001391form_unfreeze_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001392{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001393 return form_call(fl_unfreeze_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001394}
1395
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001396static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001397form_activate_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001398{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001399 return form_call(fl_activate_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001400}
1401
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001402static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001403form_deactivate_form(formobject *f, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001404{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001405 return form_call(fl_deactivate_form, f-> ob_form, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001406}
1407
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001408static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001409form_bgn_group(formobject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00001410{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001411 FL_OBJECT *obj;
1412
1413 fl_addto_form(f-> ob_form);
1414 obj = fl_bgn_group();
1415 fl_end_form();
1416
1417 if (obj == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001418 PyErr_NoMemory();
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001419 return NULL;
1420 }
1421
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001422 return newgenericobject (obj, (PyMethodDef *) NULL);
Guido van Rossum03747111991-08-08 12:10:01 +00001423}
1424
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001425static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001426form_end_group(formobject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00001427{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001428 fl_addto_form(f-> ob_form);
Guido van Rossum03747111991-08-08 12:10:01 +00001429 fl_end_group();
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001430 fl_end_form();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001431 Py_INCREF(Py_None);
1432 return Py_None;
Guido van Rossum03747111991-08-08 12:10:01 +00001433}
1434
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001435static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001436forms_find_first_or_last(FL_OBJECT *(*func)(FL_FORM *, int, float, float), formobject *f, PyObject *args)
Guido van Rossum75cc8981991-08-08 12:07:45 +00001437{
1438 int type;
1439 float mx, my;
1440 FL_OBJECT *generic;
1441 genericobject *g;
1442
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001443 if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001444
Guido van Rossum03747111991-08-08 12:10:01 +00001445 generic = (*func) (f-> ob_form, type, mx, my);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001446
1447 if (generic == NULL)
1448 {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001449 Py_INCREF(Py_None);
1450 return Py_None;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001451 }
1452
1453 g = findgeneric(generic);
1454 if (g == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001455 PyErr_SetString(PyExc_RuntimeError,
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001456 "forms_find_{first|last} returns unknown object");
Guido van Rossum75cc8981991-08-08 12:07:45 +00001457 return NULL;
1458 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001459 Py_INCREF(g);
1460 return (PyObject *) g;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001461}
1462
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001463static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001464form_find_first(formobject *f, PyObject *args)
Guido van Rossum75cc8981991-08-08 12:07:45 +00001465{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001466 return forms_find_first_or_last(fl_find_first, f, args);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001467}
1468
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001469static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001470form_find_last(formobject *f, PyObject *args)
Guido van Rossum75cc8981991-08-08 12:07:45 +00001471{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001472 return forms_find_first_or_last(fl_find_last, f, args);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001473}
1474
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001475static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001476form_set_object_focus(formobject *f, PyObject *args)
Guido van Rossum7066dd71992-09-17 17:54:56 +00001477{
1478 genericobject *g;
1479 if (args == NULL || !is_genericobject(args)) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001480 PyErr_BadArgument();
Guido van Rossum7066dd71992-09-17 17:54:56 +00001481 return NULL;
1482 }
1483 g = (genericobject *)args;
1484 fl_set_object_focus(f->ob_form, g->ob_generic);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001485 Py_INCREF(Py_None);
1486 return Py_None;
Guido van Rossum7066dd71992-09-17 17:54:56 +00001487}
1488
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001489static PyMethodDef form_methods[] = {
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001490/* adm */
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001491 {"show_form", (PyCFunction)form_show_form},
1492 {"hide_form", (PyCFunction)form_hide_form},
1493 {"redraw_form", (PyCFunction)form_redraw_form},
1494 {"set_form_position", (PyCFunction)form_set_form_position},
1495 {"set_form_size", (PyCFunction)form_set_form_size},
1496 {"scale_form", (PyCFunction)form_scale_form},
1497 {"freeze_form", (PyCFunction)form_freeze_form},
1498 {"unfreeze_form", (PyCFunction)form_unfreeze_form},
1499 {"activate_form", (PyCFunction)form_activate_form},
1500 {"deactivate_form", (PyCFunction)form_deactivate_form},
1501 {"bgn_group", (PyCFunction)form_bgn_group},
1502 {"end_group", (PyCFunction)form_end_group},
1503 {"find_first", (PyCFunction)form_find_first},
1504 {"find_last", (PyCFunction)form_find_last},
1505 {"set_object_focus", (PyCFunction)form_set_object_focus},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001506
1507/* basic objects */
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001508 {"add_button", (PyCFunction)form_add_button},
Guido van Rossumb6775db1994-08-01 11:34:53 +00001509/* {"add_bitmap", (method)form_add_bitmap}, */
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001510 {"add_lightbutton", (PyCFunction)form_add_lightbutton},
1511 {"add_roundbutton", (PyCFunction)form_add_roundbutton},
1512 {"add_menu", (PyCFunction)form_add_menu},
1513 {"add_slider", (PyCFunction)form_add_slider},
1514 {"add_positioner", (PyCFunction)form_add_positioner},
1515 {"add_valslider", (PyCFunction)form_add_valslider},
1516 {"add_dial", (PyCFunction)form_add_dial},
1517 {"add_counter", (PyCFunction)form_add_counter},
1518 {"add_box", (PyCFunction)form_add_box},
1519 {"add_clock", (PyCFunction)form_add_clock},
1520 {"add_choice", (PyCFunction)form_add_choice},
1521 {"add_browser", (PyCFunction)form_add_browser},
1522 {"add_input", (PyCFunction)form_add_input},
1523 {"add_timer", (PyCFunction)form_add_timer},
1524 {"add_text", (PyCFunction)form_add_text},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001525 {NULL, NULL} /* sentinel */
1526};
1527
1528static void
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001529form_dealloc(formobject *f)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001530{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001531 releaseobjects(f->ob_form);
Guido van Rossum336b5911992-04-08 11:16:25 +00001532 if (f->ob_form->visible)
1533 fl_hide_form(f->ob_form);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001534 fl_free_form(f->ob_form);
Guido van Rossumb18618d2000-05-03 23:44:39 +00001535 PyObject_Del(f);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001536}
1537
Guido van Rossumd97f0481991-11-19 20:26:28 +00001538#define OFF(x) offsetof(FL_FORM, x)
1539
Guido van Rossum32db5e31991-11-12 15:43:18 +00001540static struct memberlist form_memberlist[] = {
1541 {"window", T_LONG, OFF(window), RO},
1542 {"w", T_FLOAT, OFF(w)},
1543 {"h", T_FLOAT, OFF(h)},
Guido van Rossum7066dd71992-09-17 17:54:56 +00001544 {"x", T_FLOAT, OFF(x), RO},
1545 {"y", T_FLOAT, OFF(y), RO},
Guido van Rossum32db5e31991-11-12 15:43:18 +00001546 {"deactivated", T_INT, OFF(deactivated)},
Guido van Rossum7066dd71992-09-17 17:54:56 +00001547 {"visible", T_INT, OFF(visible), RO},
1548 {"frozen", T_INT, OFF(frozen), RO},
Guido van Rossum32db5e31991-11-12 15:43:18 +00001549 {"doublebuf", T_INT, OFF(doublebuf)},
1550 {NULL} /* Sentinel */
1551};
1552
Guido van Rossumd97f0481991-11-19 20:26:28 +00001553#undef OFF
1554
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001555static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001556form_getattr(formobject *f, char *name)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001557{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001558 PyObject *meth;
Guido van Rossum32db5e31991-11-12 15:43:18 +00001559
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001560 meth = Py_FindMethod(form_methods, (PyObject *)f, name);
Guido van Rossum32db5e31991-11-12 15:43:18 +00001561 if (meth != NULL)
1562 return meth;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001563 PyErr_Clear();
1564 return PyMember_Get((char *)f->ob_form, form_memberlist, name);
Guido van Rossum32db5e31991-11-12 15:43:18 +00001565}
1566
1567static int
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001568form_setattr(formobject *f, char *name, PyObject *v)
Guido van Rossum32db5e31991-11-12 15:43:18 +00001569{
Guido van Rossum32db5e31991-11-12 15:43:18 +00001570 if (v == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001571 PyErr_SetString(PyExc_TypeError,
1572 "can't delete form attributes");
Guido van Rossum3863abb1996-09-11 23:31:07 +00001573 return -1;
Guido van Rossum32db5e31991-11-12 15:43:18 +00001574 }
1575
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001576 return PyMember_Set((char *)f->ob_form, form_memberlist, name, v);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001577}
1578
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001579static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001580form_repr(formobject *f)
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001581{
1582 char buf[100];
Fred Drakea44d3532000-06-30 15:01:00 +00001583 sprintf(buf, "<FORMS_form at %p, window=%ld>",
1584 f, f->ob_form->window);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001585 return PyString_FromString(buf);
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001586}
1587
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001588static PyTypeObject Formtype = {
1589 PyObject_HEAD_INIT(&PyType_Type)
Guido van Rossumb6775db1994-08-01 11:34:53 +00001590 0, /*ob_size*/
1591 "FORMS_form", /*tp_name*/
1592 sizeof(formobject), /*tp_size*/
1593 0, /*tp_itemsize*/
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001594 /* methods */
Guido van Rossumb6775db1994-08-01 11:34:53 +00001595 (destructor)form_dealloc, /*tp_dealloc*/
1596 0, /*tp_print*/
1597 (getattrfunc)form_getattr, /*tp_getattr*/
1598 (setattrfunc)form_setattr, /*tp_setattr*/
1599 0, /*tp_compare*/
1600 (reprfunc)form_repr, /*tp_repr*/
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001601};
1602
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001603static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001604newformobject(FL_FORM *form)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001605{
1606 formobject *f;
Guido van Rossumb18618d2000-05-03 23:44:39 +00001607 f = PyObject_New(formobject, &Formtype);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001608 if (f == NULL)
1609 return NULL;
1610 f->ob_form = form;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001611 return (PyObject *)f;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001612}
1613
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001614
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001615/* The "fl" module */
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001616
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001617static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001618forms_make_form(PyObject *dummy, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001619{
1620 int type;
1621 float w, h;
1622 FL_FORM *form;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001623 if (!PyArg_Parse(args, "(iff)", &type, &w, &h))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001624 return NULL;
1625 form = fl_bgn_form(type, w, h);
1626 if (form == NULL) {
1627 /* XXX Actually, cannot happen! */
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001628 PyErr_NoMemory();
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001629 return NULL;
1630 }
1631 fl_end_form();
1632 return newformobject(form);
1633}
1634
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001635static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001636forms_activate_all_forms(PyObject *f, PyObject *args)
Guido van Rossum2bac4d31992-03-27 17:20:21 +00001637{
1638 fl_activate_all_forms();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001639 Py_INCREF(Py_None);
1640 return Py_None;
Guido van Rossum2bac4d31992-03-27 17:20:21 +00001641}
1642
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001643static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001644forms_deactivate_all_forms(PyObject *f, PyObject *args)
Guido van Rossum2bac4d31992-03-27 17:20:21 +00001645{
1646 fl_deactivate_all_forms();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001647 Py_INCREF(Py_None);
1648 return Py_None;
Guido van Rossum2bac4d31992-03-27 17:20:21 +00001649}
1650
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001651static PyObject *my_event_callback = NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001652
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001653static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001654forms_set_event_call_back(PyObject *dummy, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001655{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001656 if (args == Py_None)
Guido van Rossumf6da4f61993-07-26 15:24:57 +00001657 args = NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001658 my_event_callback = args;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001659 Py_XINCREF(args);
1660 Py_INCREF(Py_None);
1661 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001662}
1663
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001664static PyObject *
Thomas Woutersbd4bc4e2000-07-22 23:57:55 +00001665forms_do_or_check_forms(PyObject *dummy, PyObject *args, FL_OBJECT *(*func)(void))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001666{
1667 FL_OBJECT *generic;
1668 genericobject *g;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001669 PyObject *arg, *res;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001670
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001671 if (!PyArg_NoArgs(args))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001672 return NULL;
1673
1674 for (;;) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001675 Py_BEGIN_ALLOW_THREADS
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001676 generic = (*func)();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001677 Py_END_ALLOW_THREADS
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001678 if (generic == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001679 Py_INCREF(Py_None);
1680 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001681 }
1682 if (generic == FL_EVENT) {
1683 int dev;
1684 short val;
1685 if (my_event_callback == NULL)
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001686 return PyInt_FromLong(-1L);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001687 dev = fl_qread(&val);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001688 arg = Py_BuildValue("(ih)", dev, val);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001689 if (arg == NULL)
1690 return NULL;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001691 res = PyEval_CallObject(my_event_callback, arg);
1692 Py_XDECREF(res);
1693 Py_DECREF(arg);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001694 if (res == NULL)
1695 return NULL; /* Callback raised exception */
1696 continue;
1697 }
1698 g = findgeneric(generic);
1699 if (g == NULL) {
Guido van Rossuma9e7dc11992-10-18 18:53:57 +00001700 /* Object not known to us (some dialogs cause this) */
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001701 continue; /* Ignore it */
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001702 }
1703 if (g->ob_callback == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001704 Py_INCREF(g);
1705 return ((PyObject *) g);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001706 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001707 arg = Py_BuildValue("(OO)", (PyObject *)g, g->ob_callback_arg);
Guido van Rossume5372401993-03-16 12:15:04 +00001708 if (arg == NULL)
1709 return NULL;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001710 res = PyEval_CallObject(g->ob_callback, arg);
1711 Py_XDECREF(res);
1712 Py_DECREF(arg);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001713 if (res == NULL)
1714 return NULL; /* Callback raised exception */
1715 }
1716}
1717
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001718static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001719forms_do_forms(PyObject *dummy, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001720{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001721 return forms_do_or_check_forms(dummy, args, fl_do_forms);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001722}
1723
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001724static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001725forms_check_forms(PyObject *dummy, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001726{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001727 return forms_do_or_check_forms(dummy, args, fl_check_forms);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001728}
1729
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001730static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001731forms_do_only_forms(PyObject *dummy, PyObject *args)
Guido van Rossum7066dd71992-09-17 17:54:56 +00001732{
1733 return forms_do_or_check_forms(dummy, args, fl_do_only_forms);
1734}
1735
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001736static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001737forms_check_only_forms(PyObject *dummy, PyObject *args)
Guido van Rossum7066dd71992-09-17 17:54:56 +00001738{
1739 return forms_do_or_check_forms(dummy, args, fl_check_only_forms);
1740}
1741
Guido van Rossum03747111991-08-08 12:10:01 +00001742#ifdef UNUSED
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001743static PyObject *
Thomas Woutersbd4bc4e2000-07-22 23:57:55 +00001744fl_call(void (*func)(void), PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001745{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001746 if (!PyArg_NoArgs(args))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001747 return NULL;
1748 (*func)();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001749 Py_INCREF(Py_None);
1750 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001751}
Guido van Rossum03747111991-08-08 12:10:01 +00001752#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001753
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001754static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001755forms_set_graphics_mode(PyObject *dummy, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001756{
1757 int rgbmode, doublebuf;
1758
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001759 if (!PyArg_Parse(args, "(ii)", &rgbmode, &doublebuf))
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001760 return NULL;
1761 fl_set_graphics_mode(rgbmode,doublebuf);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001762 Py_INCREF(Py_None);
1763 return Py_None;
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001764}
1765
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001766static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001767forms_get_rgbmode(PyObject *dummy, PyObject *args)
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001768{
Guido van Rossum7066dd71992-09-17 17:54:56 +00001769 extern int fl_rgbmode;
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001770
1771 if (args != NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001772 PyErr_BadArgument();
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001773 return NULL;
1774 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001775 return PyInt_FromLong((long)fl_rgbmode);
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001776}
Guido van Rossum7066dd71992-09-17 17:54:56 +00001777
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001778static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001779forms_show_errors(PyObject *dummy, PyObject *args)
Guido van Rossum7066dd71992-09-17 17:54:56 +00001780{
1781 int show;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001782 if (!PyArg_Parse(args, "i", &show))
Guido van Rossum7066dd71992-09-17 17:54:56 +00001783 return NULL;
1784 fl_show_errors(show);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001785 Py_INCREF(Py_None);
1786 return Py_None;
Guido van Rossum7066dd71992-09-17 17:54:56 +00001787}
1788
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001789static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001790forms_set_font_name(PyObject *dummy, PyObject *args)
Guido van Rossum7066dd71992-09-17 17:54:56 +00001791{
1792 int numb;
1793 char *name;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001794 if (!PyArg_Parse(args, "(is)", &numb, &name))
Guido van Rossum7066dd71992-09-17 17:54:56 +00001795 return NULL;
1796 fl_set_font_name(numb, name);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001797 Py_INCREF(Py_None);
1798 return Py_None;
Guido van Rossum7066dd71992-09-17 17:54:56 +00001799}
1800
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00001801
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001802static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001803forms_qdevice(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001804{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001805 short arg1;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001806 if (!PyArg_Parse(args, "h", &arg1))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001807 return NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001808 fl_qdevice(arg1);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001809 Py_INCREF(Py_None);
1810 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001811}
1812
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001813static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001814forms_unqdevice(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001815{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001816 short arg1;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001817 if (!PyArg_Parse(args, "h", &arg1))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001818 return NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001819 fl_unqdevice(arg1);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001820 Py_INCREF(Py_None);
1821 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001822}
1823
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001824static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001825forms_isqueued(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001826{
Guido van Rossum03747111991-08-08 12:10:01 +00001827 long retval;
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001828 short arg1;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001829 if (!PyArg_Parse(args, "h", &arg1))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001830 return NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001831 retval = fl_isqueued(arg1);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001832
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001833 return PyInt_FromLong(retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001834}
1835
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001836static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001837forms_qtest(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001838{
1839 long retval;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001840 retval = fl_qtest();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001841 return PyInt_FromLong(retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001842}
1843
1844
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001845static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001846forms_qread(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001847{
Guido van Rossume5372401993-03-16 12:15:04 +00001848 int dev;
1849 short val;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001850 Py_BEGIN_ALLOW_THREADS
Guido van Rossume5372401993-03-16 12:15:04 +00001851 dev = fl_qread(&val);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001852 Py_END_ALLOW_THREADS
1853 return Py_BuildValue("(ih)", dev, val);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001854}
1855
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001856static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001857forms_qreset(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001858{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001859 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001860
Guido van Rossum03747111991-08-08 12:10:01 +00001861 fl_qreset();
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001862 Py_INCREF(Py_None);
1863 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001864}
1865
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001866static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001867forms_qenter(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001868{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001869 short arg1, arg2;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001870 if (!PyArg_Parse(args, "(hh)", &arg1, &arg2))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001871 return NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001872 fl_qenter(arg1, arg2);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001873 Py_INCREF(Py_None);
1874 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001875}
1876
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001877static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001878forms_color(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001879{
1880 int arg;
1881
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001882 if (!PyArg_Parse(args, "i", &arg)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001883
1884 fl_color((short) arg);
1885
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001886 Py_INCREF(Py_None);
1887 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001888}
1889
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001890static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001891forms_mapcolor(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001892{
1893 int arg0, arg1, arg2, arg3;
1894
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001895 if (!PyArg_Parse(args, "(iiii)", &arg0, &arg1, &arg2, &arg3))
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001896 return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001897
1898 fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3);
1899
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001900 Py_INCREF(Py_None);
1901 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001902}
1903
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001904static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001905forms_getmcolor(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001906{
Guido van Rossum03747111991-08-08 12:10:01 +00001907 int arg;
1908 short r, g, b;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001909
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001910 if (!PyArg_Parse(args, "i", &arg)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001911
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001912 fl_getmcolor(arg, &r, &g, &b);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001913
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001914 return Py_BuildValue("(hhh)", r, g, b);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001915}
1916
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001917static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001918forms_get_mouse(PyObject *self, PyObject *args)
Guido van Rossum75cc8981991-08-08 12:07:45 +00001919{
Guido van Rossume5372401993-03-16 12:15:04 +00001920 float x, y;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001921
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001922 if (!PyArg_NoArgs(args)) return NULL;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001923
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001924 fl_get_mouse(&x, &y);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001925
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001926 return Py_BuildValue("(ff)", x, y);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001927}
1928
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001929static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001930forms_tie(PyObject *self, PyObject *args)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001931{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00001932 short arg1, arg2, arg3;
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001933 if (!PyArg_Parse(args, "(hhh)", &arg1, &arg2, &arg3))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001934 return NULL;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00001935 fl_tie(arg1, arg2, arg3);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001936 Py_INCREF(Py_None);
1937 return Py_None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001938}
1939
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001940static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001941forms_show_message(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00001942{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001943 char *a, *b, *c;
Guido van Rossum03747111991-08-08 12:10:01 +00001944
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001945 if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +00001946
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001947 Py_BEGIN_ALLOW_THREADS
Guido van Rossumfc58e581992-01-27 16:45:55 +00001948 fl_show_message(a, b, c);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001949 Py_END_ALLOW_THREADS
Guido van Rossum03747111991-08-08 12:10:01 +00001950
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001951 Py_INCREF(Py_None);
1952 return Py_None;
Guido van Rossum03747111991-08-08 12:10:01 +00001953}
1954
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001955static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001956forms_show_choice(PyObject *f, PyObject *args)
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001957{
1958 char *m1, *m2, *m3, *b1, *b2, *b3;
1959 int nb;
1960 char *format;
Guido van Rossum7066dd71992-09-17 17:54:56 +00001961 long rv;
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001962
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001963 if (args == NULL || !PyTuple_Check(args)) {
1964 PyErr_BadArgument();
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001965 return NULL;
1966 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001967 nb = PyTuple_Size(args) - 3;
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001968 if (nb <= 0) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001969 PyErr_SetString(PyExc_TypeError,
1970 "need at least one button label");
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001971 return NULL;
1972 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001973 if (PyInt_Check(PyTuple_GetItem(args, 3))) {
1974 PyErr_SetString(PyExc_TypeError,
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001975 "'number-of-buttons' argument not needed");
1976 return NULL;
1977 }
1978 switch (nb) {
1979 case 1: format = "(ssss)"; break;
1980 case 2: format = "(sssss)"; break;
1981 case 3: format = "(ssssss)"; break;
1982 default:
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001983 PyErr_SetString(PyExc_TypeError, "too many button labels");
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001984 return NULL;
1985 }
1986
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001987 if (!PyArg_Parse(args, format, &m1, &m2, &m3, &b1, &b2, &b3))
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001988 return NULL;
1989
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001990 Py_BEGIN_ALLOW_THREADS
Jack Jansen743db361992-08-13 14:13:11 +00001991 rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001992 Py_END_ALLOW_THREADS
1993 return PyInt_FromLong(rv);
Guido van Rossumb3a0e4c1992-03-23 18:20:54 +00001994}
1995
Roger E. Masse7ba4c071997-01-03 22:17:11 +00001996static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00001997forms_show_question(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00001998{
Guido van Rossumfc58e581992-01-27 16:45:55 +00001999 int ret;
2000 char *a, *b, *c;
Guido van Rossum03747111991-08-08 12:10:01 +00002001
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002002 if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +00002003
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002004 Py_BEGIN_ALLOW_THREADS
Guido van Rossumfc58e581992-01-27 16:45:55 +00002005 ret = fl_show_question(a, b, c);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002006 Py_END_ALLOW_THREADS
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002007
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002008 return PyInt_FromLong((long) ret);
Guido van Rossum03747111991-08-08 12:10:01 +00002009}
2010
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002011static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00002012forms_show_input(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00002013{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002014 char *str;
Guido van Rossumfc58e581992-01-27 16:45:55 +00002015 char *a, *b;
Guido van Rossum03747111991-08-08 12:10:01 +00002016
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002017 if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +00002018
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002019 Py_BEGIN_ALLOW_THREADS
Guido van Rossumfc58e581992-01-27 16:45:55 +00002020 str = fl_show_input(a, b);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002021 Py_END_ALLOW_THREADS
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002022
2023 if (str == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002024 Py_INCREF(Py_None);
2025 return Py_None;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002026 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002027 return PyString_FromString(str);
Guido van Rossum03747111991-08-08 12:10:01 +00002028}
2029
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002030static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00002031forms_file_selector(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00002032{
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002033 char *str;
Guido van Rossumfc58e581992-01-27 16:45:55 +00002034 char *a, *b, *c, *d;
Guido van Rossum03747111991-08-08 12:10:01 +00002035
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002036 if (!PyArg_Parse(args, "(ssss)", &a, &b, &c, &d)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +00002037
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002038 Py_BEGIN_ALLOW_THREADS
Guido van Rossumfc58e581992-01-27 16:45:55 +00002039 str = fl_show_file_selector(a, b, c, d);
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002040 Py_END_ALLOW_THREADS
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002041
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002042 if (str == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002043 Py_INCREF(Py_None);
2044 return Py_None;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002045 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002046 return PyString_FromString(str);
Guido van Rossum03747111991-08-08 12:10:01 +00002047}
2048
2049
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002050static PyObject *
Thomas Woutersbd4bc4e2000-07-22 23:57:55 +00002051forms_file_selector_func(PyObject *args, char *(*func)(void))
Guido van Rossum03747111991-08-08 12:10:01 +00002052{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002053 char *str;
Guido van Rossum03747111991-08-08 12:10:01 +00002054
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002055 str = (*func) ();
2056
2057 if (str == NULL) {
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002058 Py_INCREF(Py_None);
2059 return Py_None;
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002060 }
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002061 return PyString_FromString(str);
Guido van Rossum03747111991-08-08 12:10:01 +00002062}
2063
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002064static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00002065forms_get_directory(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00002066{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002067 return forms_file_selector_func(args, fl_get_directory);
Guido van Rossum03747111991-08-08 12:10:01 +00002068}
2069
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002070static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00002071forms_get_pattern(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00002072{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002073 return forms_file_selector_func(args, fl_get_pattern);
Guido van Rossum03747111991-08-08 12:10:01 +00002074}
2075
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002076static PyObject *
Peter Schneider-Kamp6a850272000-07-10 17:04:33 +00002077forms_get_filename(PyObject *f, PyObject *args)
Guido van Rossum03747111991-08-08 12:10:01 +00002078{
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002079 return forms_file_selector_func(args, fl_get_filename);
Guido van Rossum03747111991-08-08 12:10:01 +00002080}
2081
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002082static PyMethodDef forms_methods[] = {
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002083/* adm */
2084 {"make_form", forms_make_form},
Guido van Rossum2bac4d31992-03-27 17:20:21 +00002085 {"activate_all_forms", forms_activate_all_forms},
2086 {"deactivate_all_forms",forms_deactivate_all_forms},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002087/* gl support wrappers */
2088 {"qdevice", forms_qdevice},
2089 {"unqdevice", forms_unqdevice},
2090 {"isqueued", forms_isqueued},
2091 {"qtest", forms_qtest},
2092 {"qread", forms_qread},
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002093/* {"blkqread", forms_blkqread}, */
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002094 {"qreset", forms_qreset},
2095 {"qenter", forms_qenter},
Guido van Rossum03747111991-08-08 12:10:01 +00002096 {"get_mouse", forms_get_mouse},
2097 {"tie", forms_tie},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002098/* {"new_events", forms_new_events}, */
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002099 {"color", forms_color},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002100 {"mapcolor", forms_mapcolor},
2101 {"getmcolor", forms_getmcolor},
2102/* interaction */
2103 {"do_forms", forms_do_forms},
Guido van Rossuma9e7dc11992-10-18 18:53:57 +00002104 {"do_only_forms", forms_do_only_forms},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002105 {"check_forms", forms_check_forms},
Guido van Rossuma9e7dc11992-10-18 18:53:57 +00002106 {"check_only_forms", forms_check_only_forms},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002107 {"set_event_call_back", forms_set_event_call_back},
2108/* goodies */
Guido van Rossumaa7ca2d1992-09-03 20:37:02 +00002109 {"show_message", forms_show_message},
2110 {"show_question", forms_show_question},
2111 {"show_choice", forms_show_choice},
2112 {"show_input", forms_show_input},
2113 {"show_file_selector", forms_file_selector},
2114 {"file_selector", forms_file_selector}, /* BW compat */
2115 {"get_directory", forms_get_directory},
2116 {"get_pattern", forms_get_pattern},
2117 {"get_filename", forms_get_filename},
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00002118 {"set_graphics_mode", forms_set_graphics_mode},
2119 {"get_rgbmode", forms_get_rgbmode},
Guido van Rossum7066dd71992-09-17 17:54:56 +00002120 {"show_errors", forms_show_errors},
2121 {"set_font_name", forms_set_font_name},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002122 {NULL, NULL} /* sentinel */
2123};
2124
Guido van Rossum3886bb61998-12-04 18:50:17 +00002125DL_EXPORT(void)
Thomas Woutersf3f33dc2000-07-21 06:00:07 +00002126initfl(void)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002127{
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002128 Py_InitModule("fl", forms_methods);
Guido van Rossum2df7bcc1991-10-20 20:18:26 +00002129 foreground();
Guido van Rossumddc0d3e1991-12-10 13:56:42 +00002130 fl_init();
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002131}
Roger E. Masse7ba4c071997-01-03 22:17:11 +00002132
2133
2134