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