aboutsummaryrefslogtreecommitdiff
path: root/Perl/demos/Tk/demos/zinc_lib/items.pl
diff options
context:
space:
mode:
authormertz2002-03-12 17:02:49 +0000
committermertz2002-03-12 17:02:49 +0000
commit9f9717711fed84aec81f6530266b7e97ad831ecc (patch)
tree77f81a44b9e6bead9d95f8d8836d1d1cf5fe2080 /Perl/demos/Tk/demos/zinc_lib/items.pl
parent9b8d0d371f494ce0059db9e0cc7d63cbcefae91d (diff)
downloadtkzinc-9f9717711fed84aec81f6530266b7e97ad831ecc.zip
tkzinc-9f9717711fed84aec81f6530266b7e97ad831ecc.tar.gz
tkzinc-9f9717711fed84aec81f6530266b7e97ad831ecc.tar.bz2
tkzinc-9f9717711fed84aec81f6530266b7e97ad831ecc.tar.xz
demos d�plac�es de examples/ vers demos/
ajout de nouvelles demos: tkZincLogo.pl window-contours.pl
Diffstat (limited to 'Perl/demos/Tk/demos/zinc_lib/items.pl')
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/items.pl182
1 files changed, 182 insertions, 0 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/items.pl b/Perl/demos/Tk/demos/zinc_lib/items.pl
new file mode 100644
index 0000000..5ae9774
--- /dev/null
+++ b/Perl/demos/Tk/demos/zinc_lib/items.pl
@@ -0,0 +1,182 @@
+#!/usr/bin/perl
+# $Id$
+# these simple samples have been developped by C. Mertz mertz@cena.fr
+
+use Tk;
+use Tk::Zinc;
+use strict;
+
+my $defaultfont = '-adobe-helvetica-bold-r-normal-*-120-*-*-*-*-*-*';
+my $mw = MainWindow->new();
+my $zinc = $mw->Zinc(-width => 700, -height => 600,
+ -font => "10x20", # usually fonts are sets in resources
+ # but for this example it is set in the code!
+ -borderwidth => 3, -relief => 'sunken',
+# -backcolor => "white",
+# -render => 1,
+ )->pack;
+
+$zinc->add('rectangle', 1, [10,10, 100, 50], -fillcolor => "green", -filled => 1,
+ -linewidth => 3);
+
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "A filled rectangle with a border of 3 pixels.",
+ -anchor => 'nw',
+ -position => [120, 20]);
+
+
+my $labelformat = "x82x60+0+0 x60a0^0^0 x32a0^0>1 a0a0>2>1 x32a0>3>1 a0a0^0>2";
+
+my $x=20;
+my $y=120;
+my $track=$zinc->add('track', 1, 6, # 6 is the number of field in the flightlabel
+ -labelformat => $labelformat,
+ -position => [$x, $y],
+ -speedvector => [40, -10],
+ -speedvectormark => 1, # currently works only with openGL
+ -speedvectorticks => 1, # currently works only with openGL
+ );
+# moving the track, to display past positions
+foreach my $i (0..5) { $zinc->coords("$track",[$x+$i*10,$y-$i*2]); }
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "A flight track for a radar display.\n".
+ "(A waypoint is very similar, but has no speed neither past positions)",
+ -anchor => 'nw',
+ -position => [120, 120],
+ );
+
+$zinc->itemconfigure($track, 0,
+ -filled => 0,
+ -bordercolor => 'DarkGreen',
+ -border => "contour",
+ );
+$zinc->itemconfigure($track, 1,
+ -filled => 1,
+ -backcolor => 'gray60',
+ -text => "AFR001");
+$zinc->itemconfigure($track, 2,
+ -filled => 0,
+ -backcolor => 'gray65',
+ -text => "360");
+$zinc->itemconfigure($track, 3,
+ -filled => 0,
+ -backcolor => 'gray65',
+ -text => "/");
+$zinc->itemconfigure($track, 4,
+ -filled => 0,
+ -backcolor => 'gray65',
+ -text => "410");
+$zinc->itemconfigure($track, 5,
+ -filled => 0,
+ -backcolor => 'gray65',
+ -text => "Beacon");
+
+
+
+
+
+$zinc->add('arc', 1, [90, 210, 390, 310], -fillcolor => "gray20",
+ -filled => 0, -linewidth => 1,
+ -startangle => 45, -extent => 270);
+$zinc->add('arc', 1, [200, 220, 280, 300], -fillcolor => "gray20",
+ -filled => 0, -linewidth => 1,
+ -startangle => 45, -extent => 270,
+ -pieslice => 1, -closed => 1,
+ );
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "Two arcs, starting at 45° with an extent of 270°.",
+ -anchor => 'nw',
+ -position => [250, 250]);
+
+$zinc->add('curve', 1, [10, 324, 24, 300, 45, 432, 247, 356, 128, 401],
+ -filled => 0,
+ );
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "An open curve.",
+ -anchor => 'nw',
+ -position => [50, 350]);
+
+# Bug: this bezier does not display with openGL (zinc-perl v3.2.3e)
+$zinc->add('bezier', 1, [310, 324, 324, 300, 345, 432, 547, 356, 428, 401, 534, 407],
+ -filled => 0,
+ );
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "An open bezier.",
+ -anchor => 'nw',
+ -position => [450, 320]);
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "A waypoint",
+ -anchor => 'nw',
+ -position => [10, 480],
+ );
+my $waypoint = $zinc->add('waypoint', 1, 6, -position => [100,520],
+ -labelformat => $labelformat,
+ -symbol => "AtcSymbol2",
+ -labeldistance => 30);
+
+foreach my $fieldId (1..5) {
+ $zinc->itemconfigure($waypoint, $fieldId,
+ -filled => 0,
+ -bordercolor => 'DarkGreen',
+ -border => "contour", # does not work with openGL (zinc-perl v3.2.3e)
+ -text => "field$fieldId",
+ );
+}
+
+my $waypoint = $zinc->add('waypoint', 1, 6, -position => [100,520],
+ -labelformat => $labelformat,
+ -symbol => "AtcSymbol2",
+ -labeldistance => 30);
+
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "3 tabulars of 2 fields,\nattached together",
+ -anchor => 'nw',
+ -position => [310, 480],
+ );
+
+#my $labelformat2 = "80x24 a7a1+0+0 f3f1+0+10";
+my $labelformat2 = "x72x40 x72a0^0^0 x34a0^0>1";
+
+my $tabular1 = $zinc->add('tabular', 1, 6, -position => [490,420],
+ -labelformat => $labelformat2,
+ );
+my $tabular2 = $zinc->add('tabular', 1, 6, -connecteditem => $tabular1,
+ -labelformat => $labelformat2,
+ );
+my $tabular3 = $zinc->add('tabular', 1, 6, -connecteditem => $tabular2,
+ -labelformat => $labelformat2,
+ );
+my $count=1;
+foreach my $tab ($tabular1, $tabular2, $tabular3) {
+ $zinc->itemconfigure($tab, 1, -filled => 0,
+ -bordercolor => 'DarkGreen',
+ -border => "contour", -text => "tabular",
+ );
+ $zinc->itemconfigure($tab, 2, -filled => 0,
+ -bordercolor => 'DarkGreen',
+ -border => "contour", -text => "n°$count",
+ );
+ $count++;
+}
+
+$zinc->add('text', 1,
+ -font => $defaultfont,
+ -text => "Items not yet demonstrated are map, reticle, group...",
+ -anchor => 'nw',
+ -position => [50, 570]);
+
+
+MainLoop;
+