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 / auto / Tk / Scrollbar / ButtonDown.al
CommitLineData
86530b38
AT
1# NOTE: Derived from ../blib/lib/Tk/Scrollbar.pm.
2# Changes made here will be lost when autosplit is run again.
3# See AutoSplit.pm.
4package Tk::Scrollbar;
5
6#line 106 "../blib/lib/Tk/Scrollbar.pm (autosplit into ../blib/lib/auto/Tk/Scrollbar/ButtonDown.al)"
7# tkScrollButtonDown --
8# This procedure is invoked when a button is pressed in a scrollbar.
9# It changes the way the scrollbar is displayed and takes actions
10# depending on where the mouse is.
11#
12# Arguments:
13# w - The scrollbar widget.
14# x, y - Mouse coordinates.
15
16sub ButtonDown
17{my $w = shift;
18 my $e = $w->XEvent;
19 my $element = $w->identify($e->x,$e->y);
20 $w->configure('-activerelief' => 'sunken');
21 if ($e->b == 1 and
22 (defined($element) && $element eq 'slider'))
23 {
24 $w->StartDrag($e->x,$e->y);
25 }
26 elsif ($e->b == 2 and
27 (defined($element) && $element =~ /^(trough[12]|slider)$/o))
28 {
29 my $pos = $w->fraction($e->x, $e->y);
30 my($head, $tail) = $w->get;
31 my $len = $tail - $head;
32
33 $head = $pos - $len/2;
34 $tail = $pos + $len/2;
35 if ($head < 0) {
36 $head = 0;
37 $tail = $len;
38 }
39 elsif ($tail > 1) {
40 $head = 1 - $len;
41 $tail = 1;
42 }
43 $w->ScrlToPos($head);
44 $w->set($head, $tail);
45
46 $w->StartDrag($e->x,$e->y);
47 }
48 else
49 {
50 $w->Select($element,'initial');
51 }
52}
53
54# end of Tk::Scrollbar::ButtonDown
551;