aboutsummaryrefslogtreecommitdiff
path: root/Perl/demos/Tk
diff options
context:
space:
mode:
authormertz2003-03-21 09:43:34 +0000
committermertz2003-03-21 09:43:34 +0000
commitdc52b76e565ab6d780e65860eeb34dced5be1f1a (patch)
tree83c3472c7ec5a59d985e321ce6ff1e2fef117b64 /Perl/demos/Tk
parent4d3ae3c90bf043d8c924b575cca0244c4d474138 (diff)
downloadtkzinc-dc52b76e565ab6d780e65860eeb34dced5be1f1a.zip
tkzinc-dc52b76e565ab6d780e65860eeb34dced5be1f1a.tar.gz
tkzinc-dc52b76e565ab6d780e65860eeb34dced5be1f1a.tar.bz2
tkzinc-dc52b76e565ab6d780e65860eeb34dced5be1f1a.tar.xz
Corrections (le d�placement de la piste ne fonctionait plus)
et simplification du code
Diffstat (limited to 'Perl/demos/Tk')
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl121
1 files changed, 54 insertions, 67 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl b/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl
index 6b4e86a..08d25b1 100644
--- a/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl
@@ -25,12 +25,13 @@ my $zinc = $mw->Zinc(-width => $zinc_width, -height => $zinc_height,
# The explanation displayed when running this demo
$zinc->add('text', 1,
-position=> [10,10],
- -text => 'This toy-appli shows some interactions on different parts of a flight track item.
-The following operations are possible:
- - Drag Button 1 on the track to move it.
- Please Note the position history (past positions)
- - Enter/Leave flight label fields
- - Enter/Leave the speedvector, symbol (i.e. current position), label leader',
+ -text => 'This toy-appli shows some interactions on different parts
+of a flight track item. The following operations are possible:
+ - Drag Button 1 on the track to move it.
+ Please Note the position history (past positions)
+ - Enter/Leave flight label fields
+ - Enter/Leave the speedvector, symbol (i.e. current position),
+ label, or leader',
-font => "9x15",
);
@@ -51,7 +52,7 @@ my $track=$zinc->add('track', 1, 6, # 6 is the number of field in the flightlabe
-markersize => 10,
);
# moving the track, to display past positions
-foreach my $i (0..5) { $zinc->coords("$track",[$x+$i*10,$y-$i*5]); }
+foreach my $i (0..5) { $zinc->coords($track,[$x+$i*10,$y-$i*5]); }
#fields of the label#
$zinc->itemconfigure($track, 0,#configuration of field 0 of the label
@@ -96,11 +97,11 @@ foreach my $field (0..5) {
sub {
if ($field==0){
higlight_label_on();
- print "CP=", $zinc->currentpart, "\n";
+# print "CP=", $zinc->currentpart, "\n";
}
else{
highlight_fields_on($field);
- print "CP=", $zinc->currentpart, "\n";
+# print "CP=", $zinc->currentpart, "\n";
}
});
@@ -174,105 +175,91 @@ sub highlight_other_fields_off{
#---------------------------------------------
$zinc->bind("$track:position",
'<Enter>',
- sub { $zinc->itemconfigure("$track",
+ sub { $zinc->itemconfigure($track,
-symbolcolor=>"red",
);
- print "CP=", $zinc->currentpart, "\n";
+# print "CP=", $zinc->currentpart, "\n";
});
$zinc->bind("$track:position",
'<Leave>',
- sub { $zinc->itemconfigure("$track",
+ sub { $zinc->itemconfigure($track,
-symbolcolor=>"black",
);
});
$zinc->bind("$track:speedvector",
'<Enter>',
- sub { $zinc->itemconfigure("$track",
+ sub { $zinc->itemconfigure($track,
-speedvectorcolor=>"red",
);
});
-$zinc->bind("$track:speedvector",
- '<Leave>',
- sub { $zinc->itemconfigure("$track",
- -speedvectorcolor=>"black",
- );
- });
+$zinc->bind("$track:speedvector", '<Leave>',
+ sub { $zinc->itemconfigure($track,
+ -speedvectorcolor=>"black",
+ );
+ });
-$zinc->bind("$track:leader",
- '<Enter>',
- sub { $zinc->itemconfigure("$track",
- -leadercolor=>"red",
- );
- });
+$zinc->bind("$track:leader", '<Enter>',
+ sub { $zinc->itemconfigure($track,
+ -leadercolor=>"red",
+ );
+ });
-$zinc->bind("$track:leader",
- '<Leave>',
- sub { $zinc->itemconfigure("$track",
- -leadercolor=>"black",
- );
- });
+$zinc->bind("$track:leader", '<Leave>',
+ sub { $zinc->itemconfigure($track,
+ -leadercolor=>"black",
+ );
+ });
#---------------------------------------------
# Drag and drop the track
#---------------------------------------------
#Binding to ButtonPress event -> "move_on" state#
-$zinc -> bind("$track",'<ButtonPress-1>'=>[ sub { select_color_on(); #change the color
- move_on(Tk::Ev('x'),Tk::Ev('y')); #"move_on" state
- }
- ]);
+$zinc -> bind($track,'<ButtonPress-1>'=>[ sub { &select_color_on(); #change the color
+ &move_on($_[1],$_[2]); #"move_on" state
+ }, Tk::Ev('x'),Tk::Ev('y') ]);
+#Binding to ButtonRelease event -> "move_off" state#
+$zinc -> bind($track,'<ButtonRelease-1>'=>sub{&select_color_off(); #change the color
+ &move_off();}); #"move_off" state
#"move_on" state#
sub move_on{
- my ($xi,$yi)=@_;
- #ButtonPress event not allowed on track
- $zinc -> bind("$track",'<ButtonPress-1>'=>"");
- #Binding to Motion event -> move the track#
- $zinc -> bind("$track",'<Motion>'=>
- [sub{move($xi,$yi,$_[1],$_[2]); #move the track
- $xi=$_[1];
- $yi=$_[2];
+ my ($xi,$yi)=@_;
+ #Binding to Motion event -> move the track#
+ $zinc -> bind($track,'<Motion>'=>
+ [sub{move($xi,$yi,$_[1],$_[2]); #move the track
+ $xi=$_[1];
+ $yi=$_[2];
},Tk::Ev('x'),Tk::Ev('y')]);
- #Binding to ButtonRelease event -> "move_off" state#
- $zinc -> bind("$track",'<ButtonRelease-1>'=>sub{select_color_off(); #change the color
- move_off();}); #"move_off" state
}
#"move_off" state#
sub move_off{
- #Binding to ButtonPress event -> "move_on" state#
- $zinc -> bind("$track",'<ButtonPress-1>'=>[sub { select_color_on(); #change the color
- move_on(Tk::Ev('x'),Tk::Ev('y'))
- }
- ]);
-
- #Motion event not allowed on track
- $zinc -> bind("$track",'<Motion>'=>"");
- #ButtonRelease event not allowed on track
- $zinc -> bind("$track",'<ButtonRelease-1>'=>"");
+ #Motion event not allowed on track
+ $zinc -> bind($track,'<Motion>'=>"");
}
#move the track#
sub move{
- my ($xi,$yi,$x,$y)=@_;
- select_color_on();
- my @coords=$zinc->coords("$track");
- $zinc->coords("$track",[$coords[0]+$x-$xi,$coords[1]+$y-$yi]);
+ my ($xi,$yi,$x,$y)=@_;
+ select_color_on();
+ my @coords=$zinc->coords($track);
+ $zinc->coords($track,[$coords[0]+$x-$xi,$coords[1]+$y-$yi]);
}
sub select_color_on{
-$zinc->itemconfigure("$track",
- -speedvectorcolor=>"white",
- -markercolor=>"white",
- -leadercolor=>"white" );
+ $zinc->itemconfigure($track,
+ -speedvectorcolor=>"white",
+ -markercolor=>"white",
+ -leadercolor=>"white" );
}
sub select_color_off{
- $zinc->itemconfigure("$track",
+ $zinc->itemconfigure($track,
-speedvectorcolor=>"black",
-markercolor=>"black",
-leadercolor=>"black" );
- }
-Tk::MainLoop;
+}
+ Tk::MainLoop;