Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20448
Modified Files: Tag: impd_0_37 g_numbox.c u_main.tk u_object.tk Log Message: [nbx] gets tickled
Index: u_object.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/u_object.tk,v retrieving revision 1.1.2.36 retrieving revision 1.1.2.37 diff -C2 -d -r1.1.2.36 -r1.1.2.37 *** u_object.tk 4 May 2004 21:11:09 -0000 1.1.2.36 --- u_object.tk 6 May 2004 07:12:27 -0000 1.1.2.37 *************** *** 117,120 **** --- 117,128 ---- ############ rendering
+ proc update_item {self canvas suffix type coords args} { + if {![llength [$canvas gettags ${self}${suffix}]]} { + $canvas create $type $coords -tags ${self}$suffix $args... + } { + $canvas itemconfigure ${self}$suffix $args... + } + } + # modes: # 0: creation *************** *** 370,405 **** set x2 [expr $x1+$xs] set y2 [expr $y1+$ys] ! set ins [expr [string compare $_($self:snd) empty]==0] set outs [expr [string compare $_($self:snd) empty]==0] set points [list $x1 $y1 [expr $x2-4] $y1 $x2 [expr $y1+4] $x2 $y2 $x1 $y2] set isnew [expr [llength [$canvas gettags ${self}BASE]] == 0] - set half [expr $ys/2] - set d [expr 1+$xs/34] set font courier ! set xt [expr $x1+$half+2] ! set yt [expr $y1+$half+$d] ! #set color [format #%6.6x [expr $_($self:fcol) & 0xffffff]] ! set color "#000000" ! #puts "numbox.color = $color" #shadow_draw $self $canvas $points ! set points2 [list $x1 $y1 [expr $x1+$half] [expr $y1+$half] $x1 $y2] puts "numbox_draw $self $canvas" if {$isnew} { ! $canvas create polygon $points -tag ${self}BASE \ ! -fill $look(objectbg) -outline $look(objectframe3) ! $canvas create polygon $points2 -tag ${self}BASE4 \ ! -fill $look(objectbg) -outline $look(objectframe3) ! $canvas create text $xt $yt \ ! -text [numbox_ftoa $self] -anchor w \ ! -font [list $font $_($self:fs) bold] \ ! -fill $color -tags ${self}NUMBER } { $canvas coords ${self}BASE $points $canvas coords ${self}BASE4 $points2 $canvas coords ${self}NUMBER $xt $yt ! $canvas itemconfigure ${self}NUMBER \ ! -text [numbox_ftoa $self] \ ! -font [list $font $_($self:fs) bold] \ ! -fill $color } io_draw $self $canvas $x1 $y1 $xs $ys $ins $outs --- 378,409 ---- set x2 [expr $x1+$xs] set y2 [expr $y1+$ys] ! set ins [expr [string compare $_($self:rcv) empty]==0] set outs [expr [string compare $_($self:snd) empty]==0] set points [list $x1 $y1 [expr $x2-4] $y1 $x2 [expr $y1+4] $x2 $y2 $x1 $y2] set isnew [expr [llength [$canvas gettags ${self}BASE]] == 0] set font courier ! set xt [expr $x1+$ys/2+2] ! set yt [expr $y1+$ys/2+1+$xs/34] #shadow_draw $self $canvas $points ! set points2 [list $x1 $y1 [expr $x1+$ys/2] [expr $y1+$ys/2] $x1 $y2] puts "numbox_draw $self $canvas" if {$isnew} { ! $canvas create polygon $points -tag ${self}BASE ! $canvas create polygon $points2 -tag ${self}BASE4 ! $canvas create text $xt $yt -anchor w -tags ${self}NUMBER } { $canvas coords ${self}BASE $points $canvas coords ${self}BASE4 $points2 $canvas coords ${self}NUMBER $xt $yt ! } ! set grabbed [expr ![string compare $self [canvas_grabber $canvas]]] ! if {$grabbed} {set color4 #00ff00} {set color4 $look(objectbg)} ! $canvas itemconfigure ${self}BASE -fill [parse_color $_($self:bcol)] -outline $look(objectframe3) ! $canvas itemconfigure ${self}BASE4 -fill $color4 -outline $look(objectframe3) ! $canvas itemconfigure ${self}NUMBER -text [numbox_ftoa $self] -font [list $font $_($self:fs) bold] -fill [parse_color $_($self:fcol)] ! $canvas delete ${self}CURS ! if {[string length $_($self:buf)]>0} { ! foreach {blah blah x3 blah} [$canvas bbox ${self}NUMBER] {} ! $canvas create line $x3 $y1 $x3 $y2 -tags ${self}CURS -fill red } io_draw $self $canvas $x1 $y1 $xs $ys $ins $outs *************** *** 407,410 **** --- 411,415 ---- set _($self:clickevent) numbox_clickevent set _($self:keyevent) numbox_keyevent + set _($self:ungrabevent) numbox_ungrabevent }
*************** *** 413,418 **** if {$flag==1} {set colour $look(objectframe4)} {set colour $look(objectframe3)} $canvas itemconfigure ${self}BASE -outline $colour - if {$flag==2} {set colour #00ff00} {set colour $look(objectbg)} - $canvas itemconfigure ${self}BASE4 -fill $colour label_select $self $canvas canvas_select_object $canvas $self $flag --- 418,421 ---- *************** *** 465,476 **** #set can [trimleft [trimright $canvas .c] .] canvas_grab $canvas $self }
proc numbox_keyevent {self canvas key shift} { ! global _ ! set c [format %c $key] ! switch -regexp -- $c { ! [0-9] {set _($self:buf) "$_($self:buf)$c"; puts $_($self:buf); numbox_draw $self $canvas} ! default {puts "numbox_keyevent $key"} } } --- 468,500 ---- #set can [trimleft [trimright $canvas .c] .] canvas_grab $canvas $self + $canvas itemconfigure ${self}BASE4 -fill #00ff00 + } + + proc numbox_ungrabevent {self canvas} { + global _ + puts "numbox_ungrabevent $self $canvas" + set _($self:buf) "" + numbox_draw $self $canvas }
proc numbox_keyevent {self canvas key shift} { ! global _ look ! set c -1 ! catch {set c [format %c $key]} ! if {[string first $c 0123456789.eE+-]>=0} { ! set _($self:buf) "$_($self:buf)$c" ! numbox_draw $self $canvas ! } elseif {$key==13} { ! # Return ! catch {set _($self:val) [expr $_($self:buf)]} ! canvas_ungrab $canvas ! } elseif {$key==8 || $key==127} { ! # Backspace ! if {[string length $_($self:buf)] >= 0} { ! set _($self:buf) [string range $_($self:buf) 0 end-1] ! } ! numbox_draw $self $canvas ! } else { ! puts "numbox_keyevent $key" } } *************** *** 947,951 **** canvas $canvas.${self}DROP -width $xs -height $xs -bg $colour -highlightbackground $lcolour -highlightcolor $colour $canvas create window [expr $x1 + 7] [expr $y1 - 2] -window $canvas.${self}DROP -anchor nw -tags $canvas.${self}window ! dnd bindtarget $canvas.${self}DROP text/uri-list <Drop> "pd "x[list ${self}] symbol [ pdtk_enquote %D ] ;"" } { $canvas coords $canvas.${self}window [expr $x1 + 7] [expr $y1 - 2] --- 971,975 ---- canvas $canvas.${self}DROP -width $xs -height $xs -bg $colour -highlightbackground $lcolour -highlightcolor $colour $canvas create window [expr $x1 + 7] [expr $y1 - 2] -window $canvas.${self}DROP -anchor nw -tags $canvas.${self}window ! dnd bindtarget $canvas.${self}DROP text/uri-list <Drop> "pd "d[list ${self}] symbol [ pdtk_enquote %D ] ;"" } { $canvas coords $canvas.${self}window [expr $x1 + 7] [expr $y1 - 2]
Index: g_numbox.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_numbox.c,v retrieving revision 1.1.1.4.2.2.2.18 retrieving revision 1.1.1.4.2.2.2.19 diff -C2 -d -r1.1.1.4.2.2.2.18 -r1.1.1.4.2.2.2.19 *** g_numbox.c 4 May 2004 07:15:49 -0000 1.1.1.4.2.2.2.18 --- g_numbox.c 6 May 2004 07:12:26 -0000 1.1.1.4.2.2.2.19 *************** *** 183,219 **** }
- static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos, - t_floatarg shift, t_floatarg ctrl, t_floatarg alt) - { - glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, - (t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos); - } - static int my_numbox_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { t_my_numbox* x = (t_my_numbox *)z; ! if(doit) ! { ! my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix, ! (t_floatarg)shift, 0, (t_floatarg)alt); ! x->x_gui.x_finemoved = !! shift; ! if(!x->x_gui.x_change) ! { ! clock_delay(x->x_clock_wait, 50); ! x->x_gui.x_change = 1; CH ! clock_delay(x->x_clock_reset, 3000); ! x->x_buf[0] = 0; ! } ! else ! { ! x->x_gui.x_change = 0; CH ! clock_unset(x->x_clock_reset); ! glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0); ! x->x_buf[0] = 0; ! x->x_gui.x_draw(x, x->x_gui.x_glist, 0); ! } ! } ! return (1); }
--- 183,193 ---- }
static int my_numbox_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { t_my_numbox* x = (t_my_numbox *)z; ! if(!doit) return 1; ! x->x_gui.x_finemoved = !! shift; ! return 1; }
*************** *** 270,318 **** }
- static void my_numbox_key(void *z, t_floatarg fkey) - { - t_my_numbox *x = z; - char c=fkey; - char buf[3]; - buf[1] = 0; - - if (c == 0) - { - x->x_gui.x_change = 0; CH - clock_unset(x->x_clock_reset); - x->x_gui.x_draw(x, x->x_gui.x_glist, 0); - return; - } - if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')|| - (c=='e')||(c=='+')||(c=='E')) - { - if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2)) - { - buf[0] = c; - strcat(x->x_buf, buf); - x->x_gui.x_draw(x, x->x_gui.x_glist, 0); - } - } - else if((c=='\b')||(c==127)) - { - int sl=strlen(x->x_buf)-1; - - if(sl < 0) sl = 0; - x->x_buf[sl] = 0; - x->x_gui.x_draw(x, x->x_gui.x_glist, 0); - } - else if((c=='\n')||(c==13)) - { - x->x_val = atof(x->x_buf); - x->x_buf[0] = 0; - x->x_gui.x_change = 0; CH - clock_unset(x->x_clock_reset); - my_numbox_clip(x); - my_numbox_bang(x); - x->x_gui.x_draw(x, x->x_gui.x_glist, 0); - } - clock_delay(x->x_clock_reset, 3000); - } - static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av) { --- 244,247 ---- *************** *** 383,387 **** class_addfloat(c,my_numbox_float); class_addlist(c, my_numbox_list); - class_addmethod(c, (t_method)my_numbox_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_motion, gensym("motion"), A_FLOAT, A_FLOAT, 0); class_addmethod(c, (t_method)my_numbox_reload, gensym("reload"), A_GIMME, 0); --- 312,315 ----
Index: u_main.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v retrieving revision 1.1.1.4.2.7.4.62 retrieving revision 1.1.1.4.2.7.4.63 diff -C2 -d -r1.1.1.4.2.7.4.62 -r1.1.1.4.2.7.4.63 *** u_main.tk 4 May 2004 21:11:08 -0000 1.1.1.4.2.7.4.62 --- u_main.tk 6 May 2004 07:12:26 -0000 1.1.1.4.2.7.4.63 *************** *** 1770,1774 **** --- 1770,1784 ---- global _ set self [canvastosym $canvas] + set obj $_($self:grab) set _($self:grab) "" + set ung $_($obj:ungrabevent) + puts "ungrab = $ung" + if {[string length $ung]>0} {$ung $obj $canvas} + } + + proc canvas_grabber {canvas} { + global _ + set self [canvastosym $canvas] + return $_($self:grab) }