~ubuntu-branches/ubuntu/natty/perl-tk/natty

« back to all changes in this revision

Viewing changes to demos/demos/widget_lib/mkVScale.pl

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Zander
  • Date: 2004-03-14 13:54:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314135444-prc09u2or4dbr3to
Tags: 1:800.025-2
Add xlibs-dev to Build-Depends:,
Closes: #237942

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
sub 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
 
 
35
 
sub 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
 
 
48
 
1;