File Coverage

examples/autoscroll.pl
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl -w
2             # -*- perl -*-
3              
4             #
5             # $Id: autoscroll.pl,v 1.8 2003/10/22 21:06:19 eserte Exp $
6             # Author: Slaven Rezic
7             #
8             # Copyright (C) 1999,2002 Slaven Rezic. All rights reserved.
9             # This program is free software; you can redistribute it and/or
10             # modify it under the same terms as Perl itself.
11             #
12             # Mail: eserte@cs.tu-berlin.de
13             # WWW: http://user.cs.tu-berlin.de/~eserte/
14             #
15              
16 1     1   1414 use Tk;
  0            
  0            
17             use Tk::Autoscroll qw(as_default);
18             @Tk::Autoscroll::default_args = (-stoptrigger => '');
19              
20             $top = new MainWindow;
21              
22             $top->Label(-text => "Hold middle button to en/disable scrolling")->pack;
23              
24             $lb = $top->Scrolled('Listbox')->pack;
25             $lb->insert("end", 1..1000);
26              
27             $c = $top->Scrolled('Canvas')->pack;
28             for(1..1000) {
29             my($x1,$y1,$x2,$y2) = (int(rand(500)), int(rand(500)),
30             int(rand(500)), int(rand(500)));
31             $c->createLine($x1,$y1,$x2,$y2, -fill => "red");
32             }
33              
34             # XXX Problem: widgets inside the scrolled widget steal the
35             # events ...
36             eval q{
37             use Tk::Pane;
38             $p = $top->Scrolled('Pane')->pack;
39             for (1..10) {
40             $f[$_] = $p->Frame->pack;
41             }
42             for (1..10) {
43             for my $y (1..5) {
44             $f[$_]->Label(-text => "$_/$y")->pack;
45             }
46             }
47             };
48             warn $@ if $@;
49              
50             if (!$ENV{BATCH}) {
51             MainLoop;
52             }
53              
54             __END__