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 | |
Jeremy Hylton | 938ace6 | 2002-07-17 16:30:39 +0000 | [diff] [blame] | 32 | static 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 | { |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 151 | if (PyTuple_GET_SIZE(args) == 0) { |
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 { |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 158 | PyObject *a, *b; |
| 159 | if (!PyArg_UnpackTuple(args, "set_call_back", 2, 2, &a, &b) |
| 160 | return NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 161 | Py_XDECREF(g->ob_callback); |
| 162 | Py_XDECREF(g->ob_callback_arg); |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 163 | g->ob_callback = a; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 164 | Py_INCREF(g->ob_callback); |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 165 | g->ob_callback_arg = b; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 166 | Py_INCREF(g->ob_callback_arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 167 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 168 | Py_INCREF(Py_None); |
| 169 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 172 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 173 | generic_call(genericobject *g, void (*func)(FL_OBJECT *)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 174 | { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 175 | (*func)(g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 176 | Py_INCREF(Py_None); |
| 177 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 180 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 181 | generic_delete_object(genericobject *g) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 182 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 183 | PyObject *res; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 184 | res = generic_call(g, fl_delete_object); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 185 | if (res != NULL) |
| 186 | forgetgeneric(g); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 187 | return res; |
| 188 | } |
| 189 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 190 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 191 | generic_show_object(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 192 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 193 | return generic_call(g, fl_show_object); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 196 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 197 | generic_hide_object(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 198 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 199 | return generic_call(g, fl_hide_object); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 202 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 203 | generic_redraw_object(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 204 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 205 | return generic_call(g, fl_redraw_object); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 208 | #ifdef OBSOLETE_FORMS_CALLS |
| 209 | |
| 210 | /* (un)freeze_object() are obsolete in FORMS 2.2 and unsupported |
| 211 | in 2.3. Since there's no foolproof way to tell which version we're |
| 212 | using, we omit them unconditionally. */ |
| 213 | |
| 214 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 215 | generic_freeze_object(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 216 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 217 | return generic_call(g, fl_freeze_object); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 220 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 221 | generic_unfreeze_object(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 222 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 223 | return generic_call(g, fl_unfreeze_object); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 226 | #endif /* OBSOLETE_FORMS_CALLS */ |
| 227 | |
| 228 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 229 | generic_activate_object(genericobject *g) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 230 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 231 | return generic_call(g, fl_activate_object); |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 234 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 235 | generic_deactivate_object(genericobject *g) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 236 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 237 | return generic_call(g, fl_deactivate_object); |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 240 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 241 | generic_set_object_shortcut(genericobject *g, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 242 | { |
| 243 | char *str; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 244 | if (!PyArg_ParseTuple(args, "s:set_object_shortcut", &str)) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 245 | return NULL; |
| 246 | fl_set_object_shortcut(g->ob_generic, str); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 247 | Py_INCREF(Py_None); |
| 248 | return Py_None; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 251 | static PyMethodDef generic_methods[] = { |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 252 | {"set_call_back", (PyCFunction)generic_set_call_back, METH_VARARGS}, |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 253 | {"delete_object", (PyCFunction)generic_delete_object, METH_NOARGS}, |
| 254 | {"show_object", (PyCFunction)generic_show_object, METH_NOARGS}, |
| 255 | {"hide_object", (PyCFunction)generic_hide_object, METH_NOARGS}, |
| 256 | {"redraw_object", (PyCFunction)generic_redraw_object, METH_NOARGS}, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 257 | #ifdef OBSOLETE_FORMS_CALLS |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 258 | {"freeze_object", (PyCFunction)generic_freeze_object, METH_NOARGS}, |
| 259 | {"unfreeze_object", (PyCFunction)generic_unfreeze_object, METH_NOARGS}, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 260 | #endif |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 261 | {"activate_object", (PyCFunction)generic_activate_object, METH_NOARGS}, |
| 262 | {"deactivate_object", (PyCFunction)generic_deactivate_object, METH_NOARGS}, |
Georg Brandl | bf92f46 | 2006-05-29 21:58:42 +0000 | [diff] [blame] | 263 | {"set_object_shortcut", (PyCFunction)generic_set_object_shortcut, METH_VARARGS}, |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 264 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 268 | generic_dealloc(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 269 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 270 | fl_free_object(g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 271 | Py_XDECREF(g->ob_callback); |
| 272 | Py_XDECREF(g->ob_callback_arg); |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 273 | PyObject_Del(g); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | #define OFF(x) offsetof(FL_OBJECT, x) |
| 277 | |
| 278 | static struct memberlist generic_memberlist[] = { |
| 279 | {"objclass", T_INT, OFF(objclass), RO}, |
| 280 | {"type", T_INT, OFF(type), RO}, |
| 281 | {"boxtype", T_INT, OFF(boxtype)}, |
| 282 | {"x", T_FLOAT, OFF(x)}, |
| 283 | {"y", T_FLOAT, OFF(y)}, |
| 284 | {"w", T_FLOAT, OFF(w)}, |
| 285 | {"h", T_FLOAT, OFF(h)}, |
| 286 | {"col1", T_INT, OFF(col1)}, |
| 287 | {"col2", T_INT, OFF(col2)}, |
| 288 | {"align", T_INT, OFF(align)}, |
| 289 | {"lcol", T_INT, OFF(lcol)}, |
| 290 | {"lsize", T_FLOAT, OFF(lsize)}, |
| 291 | /* "label" is treated specially! */ |
| 292 | {"lstyle", T_INT, OFF(lstyle)}, |
| 293 | {"pushed", T_INT, OFF(pushed), RO}, |
| 294 | {"focus", T_INT, OFF(focus), RO}, |
| 295 | {"belowmouse", T_INT, OFF(belowmouse),RO}, |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 296 | /* {"frozen", T_INT, OFF(frozen), RO}, */ |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 297 | {"active", T_INT, OFF(active)}, |
| 298 | {"input", T_INT, OFF(input)}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 299 | {"visible", T_INT, OFF(visible), RO}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 300 | {"radio", T_INT, OFF(radio)}, |
| 301 | {"automatic", T_INT, OFF(automatic)}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 302 | {NULL} /* Sentinel */ |
| 303 | }; |
| 304 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 305 | #undef OFF |
| 306 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 307 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 308 | generic_getattr(genericobject *g, char *name) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 309 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 310 | PyObject *meth; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 311 | |
| 312 | /* XXX Ought to special-case name "__methods__" */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 313 | if (g-> ob_methods) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 314 | meth = Py_FindMethod(g->ob_methods, (PyObject *)g, name); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 315 | if (meth != NULL) return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 316 | PyErr_Clear(); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 317 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 318 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 319 | meth = Py_FindMethod(generic_methods, (PyObject *)g, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 320 | if (meth != NULL) |
| 321 | return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 322 | PyErr_Clear(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 323 | |
| 324 | /* "label" is an exception, getmember only works for char pointers, |
| 325 | not for char arrays */ |
| 326 | if (strcmp(name, "label") == 0) |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 327 | return PyString_FromString(g->ob_generic->label); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 328 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 329 | return PyMember_Get((char *)g->ob_generic, generic_memberlist, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | static int |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 333 | generic_setattr(genericobject *g, char *name, PyObject *v) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 334 | { |
| 335 | int ret; |
| 336 | |
| 337 | if (v == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 338 | PyErr_SetString(PyExc_TypeError, |
| 339 | "can't delete forms object attributes"); |
Guido van Rossum | 3dd8c98 | 1992-06-03 17:07:49 +0000 | [diff] [blame] | 340 | return -1; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* "label" is an exception: setmember doesn't set strings; |
| 344 | and FORMS wants you to call a function to set the label */ |
| 345 | if (strcmp(name, "label") == 0) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 346 | if (!PyString_Check(v)) { |
| 347 | PyErr_SetString(PyExc_TypeError, |
| 348 | "label attr must be string"); |
Guido van Rossum | 3dd8c98 | 1992-06-03 17:07:49 +0000 | [diff] [blame] | 349 | return -1; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 350 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 351 | fl_set_object_label(g->ob_generic, PyString_AsString(v)); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 352 | return 0; |
| 353 | } |
| 354 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 355 | ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 356 | |
| 357 | /* Rather than calling all the various set_object_* functions, |
| 358 | we call fl_redraw_object here. This is sometimes redundant |
| 359 | but I doubt that's a big problem */ |
| 360 | if (ret == 0) |
| 361 | fl_redraw_object(g->ob_generic); |
| 362 | |
| 363 | return ret; |
| 364 | } |
| 365 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 366 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 367 | generic_repr(genericobject *g) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 368 | { |
| 369 | char buf[100]; |
Tim Peters | 885d457 | 2001-11-28 20:27:42 +0000 | [diff] [blame] | 370 | PyOS_snprintf(buf, sizeof(buf), "<FORMS_object at %p, objclass=%d>", |
| 371 | g, g->ob_generic->objclass); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 372 | return PyString_FromString(buf); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 375 | static PyTypeObject GenericObjecttype = { |
| 376 | PyObject_HEAD_INIT(&PyType_Type) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 377 | 0, /*ob_size*/ |
Guido van Rossum | 1464839 | 2001-12-08 18:02:58 +0000 | [diff] [blame] | 378 | "fl.FORMS_object", /*tp_name*/ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 379 | sizeof(genericobject), /*tp_size*/ |
| 380 | 0, /*tp_itemsize*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 381 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 382 | (destructor)generic_dealloc, /*tp_dealloc*/ |
| 383 | 0, /*tp_print*/ |
| 384 | (getattrfunc)generic_getattr, /*tp_getattr*/ |
| 385 | (setattrfunc)generic_setattr, /*tp_setattr*/ |
| 386 | 0, /*tp_compare*/ |
| 387 | (reprfunc)generic_repr, /*tp_repr*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 388 | }; |
| 389 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 390 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 391 | newgenericobject(FL_OBJECT *generic, PyMethodDef *methods) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 392 | { |
| 393 | genericobject *g; |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 394 | g = PyObject_New(genericobject, &GenericObjecttype); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 395 | if (g == NULL) |
| 396 | return NULL; |
| 397 | g-> ob_generic = generic; |
| 398 | g->ob_methods = methods; |
| 399 | g->ob_callback = NULL; |
| 400 | g->ob_callback_arg = NULL; |
| 401 | knowgeneric(g); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 402 | return (PyObject *)g; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | /**********************************************************************/ |
| 406 | /* Some common calling sequences */ |
| 407 | |
| 408 | /* void func (object, float) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 409 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 410 | 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] | 411 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 412 | float parameter; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 413 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 414 | if (!PyArg_Parse(args, "f", ¶meter)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 415 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 416 | (*func) (obj, parameter); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 417 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 418 | Py_INCREF(Py_None); |
| 419 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | /* void func (object, float) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 423 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 424 | 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] | 425 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 426 | float par1, par2; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 427 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 428 | if (!PyArg_Parse(args, "(ff)", &par1, &par2)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 429 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 430 | (*func) (obj, par1, par2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 431 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 432 | Py_INCREF(Py_None); |
| 433 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | /* void func (object, int) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 437 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 438 | 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] | 439 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 440 | int parameter; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 441 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 442 | if (!PyArg_Parse(args, "i", ¶meter)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 443 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 444 | (*func) (obj, parameter); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 445 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 446 | Py_INCREF(Py_None); |
| 447 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 450 | /* void func (object, char) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 451 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 452 | 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] | 453 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 454 | char *a; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 455 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 456 | if (!PyArg_Parse(args, "s", &a)) return NULL; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 457 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 458 | (*func) (obj, a[0]); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 459 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 460 | Py_INCREF(Py_None); |
| 461 | return Py_None; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 464 | /* void func (object, string) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 465 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 466 | 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] | 467 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 468 | char *a; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 469 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 470 | if (!PyArg_Parse(args, "s", &a)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 471 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 472 | (*func) (obj, a); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 473 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 474 | Py_INCREF(Py_None); |
| 475 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 479 | /* void func (object, int, string) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 480 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 481 | 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] | 482 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 483 | char *b; |
| 484 | int a; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 485 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 486 | if (!PyArg_Parse(args, "(is)", &a, &b)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 487 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 488 | (*func) (obj, a, b); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 489 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 490 | Py_INCREF(Py_None); |
| 491 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 492 | } |
| 493 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 494 | #ifdef UNUSED |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 495 | /* void func (object, int, int) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 496 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 497 | 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] | 498 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 499 | int par1, par2; |
| 500 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 501 | if (!PyArg_Parse(args, "(ii)", &par1, &par2)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 502 | |
| 503 | (*func) (obj, par1, par2); |
| 504 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 505 | Py_INCREF(Py_None); |
| 506 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 507 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 508 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 509 | |
| 510 | /* int func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 511 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 512 | call_forms_Ri (int (*func)(FL_OBJECT *), FL_OBJECT *obj) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 513 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 514 | int retval; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 515 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 516 | retval = (*func) (obj); |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 517 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 518 | return PyInt_FromLong ((long) retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | /* char * func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 522 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 523 | call_forms_Rstr (char * (*func)(FL_OBJECT *), FL_OBJECT *obj) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 524 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 525 | char *str; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 526 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 527 | str = (*func) (obj); |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 528 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 529 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 530 | Py_INCREF(Py_None); |
| 531 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 532 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 533 | return PyString_FromString (str); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | /* int func (object) */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 537 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 538 | call_forms_Rf (float (*func)(FL_OBJECT *), FL_OBJECT *obj) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 539 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 540 | float retval; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 541 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 542 | retval = (*func) (obj); |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 543 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 544 | return PyFloat_FromDouble (retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 547 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 548 | call_forms_OUTfOUTf (void (*func)(FL_OBJECT *, float *, float *), FL_OBJECT *obj) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 549 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 550 | float f1, f2; |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 551 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 552 | (*func) (obj, &f1, &f2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 553 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 554 | return Py_BuildValue("(ff)", f1, f2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 555 | } |
| 556 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 557 | #ifdef UNUSED |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 558 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 559 | call_forms_OUTf (void (*func)(FL_OBJECT *, float *), FL_OBJECT *obj) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 560 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 561 | float f; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 562 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 563 | (*func) (obj, &f); |
| 564 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 565 | return PyFloat_FromDouble (f); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 566 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 567 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 568 | |
| 569 | /**********************************************************************/ |
| 570 | /* Class : browser */ |
| 571 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 572 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 573 | set_browser_topline(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 574 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 575 | 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] | 576 | } |
| 577 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 578 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 579 | clear_browser(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 580 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 581 | return generic_call (g, fl_clear_browser); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 582 | } |
| 583 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 584 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 585 | add_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 586 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 587 | 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] | 588 | } |
| 589 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 590 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 591 | addto_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 592 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 593 | return call_forms_INstr (fl_addto_browser, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 594 | } |
| 595 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 596 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 597 | insert_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 598 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 599 | return call_forms_INiINstr (fl_insert_browser_line, |
| 600 | 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 | delete_browser_line (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_INi (fl_delete_browser_line, 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 | replace_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_replace_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 | get_browser_line(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 618 | { |
| 619 | int i; |
| 620 | char *str; |
| 621 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 622 | if (!PyArg_Parse(args, "i", &i)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 623 | return NULL; |
| 624 | |
| 625 | str = fl_get_browser_line (g->ob_generic, i); |
| 626 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 627 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 628 | Py_INCREF(Py_None); |
| 629 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 630 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 631 | return PyString_FromString (str); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 632 | } |
| 633 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 634 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 635 | load_browser (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 636 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 637 | /* XXX strictly speaking this is wrong since fl_load_browser |
| 638 | XXX returns int, not void */ |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 639 | return call_forms_INstr (fl_load_browser, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 642 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 643 | get_browser_maxline(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 644 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 645 | return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 646 | } |
| 647 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 648 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 649 | select_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 650 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 651 | 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] | 652 | } |
| 653 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 654 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 655 | deselect_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 656 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 657 | 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] | 658 | } |
| 659 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 660 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 661 | deselect_browser (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 662 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 663 | return generic_call (g, fl_deselect_browser); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 664 | } |
| 665 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 666 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 667 | isselected_browser_line (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 668 | { |
| 669 | int i, j; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 670 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 671 | if (!PyArg_Parse(args, "i", &i)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 672 | return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 673 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 674 | j = fl_isselected_browser_line (g->ob_generic, i); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 675 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 676 | return PyInt_FromLong (j); |
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 * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 680 | get_browser (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 681 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 682 | return call_forms_Ri (fl_get_browser, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 683 | } |
| 684 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 685 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 686 | set_browser_fontsize (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 687 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 688 | 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] | 689 | } |
| 690 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 691 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 692 | set_browser_fontstyle (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 693 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 694 | 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] | 695 | } |
| 696 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 697 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 698 | set_browser_specialkey (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 699 | { |
| 700 | return call_forms_INc(fl_set_browser_specialkey, g-> ob_generic, args); |
| 701 | } |
| 702 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 703 | static PyMethodDef browser_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 704 | {"set_browser_topline", (PyCFunction)set_browser_topline, |
| 705 | METH_OLDARGS}, |
| 706 | {"clear_browser", (PyCFunction)clear_browser, |
| 707 | METH_NOARGS}, |
| 708 | {"add_browser_line", (PyCFunction)add_browser_line, |
| 709 | METH_OLDARGS}, |
| 710 | {"addto_browser", (PyCFunction)addto_browser, |
| 711 | METH_OLDARGS}, |
| 712 | {"insert_browser_line", (PyCFunction)insert_browser_line, |
| 713 | METH_OLDARGS}, |
| 714 | {"delete_browser_line", (PyCFunction)delete_browser_line, |
| 715 | METH_OLDARGS}, |
| 716 | {"replace_browser_line", (PyCFunction)replace_browser_line, |
| 717 | METH_OLDARGS}, |
| 718 | {"get_browser_line", (PyCFunction)get_browser_line, |
| 719 | METH_OLDARGS}, |
| 720 | {"load_browser", (PyCFunction)load_browser, |
| 721 | METH_OLDARGS}, |
| 722 | {"get_browser_maxline", (PyCFunction)get_browser_maxline, |
| 723 | METH_NOARGS,} |
| 724 | {"select_browser_line", (PyCFunction)select_browser_line, |
| 725 | METH_OLDARGS}, |
| 726 | {"deselect_browser_line", (PyCFunction)deselect_browser_line, |
| 727 | METH_OLDARGS}, |
| 728 | {"deselect_browser", (PyCFunction)deselect_browser, |
| 729 | METH_NOARGS,} |
| 730 | {"isselected_browser_line", (PyCFunction)isselected_browser_line, |
| 731 | METH_OLDARGS}, |
| 732 | {"get_browser", (PyCFunction)get_browser, |
| 733 | METH_NOARGS,} |
| 734 | {"set_browser_fontsize", (PyCFunction)set_browser_fontsize, |
| 735 | METH_OLDARGS}, |
| 736 | {"set_browser_fontstyle", (PyCFunction)set_browser_fontstyle, |
| 737 | METH_OLDARGS}, |
| 738 | {"set_browser_specialkey", (PyCFunction)set_browser_specialkey, |
| 739 | METH_OLDARGS}, |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 740 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 741 | }; |
| 742 | |
| 743 | /* Class: button */ |
| 744 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 745 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 746 | set_button(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 747 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 748 | return call_forms_INi (fl_set_button, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 749 | } |
| 750 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 751 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 752 | get_button(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 753 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 754 | return call_forms_Ri (fl_get_button, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 755 | } |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 756 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 757 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 758 | get_button_numb(genericobject *g) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 759 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 760 | return call_forms_Ri (fl_get_button_numb, g-> ob_generic); |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 761 | } |
| 762 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 763 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 764 | set_button_shortcut(genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 765 | { |
| 766 | return call_forms_INstr (fl_set_button_shortcut, g-> ob_generic, args); |
| 767 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 768 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 769 | static PyMethodDef button_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 770 | {"set_button", (PyCFunction)set_button, METH_OLDARGS}, |
| 771 | {"get_button", (PyCFunction)get_button, METH_NOARGS}, |
| 772 | {"get_button_numb", (PyCFunction)get_button_numb, METH_NOARGS}, |
| 773 | {"set_button_shortcut", (PyCFunction)set_button_shortcut, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 774 | {NULL, NULL} /* sentinel */ |
| 775 | }; |
| 776 | |
| 777 | /* Class: choice */ |
| 778 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 779 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 780 | set_choice(genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 781 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 782 | return call_forms_INi (fl_set_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 783 | } |
| 784 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 785 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 786 | get_choice(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 787 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 788 | return call_forms_Ri (fl_get_choice, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 791 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 792 | clear_choice (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 793 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 794 | return generic_call (g, fl_clear_choice); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 795 | } |
| 796 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 797 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 798 | addto_choice (genericobject *g, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 799 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 800 | return call_forms_INstr (fl_addto_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 803 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 804 | replace_choice (genericobject *g, PyObject *args) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 805 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 806 | return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 807 | } |
| 808 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 809 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 810 | delete_choice (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 811 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 812 | return call_forms_INi (fl_delete_choice, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 815 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 816 | get_choice_text (genericobject *g) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 817 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 818 | return call_forms_Rstr (fl_get_choice_text, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 819 | } |
| 820 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 821 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 822 | set_choice_fontsize (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 823 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 824 | 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] | 825 | } |
| 826 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 827 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 828 | set_choice_fontstyle (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 829 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 830 | 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] | 831 | } |
| 832 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 833 | static PyMethodDef choice_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 834 | {"set_choice", (PyCFunction)set_choice, METH_OLDARGS}, |
| 835 | {"get_choice", (PyCFunction)get_choice, METH_NOARGS}, |
| 836 | {"clear_choice", (PyCFunction)clear_choice, METH_NOARGS}, |
| 837 | {"addto_choice", (PyCFunction)addto_choice, METH_OLDARGS}, |
| 838 | {"replace_choice", (PyCFunction)replace_choice, METH_OLDARGS}, |
| 839 | {"delete_choice", (PyCFunction)delete_choice, METH_OLDARGS}, |
| 840 | {"get_choice_text", (PyCFunction)get_choice_text, METH_NOARGS}, |
| 841 | {"set_choice_fontsize", (PyCFunction)set_choice_fontsize, METH_OLDARGS}, |
| 842 | {"set_choice_fontstyle",(PyCFunction)set_choice_fontstyle, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 843 | {NULL, NULL} /* sentinel */ |
| 844 | }; |
| 845 | |
| 846 | /* Class : Clock */ |
| 847 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 848 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 849 | get_clock(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 850 | { |
| 851 | int i0, i1, i2; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 852 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 853 | fl_get_clock (g->ob_generic, &i0, &i1, &i2); |
| 854 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 855 | return Py_BuildValue("(iii)", i0, i1, i2); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 856 | } |
| 857 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 858 | static PyMethodDef clock_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 859 | {"get_clock", (PyCFunction)get_clock, METH_NOARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 860 | {NULL, NULL} /* sentinel */ |
| 861 | }; |
| 862 | |
| 863 | /* CLass : Counters */ |
| 864 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 865 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 866 | get_counter_value(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 867 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 868 | return call_forms_Rf (fl_get_counter_value, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 869 | } |
| 870 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 871 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 872 | set_counter_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 873 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 874 | 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] | 875 | } |
| 876 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 877 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 878 | set_counter_precision (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 879 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 880 | 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] | 881 | } |
| 882 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 883 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 884 | set_counter_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 885 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 886 | 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] | 887 | } |
| 888 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 889 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 890 | set_counter_step (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 891 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 892 | 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] | 893 | } |
| 894 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 895 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 896 | set_counter_return (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 897 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 898 | 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] | 899 | } |
| 900 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 901 | static PyMethodDef counter_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 902 | {"set_counter_value", (PyCFunction)set_counter_value, |
| 903 | METH_OLDARGS}, |
| 904 | {"get_counter_value", (PyCFunction)get_counter_value, |
| 905 | METH_NOARGS}, |
| 906 | {"set_counter_bounds", (PyCFunction)set_counter_bounds, |
| 907 | METH_OLDARGS}, |
| 908 | {"set_counter_step", (PyCFunction)set_counter_step, |
| 909 | METH_OLDARGS}, |
| 910 | {"set_counter_precision", (PyCFunction)set_counter_precision, |
| 911 | METH_OLDARGS}, |
| 912 | {"set_counter_return", (PyCFunction)set_counter_return, |
| 913 | METH_OLDARGS}, |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 914 | {NULL, NULL} /* sentinel */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 915 | }; |
| 916 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 917 | |
| 918 | /* Class: Dials */ |
| 919 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 920 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 921 | get_dial_value(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 922 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 923 | return call_forms_Rf (fl_get_dial_value, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 924 | } |
| 925 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 926 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 927 | set_dial_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 928 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 929 | 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] | 930 | } |
| 931 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 932 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 933 | set_dial_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 934 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 935 | 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] | 936 | } |
| 937 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 938 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 939 | get_dial_bounds (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 940 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 941 | return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 942 | } |
| 943 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 944 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 945 | set_dial_step (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 946 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 947 | 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] | 948 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 949 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 950 | static PyMethodDef dial_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 951 | {"set_dial_value", (PyCFunction)set_dial_value, METH_OLDARGS}, |
| 952 | {"get_dial_value", (PyCFunction)get_dial_value, METH_NOARGS}, |
| 953 | {"set_dial_bounds", (PyCFunction)set_dial_bounds, METH_OLDARGS}, |
| 954 | {"get_dial_bounds", (PyCFunction)get_dial_bounds, METH_NOARGS}, |
| 955 | {"set_dial_step", (PyCFunction)set_dial_step, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 956 | {NULL, NULL} /* sentinel */ |
| 957 | }; |
| 958 | |
| 959 | /* Class : Input */ |
| 960 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 961 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 962 | set_input (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 963 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 964 | return call_forms_INstr (fl_set_input, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 965 | } |
| 966 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 967 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 968 | get_input (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 969 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 970 | return call_forms_Rstr (fl_get_input, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 971 | } |
| 972 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 973 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 974 | set_input_color (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 975 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 976 | 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] | 977 | } |
| 978 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 979 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 980 | set_input_return (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 981 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 982 | 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] | 983 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 984 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 985 | static PyMethodDef input_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 986 | {"set_input", (PyCFunction)set_input, METH_OLDARGS}, |
| 987 | {"get_input", (PyCFunction)get_input, METH_NOARGS}, |
| 988 | {"set_input_color", (PyCFunction)set_input_color, METH_OLDARGS}, |
| 989 | {"set_input_return", (PyCFunction)set_input_return, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 990 | {NULL, NULL} /* sentinel */ |
| 991 | }; |
| 992 | |
| 993 | |
| 994 | /* Class : Menu */ |
| 995 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 996 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 997 | set_menu (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 998 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 999 | return call_forms_INstr (fl_set_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 * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1003 | get_menu (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1004 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 1005 | /* XXX strictly speaking this is wrong since fl_get_menu |
| 1006 | XXX returns long, not int */ |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1007 | return call_forms_Ri (fl_get_menu, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1010 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1011 | get_menu_text (genericobject *g) |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 1012 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1013 | return call_forms_Rstr (fl_get_menu_text, g-> ob_generic); |
Guido van Rossum | 8b17d6b | 1993-03-30 13:18:41 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1016 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1017 | addto_menu (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1018 | { |
Guido van Rossum | abe5835 | 1991-08-08 12:34:44 +0000 | [diff] [blame] | 1019 | return call_forms_INstr (fl_addto_menu, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1022 | static PyMethodDef menu_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1023 | {"set_menu", (PyCFunction)set_menu, METH_OLDARGS}, |
| 1024 | {"get_menu", (PyCFunction)get_menu, METH_NOARGS}, |
| 1025 | {"get_menu_text", (PyCFunction)get_menu_text, METH_NOARGS}, |
| 1026 | {"addto_menu", (PyCFunction)addto_menu, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1027 | {NULL, NULL} /* sentinel */ |
| 1028 | }; |
| 1029 | |
| 1030 | |
| 1031 | /* Class: Sliders */ |
| 1032 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1033 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1034 | get_slider_value(genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1035 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1036 | return call_forms_Rf (fl_get_slider_value, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1039 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1040 | set_slider_value (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1041 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1042 | 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] | 1043 | } |
| 1044 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1045 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1046 | set_slider_bounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1047 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1048 | 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] | 1049 | } |
| 1050 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1051 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1052 | get_slider_bounds (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1053 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1054 | return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1057 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1058 | set_slider_return (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1059 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1060 | 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] | 1061 | } |
| 1062 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1063 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1064 | set_slider_size (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1065 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1066 | 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] | 1067 | } |
| 1068 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1069 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1070 | set_slider_precision (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1071 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1072 | 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] | 1073 | } |
| 1074 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1075 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1076 | set_slider_step (genericobject *g, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1077 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1078 | 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] | 1079 | } |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1080 | |
| 1081 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1082 | static PyMethodDef slider_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1083 | {"set_slider_value", (PyCFunction)set_slider_value, METH_OLDARGS}, |
| 1084 | {"get_slider_value", (PyCFunction)get_slider_value, METH_NOARGS}, |
| 1085 | {"set_slider_bounds", (PyCFunction)set_slider_bounds, METH_OLDARGS}, |
| 1086 | {"get_slider_bounds", (PyCFunction)get_slider_bounds, METH_NOARGS}, |
| 1087 | {"set_slider_return", (PyCFunction)set_slider_return, METH_OLDARGS}, |
| 1088 | {"set_slider_size", (PyCFunction)set_slider_size, METH_OLDARGS}, |
| 1089 | {"set_slider_precision",(PyCFunction)set_slider_precision, METH_OLDARGS}, |
| 1090 | {"set_slider_step", (PyCFunction)set_slider_step, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1091 | {NULL, NULL} /* sentinel */ |
| 1092 | }; |
| 1093 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1094 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1095 | set_positioner_xvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1096 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1097 | 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] | 1098 | } |
| 1099 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1100 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1101 | set_positioner_xbounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1102 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1103 | return call_forms_INfINf (fl_set_positioner_xbounds, |
| 1104 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1107 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1108 | set_positioner_yvalue (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1109 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1110 | 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] | 1111 | } |
| 1112 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1113 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1114 | set_positioner_ybounds (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1115 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1116 | return call_forms_INfINf (fl_set_positioner_ybounds, |
| 1117 | g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1118 | } |
| 1119 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1120 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1121 | get_positioner_xvalue (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1122 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1123 | return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1126 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1127 | get_positioner_xbounds (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1128 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1129 | return call_forms_OUTfOUTf (fl_get_positioner_xbounds, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1132 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1133 | get_positioner_yvalue (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1134 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1135 | return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic); |
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 PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1139 | get_positioner_ybounds (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1140 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1141 | return call_forms_OUTfOUTf (fl_get_positioner_ybounds, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1142 | } |
| 1143 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1144 | static PyMethodDef positioner_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1145 | {"set_positioner_xvalue", (PyCFunction)set_positioner_xvalue, |
| 1146 | METH_OLDARGS}, |
| 1147 | {"set_positioner_yvalue", (PyCFunction)set_positioner_yvalue, |
| 1148 | METH_OLDARGS}, |
| 1149 | {"set_positioner_xbounds", (PyCFunction)set_positioner_xbounds, |
| 1150 | METH_OLDARGS}, |
| 1151 | {"set_positioner_ybounds", (PyCFunction)set_positioner_ybounds, |
| 1152 | METH_OLDARGS}, |
| 1153 | {"get_positioner_xvalue", (PyCFunction)get_positioner_xvalue, |
| 1154 | METH_NOARGS}, |
| 1155 | {"get_positioner_yvalue", (PyCFunction)get_positioner_yvalue, |
| 1156 | METH_NOARGS}, |
| 1157 | {"get_positioner_xbounds", (PyCFunction)get_positioner_xbounds, |
| 1158 | METH_NOARGS}, |
| 1159 | {"get_positioner_ybounds", (PyCFunction)get_positioner_ybounds, |
| 1160 | METH_NOARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1161 | {NULL, NULL} /* sentinel */ |
| 1162 | }; |
| 1163 | |
| 1164 | /* Class timer */ |
| 1165 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1166 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1167 | set_timer (genericobject *g, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1168 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1169 | return call_forms_INf (fl_set_timer, g-> ob_generic, args); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1172 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1173 | get_timer (genericobject *g) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1174 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1175 | return call_forms_Rf (fl_get_timer, g-> ob_generic); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1176 | } |
| 1177 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1178 | static PyMethodDef timer_methods[] = { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1179 | {"set_timer", (PyCFunction)set_timer, METH_OLDARGS}, |
| 1180 | {"get_timer", (PyCFunction)get_timer, METH_NOARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1181 | {NULL, NULL} /* sentinel */ |
| 1182 | }; |
| 1183 | |
| 1184 | /* Form objects */ |
| 1185 | |
| 1186 | typedef struct { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1187 | PyObject_HEAD |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1188 | FL_FORM *ob_form; |
| 1189 | } formobject; |
| 1190 | |
Jeremy Hylton | 938ace6 | 2002-07-17 16:30:39 +0000 | [diff] [blame] | 1191 | static PyTypeObject Formtype; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1192 | |
| 1193 | #define is_formobject(v) ((v)->ob_type == &Formtype) |
| 1194 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1195 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1196 | form_show_form(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1197 | { |
| 1198 | int place, border; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1199 | char *name; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1200 | if (!PyArg_Parse(args, "(iis)", &place, &border, &name)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1201 | return NULL; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1202 | fl_show_form(f->ob_form, place, border, name); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1203 | Py_INCREF(Py_None); |
| 1204 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1205 | } |
| 1206 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1207 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1208 | form_call(void (*func)(FL_FORM *), FL_FORM *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1209 | { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1210 | (*func)(f); |
| 1211 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1212 | Py_INCREF(Py_None); |
| 1213 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1216 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1217 | 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] | 1218 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1219 | int a, b; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1220 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1221 | if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1222 | |
| 1223 | (*func)(f, a, b); |
| 1224 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1225 | Py_INCREF(Py_None); |
| 1226 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1227 | } |
| 1228 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1229 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1230 | 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] | 1231 | { |
| 1232 | float a, b; |
| 1233 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1234 | if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1235 | |
| 1236 | (*func)(f, a, b); |
| 1237 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1238 | Py_INCREF(Py_None); |
| 1239 | return Py_None; |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1240 | } |
| 1241 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1242 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1243 | form_hide_form(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1244 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1245 | return form_call(fl_hide_form, f-> ob_form); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1246 | } |
| 1247 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1248 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1249 | form_redraw_form(formobject *f) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1250 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1251 | return form_call(fl_redraw_form, f-> ob_form); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 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_set_form_position(formobject *f, PyObject *args) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1256 | { |
| 1257 | return form_call_INiINi(fl_set_form_position, 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 | form_set_form_size(formobject *f, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1262 | { |
| 1263 | return form_call_INiINi(fl_set_form_size, f-> ob_form, args); |
| 1264 | } |
| 1265 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1266 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1267 | form_scale_form(formobject *f, PyObject *args) |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 1268 | { |
| 1269 | return form_call_INfINf(fl_scale_form, f-> ob_form, args); |
| 1270 | } |
| 1271 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1272 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1273 | 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] | 1274 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1275 | int type; |
| 1276 | float x, y, w, h; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1277 | char *name; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1278 | FL_OBJECT *obj; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1279 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1280 | if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name)) |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1281 | return NULL; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1282 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1283 | fl_addto_form (f-> ob_form); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1284 | |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1285 | obj = (*func) (type, x, y, w, h, name); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1286 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1287 | fl_end_form(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1288 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1289 | if (obj == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1290 | PyErr_NoMemory(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1291 | return NULL; |
| 1292 | } |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1293 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1294 | return newgenericobject (obj, internal_methods); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 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_button(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_button, 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_lightbutton(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_lightbutton, button_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_roundbutton(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_roundbutton, button_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_menu (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_menu, menu_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_slider(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_slider, slider_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_valslider(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_valslider, slider_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_dial(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_dial, dial_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_counter(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1341 | { |
| 1342 | return generic_add_object(f, args, fl_add_counter, counter_methods); |
| 1343 | } |
| 1344 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1345 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1346 | form_add_clock(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1347 | { |
| 1348 | return generic_add_object(f, args, fl_add_clock, clock_methods); |
| 1349 | } |
| 1350 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1351 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1352 | form_add_box(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1353 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1354 | return generic_add_object(f, args, fl_add_box, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1355 | (PyMethodDef *)NULL); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 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_choice(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1360 | { |
| 1361 | return generic_add_object(f, args, fl_add_choice, choice_methods); |
| 1362 | } |
| 1363 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1364 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1365 | form_add_browser(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1366 | { |
| 1367 | return generic_add_object(f, args, fl_add_browser, browser_methods); |
| 1368 | } |
| 1369 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1370 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1371 | form_add_positioner(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1372 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1373 | return generic_add_object(f, args, fl_add_positioner, |
| 1374 | positioner_methods); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1375 | } |
| 1376 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1377 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1378 | form_add_input(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1379 | { |
| 1380 | return generic_add_object(f, args, fl_add_input, input_methods); |
| 1381 | } |
| 1382 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1383 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1384 | form_add_text(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1385 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1386 | return generic_add_object(f, args, fl_add_text, |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1387 | (PyMethodDef *)NULL); |
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_add_timer(formobject *f, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1392 | { |
| 1393 | return generic_add_object(f, args, fl_add_timer, timer_methods); |
| 1394 | } |
| 1395 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1396 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1397 | form_freeze_form(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1398 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1399 | return form_call(fl_freeze_form, f-> ob_form); |
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 * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1403 | form_unfreeze_form(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1404 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1405 | return form_call(fl_unfreeze_form, f-> ob_form); |
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 * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1409 | form_activate_form(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1410 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1411 | return form_call(fl_activate_form, f-> ob_form); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1412 | } |
| 1413 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1414 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1415 | form_deactivate_form(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1416 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1417 | return form_call(fl_deactivate_form, f-> ob_form); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1418 | } |
| 1419 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1420 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1421 | form_bgn_group(formobject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1422 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1423 | FL_OBJECT *obj; |
| 1424 | |
| 1425 | fl_addto_form(f-> ob_form); |
| 1426 | obj = fl_bgn_group(); |
| 1427 | fl_end_form(); |
| 1428 | |
| 1429 | if (obj == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1430 | PyErr_NoMemory(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1431 | return NULL; |
| 1432 | } |
| 1433 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1434 | return newgenericobject (obj, (PyMethodDef *) NULL); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1437 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1438 | form_end_group(formobject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1439 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1440 | fl_addto_form(f-> ob_form); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1441 | fl_end_group(); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1442 | fl_end_form(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1443 | Py_INCREF(Py_None); |
| 1444 | return Py_None; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1445 | } |
| 1446 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1447 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1448 | 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] | 1449 | { |
| 1450 | int type; |
| 1451 | float mx, my; |
| 1452 | FL_OBJECT *generic; |
| 1453 | genericobject *g; |
| 1454 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1455 | if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1456 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1457 | generic = (*func) (f-> ob_form, type, mx, my); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1458 | |
| 1459 | if (generic == NULL) |
| 1460 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1461 | Py_INCREF(Py_None); |
| 1462 | return Py_None; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | g = findgeneric(generic); |
| 1466 | if (g == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1467 | PyErr_SetString(PyExc_RuntimeError, |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1468 | "forms_find_{first|last} returns unknown object"); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1469 | return NULL; |
| 1470 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1471 | Py_INCREF(g); |
| 1472 | return (PyObject *) g; |
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_find_first(formobject *f, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1477 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1478 | return forms_find_first_or_last(fl_find_first, f, args); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1479 | } |
| 1480 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1481 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1482 | form_find_last(formobject *f, PyObject *args) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1483 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1484 | return forms_find_first_or_last(fl_find_last, f, args); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1487 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1488 | form_set_object_focus(formobject *f, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1489 | { |
| 1490 | genericobject *g; |
| 1491 | if (args == NULL || !is_genericobject(args)) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1492 | PyErr_BadArgument(); |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1493 | return NULL; |
| 1494 | } |
| 1495 | g = (genericobject *)args; |
| 1496 | fl_set_object_focus(f->ob_form, g->ob_generic); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1497 | Py_INCREF(Py_None); |
| 1498 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1499 | } |
| 1500 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1501 | static PyMethodDef form_methods[] = { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1502 | /* adm */ |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1503 | {"show_form", (PyCFunction)form_show_form, METH_OLDARGS}, |
| 1504 | {"hide_form", (PyCFunction)form_hide_form, METH_NOARGS}, |
| 1505 | {"redraw_form", (PyCFunction)form_redraw_form, METH_NOARGS}, |
| 1506 | {"set_form_position", (PyCFunction)form_set_form_position, METH_OLDARGS}, |
| 1507 | {"set_form_size", (PyCFunction)form_set_form_size, METH_OLDARGS}, |
| 1508 | {"scale_form", (PyCFunction)form_scale_form, METH_OLDARGS}, |
| 1509 | {"freeze_form", (PyCFunction)form_freeze_form, METH_NOARGS}, |
| 1510 | {"unfreeze_form", (PyCFunction)form_unfreeze_form, METH_NOARGS}, |
| 1511 | {"activate_form", (PyCFunction)form_activate_form, METH_NOARGS}, |
| 1512 | {"deactivate_form", (PyCFunction)form_deactivate_form, METH_NOARGS}, |
| 1513 | {"bgn_group", (PyCFunction)form_bgn_group, METH_OLDARGS}, |
| 1514 | {"end_group", (PyCFunction)form_end_group, METH_OLDARGS}, |
| 1515 | {"find_first", (PyCFunction)form_find_first, METH_OLDARGS}, |
| 1516 | {"find_last", (PyCFunction)form_find_last, METH_OLDARGS}, |
| 1517 | {"set_object_focus", (PyCFunction)form_set_object_focus, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1518 | |
| 1519 | /* basic objects */ |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1520 | {"add_button", (PyCFunction)form_add_button, METH_OLDARGS}, |
| 1521 | /* {"add_bitmap", (method)form_add_bitmap, METH_OLDARGS}, */ |
| 1522 | {"add_lightbutton", (PyCFunction)form_add_lightbutton, METH_OLDARGS}, |
| 1523 | {"add_roundbutton", (PyCFunction)form_add_roundbutton, METH_OLDARGS}, |
| 1524 | {"add_menu", (PyCFunction)form_add_menu, METH_OLDARGS}, |
| 1525 | {"add_slider", (PyCFunction)form_add_slider, METH_OLDARGS}, |
| 1526 | {"add_positioner", (PyCFunction)form_add_positioner, METH_OLDARGS}, |
| 1527 | {"add_valslider", (PyCFunction)form_add_valslider, METH_OLDARGS}, |
| 1528 | {"add_dial", (PyCFunction)form_add_dial, METH_OLDARGS}, |
| 1529 | {"add_counter", (PyCFunction)form_add_counter, METH_OLDARGS}, |
| 1530 | {"add_box", (PyCFunction)form_add_box, METH_OLDARGS}, |
| 1531 | {"add_clock", (PyCFunction)form_add_clock, METH_OLDARGS}, |
| 1532 | {"add_choice", (PyCFunction)form_add_choice, METH_OLDARGS}, |
| 1533 | {"add_browser", (PyCFunction)form_add_browser, METH_OLDARGS}, |
| 1534 | {"add_input", (PyCFunction)form_add_input, METH_OLDARGS}, |
| 1535 | {"add_timer", (PyCFunction)form_add_timer, METH_OLDARGS}, |
| 1536 | {"add_text", (PyCFunction)form_add_text, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1537 | {NULL, NULL} /* sentinel */ |
| 1538 | }; |
| 1539 | |
| 1540 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1541 | form_dealloc(formobject *f) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1542 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1543 | releaseobjects(f->ob_form); |
Guido van Rossum | 336b591 | 1992-04-08 11:16:25 +0000 | [diff] [blame] | 1544 | if (f->ob_form->visible) |
| 1545 | fl_hide_form(f->ob_form); |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1546 | fl_free_form(f->ob_form); |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 1547 | PyObject_Del(f); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1548 | } |
| 1549 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 1550 | #define OFF(x) offsetof(FL_FORM, x) |
| 1551 | |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1552 | static struct memberlist form_memberlist[] = { |
| 1553 | {"window", T_LONG, OFF(window), RO}, |
| 1554 | {"w", T_FLOAT, OFF(w)}, |
| 1555 | {"h", T_FLOAT, OFF(h)}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1556 | {"x", T_FLOAT, OFF(x), RO}, |
| 1557 | {"y", T_FLOAT, OFF(y), RO}, |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1558 | {"deactivated", T_INT, OFF(deactivated)}, |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1559 | {"visible", T_INT, OFF(visible), RO}, |
| 1560 | {"frozen", T_INT, OFF(frozen), RO}, |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1561 | {"doublebuf", T_INT, OFF(doublebuf)}, |
| 1562 | {NULL} /* Sentinel */ |
| 1563 | }; |
| 1564 | |
Guido van Rossum | d97f048 | 1991-11-19 20:26:28 +0000 | [diff] [blame] | 1565 | #undef OFF |
| 1566 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1567 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1568 | form_getattr(formobject *f, char *name) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1569 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1570 | PyObject *meth; |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1571 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1572 | meth = Py_FindMethod(form_methods, (PyObject *)f, name); |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1573 | if (meth != NULL) |
| 1574 | return meth; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1575 | PyErr_Clear(); |
| 1576 | return PyMember_Get((char *)f->ob_form, form_memberlist, name); |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | static int |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1580 | form_setattr(formobject *f, char *name, PyObject *v) |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1581 | { |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1582 | if (v == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1583 | PyErr_SetString(PyExc_TypeError, |
| 1584 | "can't delete form attributes"); |
Guido van Rossum | 3863abb | 1996-09-11 23:31:07 +0000 | [diff] [blame] | 1585 | return -1; |
Guido van Rossum | 32db5e3 | 1991-11-12 15:43:18 +0000 | [diff] [blame] | 1586 | } |
| 1587 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1588 | return PyMember_Set((char *)f->ob_form, form_memberlist, name, v); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1589 | } |
| 1590 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1591 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1592 | form_repr(formobject *f) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1593 | { |
| 1594 | char buf[100]; |
Tim Peters | 885d457 | 2001-11-28 20:27:42 +0000 | [diff] [blame] | 1595 | PyOS_snprintf(buf, sizeof(buf), "<FORMS_form at %p, window=%ld>", |
| 1596 | f, f->ob_form->window); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1597 | return PyString_FromString(buf); |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1598 | } |
| 1599 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1600 | static PyTypeObject Formtype = { |
| 1601 | PyObject_HEAD_INIT(&PyType_Type) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1602 | 0, /*ob_size*/ |
Guido van Rossum | 1464839 | 2001-12-08 18:02:58 +0000 | [diff] [blame] | 1603 | "fl.FORMS_form", /*tp_name*/ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1604 | sizeof(formobject), /*tp_size*/ |
| 1605 | 0, /*tp_itemsize*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1606 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 1607 | (destructor)form_dealloc, /*tp_dealloc*/ |
| 1608 | 0, /*tp_print*/ |
| 1609 | (getattrfunc)form_getattr, /*tp_getattr*/ |
| 1610 | (setattrfunc)form_setattr, /*tp_setattr*/ |
| 1611 | 0, /*tp_compare*/ |
| 1612 | (reprfunc)form_repr, /*tp_repr*/ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1613 | }; |
| 1614 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1615 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1616 | newformobject(FL_FORM *form) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1617 | { |
| 1618 | formobject *f; |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 1619 | f = PyObject_New(formobject, &Formtype); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1620 | if (f == NULL) |
| 1621 | return NULL; |
| 1622 | f->ob_form = form; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1623 | return (PyObject *)f; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1624 | } |
| 1625 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1626 | |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1627 | /* The "fl" module */ |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1628 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1629 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1630 | forms_make_form(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1631 | { |
| 1632 | int type; |
| 1633 | float w, h; |
| 1634 | FL_FORM *form; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1635 | if (!PyArg_Parse(args, "(iff)", &type, &w, &h)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1636 | return NULL; |
| 1637 | form = fl_bgn_form(type, w, h); |
| 1638 | if (form == NULL) { |
| 1639 | /* XXX Actually, cannot happen! */ |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1640 | PyErr_NoMemory(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1641 | return NULL; |
| 1642 | } |
| 1643 | fl_end_form(); |
| 1644 | return newformobject(form); |
| 1645 | } |
| 1646 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1647 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1648 | forms_activate_all_forms(PyObject *f, PyObject *args) |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1649 | { |
| 1650 | fl_activate_all_forms(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1651 | Py_INCREF(Py_None); |
| 1652 | return Py_None; |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1653 | } |
| 1654 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1655 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1656 | forms_deactivate_all_forms(PyObject *f, PyObject *args) |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1657 | { |
| 1658 | fl_deactivate_all_forms(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1659 | Py_INCREF(Py_None); |
| 1660 | return Py_None; |
Guido van Rossum | 2bac4d3 | 1992-03-27 17:20:21 +0000 | [diff] [blame] | 1661 | } |
| 1662 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1663 | static PyObject *my_event_callback = NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1664 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1665 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1666 | forms_set_event_call_back(PyObject *dummy, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1667 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1668 | if (args == Py_None) |
Guido van Rossum | f6da4f6 | 1993-07-26 15:24:57 +0000 | [diff] [blame] | 1669 | args = NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1670 | my_event_callback = args; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1671 | Py_XINCREF(args); |
| 1672 | Py_INCREF(Py_None); |
| 1673 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1674 | } |
| 1675 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1676 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1677 | forms_do_or_check_forms(PyObject *dummy, FL_OBJECT *(*func)(void)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1678 | { |
| 1679 | FL_OBJECT *generic; |
| 1680 | genericobject *g; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1681 | PyObject *arg, *res; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1682 | |
| 1683 | for (;;) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1684 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1685 | generic = (*func)(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1686 | Py_END_ALLOW_THREADS |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1687 | if (generic == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1688 | Py_INCREF(Py_None); |
| 1689 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1690 | } |
| 1691 | if (generic == FL_EVENT) { |
| 1692 | int dev; |
| 1693 | short val; |
| 1694 | if (my_event_callback == NULL) |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1695 | return PyInt_FromLong(-1L); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1696 | dev = fl_qread(&val); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1697 | arg = Py_BuildValue("(ih)", dev, val); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1698 | if (arg == NULL) |
| 1699 | return NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1700 | res = PyEval_CallObject(my_event_callback, arg); |
| 1701 | Py_XDECREF(res); |
| 1702 | Py_DECREF(arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1703 | if (res == NULL) |
| 1704 | return NULL; /* Callback raised exception */ |
| 1705 | continue; |
| 1706 | } |
| 1707 | g = findgeneric(generic); |
| 1708 | if (g == NULL) { |
Guido van Rossum | a9e7dc1 | 1992-10-18 18:53:57 +0000 | [diff] [blame] | 1709 | /* Object not known to us (some dialogs cause this) */ |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1710 | continue; /* Ignore it */ |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1711 | } |
| 1712 | if (g->ob_callback == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1713 | Py_INCREF(g); |
| 1714 | return ((PyObject *) g); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1715 | } |
Raymond Hettinger | 8ae4689 | 2003-10-12 19:09:37 +0000 | [diff] [blame] | 1716 | arg = PyTuple_Pack(2, (PyObject *)g, g->ob_callback_arg); |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1717 | if (arg == NULL) |
| 1718 | return NULL; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1719 | res = PyEval_CallObject(g->ob_callback, arg); |
| 1720 | Py_XDECREF(res); |
| 1721 | Py_DECREF(arg); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1722 | if (res == NULL) |
| 1723 | return NULL; /* Callback raised exception */ |
| 1724 | } |
| 1725 | } |
| 1726 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1727 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1728 | forms_do_forms(PyObject *dummy) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1729 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1730 | return forms_do_or_check_forms(dummy, fl_do_forms); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1731 | } |
| 1732 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1733 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1734 | forms_check_forms(PyObject *dummy) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1735 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1736 | return forms_do_or_check_forms(dummy, fl_check_forms); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1737 | } |
| 1738 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1739 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1740 | forms_do_only_forms(PyObject *dummy) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1741 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1742 | return forms_do_or_check_forms(dummy, fl_do_only_forms); |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1743 | } |
| 1744 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1745 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1746 | forms_check_only_forms(PyObject *dummy) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1747 | { |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1748 | return forms_do_or_check_forms(dummy, fl_check_only_forms); |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1749 | } |
| 1750 | |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1751 | #ifdef UNUSED |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1752 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1753 | fl_call(void (*func)(void)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1754 | { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1755 | (*func)(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1756 | Py_INCREF(Py_None); |
| 1757 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1758 | } |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1759 | #endif |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1760 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1761 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1762 | forms_set_graphics_mode(PyObject *dummy, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1763 | { |
| 1764 | int rgbmode, doublebuf; |
| 1765 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1766 | if (!PyArg_Parse(args, "(ii)", &rgbmode, &doublebuf)) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1767 | return NULL; |
| 1768 | fl_set_graphics_mode(rgbmode,doublebuf); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1769 | Py_INCREF(Py_None); |
| 1770 | return Py_None; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1771 | } |
| 1772 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1773 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1774 | forms_get_rgbmode(PyObject *dummy, PyObject *args) |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1775 | { |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1776 | extern int fl_rgbmode; |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1777 | |
| 1778 | if (args != NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1779 | PyErr_BadArgument(); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1780 | return NULL; |
| 1781 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1782 | return PyInt_FromLong((long)fl_rgbmode); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1783 | } |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1784 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1785 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1786 | forms_show_errors(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1787 | { |
| 1788 | int show; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1789 | if (!PyArg_Parse(args, "i", &show)) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1790 | return NULL; |
| 1791 | fl_show_errors(show); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1792 | Py_INCREF(Py_None); |
| 1793 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1794 | } |
| 1795 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1796 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1797 | forms_set_font_name(PyObject *dummy, PyObject *args) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1798 | { |
| 1799 | int numb; |
| 1800 | char *name; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1801 | if (!PyArg_Parse(args, "(is)", &numb, &name)) |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1802 | return NULL; |
| 1803 | fl_set_font_name(numb, name); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1804 | Py_INCREF(Py_None); |
| 1805 | return Py_None; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1806 | } |
| 1807 | |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 1808 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1809 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1810 | forms_qdevice(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1811 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1812 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1813 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1814 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1815 | fl_qdevice(arg1); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1816 | Py_INCREF(Py_None); |
| 1817 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1818 | } |
| 1819 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1820 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1821 | forms_unqdevice(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1822 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1823 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1824 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1825 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1826 | fl_unqdevice(arg1); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1827 | Py_INCREF(Py_None); |
| 1828 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1829 | } |
| 1830 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1831 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1832 | forms_isqueued(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1833 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1834 | long retval; |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1835 | short arg1; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1836 | if (!PyArg_Parse(args, "h", &arg1)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1837 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1838 | retval = fl_isqueued(arg1); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1839 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1840 | return PyInt_FromLong(retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1841 | } |
| 1842 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1843 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1844 | forms_qtest(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1845 | { |
| 1846 | long retval; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1847 | retval = fl_qtest(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1848 | return PyInt_FromLong(retval); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1852 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1853 | forms_qread(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1854 | { |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1855 | int dev; |
| 1856 | short val; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1857 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1858 | dev = fl_qread(&val); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1859 | Py_END_ALLOW_THREADS |
| 1860 | return Py_BuildValue("(ih)", dev, val); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1861 | } |
| 1862 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1863 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1864 | forms_qreset(PyObject *self) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1865 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1866 | fl_qreset(); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1867 | Py_INCREF(Py_None); |
| 1868 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1869 | } |
| 1870 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1871 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1872 | forms_qenter(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1873 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1874 | short arg1, arg2; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1875 | if (!PyArg_Parse(args, "(hh)", &arg1, &arg2)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1876 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1877 | fl_qenter(arg1, arg2); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1878 | Py_INCREF(Py_None); |
| 1879 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1880 | } |
| 1881 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1882 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1883 | forms_color(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1884 | { |
| 1885 | int arg; |
| 1886 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1887 | if (!PyArg_Parse(args, "i", &arg)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1888 | |
| 1889 | fl_color((short) arg); |
| 1890 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1891 | Py_INCREF(Py_None); |
| 1892 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1893 | } |
| 1894 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1895 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1896 | forms_mapcolor(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1897 | { |
| 1898 | int arg0, arg1, arg2, arg3; |
| 1899 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1900 | if (!PyArg_Parse(args, "(iiii)", &arg0, &arg1, &arg2, &arg3)) |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1901 | return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1902 | |
| 1903 | fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3); |
| 1904 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1905 | Py_INCREF(Py_None); |
| 1906 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1907 | } |
| 1908 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1909 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1910 | forms_getmcolor(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1911 | { |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1912 | int arg; |
| 1913 | short r, g, b; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1914 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1915 | if (!PyArg_Parse(args, "i", &arg)) return NULL; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1916 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1917 | fl_getmcolor(arg, &r, &g, &b); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1918 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1919 | return Py_BuildValue("(hhh)", r, g, b); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1920 | } |
| 1921 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1922 | static PyObject * |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 1923 | forms_get_mouse(PyObject *self) |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1924 | { |
Guido van Rossum | e537240 | 1993-03-16 12:15:04 +0000 | [diff] [blame] | 1925 | float x, y; |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1926 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1927 | fl_get_mouse(&x, &y); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1928 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1929 | return Py_BuildValue("(ff)", x, y); |
Guido van Rossum | 75cc898 | 1991-08-08 12:07:45 +0000 | [diff] [blame] | 1930 | } |
| 1931 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1932 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1933 | forms_tie(PyObject *self, PyObject *args) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1934 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 1935 | short arg1, arg2, arg3; |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1936 | if (!PyArg_Parse(args, "(hhh)", &arg1, &arg2, &arg3)) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1937 | return NULL; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 1938 | fl_tie(arg1, arg2, arg3); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1939 | Py_INCREF(Py_None); |
| 1940 | return Py_None; |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 1941 | } |
| 1942 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1943 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1944 | forms_show_message(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1945 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1946 | char *a, *b, *c; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1947 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1948 | if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1949 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1950 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 1951 | fl_show_message(a, b, c); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1952 | Py_END_ALLOW_THREADS |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1953 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1954 | Py_INCREF(Py_None); |
| 1955 | return Py_None; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 1956 | } |
| 1957 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1958 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 1959 | forms_show_choice(PyObject *f, PyObject *args) |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1960 | { |
| 1961 | char *m1, *m2, *m3, *b1, *b2, *b3; |
| 1962 | int nb; |
| 1963 | char *format; |
Guido van Rossum | 7066dd7 | 1992-09-17 17:54:56 +0000 | [diff] [blame] | 1964 | long rv; |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1965 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1966 | if (args == NULL || !PyTuple_Check(args)) { |
| 1967 | PyErr_BadArgument(); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1968 | return NULL; |
| 1969 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1970 | nb = PyTuple_Size(args) - 3; |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1971 | if (nb <= 0) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1972 | PyErr_SetString(PyExc_TypeError, |
| 1973 | "need at least one button label"); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1974 | return NULL; |
| 1975 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1976 | if (PyInt_Check(PyTuple_GetItem(args, 3))) { |
| 1977 | PyErr_SetString(PyExc_TypeError, |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1978 | "'number-of-buttons' argument not needed"); |
| 1979 | return NULL; |
| 1980 | } |
| 1981 | switch (nb) { |
| 1982 | case 1: format = "(ssss)"; break; |
| 1983 | case 2: format = "(sssss)"; break; |
| 1984 | case 3: format = "(ssssss)"; break; |
| 1985 | default: |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1986 | PyErr_SetString(PyExc_TypeError, "too many button labels"); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1987 | return NULL; |
| 1988 | } |
| 1989 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1990 | if (!PyArg_Parse(args, format, &m1, &m2, &m3, &b1, &b2, &b3)) |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1991 | return NULL; |
| 1992 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1993 | Py_BEGIN_ALLOW_THREADS |
Jack Jansen | 743db36 | 1992-08-13 14:13:11 +0000 | [diff] [blame] | 1994 | rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1995 | Py_END_ALLOW_THREADS |
| 1996 | return PyInt_FromLong(rv); |
Guido van Rossum | b3a0e4c | 1992-03-23 18:20:54 +0000 | [diff] [blame] | 1997 | } |
| 1998 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 1999 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2000 | forms_show_question(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2001 | { |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2002 | int ret; |
| 2003 | char *a, *b, *c; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2004 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2005 | if (!PyArg_Parse(args, "(sss)", &a, &b, &c)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2006 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2007 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2008 | ret = fl_show_question(a, b, c); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2009 | Py_END_ALLOW_THREADS |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2010 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2011 | return PyInt_FromLong((long) ret); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2012 | } |
| 2013 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2014 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2015 | forms_show_input(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2016 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2017 | char *str; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2018 | char *a, *b; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2019 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2020 | if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2021 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2022 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2023 | str = fl_show_input(a, b); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2024 | Py_END_ALLOW_THREADS |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2025 | |
| 2026 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2027 | Py_INCREF(Py_None); |
| 2028 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2029 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2030 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2031 | } |
| 2032 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2033 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2034 | forms_file_selector(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2035 | { |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2036 | char *str; |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2037 | char *a, *b, *c, *d; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2038 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2039 | if (!PyArg_Parse(args, "(ssss)", &a, &b, &c, &d)) return NULL; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2040 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2041 | Py_BEGIN_ALLOW_THREADS |
Guido van Rossum | fc58e58 | 1992-01-27 16:45:55 +0000 | [diff] [blame] | 2042 | str = fl_show_file_selector(a, b, c, d); |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2043 | Py_END_ALLOW_THREADS |
Guido van Rossum | aa7ca2d | 1992-09-03 20:37:02 +0000 | [diff] [blame] | 2044 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2045 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2046 | Py_INCREF(Py_None); |
| 2047 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2048 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2049 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2050 | } |
| 2051 | |
| 2052 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2053 | static PyObject * |
Thomas Wouters | bd4bc4e | 2000-07-22 23:57:55 +0000 | [diff] [blame] | 2054 | forms_file_selector_func(PyObject *args, char *(*func)(void)) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2055 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2056 | char *str; |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2057 | |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2058 | str = (*func) (); |
| 2059 | |
| 2060 | if (str == NULL) { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2061 | Py_INCREF(Py_None); |
| 2062 | return Py_None; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2063 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2064 | return PyString_FromString(str); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2065 | } |
| 2066 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2067 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2068 | forms_get_directory(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2069 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2070 | return forms_file_selector_func(args, fl_get_directory); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2071 | } |
| 2072 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2073 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2074 | forms_get_pattern(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2075 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2076 | return forms_file_selector_func(args, fl_get_pattern); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2077 | } |
| 2078 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2079 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 2080 | forms_get_filename(PyObject *f, PyObject *args) |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2081 | { |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2082 | return forms_file_selector_func(args, fl_get_filename); |
Guido van Rossum | 0374711 | 1991-08-08 12:10:01 +0000 | [diff] [blame] | 2083 | } |
| 2084 | |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2085 | static PyMethodDef forms_methods[] = { |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2086 | /* adm */ |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2087 | {"make_form", forms_make_form, METH_OLDARGS}, |
| 2088 | {"activate_all_forms", forms_activate_all_forms, METH_OLDARGS}, |
| 2089 | {"deactivate_all_forms",forms_deactivate_all_forms, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2090 | /* gl support wrappers */ |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2091 | {"qdevice", forms_qdevice, METH_OLDARGS}, |
| 2092 | {"unqdevice", forms_unqdevice, METH_OLDARGS}, |
| 2093 | {"isqueued", forms_isqueued, METH_OLDARGS}, |
| 2094 | {"qtest", forms_qtest, METH_OLDARGS}, |
| 2095 | {"qread", forms_qread, METH_OLDARGS}, |
| 2096 | /* {"blkqread", forms_blkqread, METH_OLDARGS}, */ |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 2097 | {"qreset", forms_qreset, METH_NOARGS}, |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2098 | {"qenter", forms_qenter, METH_OLDARGS}, |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 2099 | {"get_mouse", forms_get_mouse, METH_NOARGS}, |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2100 | {"tie", forms_tie, METH_OLDARGS}, |
| 2101 | /* {"new_events", forms_new_events, METH_OLDARGS}, */ |
| 2102 | {"color", forms_color, METH_OLDARGS}, |
| 2103 | {"mapcolor", forms_mapcolor, METH_OLDARGS}, |
| 2104 | {"getmcolor", forms_getmcolor, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2105 | /* interaction */ |
Neal Norwitz | 28faa1b | 2002-03-31 15:56:56 +0000 | [diff] [blame] | 2106 | {"do_forms", forms_do_forms, METH_NOARGS}, |
| 2107 | {"do_only_forms", forms_do_only_forms, METH_NOARGS}, |
| 2108 | {"check_forms", forms_check_forms, METH_NOARGS}, |
| 2109 | {"check_only_forms", forms_check_only_forms, METH_NOARGS}, |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2110 | {"set_event_call_back", forms_set_event_call_back, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2111 | /* goodies */ |
Martin v. Löwis | 43b936d | 2002-01-17 23:15:58 +0000 | [diff] [blame] | 2112 | {"show_message", forms_show_message, METH_OLDARGS}, |
| 2113 | {"show_question", forms_show_question, METH_OLDARGS}, |
| 2114 | {"show_choice", forms_show_choice, METH_OLDARGS}, |
| 2115 | {"show_input", forms_show_input, METH_OLDARGS}, |
| 2116 | {"show_file_selector", forms_file_selector, METH_OLDARGS}, |
| 2117 | {"file_selector", forms_file_selector, METH_OLDARGS}, /* BW compat */ |
| 2118 | {"get_directory", forms_get_directory, METH_OLDARGS}, |
| 2119 | {"get_pattern", forms_get_pattern, METH_OLDARGS}, |
| 2120 | {"get_filename", forms_get_filename, METH_OLDARGS}, |
| 2121 | {"set_graphics_mode", forms_set_graphics_mode, METH_OLDARGS}, |
| 2122 | {"get_rgbmode", forms_get_rgbmode, METH_OLDARGS}, |
| 2123 | {"show_errors", forms_show_errors, METH_OLDARGS}, |
| 2124 | {"set_font_name", forms_set_font_name, METH_OLDARGS}, |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2125 | {NULL, NULL} /* sentinel */ |
| 2126 | }; |
| 2127 | |
Mark Hammond | fe51c6d | 2002-08-02 02:27:13 +0000 | [diff] [blame] | 2128 | PyMODINIT_FUNC |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 2129 | initfl(void) |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2130 | { |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2131 | Py_InitModule("fl", forms_methods); |
Neal Norwitz | 1ac754f | 2006-01-19 06:09:39 +0000 | [diff] [blame] | 2132 | if (m == NULL) |
| 2133 | return; |
Guido van Rossum | 2df7bcc | 1991-10-20 20:18:26 +0000 | [diff] [blame] | 2134 | foreground(); |
Guido van Rossum | ddc0d3e | 1991-12-10 13:56:42 +0000 | [diff] [blame] | 2135 | fl_init(); |
Guido van Rossum | c7df79e | 1991-08-07 11:32:58 +0000 | [diff] [blame] | 2136 | } |
Roger E. Masse | 7ba4c07 | 1997-01-03 22:17:11 +0000 | [diff] [blame] | 2137 | |
| 2138 | |
| 2139 | |