1 /* (C) Guenter Geiger <geiger@xdv.org> */
7 /* ------------------------ gcanvas ----------------------------- */
10 #define BACKGROUNDCOLOR "grey"
12 #define DEFAULTSIZE 80
14 static t_class
*gcanvas_class
;
16 typedef struct _gcanvas
31 static void rectangle(void* cv
,void* o
,char c
,int x
, int y
,int w
,int h
,char* color
) {
32 sys_vgui(".x%x.c create rectangle \
33 %d %d %d %d -tags %x%c -fill %s\n",cv
,x
,y
,x
+w
,y
+h
,o
,c
,color
);
36 static void move_object(void* cv
,void* o
,char c
,int x
, int y
,int w
,int h
) {
37 sys_vgui(".x%x.c coords %x%c %d %d %d %d\n",
42 static void color_object(void* cv
,void* o
,char c
,char* color
) {
43 sys_vgui(".x%x.c itemconfigure %x%c -fill %s\n", cv
,
47 static void delete_object(void* cv
,void* o
,char c
) {
48 sys_vgui(".x%x.c delete %x%c\n",
52 static void line(void* cv
,void* o
,char c
,int x
,int y
,int w
,int h
,char* color
) {
53 sys_vgui(".x%x.c create line \
54 %d %d %d %d -tags %x%c -fill %s\n",cv
,x
,y
,x
+w
,y
+h
,o
,c
,color
);
58 /* widget helper functions */
60 void gcanvas_drawme(t_gcanvas
*x
, t_glist
*glist
, int firsttime
)
64 rectangle(glist_getcanvas(glist
),x
,'a',
65 x
->x_obj
.te_xpix
, x
->x_obj
.te_ypix
,
66 x
->x_width
, x
->x_height
,BACKGROUNDCOLOR
);
67 for (i
=1;i
<x
->x_xgrid
;i
++)
68 line(glist_getcanvas(glist
),x
,'b'+ i
,
69 x
->x_obj
.te_xpix
+ x
->x_width
*i
/x
->x_xgrid
,
71 0, x
->x_height
,"red");
72 for (i
=1;i
<x
->x_ygrid
;i
++)
73 line(glist_getcanvas(glist
),x
,'B'+ i
,
75 x
->x_obj
.te_ypix
+ x
->x_height
*i
/x
->x_ygrid
,
76 x
->x_width
, 0,"blue");
80 glist_getcanvas(glist
),x
,'a',
81 x
->x_obj
.te_xpix
, x
->x_obj
.te_ypix
,
82 x
->x_width
, x
->x_height
);
83 for (i
=1;i
<x
->x_xgrid
;i
++)
84 move_object(glist_getcanvas(glist
),x
,'b'+ i
,
85 x
->x_obj
.te_xpix
+ x
->x_width
*i
/x
->x_xgrid
,
88 for (i
=1;i
<x
->x_ygrid
;i
++)
89 move_object(glist_getcanvas(glist
),x
,'B'+ i
,
91 x
->x_obj
.te_ypix
+ x
->x_height
*i
/x
->x_ygrid
,
99 nplus
= (n
== 1 ? 1 : n
-1);
100 for (i
= 0; i
< n
; i
++)
102 int onset
= x
->x_obj
.te_xpix
+ (x
->x_width
- IOWIDTH
) * i
/ nplus
;
104 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
105 glist_getcanvas(glist
),
106 onset
, x
->x_obj
.te_ypix
+ x
->x_height
- 1,
107 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ x
->x_height
,
110 sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
111 glist_getcanvas(glist
), x
, i
,
112 onset
, x
->x_obj
.te_ypix
+ x
->x_height
- 1,
113 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ x
->x_height
);
117 nplus
= (n
== 1 ? 1 : n
-1);
118 for (i
= 0; i
< n
; i
++)
120 int onset
= x
->x_obj
.te_xpix
+ (x
->x_width
- IOWIDTH
) * i
/ nplus
;
122 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
123 glist_getcanvas(glist
),
124 onset
, x
->x_obj
.te_ypix
,
125 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ 1,
128 sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
129 glist_getcanvas(glist
), x
, i
,
130 onset
, x
->x_obj
.te_ypix
,
131 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ 1);
141 void gcanvas_erase(t_gcanvas
* x
,t_glist
* glist
)
144 delete_object(glist_getcanvas(glist
),x
,'a');
145 for (i
=1;i
<x
->x_xgrid
;i
++)
146 delete_object(glist_getcanvas(glist
),x
,'b'+ i
);
147 for (i
=1;i
<x
->x_ygrid
;i
++)
148 delete_object(glist_getcanvas(glist
),x
,'B'+ i
);
152 sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist
),x
,n
);
158 /* ------------------------ gcanvas widgetbehaviour----------------------------- */
161 static void gcanvas_getrect(t_gobj
*z
, t_glist
*owner
,
162 int *xp1
, int *yp1
, int *xp2
, int *yp2
)
165 t_gcanvas
* s
= (t_gcanvas
*)z
;
169 height
= s
->x_height
;
170 *xp1
= s
->x_obj
.te_xpix
;
171 *yp1
= s
->x_obj
.te_ypix
;
172 *xp2
= s
->x_obj
.te_xpix
+ width
;
173 *yp2
= s
->x_obj
.te_ypix
+ height
;
176 static void gcanvas_displace(t_gobj
*z
, t_glist
*glist
,
179 t_gcanvas
*x
= (t_gcanvas
*)z
;
180 x
->x_obj
.te_xpix
+= dx
;
181 x
->x_obj
.te_ypix
+= dy
;
182 gcanvas_drawme(x
, glist
, 0);
183 canvas_fixlinesfor(glist_getcanvas(glist
),(t_text
*) x
);
186 static void gcanvas_select(t_gobj
*z
, t_glist
*glist
, int state
)
188 t_gcanvas
*x
= (t_gcanvas
*)z
;
189 color_object(glist
,x
,'a',state
? "blue" : BACKGROUNDCOLOR
);
193 static void gcanvas_activate(t_gobj
*z
, t_glist
*glist
, int state
)
195 /* t_text *x = (t_text *)z;
196 t_rtext *y = glist_findrtext(glist, x);
197 if (z->g_pd != gatom_class) rtext_activate(y, state);*/
200 static void gcanvas_delete(t_gobj
*z
, t_glist
*glist
)
202 t_text
*x
= (t_text
*)z
;
203 canvas_deletelinesfor(glist_getcanvas(glist
), x
);
207 static void gcanvas_vis(t_gobj
*z
, t_glist
*glist
, int vis
)
209 t_gcanvas
* s
= (t_gcanvas
*)z
;
211 gcanvas_drawme(s
, glist
, 1);
213 gcanvas_erase(s
,glist
);
216 /* can we use the normal text save function ?? */
218 static void gcanvas_save(t_gobj
*z
, t_binbuf
*b
)
220 t_gcanvas
*x
= (t_gcanvas
*)z
;
221 binbuf_addv(b
, "ssiisiiii", gensym("#X"),gensym("obj"),
222 (t_int
)x
->x_obj
.te_xpix
, (t_int
)x
->x_obj
.te_ypix
,
223 gensym("gcanvas"),x
->x_width
,x
->x_height
,
230 t_widgetbehavior gcanvas_widgetbehavior
;
232 static void gcanvas_motion(t_gcanvas
*x
, t_floatarg dx
, t_floatarg dy
)
236 outlet_float(x
->out2
,x
->y
);
237 outlet_float(x
->x_obj
.ob_outlet
,x
->x
);
240 void gcanvas_key(t_gcanvas
*x
, t_floatarg f
)
246 static void gcanvas_click(t_gcanvas
*x
,
247 t_floatarg xpos
, t_floatarg ypos
, t_floatarg shift
, t_floatarg ctrl
,
248 t_floatarg doit
,int up
)
250 glist_grab(x
->x_glist
, &x
->x_obj
.te_g
, (t_glistmotionfn
) gcanvas_motion
,
251 (t_glistkeyfn
) NULL
, xpos
, ypos
);
253 x
->x
= xpos
- x
->x_obj
.te_xpix
;
254 x
->y
= ypos
- x
->x_obj
.te_ypix
;
255 outlet_float(x
->out2
,x
->y
);
256 outlet_float(x
->x_obj
.ob_outlet
,x
->x
);
257 outlet_float(x
->out3
,0);
260 static int gcanvas_newclick(t_gobj
*z
, struct _glist
*glist
,
261 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
)
264 gcanvas_click((t_gcanvas
*)z
, (t_floatarg
)xpix
, (t_floatarg
)ypix
,
265 (t_floatarg
)shift
, 0, (t_floatarg
)alt
,dbl
);
267 if (dbl
) outlet_float(((t_gcanvas
*)z
)->out3
,1);
271 void gcanvas_size(t_gcanvas
* x
,t_floatarg w
,t_floatarg h
) {
274 gcanvas_drawme(x
, x
->x_glist
, 0);
277 static void gcanvas_setwidget(void)
279 gcanvas_widgetbehavior
.w_getrectfn
= gcanvas_getrect
;
280 gcanvas_widgetbehavior
.w_displacefn
= gcanvas_displace
;
281 gcanvas_widgetbehavior
.w_selectfn
= gcanvas_select
;
282 gcanvas_widgetbehavior
.w_activatefn
= gcanvas_activate
;
283 gcanvas_widgetbehavior
.w_deletefn
= gcanvas_delete
;
284 gcanvas_widgetbehavior
.w_visfn
= gcanvas_vis
;
285 gcanvas_widgetbehavior
.w_clickfn
= gcanvas_newclick
;
286 class_setsavefn(gcanvas_class
,gcanvas_save
);
290 static void *gcanvas_new(t_symbol
* s
,t_int ac
,t_atom
* at
)
292 t_gcanvas
*x
= (t_gcanvas
*)pd_new(gcanvas_class
);
294 x
->x_glist
= (t_glist
*) canvas_getcurrent();
297 /* Fetch the width */
299 x
->x_width
= DEFAULTSIZE
;
301 if (at
->a_type
!= A_FLOAT
)
302 error("gcanvas: wrong argument type");
304 x
->x_width
= atom_getfloat(at
++);
306 if (x
->x_width
< 0 || x
->x_width
> 2000) {
307 error("gcanvas: unallowed width %f",x
->x_width
);
308 x
->x_width
= DEFAULTSIZE
;
312 /* Fetch the height */
314 x
->x_height
= DEFAULTSIZE
;
316 if (at
->a_type
!= A_FLOAT
)
317 error("gcanvas: wrong argument type");
319 x
->x_height
= atom_getfloat(at
++);
321 if (x
->x_height
< 0 || x
->x_height
> 2000) {
322 error("gcanvas: unallowed height %f",x
->x_height
);
323 x
->x_width
= DEFAULTSIZE
;
327 /* Fetch the xgrid */
331 if (at
->a_type
!= A_FLOAT
)
332 error("gcanvas: wrong argument type");
334 x
->x_xgrid
= atom_getfloat(at
++);
336 if (x
->x_xgrid
< 0 || x
->x_xgrid
> x
->x_width
/2) {
337 error("gcanvas: unallowed xgrid %f",x
->x_xgrid
);
342 /* Fetch the ygrid */
346 if (at
->a_type
!= A_FLOAT
)
347 error("gcanvas: wrong argument type");
349 x
->x_ygrid
= atom_getfloat(at
++);
351 if (x
->x_ygrid
< 0 || x
->x_ygrid
> x
->x_height
/2) {
352 error("gcanvas: unallowed xgrid %f",x
->x_ygrid
);
357 outlet_new(&x
->x_obj
, &s_float
);
358 x
->out2
= outlet_new(&x
->x_obj
, &s_float
);
359 x
->out3
= outlet_new(&x
->x_obj
, &s_float
);
365 void gcanvas_setup(void)
367 gcanvas_class
= class_new(gensym("gcanvas"), (t_newmethod
)gcanvas_new
, 0,
368 sizeof(t_gcanvas
),0, A_GIMME
,0);
370 class_addmethod(gcanvas_class
, (t_method
)gcanvas_click
, gensym("click"),
371 A_FLOAT
, A_FLOAT
, A_FLOAT
, A_FLOAT
, A_FLOAT
, 0);
372 class_addmethod(gcanvas_class
, (t_method
)gcanvas_size
, gensym("size"),
373 A_FLOAT
, A_FLOAT
, 0);
376 class_setwidget(gcanvas_class
,&gcanvas_widgetbehavior
);
380 /* (C) Guenter Geiger <geiger@xdv.org> */
384 #include "g_canvas.h"
386 /* ------------------------ gcanvas ----------------------------- */
389 #define BACKGROUNDCOLOR "grey"
391 #define DEFAULTSIZE 80
393 static t_class
*gcanvas_class
;
395 typedef struct _gcanvas
410 static void rectangle(void* cv
,void* o
,char c
,int x
, int y
,int w
,int h
,char* color
) {
411 sys_vgui(".x%x.c create rectangle \
412 %d %d %d %d -tags %x%c -fill %s\n",cv
,x
,y
,x
+w
,y
+h
,o
,c
,color
);
415 static void move_object(void* cv
,void* o
,char c
,int x
, int y
,int w
,int h
) {
416 sys_vgui(".x%x.c coords %x%c %d %d %d %d\n",
421 static void color_object(void* cv
,void* o
,char c
,char* color
) {
422 sys_vgui(".x%x.c itemconfigure %x%c -fill %s\n", cv
,
426 static void delete_object(void* cv
,void* o
,char c
) {
427 sys_vgui(".x%x.c delete %x%c\n",
431 static void line(void* cv
,void* o
,char c
,int x
,int y
,int w
,int h
,char* color
) {
432 sys_vgui(".x%x.c create line \
433 %d %d %d %d -tags %x%c -fill %s\n",cv
,x
,y
,x
+w
,y
+h
,o
,c
,color
);
437 /* widget helper functions */
439 void gcanvas_drawme(t_gcanvas
*x
, t_glist
*glist
, int firsttime
)
443 rectangle(glist_getcanvas(glist
),x
,'a',
444 x
->x_obj
.te_xpix
, x
->x_obj
.te_ypix
,
445 x
->x_width
, x
->x_height
,BACKGROUNDCOLOR
);
446 for (i
=1;i
<x
->x_xgrid
;i
++)
447 line(glist_getcanvas(glist
),x
,'b'+ i
,
448 x
->x_obj
.te_xpix
+ x
->x_width
*i
/x
->x_xgrid
,
450 0, x
->x_height
,"red");
451 for (i
=1;i
<x
->x_ygrid
;i
++)
452 line(glist_getcanvas(glist
),x
,'B'+ i
,
454 x
->x_obj
.te_ypix
+ x
->x_height
*i
/x
->x_ygrid
,
455 x
->x_width
, 0,"blue");
459 glist_getcanvas(glist
),x
,'a',
460 x
->x_obj
.te_xpix
, x
->x_obj
.te_ypix
,
461 x
->x_width
, x
->x_height
);
462 for (i
=1;i
<x
->x_xgrid
;i
++)
463 move_object(glist_getcanvas(glist
),x
,'b'+ i
,
464 x
->x_obj
.te_xpix
+ x
->x_width
*i
/x
->x_xgrid
,
467 for (i
=1;i
<x
->x_ygrid
;i
++)
468 move_object(glist_getcanvas(glist
),x
,'B'+ i
,
470 x
->x_obj
.te_ypix
+ x
->x_height
*i
/x
->x_ygrid
,
478 nplus
= (n
== 1 ? 1 : n
-1);
479 for (i
= 0; i
< n
; i
++)
481 int onset
= x
->x_obj
.te_xpix
+ (x
->x_width
- IOWIDTH
) * i
/ nplus
;
483 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
484 glist_getcanvas(glist
),
485 onset
, x
->x_obj
.te_ypix
+ x
->x_height
- 1,
486 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ x
->x_height
,
489 sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
490 glist_getcanvas(glist
), x
, i
,
491 onset
, x
->x_obj
.te_ypix
+ x
->x_height
- 1,
492 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ x
->x_height
);
496 nplus
= (n
== 1 ? 1 : n
-1);
497 for (i
= 0; i
< n
; i
++)
499 int onset
= x
->x_obj
.te_xpix
+ (x
->x_width
- IOWIDTH
) * i
/ nplus
;
501 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
502 glist_getcanvas(glist
),
503 onset
, x
->x_obj
.te_ypix
,
504 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ 1,
507 sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
508 glist_getcanvas(glist
), x
, i
,
509 onset
, x
->x_obj
.te_ypix
,
510 onset
+ IOWIDTH
, x
->x_obj
.te_ypix
+ 1);
520 void gcanvas_erase(t_gcanvas
* x
,t_glist
* glist
)
523 delete_object(glist_getcanvas(glist
),x
,'a');
524 for (i
=1;i
<x
->x_xgrid
;i
++)
525 delete_object(glist_getcanvas(glist
),x
,'b'+ i
);
526 for (i
=1;i
<x
->x_ygrid
;i
++)
527 delete_object(glist_getcanvas(glist
),x
,'B'+ i
);
531 sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist
),x
,n
);
537 /* ------------------------ gcanvas widgetbehaviour----------------------------- */
540 static void gcanvas_getrect(t_gobj
*z
, t_glist
*owner
,
541 int *xp1
, int *yp1
, int *xp2
, int *yp2
)
544 t_gcanvas
* s
= (t_gcanvas
*)z
;
548 height
= s
->x_height
;
549 *xp1
= s
->x_obj
.te_xpix
;
550 *yp1
= s
->x_obj
.te_ypix
;
551 *xp2
= s
->x_obj
.te_xpix
+ width
;
552 *yp2
= s
->x_obj
.te_ypix
+ height
;
555 static void gcanvas_displace(t_gobj
*z
, t_glist
*glist
,
558 t_gcanvas
*x
= (t_gcanvas
*)z
;
559 x
->x_obj
.te_xpix
+= dx
;
560 x
->x_obj
.te_ypix
+= dy
;
561 gcanvas_drawme(x
, glist
, 0);
562 canvas_fixlinesfor(glist_getcanvas(glist
),(t_text
*) x
);
565 static void gcanvas_select(t_gobj
*z
, t_glist
*glist
, int state
)
567 t_gcanvas
*x
= (t_gcanvas
*)z
;
568 color_object(glist
,x
,'a',state
? "blue" : BACKGROUNDCOLOR
);
572 static void gcanvas_activate(t_gobj
*z
, t_glist
*glist
, int state
)
574 /* t_text *x = (t_text *)z;
575 t_rtext *y = glist_findrtext(glist, x);
576 if (z->g_pd != gatom_class) rtext_activate(y, state);*/
579 static void gcanvas_delete(t_gobj
*z
, t_glist
*glist
)
581 t_text
*x
= (t_text
*)z
;
582 canvas_deletelinesfor(glist_getcanvas(glist
), x
);
586 static void gcanvas_vis(t_gobj
*z
, t_glist
*glist
, int vis
)
588 t_gcanvas
* s
= (t_gcanvas
*)z
;
590 gcanvas_drawme(s
, glist
, 1);
592 gcanvas_erase(s
,glist
);
595 /* can we use the normal text save function ?? */
597 static void gcanvas_save(t_gobj
*z
, t_binbuf
*b
)
599 t_gcanvas
*x
= (t_gcanvas
*)z
;
600 binbuf_addv(b
, "ssiisiiii", gensym("#X"),gensym("obj"),
601 (t_int
)x
->x_obj
.te_xpix
, (t_int
)x
->x_obj
.te_ypix
,
602 gensym("gcanvas"),x
->x_width
,x
->x_height
,
609 t_widgetbehavior gcanvas_widgetbehavior
;
611 static void gcanvas_motion(t_gcanvas
*x
, t_floatarg dx
, t_floatarg dy
)
615 outlet_float(x
->out2
,x
->y
);
616 outlet_float(x
->x_obj
.ob_outlet
,x
->x
);
619 void gcanvas_key(t_gcanvas
*x
, t_floatarg f
)
625 static void gcanvas_click(t_gcanvas
*x
,
626 t_floatarg xpos
, t_floatarg ypos
, t_floatarg shift
, t_floatarg ctrl
,
627 t_floatarg doit
,int up
)
629 glist_grab(x
->x_glist
, &x
->x_obj
.te_g
, (t_glistmotionfn
) gcanvas_motion
,
630 (t_glistkeyfn
) NULL
, xpos
, ypos
);
632 x
->x
= xpos
- x
->x_obj
.te_xpix
;
633 x
->y
= ypos
- x
->x_obj
.te_ypix
;
634 outlet_float(x
->out2
,x
->y
);
635 outlet_float(x
->x_obj
.ob_outlet
,x
->x
);
636 outlet_float(x
->out3
,0);
639 static int gcanvas_newclick(t_gobj
*z
, struct _glist
*glist
,
640 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
)
643 gcanvas_click((t_gcanvas
*)z
, (t_floatarg
)xpix
, (t_floatarg
)ypix
,
644 (t_floatarg
)shift
, 0, (t_floatarg
)alt
,dbl
);
646 if (dbl
) outlet_float(((t_gcanvas
*)z
)->out3
,1);
650 void gcanvas_size(t_gcanvas
* x
,t_floatarg w
,t_floatarg h
) {
653 gcanvas_drawme(x
, x
->x_glist
, 0);
656 static void gcanvas_setwidget(void)
658 gcanvas_widgetbehavior
.w_getrectfn
= gcanvas_getrect
;
659 gcanvas_widgetbehavior
.w_displacefn
= gcanvas_displace
;
660 gcanvas_widgetbehavior
.w_selectfn
= gcanvas_select
;
661 gcanvas_widgetbehavior
.w_activatefn
= gcanvas_activate
;
662 gcanvas_widgetbehavior
.w_deletefn
= gcanvas_delete
;
663 gcanvas_widgetbehavior
.w_visfn
= gcanvas_vis
;
664 gcanvas_widgetbehavior
.w_clickfn
= gcanvas_newclick
;
665 class_setsavefn(gcanvas_class
,gcanvas_save
);
669 static void *gcanvas_new(t_symbol
* s
,t_int ac
,t_atom
* at
)
671 t_gcanvas
*x
= (t_gcanvas
*)pd_new(gcanvas_class
);
673 x
->x_glist
= (t_glist
*) canvas_getcurrent();
676 /* Fetch the width */
678 x
->x_width
= DEFAULTSIZE
;
680 if (at
->a_type
!= A_FLOAT
)
681 error("gcanvas: wrong argument type");
683 x
->x_width
= atom_getfloat(at
++);
685 if (x
->x_width
< 0 || x
->x_width
> 2000) {
686 error("gcanvas: unallowed width %f",x
->x_width
);
687 x
->x_width
= DEFAULTSIZE
;
691 /* Fetch the height */
693 x
->x_height
= DEFAULTSIZE
;
695 if (at
->a_type
!= A_FLOAT
)
696 error("gcanvas: wrong argument type");
698 x
->x_height
= atom_getfloat(at
++);
700 if (x
->x_height
< 0 || x
->x_height
> 2000) {
701 error("gcanvas: unallowed height %f",x
->x_height
);
702 x
->x_width
= DEFAULTSIZE
;
706 /* Fetch the xgrid */
710 if (at
->a_type
!= A_FLOAT
)
711 error("gcanvas: wrong argument type");
713 x
->x_xgrid
= atom_getfloat(at
++);
715 if (x
->x_xgrid
< 0 || x
->x_xgrid
> x
->x_width
/2) {
716 error("gcanvas: unallowed xgrid %f",x
->x_xgrid
);
721 /* Fetch the ygrid */
725 if (at
->a_type
!= A_FLOAT
)
726 error("gcanvas: wrong argument type");
728 x
->x_ygrid
= atom_getfloat(at
++);
730 if (x
->x_ygrid
< 0 || x
->x_ygrid
> x
->x_height
/2) {
731 error("gcanvas: unallowed xgrid %f",x
->x_ygrid
);
736 outlet_new(&x
->x_obj
, &s_float
);
737 x
->out2
= outlet_new(&x
->x_obj
, &s_float
);
738 x
->out3
= outlet_new(&x
->x_obj
, &s_float
);
744 void gcanvas_setup(void)
746 gcanvas_class
= class_new(gensym("gcanvas"), (t_newmethod
)gcanvas_new
, 0,
747 sizeof(t_gcanvas
),0, A_GIMME
,0);
749 class_addmethod(gcanvas_class
, (t_method
)gcanvas_click
, gensym("click"),
750 A_FLOAT
, A_FLOAT
, A_FLOAT
, A_FLOAT
, A_FLOAT
, 0);
751 class_addmethod(gcanvas_class
, (t_method
)gcanvas_size
, gensym("size"),
752 A_FLOAT
, A_FLOAT
, 0);
755 class_setwidget(gcanvas_class
,&gcanvas_widgetbehavior
);