/* 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 bng_draw_select(t_bng* x, t_glist* glist); /* --------------- bng gui-bang ------------------------- */ t_widgetbehavior bng_widgetbehavior; static t_class *bng_class; /* widget helper functions */ void bng_draw_update(t_bng *x, t_glist *glist) { if(glist_isvisible(glist)) { sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", glist_getcanvas(glist), x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); } } void bng_draw_new(t_bng *x, t_glist *glist) { 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); t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle; sprintf(sh->h_pathname, ".x%x.h%x", (int)canvas, (int)sh); t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle; sprintf(lh->h_pathname, ".x%x.h%x", (int)canvas, (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"; sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags {%lxBASE %lxBNG}\n", canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, x->x_gui.x_bcol, x, x); sys_vgui(".x%lx.c create oval %d %d %d %d -fill #%6.6x -tags {%lxBUT %lxBNG}\n", canvas, xpos+1, ypos+1, xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1, x->x_flashed?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 %lxBNG}\n", canvas, xpos+x->x_gui.x_ldx, ypos+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 %lxBNG}\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, ypos + 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 %lxBNG}\n", canvas, xpos, ypos, xpos + IOWIDTH, ypos+1, nlet_tag, 0, x); } //} } void bng_draw_move(t_bng *x, t_glist *glist) { 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"; sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", canvas, x, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h); sys_vgui(".x%lx.c coords %lxBUT %d %d %d %d\n", canvas, x, xpos+1,ypos+1, xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1); sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xpos+x->x_gui.x_ldx, ypos+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, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, ypos + 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, xpos, ypos, xpos + IOWIDTH, ypos+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) bng_draw_select(x, x->x_gui.x_glist); } } void bng_draw_erase(t_bng* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c delete %lxBNG\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxBNG\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 %lxBUT\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 %so%d\n", canvas, rtext_gettag(yy), 0); if(!x->x_gui.x_fsf.x_rcv_able) sys_vgui(".x%lx.c delete %si%d\n", canvas, rtext_gettag(yy), 0); */ } void bng_draw_config(t_bng* 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:""); sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); } void bng_draw_io(t_bng* 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 bng_draw_select(t_bng* 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 %lxBUT -outline $select_color\n", canvas, x); sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill $select_color\n", canvas, x); 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 %lxBNG}\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