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 / hscale.pl
CommitLineData
86530b38
AT
1# hscale.pl
2
3use subs qw /hscale_width/;
4use vars qw/$TOP/;
5
6sub hscale {
7
8 # Create a top-level window that displays a horizontal scale.
9
10 my($demo) = @_;
11 $TOP = $MW->WidgetDemo(
12 -name => $demo,
13 -text => 'An arrow and a horizontal scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the size of the arrow.',
14 -title => 'Horizontal Scale Demonstration',
15 -iconname => 'hscale',
16 );
17
18 my $frame = $TOP->Frame(-borderwidth => 10)->pack(qw/-side top -fill x/);
19
20 my $canvas = $frame->Canvas(
21 qw/width 50 -height 50 -bd 0 -highlightthickness 0/);
22 $canvas->create(qw/polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly/);
23 $canvas->create(qw/line 0 0 1 1 2 2 0 0 -fill black -tags line/);
24
25 my $scale = $frame->Scale(qw/-orient horizontal -length 284 -from 0
26 -to 250 -tickinterval 50 -command/ => [\&hscale_width, $canvas]);
27 $scale->set(75);
28
29 $canvas->pack(qw/-side top -expand yes -anchor w -fill x/);
30 $scale->pack(qw/-side bottom -expand yes -anchor w/);
31
32} # end hscale
33
34sub hscale_width {
35
36 my($w, $width) = @_;
37
38 $width += 21;
39 my $x2 = $width - 30;
40 $x2 = 21 if $x2 < 21;
41 $w->coords('poly', 20, 15, 20, 35, $x2, 35, $x2, 45, $width, 25, $x2, 5,
42 $x2, 15, 20, 15);
43 $w->coords('line', 20, 15, 20, 35, $x2, 35, $x2, 45, $width, 25, $x2, 5,
44 $x2, 15, 20, 15);
45
46} # end hscale_width
47
481;