/* 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 my_canvas_draw_select(t_my_canvas* x, t_glist* glist); /* ---------- cnv my gui-canvas for a window ---------------- */ t_widgetbehavior my_canvas_widgetbehavior; static t_class *my_canvas_class; /* widget helper functions */ void my_canvas_draw_new(t_my_canvas *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%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(glist)) { sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags {%lxRECT %lxMYCNV text}\n", canvas, xpos, ypos, xpos + x->x_vis_w, ypos + x->x_vis_h, x->x_gui.x_bcol, x->x_gui.x_bcol, x, x); sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline #%6.6x -tags {%lxBASE %lxMYCNV text}\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 text %d %d -text {%s} -anchor w \ -font {{%s} -%d %s} -fill #%6.6x -tags {%lxLABEL %lxMYCNV text}\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); //} } void my_canvas_draw_move(t_my_canvas *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)) { sys_vgui(".x%lx.c coords %lxRECT %d %d %d %d\n", canvas, x, xpos, ypos, xpos + x->x_vis_w, ypos + x->x_vis_h); 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 %lxLABEL %d %d\n", canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) { my_canvas_draw_select(x, x->x_gui.x_glist); } } } void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c delete %lxMYCNV\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxMYCNV\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 %lxRECT\n", canvas, x); //sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); } void my_canvas_draw_config(t_my_canvas* 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_bcol); */ sys_vgui(".x%lx.c itemconfigure %lxRECT -fill #%6.6x -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol); if (x->x_gui.x_fsf.x_selected) sys_vgui(".x%lx.c itemconfigure %lxBASE -outline $select_color\n", canvas, x); else sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol); 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:""); } void my_canvas_draw_select(t_my_canvas* 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) { // check if we are drawing inside a gop abstraction visible on parent canvas // if so, disable highlighting if (x->x_gui.x_glist == glist_getcanvas(glist)) { sys_vgui(".x%lx.c itemconfigure %lxBASE -outline $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 %lxMYCNV}\n", canvas, x->x_gui.x_obj.te_xpix + x->x_vis_w - SCALEHANDLE_WIDTH - 1, x->x_gui.x_obj.te_ypix + x->x_vis_h - SCALEHANDLE_HEIGHT - 1, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, sh->h_pathname, x, x); sys_vgui("bind %s