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

  1. # NOTE: Derived from ..\blib\lib\Tk\Scrollbar.pm.  Changes made here will be lost.
  2. package Tk::Scrollbar;
  3.  
  4. # tkScrlByPages --
  5. # This procedure tells the scrollbar's associated widget to scroll up
  6. # or down by a given number of screenfuls.  It notifies the associated
  7. # widget in different ways for old and new command syntaxes.
  8. #
  9. # Arguments:
  10. # w -        The scrollbar widget.
  11. # orient -    Which kinds of scrollbars this applies to:  "h" for
  12. #        horizontal, "v" for vertical, "hv" for both.
  13. # amount -    How many screens to scroll:  typically 1 or -1.
  14.  
  15. sub ScrlByPages 
  16. {
  17.  my $w = shift;
  18.  my $orient = shift;
  19.  my $amount = shift;
  20.  my $cmd    = $w->cget("-command");
  21.  return unless (defined $cmd);
  22.  return if (index($orient,substr($w->cget("-orient"),0,1)) < 0); 
  23.  my @info = $w->get;
  24.  if (@info == 2)
  25.   {
  26.    $cmd->Call("scroll",$amount,"pages");
  27.   }
  28.  else
  29.   {
  30.    $cmd->Call($info[2]+$amount*($info[1]-1));
  31.   }
  32. }
  33.  
  34. 1;
  35.