diff options
author | mertz | 2002-11-19 09:56:00 +0000 |
---|---|---|
committer | mertz | 2002-11-19 09:56:00 +0000 |
commit | c51cf9b5a63bde35d57f8e69072a41fe76fbfd6c (patch) | |
tree | 2ab7191228793f72aebeb3c356317ab9bcc2e877 | |
parent | d953c1777587adf946a07d505c9f5d52325a0c1d (diff) | |
download | tkzinc-c51cf9b5a63bde35d57f8e69072a41fe76fbfd6c.zip tkzinc-c51cf9b5a63bde35d57f8e69072a41fe76fbfd6c.tar.gz tkzinc-c51cf9b5a63bde35d57f8e69072a41fe76fbfd6c.tar.bz2 tkzinc-c51cf9b5a63bde35d57f8e69072a41fe76fbfd6c.tar.xz |
passage � la nouvelle m�thode contour (addhole).
diverses simplifaction/correction du code des callbacks de drag&drop
-rw-r--r-- | Perl/demos/Tk/demos/zinc_lib/counter.pl | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/counter.pl b/Perl/demos/Tk/demos/zinc_lib/counter.pl index 74c51aa..1ef3295 100644 --- a/Perl/demos/Tk/demos/zinc_lib/counter.pl +++ b/Perl/demos/Tk/demos/zinc_lib/counter.pl @@ -231,7 +231,7 @@ my $clipping_item2 = $zinc->add('curve', $clipped_group2, -linewidth=>0, ); -$zinc->contour($clipping_item2,"diff",[$x2,$y2,$x3,$y2,$x3,$y3,$x2,$y3,$x2,$y2]); +$zinc->contour($clipping_item2,"addhole",[$x2,$y2,$x3,$y2,$x3,$y3,$x2,$y3,$x2,$y2]); #-------------------------------- # Clipped items @@ -312,7 +312,7 @@ sub refresh { # Rotation de la fleche #--------------------------------- return if $timerIsDead; # the timer is still running when using zinc-demos! - $zinc->rotate("$fleche",$angle,$centre[0],$centre[1]); + $zinc->rotate($fleche,$angle,$centre[0],$centre[1]); $nb+=1; if (($nb==$nb_tot)&&($angle==$PI/$pas)) { @@ -332,7 +332,7 @@ sub refresh { #-------------------------------- # Centaines #--------------------------------- - $zinc->translate("$cent",0,-0.01); + $zinc->translate($cent,0,-0.01); my @coords_c1=$zinc->transform($cent,$group1,[$c_c1[0],$c_c1[1]]); if(int($coords_c1[1])==$yc-210){ @@ -351,7 +351,7 @@ sub refresh { #-------------------------------- #Dixaines #--------------------------------- - $zinc->translate("$dix",0,-0.1); + $zinc->translate($dix,0,-0.1); my @coords_d1=$zinc->transform($dix,$group1,[$c_d1[0],$c_d1[1]]); if(int($coords_d1[1])==$yd-210){ @@ -371,7 +371,7 @@ sub refresh { #-------------------------------- # Unites #--------------------------------- - $zinc->translate("$unit",0,-1); + $zinc->translate($unit,0,-1); my @coords_u1=$zinc->transform($unit,$group1,[$c_u1[0],$c_u1[1]]); if($coords_u1[1]==$yu-210){ @@ -397,38 +397,33 @@ sub refresh { # Drag and drop the counter #--------------------------------------------- -$zinc -> bind("$cercle",'<ButtonPress-1>'=>[sub{ - move_on($_[1],$_[2]); #"move_on" state - },Ev('x'),Ev('y')]); +my ($prev_x, $prev_y); +$zinc -> bind($cercle,'<ButtonPress-1>'=>[\&move_on] ); + #"move_on" state# sub move_on{ - my ($xi,$yi)=@_; - $zinc -> bind("$cercle",'<ButtonPress-1>'=>""); - $zinc -> bind("$cercle",'<Motion>'=> - [sub{move($xi,$yi,$_[1],$_[2]); #move the counter - $xi=$_[1]; - $yi=$_[2]; - },Ev('x'),Ev('y')]); - $zinc -> bind("$cercle",'<ButtonRelease-1>'=>sub{ - move_off();}); #"move_off" state + $prev_x=$zinc->XEvent()->x; + $prev_y=$zinc->XEvent()->y; + # move the counter + $zinc -> bind($cercle,'<Motion>'=> [\&move]); + $zinc -> bind($cercle,'<ButtonRelease-1>'=> [\&move_off]); #"move_off" state } #"move_off" state# sub move_off{ - $zinc -> bind("$cercle",'<ButtonPress-1>'=>[sub{ - move_on($_[1],$_[2]); #"move_on" state - },Ev('x'),Ev('y')]); - $zinc -> bind("$cercle",'<Motion>'=>""); - $zinc -> bind("$cercle",'<ButtonRelease-1>'=>""); + $zinc -> bind($cercle,'<Motion>'=>""); + $zinc -> bind($cercle,'<ButtonRelease-1>'=>""); } #move the counter# sub move{ - my ($xi,$yi,$x,$y)=@_; - $zinc->translate("$clipped_group1",$x-$xi,$y-$yi); - $zinc->translate("$clipped_group2",$x-$xi,$y-$yi); + my $x=$zinc->XEvent()->x, + my $y=$zinc->XEvent()->y; + $zinc->translate($clipped_group1,$x-$prev_x,$y-$prev_y); + $zinc->translate($clipped_group2,$x-$prev_x,$y-$prev_y); + ($prev_x,$prev_y) = ($x,$y); } Tk::MainLoop; |