blob: ec77700cbdd6398d1ca2a6299e74b2a24f78bc98 [file] [log] [blame]
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001/**********************************************************
2Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
3Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
25/* FL module -- interface to Mark Overmars' FORMS Library. */
26
27#include "forms.h"
28
29#include "allobjects.h"
30#include "import.h"
31#include "modsupport.h"
32#include "structmember.h"
33
34/* #include "ceval.h" */
35extern object *call_object(object *, object *);
36
37/* Generic Forms Objects */
38
39typedef struct {
40 OB_HEAD
41 FL_OBJECT *ob_generic;
42 struct methodlist *ob_methods;
43 object *ob_callback;
44 object *ob_callback_arg;
45} genericobject;
46
47/* List of all objects (later this should be a hash table on address...) */
48
49static object *allgenerics = NULL;
50
51static void
52knowgeneric(g)
53 genericobject *g;
54{
55 if (allgenerics == NULL) {
56 allgenerics = newlistobject(0);
57 if (allgenerics == NULL) {
58 err_clear();
59 return; /* Botte pech */
60 }
61 }
62 addlistitem(allgenerics, (object *)g);
63}
64
65static genericobject *
66findgeneric(generic)
67 FL_OBJECT *generic;
68{
69 int i, n;
70 genericobject *g;
71
72 if (allgenerics == NULL)
73 return NULL; /* Botte pech */
74 n = getlistsize(allgenerics);
75 for (i = 0; i < n; i++) {
76 g = (genericobject *)getlistitem(allgenerics, i);
77 if (g->ob_generic == generic)
78 return g;
79 }
80 return NULL; /* Unknown object */
81}
82
83
84/* Methods of generic objects */
85
86static object *
87generic_set_call_back(g, args)
88 genericobject *g;
89 object *args;
90{
91 if (args == NULL) {
92 XDECREF(g->ob_callback);
93 XDECREF(g->ob_callback_arg);
94 g->ob_callback = NULL;
95 g->ob_callback_arg = NULL;
96 }
97 else {
98 if (!is_tupleobject(args) || gettuplesize(args) != 2) {
99 err_badarg();
100 return NULL;
101 }
102 XDECREF(g->ob_callback);
103 XDECREF(g->ob_callback_arg);
104 g->ob_callback = gettupleitem(args, 0);
105 INCREF(g->ob_callback);
106 g->ob_callback_arg = gettupleitem(args, 1);
107 INCREF(g->ob_callback_arg);
108 }
109 INCREF(None);
110 return None;
111}
112
113static object *
114generic_call(g, args, func)
115 genericobject *g;
116 object *args;
117 void (*func)(FL_OBJECT *);
118{
119 if (!getnoarg(args))
120 return NULL;
121 (*func)(g->ob_generic);
122 INCREF(None);
123 return None;
124}
125
126static object *
127generic_show_object(g, args)
128 genericobject *g;
129 object *args;
130{
131 return generic_call(g, args, fl_show_object);
132}
133
134static object *
135generic_hide_object(g, args)
136 genericobject *g;
137 object *args;
138{
139 return generic_call(g, args, fl_hide_object);
140}
141
142static object *
143generic_redraw_object(g, args)
144 genericobject *g;
145 object *args;
146{
147 return generic_call(g, args, fl_redraw_object);
148}
149
150static object *
151generic_freeze_object(g, args)
152 genericobject *g;
153 object *args;
154{
155 return generic_call(g, args, fl_freeze_object);
156}
157
158static object *
159generic_unfreeze_object(g, args)
160 genericobject *g;
161 object *args;
162{
163 return generic_call(g, args, fl_unfreeze_object);
164}
165
166static struct methodlist generic_methods[] = {
167 {"set_call_back", generic_set_call_back},
168 {"show_object", generic_show_object},
169 {"hide_object", generic_hide_object},
170 {"redraw_object", generic_redraw_object},
171 {"freeze_object", generic_freeze_object},
172 {"unfreeze_object", generic_unfreeze_object},
173#if 0
174 {"handle_object", generic_handle_object},
175 {"handle_object_direct",generic_handle_object_direct},
176#endif
Guido van Rossum03747111991-08-08 12:10:01 +0000177 {NULL, NULL} /* sentinel */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000178};
179
180static void
181generic_dealloc(g)
182 genericobject *g;
183{
184 /* XXX can't destroy forms objects !!! */
185 DEL(g);
186}
187
188#define OFF(x) offsetof(FL_OBJECT, x)
189
190static struct memberlist generic_memberlist[] = {
191 {"objclass", T_INT, OFF(objclass), RO},
192 {"type", T_INT, OFF(type), RO},
193 {"boxtype", T_INT, OFF(boxtype)},
194 {"x", T_FLOAT, OFF(x)},
195 {"y", T_FLOAT, OFF(y)},
196 {"w", T_FLOAT, OFF(w)},
197 {"h", T_FLOAT, OFF(h)},
198 {"col1", T_INT, OFF(col1)},
199 {"col2", T_INT, OFF(col2)},
200 {"align", T_INT, OFF(align)},
201 {"lcol", T_INT, OFF(lcol)},
202 {"lsize", T_FLOAT, OFF(lsize)},
203 /* "label" is treated specially! */
204 {"lstyle", T_INT, OFF(lstyle)},
205 {"pushed", T_INT, OFF(pushed), RO},
206 {"focus", T_INT, OFF(focus), RO},
207 {"belowmouse", T_INT, OFF(belowmouse),RO},
208 {"frozen", T_INT, OFF(frozen), RO},
209 {"active", T_INT, OFF(active), RO},
210 {"input", T_INT, OFF(input), RO},
211 {"visible", T_INT, OFF(visible), RO},
212 {"radio", T_INT, OFF(radio), RO},
213 {"automatic", T_INT, OFF(automatic), RO},
214 {NULL} /* Sentinel */
215};
216
217static object *
218generic_getattr(g, name)
219 genericobject *g;
220 char *name;
221{
222 object *meth;
223
224 if (g-> ob_methods) {
Guido van Rossum03747111991-08-08 12:10:01 +0000225 meth = findmethod(g->ob_methods, (object *)g, name);
226 if (meth != NULL) return meth;
227 err_clear();
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000228 }
229
230 meth = findmethod(generic_methods, (object *)g, name);
231 if (meth != NULL)
232 return meth;
233 err_clear();
234
235 /* "label" is an exception, getmember only works for char pointers,
236 not for char arrays */
237 if (strcmp(name, "label") == 0)
238 return newstringobject(g->ob_generic->label);
239
240 return getmember((char *)g->ob_generic, generic_memberlist, name);
241}
242
243static int
244generic_setattr(g, name, v)
245 genericobject *g;
246 char *name;
247 object *v;
248{
249 int ret;
250
251 if (v == NULL) {
252 err_setstr(TypeError, "can't delete forms object attributes");
253 return NULL;
254 }
255
256 /* "label" is an exception: setmember doesn't set strings;
257 and FORMS wants you to call a function to set the label */
258 if (strcmp(name, "label") == 0) {
259 if (!is_stringobject(v)) {
260 err_setstr(TypeError, "label attr must be string");
261 return NULL;
262 }
263 fl_set_object_label(g->ob_generic, getstringvalue(v));
264 return 0;
265 }
266
267 ret = setmember((char *)g->ob_generic, generic_memberlist, name, v);
268
269 /* Rather than calling all the various set_object_* functions,
270 we call fl_redraw_object here. This is sometimes redundant
271 but I doubt that's a big problem */
272 if (ret == 0)
273 fl_redraw_object(g->ob_generic);
274
275 return ret;
276}
277
278typeobject GenericObjecttype = {
279 OB_HEAD_INIT(&Typetype)
280 0, /*ob_size*/
281 "generic FORMS object", /*tp_name*/
282 sizeof(genericobject), /*tp_size*/
283 0, /*tp_itemsize*/
284 /* methods */
285 generic_dealloc, /*tp_dealloc*/
286 0, /*tp_print*/
287 generic_getattr, /*tp_getattr*/
288 generic_setattr, /*tp_setattr*/
289 0, /*tp_compare*/
290 0, /*tp_repr*/
291};
292
293static object *
294newgenericobject(generic, methods)
295 FL_OBJECT *generic;
296 struct methodlist *methods;
297{
298 genericobject *g;
299 g = NEWOBJ(genericobject, &GenericObjecttype);
300 if (g == NULL)
301 return NULL;
302 g-> ob_generic = generic;
303 g->ob_methods = methods;
304 g->ob_callback = NULL;
305 g->ob_callback_arg = NULL;
306 knowgeneric(g);
307 return (object *)g;
308}
309
310/**********************************************************************/
311/* Some common calling sequences */
312
313/* void func (object, float) */
314static object *
315call_forms_INf (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000316 void *(*func)(FL_OBJECT *, float);
317 FL_OBJECT *obj;
318 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000319{
Guido van Rossum03747111991-08-08 12:10:01 +0000320 float parameter;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000321
Guido van Rossum03747111991-08-08 12:10:01 +0000322 if (!getfloatarg (args, &parameter)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000323
Guido van Rossum03747111991-08-08 12:10:01 +0000324 (*func) (obj, parameter);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000325
Guido van Rossum03747111991-08-08 12:10:01 +0000326 INCREF(None);
327 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000328}
329
330/* void func (object, float) */
331static object *
332call_forms_INfINf (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000333 void *(*func)(FL_OBJECT *, float, float);
334 FL_OBJECT *obj;
335 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000336{
Guido van Rossum03747111991-08-08 12:10:01 +0000337 float par1, par2;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000338
Guido van Rossum03747111991-08-08 12:10:01 +0000339 if (!getfloatfloatarg (args, &par1, &par2)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000340
Guido van Rossum03747111991-08-08 12:10:01 +0000341 (*func) (obj, par1, par2);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000342
Guido van Rossum03747111991-08-08 12:10:01 +0000343 INCREF(None);
344 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000345}
346
347/* void func (object, int) */
348static object *
349call_forms_INi (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000350 void *(*func)(FL_OBJECT *, int);
351 FL_OBJECT *obj;
352 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000353{
Guido van Rossum03747111991-08-08 12:10:01 +0000354 int parameter;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000355
Guido van Rossum03747111991-08-08 12:10:01 +0000356 if (!getintarg (args, &parameter)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000357
Guido van Rossum03747111991-08-08 12:10:01 +0000358 (*func) (obj, parameter);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000359
Guido van Rossum03747111991-08-08 12:10:01 +0000360 INCREF(None);
361 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000362}
363
364/* void func (object, string) */
365static object *
366call_forms_INstr (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000367 void *(*func)(FL_OBJECT *, char *);
368 FL_OBJECT *obj;
369 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000370{
Guido van Rossum03747111991-08-08 12:10:01 +0000371 object *a;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000372
Guido van Rossum03747111991-08-08 12:10:01 +0000373 if (!getstrarg (args, &a)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000374
Guido van Rossum03747111991-08-08 12:10:01 +0000375 (*func) (obj, getstringvalue (a));
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000376
Guido van Rossum03747111991-08-08 12:10:01 +0000377 INCREF(None);
378 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000379}
380
381
382/* voide func (object, int, string) */
383static object *
384call_forms_INiINstr (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000385 void *(*func)(FL_OBJECT *, int, char *);
386 FL_OBJECT *obj;
387 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000388{
Guido van Rossum03747111991-08-08 12:10:01 +0000389 object *a;
390 int b;
391
392 if (!getintstrarg (args, &b, &a)) return NULL;
393
394 (*func) (obj, b, getstringvalue (a));
395
396 INCREF(None);
397 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000398}
399
Guido van Rossum03747111991-08-08 12:10:01 +0000400#ifdef UNUSED
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000401/* void func (object, float) */
402static object *
403call_forms_INiINi (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000404 void *(*func)(FL_OBJECT *, float, float);
405 FL_OBJECT *obj;
406 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000407{
Guido van Rossum03747111991-08-08 12:10:01 +0000408 int par1, par2;
409
410 if (!getintintarg (args, &par1, &par2)) return NULL;
411
412 (*func) (obj, par1, par2);
413
414 INCREF(None);
415 return None;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000416}
Guido van Rossum03747111991-08-08 12:10:01 +0000417#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000418
419/* int func (object) */
420static object *
421call_forms_Ri (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000422 int (*func)(FL_OBJECT *);
423 FL_OBJECT *obj;
424 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000425{
Guido van Rossum03747111991-08-08 12:10:01 +0000426 int retval;
427
428 if (!getnoarg(args)) return NULL;
429
430 retval = (*func) (obj);
431
432 return newintobject ((long) retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000433}
434
435/* char * func (object) */
436static object *
437call_forms_Rstr (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000438 char * (*func)(FL_OBJECT *);
439 FL_OBJECT *obj;
440 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000441{
Guido van Rossum03747111991-08-08 12:10:01 +0000442 char *str;
443
444 if (!getnoarg (args)) return NULL;
445
446 str = (*func) (obj);
447
448 return newstringobject (str);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000449}
450
451/* int func (object) */
452static object *
453call_forms_Rf (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000454 float (*func)(FL_OBJECT *);
455 FL_OBJECT *obj;
456 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000457{
Guido van Rossum03747111991-08-08 12:10:01 +0000458 float retval;
459
460 if (!getnoarg(args)) return NULL;
461
462 retval = (*func) (obj);
463
464 return newfloatobject (retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000465}
466
467static object *
468call_forms_OUTfOUTf (func, obj, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000469 void *(*func)(FL_OBJECT *, float *, float *);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000470 FL_OBJECT *obj;
471 object *args;
472{
473 float f1, f2;
474 object *arg;
Guido van Rossum03747111991-08-08 12:10:01 +0000475
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000476 if (!getnoarg(args)) return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000477
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000478 (*func) (obj, &f1, &f2);
479
480 arg = newtupleobject (2);
481 if (arg == NULL) return NULL;
482
483 settupleitem (arg, 0, newfloatobject (f1));
484 settupleitem (arg, 1, newfloatobject (f2));
485 return arg;
486}
487
Guido van Rossum03747111991-08-08 12:10:01 +0000488#ifdef UNUSED
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000489static object *
490call_forms_OUTf (func, obj, args)
491 void *(*func)(FL_OBJECT *, float *);
492 FL_OBJECT *obj;
493 object *args;
494{
495 float f;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000496
497 if (!getnoarg(args)) return NULL;
498
499 (*func) (obj, &f);
500
501 return newfloatobject (f);
502}
Guido van Rossum03747111991-08-08 12:10:01 +0000503#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000504
505/**********************************************************************/
506/* Class : browser */
507
508static object *
509set_browser_topline(g, args)
510 genericobject *g;
511 object *args;
512{
Guido van Rossum03747111991-08-08 12:10:01 +0000513 return call_forms_INi (fl_set_browser_topline, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000514}
515
516static object *
517clear_browser(g, args)
518 genericobject *g;
519 object *args;
520{
Guido van Rossum03747111991-08-08 12:10:01 +0000521 return generic_call (g, args, fl_clear_browser);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000522}
523
524static object *
525add_browser_line (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000526 genericobject *g;
527 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000528{
Guido van Rossum03747111991-08-08 12:10:01 +0000529 return call_forms_INstr (fl_add_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000530}
531
532static object *
533addto_browser (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000534 genericobject *g;
535 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000536{
Guido van Rossum03747111991-08-08 12:10:01 +0000537 return call_forms_INstr (fl_addto_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000538}
539
540static object *
541insert_browser_line (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000542 genericobject *g;
543 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000544{
Guido van Rossum03747111991-08-08 12:10:01 +0000545 return call_forms_INiINstr (fl_insert_browser_line,
546 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000547}
548
549static object *
550delete_browser_line (g, args)
551 genericobject *g;
552 object *args;
553{
Guido van Rossum03747111991-08-08 12:10:01 +0000554 return call_forms_INi (fl_delete_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000555}
556
557static object *
558replace_browser_line (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000559 genericobject *g;
560 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000561{
Guido van Rossum03747111991-08-08 12:10:01 +0000562 return call_forms_INiINstr (fl_replace_browser_line,
563 g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000564}
565
566static object *
567get_browser_line(g, args)
568 genericobject *g;
569 object *args;
570{
571 int i;
572 char *str;
573
574 if (!getintarg(args, &i))
575 return NULL;
576
577 str = fl_get_browser_line (g->ob_generic, i);
578
579 return newstringobject (str);
580}
581
582static object *
583load_browser (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000584 genericobject *g;
585 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000586{
Guido van Rossum03747111991-08-08 12:10:01 +0000587 return call_forms_INstr (fl_load_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000588}
589
590static object *
591get_browser_maxline(g, args)
592 genericobject *g;
593 object *args;
594{
Guido van Rossum03747111991-08-08 12:10:01 +0000595 return call_forms_Ri (fl_get_browser_maxline, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000596}
597
598static object *
599select_browser_line (g, args)
600 genericobject *g;
601 object *args;
602{
Guido van Rossum03747111991-08-08 12:10:01 +0000603 return call_forms_INi (fl_select_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000604}
605
606static object *
607deselect_browser_line (g, args)
608 genericobject *g;
609 object *args;
610{
Guido van Rossum03747111991-08-08 12:10:01 +0000611 return call_forms_INi (fl_deselect_browser_line, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000612}
613
614static object *
615deselect_browser (g, args)
616 genericobject *g;
617 object *args;
618{
Guido van Rossum03747111991-08-08 12:10:01 +0000619 return generic_call (g, args, fl_deselect_browser);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000620}
621
622static object *
623isselected_browser_line (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000624 genericobject *g;
625 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000626{
627 int i, j;
Guido van Rossum03747111991-08-08 12:10:01 +0000628
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000629 if (!getintarg(args, &i))
630 return NULL;
Guido van Rossum03747111991-08-08 12:10:01 +0000631
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000632 j = fl_isselected_browser_line (g->ob_generic, i);
Guido van Rossum03747111991-08-08 12:10:01 +0000633
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000634 return newintobject (j);
635}
636
637static object *
638get_browser (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000639 genericobject *g;
640 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000641{
Guido van Rossum03747111991-08-08 12:10:01 +0000642 return call_forms_Ri (fl_get_browser, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000643}
644
645static object *
646set_browser_fontsize (g, args)
647 genericobject *g;
648 object *args;
649{
Guido van Rossum03747111991-08-08 12:10:01 +0000650 return call_forms_INf (fl_set_browser_fontsize, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000651}
652
653static object *
654set_browser_fontstyle (g, args)
655 genericobject *g;
656 object *args;
657{
Guido van Rossum03747111991-08-08 12:10:01 +0000658 return call_forms_INi (fl_set_browser_fontstyle, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000659}
660
661static struct methodlist browser_methods[] = {
662 {"set_browser_topline", set_browser_topline},
663 {"clear_browser", clear_browser},
664 {"add_browser_line", add_browser_line},
665 {"addto_browser", addto_browser},
666 {"insert_browser_line", insert_browser_line},
667 {"delete_browser_line", delete_browser_line},
668 {"replace_browser_line",replace_browser_line},
669 {"get_browser_line", get_browser_line},
670 {"load_browser", load_browser},
671 {"get_browser_maxline", get_browser_maxline},
672 {"select_browser_line", select_browser_line},
673 {"deselect_browser_line", deselect_browser_line},
674 {"deselect_browser", deselect_browser},
675 {"isselected_browser_line", isselected_browser_line},
676 {"get_browser", get_browser},
677 {"set_browser_fontsize",set_browser_fontsize},
678 {"set_browser_fontstyle", set_browser_fontstyle},
679 {NULL, NULL} /* sentinel */
680};
681
682/* Class: button */
683
684static object *
685set_button(g, args)
686 genericobject *g;
687 object *args;
688{
Guido van Rossum03747111991-08-08 12:10:01 +0000689 return call_forms_INi (fl_set_button, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000690}
691
692static object *
693get_button(g, args)
694 genericobject *g;
695 object *args;
696{
Guido van Rossum03747111991-08-08 12:10:01 +0000697 return call_forms_Ri (fl_get_button, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000698}
699
700static struct methodlist button_methods[] = {
701 {"set_button", set_button},
702 {"get_button", get_button},
703 {NULL, NULL} /* sentinel */
704};
705
706/* Class: choice */
707
708static object *
709set_choice(g, args)
710 genericobject *g;
711 object *args;
712{
Guido van Rossum03747111991-08-08 12:10:01 +0000713 return call_forms_INi (fl_set_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000714}
715
716static object *
717get_choice(g, args)
718 genericobject *g;
719 object *args;
720{
Guido van Rossum03747111991-08-08 12:10:01 +0000721 return call_forms_Ri (fl_get_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000722}
723
724static object *
725clear_choice (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000726 genericobject *g;
727 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000728{
Guido van Rossum03747111991-08-08 12:10:01 +0000729 return generic_call (g, args, fl_clear_choice);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000730}
731
732static object *
733addto_choice (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000734 genericobject *g;
735 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000736{
Guido van Rossum03747111991-08-08 12:10:01 +0000737 return call_forms_INstr (fl_addto_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000738}
739
740static object *
741replace_choice (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000742 genericobject *g;
743 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000744{
Guido van Rossum03747111991-08-08 12:10:01 +0000745 return call_forms_INiINstr (fl_replace_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000746}
747
748static object *
749delete_choice (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000750 genericobject *g;
751 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000752{
Guido van Rossum03747111991-08-08 12:10:01 +0000753 return call_forms_INi (fl_delete_choice, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000754}
755
756static object *
757get_choice_text (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000758 genericobject *g;
759 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000760{
Guido van Rossum03747111991-08-08 12:10:01 +0000761 return call_forms_Rstr (fl_get_choice_text, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000762}
763
764static object *
765set_choice_fontsize (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000766 genericobject *g;
767 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000768{
Guido van Rossum03747111991-08-08 12:10:01 +0000769 return call_forms_INf (fl_set_choice_fontsize, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000770}
771
772static object *
773set_choice_fontstyle (g, args)
Guido van Rossum03747111991-08-08 12:10:01 +0000774 genericobject *g;
775 object *args;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000776{
Guido van Rossum03747111991-08-08 12:10:01 +0000777 return call_forms_INi (fl_set_choice_fontstyle, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000778}
779
780static struct methodlist choice_methods[] = {
781 {"set_choice", set_choice},
782 {"get_choice", get_choice},
783 {"clear_choice", clear_choice},
784 {"addto_choice", addto_choice},
785 {"replace_choice", replace_choice},
786 {"delete_choice", delete_choice},
787 {"get_choice_text", get_choice_text},
788 {"set_choice_fontsize", set_choice_fontsize},
789 {"set_choice_fontstyle",set_choice_fontstyle},
790 {NULL, NULL} /* sentinel */
791};
792
793/* Class : Clock */
794
795static object *
796get_clock(g, args)
797 genericobject *g;
798 object *args;
799{
800 int i0, i1, i2;
801 object *arg;
802
803 if (!getnoarg(args))
804 return NULL;
805
806 fl_get_clock (g->ob_generic, &i0, &i1, &i2);
807
808 arg = newtupleobject (3);
809 if (arg == NULL) return NULL;
810
811 settupleitem (arg, 0, newintobject (i0));
812 settupleitem (arg, 1, newintobject (i1));
813 settupleitem (arg, 2, newintobject (i2));
814 return arg;
815}
816
817static struct methodlist clock_methods[] = {
818 {"get_clock", get_clock},
819 {NULL, NULL} /* sentinel */
820};
821
822/* CLass : Counters */
823
824static object *
825get_counter_value(g, args)
826 genericobject *g;
827 object *args;
828{
829 return call_forms_Rf (fl_get_counter_value, g-> ob_generic, args);
830}
831
832static object *
833set_counter_value (g, args)
834 genericobject *g;
835 object *args;
836{
837 return call_forms_INf (fl_set_counter_value, g-> ob_generic, args);
838}
839
840static object *
841set_counter_precision (g, args)
842 genericobject *g;
843 object *args;
844{
845 return call_forms_INi (fl_set_counter_precision, g-> ob_generic, args);
846}
847
848static object *
849set_counter_bounds (g, args)
850 genericobject *g;
851 object *args;
852{
853 return call_forms_INfINf (fl_set_counter_bounds, g-> ob_generic, args);
854}
855
856static object *
857set_counter_step (g, args)
858 genericobject *g;
859 object *args;
860{
861 return call_forms_INfINf (fl_set_counter_step, g-> ob_generic, args);
862}
863
864static object *
865set_counter_return (g, args)
866 genericobject *g;
867 object *args;
868{
Guido van Rossum03747111991-08-08 12:10:01 +0000869 return call_forms_INi (fl_set_counter_return, g-> ob_generic, args);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000870}
871
872static struct methodlist counter_methods[] = {
873 {"set_counter_value", set_counter_value},
874 {"get_counter_value", get_counter_value},
875 {"set_counter_bounds", set_counter_bounds},
876 {"set_counter_step", set_counter_step},
877 {"set_counter_precision", set_counter_precision},
878 {"set_counter_return", set_counter_return},
879 {NULL, NULL} /* sentinel */
880};
881
882/* Class : Defaults */
883
884static object *
885get_default(g, args)
886 genericobject *g;
887 object *args;
888{
Guido van Rossum03747111991-08-08 12:10:01 +0000889 char c;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000890
Guido van Rossum03747111991-08-08 12:10:01 +0000891 if (!getnoarg(args)) return NULL;
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000892
Guido van Rossum03747111991-08-08 12:10:01 +0000893 c = fl_get_default (g->ob_generic);
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000894
Guido van Rossum03747111991-08-08 12:10:01 +0000895 return ((object *) mknewcharobject (c)); /* in cgensupport.c */
Guido van Rossumc7df79e1991-08-07 11:32:58 +0000896}
897
898static struct methodlist default_methods[] = {
899 {"get_default", get_default},
900 {NULL, NULL} /* sentinel */
901};
902
903
904/* Class: Dials */
905
906static object *
907set_dial (g, args)
908 genericobject *g;
909 object *args;
910{
911 float f1, f2, f3;
912
913 if (!getfloatfloatfloatarg(args, &f1, &f2, &f3))
914 return NULL;
915 fl_set_dial (g->ob_generic, f1, f2, f3);
916 INCREF(None);
917 return None;
918}
919
920static object *
921get_dial(g, args)
922 genericobject *g;
923 object *args;
924{
925 return call_forms_Rf (fl_get_dial, g-> ob_generic, args);
926}
927
928static object *
929set_dial_value (g, args)
930 genericobject *g;
931 object *args;
932{
933 return call_forms_INf (fl_set_dial_value, g-> ob_generic, args);
934}
935
936static object *
937set_dial_bounds (g, args)
938 genericobject *g;
939 object *args;
940{
941 return call_forms_INfINf (fl_set_dial_bounds, g-> ob_generic, args);
942}
943
944static object *
945get_dial_bounds (g, args)
946 genericobject *g;
947 object *args;
948{
949 return call_forms_OUTfOUTf (fl_get_dial_bounds, g-> ob_generic, args);
950}
951
952static struct methodlist dial_methods[] = {
953 {"set_dial", set_dial},
954 {"get_dial", get_dial},
955 {"set_dial_value", set_dial_value},
956 {"get_dial_value", get_dial},
957 {"set_dial_bounds", set_dial_bounds},
958 {"get_dial_bounds", get_dial_bounds},
959 {NULL, NULL} /* sentinel */
960};
961
962/* Class : Input */
963
964static object *
965set_input (g, args)
966 genericobject *g;
967 object *args;
968{
969 return call_forms_INstr (fl_set_input, g-> ob_generic, args);
970}
971
972static object *
973get_input (g, args)
974 genericobject *g;
975 object *args;
976{
977 return call_forms_Rstr (fl_get_input, g-> ob_generic, args);
978}
979
980static object *
981set_input_color (g, args)
982 genericobject *g;
983 object *args;
984{
985 return call_forms_INfINf (fl_set_input_color, g-> ob_generic, args);
986}
987
988static struct methodlist input_methods[] = {
989 {"set_input", set_input},
990 {"get_input", get_input},
991 {"set_input_color", set_input_color},
992 {NULL, NULL} /* sentinel */
993};
994
995
996/* Class : Menu */
997
998static object *
999set_menu (g, args)
1000 genericobject *g;
1001 object *args;
1002{
1003 return call_forms_INstr (fl_set_menu, g-> ob_generic, args);
1004}
1005
1006static object *
1007get_menu (g, args)
1008 genericobject *g;
1009 object *args;
1010{
1011 return call_forms_Ri (fl_get_menu, g-> ob_generic, args);
1012}
1013
1014static object *
1015addto_menu (g, args)
1016 genericobject *g;
1017 object *args;
1018{
1019 return call_forms_INstr (fl_addto_menu, g-> ob_generic, args);
1020}
1021
1022static struct methodlist menu_methods[] = {
1023 {"set_menu", set_menu},
1024 {"get_menu", get_menu},
1025 {"addto_menu", addto_menu},
1026 {NULL, NULL} /* sentinel */
1027};
1028
1029
1030/* Class: Sliders */
1031
1032static object *
1033set_slider (g, args)
1034 genericobject *g;
1035 object *args;
1036{
1037 float f1, f2, f3;
1038
1039 if (!getfloatfloatfloatarg(args, &f1, &f2, &f3))
1040 return NULL;
1041 fl_set_slider (g->ob_generic, f1, f2, f3);
1042 INCREF(None);
1043 return None;
1044}
1045
1046static object *
1047get_slider(g, args)
1048 genericobject *g;
1049 object *args;
1050{
1051 return call_forms_Rf (fl_get_slider, g-> ob_generic, args);
1052}
1053
1054static object *
1055set_slider_value (g, args)
1056 genericobject *g;
1057 object *args;
1058{
1059 return call_forms_INf (fl_set_slider_value, g-> ob_generic, args);
1060}
1061
1062static object *
1063set_slider_bounds (g, args)
1064 genericobject *g;
1065 object *args;
1066{
1067 return call_forms_INfINf (fl_set_slider_bounds, g-> ob_generic, args);
1068}
1069
1070static object *
1071get_slider_bounds (g, args)
1072 genericobject *g;
1073 object *args;
1074{
1075 return call_forms_OUTfOUTf(fl_get_slider_bounds, g-> ob_generic, args);
1076}
1077
1078static object *
1079set_slider_return (g, args)
1080 genericobject *g;
1081 object *args;
1082{
1083 return call_forms_INf (fl_set_slider_return, g-> ob_generic, args);
1084}
1085
1086static object *
1087set_slider_size (g, args)
1088 genericobject *g;
1089 object *args;
1090{
1091 return call_forms_INf (fl_set_slider_size, g-> ob_generic, args);
1092}
1093
1094static object *
1095set_slider_precision (g, args)
1096 genericobject *g;
1097 object *args;
1098{
1099 return call_forms_INi (fl_set_slider_precision, g-> ob_generic, args);
1100}
1101
1102static struct methodlist slider_methods[] = {
1103 {"set_slider", set_slider},
1104 {"get_slider", get_slider},
1105 {"set_slider_value", set_slider_value},
1106 {"get_slider_value", get_slider},
1107 {"set_slider_bounds", set_slider_bounds},
1108 {"get_slider_bounds", get_slider_bounds},
1109 {"set_slider_return", set_slider_return},
1110 {"set_slider_size", set_slider_size},
1111 {"set_slider_precision",set_slider_precision},
1112 {NULL, NULL} /* sentinel */
1113};
1114
1115static object *
1116set_positioner_xvalue (g, args)
1117 genericobject *g;
1118 object *args;
1119{
1120 return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args);
1121}
1122
1123static object *
1124set_positioner_xbounds (g, args)
1125 genericobject *g;
1126 object *args;
1127{
1128 return call_forms_INfINf (fl_set_positioner_xbounds, g-> ob_generic, args);
1129}
1130
1131static object *
1132set_positioner_yvalue (g, args)
1133 genericobject *g;
1134 object *args;
1135{
1136 return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args);
1137}
1138
1139static object *
1140set_positioner_ybounds (g, args)
1141 genericobject *g;
1142 object *args;
1143{
1144 return call_forms_INfINf (fl_set_positioner_ybounds, g-> ob_generic, args);
1145}
1146
1147static object *
1148get_positioner_xvalue (g, args)
1149 genericobject *g;
1150 object *args;
1151{
1152 return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic, args);
1153}
1154
1155static object *
1156get_positioner_xbounds (g, args)
1157 genericobject *g;
1158 object *args;
1159{
1160 return call_forms_OUTfOUTf (fl_get_positioner_xbounds, g-> ob_generic, args);
1161}
1162
1163static object *
1164get_positioner_yvalue (g, args)
1165 genericobject *g;
1166 object *args;
1167{
1168 return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic, args);
1169}
1170
1171static object *
1172get_positioner_ybounds (g, args)
1173 genericobject *g;
1174 object *args;
1175{
1176 return call_forms_OUTfOUTf (fl_get_positioner_ybounds, g-> ob_generic, args);
1177}
1178
1179static struct methodlist positioner_methods[] = {
1180 {"set_positioner_xvalue", set_positioner_xvalue},
1181 {"set_positioner_yvalue", set_positioner_yvalue},
1182 {"set_positioner_xbounds", set_positioner_xbounds},
1183 {"set_positioner_ybounds", set_positioner_ybounds},
1184 {"get_positioner_xvalue", get_positioner_xvalue},
1185 {"get_positioner_yvalue", get_positioner_yvalue},
1186 {"get_positioner_xbounds", get_positioner_xbounds},
Guido van Rossum03747111991-08-08 12:10:01 +00001187 {"get_positioner_ybounds", get_positioner_ybounds},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001188 {NULL, NULL} /* sentinel */
1189};
1190
1191/* Class timer */
1192
1193static object *
1194set_timer (g, args)
1195 genericobject *g;
1196 object *args;
1197{
1198 return call_forms_INf (fl_set_timer, g-> ob_generic, args);
1199}
1200
1201static object *
1202get_timer (g, args)
1203 genericobject *g;
1204 object *args;
1205{
1206 return call_forms_Rf (fl_get_timer, g-> ob_generic, args);
1207}
1208
1209static struct methodlist timer_methods[] = {
1210 {"set_timer", set_timer},
1211 {"get_timer", get_timer},
1212 {NULL, NULL} /* sentinel */
1213};
1214
1215/* Form objects */
1216
1217typedef struct {
1218 OB_HEAD
1219 FL_FORM *ob_form;
1220} formobject;
1221
1222extern typeobject Formtype; /* Forward */
1223
1224#define is_formobject(v) ((v)->ob_type == &Formtype)
1225
1226static object *
1227form_show_form(f, args)
1228 formobject *f;
1229 object *args;
1230{
1231 int place, border;
1232 object *name;
1233 if (!getintintstrarg(args, &place, &border, &name))
1234 return NULL;
1235 fl_show_form(f->ob_form, place, border, getstringvalue(name));
1236 INCREF(None);
1237 return None;
1238}
1239
1240static object *
1241form_call(func, f, args)
1242 FL_FORM *f;
1243 object *args;
1244 void (*func)(FL_FORM *);
1245{
1246 if (!getnoarg(args)) return NULL;
1247
1248 (*func)(f);
1249
1250 INCREF(None);
1251 return None;
1252}
1253
1254static object *
1255form_call_INiINi (func, f, args)
1256 FL_FORM *f;
1257 object *args;
1258 void (*func)(FL_FORM *, int, int);
1259{
1260 int a, b;
1261
1262 if (!getintintarg(args, &a, &b)) return NULL;
1263
1264 (*func)(f, a, b);
1265
1266 INCREF(None);
1267 return None;
1268}
1269
1270static object *
1271form_hide_form(f, args)
1272 formobject *f;
1273 object *args;
1274{
1275 return form_call (fl_hide_form, f-> ob_form, args);
1276}
1277
1278static object *
1279form_redraw_form(f, args)
1280 formobject *f;
1281 object *args;
1282{
1283 return form_call (fl_redraw_form, f-> ob_form, args);
1284}
1285
1286static object *
1287form_set_form_position (f, args)
1288 formobject *f;
1289 object *args;
1290{
1291 return form_call_INiINi (fl_set_form_position, f-> ob_form, args);
1292}
1293
1294static object *
1295generic_add_object (f, args, func, internal_methods)
1296 formobject *f;
1297 object *args;
1298 FL_OBJECT *(*func)(int, float, float, float, float, char*);
1299 struct methodlist *internal_methods;
1300{
1301 int type;
1302 float x, y, w, h;
1303 object *name;
1304 FL_OBJECT *genobj;
1305
Guido van Rossum03747111991-08-08 12:10:01 +00001306 if (!getintfloatfloatfloatfloatstrarg (args,&type,&x,&y,&w,&h,&name))
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001307 return NULL;
1308
1309 fl_addto_form (f-> ob_form);
1310
1311 genobj = (*func) (type, x, y, w, h, getstringvalue (name));
1312
1313 fl_end_form ();
1314
1315 if (genobj == NULL) { err_nomem(); return NULL; }
1316
1317 return newgenericobject (genobj, internal_methods);
1318}
1319
1320static object *
1321form_add_button(f, args)
1322 formobject *f;
1323 object *args;
1324{
1325 return generic_add_object(f, args, fl_add_button, button_methods);
1326}
1327
1328static object *
1329form_add_lightbutton(f, args)
1330 formobject *f;
1331 object *args;
1332{
1333 return generic_add_object(f, args, fl_add_lightbutton, button_methods);
1334}
1335
1336static object *
1337form_add_roundbutton(f, args)
1338 formobject *f;
1339 object *args;
1340{
1341 return generic_add_object(f, args, fl_add_roundbutton, button_methods);
1342}
1343
1344static object *
1345form_add_menu (f, args)
1346 formobject *f;
1347 object *args;
1348{
1349 return generic_add_object(f, args, fl_add_menu, menu_methods);
1350}
1351
1352static object *
1353form_add_slider(f, args)
1354 formobject *f;
1355 object *args;
1356{
1357 return generic_add_object(f, args, fl_add_slider, slider_methods);
1358}
1359
1360static object *
1361form_add_valslider(f, args)
1362 formobject *f;
1363 object *args;
1364{
1365 return generic_add_object(f, args, fl_add_valslider, slider_methods);
1366}
1367
1368static object *
1369form_add_dial (f, args)
1370 formobject *f;
1371 object *args;
1372{
1373 return generic_add_object(f, args, fl_add_dial, dial_methods);
1374}
1375
1376static object *
1377form_add_counter (f, args)
1378 formobject *f;
1379 object *args;
1380{
1381 return generic_add_object(f, args, fl_add_counter, counter_methods);
1382}
1383
1384static object *
1385form_add_default (f, args)
1386 formobject *f;
1387 object *args;
1388{
1389 return generic_add_object(f, args, fl_add_default, default_methods);
1390}
1391
1392static object *
1393form_add_clock (f, args)
1394 formobject *f;
1395 object *args;
1396{
1397 return generic_add_object(f, args, fl_add_clock, clock_methods);
1398}
1399
1400static object *
1401form_add_box (f, args)
1402 formobject *f;
1403 object *args;
1404{
Guido van Rossum03747111991-08-08 12:10:01 +00001405 return generic_add_object(f, args, fl_add_box,
1406 (struct methodlist *)NULL);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001407}
1408
1409static object *
1410form_add_choice (f, args)
1411 formobject *f;
1412 object *args;
1413{
1414 return generic_add_object(f, args, fl_add_choice, choice_methods);
1415}
1416
1417static object *
1418form_add_browser (f, args)
1419 formobject *f;
1420 object *args;
1421{
1422 return generic_add_object(f, args, fl_add_browser, browser_methods);
1423}
1424
1425static object *
1426form_add_positioner (f, args)
1427 formobject *f;
1428 object *args;
1429{
1430 return generic_add_object(f, args, fl_add_positioner, positioner_methods);
1431}
1432
1433static object *
1434form_add_input (f, args)
1435 formobject *f;
1436 object *args;
1437{
1438 return generic_add_object(f, args, fl_add_input, input_methods);
1439}
1440
1441static object *
1442form_add_text (f, args)
1443 formobject *f;
1444 object *args;
1445{
Guido van Rossum03747111991-08-08 12:10:01 +00001446 return generic_add_object(f, args, fl_add_text,
1447 (struct methodlist *)NULL);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001448}
1449
1450static object *
1451form_add_timer (f, args)
1452 formobject *f;
1453 object *args;
1454{
1455 return generic_add_object(f, args, fl_add_timer, timer_methods);
1456}
1457
1458static object *
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001459form_freeze_form(f, args)
1460 formobject *f;
1461 object *args;
1462{
1463 return form_call (fl_freeze_form, f-> ob_form, args);
1464}
1465
1466static object *
1467form_unfreeze_form(f, args)
1468 formobject *f;
1469 object *args;
1470{
1471 return form_call (fl_unfreeze_form, f-> ob_form, args);
1472}
1473
1474static object *
1475form_display_form(f, args)
1476 formobject *f;
1477 object *args;
1478{
1479 int place, border;
1480 object *name;
1481 if (!getintintstrarg(args, &place, &border, &name))
1482 return NULL;
1483 fl_show_form(f->ob_form, place, border, getstringvalue(name));
1484 INCREF(None);
1485 return None;
1486}
1487
1488static object *
1489form_remove_form(f, args)
1490 formobject *f;
1491 object *args;
1492{
1493 return form_call (fl_remove_form, f-> ob_form, args);
1494}
1495
1496static object *
1497form_activate_form(f, args)
1498 formobject *f;
1499 object *args;
1500{
1501 return form_call (fl_activate_form, f-> ob_form, args);
1502}
1503
1504static object *
1505form_deactivate_form(f, args)
1506 formobject *f;
1507 object *args;
1508{
1509 return form_call (fl_deactivate_form, f-> ob_form, args);
1510}
1511
Guido van Rossum75cc8981991-08-08 12:07:45 +00001512static object *
Guido van Rossum03747111991-08-08 12:10:01 +00001513form_bgn_group (f, args)
1514 formobject *f;
1515 object *args;
1516{
1517 fl_addto_form (f-> ob_form);
1518 fl_bgn_group();
1519 fl_end_form ();
1520 INCREF(None);
1521 return None;
1522}
1523
1524static object *
1525form_end_group (f, args)
1526 formobject *f;
1527 object *args;
1528{
1529 fl_addto_form (f-> ob_form);
1530 fl_end_group();
1531 fl_end_form ();
1532 INCREF(None);
1533 return None;
1534}
1535
1536static object *
1537forms_find_first_or_last (func, f, args)
Guido van Rossum75cc8981991-08-08 12:07:45 +00001538 FL_OBJECT *(*func)(FL_FORM *, int, float, float);
Guido van Rossum03747111991-08-08 12:10:01 +00001539 formobject *f;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001540 object *args;
1541{
1542 int type;
1543 float mx, my;
1544 FL_OBJECT *generic;
1545 genericobject *g;
1546
1547 if (!getintfloatfloatarg (args, &type, &mx, &my)) return NULL;
1548
Guido van Rossum03747111991-08-08 12:10:01 +00001549 generic = (*func) (f-> ob_form, type, mx, my);
Guido van Rossum75cc8981991-08-08 12:07:45 +00001550
1551 if (generic == NULL)
1552 {
1553 INCREF(None);
1554 return None;
1555 }
1556
1557 g = findgeneric(generic);
1558 if (g == NULL) {
1559 err_setstr(RuntimeError,
1560 "do_forms returns unknown object");
1561 return NULL;
1562 }
1563 INCREF(g);
1564 return ((object *) g);
1565}
1566
1567static object *
Guido van Rossum03747111991-08-08 12:10:01 +00001568form_find_first (f, args)
1569 formobject *f;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001570 object *args;
1571{
Guido van Rossum03747111991-08-08 12:10:01 +00001572 return (forms_find_first_or_last(fl_find_first, f, args));
Guido van Rossum75cc8981991-08-08 12:07:45 +00001573}
1574
1575static object *
Guido van Rossum03747111991-08-08 12:10:01 +00001576form_find_last (f, args)
1577 formobject *f;
Guido van Rossum75cc8981991-08-08 12:07:45 +00001578 object *args;
1579{
Guido van Rossum03747111991-08-08 12:10:01 +00001580 return (forms_find_first_or_last(fl_find_last, f, args));
Guido van Rossum75cc8981991-08-08 12:07:45 +00001581}
1582
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001583static struct methodlist form_methods[] = {
1584/* adm */
1585 {"show_form", form_show_form},
1586 {"hide_form", form_hide_form},
1587 {"redraw_form", form_redraw_form},
1588 {"set_form_position", form_set_form_position},
1589 {"freeze_form", form_freeze_form},
1590 {"unfreeze_form", form_unfreeze_form},
1591 {"display_form", form_display_form},
1592 {"remove_form", form_remove_form},
1593 {"activate_form", form_activate_form},
1594 {"deactivate_form", form_deactivate_form},
Guido van Rossum03747111991-08-08 12:10:01 +00001595 {"bgn_group", form_bgn_group},
1596 {"end_group", form_end_group},
Guido van Rossum75cc8981991-08-08 12:07:45 +00001597 {"find_first", form_find_first},
1598 {"find_last", form_find_last},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001599
1600/* basic objects */
1601 {"add_button", form_add_button},
1602/* {"add_bitmap", form_add_bitmap}, */
1603 {"add_lightbutton", form_add_lightbutton},
1604 {"add_roundbutton", form_add_roundbutton},
1605 {"add_menu", form_add_menu},
1606 {"add_slider", form_add_slider},
1607 {"add_positioner", form_add_positioner},
1608 {"add_valslider", form_add_valslider},
1609 {"add_dial", form_add_dial},
1610 {"add_counter", form_add_counter},
1611 {"add_default", form_add_default},
1612 {"add_box", form_add_box},
1613 {"add_clock", form_add_clock},
1614 {"add_choice", form_add_choice},
1615 {"add_browser", form_add_browser},
1616 {"add_input", form_add_input},
1617 {"add_timer", form_add_timer},
1618 {"add_text", form_add_text},
1619 {NULL, NULL} /* sentinel */
1620};
1621
1622static void
1623form_dealloc(f)
1624 formobject *f;
1625{
1626 /* XXX can't destroy form objects !!! */
1627 DEL(f);
1628}
1629
1630static object *
1631form_getattr(f, name)
1632 formobject *f;
1633 char *name;
1634{
1635 /* XXX check for data attr's: x, y etc. */
1636 return findmethod(form_methods, (object *)f, name);
1637}
1638
1639typeobject Formtype = {
1640 OB_HEAD_INIT(&Typetype)
1641 0, /*ob_size*/
1642 "form", /*tp_name*/
1643 sizeof(formobject), /*tp_size*/
1644 0, /*tp_itemsize*/
1645 /* methods */
1646 form_dealloc, /*tp_dealloc*/
1647 0, /*tp_print*/
1648 form_getattr, /*tp_getattr*/
1649 0, /*tp_setattr*/
1650 0, /*tp_compare*/
1651 0, /*tp_repr*/
1652};
1653
1654static object *
1655newformobject(form)
1656 FL_FORM *form;
1657{
1658 formobject *f;
1659 f = NEWOBJ(formobject, &Formtype);
1660 if (f == NULL)
1661 return NULL;
1662 f->ob_form = form;
1663 return (object *)f;
1664}
1665
1666/* The "fl" module */
1667static object *
1668forms_make_form(dummy, args)
1669 object *dummy;
1670 object *args;
1671{
1672 int type;
1673 float w, h;
1674 FL_FORM *form;
1675 if (!getintfloatfloatarg(args, &type, &w, &h))
1676 return NULL;
1677 form = fl_bgn_form(type, w, h);
1678 if (form == NULL) {
1679 /* XXX Actually, cannot happen! */
1680 err_nomem();
1681 return NULL;
1682 }
1683 fl_end_form();
1684 return newformobject(form);
1685}
1686
1687static object *my_event_callback = NULL;
1688
1689static object *
1690forms_set_event_call_back(dummy, args)
1691 object *dummy;
1692 object *args;
1693{
1694 my_event_callback = args;
1695 XINCREF(args);
1696 INCREF(None);
1697 return None;
1698}
1699
1700static object *
1701forms_do_or_check_forms(dummy, args, func)
1702 object *dummy;
1703 object *args;
1704 FL_OBJECT *(*func)();
1705{
1706 FL_OBJECT *generic;
1707 genericobject *g;
1708 object *arg, *res;
1709
1710 if (!getnoarg(args))
1711 return NULL;
1712
1713 for (;;) {
1714 generic = (*func)();
1715 if (generic == NULL) {
1716 INCREF(None);
1717 return None;
1718 }
1719 if (generic == FL_EVENT) {
1720 int dev;
1721 short val;
1722 if (my_event_callback == NULL)
1723 return newintobject(-1);
1724 dev = fl_qread(&val);
1725 arg = newtupleobject(2);
1726 if (arg == NULL)
1727 return NULL;
1728 settupleitem(arg, 0, newintobject((long)dev));
1729 settupleitem(arg, 1, newintobject((long)val));
1730 res = call_object(my_event_callback, arg);
1731 XDECREF(res);
1732 DECREF(arg);
1733 if (res == NULL)
1734 return NULL; /* Callback raised exception */
1735 continue;
1736 }
1737 g = findgeneric(generic);
1738 if (g == NULL) {
1739 err_setstr(RuntimeError,
1740 "do_forms returns unknown object");
1741 return NULL;
1742 }
1743 if (g->ob_callback == NULL) {
1744 INCREF(g);
1745 return ((object *) g);
1746 }
1747 arg = newtupleobject(2);
1748 INCREF(g);
1749 settupleitem(arg, 0, g);
1750 INCREF(g->ob_callback_arg);
1751 settupleitem(arg, 1, g->ob_callback_arg);
1752 res = call_object(g->ob_callback, arg);
1753 XDECREF(res);
1754 DECREF(arg);
1755 if (res == NULL)
1756 return NULL; /* Callback raised exception */
1757 }
1758}
1759
1760static object *
1761forms_do_forms (dummy, args)
1762 object *dummy;
1763 object *args;
1764{
1765 return forms_do_or_check_forms (dummy, args, fl_do_forms);
1766}
1767
1768static object *
1769forms_check_forms (dummy, args)
1770 object *dummy;
1771 object *args;
1772{
1773 return forms_do_or_check_forms (dummy, args, fl_check_forms);
1774}
1775
Guido van Rossum03747111991-08-08 12:10:01 +00001776#ifdef UNUSED
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001777static object *
1778fl_call(func, args)
1779 object *args;
1780 void (*func)();
1781{
1782 if (!getnoarg(args))
1783 return NULL;
1784 (*func)();
1785 INCREF(None);
1786 return None;
1787}
Guido van Rossum03747111991-08-08 12:10:01 +00001788#endif
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001789
1790static object *
1791forms_qdevice(self, args)
1792 object *self;
1793 object *args;
1794{
1795 short arg1 ;
1796 if (!getishortarg(args, 1, 0, &arg1))
1797 return NULL;
1798 fl_qdevice( arg1 );
1799 INCREF(None);
1800 return None;
1801}
1802
1803static object *
1804forms_unqdevice(self, args)
1805 object *self;
1806 object *args;
1807{
1808 short arg1 ;
1809 if (!getishortarg(args, 1, 0, &arg1))
1810 return NULL;
1811 fl_unqdevice( arg1 );
1812 INCREF(None);
1813 return None;
1814}
1815
1816static object *
1817forms_isqueued(self, args)
1818 object *self;
1819 object *args;
1820{
Guido van Rossum03747111991-08-08 12:10:01 +00001821 long retval;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001822 short arg1 ;
1823 if (!getishortarg(args, 1, 0, &arg1))
1824 return NULL;
1825 retval = fl_isqueued( arg1 );
1826
Guido van Rossum03747111991-08-08 12:10:01 +00001827 return newintobject(retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001828}
1829
1830static object *
1831forms_qtest(self, args)
1832 object *self;
1833 object *args;
1834{
1835 long retval;
1836 retval = fl_qtest( );
Guido van Rossum03747111991-08-08 12:10:01 +00001837 return newintobject(retval);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001838}
1839
1840
1841static object *
1842forms_qread(self, args)
1843 object *self;
1844 object *args;
1845{
1846 long retval;
1847 short arg1 ;
1848 retval = fl_qread( & arg1 );
1849 { object *v = newtupleobject( 2 );
1850 if (v == NULL) return NULL;
1851 settupleitem(v, 0, newintobject(retval));
1852 settupleitem(v, 1, newintobject((long)arg1));
1853 return v;
1854 }
1855}
1856
1857static object *
1858forms_qreset(self, args)
1859 object *self;
1860 object *args;
1861{
1862 if (!getnoarg(args)) return NULL;
1863
Guido van Rossum03747111991-08-08 12:10:01 +00001864 fl_qreset();
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001865 INCREF(None);
1866 return None;
1867}
1868
1869static object *
1870forms_qenter(self, args)
1871 object *self;
1872 object *args;
1873{
1874 short arg1 ;
1875 short arg2 ;
1876 if (!getishortarg(args, 2, 0, &arg1))
1877 return NULL;
1878 if (!getishortarg(args, 2, 1, &arg2))
1879 return NULL;
1880 fl_qenter( arg1 , arg2 );
1881 INCREF(None);
1882 return None;
1883}
1884
1885static object *
1886forms_color (self, args)
1887 object *self;
1888 object *args;
1889{
1890 int arg;
1891
1892 if (!getintarg(args, &arg)) return NULL;
1893
1894 fl_color((short) arg);
1895
1896 INCREF(None);
1897 return None;
1898}
1899
1900static object *
1901forms_mapcolor (self, args)
1902 object *self;
1903 object *args;
1904{
1905 int arg0, arg1, arg2, arg3;
1906
1907 if (!getintintintintarg(args, &arg0, &arg1, &arg2, &arg3))
1908 return NULL;
1909
1910 fl_mapcolor(arg0, (short) arg1, (short) arg2, (short) arg3);
1911
1912 INCREF(None);
1913 return None;
1914}
1915
1916static object *
1917forms_getmcolor (self, args)
1918 object *self;
1919 object *args;
1920{
Guido van Rossum03747111991-08-08 12:10:01 +00001921 int arg;
1922 short r, g, b;
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001923 object *v;
1924
1925 if (!getintarg(args, &arg)) return NULL;
1926
Guido van Rossum03747111991-08-08 12:10:01 +00001927 fl_getmcolor (arg, &r, &g, &b);
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001928
1929 v = newtupleobject(3);
1930
1931 if (v == NULL) return NULL;
1932
Guido van Rossum03747111991-08-08 12:10:01 +00001933 settupleitem(v, 0, newintobject((long)r));
1934 settupleitem(v, 1, newintobject((long)g));
1935 settupleitem(v, 2, newintobject((long)b));
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001936
1937 return v;
1938}
1939
1940static object *
Guido van Rossum75cc8981991-08-08 12:07:45 +00001941forms_get_mouse (self, args)
1942 object *self;
1943 object *args;
1944{
1945 float x, y ;
1946 object *v;
1947
1948 if (!getnoarg(args)) return NULL;
1949
1950 fl_get_mouse (&x, &y);
1951
1952 v = newtupleobject(2);
1953
1954 if (v == NULL) return NULL;
1955
1956 settupleitem(v, 0, newfloatobject(x));
1957 settupleitem(v, 1, newfloatobject(y));
1958
1959 return v;
1960}
1961
1962static object *
Guido van Rossumc7df79e1991-08-07 11:32:58 +00001963forms_tie(self, args)
1964 object *self;
1965 object *args;
1966{
1967 short arg1 ;
1968 short arg2 ;
1969 short arg3 ;
1970 if (!getishortarg(args, 3, 0, &arg1))
1971 return NULL;
1972 if (!getishortarg(args, 3, 1, &arg2))
1973 return NULL;
1974 if (!getishortarg(args, 3, 2, &arg3))
1975 return NULL;
1976 fl_tie( arg1 , arg2 , arg3 );
1977 INCREF(None);
1978 return None;
1979}
1980
Guido van Rossum03747111991-08-08 12:10:01 +00001981static object *
1982forms_show_message (f, args)
1983 object *f;
1984 object *args;
1985{
1986 object *a, *b, *c;
1987
1988 if (!getstrstrstrarg(args, &a, &b, &c)) return NULL;
1989
1990 fl_show_message (
1991 getstringvalue(a), getstringvalue(b), getstringvalue(c));
1992
1993 INCREF (None);
1994 return None;
1995}
1996
1997static object *
1998forms_show_question (f, args)
1999 object *f;
2000 object *args;
2001{
2002 int ret;
2003 object *a, *b, *c;
2004
2005 if (!getstrstrstrarg(args, &a, &b, &c)) return NULL;
2006
2007 ret = fl_show_question (
2008 getstringvalue(a), getstringvalue(b), getstringvalue(c));
2009
2010 return newintobject ((long) ret);
2011}
2012
2013static object *
2014forms_show_input (f, args)
2015 object *f;
2016 object *args;
2017{
2018 char *str;
2019 object *a, *b;
2020
2021 if (!getstrstrarg(args, &a, &b)) return NULL;
2022
2023 str = fl_show_input (getstringvalue(a), getstringvalue(b));
2024
2025 return newstringobject (str);
2026}
2027
2028static object *
2029forms_file_selector (f, args)
2030 object *f;
2031 object *args;
2032{
2033 char *str;
2034 object *a, *b, *c, *d;
2035
2036 if (!getstrstrstrstrarg(args, &a, &b, &c, &d)) return NULL;
2037
2038 str = fl_show_file_selector (getstringvalue(a), getstringvalue(b),
2039 getstringvalue (c), getstringvalue (d));
2040
2041 return newstringobject (str);
2042}
2043
2044
2045static object *
2046forms_file_selector_func (args, func)
2047 object *args;
2048 char *(*func)();
2049{
2050 char *str;
2051
2052 str = (*func) ();
2053
2054 return newstringobject (str);
2055}
2056
2057static object *
2058forms_get_directory (f, args)
2059 object *f;
2060 object *args;
2061{
2062 return forms_file_selector_func (args, fl_get_directory);
2063}
2064
2065static object *
2066forms_get_pattern (f, args)
2067 object *f;
2068 object *args;
2069{
2070 return forms_file_selector_func (args, fl_get_pattern);
2071}
2072
2073static object *
2074forms_get_filename (f, args)
2075 object *f;
2076 object *args;
2077{
2078 return forms_file_selector_func (args, fl_get_filename);
2079
2080}
2081
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002082static struct methodlist forms_methods[] = {
2083/* adm */
2084 {"make_form", forms_make_form},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002085/* gl support wrappers */
2086 {"qdevice", forms_qdevice},
2087 {"unqdevice", forms_unqdevice},
2088 {"isqueued", forms_isqueued},
2089 {"qtest", forms_qtest},
2090 {"qread", forms_qread},
2091/* {"blkqread", forms_blkqread}, */
2092 {"qreset", forms_qreset},
2093 {"qenter", forms_qenter},
Guido van Rossum03747111991-08-08 12:10:01 +00002094 {"get_mouse", forms_get_mouse},
2095 {"tie", forms_tie},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002096/* {"new_events", forms_new_events}, */
2097 {"color", forms_color},
2098 {"mapcolor", forms_mapcolor},
2099 {"getmcolor", forms_getmcolor},
2100/* interaction */
2101 {"do_forms", forms_do_forms},
2102 {"check_forms", forms_check_forms},
2103 {"set_event_call_back", forms_set_event_call_back},
2104/* goodies */
Guido van Rossum03747111991-08-08 12:10:01 +00002105 {"show_message", forms_show_message},
2106 {"show_question", forms_show_question},
2107 {"file_selector", forms_file_selector},
2108 {"get_directory", forms_get_directory},
2109 {"get_pattern", forms_get_pattern},
2110 {"get_filename", forms_get_filename},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002111/*
Guido van Rossum03747111991-08-08 12:10:01 +00002112 {"show_choice", forms_show_choice},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002113 XXX - draw.c
2114*/
Guido van Rossum03747111991-08-08 12:10:01 +00002115 {"show_input", forms_show_input},
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002116 {NULL, NULL} /* sentinel */
2117};
2118
2119void
2120initfl()
2121{
2122 initmodule("fl", forms_methods);
2123 foreground ();
2124}
2125
2126
2127/* Support routines */
2128
2129int
2130getintintstrarg(args, a, b, c)
2131 object *args;
2132 int *a, *b;
2133 object **c;
2134{
2135 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
2136 err_badarg();
2137 return NULL;
2138 }
2139 return getintarg(gettupleitem(args, 0), a) &&
2140 getintarg(gettupleitem(args, 1), b) &&
2141 getstrarg(gettupleitem(args, 2), c);
2142}
2143
2144int
2145getintfloatfloatarg(args, a, b, c)
2146 object *args;
2147 int *a;
2148 float *b, *c;
2149{
2150 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
2151 err_badarg();
2152 return NULL;
2153 }
2154 return getintarg(gettupleitem(args, 0), a) &&
2155 getfloatarg(gettupleitem(args, 1), b) &&
2156 getfloatarg(gettupleitem(args, 2), c);
2157}
2158
2159int
2160getintintintintarg(args, a, b, c, d)
2161 object *args;
2162 int *a, *b, *c, *d;
2163{
2164 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 4) {
2165 err_badarg();
2166 return NULL;
2167 }
2168 return getintarg(gettupleitem(args, 0), a) &&
2169 getintarg(gettupleitem(args, 1), b) &&
2170 getintarg(gettupleitem(args, 2), c) &&
2171 getintarg(gettupleitem(args, 3), d);
2172}
2173
2174int
2175getfloatarg(args, a)
2176 object *args;
2177 float *a;
2178{
2179 double x;
2180 if (!getdoublearg(args, &x))
2181 return 0;
2182 *a = x;
2183 return 1;
2184}
2185
2186int
Guido van Rossum03747111991-08-08 12:10:01 +00002187getintfloatfloatfloatfloatstrarg(args, type, x, y, w, h, name)
Guido van Rossumc7df79e1991-08-07 11:32:58 +00002188 object *args;
2189 int *type;
2190 float *x, *y, *w, *h;
2191 object **name;
2192{
2193 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 6) {
2194 err_badarg();
2195 return NULL;
2196 }
2197 return getintarg(gettupleitem(args, 0), type) &&
2198 getfloatarg(gettupleitem(args, 1), x) &&
2199 getfloatarg(gettupleitem(args, 2), y) &&
2200 getfloatarg(gettupleitem(args, 3), w) &&
2201 getfloatarg(gettupleitem(args, 4), h) &&
2202 getstrarg(gettupleitem(args, 5), name);
2203}
2204
2205int
2206getfloatfloatfloatarg(args, f1, f2, f3)
2207 object *args;
2208 float *f1, *f2, *f3;
2209{
2210 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 3) {
2211 err_badarg();
2212 return NULL;
2213 }
2214 return getfloatarg(gettupleitem(args, 0), f1) &&
2215 getfloatarg(gettupleitem(args, 1), f2) &&
2216 getfloatarg(gettupleitem(args, 2), f3);
2217}
2218
2219int
2220getfloatfloatarg(args, f1, f2)
2221 object *args;
2222 float *f1, *f2;
2223{
2224 if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 2) {
2225 err_badarg();
2226 return NULL;
2227 }
2228 return getfloatarg(gettupleitem(args, 0), f1) &&
2229 getfloatarg(gettupleitem(args, 1), f2);
2230}
2231
2232int
2233getstrstrstrarg(v, a, b, c)
2234 object *v;
2235 object **a;
2236 object **b;
2237 object **c;
2238{
2239 if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 3) {
2240 return err_badarg();
2241 }
2242 return getstrarg(gettupleitem(v, 0), a) &&
2243 getstrarg(gettupleitem(v, 1), b)&&
2244 getstrarg(gettupleitem(v, 2), c);
2245}
2246
2247
2248int
2249getstrstrstrstrarg(v, a, b, c, d)
2250 object *v;
2251 object **a;
2252 object **b;
2253 object **c;
2254 object **d;
2255{
2256 if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 4) {
2257 return err_badarg();
2258 }
2259 return getstrarg(gettupleitem(v, 0), a) &&
2260 getstrarg(gettupleitem(v, 1), b)&&
2261 getstrarg(gettupleitem(v, 2), c) &&
2262 getstrarg(gettupleitem(v, 3),d);
2263
2264}