aboutsummaryrefslogtreecommitdiff
path: root/Perl/t/Scale_clipped_group.t
blob: 03e571fe478512252d32bd1be0c6aa5f9225c6ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl -w

#
# $Id: Scale_clipped_group.t,v 1.2 2006-02-12 09:42:23 mertz Exp $
# Author: Christophe Mertz  mertz@intuilab.com, adapted from a script 
# reported by Daniel Etienne for a bug report in Tk::Zinc 3.2.96
#

use strict;

# testing all the import

BEGIN {
    if (!eval q{
        use Test::More tests => 1;
        1;
    }) {
        print "# tests only work properly with installed Test::More module\n";
        print "1..1\n";
        print "ok 1\n";
        exit;
    }
    if (!eval q{
	use Tk::Zinc;
 	1;
    }) {
        print "unable to load Tk::Zinc";
        print "1..1\n";
        print "ok 1\n";
        exit;
    }
}
use Tk;

my $mw = MainWindow->new();
my $zinc = $mw->Zinc(-render => 0)->pack(-expand => 1, -fill => "both");


# creating the father group 1 and 2
my $fatherGroup1=$zinc->add("group", 1);
my $fatherGroup2=$zinc->add("group", 1);

$zinc->coords($fatherGroup1, [50,100]);
$zinc->coords($fatherGroup2, [200,100]);

# creating subGroup 1 and 2
my $subGroup1=$zinc->add("group", $fatherGroup1);
my $subGroup2=$zinc->add("group", $fatherGroup2);

# creating null sized rectangle 1 to clip the subgroup 1
my $rectangle1 = $zinc->add("rectangle", $subGroup1, [ [0, 0], [0, 0] ]);

$zinc->itemconfigure($subGroup1, -clip => $rectangle1);

# creating an icon in the sub-group
my $surroundimgfile = Tk->findINC("Tk.xbm");

my $surroundimg = $zinc->Bitmap(-file => $surroundimgfile,
				-foreground => 'sienna',
				);
my $icon1 = $zinc->add("icon", $subGroup1,
                       -image => $surroundimg,
                      );
my $icon2 = $zinc->add("icon", $subGroup2,
                       -image => $surroundimg,
                      );


## scaling fatherGroup1 makes an image visible on 3.2.96/3.3.2 TkZinc version
$zinc->scale($fatherGroup1, 0.8, 0.8);

##  test cannot be run directly since $zinc->update does not work properly 
##  when not in a  mainloop
##  so I use a timer to trigger tests after entering the mainloop

$zinc->after(10, \&testExecute);  

Tk::MainLoop;

sub testExecute {


    &wait ("You should see ONLY ONE ptk ICON (a camel), please INSPECT VISUALY!"); sleep 2;

    diag("############## Scale clipped group test");
    exit;

}


sub wait {
    $zinc->update;
    ok (1, $_[0]);

    my $delay = $ARGV[0];
    if (defined $delay) {
	$zinc->update;
	if ($delay =~ /^\d+$/) {
	    sleep $delay;
	} else {
	    sleep 1;
	}
    }
}