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 / mkVScale.pl
CommitLineData
86530b38
AT
1
2
3sub mkVScale {
4
5# Create a top-level window that displays a vertical scale.
6
7 $mkVScale->destroy if Exists($mkVScale);
8 $mkVScale = $top->Toplevel();
9 my $w = $mkVScale;
10 dpos $w;
11 $w->title('Vertical Scale Demonstration');
12 $w->iconname('Scale');
13 my $w_msg = $w->Label(-font => '-Adobe-times-medium-r-normal--*-180*-*-*-*-*-*-*', -wraplength => '4i',
14 -justify => 'left', -text => 'An arrow and a vertical scale are displayed below. If you click ' .
15 'or drag mouse button 1 in the scale, you can change the height 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 => ['destroy', $w]);
19 $w_msg->pack();
20 $w_frame->pack();
21 $w_ok->pack();
22
23 my $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 SeaGreen3 -tags poly));
25 $w_frame_canvas->create(qw(line 0 0 1 1 2 2 0 0 -fill black -tags line));
26 my $w_frame_scale = $w_frame->Scale(-orient => 'vertical', '-length' => 284, -from => 0, -to => 250, -tickinterval => 50,
27 -command => [\&setHeight, $w_frame_canvas]);
28 $w_frame_scale->pack(-side => 'left', -anchor => 'ne');
29 $w_frame_canvas->pack(-side => 'left', -anchor => 'nw', -fill => 'y');
30 $w_frame_scale->set(75);
31
32} # end mkVScale
33
34
35sub setHeight {
36
37 my($w, $height) = @_;
38
39 $height += 21;
40 $y2 = $height - 30;
41 $y2 = 21 if $y2 < 21;
42 $w->coords('poly', 15, 20, 35, 20, 35, $y2, 45, $y2, 25, $height, 5, $y2, 15, $y2, 15, 20);
43 $w->coords('line', 15, 20, 35, 20, 35, $y2, 45, $y2, 25, $height, 5, $y2, 15, $y2, 15, 20);
44
45} # end setHeight
46
47
481;