home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Scale / Increment.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  1.5 KB  |  58 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Scale.pm.  Changes made here will be lost.
  2. package Tk::Scale;
  3.  
  4. # Increment --
  5. # This procedure is invoked to increment the value of a scale and
  6. # to set up auto-repeating of the action if that is desired. The
  7. # way the value is incremented depends on the "dir" and "big"
  8. # arguments.
  9. #
  10. # Arguments:
  11. # w - The scale widget.
  12. # dir - "up" means move value towards -from, "down" means
  13. # move towards -to.
  14. # big - Size of increments: "big" or "little".
  15. # repeat - Whether and how to auto-repeat the action: "noRepeat"
  16. # means don't auto-repeat, "initial" means this is the
  17. # first action in an auto-repeat sequence, and "again"
  18. # means this is the second repetition or later.
  19. sub Increment
  20. {
  21.  my $w = shift;
  22.  my $dir = shift;
  23.  my $big = shift;
  24.  my $repeat = shift;
  25.  my $inc;
  26.  if ($big eq "big")
  27.   {
  28.    $inc = $w->cget("-bigincrement");
  29.    if ($inc == 0)
  30.     {
  31.      $inc = abs(($w->cget("-to")-$w->cget("-from")))/10.0
  32.     }
  33.    if ($inc < $w->cget("-resolution"))
  34.     {
  35.      $inc = $w->cget("-resolution")
  36.     }
  37.   }
  38.  else
  39.   {
  40.    $inc = $w->cget("-resolution")
  41.   }
  42.  if (($w->cget("-from") > $w->cget("-to")) ^ ($dir eq "up"))
  43.   {
  44.    $inc = -$inc
  45.   }
  46.  $w->set($w->get()+$inc);
  47.  if ($repeat eq "again")
  48.   {
  49.    $w->RepeatId($w->after($w->cget("-repeatinterval"),"Increment",$w,$dir,$big,"again"));
  50.   }
  51.  elsif ($repeat eq "initial")
  52.   {
  53.    $w->RepeatId($w->after($w->cget("-repeatdelay"),"Increment",$w,$dir,$big,"again"));
  54.   }
  55. }
  56.  
  57. 1;
  58.