Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / demos / widget_lib / transtile.pl
CommitLineData
86530b38
AT
1# transtile.pl
2
3use vars qw/$TOP/;
4
5sub transtile {
6
7 # Create a top-level window that demonstrates tiles
8 # and transparent stuff.
9
10 my($demo) = @_;
11 $TOP = $MW->WidgetDemo(
12 -name => $demo,
13 -text => ['This window demonstrates tiles and transparent images. The Canvas has a yellow background, which displays for one second before it\'s overlayed with a tile of tiny camels. On top of the tile layer are three non-transparent images that obscure the tile. Canvas items such as ovals, rectangles and polygons cannot react to bound events unless they are filled with a color - move the cursor over the blue circle and note that it reacts to <Motion> events. The transparent circle outlined in red to the left of the blue circle does not react to <Motion> events in its interior because it\'s transparent, or unfilled. If you need a transparent item that also reacts to events then add a transparent stipple. The bottom red circle is both transparent and aware of events. Finally, a blue lattice (a transparent GIF that\'s been Base64 encoded so it can be embedded in the source) is overlayed on top of everything, anchored to the southeast corner of the Canvas.', -wraplength => '8i'],
14 -title => 'Tile and Transparent Demonstration',
15 -iconname => 'transtile',
16 );
17
18 my $tile = $TOP->Photo(-file =>Tk->findINC('Camel.xpm'));
19
20 # A tiled Canvas - the tile overlays the background color.
21
22 my $c = $TOP->Canvas(
23 -background => 'yellow',
24 -width => 300,
25 -height => 250,
26 -relief => 'raised',
27 -borderwidth => 3,
28 )->grid;
29 $c->update;
30 $c->after(1000);
31 $c->configure(-tile => $tile);
32
33 # These images are not transparent, thus they obscure the tile
34 # or background.
35
36 my($x, $y) = (30, 30);
37 foreach (qw/Xcamel.gif anim.gif icon.gif/) {
38 $c->createImage($x, $y, -image => $TOP->Photo(-file => Tk->findINC($_)));
39 $x += 50;
40 $y += 50;
41 }
42
43 # Transparent Canvas items do not generate events.
44
45 my $cb = sub {
46 print "Over circle, args = @_!\n";
47 };
48
49 # Not filled (transparent), no events.
50
51 my $o1 = $c->createOval(25, 25, 100, 100,
52 -outline => 'red',
53 );
54 $c->bind($o1, '<Motion>' => $cb);
55
56 # Filled (non-transparent), but with events.
57
58 my $o2 = $c->createOval(155, 25, 225, 100,
59 -outline => 'red',
60 -fill => 'blue',
61 );
62 $c->bind($o2, '<Motion>' => $cb);
63
64 # Transparently filled, with events.
65
66 my $o3 = $c->createOval(25, 120, 100, 195,
67 -outline => 'red',
68 -fill => 'blue',
69 -stipple => 'transparent',
70 );
71 $c->bind($o3, '<Motion>' => $cb);
72
73 # A transparent GIF overlaying everything.
74
75 $c->createImage(300, 300,
76 -image => $TOP->Photo(-data => &encoded_gif, -format => 'gif'),
77 -anchor => 'se',
78 );
79
80} # end transtile
81
82sub encoded_gif {
83
84 # A Base64 encoded transparent GIF.
85
86 my $gif = <<'END_OF_GIF';
87R0lGODlhyADIAIAAAB0A/////yH+Dk1hZGUgd2l0aCBHSU1QACH5BAEKAAEALAAAAADIAMgAAAL+
88jI+py+0Po5y02ouz3rz7D4biSJbmiabqCgJuC7DZK9Ly5+Zdrt8Sb+MAYzDUkKgZ+n5AXNOjLB03
89R6TQmpxeo9seSTsDZ3ldctk7fo7EGC5VnQ6+zWd5CB6mx9Ft/N6p92WXBejXt4Z1trTI4MboM/i4
906ChZabkUeam5ydnp+QkaKjpKWmp6ipqqusoKldjqWvOqSQmbx3ebSTiH+yZrZHhR+9c3bGFcgcwb
91KMy2PBtR5cpc3DsdTCF9Tc3Efez8rUysWOgNId6NPaGNaJ6t3uweDV2t+y5/9SuLf4M+z2/rXSh7
92zQIaPIgwocKFDBs6fAgxosSJjehRHGhxB7z+ZBm/6StSrmMukec2piN4kuQDfyUBhjPZ0tpLlP9k
93cnTZgN0dcDdhOtBZz2ZKmj95asRZkWVOo+uYDlW5FOk9oU2lLlBa1KoCrFGp5gu5DWpXoit9zmNF
94lslHJxfbun0LN67cuXTr2r2LN6/evbvspj2oVcbfnoP7iR17uGK7xCl37iy81WxWxkm9xpM8GexR
95ygi4ToZc1vNVzJVBJzDdmXRmKapHBz5tGVNsgSZEV3aMsRXq0Xx7+/4NPLjw4cSLGz+OPLmK3b5f
96p3COinlN6QGo21bsCfp05tqrt3bNGfZm6ojDe+/e/fzs1eNqXz/wXjwM6PHTh17fdZT2+N7+BeMv
97Wop1/ykHCnkEHohgggouyGCDDj4oCITRDQiYeYyYx598oti3wnfqkcfhPhRqeIJTMT02Im+a8fJc
98fRamll6MKRqQ4WcGFjLfjKmFBYyHJb5Io4+s3QgekAHq6J5gcBEpYZNOPglllFJO2R+V2SFpZY5M
99NvlijVXqZ+SWMHKHpXq45Yjjj0J+OV6XZfLnZZFijsRjnc+oGeI1K26WpntrRojmmbG0WOaRehmZ
100ZaKKLspoo44+CmmkksyZZIJ54kkmoAX+2aGQHF5qJylAzQRknCIKuthrXsYJYpiFRkbfq/aBSo4g
101+yEaJIqUBgXMW6YGCiGtGj25q6TGHov+bLLKLstss2ziOWhc0gn7YXif4morhpyWxtmqrz57Z7hD
102flcjq1jC+S2sM8rI7rnuLucporNyWuypmy7mbK/57stvv/7+C3DAAvd1r4S/9gnSXAe3ieKG2MJn
103Im21MvwJqKPeoqeWpbpp8Z8Z3thuqCJOuy0iGmf8o70UlfswvL6m22+9A89Mc80231yXzKLKiyvJ
104OieMMp/AtjcsphZ+7LGP3oqJ9K3oxSvgpRdfNrTQRe+p67uoRlsxzEFSm9ycC+/7M85mn4122mqv
105zfZXbSOWM89rUez2hE4j2bTS3zK9Zt5kvmcuk1NP5dzghFlLb8lf6+2i39q2KnXfks8fCzTCIx89
106ude56Vv51W9/Dnrooo9Oeummn4566g4UAAA7
107END_OF_GIF
108
109 return $gif;
110
111} # end encoded_gif
112
1131;