diff options
Diffstat (limited to 'Perl/t/Text2.t')
-rw-r--r-- | Perl/t/Text2.t | 98 |
1 files changed, 56 insertions, 42 deletions
diff --git a/Perl/t/Text2.t b/Perl/t/Text2.t index 0b13dfe..2f15c1e 100644 --- a/Perl/t/Text2.t +++ b/Perl/t/Text2.t @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # -# $Id: Text2.t,v 1.3 2005-09-16 07:36:32 mertz Exp $ +# $Id: Text2.t,v 1.4 2005-12-02 22:01:26 mertz Exp $ # Author: Christophe Mertz # @@ -80,63 +80,78 @@ like ($zinc0, qr/^Tk::Zinc=HASH/ , "zinc0 has been created"); $zinc0->fontCreate("fonta", -family => $family, -size => -20, -weight => 'normal'); +## doing updates after the mainloop is launched +## this avoids the bug #32 described in http://bugzilla.tkzinc.org/show_bug.cgi?id=32 +## and the bug #48 http://bugzilla.tkzinc.org/show_bug.cgi?id=48 -foreach my $row (2..15) { - my $string = ""; - foreach my $col (0..15) { - $string .= chr($row*16+$col); - } - $zinc0->add('text', 1, -position => [10,$row*20-40], - -text => $string, -font => 'fonta'); - $zinc0->update; - &pass("adding text item n°$row with a $family font of size 20 and normal weight"); -} +$zinc->after(10, \&testExecute); +Tk::MainLoop; -### creating text items with many different fonts: -my $size = 8; -my $y = 10 ; +sub testExecute { -$zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); + foreach my $row (2..15) { + my $string = ""; + foreach my $col (0..15) { + my $val = $row*16+$col; + $string .= chr($val) unless $val == 127; + } + $zinc0->add('text', 1, -position => [10,$row*20-40], + -text => $string, -font => 'fonta'); + &pass("adding text item n°$row with a $family font of size 20 and normal weight"); + } + $zinc0->update; + + + # creating text items with many different fonts: + my $size = 8; + my $y = 10 ; -### creating text items with many different fonts: -$zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", - -text => "$size pixels $family"); -$zinc->remove('txt8'); -$zinc->fontDelete("font$size"); -$zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); -$zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", - -text => "$size pixels $family"); + $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); + # creating text items with many different fonts: + $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", + -text => "$size pixels $family"); + $zinc->remove('txt8'); + $zinc->fontDelete("font$size"); + $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); + $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", + -text => "$size pixels $family"); + -foreach my $size (9..60) { - $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); - $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", - -text => "$size pixels $family"); - $zinc->update; - # deleting both the font and the text item and recreating it 10 times - foreach my $count (1..10) { - $zinc->fontDelete("font$size"); - $zinc->remove('txt8'); - $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); - $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", - -text => "$size pixels $family"); - $zinc->update; + foreach my $size (9..60) { + $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); + $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", + -text => "$size pixels $family"); + $zinc->update; + + # deleting both the font and the text item and recreating it 10 times + foreach my $count (1..10) { + $zinc->fontDelete("font$size"); + $zinc->remove('txt8'); + $zinc->fontCreate("font$size", -family => $family, -size => -$size, -weight => 'normal'); + $zinc->add('text', $g1, -position => [10,$y], -tags => ["txt$size"], -font => "font$size", + -text => "$size pixels $family"); + $zinc->update; + } + &pass("creating and deleting 10 times a text item with a $family font of size $size"); + $y += $size; } - &pass("creating and deleting 10 times a text item with a $family font of size $size"); - $y += $size; -} -&wait; + &wait; -## we should certainly test much much other things! + # we should certainly test much much other things! + + diag("############## end of text test"); + exit; +} @@ -158,4 +173,3 @@ sub wait { -diag("############## end of text test"); |