/* Copyright (c) 1997-1999 Miller Puckette. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ #include "config.h" #include #include #include #include #include "m_pd.h" #include "g_canvas.h" #include "t_tk.h" #include "g_all_guis.h" #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_IO_H #include #endif extern int gfxstub_haveproperties(void *key); void toggle_draw_select(t_toggle* x, t_glist* glist); /* --------------- tgl gui-toggle ------------------------- */ t_widgetbehavior toggle_widgetbehavior; static t_class *toggle_class; /* widget helper functions */ void toggle_draw_update(t_toggle *x, t_glist *glist) { if(glist_isvisible(glist)) { t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c itemconfigure %lxX1 -fill #%6.6x\n", canvas, x, (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); sys_vgui(".x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x, (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); } } void toggle_draw_new(t_toggle *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle; sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)sh); t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle; sprintf(lh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)lh); //if (glist_isvisible(canvas)) { t_gobj *y = (t_gobj *)x; t_object *ob = pd_checkobject(&y->g_pd); /* GOP objects are unable to call findrtext triggering consistency check error */ t_rtext *yyyy = NULL; if (!glist->gl_isgraph || glist_istoplevel(glist)) yyyy = glist_findrtext(canvas, (t_text *)&ob->ob_g); /* on GOP we cause segfault as apparently text_gettag() returns bogus data */ char *nlet_tag; if (yyyy) nlet_tag = rtext_gettag(yyyy); else nlet_tag = "bogus"; if(x->x_gui.x_w >= 30) w = 2; if(x->x_gui.x_w >= 60) w = 3; sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags {%lxBASE %lxTGL}\n", canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h, x->x_gui.x_bcol, x, x); sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags {%lxX1 %lxTGL}\n", canvas, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w, w, (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, x); sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags {%lxX2 %lxTGL}\n", canvas, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w, w, (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, x); sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d %s} -fill #%6.6x -tags {%lxLABEL %lxTGL}\n", canvas, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxTGL}\n", canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxTGL}\n", canvas, xx, yy, xx + IOWIDTH, yy+1, nlet_tag, 0, x); //} } void toggle_draw_move(t_toggle *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); if (glist_isvisible(canvas)) { t_gobj *y = (t_gobj *)x; t_object *ob = pd_checkobject(&y->g_pd); /* GOP objects are unable to call findrtext triggering consistency check error */ t_rtext *yyyy = NULL; if (!glist->gl_isgraph || glist_istoplevel(glist)) yyyy = glist_findrtext(canvas, (t_text *)&ob->ob_g); /* on GOP we cause segfault as apparently text_gettag() returns bogus data */ char *nlet_tag; if (yyyy) nlet_tag = rtext_gettag(yyyy); else nlet_tag = "bogus"; if(x->x_gui.x_w >= 30) w = 2; if(x->x_gui.x_w >= 60) w = 3; sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h); sys_vgui(".x%lx.c itemconfigure %lxX1 -width %d\n", canvas, x, w); sys_vgui(".x%lx.c coords %lxX1 %d %d %d %d\n", canvas, x, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w); sys_vgui(".x%lx.c itemconfigure %lxX2 -width %d\n", canvas, x, w); sys_vgui(".x%lx.c coords %lxX2 %d %d %d %d\n", canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w); sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", canvas, nlet_tag, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); if(!x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", canvas, nlet_tag, 0, xx, yy, xx + IOWIDTH, yy+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) toggle_draw_select(x, x->x_gui.x_glist); } } void toggle_draw_erase(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c delete %lxTGL\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxTGL\n", canvas, x); if (x->x_gui.x_fsf.x_selected) { t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); sys_vgui("destroy %s\n", sh->h_pathname); t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); sys_vgui("destroy %s\n", lh->h_pathname); } /* sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); sys_vgui(".x%lx.c delete %lxX1\n", canvas, x); sys_vgui(".x%lx.c delete %lxX2\n", canvas, x); sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); if(!x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0); if(!x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0); */ } void toggle_draw_config(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); /* char color[64]; if (x->x_gui.x_fsf.x_selected) sprintf(color, "$select_color"); else sprintf(color, "#%6.6x", x->x_gui.x_lcol); sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s} -fill %s -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, color, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); */ if (x->x_gui.x_fsf.x_selected) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s} -fill $select_color -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); } else { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} %d %s} -fill #%6.6x -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); } sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n .x%lx.c itemconfigure %lxX1 -fill #%6.6x\n .x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol , canvas, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol, canvas, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); /* sys_vgui(".x%lx.c itemconfigure %lxX1 -fill #%6.6x\n", canvas, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); sys_vgui(".x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x, x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); */ } void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) { int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); if (glist_isvisible(canvas)) { t_gobj *y = (t_gobj *)x; t_object *ob = pd_checkobject(&y->g_pd); /* GOP objects are unable to call findrtext triggering consistency check error */ t_rtext *yyyy = NULL; if (!glist->gl_isgraph || glist_istoplevel(glist)) yyyy = glist_findrtext(canvas, (t_text *)&ob->ob_g); /* on GOP we cause segfault as apparently text_gettag() returns bogus data */ char *nlet_tag; if (yyyy) nlet_tag = rtext_gettag(yyyy); else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, ypos + x->x_gui.x_h, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", canvas, xpos, ypos, xpos + IOWIDTH, ypos+1, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); } } void toggle_draw_select(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); if (glist_isvisible(canvas)) { if(x->x_gui.x_fsf.x_selected) { sys_vgui(".x%lx.c itemconfigure %lxBASE -outline $select_color\n", canvas, x); sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill $select_color\n", canvas, x); // check if we are drawing inside a gop abstraction visible on parent canvas // if so, disable drawing of the handles if (x->x_gui.x_glist == glist_getcanvas(glist)) { if (x->x_gui.scale_vis) sys_vgui("destroy %s\n", sh->h_pathname); sys_vgui("canvas %s -width %d -height %d -bg $select_color -bd 0 -cursor bottom_right_corner\n", sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT); sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxTGL}\n", canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w - SCALEHANDLE_WIDTH - 1, x->x_gui.x_obj.te_ypix + x->x_gui.x_h - SCALEHANDLE_HEIGHT - 1, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, sh->h_pathname, x, x); sys_vgui("bind %s