aboutsummaryrefslogtreecommitdiff
path: root/Perl/demos/Tk
diff options
context:
space:
mode:
authormertz2003-03-11 14:48:00 +0000
committermertz2003-03-11 14:48:00 +0000
commit488145f34eb3928c2993b31188d08259252645e8 (patch)
treefa7959e2fbbbe0b0ff2863ec235a71aa070b0c6d /Perl/demos/Tk
parentd4a1faadc0a7ba029c5f3eb99f5fe04fd62f0851 (diff)
downloadtkzinc-488145f34eb3928c2993b31188d08259252645e8.zip
tkzinc-488145f34eb3928c2993b31188d08259252645e8.tar.gz
tkzinc-488145f34eb3928c2993b31188d08259252645e8.tar.bz2
tkzinc-488145f34eb3928c2993b31188d08259252645e8.tar.xz
some slight comment modifications
Diffstat (limited to 'Perl/demos/Tk')
-rw-r--r--Perl/demos/Tk/demos/zinc_lib/path_tags.pl72
1 files changed, 40 insertions, 32 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/path_tags.pl b/Perl/demos/Tk/demos/zinc_lib/path_tags.pl
index 695335b..0ea1619 100644
--- a/Perl/demos/Tk/demos/zinc_lib/path_tags.pl
+++ b/Perl/demos/Tk/demos/zinc_lib/path_tags.pl
@@ -1,39 +1,38 @@
#!/usr/bin/perl -w
# $Id$
-# these simple samples have been developped by C. Mertz mertz@cena.fr
+# this pathtatg demo have been developped by C. Mertz mertz@cena.fr
+# with the help of Daniel Etienne etienne@cena.fr
use Tk;
use Tk::Zinc;
use strict;
-#exit if $Tk::Zinc::VERSION lt "3.2.5b";
-
-## this demo demonstrates the use of path tags to adress one or more items
-## belonging to ha hierarchy of groups.
-## This hierarchy is described just below, $gr_xxx designates a group
-## (with a tag xxx) and $i_yyy designates an non-group item (with a tag yyy).
-
-my $hierarchy = '
-# $gr_top --- $gr_a --- $gr_aa --- $gr_aaa --- $gr_aaaa --- $i_aaaaa
-# | | | |-- $i_aaab |-- $i_aaaab
-# | | --- $i_aab
-# | |-- $i_ab
-# | |
-# | ---$gr_ac --- $i_aca
-# | |
-# |-- $i_b --- $i_acb
+#This demo only works with Tk::Zinc > "3.2.5b";
+
+## this demo demonstrates the use of path tags to address one or more items
+## belonging to a hierarchy of groups.
+## This hierarchy is described just below, gr_xxx designates a group
+## (with a tag xxx) and i_yyy designates an non-group item (with a tag yyy).
+
+# gr_top --- gr_a --- gr_aa --- gr_aaa --- gr_aaaa --- i_aaaaa
+# | | | |-- i_aaab |-- i_aaaab
+# | | -- i_aab
+# | |-- i_ab
+# | |
+# | ---gr_ac --- i_aca
+# | |
+# |-- i_b --- i_acb
# |
-# --- $gr_c --- $gr_ca --- $i_caa
-# | |
-# | --- $i_cab
-# |-- $i_cb
-# |
-# ---$gr_cc --- $i_cca
-# |
-# --- $i_ccb
-the same objects are cloned and put in an other hierarchy where
-$gr_top is replace by $other_top
-';
+# --- gr_c --- gr_ca --- i_caa
+# | |
+# | --- i_cab
+# |-- i_cb
+# |
+# ---gr_cc --- i_cca
+# |
+# --- i_ccb
+#the same objects are cloned and put in an other hierarchy where
+#gr_top is replaced by gr_other_top
my $defaultForecolor = "sienna";
my $mw = MainWindow->new();
@@ -61,6 +60,11 @@ my $zinc = $mw->Zinc(-width => 850, -height => 360, -font => "10x20",
-borderwidth => 0, -backcolor => "white",
-forecolor => $defaultForecolor,
)->pack;
+
+###########################################
+# Creation of a bunch of radiobutton and a text input
+###########################################
+
my $row = $mw->Frame()->pack();
my @pl = qw/-side left -expand 1 -padx .5c -pady .2c/;
my $left = $row->Frame->pack(@pl);
@@ -118,6 +122,8 @@ $zinc ->add('group', 1, -tags => ['top']);
$zinc ->add('group', 1, -tags => ['other_top']);
&createSubHierarchy ('other_top');
+### Here we create the genuine hierarchy of groups and items
+### Later we will create graphical objects to display groups
sub createSubHierarchy {
my ($gr) = @_;
$zinc->add('group', $gr, -tags => ['a']);
@@ -163,7 +169,7 @@ sub createSubHierarchy {
}
-# convert a list of items ids in a list of sorted tags (the first tag of each item)
+# converts a list of items ids in a list of sorted tags (the first tag of each item)
sub items2tags {
my @items = @_;
my @selected_tags;
@@ -176,8 +182,8 @@ sub items2tags {
}
### drawing :
-#### a rectangle for each group, with the group name (i.e. its first tag)
-### a text for each item which is not a group
+#### a rectangle item for showing the bounding box of each group,
+### a text item for the group name (i.e. its first tag)
## backgrounds used to fill rectangles representing groups
my @backgrounds = qw(grey90 grey82 grey75 grey68 grey60 grey52 grey45);
@@ -210,7 +216,9 @@ sub drawHierarchy {
}
}
-## this sub extracts out of groups both text and frame representing each group
+### this sub extracts out of groups both text and frame representing
+### each group. This is necessary to avoid unexpected selection of
+### rectangles and titles inside groups
sub extractTextAndFrames {
foreach my $group_title ($zinc->find('withtag', 'group_title || group_frame')) {
my @ancestors = $zinc->find('ancestor',$group_title);