Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / auto / Tk / focusPrev.al
CommitLineData
86530b38
AT
1# NOTE: Derived from blib/lib/Tk.pm.
2# Changes made here will be lost when autosplit is run again.
3# See AutoSplit.pm.
4package Tk;
5
6#line 485 "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.
17sub 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
651;