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