cpython/Modules/flmodule.c

2533 lines
52 KiB
C
Raw Normal View History

1991-08-07 11:32:58 +00:00
/**********************************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
1991-08-07 11:32:58 +00:00
All Rights Reserved
1996-10-25 14:44:06 +00:00
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
1991-08-07 11:32:58 +00:00
provided that the above copyright notice appear in all copies and that
1996-10-25 14:44:06 +00:00
both that copyright notice and this permission notice appear in
1991-08-07 11:32:58 +00:00
supporting documentation, and that the names of Stichting Mathematisch
1996-10-25 14:44:06 +00:00
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
1991-08-07 11:32:58 +00:00
******************************************************************/
/* FL module -- interface to Mark Overmars' FORMS Library. */
1997-01-03 22:17:11 +00:00
/* This code works with FORMS version 2.2 (if you defined
OBSOLETE_FORMS_CALLS), and 2.3.
FORMS can be ftp'ed from ftp.cs.ruu.nl (131.211.80.17), directory
/pub/SGI/FORMS. */
1991-12-10 13:56:42 +00:00
/* A half-hearted attempt has been made to allow programs using this
* module to exploit parallelism (through the threads module). No provisions
* have been made for multiple threads to use this module at the same time,
* though. So, a program with a forms thread and a non-forms thread will work
* fine but a program with two threads using forms will probably crash (unless
* the program takes precaution to ensure that only one thread can be in
* this module at any time). This will have to be fixed some time.
* (A fix will probably also have to synchronise with the gl module).
*/
1997-01-03 22:17:11 +00:00
#include "Python.h"
1991-08-07 11:32:58 +00:00
#include "forms.h"
#include "structmember.h"
/* Generic Forms Objects */
typedef struct {
1997-01-03 22:17:11 +00:00
PyObject_HEAD
1991-08-07 11:32:58 +00:00
FL_OBJECT *ob_generic;
1997-01-03 22:17:11 +00:00
PyMethodDef *ob_methods;
PyObject *ob_callback;
PyObject *ob_callback_arg;
1991-08-07 11:32:58 +00:00
} genericobject;
1997-01-03 22:17:11 +00:00
staticforward PyTypeObject GenericObjecttype;
#define is_genericobject(g) ((g)->ob_type == &GenericObjecttype)
/* List of all objects (XXX this should be a hash table on address...) */
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
static PyObject *allgenerics = NULL;
static int nfreeslots = 0;
/* Add an object to the list of known objects */
1991-08-07 11:32:58 +00:00
static void
knowgeneric(g)
genericobject *g;
{
int i, n;
/* Create the list if it doesn't already exist */
1991-08-07 11:32:58 +00:00
if (allgenerics == NULL) {
1997-01-03 22:17:11 +00:00
allgenerics = PyList_New(0);
1991-08-07 11:32:58 +00:00
if (allgenerics == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_Clear();
return; /* Too bad, live without allgenerics... */
}
}
if (nfreeslots > 0) {
/* Search the list for reusable slots (NULL items) */
/* XXX This can be made faster! */
1997-01-03 22:17:11 +00:00
n = PyList_Size(allgenerics);
for (i = 0; i < n; i++) {
1997-01-03 22:17:11 +00:00
if (PyList_GetItem(allgenerics, i) == NULL) {
Py_INCREF(g);
PyList_SetItem(allgenerics, i, (PyObject *)g);
nfreeslots--;
return;
}
1991-08-07 11:32:58 +00:00
}
/* Strange... no free slots found... */
nfreeslots = 0;
1991-08-07 11:32:58 +00:00
}
/* No free entries, append new item to the end */
1997-01-03 22:17:11 +00:00
PyList_Append(allgenerics, (PyObject *)g);
1991-08-07 11:32:58 +00:00
}
/* Find an object in the list of known objects */
1991-08-07 11:32:58 +00:00
static genericobject *
findgeneric(generic)
FL_OBJECT *generic;
{
int i, n;
genericobject *g;
if (allgenerics == NULL)
return NULL; /* No objects known yet */
1997-01-03 22:17:11 +00:00
n = PyList_Size(allgenerics);
1991-08-07 11:32:58 +00:00
for (i = 0; i < n; i++) {
1997-01-03 22:17:11 +00:00
g = (genericobject *)PyList_GetItem(allgenerics, i);
if (g != NULL && g->ob_generic == generic)
1991-08-07 11:32:58 +00:00
return g;
}
return NULL; /* Unknown object */
}
/* Remove an object from the list of known objects */
static void
forgetgeneric(g)
genericobject *g;
{
int i, n;
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback);
g->ob_callback = NULL;
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback_arg);
g->ob_callback_arg = NULL;
if (allgenerics == NULL)
return; /* No objects known yet */
1997-01-03 22:17:11 +00:00
n = PyList_Size(allgenerics);
for (i = 0; i < n; i++) {
1997-01-03 22:17:11 +00:00
if (g == (genericobject *)PyList_GetItem(allgenerics, i)) {
PyList_SetItem(allgenerics, i, (PyObject *)NULL);
nfreeslots++;
break;
}
}
}
/* Called when a form is about to be freed --
remove all the objects that we know about from it. */
static void
releaseobjects(form)
FL_FORM *form;
{
int i, n;
genericobject *g;
if (allgenerics == NULL)
return; /* No objects known yet */
1997-01-03 22:17:11 +00:00
n = PyList_Size(allgenerics);
for (i = 0; i < n; i++) {
1997-01-03 22:17:11 +00:00
g = (genericobject *)PyList_GetItem(allgenerics, i);
if (g != NULL && g->ob_generic->form == form) {
fl_delete_object(g->ob_generic);
/* The object is now unreachable for
do_forms and check_forms, so
delete it from the list of known objects */
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback);
g->ob_callback = NULL;
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback_arg);
g->ob_callback_arg = NULL;
1997-01-03 22:17:11 +00:00
PyList_SetItem(allgenerics, i, (PyObject *)NULL);
nfreeslots++;
}
}
}
1991-08-07 11:32:58 +00:00
/* Methods of generic objects */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_set_call_back(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
if (args == NULL) {
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
1991-08-07 11:32:58 +00:00
g->ob_callback = NULL;
g->ob_callback_arg = NULL;
}
else {
1997-01-03 22:17:11 +00:00
if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) {
PyErr_BadArgument();
1991-08-07 11:32:58 +00:00
return NULL;
}
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
g->ob_callback = PyTuple_GetItem(args, 0);
Py_INCREF(g->ob_callback);
g->ob_callback_arg = PyTuple_GetItem(args, 1);
Py_INCREF(g->ob_callback_arg);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_call(g, args, func)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
void (*func)(FL_OBJECT *);
{
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args))
1991-08-07 11:32:58 +00:00
return NULL;
(*func)(g->ob_generic);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
generic_delete_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
1997-01-03 22:17:11 +00:00
PyObject *res;
res = generic_call(g, args, fl_delete_object);
if (res != NULL)
forgetgeneric(g);
return res;
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_show_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call(g, args, fl_show_object);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_hide_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call(g, args, fl_hide_object);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_redraw_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call(g, args, fl_redraw_object);
}
1997-01-03 22:17:11 +00:00
#ifdef OBSOLETE_FORMS_CALLS
/* (un)freeze_object() are obsolete in FORMS 2.2 and unsupported
in 2.3. Since there's no foolproof way to tell which version we're
using, we omit them unconditionally. */
static PyObject *
1991-08-07 11:32:58 +00:00
generic_freeze_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call(g, args, fl_freeze_object);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_unfreeze_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call(g, args, fl_unfreeze_object);
}
1997-01-03 22:17:11 +00:00
#endif /* OBSOLETE_FORMS_CALLS */
static PyObject *
generic_activate_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return generic_call(g, args, fl_activate_object);
}
1997-01-03 22:17:11 +00:00
static PyObject *
generic_deactivate_object(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return generic_call(g, args, fl_deactivate_object);
}
1997-01-03 22:17:11 +00:00
static PyObject *
generic_set_object_shortcut(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
char *str;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "s", &str))
return NULL;
fl_set_object_shortcut(g->ob_generic, str);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef generic_methods[] = {
{"set_call_back", (PyCFunction)generic_set_call_back},
{"delete_object", (PyCFunction)generic_delete_object},
{"show_object", (PyCFunction)generic_show_object},
{"hide_object", (PyCFunction)generic_hide_object},
{"redraw_object", (PyCFunction)generic_redraw_object},
#ifdef OBSOLETE_FORMS_CALLS
{"freeze_object", (PyCFunction)generic_freeze_object},
{"unfreeze_object", (PyCFunction)generic_unfreeze_object},
#endif
{"activate_object", (PyCFunction)generic_activate_object},
{"deactivate_object", (PyCFunction)generic_deactivate_object},
{"set_object_shortcut", (PyCFunction)generic_set_object_shortcut},
{NULL, NULL} /* sentinel */
1991-08-07 11:32:58 +00:00
};
static void
generic_dealloc(g)
genericobject *g;
{
fl_free_object(g->ob_generic);
1997-01-03 22:17:11 +00:00
Py_XDECREF(g->ob_callback);
Py_XDECREF(g->ob_callback_arg);
PyMem_DEL(g);
1991-08-07 11:32:58 +00:00
}
#define OFF(x) offsetof(FL_OBJECT, x)
static struct memberlist generic_memberlist[] = {
{"objclass", T_INT, OFF(objclass), RO},
{"type", T_INT, OFF(type), RO},
{"boxtype", T_INT, OFF(boxtype)},
{"x", T_FLOAT, OFF(x)},
{"y", T_FLOAT, OFF(y)},
{"w", T_FLOAT, OFF(w)},
{"h", T_FLOAT, OFF(h)},
{"col1", T_INT, OFF(col1)},
{"col2", T_INT, OFF(col2)},
{"align", T_INT, OFF(align)},
{"lcol", T_INT, OFF(lcol)},
{"lsize", T_FLOAT, OFF(lsize)},
/* "label" is treated specially! */
{"lstyle", T_INT, OFF(lstyle)},
{"pushed", T_INT, OFF(pushed), RO},
{"focus", T_INT, OFF(focus), RO},
{"belowmouse", T_INT, OFF(belowmouse),RO},
/* {"frozen", T_INT, OFF(frozen), RO}, */
{"active", T_INT, OFF(active)},
{"input", T_INT, OFF(input)},
1991-08-07 11:32:58 +00:00
{"visible", T_INT, OFF(visible), RO},
{"radio", T_INT, OFF(radio)},
{"automatic", T_INT, OFF(automatic)},
1991-08-07 11:32:58 +00:00
{NULL} /* Sentinel */
};
1991-11-19 20:26:28 +00:00
#undef OFF
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
generic_getattr(g, name)
genericobject *g;
char *name;
{
1997-01-03 22:17:11 +00:00
PyObject *meth;
/* XXX Ought to special-case name "__methods__" */
1991-08-07 11:32:58 +00:00
if (g-> ob_methods) {
1997-01-03 22:17:11 +00:00
meth = Py_FindMethod(g->ob_methods, (PyObject *)g, name);
if (meth != NULL) return meth;
1997-01-03 22:17:11 +00:00
PyErr_Clear();
}
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
meth = Py_FindMethod(generic_methods, (PyObject *)g, name);
1991-08-07 11:32:58 +00:00
if (meth != NULL)
return meth;
1997-01-03 22:17:11 +00:00
PyErr_Clear();
1991-08-07 11:32:58 +00:00
/* "label" is an exception, getmember only works for char pointers,
not for char arrays */
if (strcmp(name, "label") == 0)
1997-01-03 22:17:11 +00:00
return PyString_FromString(g->ob_generic->label);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
return PyMember_Get((char *)g->ob_generic, generic_memberlist, name);
1991-08-07 11:32:58 +00:00
}
static int
generic_setattr(g, name, v)
genericobject *g;
char *name;
1997-01-03 22:17:11 +00:00
PyObject *v;
1991-08-07 11:32:58 +00:00
{
int ret;
if (v == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_SetString(PyExc_TypeError,
"can't delete forms object attributes");
return -1;
1991-08-07 11:32:58 +00:00
}
/* "label" is an exception: setmember doesn't set strings;
and FORMS wants you to call a function to set the label */
if (strcmp(name, "label") == 0) {
1997-01-03 22:17:11 +00:00
if (!PyString_Check(v)) {
PyErr_SetString(PyExc_TypeError,
"label attr must be string");
return -1;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
fl_set_object_label(g->ob_generic, PyString_AsString(v));
1991-08-07 11:32:58 +00:00
return 0;
}
1997-01-03 22:17:11 +00:00
ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v);
1991-08-07 11:32:58 +00:00
/* Rather than calling all the various set_object_* functions,
we call fl_redraw_object here. This is sometimes redundant
but I doubt that's a big problem */
if (ret == 0)
fl_redraw_object(g->ob_generic);
return ret;
}
1997-01-03 22:17:11 +00:00
static PyObject *
generic_repr(g)
genericobject *g;
{
char buf[100];
sprintf(buf, "<FORMS_object at %lx, objclass=%d>",
(long)g, g->ob_generic->objclass);
1997-01-03 22:17:11 +00:00
return PyString_FromString(buf);
}
1997-01-03 22:17:11 +00:00
static PyTypeObject GenericObjecttype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"FORMS_object", /*tp_name*/
sizeof(genericobject), /*tp_size*/
0, /*tp_itemsize*/
1991-08-07 11:32:58 +00:00
/* methods */
(destructor)generic_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc)generic_getattr, /*tp_getattr*/
(setattrfunc)generic_setattr, /*tp_setattr*/
0, /*tp_compare*/
(reprfunc)generic_repr, /*tp_repr*/
1991-08-07 11:32:58 +00:00
};
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
newgenericobject(generic, methods)
FL_OBJECT *generic;
1997-01-03 22:17:11 +00:00
PyMethodDef *methods;
1991-08-07 11:32:58 +00:00
{
genericobject *g;
1997-01-03 22:17:11 +00:00
g = PyObject_NEW(genericobject, &GenericObjecttype);
1991-08-07 11:32:58 +00:00
if (g == NULL)
return NULL;
g-> ob_generic = generic;
g->ob_methods = methods;
g->ob_callback = NULL;
g->ob_callback_arg = NULL;
knowgeneric(g);
1997-01-03 22:17:11 +00:00
return (PyObject *)g;
1991-08-07 11:32:58 +00:00
}
/**********************************************************************/
/* Some common calling sequences */
/* void func (object, float) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INf (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, float);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
float parameter;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "f", &parameter)) return NULL;
1991-08-07 11:32:58 +00:00
(*func) (obj, parameter);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
/* void func (object, float) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INfINf (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, float, float);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
float par1, par2;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ff)", &par1, &par2)) return NULL;
1991-08-07 11:32:58 +00:00
(*func) (obj, par1, par2);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
/* void func (object, int) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INi (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, int);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int parameter;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &parameter)) return NULL;
1991-08-07 11:32:58 +00:00
(*func) (obj, parameter);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1991-12-10 13:56:42 +00:00
/* void func (object, char) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
call_forms_INc (func, obj, args)
void (*func)(FL_OBJECT *, int);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
1992-01-27 16:45:55 +00:00
char *a;
1991-12-10 13:56:42 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "s", &a)) return NULL;
1991-12-10 13:56:42 +00:00
1992-01-27 16:45:55 +00:00
(*func) (obj, a[0]);
1991-12-10 13:56:42 +00:00
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-12-10 13:56:42 +00:00
}
1991-08-07 11:32:58 +00:00
/* void func (object, string) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INstr (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, char *);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
1992-01-27 16:45:55 +00:00
char *a;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "s", &a)) return NULL;
1991-08-07 11:32:58 +00:00
1992-01-27 16:45:55 +00:00
(*func) (obj, a);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
/* void func (object, int, string) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INiINstr (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, int, char *);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1992-01-27 16:45:55 +00:00
char *b;
int a;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(is)", &a, &b)) return NULL;
1992-01-27 16:45:55 +00:00
(*func) (obj, a, b);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
#ifdef UNUSED
/* void func (object, int, int) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_INiINi (func, obj, args)
void (*func)(FL_OBJECT *, int, int);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int par1, par2;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ii)", &par1, &par2)) return NULL;
(*func) (obj, par1, par2);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
#endif
1991-08-07 11:32:58 +00:00
/* int func (object) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_Ri (func, obj, args)
int (*func)(FL_OBJECT *);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int retval;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
retval = (*func) (obj);
1997-01-03 22:17:11 +00:00
return PyInt_FromLong ((long) retval);
1991-08-07 11:32:58 +00:00
}
/* char * func (object) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_Rstr (func, obj, args)
char * (*func)(FL_OBJECT *);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
char *str;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
str = (*func) (obj);
if (str == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
return PyString_FromString (str);
1991-08-07 11:32:58 +00:00
}
/* int func (object) */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_Rf (func, obj, args)
float (*func)(FL_OBJECT *);
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
float retval;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
retval = (*func) (obj);
1997-01-03 22:17:11 +00:00
return PyFloat_FromDouble (retval);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_OUTfOUTf (func, obj, args)
1991-08-08 12:34:44 +00:00
void (*func)(FL_OBJECT *, float *, float *);
1991-08-07 11:32:58 +00:00
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
float f1, f2;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
1991-08-07 11:32:58 +00:00
(*func) (obj, &f1, &f2);
1997-01-03 22:17:11 +00:00
return Py_BuildValue("(ff)", f1, f2);
1991-08-07 11:32:58 +00:00
}
#ifdef UNUSED
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
call_forms_OUTf (func, obj, args)
void (*func)(FL_OBJECT *, float *);
1991-08-07 11:32:58 +00:00
FL_OBJECT *obj;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
float f;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
1991-08-07 11:32:58 +00:00
(*func) (obj, &f);
1997-01-03 22:17:11 +00:00
return PyFloat_FromDouble (f);
1991-08-07 11:32:58 +00:00
}
#endif
1991-08-07 11:32:58 +00:00
/**********************************************************************/
/* Class : browser */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_browser_topline(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_browser_topline, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
clear_browser(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call (g, args, fl_clear_browser);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
add_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INstr (fl_add_browser_line, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
addto_browser (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INstr (fl_addto_browser, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
insert_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INiINstr (fl_insert_browser_line,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
delete_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_delete_browser_line, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
replace_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INiINstr (fl_replace_browser_line,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_browser_line(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int i;
char *str;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &i))
1991-08-07 11:32:58 +00:00
return NULL;
str = fl_get_browser_line (g->ob_generic, i);
if (str == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
return PyString_FromString (str);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
load_browser (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1991-08-08 12:34:44 +00:00
/* XXX strictly speaking this is wrong since fl_load_browser
XXX returns int, not void */
return call_forms_INstr (fl_load_browser, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_browser_maxline(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
select_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_select_browser_line, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
deselect_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_deselect_browser_line, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
deselect_browser (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call (g, args, fl_deselect_browser);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
isselected_browser_line (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int i, j;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &i))
1991-08-07 11:32:58 +00:00
return NULL;
1991-08-07 11:32:58 +00:00
j = fl_isselected_browser_line (g->ob_generic, i);
1997-01-03 22:17:11 +00:00
return PyInt_FromLong (j);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_browser (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Ri (fl_get_browser, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_browser_fontsize (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_browser_fontsize, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_browser_fontstyle (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_browser_fontstyle, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
set_browser_specialkey (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
return call_forms_INc(fl_set_browser_specialkey, g-> ob_generic, args);
}
1997-01-03 22:17:11 +00:00
static PyMethodDef browser_methods[] = {
{"set_browser_topline", (PyCFunction)set_browser_topline},
{"clear_browser", (PyCFunction)clear_browser},
{"add_browser_line", (PyCFunction)add_browser_line},
{"addto_browser", (PyCFunction)addto_browser},
{"insert_browser_line", (PyCFunction)insert_browser_line},
{"delete_browser_line", (PyCFunction)delete_browser_line},
{"replace_browser_line", (PyCFunction)replace_browser_line},
{"get_browser_line", (PyCFunction)get_browser_line},
{"load_browser", (PyCFunction)load_browser},
{"get_browser_maxline", (PyCFunction)get_browser_maxline},
{"select_browser_line", (PyCFunction)select_browser_line},
{"deselect_browser_line", (PyCFunction)deselect_browser_line},
{"deselect_browser", (PyCFunction)deselect_browser},
{"isselected_browser_line", (PyCFunction)isselected_browser_line},
{"get_browser", (PyCFunction)get_browser},
{"set_browser_fontsize", (PyCFunction)set_browser_fontsize},
{"set_browser_fontstyle", (PyCFunction)set_browser_fontstyle},
{"set_browser_specialkey", (PyCFunction)set_browser_specialkey},
1991-12-10 13:56:42 +00:00
{NULL, NULL} /* sentinel */
1991-08-07 11:32:58 +00:00
};
/* Class: button */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_button(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_button, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_button(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Ri (fl_get_button, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
get_button_numb(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return call_forms_Ri (fl_get_button_numb, g-> ob_generic, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
set_button_shortcut(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
return call_forms_INstr (fl_set_button_shortcut, g-> ob_generic, args);
}
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
static PyMethodDef button_methods[] = {
{"set_button", (PyCFunction)set_button},
{"get_button", (PyCFunction)get_button},
{"get_button_numb", (PyCFunction)get_button_numb},
{"set_button_shortcut", (PyCFunction)set_button_shortcut},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class: choice */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_choice(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_choice, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_choice(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Ri (fl_get_choice, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
clear_choice (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_call (g, args, fl_clear_choice);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
addto_choice (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return call_forms_INstr (fl_addto_choice, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
replace_choice (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
delete_choice (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_delete_choice, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_choice_text (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return call_forms_Rstr (fl_get_choice_text, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_choice_fontsize (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_choice_fontsize, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_choice_fontstyle (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_choice_fontstyle, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef choice_methods[] = {
{"set_choice", (PyCFunction)set_choice},
{"get_choice", (PyCFunction)get_choice},
{"clear_choice", (PyCFunction)clear_choice},
{"addto_choice", (PyCFunction)addto_choice},
{"replace_choice", (PyCFunction)replace_choice},
{"delete_choice", (PyCFunction)delete_choice},
{"get_choice_text", (PyCFunction)get_choice_text},
{"set_choice_fontsize", (PyCFunction)set_choice_fontsize},
{"set_choice_fontstyle",(PyCFunction)set_choice_fontstyle},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class : Clock */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_clock(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int i0, i1, i2;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args))
1991-08-07 11:32:58 +00:00
return NULL;
fl_get_clock (g->ob_generic, &i0, &i1, &i2);
1997-01-03 22:17:11 +00:00
return Py_BuildValue("(iii)", i0, i1, i2);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef clock_methods[] = {
{"get_clock", (PyCFunction)get_clock},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* CLass : Counters */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_counter_value(g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_counter_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_counter_value (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_counter_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_counter_precision (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_counter_precision, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_counter_bounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_counter_bounds, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_counter_step (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_counter_step, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_counter_return (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_counter_return, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef counter_methods[] = {
{"set_counter_value", (PyCFunction)set_counter_value},
{"get_counter_value", (PyCFunction)get_counter_value},
{"set_counter_bounds", (PyCFunction)set_counter_bounds},
{"set_counter_step", (PyCFunction)set_counter_step},
{"set_counter_precision", (PyCFunction)set_counter_precision},
{"set_counter_return", (PyCFunction)set_counter_return},
1991-12-10 13:56:42 +00:00
{NULL, NULL} /* sentinel */
1991-08-07 11:32:58 +00:00
};
/* Class: Dials */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
get_dial_value(g, args)
1991-08-07 11:32:58 +00:00
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_dial_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_dial_value (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_dial_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_dial_bounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_dial_bounds, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_dial_bounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
set_dial_step (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
return call_forms_INf (fl_set_dial_step, g-> ob_generic, args);
1991-12-10 13:56:42 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef dial_methods[] = {
{"set_dial_value", (PyCFunction)set_dial_value},
{"get_dial_value", (PyCFunction)get_dial_value},
{"set_dial_bounds", (PyCFunction)set_dial_bounds},
{"get_dial_bounds", (PyCFunction)get_dial_bounds},
{"set_dial_step", (PyCFunction)set_dial_step},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class : Input */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_input (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INstr (fl_set_input, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_input (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rstr (fl_get_input, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_input_color (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
set_input_return (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
return call_forms_INi (fl_set_input_return, g-> ob_generic, args);
1991-12-10 13:56:42 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef input_methods[] = {
{"set_input", (PyCFunction)set_input},
{"get_input", (PyCFunction)get_input},
{"set_input_color", (PyCFunction)set_input_color},
{"set_input_return", (PyCFunction)set_input_return},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class : Menu */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_menu (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1991-08-08 12:34:44 +00:00
return call_forms_INstr (fl_set_menu, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_menu (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1991-08-08 12:34:44 +00:00
/* XXX strictly speaking this is wrong since fl_get_menu
XXX returns long, not int */
return call_forms_Ri (fl_get_menu, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
get_menu_text (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return call_forms_Rstr (fl_get_menu_text, g-> ob_generic, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
addto_menu (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1991-08-08 12:34:44 +00:00
return call_forms_INstr (fl_addto_menu, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef menu_methods[] = {
{"set_menu", (PyCFunction)set_menu},
{"get_menu", (PyCFunction)get_menu},
{"get_menu_text", (PyCFunction)get_menu_text},
{"addto_menu", (PyCFunction)addto_menu},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class: Sliders */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
get_slider_value(g, args)
1991-08-07 11:32:58 +00:00
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_slider_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_slider_value (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_slider_value, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_slider_bounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_slider_bounds, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_slider_bounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_slider_return (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_slider_return, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_slider_size (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_slider_size, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_slider_precision (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
set_slider_step (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-12-10 13:56:42 +00:00
{
return call_forms_INf (fl_set_slider_step, g-> ob_generic, args);
1991-12-10 13:56:42 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef slider_methods[] = {
{"set_slider_value", (PyCFunction)set_slider_value},
{"get_slider_value", (PyCFunction)get_slider_value},
{"set_slider_bounds", (PyCFunction)set_slider_bounds},
{"get_slider_bounds", (PyCFunction)get_slider_bounds},
{"set_slider_return", (PyCFunction)set_slider_return},
{"set_slider_size", (PyCFunction)set_slider_size},
{"set_slider_precision",(PyCFunction)set_slider_precision},
{"set_slider_step", (PyCFunction)set_slider_step},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_positioner_xvalue (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_positioner_xbounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_positioner_xbounds,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_positioner_yvalue (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_positioner_ybounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INfINf (fl_set_positioner_ybounds,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_positioner_xvalue (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_positioner_xbounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_OUTfOUTf (fl_get_positioner_xbounds,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_positioner_yvalue (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_positioner_ybounds (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_OUTfOUTf (fl_get_positioner_ybounds,
g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef positioner_methods[] = {
{"set_positioner_xvalue", (PyCFunction)set_positioner_xvalue},
{"set_positioner_yvalue", (PyCFunction)set_positioner_yvalue},
{"set_positioner_xbounds", (PyCFunction)set_positioner_xbounds},
{"set_positioner_ybounds", (PyCFunction)set_positioner_ybounds},
{"get_positioner_xvalue", (PyCFunction)get_positioner_xvalue},
{"get_positioner_yvalue", (PyCFunction)get_positioner_yvalue},
{"get_positioner_xbounds", (PyCFunction)get_positioner_xbounds},
{"get_positioner_ybounds", (PyCFunction)get_positioner_ybounds},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Class timer */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
set_timer (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_INf (fl_set_timer, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
get_timer (g, args)
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return call_forms_Rf (fl_get_timer, g-> ob_generic, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyMethodDef timer_methods[] = {
{"set_timer", (PyCFunction)set_timer},
{"get_timer", (PyCFunction)get_timer},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
/* Form objects */
typedef struct {
1997-01-03 22:17:11 +00:00
PyObject_HEAD
1991-08-07 11:32:58 +00:00
FL_FORM *ob_form;
} formobject;
1997-01-03 22:17:11 +00:00
staticforward PyTypeObject Formtype;
1991-08-07 11:32:58 +00:00
#define is_formobject(v) ((v)->ob_type == &Formtype)
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_show_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int place, border;
1992-01-27 16:45:55 +00:00
char *name;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(iis)", &place, &border, &name))
1991-08-07 11:32:58 +00:00
return NULL;
1992-01-27 16:45:55 +00:00
fl_show_form(f->ob_form, place, border, name);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_call(func, f, args)
FL_FORM *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
void (*func)(FL_FORM *);
{
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
1991-08-07 11:32:58 +00:00
(*func)(f);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_call_INiINi(func, f, args)
1991-08-07 11:32:58 +00:00
FL_FORM *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
void (*func)(FL_FORM *, int, int);
{
int a, b;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL;
1991-08-07 11:32:58 +00:00
(*func)(f, a, b);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_call_INfINf(func, f, args)
FL_FORM *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
void (*func)(FL_FORM *, float, float);
{
float a, b;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL;
(*func)(f, a, b);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_hide_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return form_call(fl_hide_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_redraw_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return form_call(fl_redraw_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_set_form_position(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return form_call_INiINi(fl_set_form_position, f-> ob_form, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_set_form_size(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return form_call_INiINi(fl_set_form_size, f-> ob_form, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_scale_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return form_call_INfINf(fl_scale_form, f-> ob_form, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
generic_add_object(f, args, func, internal_methods)
1991-08-07 11:32:58 +00:00
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
FL_OBJECT *(*func)(int, float, float, float, float, char*);
1997-01-03 22:17:11 +00:00
PyMethodDef *internal_methods;
1991-08-07 11:32:58 +00:00
{
int type;
float x, y, w, h;
1992-01-27 16:45:55 +00:00
char *name;
FL_OBJECT *obj;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name))
return NULL;
fl_addto_form (f-> ob_form);
1992-01-27 16:45:55 +00:00
obj = (*func) (type, x, y, w, h, name);
1991-08-07 11:32:58 +00:00
fl_end_form();
1991-08-07 11:32:58 +00:00
if (obj == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_NoMemory();
return NULL;
}
1991-08-07 11:32:58 +00:00
return newgenericobject (obj, internal_methods);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_button(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_button, button_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_lightbutton(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_lightbutton, button_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_roundbutton(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_roundbutton, button_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_menu (f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_menu, menu_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_slider(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_slider, slider_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_add_valslider(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_valslider, slider_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_dial(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_dial, dial_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_counter(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_counter, counter_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_clock(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_clock, clock_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_box(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_box,
1997-01-03 22:17:11 +00:00
(PyMethodDef *)NULL);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_choice(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_choice, choice_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_browser(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_browser, browser_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_positioner(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1997-01-03 22:17:11 +00:00
return generic_add_object(f, args, fl_add_positioner,
positioner_methods);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_input(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_input, input_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_text(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_text,
1997-01-03 22:17:11 +00:00
(PyMethodDef *)NULL);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_add_timer(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return generic_add_object(f, args, fl_add_timer, timer_methods);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_freeze_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return form_call(fl_freeze_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_unfreeze_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return form_call(fl_unfreeze_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_activate_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return form_call(fl_activate_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_deactivate_form(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return form_call(fl_deactivate_form, f-> ob_form, args);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_bgn_group(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
FL_OBJECT *obj;
fl_addto_form(f-> ob_form);
obj = fl_bgn_group();
fl_end_form();
if (obj == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_NoMemory();
return NULL;
}
1997-01-03 22:17:11 +00:00
return newgenericobject (obj, (PyMethodDef *) NULL);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_end_group(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
fl_addto_form(f-> ob_form);
fl_end_group();
fl_end_form();
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_find_first_or_last(func, f, args)
FL_OBJECT *(*func)(FL_FORM *, int, float, float);
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
int type;
float mx, my;
FL_OBJECT *generic;
genericobject *g;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL;
generic = (*func) (f-> ob_form, type, mx, my);
if (generic == NULL)
{
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
g = findgeneric(generic);
if (g == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_SetString(PyExc_RuntimeError,
"forms_find_{first|last} returns unknown object");
return NULL;
}
1997-01-03 22:17:11 +00:00
Py_INCREF(g);
return (PyObject *) g;
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_find_first(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return forms_find_first_or_last(fl_find_first, f, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_find_last(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
return forms_find_first_or_last(fl_find_last, f, args);
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_set_object_focus(f, args)
formobject *f;
1997-01-03 22:17:11 +00:00
PyObject *args;
{
genericobject *g;
if (args == NULL || !is_genericobject(args)) {
1997-01-03 22:17:11 +00:00
PyErr_BadArgument();
return NULL;
}
g = (genericobject *)args;
fl_set_object_focus(f->ob_form, g->ob_generic);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyMethodDef form_methods[] = {
1991-08-07 11:32:58 +00:00
/* adm */
1997-01-03 22:17:11 +00:00
{"show_form", (PyCFunction)form_show_form},
{"hide_form", (PyCFunction)form_hide_form},
{"redraw_form", (PyCFunction)form_redraw_form},
{"set_form_position", (PyCFunction)form_set_form_position},
{"set_form_size", (PyCFunction)form_set_form_size},
{"scale_form", (PyCFunction)form_scale_form},
{"freeze_form", (PyCFunction)form_freeze_form},
{"unfreeze_form", (PyCFunction)form_unfreeze_form},
{"activate_form", (PyCFunction)form_activate_form},
{"deactivate_form", (PyCFunction)form_deactivate_form},
{"bgn_group", (PyCFunction)form_bgn_group},
{"end_group", (PyCFunction)form_end_group},
{"find_first", (PyCFunction)form_find_first},
{"find_last", (PyCFunction)form_find_last},
{"set_object_focus", (PyCFunction)form_set_object_focus},
1991-08-07 11:32:58 +00:00
/* basic objects */
1997-01-03 22:17:11 +00:00
{"add_button", (PyCFunction)form_add_button},
/* {"add_bitmap", (method)form_add_bitmap}, */
1997-01-03 22:17:11 +00:00
{"add_lightbutton", (PyCFunction)form_add_lightbutton},
{"add_roundbutton", (PyCFunction)form_add_roundbutton},
{"add_menu", (PyCFunction)form_add_menu},
{"add_slider", (PyCFunction)form_add_slider},
{"add_positioner", (PyCFunction)form_add_positioner},
{"add_valslider", (PyCFunction)form_add_valslider},
{"add_dial", (PyCFunction)form_add_dial},
{"add_counter", (PyCFunction)form_add_counter},
{"add_box", (PyCFunction)form_add_box},
{"add_clock", (PyCFunction)form_add_clock},
{"add_choice", (PyCFunction)form_add_choice},
{"add_browser", (PyCFunction)form_add_browser},
{"add_input", (PyCFunction)form_add_input},
{"add_timer", (PyCFunction)form_add_timer},
{"add_text", (PyCFunction)form_add_text},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
static void
form_dealloc(f)
formobject *f;
{
releaseobjects(f->ob_form);
if (f->ob_form->visible)
fl_hide_form(f->ob_form);
fl_free_form(f->ob_form);
1997-01-03 22:17:11 +00:00
PyMem_DEL(f);
1991-08-07 11:32:58 +00:00
}
1991-11-19 20:26:28 +00:00
#define OFF(x) offsetof(FL_FORM, x)
1991-11-12 15:43:18 +00:00
static struct memberlist form_memberlist[] = {
{"window", T_LONG, OFF(window), RO},
{"w", T_FLOAT, OFF(w)},
{"h", T_FLOAT, OFF(h)},
{"x", T_FLOAT, OFF(x), RO},
{"y", T_FLOAT, OFF(y), RO},
1991-11-12 15:43:18 +00:00
{"deactivated", T_INT, OFF(deactivated)},
{"visible", T_INT, OFF(visible), RO},
{"frozen", T_INT, OFF(frozen), RO},
1991-11-12 15:43:18 +00:00
{"doublebuf", T_INT, OFF(doublebuf)},
{NULL} /* Sentinel */
};
1991-11-19 20:26:28 +00:00
#undef OFF
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
form_getattr(f, name)
formobject *f;
char *name;
{
1997-01-03 22:17:11 +00:00
PyObject *meth;
1991-11-12 15:43:18 +00:00
1997-01-03 22:17:11 +00:00
meth = Py_FindMethod(form_methods, (PyObject *)f, name);
1991-11-12 15:43:18 +00:00
if (meth != NULL)
return meth;
1997-01-03 22:17:11 +00:00
PyErr_Clear();
return PyMember_Get((char *)f->ob_form, form_memberlist, name);
1991-11-12 15:43:18 +00:00
}
static int
form_setattr(f, name, v)
formobject *f;
char *name;
1997-01-03 22:17:11 +00:00
PyObject *v;
1991-11-12 15:43:18 +00:00
{
if (v == NULL) {
1997-01-03 22:17:11 +00:00
PyErr_SetString(PyExc_TypeError,
"can't delete form attributes");
return -1;
1991-11-12 15:43:18 +00:00
}
1997-01-03 22:17:11 +00:00
return PyMember_Set((char *)f->ob_form, form_memberlist, name, v);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
form_repr(f)
formobject *f;
{
char buf[100];
sprintf(buf, "<FORMS_form at %lx, window=%ld>",
(long)f, f->ob_form->window);
1997-01-03 22:17:11 +00:00
return PyString_FromString(buf);
}
1997-01-03 22:17:11 +00:00
static PyTypeObject Formtype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
"FORMS_form", /*tp_name*/
sizeof(formobject), /*tp_size*/
0, /*tp_itemsize*/
1991-08-07 11:32:58 +00:00
/* methods */
(destructor)form_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc)form_getattr, /*tp_getattr*/
(setattrfunc)form_setattr, /*tp_setattr*/
0, /*tp_compare*/
(reprfunc)form_repr, /*tp_repr*/
1991-08-07 11:32:58 +00:00
};
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
newformobject(form)
FL_FORM *form;
{
formobject *f;
1997-01-03 22:17:11 +00:00
f = PyObject_NEW(formobject, &Formtype);
1991-08-07 11:32:58 +00:00
if (f == NULL)
return NULL;
f->ob_form = form;
1997-01-03 22:17:11 +00:00
return (PyObject *)f;
1991-08-07 11:32:58 +00:00
}
1991-08-07 11:32:58 +00:00
/* The "fl" module */
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_make_form(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int type;
float w, h;
FL_FORM *form;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(iff)", &type, &w, &h))
1991-08-07 11:32:58 +00:00
return NULL;
form = fl_bgn_form(type, w, h);
if (form == NULL) {
/* XXX Actually, cannot happen! */
1997-01-03 22:17:11 +00:00
PyErr_NoMemory();
1991-08-07 11:32:58 +00:00
return NULL;
}
fl_end_form();
return newformobject(form);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_activate_all_forms(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
fl_activate_all_forms();
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_deactivate_all_forms(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
fl_deactivate_all_forms();
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *my_event_callback = NULL;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_set_event_call_back(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1997-01-03 22:17:11 +00:00
if (args == Py_None)
args = NULL;
1991-08-07 11:32:58 +00:00
my_event_callback = args;
1997-01-03 22:17:11 +00:00
Py_XINCREF(args);
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_do_or_check_forms(dummy, args, func)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-08-07 11:32:58 +00:00
FL_OBJECT *(*func)();
{
FL_OBJECT *generic;
genericobject *g;
1997-01-03 22:17:11 +00:00
PyObject *arg, *res;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args))
1991-08-07 11:32:58 +00:00
return NULL;
for (;;) {
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
1991-08-07 11:32:58 +00:00
generic = (*func)();
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
1991-08-07 11:32:58 +00:00
if (generic == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
if (generic == FL_EVENT) {
int dev;
short val;
if (my_event_callback == NULL)
1997-01-03 22:17:11 +00:00
return PyInt_FromLong(-1L);
1991-08-07 11:32:58 +00:00
dev = fl_qread(&val);
1997-01-03 22:17:11 +00:00
arg = Py_BuildValue("(ih)", dev, val);
1991-08-07 11:32:58 +00:00
if (arg == NULL)
return NULL;
1997-01-03 22:17:11 +00:00
res = PyEval_CallObject(my_event_callback, arg);
Py_XDECREF(res);
Py_DECREF(arg);
1991-08-07 11:32:58 +00:00
if (res == NULL)
return NULL; /* Callback raised exception */
continue;
}
g = findgeneric(generic);
if (g == NULL) {
/* Object not known to us (some dialogs cause this) */
continue; /* Ignore it */
1991-08-07 11:32:58 +00:00
}
if (g->ob_callback == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(g);
return ((PyObject *) g);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
arg = Py_BuildValue("(OO)", (PyObject *)g, g->ob_callback_arg);
if (arg == NULL)
return NULL;
1997-01-03 22:17:11 +00:00
res = PyEval_CallObject(g->ob_callback, arg);
Py_XDECREF(res);
Py_DECREF(arg);
1991-08-07 11:32:58 +00:00
if (res == NULL)
return NULL; /* Callback raised exception */
}
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_do_forms(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return forms_do_or_check_forms(dummy, args, fl_do_forms);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_check_forms(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
return forms_do_or_check_forms(dummy, args, fl_check_forms);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_do_only_forms(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
{
return forms_do_or_check_forms(dummy, args, fl_do_only_forms);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_check_only_forms(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
{
return forms_do_or_check_forms(dummy, args, fl_check_only_forms);
}
#ifdef UNUSED
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
fl_call(func, args)
1997-01-03 22:17:11 +00:00
PyObject *args;
1991-08-07 11:32:58 +00:00
void (*func)();
{
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args))
1991-08-07 11:32:58 +00:00
return NULL;
(*func)();
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
#endif
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
forms_set_graphics_mode(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-12-10 13:56:42 +00:00
{
int rgbmode, doublebuf;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ii)", &rgbmode, &doublebuf))
1991-12-10 13:56:42 +00:00
return NULL;
fl_set_graphics_mode(rgbmode,doublebuf);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-12-10 13:56:42 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-12-10 13:56:42 +00:00
forms_get_rgbmode(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
1991-12-10 13:56:42 +00:00
{
extern int fl_rgbmode;
1991-12-10 13:56:42 +00:00
if (args != NULL) {
1997-01-03 22:17:11 +00:00
PyErr_BadArgument();
1991-12-10 13:56:42 +00:00
return NULL;
}
1997-01-03 22:17:11 +00:00
return PyInt_FromLong((long)fl_rgbmode);
1991-12-10 13:56:42 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_show_errors(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
{
int show;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &show))
return NULL;
fl_show_errors(show);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_set_font_name(dummy, args)
1997-01-03 22:17:11 +00:00
PyObject *dummy;
PyObject *args;
{
int numb;
char *name;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(is)", &numb, &name))
return NULL;
fl_set_font_name(numb, name);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1991-12-10 13:56:42 +00:00
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_qdevice(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
short arg1;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "h", &arg1))
1991-08-07 11:32:58 +00:00
return NULL;
fl_qdevice(arg1);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_unqdevice(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
short arg1;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "h", &arg1))
1991-08-07 11:32:58 +00:00
return NULL;
fl_unqdevice(arg1);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_isqueued(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
long retval;
short arg1;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "h", &arg1))
1991-08-07 11:32:58 +00:00
return NULL;
retval = fl_isqueued(arg1);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
return PyInt_FromLong(retval);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_qtest(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
long retval;
retval = fl_qtest();
1997-01-03 22:17:11 +00:00
return PyInt_FromLong(retval);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_qread(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int dev;
short val;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
dev = fl_qread(&val);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
return Py_BuildValue("(ih)", dev, val);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_qreset(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
1991-08-07 11:32:58 +00:00
fl_qreset();
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_qenter(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
short arg1, arg2;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(hh)", &arg1, &arg2))
1991-08-07 11:32:58 +00:00
return NULL;
fl_qenter(arg1, arg2);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_color(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int arg;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &arg)) return NULL;
1991-08-07 11:32:58 +00:00
fl_color((short) arg);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_mapcolor(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int arg0, arg1, arg2, arg3;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(iiii)", &arg0, &arg1, &arg2, &arg3))
return NULL;
1991-08-07 11:32:58 +00:00
fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_getmcolor(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
int arg;
short r, g, b;
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "i", &arg)) return NULL;
1991-08-07 11:32:58 +00:00
fl_getmcolor(arg, &r, &g, &b);
1991-08-07 11:32:58 +00:00
1997-01-03 22:17:11 +00:00
return Py_BuildValue("(hhh)", r, g, b);
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_get_mouse(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
{
float x, y;
1997-01-03 22:17:11 +00:00
if (!PyArg_NoArgs(args)) return NULL;
fl_get_mouse(&x, &y);
1997-01-03 22:17:11 +00:00
return Py_BuildValue("(ff)", x, y);
}
1997-01-03 22:17:11 +00:00
static PyObject *
1991-08-07 11:32:58 +00:00
forms_tie(self, args)
1997-01-03 22:17:11 +00:00
PyObject *self;
PyObject *args;
1991-08-07 11:32:58 +00:00
{
short arg1, arg2, arg3;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(hhh)", &arg1, &arg2, &arg3))
1991-08-07 11:32:58 +00:00
return NULL;
fl_tie(arg1, arg2, arg3);
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_show_message(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
1992-01-27 16:45:55 +00:00
char *a, *b, *c;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
1992-01-27 16:45:55 +00:00
fl_show_message(a, b, c);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_show_choice(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
char *m1, *m2, *m3, *b1, *b2, *b3;
int nb;
char *format;
long rv;
1997-01-03 22:17:11 +00:00
if (args == NULL || !PyTuple_Check(args)) {
PyErr_BadArgument();
return NULL;
}
1997-01-03 22:17:11 +00:00
nb = PyTuple_Size(args) - 3;
if (nb <= 0) {
1997-01-03 22:17:11 +00:00
PyErr_SetString(PyExc_TypeError,
"need at least one button label");
return NULL;
}
1997-01-03 22:17:11 +00:00
if (PyInt_Check(PyTuple_GetItem(args, 3))) {
PyErr_SetString(PyExc_TypeError,
"'number-of-buttons' argument not needed");
return NULL;
}
switch (nb) {
case 1: format = "(ssss)"; break;
case 2: format = "(sssss)"; break;
case 3: format = "(ssssss)"; break;
default:
1997-01-03 22:17:11 +00:00
PyErr_SetString(PyExc_TypeError, "too many button labels");
return NULL;
}
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, format, &m1, &m2, &m3, &b1, &b2, &b3))
return NULL;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
return PyInt_FromLong(rv);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_show_question(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
1992-01-27 16:45:55 +00:00
int ret;
char *a, *b, *c;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
1992-01-27 16:45:55 +00:00
ret = fl_show_question(a, b, c);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
1997-01-03 22:17:11 +00:00
return PyInt_FromLong((long) ret);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_show_input(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
char *str;
1992-01-27 16:45:55 +00:00
char *a, *b;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
1992-01-27 16:45:55 +00:00
str = fl_show_input(a, b);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
if (str == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
return PyString_FromString(str);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_file_selector(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
char *str;
1992-01-27 16:45:55 +00:00
char *a, *b, *c, *d;
1997-01-03 22:17:11 +00:00
if (!PyArg_Parse(args, "(ssss)", &a, &b, &c, &d)) return NULL;
1997-01-03 22:17:11 +00:00
Py_BEGIN_ALLOW_THREADS
1992-01-27 16:45:55 +00:00
str = fl_show_file_selector(a, b, c, d);
1997-01-03 22:17:11 +00:00
Py_END_ALLOW_THREADS
if (str == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
return PyString_FromString(str);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_file_selector_func(args, func)
1997-01-03 22:17:11 +00:00
PyObject *args;
char *(*func)();
{
char *str;
str = (*func) ();
if (str == NULL) {
1997-01-03 22:17:11 +00:00
Py_INCREF(Py_None);
return Py_None;
}
1997-01-03 22:17:11 +00:00
return PyString_FromString(str);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_get_directory(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
return forms_file_selector_func(args, fl_get_directory);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_get_pattern(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
return forms_file_selector_func(args, fl_get_pattern);
}
1997-01-03 22:17:11 +00:00
static PyObject *
forms_get_filename(f, args)
1997-01-03 22:17:11 +00:00
PyObject *f;
PyObject *args;
{
return forms_file_selector_func(args, fl_get_filename);
}
1997-01-03 22:17:11 +00:00
static PyMethodDef forms_methods[] = {
1991-08-07 11:32:58 +00:00
/* adm */
{"make_form", forms_make_form},
{"activate_all_forms", forms_activate_all_forms},
{"deactivate_all_forms",forms_deactivate_all_forms},
1991-08-07 11:32:58 +00:00
/* gl support wrappers */
{"qdevice", forms_qdevice},
{"unqdevice", forms_unqdevice},
{"isqueued", forms_isqueued},
{"qtest", forms_qtest},
{"qread", forms_qread},
/* {"blkqread", forms_blkqread}, */
1991-08-07 11:32:58 +00:00
{"qreset", forms_qreset},
{"qenter", forms_qenter},
{"get_mouse", forms_get_mouse},
{"tie", forms_tie},
1991-08-07 11:32:58 +00:00
/* {"new_events", forms_new_events}, */
{"color", forms_color},
1991-08-07 11:32:58 +00:00
{"mapcolor", forms_mapcolor},
{"getmcolor", forms_getmcolor},
/* interaction */
{"do_forms", forms_do_forms},
{"do_only_forms", forms_do_only_forms},
1991-08-07 11:32:58 +00:00
{"check_forms", forms_check_forms},
{"check_only_forms", forms_check_only_forms},
1991-08-07 11:32:58 +00:00
{"set_event_call_back", forms_set_event_call_back},
/* goodies */
{"show_message", forms_show_message},
{"show_question", forms_show_question},
{"show_choice", forms_show_choice},
{"show_input", forms_show_input},
{"show_file_selector", forms_file_selector},
{"file_selector", forms_file_selector}, /* BW compat */
{"get_directory", forms_get_directory},
{"get_pattern", forms_get_pattern},
{"get_filename", forms_get_filename},
1991-12-10 13:56:42 +00:00
{"set_graphics_mode", forms_set_graphics_mode},
{"get_rgbmode", forms_get_rgbmode},
{"show_errors", forms_show_errors},
{"set_font_name", forms_set_font_name},
1991-08-07 11:32:58 +00:00
{NULL, NULL} /* sentinel */
};
void
initfl()
{
1997-01-03 22:17:11 +00:00
Py_InitModule("fl", forms_methods);
foreground();
1991-12-10 13:56:42 +00:00
fl_init();
1991-08-07 11:32:58 +00:00
}
1997-01-03 22:17:11 +00:00