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 / mkHScale.pl
CommitLineData
86530b38
AT
1
2
3sub mkHScale {
4
5 # Create a top-level window that displays a horizontal scale.
6
7 $mkHScale->destroy if Exists($mkHScale);
8 $mkHScale = $top->Toplevel();
9 my $w = $mkHScale;
10 dpos $w;
11 $w->title('Horizontal Scale Demonstration');
12 $w->iconname('Scale');
13 my $w_msg = $w->Label(-font => '-Adobe-times-medium-r-normal--*-180-*-*-*-*-*-*', -wraplength => '3i',
14 -justify => 'left', -text => 'An arrow and a horizontal scale are displayed below. If you click ' .
15 'or drag mouse button 1 in the scale, you can change the width of the arrow. Click the "OK" ' .
16 'button when you\'re finished.');
17 my $w_frame = $w->Frame(-borderwidth => 10);
18 my $w_ok = $w->Button(-text => 'OK', -width => 8, -command => [sub{shift->destroy}, $w]);
19 $w_msg->pack(-side => 'top', -fill => 'x');
20 $w_frame->pack(-side => 'top', -fill => 'x');
21 $w_ok->pack(-side => 'top');
22
23 $w_frame_canvas = $w_frame->Canvas(qw(-width 50 -height 50 -bd 0 -highlightthickness 0));
24 $w_frame_canvas->create(qw(polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly));
25 $w_frame_canvas->create(qw(line 0 0 1 1 2 2 0 0 -fill black -tags line));
26 $w_frame_scale = $w_frame->Scale(qw(-orient horizontal -length 284 -from 0 -to 250 -tickinterval 50),
27 -command => [\&setWidth, $w_frame_canvas]);
28 $w_frame_canvas->pack(qw(-side top -expand yes -anchor s -fill x));
29 $w_frame_scale->pack(qw(-side bottom -expand yes -anchor n));
30 $w_frame_scale->set(75);
31
32} # end mkHScale
33
34
35sub setWidth {
36
37 my($w, $width) = @_;
38
39 $width += 21;
40 my $x2 = $width - 30;
41 $x2 = 21 if $x2 < 21;
42 $w->coords('poly', 20, 15, 20, 35, $x2, 35, $x2, 45, $width, 25, $x2, 5, $x2, 15, 20, 15);
43 $w->coords('line', 20, 15, 20, 35, $x2, 35, $x2, 45, $width, 25, $x2, 5, $x2, 15, 20, 15);
44
45} # end setWidth
46
47
481;