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