Update of /cvsroot/pure-data/externals/bbogart/entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22440
Modified Files: entry-gop-test.pd entry-help.pd entry.c Log Message: added a scrollbar, fontsize message; cleaned up code some more
Index: entry-gop-test.pd =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry-gop-test.pd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** entry-gop-test.pd 18 May 2004 23:16:15 -0000 1.1 --- entry-gop-test.pd 28 Oct 2007 03:54:54 -0000 1.2 *************** *** 1,5 **** ! #N canvas 481 513 162 168 10; ! #X obj 10 12 entry 100 100 grey85 black; ! #X obj 4 6 cnv 15 160 160 empty empty empty 20 12 0 14 -233017 -66577 ! 0; ! #X coords 0 0 1 1 200 140 1; --- 1,6 ---- ! #N canvas 249 374 516 408 10; ! #N canvas 180 104 454 304 entry 0; ! #X obj 133 128 entry 124 100 grey70 black; ! #X coords 0 -1 1 1 200 160 1 100 100; ! #X restore 135 105 pd entry gop; ! #X coords 0 0 1 1 200 140 0;
Index: entry.c =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** entry.c 28 Oct 2007 02:09:28 -0000 1.16 --- entry.c 28 Oct 2007 03:54:54 -0000 1.17 *************** *** 28,33 **** /* TODO: set message doesnt work with a loadbang */ /* TODO: make message to add a single character to the existing text */ ! /* TODO: make scrollbar (check .printout.text in u_main.tk) */ ! /* TODO: make erase_inlets() called by ( !editmode && !firsttime ) */
#ifdef _MSC_VER --- 28,32 ---- /* TODO: set message doesnt work with a loadbang */ /* TODO: make message to add a single character to the existing text */ ! /* TODO: complete inlet draw/erase logic */
#ifdef _MSC_VER *************** *** 52,56 **** int x_rect_height; t_symbol* x_receive_name; ! /* TODO: these all should be settable by messages */ int x_height; --- 51,55 ---- int x_rect_height; t_symbol* x_receive_name; ! /* TODO: these all should be settable by messages */ int x_height; *************** *** 60,68 **** t_symbol* x_fgcolour;
- /* TODO: these all should be settable by messages t_symbol *x_font_face; ! t_float x_font_size; t_symbol *x_font_weight;
t_float x_border; t_float x_highlightthickness; --- 59,67 ---- t_symbol* x_fgcolour;
t_symbol *x_font_face; ! t_int x_font_size; t_symbol *x_font_weight;
+ /* TODO: these all should be settable by messages t_float x_border; t_float x_highlightthickness; *************** *** 180,183 **** --- 179,195 ---- }
+ static void erase_inlets(t_entry *x, t_canvas *canvas) + { + DEBUG(post("erase_inlets");); + /* Added tag for all inlets of one instance */ + DEBUG(post(".x%x.c delete %xi\n", canvas,x);); + sys_vgui(".x%x.c delete %xi\n", canvas,x); + DEBUG(post(".x%x.c delete %xo\n", canvas,x);); + sys_vgui(".x%x.c delete %xo\n", canvas,x); + /* Added tag for all outlets of one instance */ + DEBUG(post(".x%x.c delete %xhandle\n", canvas,x,0);); + sys_vgui(".x%x.c delete %xhandle\n", canvas,x,0); + } + /* currently unused static void draw_handle(t_entry *x, t_glist *glist, int firsttime) { *************** *** 213,227 **** sys_vgui("destroy .x%x.c.s%x\n", canvas, x);
! DEBUG(post("text .x%x.c.s%x -font {helvetica 10} -border 1 -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \n", ! canvas, x, x->x_bgcolour->s_name,x->x_fgcolour->s_name);); ! sys_vgui("text .x%x.c.s%x -font {helvetica 10} -border 1 -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \n", ! canvas, x,x->x_bgcolour->s_name,x->x_fgcolour->s_name); ! DEBUG(post("bind .x%x.c.s%x <KeyRelease> {+pd %s keyup %%N \;} \n", canvas, x, x->x_receive_name->s_name);); ! sys_vgui("bind .x%x.c.s%x <KeyRelease> {+pd %s keyup %%N \;} \n", canvas, x, x->x_receive_name->s_name); ! DEBUG(post("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", canvas, x, canvas, x);); ! sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", canvas, x, canvas, x); } --- 225,261 ---- sys_vgui("destroy .x%x.c.s%x\n", canvas, x);
! ! DEBUG(post("frame .x%x.c.s%x \n",canvas, x);); ! sys_vgui("frame .x%x.c.s%x \n",canvas, x); ! DEBUG(post("text .x%x.c.s%x.text -font {%s %d %s} -border 1 \ ! -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \ ! -yscrollcommand {.x%x.c.s%x.scrollbar set} \n", ! 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, ! canvas, x);); ! sys_vgui("text .x%x.c.s%x.text -font {%s %d %s} -border 1 \ ! -highlightthickness 1 -relief sunken -bg "%s" -fg "%s" \ ! -yscrollcommand {.x%x.c.s%x.scrollbar set} \n", ! 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, ! canvas, x); ! DEBUG(post("scrollbar .x%x.c.s%x.scrollbar -command {.x%x.c.s%x.text yview} \n",canvas, x, canvas, x);); ! sys_vgui("scrollbar .x%x.c.s%x.scrollbar -command {.x%x.c.s%x.text yview} \n",canvas, x ,canvas, x); ! DEBUG(post("pack .x%x.c.s%x.scrollbar -side right -fill y \n",canvas, x);); ! sys_vgui("pack .x%x.c.s%x.scrollbar -side right -fill y \n",canvas, x); ! DEBUG(post("pack .x%x.c.s%x.text -side left -fill both -expand 1 \n",canvas, x);); ! sys_vgui("pack .x%x.c.s%x.text -side left -fill both -expand 1 \n",canvas, x); ! DEBUG(post("pack .x%x.c.s%x -side bottom -fill both -expand 1 \n",canvas, x);); ! sys_vgui("pack .x%x.c.s%x -side bottom -fill both -expand 1 \n",canvas, x); ! ! DEBUG(post("bind .x%x.c.s%x.text <KeyRelease> {+pd %s keyup %%N \;} \n", canvas, x, x->x_receive_name->s_name);); ! sys_vgui("bind .x%x.c.s%x.text <KeyRelease> {+pd %s keyup %%N \;} \n", canvas, x, x->x_receive_name->s_name); ! DEBUG(post("bind .x%x.c.s%x.text <Leave> {focus [winfo parent .x%x.c.s%x]} \n", canvas, x, canvas, x);); ! sys_vgui("bind .x%x.c.s%x.text <Leave> {focus [winfo parent .x%x.c.s%x]} \n", canvas, x, canvas, x); } *************** *** 234,237 **** --- 268,272 ---- if (firsttime) { + x->x_glist = canvas; create_widget(x,glist); DEBUG(post(".x%x.c create window %d %d -anchor nw -window .x%x.c.s%x \ *************** *** 251,257 **** text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! /* post("canvas: %d glist: %d", canvas->gl_edit, glist->gl_edit); */ ! /* if(canvas->gl_edit) */ draw_inlets(x, glist, firsttime, 1,2); // draw_handle(x, glist, firsttime); } --- 286,294 ---- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); } ! post("canvas: %d glist: %d", canvas->gl_edit, glist->gl_edit); ! if( (x->x_glist->gl_edit) && (canvas == x->x_glist) ) draw_inlets(x, glist, firsttime, 1,2); + else + erase_inlets(x, canvas); // draw_handle(x, glist, firsttime); } *************** *** 268,280 **** sys_vgui(".x%x.c delete %xS\n", canvas, x);
! /* inlets and outlets */ ! /* Added tag for all inlets of one instance */ ! DEBUG(post(".x%x.c delete %xi\n", canvas,x);); ! sys_vgui(".x%x.c delete %xi\n", canvas,x); ! DEBUG(post(".x%x.c delete %xo\n", canvas,x);); ! sys_vgui(".x%x.c delete %xo\n", canvas,x); ! /* Added tag for all outlets of one instance */ ! DEBUG(post(".x%x.c delete %xhandle\n", canvas,x,0);); ! sys_vgui(".x%x.c delete %xhandle\n", canvas,x,0); } --- 305,309 ---- sys_vgui(".x%x.c delete %xS\n", canvas, x);
! erase_inlets(x, canvas); } *************** *** 327,345 **** DEBUG(post("entry_select");); t_entry *x = (t_entry *)z; if (state) { DEBUG(post(".x%x.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! glist_getcanvas(glist), 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%x.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! glist_getcanvas(glist), 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); } else { ! DEBUG(post(".x%x.c delete %xSEL\n", glist_getcanvas(glist), x);); ! sys_vgui(".x%x.c delete %xSEL\n", glist_getcanvas(glist), x); } } --- 356,375 ---- DEBUG(post("entry_select");); t_entry *x = (t_entry *)z; + t_canvas *canvas = glist_getcanvas(glist); if (state) { DEBUG(post(".x%x.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! 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%x.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n", ! 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); } else { ! DEBUG(post(".x%x.c delete %xSEL\n", canvas, x);); ! sys_vgui(".x%x.c delete %xSEL\n", canvas, x); } } *************** *** 404,413 **** DEBUG(post("append ::entry%lx::list " "\n", x);); sys_vgui("append ::entry%lx::list " "\n", x); ! DEBUG(post(".x%x.c.s%x insert end $::entry%lx::list ; unset ::entry%lx::list \n", x->x_glist, x, x, x );); ! sys_vgui(".x%x.c.s%x insert end $::entry%lx::list ; unset ::entry%lx::list \n", x->x_glist, x, x, x ); }
/* Function to reset the contents of the entry box */ static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) --- 434,450 ---- DEBUG(post("append ::entry%lx::list " "\n", x);); sys_vgui("append ::entry%lx::list " "\n", x); ! DEBUG(post(".x%x.c.s%x.text insert end $::entry%lx::list ; unset ::entry%lx::list \n", x->x_glist, x, x, x );); ! sys_vgui(".x%x.c.s%x.text insert end $::entry%lx::list ; unset ::entry%lx::list \n", x->x_glist, x, x, x ); }
+ /* Clear the contents of the text widget */ + static void entry_clear(t_entry* x) + { + DEBUG(post(".x%x.c.s%x.text delete 0.0 end \n", x->x_glist, x);); + sys_vgui(".x%x.c.s%x.text delete 0.0 end \n", x->x_glist, x); + } + /* Function to reset the contents of the entry box */ static void entry_set(t_entry* x, t_symbol *s, int argc, t_atom *argv) *************** *** 416,431 **** int i;
! DEBUG(post(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x);); ! sys_vgui(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x); entry_add(x, s, argc, argv); }
- /* Clear the contents of the text widget */ - static void entry_clear(t_entry* x) - { - DEBUG(post(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x);); - sys_vgui(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x); - } - /* Output the symbol */ /* , t_symbol *s, int argc, t_atom *argv) */ --- 453,460 ---- int i;
! entry_clear(x); entry_add(x, s, argc, argv); }
/* Output the symbol */ /* , t_symbol *s, int argc, t_atom *argv) */ *************** *** 444,450 **** x->x_receive_name->s_name, x->x_glist, x);
! DEBUG(post("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", x->x_glist, x, x->x_glist, x);); ! sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", x->x_glist, x, x->x_glist, x); } --- 473,479 ---- x->x_receive_name->s_name, x->x_glist, x);
! DEBUG(post("bind .x%x.c.s%x.text <Leave> {focus [winfo parent .x%x.c.s%x]} \n", x->x_glist, x, x->x_glist, x);); ! sys_vgui("bind .x%x.c.s%x.text <Leave> {focus [winfo parent .x%x.c.s%x]} \n", x->x_glist, x, x->x_glist, x); } *************** *** 513,519 **** { x->x_bgcolour = bgcol; ! DEBUG(post(".x%x.c.s%x configure -background "%s" \n", x->x_glist, x, x->x_bgcolour->s_name);); ! sys_vgui(".x%x.c.s%x configure -background "%s" \n", x->x_glist, x, x->x_bgcolour->s_name); } --- 542,548 ---- { x->x_bgcolour = bgcol; ! DEBUG(post(".x%x.c.s%x.text configure -background "%s" \n", x->x_glist, x, x->x_bgcolour->s_name);); ! sys_vgui(".x%x.c.s%x.text configure -background "%s" \n", x->x_glist, x, x->x_bgcolour->s_name); } *************** *** 523,532 **** { x->x_fgcolour = fgcol; ! DEBUG(post(".x%x.c.s%x configure -foreground "%s" \n", x->x_glist, x, x->x_fgcolour->s_name);); ! sys_vgui(".x%x.c.s%x configure -foreground "%s" \n", x->x_glist, x, x->x_fgcolour->s_name); }
static void entry_size(t_entry *x, t_float width, t_float height) { --- 552,580 ---- { x->x_fgcolour = fgcol; ! DEBUG(post(".x%x.c.s%x.text configure -foreground "%s" \n", x->x_glist, x, x->x_fgcolour->s_name);); ! sys_vgui(".x%x.c.s%x.text configure -foreground "%s" \n", x->x_glist, x, x->x_fgcolour->s_name); }
+ static void entry_fontsize(t_entry *x, t_float font_size) + { + DEBUG(post("entry_fontsize");); + post("font size: %f",font_size); + if(font_size > 8) + { + x->x_font_size = (t_int)font_size; + DEBUG(post(".x%x.c.s%x.text configure -font {%s %d %s} \n", + x->x_glist, x, + x->x_font_face->s_name, x->x_font_size, x->x_font_weight->s_name);); + sys_vgui(".x%x.c.s%x.text configure -font {%s %d %s} \n", + x->x_glist, x, + x->x_font_face->s_name, x->x_font_size, + x->x_font_weight->s_name); + } + else + pd_error(x,"entry: invalid font size: %f",font_size); + } + static void entry_size(t_entry *x, t_float width, t_float height) { *************** *** 548,551 **** --- 596,602 ----
x->x_height = 1; + x->x_font_face = gensym("helvetica"); + x->x_font_size = 10; + x->x_font_weight = gensym("normal"); if (argc < 4) *************** *** 591,594 **** --- 642,650 ---- A_DEFFLOAT, 0); + + class_addmethod(entry_class, (t_method)entry_fontsize, + gensym("fontsize"), + A_DEFFLOAT, + 0); class_addmethod(entry_class, (t_method)entry_output,
Index: entry-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry-help.pd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** entry-help.pd 27 Oct 2007 23:50:16 -0000 1.5 --- entry-help.pd 28 Oct 2007 03:54:54 -0000 1.6 *************** *** 1,3 **** ! #N canvas 200 48 476 595 10; #X obj 73 212 entry 150 100 grey black; #X obj 11 84 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --- 1,3 ---- ! #N canvas 200 48 484 603 10; #X obj 73 212 entry 150 100 grey black; #X obj 11 84 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 *************** *** 25,28 **** --- 25,32 ---- #X msg 169 127 add seven eight nine; #X msg 196 149 add ten eleven.; + #X msg 26 469 fontsize $1; + #X msg 48 442 12; + #X msg 16 441 9; + #X msg 81 439 98; #X connect 0 0 2 0; #X connect 0 0 10 0; *************** *** 44,45 **** --- 48,53 ---- #X connect 20 0 0 0; #X connect 21 0 0 0; + #X connect 22 0 7 0; + #X connect 23 0 22 0; + #X connect 24 0 22 0; + #X connect 25 0 22 0;