home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _c940161b2267fd35c12457aa96a68ee0 < prev    next >
Encoding:
Text File  |  2004-06-01  |  1.8 KB  |  66 lines

  1. # NOTE: Derived from blib\lib\Tk.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package Tk;
  5.  
  6. #line 571 "blib\lib\Tk.pm (autosplit into blib\lib\auto\Tk\focusPrev.al)"
  7. # focusPrev --
  8. # This procedure is invoked to move the input focus to the previous
  9. # window before a given one. "Previous" is defined in terms of the
  10. # window stacking order, with all the windows underneath a given
  11. # top-level (no matter how deeply nested in the hierarchy) considered.
  12. #
  13. # Arguments:
  14. # w - Name of a window: the procedure will set the focus
  15. # to the previous window before this one in the traversal
  16. # order.
  17. sub focusPrev
  18. {
  19.  my $w = shift;
  20.  my $cur = $w;
  21.  my @children;
  22.  my $i;
  23.  my $parent;
  24.  while (1)
  25.   {
  26.    # Collect information about the current window's position
  27.    # among its siblings. Also, if the window is a top-level,
  28.    # then reposition to just after the last child of the window.
  29.    if ($cur->toplevel() == $cur)
  30.     {
  31.      $parent = $cur;
  32.      @children = $cur->FocusChildren();
  33.      $i = @children;
  34.     }
  35.    else
  36.     {
  37.      $parent = $cur->parent();
  38.      @children = $parent->FocusChildren();
  39.      $i = lsearch(\@children,$cur);
  40.     }
  41.    # Go to the previous sibling, then descend to its last descendant
  42.    # (highest in stacking order. While doing this, ignore top-levels
  43.    # and their descendants. When we run out of descendants, go up
  44.    # one level to the parent.
  45.    while ($i > 0)
  46.     {
  47.      $i--;
  48.      $cur = $children[$i];
  49.      next if ($cur->toplevel() == $cur);
  50.      $parent = $cur;
  51.      @children = $parent->FocusChildren();
  52.      $i = @children;
  53.     }
  54.    $cur = $parent;
  55.    if ($cur == $w || $cur->FocusOK)
  56.     {
  57.      $cur->tabFocus;
  58.      return;
  59.     }
  60.   }
  61.  
  62. }
  63.  
  64. # end of Tk::focusPrev
  65. 1;
  66.