From 9bfc13c30f64c8deff73c29ec4d5f4c9cc92680b Mon Sep 17 00:00:00 2001 From: mertz Date: Fri, 20 Dec 2002 12:32:03 +0000 Subject: simplifiaction du code (suppression de l'ascenseur dans les zones text Tk ou passage du texte d'explication directement dans le Zinc --- Perl/demos/Tk/demos/zinc_lib/contours.pl | 6 +- Perl/demos/Tk/demos/zinc_lib/counter.pl | 23 ++++---- .../Tk/demos/zinc_lib/groups_in_ATC_strips.pl | 4 +- Perl/demos/Tk/demos/zinc_lib/groups_priority.pl | 4 +- Perl/demos/Tk/demos/zinc_lib/labelformat.pl | 4 +- Perl/demos/Tk/demos/zinc_lib/mapinfo.pl | 4 +- Perl/demos/Tk/demos/zinc_lib/rotation.pl | 3 +- .../Tk/demos/zinc_lib/simple_interaction_track.pl | 67 ++++++++-------------- Perl/demos/Tk/demos/zinc_lib/simpleradar.pl | 10 ++-- Perl/demos/Tk/demos/zinc_lib/textInput.pl | 3 +- Perl/demos/Tk/demos/zinc_lib/transforms.pl | 12 ++-- Perl/demos/Tk/demos/zinc_lib/window-contours.pl | 22 +++---- Perl/demos/Tk/demos/zinc_lib/zoom.pl | 3 +- 13 files changed, 69 insertions(+), 96 deletions(-) diff --git a/Perl/demos/Tk/demos/zinc_lib/contours.pl b/Perl/demos/Tk/demos/zinc_lib/contours.pl index 8907dda..5d4a4ed 100644 --- a/Perl/demos/Tk/demos/zinc_lib/contours.pl +++ b/Perl/demos/Tk/demos/zinc_lib/contours.pl @@ -12,8 +12,8 @@ package contours; # for avoiding symbol collision between different demos my $mw = MainWindow->new(); # The explanation displayed when running this demo -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 9 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -setgrid => 'true', -height => 9); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', @@ -25,7 +25,7 @@ $text->insert('0.0', The following operations are possible: - "Mouse Button 1" for dragging objects. - "Mouse Button 1" for dragging the black handle and - modifying the grey curve contour.'); + modifying the grey curve contour.'); # Creating the zinc widget my $zinc = $mw->Zinc(-width => 600, -height => 500, diff --git a/Perl/demos/Tk/demos/zinc_lib/counter.pl b/Perl/demos/Tk/demos/zinc_lib/counter.pl index 1ef3295..45b5208 100644 --- a/Perl/demos/Tk/demos/zinc_lib/counter.pl +++ b/Perl/demos/Tk/demos/zinc_lib/counter.pl @@ -15,19 +15,6 @@ my $boldfont = '-adobe-helvetica-bold-r-normal--20-240-100-100-p-182-iso8859-1'; my $mw = MainWindow->new(); -########################################### -# Text zone -########################################### - -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 6 -scrollbars e/); -$text->pack(qw/-expand yes -fill both/); - -$text->insert('0.0', - 'This toy-appli shows a simple counter.It is made thanks to clips and contours : this is the only way to do this. -The following operations are possible: - Drag and drop the counter to move it. Observe that the colour of the backgound of the counter is the same as the one of the window (use of clips)' ); - ################################################### # Zinc ################################################### @@ -45,6 +32,16 @@ my $r = $zinc->add('rectangle', 1, -fillcolor => "red:40|green:40 50|blue:40/90" ); +# The explanation displayed when running this demo +$zinc->add('text', 1, + -position=> [10,10], + -text => 'This toy-appli shows a simple counter. It is made thanks to clipping +and contours : this is the only way to do this. +You can drag the counter. Observe that the colour of the backgound of the +counter is the same as the one of the window (use of clips)', + -font => "9x15", + ); + ################################################### # Les positions ################################################### diff --git a/Perl/demos/Tk/demos/zinc_lib/groups_in_ATC_strips.pl b/Perl/demos/Tk/demos/zinc_lib/groups_in_ATC_strips.pl index 38b0e41..b93ff40 100644 --- a/Perl/demos/Tk/demos/zinc_lib/groups_in_ATC_strips.pl +++ b/Perl/demos/Tk/demos/zinc_lib/groups_in_ATC_strips.pl @@ -341,8 +341,8 @@ my $mw; $mw = MainWindow->new(); # The explanation displayed when running this demo -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 7 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -setgrid => 'true', -height =>7); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', diff --git a/Perl/demos/Tk/demos/zinc_lib/groups_priority.pl b/Perl/demos/Tk/demos/zinc_lib/groups_priority.pl index f2c7594..d18e71c 100644 --- a/Perl/demos/Tk/demos/zinc_lib/groups_priority.pl +++ b/Perl/demos/Tk/demos/zinc_lib/groups_priority.pl @@ -11,8 +11,8 @@ package groups_priority; # for avoiding symbol sharing between different demos my $mw = MainWindow->new(); # The explanation displayed when running this demo -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 12 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -height => 12); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', diff --git a/Perl/demos/Tk/demos/zinc_lib/labelformat.pl b/Perl/demos/Tk/demos/zinc_lib/labelformat.pl index 9cb1fcb..55e65ab 100644 --- a/Perl/demos/Tk/demos/zinc_lib/labelformat.pl +++ b/Perl/demos/Tk/demos/zinc_lib/labelformat.pl @@ -14,8 +14,8 @@ my $mw = MainWindow->new(); # Text zone ########################################### -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 4 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -height => 4); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', diff --git a/Perl/demos/Tk/demos/zinc_lib/mapinfo.pl b/Perl/demos/Tk/demos/zinc_lib/mapinfo.pl index ec9202c..2daccd8 100644 --- a/Perl/demos/Tk/demos/zinc_lib/mapinfo.pl +++ b/Perl/demos/Tk/demos/zinc_lib/mapinfo.pl @@ -14,8 +14,8 @@ my $mw = MainWindow->new(); # Text zone ########################################### -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 4 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -height => 4); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', diff --git a/Perl/demos/Tk/demos/zinc_lib/rotation.pl b/Perl/demos/Tk/demos/zinc_lib/rotation.pl index e8978dc..f82119a 100644 --- a/Perl/demos/Tk/demos/zinc_lib/rotation.pl +++ b/Perl/demos/Tk/demos/zinc_lib/rotation.pl @@ -18,8 +18,7 @@ my $mw = MainWindow->new(); # Text zone ########################################### -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 4 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, -height => 4); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', 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 c872f82..6b4e86a 100644 --- a/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl +++ b/Perl/demos/Tk/demos/zinc_lib/simple_interaction_track.pl @@ -13,23 +13,6 @@ my $mw = MainWindow->new(); ########################################### -# Text zone -########################################### - -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 6 -scrollbars e/); -$text->pack(qw/-expand yes -fill both/); - -$text->insert('0.0', - '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' ); - - -########################################### # Zinc ########################################### my $zinc_width=600; @@ -39,6 +22,18 @@ my $zinc = $mw->Zinc(-width => $zinc_width, -height => $zinc_height, -borderwidth => 3, -relief => 'sunken', )->pack; +# 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', + -font => "9x15", + ); + ########################################### # Track ########################################### @@ -50,9 +45,9 @@ my $labelformat = "x80x60+0+0 x60a0^0^0 x30a0^0>1 a0a0>2>1 x30a0>3>1 a0a0^0>2"; my $x=250; my $y=200; my $track=$zinc->add('track', 1, 6, # 6 is the number of field in the flightlabel - -labelformat => $labelformat, - -position => [$x, $y],#position of the marker - -speedvector => [30, -15],#ccords of the speed vector + -labelformat => $labelformat, + -position => [$x, $y],#position of the marker + -speedvector => [30, -15],#ccords of the speed vector -markersize => 10, ); # moving the track, to display past positions @@ -218,28 +213,14 @@ $zinc->bind("$track:leader", ); }); -# $zinc->bind("$track:marker", -# '', -# sub { $zinc->itemconfigure("$track", -# -markercolor=>"red", -# ); -# }); -# -# $zinc->bind("$track:marker", -# '', -# sub { $zinc->itemconfigure("$track", -# -markercolor=>"black", -# ); -# }); - #--------------------------------------------- # Drag and drop the track #--------------------------------------------- #Binding to ButtonPress event -> "move_on" state# -$zinc -> bind("$track",''=>[sub{ - select_color_on(); #change the color - move_on($_[1],$_[2]); #"move_on" state - },Ev('x'),Ev('y')]); +$zinc -> bind("$track",''=>[ sub { select_color_on(); #change the color + move_on(Tk::Ev('x'),Tk::Ev('y')); #"move_on" state + } + ]); #"move_on" state# @@ -252,7 +233,7 @@ sub move_on{ [sub{move($xi,$yi,$_[1],$_[2]); #move the track $xi=$_[1]; $yi=$_[2]; - },Ev('x'),Ev('y')]); + },Tk::Ev('x'),Tk::Ev('y')]); #Binding to ButtonRelease event -> "move_off" state# $zinc -> bind("$track",''=>sub{select_color_off(); #change the color move_off();}); #"move_off" state @@ -261,10 +242,10 @@ sub move_on{ #"move_off" state# sub move_off{ #Binding to ButtonPress event -> "move_on" state# - $zinc -> bind("$track",''=>[sub{ - select_color_on(); #change the color - move_on($_[1],$_[2]); #"move_on" state - },Ev('x'),Ev('y')]); + $zinc -> bind("$track",''=>[sub { select_color_on(); #change the color + move_on(Tk::Ev('x'),Tk::Ev('y')) + } + ]); #Motion event not allowed on track $zinc -> bind("$track",''=>""); diff --git a/Perl/demos/Tk/demos/zinc_lib/simpleradar.pl b/Perl/demos/Tk/demos/zinc_lib/simpleradar.pl index 796270f..8912092 100644 --- a/Perl/demos/Tk/demos/zinc_lib/simpleradar.pl +++ b/Perl/demos/Tk/demos/zinc_lib/simpleradar.pl @@ -18,19 +18,21 @@ my $map_path = Tk->findINC('demos/zinc_data'); my $mw = MainWindow->new(); -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 10 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, + -height => 11); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', - 'This a very simple radar display, where you can see flight tracks, a so-called ministrip (green) and and extend flight label (tan background). + 'This a very simple radar display, where you can see flight tracks, + a so-called ministrip (green) and and extend flight label (tan background). The following operations are possible: Shift-Button 1 for using a squarre lasso (result in the terminal). Click Button 2 for identifiying the closest item (result in the terminal). Button 3 for dragging most items, but not the ministrip (not in the same group). Shift-Button 3 for zooming independently on X and Y axis. Ctrl-Button 3 for rotationg graphic objects. - Enter/Leave in flight label fields, speed vector, position and leader, and in the ministrip fields. + Enter/Leave in flight label fields, speed vector, position and leader, + and in the ministrip fields. Click Button 1 on flight track to display a route.'); diff --git a/Perl/demos/Tk/demos/zinc_lib/textInput.pl b/Perl/demos/Tk/demos/zinc_lib/textInput.pl index eb84832..96d21d7 100644 --- a/Perl/demos/Tk/demos/zinc_lib/textInput.pl +++ b/Perl/demos/Tk/demos/zinc_lib/textInput.pl @@ -17,8 +17,7 @@ my $mw = MainWindow->new(); # Text zone ########################################### -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 4 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, -height => 4); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', diff --git a/Perl/demos/Tk/demos/zinc_lib/transforms.pl b/Perl/demos/Tk/demos/zinc_lib/transforms.pl index abffd04..49187bf 100644 --- a/Perl/demos/Tk/demos/zinc_lib/transforms.pl +++ b/Perl/demos/Tk/demos/zinc_lib/transforms.pl @@ -1,5 +1,8 @@ #!/usr/bin/perl -w +# $Id$ +# This simple demo has been developped by P. Lecoanet + # # TODO: # @@ -26,12 +29,9 @@ my $drag = 0; my $image_path = Tk->findINC('demos/zinc_data'); my $logo = $mw->Photo(-file => "$image_path/zinc_anti.gif"); -my $text = $mw->Scrolled('Text', - -relief => 'sunken', - -borderwidth => 2, - -setgrid => 1, - -height => 12, - -scrollbars => 'e'); +my $text = $mw->Text(-relief => 'sunken', + -borderwidth => 2, + -height => 12); $text->pack(-expand => 0, -fill => 'x'); $text->insert('0.0', 'Items are always added to the current group. The available commands are: diff --git a/Perl/demos/Tk/demos/zinc_lib/window-contours.pl b/Perl/demos/Tk/demos/zinc_lib/window-contours.pl index 0cf4018..9199f20 100644 --- a/Perl/demos/Tk/demos/zinc_lib/window-contours.pl +++ b/Perl/demos/Tk/demos/zinc_lib/window-contours.pl @@ -11,32 +11,28 @@ package window_contours; # for avoiding symbol collision between different demos my $mw = MainWindow->new(); -# The explanation displayed when running this demo -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 10 -scrollbars e/); -$text->pack(qw/-expand yes -fill both/); - -$text->insert('0.0', -'These "windows" are simply rectangles holed by 4 smaller rectangles. -You can see text appearing behind the "windows"! -The following operations are possible: - "Mouse Button 1" for dragging text or "windows".'); # Creating the zinc widget my $zinc = $mw->Zinc(-width => 600, -height => 500, - -font => "10x20", # usually fonts are sets in resources + -font => "9x15", # usually fonts are sets in resources # but for this example it is set in the code! -borderwidth => 3, -relief => 'sunken', -# -backcolor => "white", )->pack; +# The explanation displayed when running this demo +$zinc->add('text', 1, + -position=> [10,10], + -text => 'These "windows" are simply rectangles holed by 4 smaller +rectangles. The text appears behind the window glasses. +You can drag text or "windows".', + -font => "10x20", + ); # Text in background my $backtext = $zinc->add('text', 1, -position=> [50,200], -text => "This text appears\nthrough holes of curves", -font => "-adobe-helvetica-bold-o-normal--34-240-100-100-p-182-iso8859-1", - #"10x20" ); my $window = $zinc->add('curve', 1, [100,100 , 300,100, 300,400 , 100,400 ], diff --git a/Perl/demos/Tk/demos/zinc_lib/zoom.pl b/Perl/demos/Tk/demos/zinc_lib/zoom.pl index b5bc4e5..a97dd5e 100644 --- a/Perl/demos/Tk/demos/zinc_lib/zoom.pl +++ b/Perl/demos/Tk/demos/zinc_lib/zoom.pl @@ -15,8 +15,7 @@ my $mw = MainWindow->new(); # Text zone ########################################### -my $text = $mw->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true - -height 4 -scrollbars e/); +my $text = $mw->Text(-relief => 'sunken', -borderwidth => 2, -height => 4); $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', -- cgit v1.1