Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1 | /* FL module -- interface to Mark Overmars' FORMS Library. */ |
| 2 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 3 | /* This code works with FORMS version 2.2 (if you defined |
| 4 | OBSOLETE_FORMS_CALLS), and 2.3. |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 5 | FORMS can be ftp'ed from ftp.cs.ruu.nl (131.211.80.17), directory |
| 6 | /pub/SGI/FORMS. */ |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 7 | |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 8 | /* 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 Wouters | 7e47402 | 2000-07-16 12:04:32 +0000 | [diff] [blame] | 15 | * (A fix will probably also have to synchronize with the gl module). |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 18 | #include "Python.h" |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 19 | #include "forms.h" |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 20 | #include "structmember.h" |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 21 | |
| 22 | /* Generic Forms Objects */ |
| 23 | |
| 24 | typedef struct { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 25 | PyObject_HEAD |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 26 | FL_OBJECT *ob_generic; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 27 | PyMethodDef *ob_methods; |
| 28 | PyObject *ob_callback; |
| 29 | PyObject *ob_callback_arg; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 30 | } genericobject; |
| 31 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 32 | staticforward PyTypeObject GenericObjecttype; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 33 | |
| 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 37 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 38 | static PyObject *allgenerics = NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 39 | static int nfreeslots = 0; |
| 40 | |
| 41 | /* Add an object to the list of known objects */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 42 | |
| 43 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 44 | knowgeneric(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 45 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 46 | int i, n; |
| 47 | /* Create the list if it doesn't already exist */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 48 | if (allgenerics == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 49 | allgenerics = PyList_New(0); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 50 | if (allgenerics == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 51 | PyErr_Clear(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 52 | return; /* Too bad, live without allgenerics... */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 55 | if (nfreeslots > 0) { |
| 56 | /* Search the list for reusable slots (NULL items) */ |
| 57 | /* XXX This can be made faster! */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 58 | n = PyList_Size(allgenerics); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 59 | for (i = 0; i < n; i++) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 60 | if (PyList_GetItem(allgenerics, i) == NULL) { |
| 61 | Py_INCREF(g); |
| 62 | PyList_SetItem(allgenerics, i, (PyObject *)g); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 63 | 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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 71 | PyList_Append(allgenerics, (PyObject *)g); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 74 | /* Find an object in the list of known objects */ |
| 75 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 76 | static genericobject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 77 | findgeneric(FL_OBJECT *generic) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 78 | { |
| 79 | int i, n; |
| 80 | genericobject *g; |
| 81 | |
| 82 | if (allgenerics == NULL) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 83 | return NULL; /* No objects known yet */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 84 | n = PyList_Size(allgenerics); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 85 | for (i = 0; i < n; i++) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 86 | g = (genericobject *)PyList_GetItem(allgenerics, i); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 87 | if (g != NULL && g->ob_generic == generic) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 88 | return g; |
| 89 | } |
| 90 | return NULL; /* Unknown object */ |
| 91 | } |
| 92 | |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 93 | /* Remove an object from the list of known objects */ |
| 94 | |
| 95 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 96 | forgetgeneric(genericobject *g) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 97 | { |
| 98 | int i, n; |
| 99 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 100 | Py_XDECREF(g->ob_callback); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 101 | g->ob_callback = NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 102 | Py_XDECREF(g->ob_callback_arg); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 103 | g->ob_callback_arg = NULL; |
| 104 | if (allgenerics == NULL) |
| 105 | return; /* No objects known yet */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 106 | n = PyList_Size(allgenerics); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 107 | for (i = 0; i < n; i++) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 108 | if (g == (genericobject *)PyList_GetItem(allgenerics, i)) { |
| 109 | PyList_SetItem(allgenerics, i, (PyObject *)NULL); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 110 | nfreeslots++; |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 116 | /* Called when a form is about to be freed -- |
| 117 | remove all the objects that we know about from it. */ |
| 118 | |
| 119 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 120 | releaseobjects(FL_FORM *form) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 121 | { |
| 122 | int i, n; |
| 123 | genericobject *g; |
| 124 | |
| 125 | if (allgenerics == NULL) |
| 126 | return; /* No objects known yet */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 127 | n = PyList_Size(allgenerics); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 128 | for (i = 0; i < n; i++) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 129 | g = (genericobject *)PyList_GetItem(allgenerics, i); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 130 | if (g != NULL && g->ob_generic->form == form) { |
| 131 | fl_delete_object(g->ob_generic); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 132 | /* The object is now unreachable for |
| 133 | do_forms and check_forms, so |
| 134 | delete it from the list of known objects */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 135 | Py_XDECREF(g->ob_callback); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 136 | g->ob_callback = NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 137 | Py_XDECREF(g->ob_callback_arg); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 138 | g->ob_callback_arg = NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 139 | PyList_SetItem(allgenerics, i, (PyObject *)NULL); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 140 | nfreeslots++; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 141 | } |
| 142 | } |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 145 | |
| 146 | /* Methods of generic objects */ |
| 147 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 148 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 149 | generic_set_call_back(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 150 | { |
| 151 | if (args == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 152 | Py_XDECREF(g->ob_callback); |
| 153 | Py_XDECREF(g->ob_callback_arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 154 | g->ob_callback = NULL; |
| 155 | g->ob_callback_arg = NULL; |
| 156 | } |
| 157 | else { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 158 | if (!PyTuple_Check(args) || PyTuple_Size(args) != 2) { |
| 159 | PyErr_BadArgument(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 160 | return NULL; |
| 161 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 162 | 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 168 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 169 | Py_INCREF(Py_None); |
| 170 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 173 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 174 | generic_call(genericobject *g, PyObject *args, void (*func)(FL_OBJECT *)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 175 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 176 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 177 | return NULL; |
| 178 | (*func)(g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 179 | Py_INCREF(Py_None); |
| 180 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 183 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 184 | generic_delete_object(genericobject *g, PyObject *args) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 185 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 186 | PyObject *res; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 187 | res = generic_call(g, args, fl_delete_object); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 188 | if (res != NULL) |
| 189 | forgetgeneric(g); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 190 | return res; |
| 191 | } |
| 192 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 193 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 194 | generic_show_object(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 195 | { |
| 196 | return generic_call(g, args, fl_show_object); |
| 197 | } |
| 198 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 199 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 200 | generic_hide_object(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 201 | { |
| 202 | return generic_call(g, args, fl_hide_object); |
| 203 | } |
| 204 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 205 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 206 | generic_redraw_object(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 207 | { |
| 208 | return generic_call(g, args, fl_redraw_object); |
| 209 | } |
| 210 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 211 | #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 | |
| 217 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 218 | generic_freeze_object(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 219 | { |
| 220 | return generic_call(g, args, fl_freeze_object); |
| 221 | } |
| 222 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 223 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 224 | generic_unfreeze_object(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 225 | { |
| 226 | return generic_call(g, args, fl_unfreeze_object); |
| 227 | } |
| 228 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 229 | #endif /* OBSOLETE_FORMS_CALLS */ |
| 230 | |
| 231 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 232 | generic_activate_object(genericobject *g, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 233 | { |
| 234 | return generic_call(g, args, fl_activate_object); |
| 235 | } |
| 236 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 237 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 238 | generic_deactivate_object(genericobject *g, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 239 | { |
| 240 | return generic_call(g, args, fl_deactivate_object); |
| 241 | } |
| 242 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 243 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 244 | generic_set_object_shortcut(genericobject *g, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 245 | { |
| 246 | char *str; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 247 | if (!PyArg_Parse(args, "s", &str)) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 248 | return NULL; |
| 249 | fl_set_object_shortcut(g->ob_generic, str); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 250 | Py_INCREF(Py_None); |
| 251 | return Py_None; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 254 | static 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 Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 267 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 271 | generic_dealloc(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 272 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 273 | fl_free_object(g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 274 | Py_XDECREF(g->ob_callback); |
| 275 | Py_XDECREF(g->ob_callback_arg); |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 276 | PyObject_Del(g); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | #define OFF(x) offsetof(FL_OBJECT, x) |
| 280 | |
| 281 | static 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 Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 299 | /* {"frozen", T_INT, OFF(frozen), RO}, */ |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 300 | {"active", T_INT, OFF(active)}, |
| 301 | {"input", T_INT, OFF(input)}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 302 | {"visible", T_INT, OFF(visible), RO}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 303 | {"radio", T_INT, OFF(radio)}, |
| 304 | {"automatic", T_INT, OFF(automatic)}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 305 | {NULL} /* Sentinel */ |
| 306 | }; |
| 307 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 308 | #undef OFF |
| 309 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 310 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 311 | generic_getattr(genericobject *g, char *name) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 312 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 313 | PyObject *meth; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 314 | |
| 315 | /* XXX Ought to special-case name "__methods__" */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 316 | if (g-> ob_methods) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 317 | meth = Py_FindMethod(g->ob_methods, (PyObject *)g, name); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 318 | if (meth != NULL) return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 319 | PyErr_Clear(); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 320 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 321 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 322 | meth = Py_FindMethod(generic_methods, (PyObject *)g, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 323 | if (meth != NULL) |
| 324 | return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 325 | PyErr_Clear(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 326 | |
| 327 | /* "label" is an exception, getmember only works for char pointers, |
| 328 | not for char arrays */ |
| 329 | if (strcmp(name, "label") == 0) |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 330 | return PyString_FromString(g->ob_generic->label); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 331 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 332 | return PyMember_Get((char *)g->ob_generic, generic_memberlist, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | static int |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 336 | generic_setattr(genericobject *g, char *name, PyObject *v) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 337 | { |
| 338 | int ret; |
| 339 | |
| 340 | if (v == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 341 | PyErr_SetString(PyExc_TypeError, |
| 342 | "can't delete forms object attributes"); |
Guido van Rossum | 3dd8c98 | 1992-06-03 17:07:49 +0000 | [diff] [blame] | 343 | return -1; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 344 | } |
| 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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 349 | if (!PyString_Check(v)) { |
| 350 | PyErr_SetString(PyExc_TypeError, |
| 351 | "label attr must be string"); |
Guido van Rossum | 3dd8c98 | 1992-06-03 17:07:49 +0000 | [diff] [blame] | 352 | return -1; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 353 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 354 | fl_set_object_label(g->ob_generic, PyString_AsString(v)); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 355 | return 0; |
| 356 | } |
| 357 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 358 | ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 359 | |
| 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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 369 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 370 | generic_repr(genericobject *g) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 371 | { |
| 372 | char buf[100]; |
Fred Drake | a44d353 | 2000-06-30 15:01:00 +0000 | [diff] [blame] | 373 | sprintf(buf, "<FORMS_object at %p, objclass=%d>", |
| 374 | g, g->ob_generic->objclass); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 375 | return PyString_FromString(buf); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 378 | static PyTypeObject GenericObjecttype = { |
| 379 | PyObject_HEAD_INIT(&PyType_Type) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 380 | 0, /*ob_size*/ |
| 381 | "FORMS_object", /*tp_name*/ |
| 382 | sizeof(genericobject), /*tp_size*/ |
| 383 | 0, /*tp_itemsize*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 384 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 385 | (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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 391 | }; |
| 392 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 393 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 394 | newgenericobject(FL_OBJECT *generic, PyMethodDef *methods) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 395 | { |
| 396 | genericobject *g; |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 397 | g = PyObject_New(genericobject, &GenericObjecttype); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 398 | 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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 405 | return (PyObject *)g; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | /**********************************************************************/ |
| 409 | /* Some common calling sequences */ |
| 410 | |
| 411 | /* void func (object, float) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 412 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 413 | call_forms_INf (void (*func)(FL_OBJECT *, float), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 414 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 415 | float parameter; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 416 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 417 | if (!PyArg_Parse(args, "f", ¶meter)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 418 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 419 | (*func) (obj, parameter); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 420 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 421 | Py_INCREF(Py_None); |
| 422 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /* void func (object, float) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 426 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 427 | call_forms_INfINf (void (*func)(FL_OBJECT *, float, float), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 428 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 429 | float par1, par2; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 430 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 431 | if (!PyArg_Parse(args, "(ff)", &par1, &par2)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 432 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 433 | (*func) (obj, par1, par2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 434 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 435 | Py_INCREF(Py_None); |
| 436 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | /* void func (object, int) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 440 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 441 | call_forms_INi (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 442 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 443 | int parameter; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 444 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 445 | if (!PyArg_Parse(args, "i", ¶meter)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 446 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 447 | (*func) (obj, parameter); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 448 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 449 | Py_INCREF(Py_None); |
| 450 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 453 | /* void func (object, char) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 454 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 455 | call_forms_INc (void (*func)(FL_OBJECT *, int), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 456 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 457 | char *a; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 458 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 459 | if (!PyArg_Parse(args, "s", &a)) return NULL; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 460 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 461 | (*func) (obj, a[0]); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 462 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 463 | Py_INCREF(Py_None); |
| 464 | return Py_None; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 465 | } |
| 466 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 467 | /* void func (object, string) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 468 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 469 | call_forms_INstr (void (*func)(FL_OBJECT *, char *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 470 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 471 | char *a; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 472 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 473 | if (!PyArg_Parse(args, "s", &a)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 474 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 475 | (*func) (obj, a); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 476 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 477 | Py_INCREF(Py_None); |
| 478 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 482 | /* void func (object, int, string) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 483 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 484 | call_forms_INiINstr (void (*func)(FL_OBJECT *, int, char *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 485 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 486 | char *b; |
| 487 | int a; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 488 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 489 | if (!PyArg_Parse(args, "(is)", &a, &b)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 490 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 491 | (*func) (obj, a, b); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 492 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 493 | Py_INCREF(Py_None); |
| 494 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 495 | } |
| 496 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 497 | #ifdef UNUSED |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 498 | /* void func (object, int, int) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 499 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 500 | call_forms_INiINi (void (*func)(FL_OBJECT *, int, int), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 501 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 502 | int par1, par2; |
| 503 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 504 | if (!PyArg_Parse(args, "(ii)", &par1, &par2)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 505 | |
| 506 | (*func) (obj, par1, par2); |
| 507 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 508 | Py_INCREF(Py_None); |
| 509 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 510 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 511 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 512 | |
| 513 | /* int func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 514 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 515 | call_forms_Ri (int (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 516 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 517 | int retval; |
| 518 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 519 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 520 | |
| 521 | retval = (*func) (obj); |
| 522 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 523 | return PyInt_FromLong ((long) retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | /* char * func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 527 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 528 | call_forms_Rstr (char * (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 529 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 530 | char *str; |
| 531 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 532 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 533 | |
| 534 | str = (*func) (obj); |
| 535 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 536 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 537 | Py_INCREF(Py_None); |
| 538 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 539 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 540 | return PyString_FromString (str); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | /* int func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 544 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 545 | call_forms_Rf (float (*func)(FL_OBJECT *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 546 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 547 | float retval; |
| 548 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 549 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 550 | |
| 551 | retval = (*func) (obj); |
| 552 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 553 | return PyFloat_FromDouble (retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 556 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 557 | call_forms_OUTfOUTf (void (*func)(FL_OBJECT *, float *, float *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 558 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 559 | float f1, f2; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 560 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 561 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 562 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 563 | (*func) (obj, &f1, &f2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 564 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 565 | return Py_BuildValue("(ff)", f1, f2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 566 | } |
| 567 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 568 | #ifdef UNUSED |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 569 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 570 | call_forms_OUTf (void (*func)(FL_OBJECT *, float *), FL_OBJECT *obj, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 571 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 572 | float f; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 573 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 574 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 575 | |
| 576 | (*func) (obj, &f); |
| 577 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 578 | return PyFloat_FromDouble (f); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 579 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 580 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 581 | |
| 582 | /**********************************************************************/ |
| 583 | /* Class : browser */ |
| 584 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 585 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 586 | set_browser_topline(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 587 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 588 | return call_forms_INi (fl_set_browser_topline, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 591 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 592 | clear_browser(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 593 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 594 | return generic_call (g, args, fl_clear_browser); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 597 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 598 | add_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 599 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 600 | return call_forms_INstr (fl_add_browser_line, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 601 | } |
| 602 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 603 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 604 | addto_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 605 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 606 | return call_forms_INstr (fl_addto_browser, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 609 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 610 | insert_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 611 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 612 | return call_forms_INiINstr (fl_insert_browser_line, |
| 613 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 614 | } |
| 615 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 616 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 617 | delete_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 618 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 619 | return call_forms_INi (fl_delete_browser_line, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 622 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 623 | replace_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 624 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 625 | return call_forms_INiINstr (fl_replace_browser_line, |
| 626 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 627 | } |
| 628 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 629 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 630 | get_browser_line(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 631 | { |
| 632 | int i; |
| 633 | char *str; |
| 634 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 635 | if (!PyArg_Parse(args, "i", &i)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 636 | return NULL; |
| 637 | |
| 638 | str = fl_get_browser_line (g->ob_generic, i); |
| 639 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 640 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 641 | Py_INCREF(Py_None); |
| 642 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 643 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 644 | return PyString_FromString (str); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 645 | } |
| 646 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 647 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 648 | load_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 649 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 650 | /* XXX strictly speaking this is wrong since fl_load_browser |
| 651 | XXX returns int, not void */ |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 652 | return call_forms_INstr (fl_load_browser, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 653 | } |
| 654 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 655 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 656 | get_browser_maxline(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 657 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 658 | return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 659 | } |
| 660 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 661 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 662 | select_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 663 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 664 | return call_forms_INi (fl_select_browser_line, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 665 | } |
| 666 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 667 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 668 | deselect_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 669 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 670 | return call_forms_INi (fl_deselect_browser_line, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 671 | } |
| 672 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 673 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 674 | deselect_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 675 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 676 | return generic_call (g, args, fl_deselect_browser); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 677 | } |
| 678 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 679 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 680 | isselected_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 681 | { |
| 682 | int i, j; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 683 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 684 | if (!PyArg_Parse(args, "i", &i)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 685 | return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 686 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 687 | j = fl_isselected_browser_line (g->ob_generic, i); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 688 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 689 | return PyInt_FromLong (j); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 692 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 693 | get_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 694 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 695 | return call_forms_Ri (fl_get_browser, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 696 | } |
| 697 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 698 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 699 | set_browser_fontsize (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 700 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 701 | return call_forms_INf (fl_set_browser_fontsize, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 702 | } |
| 703 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 704 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 705 | set_browser_fontstyle (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 706 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 707 | return call_forms_INi (fl_set_browser_fontstyle, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 708 | } |
| 709 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 710 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 711 | set_browser_specialkey (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 712 | { |
| 713 | return call_forms_INc(fl_set_browser_specialkey, g-> ob_generic, args); |
| 714 | } |
| 715 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 716 | static 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 Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 735 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 736 | }; |
| 737 | |
| 738 | /* Class: button */ |
| 739 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 740 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 741 | set_button(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 742 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 743 | return call_forms_INi (fl_set_button, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 746 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 747 | get_button(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 748 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 749 | return call_forms_Ri (fl_get_button, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 750 | } |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 751 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 752 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 753 | get_button_numb(genericobject *g, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 754 | { |
| 755 | return call_forms_Ri (fl_get_button_numb, g-> ob_generic, args); |
| 756 | } |
| 757 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 758 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 759 | set_button_shortcut(genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 760 | { |
| 761 | return call_forms_INstr (fl_set_button_shortcut, g-> ob_generic, args); |
| 762 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 763 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 764 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 769 | {NULL, NULL} /* sentinel */ |
| 770 | }; |
| 771 | |
| 772 | /* Class: choice */ |
| 773 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 774 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 775 | set_choice(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 776 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 777 | return call_forms_INi (fl_set_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 778 | } |
| 779 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 780 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 781 | get_choice(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 782 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 783 | return call_forms_Ri (fl_get_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 784 | } |
| 785 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 786 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 787 | clear_choice (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 788 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 789 | return generic_call (g, args, fl_clear_choice); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 790 | } |
| 791 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 792 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 793 | addto_choice (genericobject *g, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 794 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 795 | return call_forms_INstr (fl_addto_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 796 | } |
| 797 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 798 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 799 | replace_choice (genericobject *g, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 800 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 801 | return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 802 | } |
| 803 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 804 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 805 | delete_choice (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 806 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 807 | return call_forms_INi (fl_delete_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 808 | } |
| 809 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 810 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 811 | get_choice_text (genericobject *g, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 812 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 813 | return call_forms_Rstr (fl_get_choice_text, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 816 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 817 | set_choice_fontsize (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 818 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 819 | return call_forms_INf (fl_set_choice_fontsize, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 822 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 823 | set_choice_fontstyle (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 824 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 825 | return call_forms_INi (fl_set_choice_fontstyle, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 826 | } |
| 827 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 828 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 838 | {NULL, NULL} /* sentinel */ |
| 839 | }; |
| 840 | |
| 841 | /* Class : Clock */ |
| 842 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 843 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 844 | get_clock(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 845 | { |
| 846 | int i0, i1, i2; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 847 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 848 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 849 | return NULL; |
| 850 | |
| 851 | fl_get_clock (g->ob_generic, &i0, &i1, &i2); |
| 852 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 853 | return Py_BuildValue("(iii)", i0, i1, i2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 854 | } |
| 855 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 856 | static PyMethodDef clock_methods[] = { |
| 857 | {"get_clock", (PyCFunction)get_clock}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 858 | {NULL, NULL} /* sentinel */ |
| 859 | }; |
| 860 | |
| 861 | /* CLass : Counters */ |
| 862 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 863 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 864 | get_counter_value(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 865 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 866 | return call_forms_Rf (fl_get_counter_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 869 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 870 | set_counter_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 871 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 872 | return call_forms_INf (fl_set_counter_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 875 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 876 | set_counter_precision (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 877 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 878 | return call_forms_INi (fl_set_counter_precision, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 879 | } |
| 880 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 881 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 882 | set_counter_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 883 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 884 | return call_forms_INfINf (fl_set_counter_bounds, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 885 | } |
| 886 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 887 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 888 | set_counter_step (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 889 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 890 | return call_forms_INfINf (fl_set_counter_step, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 891 | } |
| 892 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 893 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 894 | set_counter_return (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 895 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 896 | return call_forms_INi (fl_set_counter_return, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 897 | } |
| 898 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 899 | static 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 Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 906 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 907 | }; |
| 908 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 909 | |
| 910 | /* Class: Dials */ |
| 911 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 912 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 913 | get_dial_value(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 914 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 915 | return call_forms_Rf (fl_get_dial_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 916 | } |
| 917 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 918 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 919 | set_dial_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 920 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 921 | return call_forms_INf (fl_set_dial_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 922 | } |
| 923 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 924 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 925 | set_dial_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 926 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 927 | return call_forms_INfINf (fl_set_dial_bounds, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 928 | } |
| 929 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 930 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 931 | get_dial_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 932 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 933 | return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 934 | } |
| 935 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 936 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 937 | set_dial_step (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 938 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 939 | return call_forms_INf (fl_set_dial_step, g-> ob_generic, args); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 940 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 941 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 942 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 948 | {NULL, NULL} /* sentinel */ |
| 949 | }; |
| 950 | |
| 951 | /* Class : Input */ |
| 952 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 953 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 954 | set_input (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 955 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 956 | return call_forms_INstr (fl_set_input, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 957 | } |
| 958 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 959 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 960 | get_input (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 961 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 962 | return call_forms_Rstr (fl_get_input, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 963 | } |
| 964 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 965 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 966 | set_input_color (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 967 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 968 | return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 969 | } |
| 970 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 971 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 972 | set_input_return (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 973 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 974 | return call_forms_INi (fl_set_input_return, g-> ob_generic, args); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 975 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 976 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 977 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 982 | {NULL, NULL} /* sentinel */ |
| 983 | }; |
| 984 | |
| 985 | |
| 986 | /* Class : Menu */ |
| 987 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 988 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 989 | set_menu (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 990 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 991 | return call_forms_INstr (fl_set_menu, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 992 | } |
| 993 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 994 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 995 | get_menu (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 996 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 997 | /* 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1002 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1003 | get_menu_text (genericobject *g, PyObject *args) |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 1004 | { |
| 1005 | return call_forms_Rstr (fl_get_menu_text, g-> ob_generic, args); |
| 1006 | } |
| 1007 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1008 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1009 | addto_menu (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1010 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 1011 | return call_forms_INstr (fl_addto_menu, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1014 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1019 | {NULL, NULL} /* sentinel */ |
| 1020 | }; |
| 1021 | |
| 1022 | |
| 1023 | /* Class: Sliders */ |
| 1024 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1025 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1026 | get_slider_value(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1027 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1028 | return call_forms_Rf (fl_get_slider_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1031 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1032 | set_slider_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1033 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1034 | return call_forms_INf (fl_set_slider_value, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1037 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1038 | set_slider_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1039 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1040 | return call_forms_INfINf (fl_set_slider_bounds, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1043 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1044 | get_slider_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1045 | { |
| 1046 | return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic, args); |
| 1047 | } |
| 1048 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1049 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1050 | set_slider_return (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1051 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1052 | return call_forms_INf (fl_set_slider_return, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1055 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1056 | set_slider_size (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1057 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1058 | return call_forms_INf (fl_set_slider_size, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1059 | } |
| 1060 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1061 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1062 | set_slider_precision (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1063 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1064 | return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1067 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1068 | set_slider_step (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1069 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1070 | return call_forms_INf (fl_set_slider_step, g-> ob_generic, args); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1071 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1072 | |
| 1073 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1074 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1083 | {NULL, NULL} /* sentinel */ |
| 1084 | }; |
| 1085 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1086 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1087 | set_positioner_xvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1088 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1089 | return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1090 | } |
| 1091 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1092 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1093 | set_positioner_xbounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1094 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1095 | return call_forms_INfINf (fl_set_positioner_xbounds, |
| 1096 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1097 | } |
| 1098 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1099 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1100 | set_positioner_yvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1101 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1102 | return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1103 | } |
| 1104 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1105 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1106 | set_positioner_ybounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1107 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1108 | return call_forms_INfINf (fl_set_positioner_ybounds, |
| 1109 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1112 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1113 | get_positioner_xvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1114 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1115 | return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1116 | } |
| 1117 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1118 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1119 | get_positioner_xbounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1120 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1121 | return call_forms_OUTfOUTf (fl_get_positioner_xbounds, |
| 1122 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1123 | } |
| 1124 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1125 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1126 | get_positioner_yvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1127 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1128 | return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1129 | } |
| 1130 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1131 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1132 | get_positioner_ybounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1133 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1134 | return call_forms_OUTfOUTf (fl_get_positioner_ybounds, |
| 1135 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1138 | static 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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1147 | {NULL, NULL} /* sentinel */ |
| 1148 | }; |
| 1149 | |
| 1150 | /* Class timer */ |
| 1151 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1152 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1153 | set_timer (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1154 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1155 | return call_forms_INf (fl_set_timer, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1156 | } |
| 1157 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1158 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1159 | get_timer (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1160 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1161 | return call_forms_Rf (fl_get_timer, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1164 | static PyMethodDef timer_methods[] = { |
| 1165 | {"set_timer", (PyCFunction)set_timer}, |
| 1166 | {"get_timer", (PyCFunction)get_timer}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1167 | {NULL, NULL} /* sentinel */ |
| 1168 | }; |
| 1169 | |
| 1170 | /* Form objects */ |
| 1171 | |
| 1172 | typedef struct { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1173 | PyObject_HEAD |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1174 | FL_FORM *ob_form; |
| 1175 | } formobject; |
| 1176 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1177 | staticforward PyTypeObject Formtype; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1178 | |
| 1179 | #define is_formobject(v) ((v)->ob_type == &Formtype) |
| 1180 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1181 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1182 | form_show_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1183 | { |
| 1184 | int place, border; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1185 | char *name; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1186 | if (!PyArg_Parse(args, "(iis)", &place, &border, &name)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1187 | return NULL; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1188 | fl_show_form(f->ob_form, place, border, name); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1189 | Py_INCREF(Py_None); |
| 1190 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1191 | } |
| 1192 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1193 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1194 | form_call(void (*func)(FL_FORM *), FL_FORM *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1195 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1196 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1197 | |
| 1198 | (*func)(f); |
| 1199 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1200 | Py_INCREF(Py_None); |
| 1201 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1204 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1205 | form_call_INiINi(void (*func)(FL_FORM *, int, int), FL_FORM *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1206 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1207 | int a, b; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1208 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1209 | if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1210 | |
| 1211 | (*func)(f, a, b); |
| 1212 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1213 | Py_INCREF(Py_None); |
| 1214 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1215 | } |
| 1216 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1217 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1218 | form_call_INfINf(void (*func)(FL_FORM *, float, float), FL_FORM *f, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1219 | { |
| 1220 | float a, b; |
| 1221 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1222 | if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1223 | |
| 1224 | (*func)(f, a, b); |
| 1225 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1226 | Py_INCREF(Py_None); |
| 1227 | return Py_None; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1230 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1231 | form_hide_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1232 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1233 | return form_call(fl_hide_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1234 | } |
| 1235 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1236 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1237 | form_redraw_form(formobject *f, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1238 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1239 | return form_call(fl_redraw_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1240 | } |
| 1241 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1242 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1243 | form_set_form_position(formobject *f, PyObject *args) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1244 | { |
| 1245 | return form_call_INiINi(fl_set_form_position, f-> ob_form, args); |
| 1246 | } |
| 1247 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1248 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1249 | form_set_form_size(formobject *f, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1250 | { |
| 1251 | return form_call_INiINi(fl_set_form_size, f-> ob_form, args); |
| 1252 | } |
| 1253 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1254 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1255 | form_scale_form(formobject *f, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1256 | { |
| 1257 | return form_call_INfINf(fl_scale_form, f-> ob_form, args); |
| 1258 | } |
| 1259 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1260 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1261 | generic_add_object(formobject *f, PyObject *args, FL_OBJECT *(*func)(int, float, float, float, float, char*), PyMethodDef *internal_methods) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1262 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1263 | int type; |
| 1264 | float x, y, w, h; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1265 | char *name; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1266 | FL_OBJECT *obj; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1267 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1268 | if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name)) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1269 | return NULL; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1270 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1271 | fl_addto_form (f-> ob_form); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1272 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1273 | obj = (*func) (type, x, y, w, h, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1274 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1275 | fl_end_form(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1276 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1277 | if (obj == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1278 | PyErr_NoMemory(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1279 | return NULL; |
| 1280 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1281 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1282 | return newgenericobject (obj, internal_methods); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1285 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1286 | form_add_button(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1287 | { |
| 1288 | return generic_add_object(f, args, fl_add_button, button_methods); |
| 1289 | } |
| 1290 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1291 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1292 | form_add_lightbutton(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1293 | { |
| 1294 | return generic_add_object(f, args, fl_add_lightbutton, button_methods); |
| 1295 | } |
| 1296 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1297 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1298 | form_add_roundbutton(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1299 | { |
| 1300 | return generic_add_object(f, args, fl_add_roundbutton, button_methods); |
| 1301 | } |
| 1302 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1303 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1304 | form_add_menu (formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1305 | { |
| 1306 | return generic_add_object(f, args, fl_add_menu, menu_methods); |
| 1307 | } |
| 1308 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1309 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1310 | form_add_slider(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1311 | { |
| 1312 | return generic_add_object(f, args, fl_add_slider, slider_methods); |
| 1313 | } |
| 1314 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1315 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1316 | form_add_valslider(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1317 | { |
| 1318 | return generic_add_object(f, args, fl_add_valslider, slider_methods); |
| 1319 | } |
| 1320 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1321 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1322 | form_add_dial(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1323 | { |
| 1324 | return generic_add_object(f, args, fl_add_dial, dial_methods); |
| 1325 | } |
| 1326 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1327 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1328 | form_add_counter(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1329 | { |
| 1330 | return generic_add_object(f, args, fl_add_counter, counter_methods); |
| 1331 | } |
| 1332 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1333 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1334 | form_add_clock(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1335 | { |
| 1336 | return generic_add_object(f, args, fl_add_clock, clock_methods); |
| 1337 | } |
| 1338 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1339 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1340 | form_add_box(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1341 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1342 | return generic_add_object(f, args, fl_add_box, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1343 | (PyMethodDef *)NULL); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1344 | } |
| 1345 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1346 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1347 | form_add_choice(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1348 | { |
| 1349 | return generic_add_object(f, args, fl_add_choice, choice_methods); |
| 1350 | } |
| 1351 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1352 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1353 | form_add_browser(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1354 | { |
| 1355 | return generic_add_object(f, args, fl_add_browser, browser_methods); |
| 1356 | } |
| 1357 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1358 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1359 | form_add_positioner(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1360 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1361 | return generic_add_object(f, args, fl_add_positioner, |
| 1362 | positioner_methods); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1363 | } |
| 1364 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1365 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1366 | form_add_input(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1367 | { |
| 1368 | return generic_add_object(f, args, fl_add_input, input_methods); |
| 1369 | } |
| 1370 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1371 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1372 | form_add_text(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1373 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1374 | return generic_add_object(f, args, fl_add_text, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1375 | (PyMethodDef *)NULL); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1378 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1379 | form_add_timer(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1380 | { |
| 1381 | return generic_add_object(f, args, fl_add_timer, timer_methods); |
| 1382 | } |
| 1383 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1384 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1385 | form_freeze_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1386 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1387 | return form_call(fl_freeze_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1388 | } |
| 1389 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1390 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1391 | form_unfreeze_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1392 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1393 | return form_call(fl_unfreeze_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1394 | } |
| 1395 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1396 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1397 | form_activate_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1398 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1399 | return form_call(fl_activate_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1400 | } |
| 1401 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1402 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1403 | form_deactivate_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1404 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1405 | return form_call(fl_deactivate_form, f-> ob_form, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1406 | } |
| 1407 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1408 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1409 | form_bgn_group(formobject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1410 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1411 | 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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1418 | PyErr_NoMemory(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1419 | return NULL; |
| 1420 | } |
| 1421 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1422 | return newgenericobject (obj, (PyMethodDef *) NULL); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1423 | } |
| 1424 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1425 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1426 | form_end_group(formobject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1427 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1428 | fl_addto_form(f-> ob_form); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1429 | fl_end_group(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1430 | fl_end_form(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1431 | Py_INCREF(Py_None); |
| 1432 | return Py_None; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1433 | } |
| 1434 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1435 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1436 | forms_find_first_or_last(FL_OBJECT *(*func)(FL_FORM *, int, float, float), formobject *f, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1437 | { |
| 1438 | int type; |
| 1439 | float mx, my; |
| 1440 | FL_OBJECT *generic; |
| 1441 | genericobject *g; |
| 1442 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1443 | if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1444 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1445 | generic = (*func) (f-> ob_form, type, mx, my); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1446 | |
| 1447 | if (generic == NULL) |
| 1448 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1449 | Py_INCREF(Py_None); |
| 1450 | return Py_None; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | g = findgeneric(generic); |
| 1454 | if (g == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1455 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1456 | "forms_find_{first|last} returns unknown object"); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1457 | return NULL; |
| 1458 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1459 | Py_INCREF(g); |
| 1460 | return (PyObject *) g; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1463 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1464 | form_find_first(formobject *f, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1465 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1466 | return forms_find_first_or_last(fl_find_first, f, args); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1467 | } |
| 1468 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1469 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1470 | form_find_last(formobject *f, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1471 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1472 | return forms_find_first_or_last(fl_find_last, f, args); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1473 | } |
| 1474 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1475 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1476 | form_set_object_focus(formobject *f, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1477 | { |
| 1478 | genericobject *g; |
| 1479 | if (args == NULL || !is_genericobject(args)) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1480 | PyErr_BadArgument(); |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1481 | return NULL; |
| 1482 | } |
| 1483 | g = (genericobject *)args; |
| 1484 | fl_set_object_focus(f->ob_form, g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1485 | Py_INCREF(Py_None); |
| 1486 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1487 | } |
| 1488 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1489 | static PyMethodDef form_methods[] = { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1490 | /* adm */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1491 | {"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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1506 | |
| 1507 | /* basic objects */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1508 | {"add_button", (PyCFunction)form_add_button}, |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1509 | /* {"add_bitmap", (method)form_add_bitmap}, */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1510 | {"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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1525 | {NULL, NULL} /* sentinel */ |
| 1526 | }; |
| 1527 | |
| 1528 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1529 | form_dealloc(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1530 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1531 | releaseobjects(f->ob_form); |
Guido van Rossum | 336b591 | 1992-04-08 11:16:25 +0000 | [diff] [blame] | 1532 | if (f->ob_form->visible) |
| 1533 | fl_hide_form(f->ob_form); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1534 | fl_free_form(f->ob_form); |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 1535 | PyObject_Del(f); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1536 | } |
| 1537 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 1538 | #define OFF(x) offsetof(FL_FORM, x) |
| 1539 | |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1540 | static 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 Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1544 | {"x", T_FLOAT, OFF(x), RO}, |
| 1545 | {"y", T_FLOAT, OFF(y), RO}, |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1546 | {"deactivated", T_INT, OFF(deactivated)}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1547 | {"visible", T_INT, OFF(visible), RO}, |
| 1548 | {"frozen", T_INT, OFF(frozen), RO}, |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1549 | {"doublebuf", T_INT, OFF(doublebuf)}, |
| 1550 | {NULL} /* Sentinel */ |
| 1551 | }; |
| 1552 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 1553 | #undef OFF |
| 1554 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1555 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1556 | form_getattr(formobject *f, char *name) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1557 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1558 | PyObject *meth; |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1559 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1560 | meth = Py_FindMethod(form_methods, (PyObject *)f, name); |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1561 | if (meth != NULL) |
| 1562 | return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1563 | PyErr_Clear(); |
| 1564 | return PyMember_Get((char *)f->ob_form, form_memberlist, name); |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | static int |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1568 | form_setattr(formobject *f, char *name, PyObject *v) |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1569 | { |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1570 | if (v == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1571 | PyErr_SetString(PyExc_TypeError, |
| 1572 | "can't delete form attributes"); |
Guido van Rossum | 3863abb | 1996-09-11 23:31:07 +0000 | [diff] [blame] | 1573 | return -1; |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1574 | } |
| 1575 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1576 | return PyMember_Set((char *)f->ob_form, form_memberlist, name, v); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1577 | } |
| 1578 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1579 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1580 | form_repr(formobject *f) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1581 | { |
| 1582 | char buf[100]; |
Fred Drake | a44d353 | 2000-06-30 15:01:00 +0000 | [diff] [blame] | 1583 | sprintf(buf, "<FORMS_form at %p, window=%ld>", |
| 1584 | f, f->ob_form->window); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1585 | return PyString_FromString(buf); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1586 | } |
| 1587 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1588 | static PyTypeObject Formtype = { |
| 1589 | PyObject_HEAD_INIT(&PyType_Type) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1590 | 0, /*ob_size*/ |
| 1591 | "FORMS_form", /*tp_name*/ |
| 1592 | sizeof(formobject), /*tp_size*/ |
| 1593 | 0, /*tp_itemsize*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1594 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1595 | (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 Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1601 | }; |
| 1602 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1603 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1604 | newformobject(FL_FORM *form) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1605 | { |
| 1606 | formobject *f; |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 1607 | f = PyObject_New(formobject, &Formtype); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1608 | if (f == NULL) |
| 1609 | return NULL; |
| 1610 | f->ob_form = form; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1611 | return (PyObject *)f; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1612 | } |
| 1613 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1614 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1615 | /* The "fl" module */ |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1616 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1617 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1618 | forms_make_form(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1619 | { |
| 1620 | int type; |
| 1621 | float w, h; |
| 1622 | FL_FORM *form; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1623 | if (!PyArg_Parse(args, "(iff)", &type, &w, &h)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1624 | return NULL; |
| 1625 | form = fl_bgn_form(type, w, h); |
| 1626 | if (form == NULL) { |
| 1627 | /* XXX Actually, cannot happen! */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1628 | PyErr_NoMemory(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1629 | return NULL; |
| 1630 | } |
| 1631 | fl_end_form(); |
| 1632 | return newformobject(form); |
| 1633 | } |
| 1634 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1635 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1636 | forms_activate_all_forms(PyObject *f, PyObject *args) |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1637 | { |
| 1638 | fl_activate_all_forms(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1639 | Py_INCREF(Py_None); |
| 1640 | return Py_None; |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1641 | } |
| 1642 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1643 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1644 | forms_deactivate_all_forms(PyObject *f, PyObject *args) |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1645 | { |
| 1646 | fl_deactivate_all_forms(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1647 | Py_INCREF(Py_None); |
| 1648 | return Py_None; |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1649 | } |
| 1650 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1651 | static PyObject *my_event_callback = NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1652 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1653 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1654 | forms_set_event_call_back(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1655 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1656 | if (args == Py_None) |
Guido van Rossum | f6da4f6 | 1993-07-26 15:24:57 +0000 | [diff] [blame] | 1657 | args = NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1658 | my_event_callback = args; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1659 | Py_XINCREF(args); |
| 1660 | Py_INCREF(Py_None); |
| 1661 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1662 | } |
| 1663 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1664 | static PyObject * |
Thomas Wouters | bd4bc4e | 2000-07-22 23:57:55 +0000 | [diff] [blame] | 1665 | forms_do_or_check_forms(PyObject *dummy, PyObject *args, FL_OBJECT *(*func)(void)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1666 | { |
| 1667 | FL_OBJECT *generic; |
| 1668 | genericobject *g; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1669 | PyObject *arg, *res; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1670 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1671 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1672 | return NULL; |
| 1673 | |
| 1674 | for (;;) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1675 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1676 | generic = (*func)(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1677 | Py_END_ALLOW_THREADS |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1678 | if (generic == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1679 | Py_INCREF(Py_None); |
| 1680 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1681 | } |
| 1682 | if (generic == FL_EVENT) { |
| 1683 | int dev; |
| 1684 | short val; |
| 1685 | if (my_event_callback == NULL) |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1686 | return PyInt_FromLong(-1L); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1687 | dev = fl_qread(&val); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1688 | arg = Py_BuildValue("(ih)", dev, val); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1689 | if (arg == NULL) |
| 1690 | return NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1691 | res = PyEval_CallObject(my_event_callback, arg); |
| 1692 | Py_XDECREF(res); |
| 1693 | Py_DECREF(arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1694 | if (res == NULL) |
| 1695 | return NULL; /* Callback raised exception */ |
| 1696 | continue; |
| 1697 | } |
| 1698 | g = findgeneric(generic); |
| 1699 | if (g == NULL) { |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 1700 | /* Object not known to us (some dialogs cause this) */ |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1701 | continue; /* Ignore it */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1702 | } |
| 1703 | if (g->ob_callback == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1704 | Py_INCREF(g); |
| 1705 | return ((PyObject *) g); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1706 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1707 | arg = Py_BuildValue("(OO)", (PyObject *)g, g->ob_callback_arg); |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1708 | if (arg == NULL) |
| 1709 | return NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1710 | res = PyEval_CallObject(g->ob_callback, arg); |
| 1711 | Py_XDECREF(res); |
| 1712 | Py_DECREF(arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1713 | if (res == NULL) |
| 1714 | return NULL; /* Callback raised exception */ |
| 1715 | } |
| 1716 | } |
| 1717 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1718 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1719 | forms_do_forms(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1720 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1721 | return forms_do_or_check_forms(dummy, args, fl_do_forms); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1722 | } |
| 1723 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1724 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1725 | forms_check_forms(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1726 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1727 | return forms_do_or_check_forms(dummy, args, fl_check_forms); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1728 | } |
| 1729 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1730 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1731 | forms_do_only_forms(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1732 | { |
| 1733 | return forms_do_or_check_forms(dummy, args, fl_do_only_forms); |
| 1734 | } |
| 1735 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1736 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1737 | forms_check_only_forms(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1738 | { |
| 1739 | return forms_do_or_check_forms(dummy, args, fl_check_only_forms); |
| 1740 | } |
| 1741 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1742 | #ifdef UNUSED |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1743 | static PyObject * |
Thomas Wouters | bd4bc4e | 2000-07-22 23:57:55 +0000 | [diff] [blame] | 1744 | fl_call(void (*func)(void), PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1745 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1746 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1747 | return NULL; |
| 1748 | (*func)(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1749 | Py_INCREF(Py_None); |
| 1750 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1751 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1752 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1753 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1754 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1755 | forms_set_graphics_mode(PyObject *dummy, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1756 | { |
| 1757 | int rgbmode, doublebuf; |
| 1758 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1759 | if (!PyArg_Parse(args, "(ii)", &rgbmode, &doublebuf)) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1760 | return NULL; |
| 1761 | fl_set_graphics_mode(rgbmode,doublebuf); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1762 | Py_INCREF(Py_None); |
| 1763 | return Py_None; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1764 | } |
| 1765 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1766 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1767 | forms_get_rgbmode(PyObject *dummy, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1768 | { |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1769 | extern int fl_rgbmode; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1770 | |
| 1771 | if (args != NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1772 | PyErr_BadArgument(); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1773 | return NULL; |
| 1774 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1775 | return PyInt_FromLong((long)fl_rgbmode); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1776 | } |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1777 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1778 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1779 | forms_show_errors(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1780 | { |
| 1781 | int show; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1782 | if (!PyArg_Parse(args, "i", &show)) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1783 | return NULL; |
| 1784 | fl_show_errors(show); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1785 | Py_INCREF(Py_None); |
| 1786 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1787 | } |
| 1788 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1789 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1790 | forms_set_font_name(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1791 | { |
| 1792 | int numb; |
| 1793 | char *name; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1794 | if (!PyArg_Parse(args, "(is)", &numb, &name)) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1795 | return NULL; |
| 1796 | fl_set_font_name(numb, name); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1797 | Py_INCREF(Py_None); |
| 1798 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1799 | } |
| 1800 | |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1801 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1802 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1803 | forms_qdevice(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1804 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1805 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1806 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1807 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1808 | fl_qdevice(arg1); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1809 | Py_INCREF(Py_None); |
| 1810 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1811 | } |
| 1812 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1813 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1814 | forms_unqdevice(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1815 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1816 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1817 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1818 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1819 | fl_unqdevice(arg1); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1820 | Py_INCREF(Py_None); |
| 1821 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1822 | } |
| 1823 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1824 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1825 | forms_isqueued(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1826 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1827 | long retval; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1828 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1829 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1830 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1831 | retval = fl_isqueued(arg1); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1832 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1833 | return PyInt_FromLong(retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1834 | } |
| 1835 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1836 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1837 | forms_qtest(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1838 | { |
| 1839 | long retval; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1840 | retval = fl_qtest(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1841 | return PyInt_FromLong(retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1842 | } |
| 1843 | |
| 1844 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1845 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1846 | forms_qread(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1847 | { |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1848 | int dev; |
| 1849 | short val; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1850 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1851 | dev = fl_qread(&val); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1852 | Py_END_ALLOW_THREADS |
| 1853 | return Py_BuildValue("(ih)", dev, val); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1854 | } |
| 1855 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1856 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1857 | forms_qreset(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1858 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1859 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1860 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1861 | fl_qreset(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1862 | Py_INCREF(Py_None); |
| 1863 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1864 | } |
| 1865 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1866 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1867 | forms_qenter(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1868 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1869 | short arg1, arg2; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1870 | if (!PyArg_Parse(args, "(hh)", &arg1, &arg2)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1871 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1872 | fl_qenter(arg1, arg2); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1873 | Py_INCREF(Py_None); |
| 1874 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1875 | } |
| 1876 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1877 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1878 | forms_color(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1879 | { |
| 1880 | int arg; |
| 1881 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1882 | if (!PyArg_Parse(args, "i", &arg)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1883 | |
| 1884 | fl_color((short) arg); |
| 1885 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1886 | Py_INCREF(Py_None); |
| 1887 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1888 | } |
| 1889 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1890 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1891 | forms_mapcolor(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1892 | { |
| 1893 | int arg0, arg1, arg2, arg3; |
| 1894 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1895 | if (!PyArg_Parse(args, "(iiii)", &arg0, &arg1, &arg2, &arg3)) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1896 | return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1897 | |
| 1898 | fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3); |
| 1899 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1900 | Py_INCREF(Py_None); |
| 1901 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1902 | } |
| 1903 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1904 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1905 | forms_getmcolor(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1906 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1907 | int arg; |
| 1908 | short r, g, b; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1909 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1910 | if (!PyArg_Parse(args, "i", &arg)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1911 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1912 | fl_getmcolor(arg, &r, &g, &b); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1913 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1914 | return Py_BuildValue("(hhh)", r, g, b); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1915 | } |
| 1916 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1917 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1918 | forms_get_mouse(PyObject *self, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1919 | { |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1920 | float x, y; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1921 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1922 | if (!PyArg_NoArgs(args)) return NULL; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1923 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1924 | fl_get_mouse(&x, &y); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1925 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1926 | return Py_BuildValue("(ff)", x, y); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1927 | } |
| 1928 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1929 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1930 | forms_tie(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1931 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1932 | short arg1, arg2, arg3; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1933 | if (!PyArg_Parse(args, "(hhh)", &arg1, &arg2, &arg3)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1934 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1935 | fl_tie(arg1, arg2, arg3); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1936 | Py_INCREF(Py_None); |
| 1937 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1938 | } |
| 1939 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1940 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1941 | forms_show_message(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1942 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1943 | char *a, *b, *c; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1944 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1945 | if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1946 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1947 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1948 | fl_show_message(a, b, c); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1949 | Py_END_ALLOW_THREADS |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1950 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1951 | Py_INCREF(Py_None); |
| 1952 | return Py_None; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1953 | } |
| 1954 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1955 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1956 | forms_show_choice(PyObject *f, PyObject *args) |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1957 | { |
| 1958 | char *m1, *m2, *m3, *b1, *b2, *b3; |
| 1959 | int nb; |
| 1960 | char *format; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1961 | long rv; |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1962 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1963 | if (args == NULL || !PyTuple_Check(args)) { |
| 1964 | PyErr_BadArgument(); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1965 | return NULL; |
| 1966 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1967 | nb = PyTuple_Size(args) - 3; |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1968 | if (nb <= 0) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1969 | PyErr_SetString(PyExc_TypeError, |
| 1970 | "need at least one button label"); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1971 | return NULL; |
| 1972 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1973 | if (PyInt_Check(PyTuple_GetItem(args, 3))) { |
| 1974 | PyErr_SetString(PyExc_TypeError, |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1975 | "'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. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1983 | PyErr_SetString(PyExc_TypeError, "too many button labels"); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1984 | return NULL; |
| 1985 | } |
| 1986 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1987 | if (!PyArg_Parse(args, format, &m1, &m2, &m3, &b1, &b2, &b3)) |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1988 | return NULL; |
| 1989 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1990 | Py_BEGIN_ALLOW_THREADS |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 1991 | rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1992 | Py_END_ALLOW_THREADS |
| 1993 | return PyInt_FromLong(rv); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1994 | } |
| 1995 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1996 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1997 | forms_show_question(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1998 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1999 | int ret; |
| 2000 | char *a, *b, *c; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2001 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2002 | if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2003 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2004 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2005 | ret = fl_show_question(a, b, c); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2006 | Py_END_ALLOW_THREADS |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2007 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2008 | return PyInt_FromLong((long) ret); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2009 | } |
| 2010 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2011 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2012 | forms_show_input(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2013 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2014 | char *str; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2015 | char *a, *b; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2016 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2017 | if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2018 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2019 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2020 | str = fl_show_input(a, b); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2021 | Py_END_ALLOW_THREADS |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2022 | |
| 2023 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2024 | Py_INCREF(Py_None); |
| 2025 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2026 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2027 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2028 | } |
| 2029 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2030 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2031 | forms_file_selector(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2032 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2033 | char *str; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2034 | char *a, *b, *c, *d; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2035 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2036 | if (!PyArg_Parse(args, "(ssss)", &a, &b, &c, &d)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2037 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2038 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2039 | str = fl_show_file_selector(a, b, c, d); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2040 | Py_END_ALLOW_THREADS |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2041 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2042 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2043 | Py_INCREF(Py_None); |
| 2044 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2045 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2046 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2050 | static PyObject * |
Thomas Wouters | bd4bc4e | 2000-07-22 23:57:55 +0000 | [diff] [blame] | 2051 | forms_file_selector_func(PyObject *args, char *(*func)(void)) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2052 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2053 | char *str; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2054 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2055 | str = (*func) (); |
| 2056 | |
| 2057 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2058 | Py_INCREF(Py_None); |
| 2059 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2060 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2061 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2062 | } |
| 2063 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2064 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2065 | forms_get_directory(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2066 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2067 | return forms_file_selector_func(args, fl_get_directory); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2068 | } |
| 2069 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2070 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2071 | forms_get_pattern(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2072 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2073 | return forms_file_selector_func(args, fl_get_pattern); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2074 | } |
| 2075 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2076 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2077 | forms_get_filename(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2078 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2079 | return forms_file_selector_func(args, fl_get_filename); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2080 | } |
| 2081 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2082 | static PyMethodDef forms_methods[] = { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2083 | /* adm */ |
| 2084 | {"make_form", forms_make_form}, |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 2085 | {"activate_all_forms", forms_activate_all_forms}, |
| 2086 | {"deactivate_all_forms",forms_deactivate_all_forms}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2087 | /* 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 Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2093 | /* {"blkqread", forms_blkqread}, */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2094 | {"qreset", forms_qreset}, |
| 2095 | {"qenter", forms_qenter}, |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2096 | {"get_mouse", forms_get_mouse}, |
| 2097 | {"tie", forms_tie}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2098 | /* {"new_events", forms_new_events}, */ |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2099 | {"color", forms_color}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2100 | {"mapcolor", forms_mapcolor}, |
| 2101 | {"getmcolor", forms_getmcolor}, |
| 2102 | /* interaction */ |
| 2103 | {"do_forms", forms_do_forms}, |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 2104 | {"do_only_forms", forms_do_only_forms}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2105 | {"check_forms", forms_check_forms}, |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 2106 | {"check_only_forms", forms_check_only_forms}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2107 | {"set_event_call_back", forms_set_event_call_back}, |
| 2108 | /* goodies */ |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2109 | {"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 Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 2118 | {"set_graphics_mode", forms_set_graphics_mode}, |
| 2119 | {"get_rgbmode", forms_get_rgbmode}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 2120 | {"show_errors", forms_show_errors}, |
| 2121 | {"set_font_name", forms_set_font_name}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2122 | {NULL, NULL} /* sentinel */ |
| 2123 | }; |
| 2124 | |
Guido van Rossum | 3886bb6 | 1998-12-04 18:50:17 +0000 | [diff] [blame] | 2125 | DL_EXPORT(void) |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 2126 | initfl(void) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2127 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2128 | Py_InitModule("fl", forms_methods); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2129 | foreground(); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 2130 | fl_init(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2131 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2132 | |
| 2133 | |
| 2134 | |