Update of /cvsroot/pure-data/externals/bbogart/entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28491
Modified Files: entry.c Log Message: refactored code to use variables for the widget IDs, should be more readable
Index: entry.c =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** entry.c 6 Nov 2007 16:13:54 -0000 1.24 --- entry.c 7 Nov 2007 05:58:05 -0000 1.25 *************** *** 39,42 **** --- 39,45 ---- #define BACKGROUNDCOLOR "grey70"
+ #define TOTAL_INLETS 1 + #define TOTAL_OUTLETS 2 + #define DEBUG(x) x
*************** *** 61,69 ****
t_float x_border; - t_float x_highlightthickness; t_symbol *x_relief; t_int x_have_scrollbar; ! t_canvas *canvas;
t_outlet* x_data_outlet; --- 64,79 ----
t_float x_border; t_symbol *x_relief; t_int x_have_scrollbar; ! t_canvas *canvas; + /* IDs for Tk widgets */ + char *tcl_namespace; + char *canvas_id; + char *frame_id; + char *text_id; + char *scrollbar_id; + char *handle_id; + char *window_id;
t_outlet* x_data_outlet; *************** *** 96,100 ****
! t_widgetbehavior entry_widgetbehavior = { w_getrectfn: entry_getrect, w_displacefn: entry_displace, --- 106,110 ----
! static t_widgetbehavior entry_widgetbehavior = { w_getrectfn: entry_getrect, w_displacefn: entry_displace, *************** *** 108,173 **** /* widget helper functions */
! static int calculate_onset(t_entry *x, t_glist *glist, int i, int nplus) { ! return(text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus); }
! static void draw_inlets(t_entry *x, t_glist *glist, int firsttime, int nin, int nout) { ! DEBUG(post("draw_inlets in: %d out: %d", nin, nout););
! int nplus, i, onset;
- nplus = (nin == 1 ? 1 : nin-1); /* inlets */ ! for (i = 0; i < nin; i++) { ! onset = calculate_onset(x,glist,i,nplus); if (firsttime) { ! DEBUG(post(".x%lx.c create rectangle %d %d %d %d -tags {%xi%d %xi}\n", ! x->canvas, onset, text_ypix(&x->x_obj, glist) - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) - 1, ! x, i, x);); ! sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%xi%d %xi}\n", ! x->canvas, onset, text_ypix(&x->x_obj, glist) - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) - 1, x, i, x); } else { ! DEBUG(post(".x%lx.c coords %xi%d %d %d %d %d\n", ! x->canvas, x, i, onset, text_ypix(&x->x_obj, glist) - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) - 1);); ! sys_vgui(".x%lx.c coords %xi%d %d %d %d %d\n", ! x->canvas, x, i, onset, text_ypix(&x->x_obj, glist) - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)- 1); } } ! nplus = (nout == 1 ? 1 : nout-1); ! for (i = 0; i < nout; i++) /* outlets */ { ! onset = calculate_onset(x,glist,i,nplus); if (firsttime) { ! DEBUG(post(".x%lx.c create rectangle %d %d %d %d -tags {%xo%d %xo}\n", ! x->canvas, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1, ! x, i, x);); ! sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%xo%d %xo}\n", ! x->canvas, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1, x, i, x); } else { ! DEBUG(post(".x%lx.c coords %xo%d %d %d %d %d\n", ! x->canvas, x, i, ! onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1);); ! sys_vgui(".x%lx.c coords %xo%d %d %d %d %d\n", ! x->canvas, x, i, ! onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1); } } --- 118,217 ---- /* widget helper functions */
! static void get_widget_state(t_entry *x) { ! // build list of options in Tcl ! // make Tcl foreach loop to get those options and create a list with the results ! // return results via callback receive as one big list }
! static void set_tk_widget_ids(t_entry *x, t_canvas *canvas) { ! char buf[MAXPDSTRING];
! x->canvas = canvas; ! ! /* Tk ID for the current canvas that this object is drawn in */ ! sprintf(buf,".x%lx.c", (long unsigned int) canvas); ! x->canvas_id = getbytes(strlen(buf)); ! strcpy(x->canvas_id, buf); ! ! /* Tk ID for the "frame" the other things are drawn in */ ! sprintf(buf,"%s.frame%lx", x->canvas_id, (long unsigned int)x); ! x->frame_id = getbytes(strlen(buf)); ! strcpy(x->frame_id, buf); ! ! sprintf(buf,"%s.text", x->frame_id); ! x->text_id = getbytes(strlen(buf)); ! strcpy(x->text_id, buf); /* Tk ID for the "text", the meat! */ ! ! sprintf(buf,"%s.window%lx", x->canvas_id, (long unsigned int)x); ! x->window_id = getbytes(strlen(buf)); ! strcpy(x->window_id, buf); /* Tk ID for the resizing "window" */ ! ! sprintf(buf,"%s.handle%lx", x->canvas_id, (long unsigned int)x); ! x->handle_id = getbytes(strlen(buf)); ! strcpy(x->handle_id, buf); /* Tk ID for the resizing "handle" */ ! ! sprintf(buf,"%s.scrollbar", x->frame_id); ! x->scrollbar_id = getbytes(strlen(buf)); ! strcpy(x->scrollbar_id, buf); /* Tk ID for the optional "scrollbar" */ ! ! post("buf: %s scrollbar_id %s", buf, x->scrollbar_id); ! post("buf: %s handle_id %s", buf, x->handle_id); ! } ! ! static void draw_resize_handle(t_entry *x) ! { ! ! } ! ! static int calculate_onset(t_entry *x, t_glist *glist, ! int current_iolet, int total_iolets) ! { ! return(text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) \ ! * current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1)); ! } ! ! static void draw_inlets(t_entry *x, t_glist *glist, int firsttime, ! int total_inlets, int total_outlets) ! { ! DEBUG(post("draw_inlets in: %d out: %d", total_inlets, total_outlets);); ! ! int i, onset;
/* inlets */ ! for (i = 0; i < total_inlets; i++) { ! onset = calculate_onset(x, glist, i, total_inlets); if (firsttime) { ! sys_vgui("%s create rectangle %d %d %d %d -tags {%xi%d %xi}\n", ! x->canvas_id, onset, text_ypix(&x->x_obj, glist) - 1, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist), x, i, x); } else { ! sys_vgui("%s coords %xi%d %d %d %d %d\n", ! x->canvas_id, x, i, onset, text_ypix(&x->x_obj, glist) - 1, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist)); } } ! for (i = 0; i < total_outlets; i++) /* outlets */ { ! onset = calculate_onset(x, glist, i, total_outlets); if (firsttime) { ! sys_vgui("%s create rectangle %d %d %d %d -tags {%xo%d %xo}\n", ! x->canvas_id, onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height, x, i, x); } else { ! sys_vgui("%s coords %xo%d %d %d %d %d\n", ! x->canvas_id, x, i, ! onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 1, ! onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height); } } *************** *** 179,214 **** DEBUG(post("erase_inlets");); /* Added tag for all inlets of one instance */ ! DEBUG(post(".x%lx.c delete %xi\n", x->canvas,x);); ! sys_vgui(".x%lx.c delete %xi\n", x->canvas,x); ! DEBUG(post(".x%lx.c delete %xo\n", x->canvas,x);); ! sys_vgui(".x%lx.c delete %xo\n", x->canvas,x); /* Added tag for all outlets of one instance */ ! DEBUG(post(".x%lx.c delete %xhandle\n", x->canvas,x,0);); ! sys_vgui(".x%lx.c delete %xhandle\n", x->canvas,x,0); }
- /* currently unused - static void draw_handle(t_entry *x, t_glist *glist, int firsttime) { - int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2); - - if (firsttime) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %xhandle\n", - x->canvas, - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, - onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4, - x); - else - sys_vgui(".x%lx.c coords %xhandle %d %d %d %d\n", - x->canvas, x, - onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 12, - onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4); - } - */ static void draw_scrollbar(t_entry *x) { ! DEBUG(post("pack .x%lx.c.s%x.scrollbar -side right -fill y -before .x%lx.c.s%x.text \n", ! x->canvas, x, x->canvas, x);); ! sys_vgui("pack .x%lx.c.s%x.scrollbar -side right -fill y -before .x%lx.c.s%x.text \n", ! x->canvas, x, x->canvas, x); x->x_have_scrollbar = 1; } --- 223,237 ---- DEBUG(post("erase_inlets");); /* Added tag for all inlets of one instance */ ! sys_vgui("%s delete %xi\n", x->canvas_id, x); ! sys_vgui("%s delete %xo\n", x->canvas_id, x); /* Added tag for all outlets of one instance */ ! sys_vgui("%s delete %xhandle\n", x->canvas_id, x); ! /* TODO are the above even active? */ }
static void draw_scrollbar(t_entry *x) { ! sys_vgui("pack %s -side right -fill y -before %s \n", ! x->scrollbar_id, x->text_id); x->x_have_scrollbar = 1; } *************** *** 216,221 **** static void erase_scrollbar(t_entry *x) { ! DEBUG(post("pack forget .x%lx.c.s%x.scrollbar \n", x->canvas, x);); ! sys_vgui("pack forget .x%lx.c.s%x.scrollbar \n", x->canvas, x); x->x_have_scrollbar = 0; } --- 239,243 ---- static void erase_scrollbar(t_entry *x) { ! sys_vgui("pack forget %s \n", x->scrollbar_id); x->x_have_scrollbar = 0; } *************** *** 223,241 **** static void bind_button_events(t_entry *x) { ! DEBUG(post("bind .x%lx.c.s%x.text <Button-2> \ ! {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->canvas, x, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix);); ! sys_vgui("bind .x%lx.c.s%x.text <Button-2> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->canvas, x, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind .x%lx.c.s%x.text <Control-Button> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->canvas, x, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind .x%lx.c.s%x.text <Button-3> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->canvas, x, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind .x%lx.c.s%x.text <Control-Button> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->canvas, x, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); }
--- 245,260 ---- static void bind_button_events(t_entry *x) { ! sys_vgui("bind %s <Button-2> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->text_id, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind %s <Control-Button> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->text_id, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind %s <Button-3> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->text_id, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); ! sys_vgui("bind %s <Control-Button> \ {pdtk_canvas_popup .x%lx [expr %%x + %d] [expr %%y + %d] 0 0} \n", ! x->text_id, x->canvas, x->x_obj.te_xpix, x->x_obj.te_ypix); }
*************** *** 246,289 **** x->x_rect_width = x->x_width; x->x_rect_height = x->x_height+2; - - DEBUG(post("namespace eval entry%lx {} \n", x);); - sys_vgui("namespace eval entry%lx {} \n", x);
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/ ! DEBUG(post("destroy .x%lx.c.s%x\n", x->canvas, x);); ! sys_vgui("destroy .x%lx.c.s%x\n", x->canvas, x); !
! DEBUG(post("frame .x%lx.c.s%x \n", x->canvas, x);); ! sys_vgui("frame .x%lx.c.s%x \n", x->canvas, x); ! DEBUG(post("text .x%lx.c.s%x.text -font {%s %d %s} -border 1 \ ! -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \ ! -yscrollcommand {.x%lx.c.s%x.scrollbar set} \n", ! x->canvas, x, x->x_font_face->s_name, x->x_font_size, ! x->x_font_weight->s_name, ! x->x_bgcolour->s_name,x->x_fgcolour->s_name, ! x->canvas, x);); ! sys_vgui("text .x%lx.c.s%x.text -font {%s %d %s} -border 1 \ ! -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \ ! -yscrollcommand {.x%lx.c.s%x.scrollbar set} \n", ! x->canvas, x, x->x_font_face->s_name, x->x_font_size, ! x->x_font_weight->s_name, ! x->x_bgcolour->s_name, x->x_fgcolour->s_name, ! x->canvas, x); ! DEBUG(post("scrollbar .x%lx.c.s%x.scrollbar -command {.x%lx.c.s%x.text yview} \n", ! x->canvas, x, x->canvas, x);); ! sys_vgui("scrollbar .x%lx.c.s%x.scrollbar -command {.x%lx.c.s%x.text yview} \n", ! x->canvas, x ,x->canvas, x); ! DEBUG(post("pack .x%lx.c.s%x.text -side left -fill both -expand 1 \n",x->canvas, x);); ! sys_vgui("pack .x%lx.c.s%x.text -side left -fill both -expand 1 \n", x->canvas, x); ! DEBUG(post("pack .x%lx.c.s%x -side bottom -fill both -expand 1 \n", x->canvas, x);); ! sys_vgui("pack .x%lx.c.s%x -side bottom -fill both -expand 1 \n", x->canvas, x);
! DEBUG(post("bind .x%lx.c.s%x.text <KeyRelease> {+pd %s keyup %%N \;} \n", ! x->canvas, x, x->x_receive_name->s_name);); ! sys_vgui("bind .x%lx.c.s%x.text <KeyRelease> {+pd %s keyup %%N \;} \n", ! x->canvas, x, x->x_receive_name->s_name); ! DEBUG(post("pdtk_standardkeybindings .x%lx.c.s%x.text \n", x->canvas, x);); ! sys_vgui("pdtk_standardkeybindings .x%lx.c.s%x.text \n", x->canvas, x);
bind_button_events(x); --- 265,291 ---- x->x_rect_width = x->x_width; x->x_rect_height = x->x_height+2;
+ sys_vgui("namespace eval entry%lx {} \n", x); + /* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/ ! sys_vgui("destroy %s\n", x->frame_id); !
! sys_vgui("frame %s \n", x->frame_id); ! sys_vgui("text %s -font {%s %d %s} -border 1 \ ! -highlightthickness 2 -relief sunken -bg "%s" -fg "%s" \ ! -yscrollcommand {%s set} \n", ! x->text_id, ! x->x_font_face->s_name, x->x_font_size, x->x_font_weight->s_name, ! x->x_bgcolour->s_name, x->x_fgcolour->s_name, ! x->scrollbar_id); ! sys_vgui("scrollbar %s -command {%s yview} \n", ! x->scrollbar_id, x->text_id); ! sys_vgui("pack %s -side left -fill both -expand 1 \n", x->text_id); ! sys_vgui("pack %s -side bottom -fill both -expand 1 \n", x->frame_id);
! sys_vgui("bind %s <KeyRelease> {+pd %s keyup %%N \;} \n", ! x->text_id, x->x_receive_name->s_name); ! sys_vgui("pdtk_standardkeybindings %s \n", x->text_id);
bind_button_events(x); *************** *** 292,321 **** static void entry_drawme(t_entry *x, t_glist *glist, int firsttime) { ! DEBUG(post("entry_drawme");); ! DEBUG(post("drawme %d",firsttime);); if (firsttime) { ! create_widget(x); ! DEBUG(post(".x%lx.c create window %d %d -anchor nw -window .x%lx.c.s%x \ ! -tags %xS -width %d -height %d \n", x->canvas, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->canvas, x, x, x->x_width, x->x_height);); ! sys_vgui(".x%lx.c create window %d %d -anchor nw -window .x%lx.c.s%x \ ! -tags %xS -width %d -height %d \n", x->canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->canvas, x,x, x->x_width, x->x_height); } else { ! DEBUG(post(".x%lx.c coords %xS %d %d\n", x->canvas, x, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));); ! sys_vgui(".x%lx.c coords %xS %d %d\n", x->canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! if( (glist->gl_edit) && (x->canvas == glist) ) /* this is buggy logic */ ! draw_inlets(x, glist, firsttime, 1,2); else erase_inlets(x); ! // draw_handle(x, glist, firsttime); }
--- 294,317 ---- static void entry_drawme(t_entry *x, t_glist *glist, int firsttime) { ! DEBUG(post("entry_drawme: firsttime %d canvas %s glist %s", firsttime, x->canvas, glist);); ! set_tk_widget_ids(x,glist_getcanvas(glist)); if (firsttime) { ! create_widget(x); /* TODO: what is this window for? */ ! sys_vgui("%s create window %d %d -anchor nw -window %s \ ! -tags %xS -width %d -height %d \n", x->canvas_id, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->frame_id,x, x->x_width, x->x_height); } else { ! sys_vgui("%s coords %xS %d %d\n", x->canvas_id, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! if(glist->gl_edit) /* this is buggy logic */ ! draw_inlets(x, glist, firsttime, TOTAL_INLETS, TOTAL_OUTLETS); else erase_inlets(x); ! // glist_drawiofor(glist, x->x_obj, firsttime, ); }
*************** *** 323,334 **** static void entry_erase(t_entry* x,t_glist* glist) { ! DEBUG(post("entry_erase");); ! DEBUG(post("destroy .x%lx.c.s%x\n", x->canvas, x);); ! sys_vgui("destroy .x%lx.c.s%x\n", x->canvas, x); ! ! DEBUG(post(".x%lx.c delete %xS\n", x->canvas, x);); ! sys_vgui(".x%lx.c delete %xS\n", x->canvas, x);
erase_inlets(x); } --- 319,327 ---- static void entry_erase(t_entry* x,t_glist* glist) { ! DEBUG(post("entry_erase: canvas %s glist %s", x->canvas, glist););
erase_inlets(x); + sys_vgui("destroy %s\n", x->frame_id); + sys_vgui("%s delete %xS\n", x->canvas_id, x); } *************** *** 341,345 **** int *xp1, int *yp1, int *xp2, int *yp2) { ! /* DEBUG(post("entry_getrect");); */ int width, height; t_entry* s = (t_entry*)z; --- 334,338 ---- int *xp1, int *yp1, int *xp2, int *yp2) { ! /* DEBUG(post("entry_getrect");); */ /* this one is very chatty :D */ int width, height; t_entry* s = (t_entry*)z; *************** *** 355,369 **** static void entry_displace(t_gobj *z, t_glist *glist, int dx, int dy) { - DEBUG(post("entry_displace");); t_entry *x = (t_entry *)z; x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; if (glist_isvisible(glist)) { ! DEBUG(post(".x%lx.c coords %xSEL %d %d %d %d\n", x->canvas, x, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, ! text_xpix(&x->x_obj, glist) + x->x_rect_width, ! text_ypix(&x->x_obj, glist) + x->x_rect_height-2);); ! sys_vgui(".x%lx.c coords %xSEL %d %d %d %d\n", x->canvas, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, --- 348,358 ---- static void entry_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_entry *x = (t_entry *)z; + DEBUG(post("entry_displace: canvas %s glist %s", x->canvas, glist);); x->x_obj.te_xpix += dx; x->x_obj.te_ypix += dy; if (glist_isvisible(glist)) { ! sys_vgui("%s coords %xSEL %d %d %d %d\n", x->canvas_id, x, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, *************** *** 371,375 ****
entry_drawme(x, glist, 0); ! canvas_fixlinesfor(x->canvas, (t_text*) x); } DEBUG(post("displace end");); --- 360,364 ----
entry_drawme(x, glist, 0); ! canvas_fixlinesfor(glist_getcanvas(glist), (t_text*) x); } DEBUG(post("displace end");); *************** *** 378,392 **** static void entry_select(t_gobj *z, t_glist *glist, int state) { - DEBUG(post("entry_select");); t_entry *x = (t_entry *)z;
if (state) { ! DEBUG(post(".x%lx.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! x->canvas, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, ! text_xpix(&x->x_obj, glist) + x->x_rect_width, ! text_ypix(&x->x_obj, glist) + x->x_rect_height-2, x);); ! sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! x->canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, --- 367,378 ---- static void entry_select(t_gobj *z, t_glist *glist, int state) { t_entry *x = (t_entry *)z; + DEBUG(post("entry_select: canvas %s glist %s", x->canvas, glist););
if (state) { ! // sys_vgui(".x%x.c itemconfigure %s -outline blue -width %f -fill %s\n", ! // x->canvas_id, x->x_bgtag, SCOPE_SELBDWIDTH, SCOPE_SELCOLOR); ! sys_vgui("%s create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! x->canvas_id, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, text_xpix(&x->x_obj, glist) + x->x_rect_width, *************** *** 394,399 **** } else { ! DEBUG(post(".x%lx.c delete %xSEL\n", x->canvas, x);); ! sys_vgui(".x%lx.c delete %xSEL\n", x->canvas, x); } } --- 380,384 ---- } else { ! sys_vgui("%s delete %xSEL\n", x->canvas_id, x); } } *************** *** 411,415 **** static void entry_delete(t_gobj *z, t_glist *glist) { ! DEBUG(post("entry_delete");); t_text *x = (t_text *)z; canvas_deletelinesfor(glist_getcanvas(glist), x); --- 396,400 ---- static void entry_delete(t_gobj *z, t_glist *glist) { ! DEBUG(post("entry_delete: glist %s", glist);); t_text *x = (t_text *)z; canvas_deletelinesfor(glist_getcanvas(glist), x); *************** *** 419,433 **** static void entry_vis(t_gobj *z, t_glist *glist, int vis) { ! DEBUG(post("entry_vis");); ! t_entry *s = (t_entry*)z; t_rtext *y; - DEBUG(post("vis: %d",vis);); if (vis) { y = (t_rtext *) rtext_new(glist, (t_text *)z); ! entry_drawme(s, glist, 1); } else { y = glist_findrtext(glist, (t_text *)z); ! entry_erase(s,glist); rtext_free(y); } --- 404,417 ---- static void entry_vis(t_gobj *z, t_glist *glist, int vis) { ! t_entry *x = (t_entry*)z; ! DEBUG(post("entry_vis: vis %d canvas %s glist %s", vis, x->canvas, glist);); t_rtext *y; if (vis) { y = (t_rtext *) rtext_new(glist, (t_text *)z); ! entry_drawme(x, glist, 1); } else { y = glist_findrtext(glist, (t_text *)z); ! entry_erase(x, glist); rtext_free(y); } *************** *** 447,467 **** { tmp_float = atom_getfloatarg(i, argc , argv); ! DEBUG(post("lappend ::entry%lx::list %g \n", x, tmp_float );); ! sys_vgui("lappend ::entry%lx::list %g \n", x, tmp_float ); } else { ! DEBUG(post("lappend ::entry%lx::list %s \n", x, tmp_symbol->s_name );); ! sys_vgui("lappend ::entry%lx::list %s \n", x, tmp_symbol->s_name ); } } ! DEBUG(post("append ::entry%lx::list " "\n", x);); ! sys_vgui("append ::entry%lx::list " "\n", x); ! DEBUG(post(".x%lx.c.s%x.text insert end $::entry%lx::list ; unset ::entry%lx::list \n", ! x->canvas, x, x, x );); ! sys_vgui(".x%lx.c.s%x.text insert end $::entry%lx::list ; unset ::entry%lx::list \n", ! x->canvas, x, x, x ); ! DEBUG(post(".x%lx.c.s%x.text yview end-2char \n", x->canvas, x );); ! sys_vgui(".x%lx.c.s%x.text yview end-2char \n", x->canvas, x ); }
--- 431,445 ---- { tmp_float = atom_getfloatarg(i, argc , argv); ! sys_vgui("lappend ::%s::list %g \n", x->tcl_namespace, tmp_float ); } else { ! sys_vgui("lappend ::%s::list %s \n", x->tcl_namespace, tmp_symbol->s_name ); } } ! sys_vgui("append ::%s::list " "\n", x->tcl_namespace); ! sys_vgui("%s insert end $::%s::list ; unset ::%s::list \n", ! x->canvas_id, x->tcl_namespace, x->tcl_namespace ); ! sys_vgui("%s yview end-2char \n", x->text_id ); }
*************** *** 478,502 **** if(tmp_int < 10) { ! DEBUG(post(".x%lx.c.s%x.text insert end %d\n", x->canvas, x, tmp_int);); ! sys_vgui(".x%lx.c.s%x.text insert end %d\n", x->canvas, x, tmp_int); } else if(tmp_int == 10) { ! DEBUG(post(".x%lx.c.s%x.text insert end {\n}\n", x->canvas, x);); ! sys_vgui(".x%lx.c.s%x.text insert end {\n}\n", x->canvas, x); } else { ! DEBUG(post(".x%lx.c.s%x.text insert end [format "%c" %d]\n", x->canvas, x, tmp_int);); ! sys_vgui(".x%lx.c.s%x.text insert end [format "%c" %d]\n", x->canvas, x, tmp_int); } } else { ! DEBUG(post(".x%lx.c.s%x.text insert end %s\n", x->canvas, x, tmp_symbol->s_name );); ! sys_vgui(".x%lx.c.s%x.text insert end %s\n", x->canvas, x, tmp_symbol->s_name ); } ! DEBUG(post(".x%lx.c.s%x.text yview end-2char \n", x->canvas, x );); ! sys_vgui(".x%lx.c.s%x.text yview end-2char \n", x->canvas, x ); }
--- 456,475 ---- if(tmp_int < 10) { ! sys_vgui("%s insert end %d\n", x->text_id, tmp_int); } else if(tmp_int == 10) { ! sys_vgui("%s insert end {\n}\n", x->text_id); } else { ! sys_vgui("%s insert end [format "%c" %d]\n", x->text_id, tmp_int); } } else { ! sys_vgui("%s insert end %s\n", x->text_id, tmp_symbol->s_name ); } ! sys_vgui("%s yview end-2char \n", x->text_id ); }
*************** *** 504,509 **** static void entry_clear(t_entry* x) { ! DEBUG(post(".x%lx.c.s%x.text delete 0.0 end \n", x->canvas, x);); ! sys_vgui(".x%lx.c.s%x.text delete 0.0 end \n", x->canvas, x); }
--- 477,481 ---- static void entry_clear(t_entry* x) { ! sys_vgui("%s delete 0.0 end \n", x->text_id); }
*************** *** 512,516 **** { DEBUG(post("entry_set");); - int i;
entry_clear(x); --- 484,487 ---- *************** *** 529,538 **** { /* With "," and ";" escaping thanks to JMZ */ - DEBUG(post("pd [concat %s output [string map {"," "\\," ";" "\\;"} \ - [.x%lx.c.s%x.text get 0.0 end]] \;]\n", - x->x_receive_name->s_name, x->canvas, x);); sys_vgui("pd [concat %s output [string map {"," "\\," ";" "\\;"} \ ! [.x%lx.c.s%x.text get 0.0 end]] \;]\n", ! x->x_receive_name->s_name, x->canvas, x); }
--- 500,506 ---- { /* With "," and ";" escaping thanks to JMZ */ sys_vgui("pd [concat %s output [string map {"," "\\," ";" "\\;"} \ ! [%s get 0.0 end]] \;]\n", ! x->x_receive_name->s_name, x->text_id); }
*************** *** 600,615 **** static void entry_option_float(t_entry* x, t_symbol *option, t_float value) { ! DEBUG(post(".x%lx.c.s%x.text configure -%s %f \n", ! x->canvas, x, option->s_name, value);); ! sys_vgui(".x%lx.c.s%x.text configure -%s %f \n", ! x->canvas, x, option->s_name, value); }
static void entry_option_symbol(t_entry* x, t_symbol *option, t_symbol *value) { ! DEBUG(post(".x%lx.c.s%x.text configure -%s {%s} \n", ! x->canvas, x, option->s_name, value->s_name);); ! sys_vgui(".x%lx.c.s%x.text configure -%s {%s} \n", ! x->canvas, x, option->s_name, value->s_name); }
--- 568,579 ---- static void entry_option_float(t_entry* x, t_symbol *option, t_float value) { ! sys_vgui("%s configure -%s %f \n", ! x->text_id, option->s_name, value); }
static void entry_option_symbol(t_entry* x, t_symbol *option, t_symbol *value) { ! sys_vgui("%s configure -%s {%s} \n", ! x->text_id, option->s_name, value->s_name); }
*************** *** 643,650 **** { x->x_bgcolour = bgcol; ! DEBUG(post(".x%lx.c.s%x.text configure -background "%s" \n", ! x->canvas, x, x->x_bgcolour->s_name);); ! sys_vgui(".x%lx.c.s%x.text configure -background "%s" \n", ! x->canvas, x, x->x_bgcolour->s_name); }
--- 607,612 ---- { x->x_bgcolour = bgcol; ! sys_vgui("%s configure -background "%s" \n", ! x->text_id, x->x_bgcolour->s_name); }
*************** *** 653,660 **** { x->x_fgcolour = fgcol; ! DEBUG(post(".x%lx.c.s%x.text configure -foreground "%s" \n", ! x->canvas, x, x->x_fgcolour->s_name);); ! sys_vgui(".x%lx.c.s%x.text configure -foreground "%s" \n", ! x->canvas, x, x->x_fgcolour->s_name); }
--- 615,620 ---- { x->x_fgcolour = fgcol; ! sys_vgui("%s configure -foreground "%s" \n", ! x->text_id, x->x_fgcolour->s_name); }
*************** *** 666,674 **** { x->x_font_size = (t_int)font_size; ! DEBUG(post(".x%lx.c.s%x.text configure -font {%s %d %s} \n", ! x->canvas, x, ! x->x_font_face->s_name, x->x_font_size, x->x_font_weight->s_name);); ! sys_vgui(".x%lx.c.s%x.text configure -font {%s %d %s} \n", ! x->canvas, x, x->x_font_face->s_name, x->x_font_size, x->x_font_weight->s_name); --- 626,631 ---- { x->x_font_size = (t_int)font_size; ! sys_vgui("%s configure -font {%s %d %s} \n", ! x->text_id, x->x_font_face->s_name, x->x_font_size, x->x_font_weight->s_name); *************** *** 720,729 **** x->x_data_outlet = outlet_new(&x->x_obj, &s_float); x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol);
! snprintf(buf,MAXPDSTRING,"#entry%lx",(long unsigned int)x); x->x_receive_name = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_receive_name);
! x->canvas = canvas_getcurrent();
return (x); --- 677,692 ---- x->x_data_outlet = outlet_new(&x->x_obj, &s_float); x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol); + post("0");
! sprintf(buf,"entry%lx",(long unsigned int)x); ! x->tcl_namespace = getbytes(strlen(buf)); ! strcpy(x->tcl_namespace, buf); ! post("1"); ! sprintf(buf,"#%s", x->tcl_namespace); x->x_receive_name = gensym(buf); pd_bind(&x->x_obj.ob_pd, x->x_receive_name); + post("2");
! set_tk_widget_ids(x, canvas_getcurrent());
return (x); *************** *** 808,813 **** up_symbol = gensym("up"); down_symbol = gensym("down"); - - post("Text v0.1 Ben Bogart.\nCVS: $Revision$ $Date$"); }
--- 771,774 ----