home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Scrollbar / ScrlToPos.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  752 b   |  32 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Scrollbar.pm.  Changes made here will be lost.
  2. package Tk::Scrollbar;
  3.  
  4. # tkScrlToPos --
  5. # This procedure tells the scrollbar's associated widget to scroll to
  6. # a particular location, given by a fraction between 0 and 1.  It notifies
  7. # the associated widget in different ways for old and new command syntaxes.
  8. #
  9. # Arguments:
  10. # w -        The scrollbar widget.
  11. # pos -        A fraction between 0 and 1 indicating a desired position
  12. #        in the document.
  13.  
  14. sub ScrlToPos
  15. {
  16.  my $w = shift;
  17.  my $pos = shift;
  18.  my $cmd = $w->cget("-command");
  19.  return unless (defined $cmd);
  20.  my @info = $w->get;
  21.  if (@info == 2)
  22.   {
  23.    $cmd->Call("moveto",$pos);
  24.   }
  25.  else
  26.   {
  27.    $cmd->Call(int($info[0]*$pos));
  28.   }
  29. }
  30.  
  31. 1;
  32.