0
  A   =ˆl–Ü4ý(!)”u( J»�3q·”Å£�þDì…Y¹��ç^�à?Ñ„?Ø_ˆI|¥�+V[(ÂÖ 'Þ    =# Conversion from Tk4.0 scrollbar.tcl competed.
package Tk::Scrollbar;

use vars qw($VERSION);
$VERSION = '4.010'; # $Id: //depot/Tkutf8/Scrollbar/Scrollbar.pm#10 $

use Tk qw($XS_VERSION Ev);
use AutoLoader;

use base  qw(Tk::Widget);

#use strict;
#use vars qw($pressX $pressY @initValues $initPos $activeBg);

Construct Tk::Widget 'Scrollbar';

bootstrap Tk::Scrollbar;

sub Tk_cmd { \&Tk::scrollbar }

Tk::Methods('activate','delta','fraction','get','identify','set');

sub Needed
{
 my ($sb) = @_;
 my @val = $sb->get;
 return 1 unless (@val == 2);
 return 1 if $val[0] != 0.0;
 return 1 if $val[1] != 1.0;
 return 0;
}


sub ClassInit
{
 my ($class,$mw) = @_;
 $mw->bind($class, '<Enter>', 'Enter');
 $mw->bind($class, '<Motion>', 'Motion');
 $mw->bind($class, '<Leave>', 'Leave');

 $mw->bind($class, '<1>', 'ButtonDown');
 $mw->bind($class, '<B1-Motion>', ['Drag', Ev('x'), Ev('y')]);
 $mw->bind($class, '<ButtonRelease-1>', 'ButtonUp');
 $mw->bind($class, '<B1-Leave>', 'NoOp'); # prevent generic <Leave>
 $mw->bind($class, '<B1-Enter>', 'NoOp'); # prevent generic <Enter>
 $mw->bind($class, '<Control-1>', 'ScrlTopBottom');

 $mw->bind($class, '<2>', 'ButtonDown');
 $mw->bind($class, '<B2-Motion>', ['Drag', Ev('x'), Ev('y')]);
 $mw->bind($class, '<ButtonRelease-2>', 'ButtonUp');
 $mw->bind($class, '<B2-Leave>', 'NoOp'); # prevent generic <Leave>
 $mw->bind($class, '<B2-Enter>', 'NoOp'); # prevent generic <Enter>
 $mw->bind($class, '<Control-2>', 'ScrlTopBottom');

 $mw->bind($class, '<Up>',            ['ScrlByUnits','v',-1]);
 $mw->bind($class, '<Down>',          ['ScrlByUnits','v', 1]);
 $mw->bind($class, '<Control-Up>',    ['ScrlByPages','v',-1]);
 $mw->bind($class, '<Control-Down>',  ['ScrlByPages','v', 1]);

 $mw->bind($class, '<Left>',          ['ScrlByUnits','h',-1]);
 $mw->bind($class, '<Right>',         ['ScrlByUnits','h', 1]);
 $mw->bind($class, '<Control-Left>',  ['ScrlByPages','h',-1]);
 $mw->bind($class, '<Control-Right>', ['ScrlByPages','h', 1]);

 $mw->bind($class, '<Prior>',         ['ScrlByPages','hv',-1]);
 $mw->bind($class, '<Next>',          ['ScrlByPages','hv', 1]);

 # X11 mousewheel - honour for horizontal too.
 $mw->bind($class, '<4>',             ['ScrlByUnits','hv',-5]);
 $mw->bind($class, '<5>',             ['ScrlByUnits','hv', 5]);

 $mw->bind($class, '<Home>',          ['ScrlToPos', 0]);
 $mw->bind($class, '<End>',           ['ScrlToPos', 1]);

 $mw->bind($class, '<4>',             ['ScrlByUnits','v',-3]);
 $mw->bind($class, '<5>',             ['ScrlByUnits','v', 3]);

 return $class;

}

1;

__END__

sub Enter
{
 my $w = shift;
 my $e = $w->XEvent;
 if ($Tk::strictMotif)
  {
   my $bg = $w->cget('-background');
   $activeBg = $w->cget('-activebackground');
   $w->configure('-activebackground' => $bg);
  }
 $w->activate($w->identify($e->x,$e->y));
}

sub Leave
{
 my $w = shift;
 if ($Tk::strictMotif)
  {
   $w->configure('-activebackground' => $activeBg) if (defined $activeBg) ;
  }
 $w->activate('');
}

sub Motion
{
 my $w = shift;
 my $e = $w->XEvent;
 $w->activate($w->identify($e->x,$e->y));
}

# tkScrollButtonDown --
# This procedure is invoked when a button is pressed in a scrollbar.
# It changes the way the scrollbar is displayed and takes actions
# depending on where the mouse is.
#
# Arguments:
# w -		The scrollbar widget.
# x, y -	Mouse coordinates.

sub ButtonDown
{my $w = shift;
 my $e = $w->XEvent;
 my $element = $w->identify($e->x,$e->y);
 $w->configure('-activerelief' => 'sunken');
 if ($e->b == 1 and
     (defined($element) && $element eq 'slider'))
  {
   $w->StartDrag($e->x,$e->y);
  }
 elsif ($e->b == 2 and
	(defined($element) && $element =~ /^(trough[12]|slider)$/o))
  {
	my $pos = $w->fraction($e->x, $e->y);
	my($head, $tail) = $w->get;
	my $len = $tail - $head;

	$head = $pos - $len/2;
	$tail = $pos + $len/2;
	if ($head < 0) {
		$head = 0;
		$tail = $len;
	}
	elsif ($tail > 1) {
		$head = 1 - $len;
		$tail = 1;
	}
	$w->ScrlToPos($head);
	$w->set($head, $tail);

	$w->StartDrag($e->x,$e->y);
   }
 e