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 / Tk / Adjuster.pod
CommitLineData
86530b38
AT
1
2=head1 NAME
3
4Tk::Adjuster - Allow size of packed widgets to be adjusted by user
5
6=for pm Tk/Adjuster.pm
7
8=for category Tk Geometry Management
9
10=head1 SYNOPSIS
11
12use Tk::Adjuster;
13
14I<$adjuster> = I<$widget>->B<Adjuster>I<(?options?)>;
15
16=head1 WIDGET-SPECIFIC OPTIONS
17
18=over 4
19
20=item Name: B<restore>
21
22=item Class: B<Restore>
23
24=item Switch: B<-restore>
25
26Specifies a boolean value that determines whether the Adjuster
27should forcibly attempt to make room
28for itself (by reducing the size of its managed widget) when it is
29unmapped (for example, due to a size change in a top level window).
30The default value is 1.
31
32=item Name: B<side>
33
34=item Class: B<Side>
35
36=item Switch: B<-side>
37
38Specifies the side on which the managed widget lies relative to the
39Adjuster. In conjunction with the pack geometry manager, this relates to
40the side of the master against which the managed widget and the Adjuster
41are packed.
42Must be B<left>, B<right>, B<top>, or B<bottom>. Defaults to B<top>.
43
44=item Name: B<widget>
45
46=item Class: B<Widget>
47
48=item Switch: B<-widget>
49
50Specifies the widget which is to be managed by the Adjuster.
51
52=back
53
54=head1 DESCRIPTION
55
56B<Tk::Adjuster> is a Frame containing a "line" and a "blob".
57
58Dragging with Mouse Button-1 results in a line being dragged
59to indicate new size. Releasing Button-1 submits GeometryRequests
60on behalf of the managed widget which will cause the packer to change the
61widget's size.
62
63If Drag is done with Shift button down, then GeometryRequests are made
64in "real time" so that text-flow effects can be seen, but as a lot more
65work is done behaviour may be sluggish.
66
67If widget is packed with -side => left or -side => right then width is
68adjusted. If packed -side => top or -side => bottom then height is adjusted.
69
70B<packPropagate> is turned off for the master window to prevent adjustment
71changing overall window size. Similarly B<packPropagate> is turned off
72for the managed widget if it has things packed inside it. This is so that
73the GeometryRequests made by B<Tk::Adjuster> are not overridden by pack.
74
75In addition, the managed widget is made non-expandable
76to prevent the geometry manager reallocating freed space in the master
77back to the managed widget.
78Note however that expansion is turned off only after the Adjuster is mapped,
79which allows the managed widget to expand naturally on window creation.
80
81The Tk::Widget method, B<packAdjust>, calls pack on the widget, then
82creates an instance of B<Tk::Adjuster>,
83and packs that "after" the widget. Its use has two disadvantages however: the
84Adjuster widget is not made available to the caller, and
85options cannot be set on the Adjuster. For these reasons, the Tk::Adjuster
86method, B<packAfter> is preferred, but B<packAdjust> is retained
87for backwards compatibility.
88
89=head1 WIDGET METHODS
90
91=over 4
92
93=item I<$adjuster>->B<packAfter>(I<managed_widget, ?pack_options?>)
94
95This command configures the Adjuster's B<-widget> and B<-side> options
96respectively to I<managed_widget> and the B<-side> value specified in
97I<pack_options> (B<top> if not specified). It then packs the Adjuster
98after I<managed_widget>, with B<-fill> set to B<x> or B<y> as appropriate.
99
100=item I<$adjuster>->B<packForget>I<?(boolean)?>
101
102This command calls B<Tk::Widget::packForget> on the Adjuster.
103If a parameter is provided and it has a true boolean value, then
104B<packForget> is also called on the managed widget.
105
106=item I<$adjuster>->B<slave>
107
108This command returns the value I<$adjuster>->I<cget('-widget')>, ie. the
109reference to the managed widget.
110
111=back
112
113=head1 EXAMPLES
114
115B<Using an Adjuster to separate two widgets, whereby the left widget
116is managed, and right widget expands to fill space on a window resize>
117
118a) Using packAfter (preferred interface)
119
120 use Tk;
121 use Tk::Adjuster;
122
123 my $f = MainWindow->new;
124 my $lst1 = $f->Listbox();
125 my $adj1 = $f->Adjuster();
126 my $lst2 = $f->Listbox();
127
128 my $side = 'left';
129 $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
130 $adj1->packAfter($lst1, -side => $side);
131 $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
132 MainLoop;
133
134b) Using packAdjust
135
136 use Tk;
137 use Tk::Adjuster;
138
139 my $f = MainWindow->new;
140 my $lst1 = $f->Listbox();
141 my $lst2 = $f->Listbox();
142
143 my $side = 'left';
144 $lst1->packAdjust(-side => $side, -fill => 'both');
145 $lst2->pack (-side => $side, -fill => 'both', -expand => 1);
146 MainLoop;
147
148c) Using the standard Tk::Widget::pack
149
150 use Tk;
151 use Tk::Adjuster;
152
153 my $f = MainWindow->new;
154 my $side = 'left';
155 my $lst1 = $f->Listbox();
156 my $adj = $f->Adjuster(-widget => $lst1, -side => $side);
157 my $lst2 = $f->Listbox();
158
159 $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
160 $adj->pack (-side => $side, -fill => 'y');
161 $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
162
163 MainLoop;
164
165Changing the above examples so that $side has the value 'right' means the
166left widget expands to fill space on a window resize.
167
168Changing the above examples so that $side has the value 'top'
169produces a testcase with a horizontal Adjuster.
170Here the bottom widget expands to fill space on a window resize.
171Packing to the 'bottom' makes the top widget expand to fill space on window
172resize.
173
174B<Using -restore =E<gt> 0 for multiple columns>
175
176In the case of multiple columns (or rows) the "restore" functionality of the
177Adjuster can be inconvenient. When the user adjusts the width of one column
178and thereby pushes the Adjuster of another column off the window, this
179adjuster tries to restore itself by reducing the size of its managed widget.
180This has the effect that column widths shrink; and the original size
181is not restored when
182the user reverses the originating change. The B<-restore> option can be
183used to turn off this functionality. (It makes some sense, however, to
184leave B<-restore>
185turned on for the first-packed Adjuster, so that at least one Adjuster
186always remains visible.)
187
188 use Tk;
189 use Tk::Adjuster;
190 my $f = MainWindow->new;
191 my $lst1 = $f->Listbox();
192 my $adj1 = $f->Adjuster();
193 my $lst2 = $f->Listbox();
194 my $adj2 = $f->Adjuster(-restore => 0);
195 my $lst3 = $f->Listbox();
196
197 my $side = 'left';
198 $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
199 $adj1->packAfter($lst1, -side => $side);
200 $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
201 $adj2->packAfter($lst2, -side => $side);
202 $lst3->pack(-side => $side, -fill => 'both', -expand => 1);
203
204 MainLoop;
205
206=head1 BUGS
207
208It is currently not possible to configure the appearance of the Adjuster.
209It would be nice to be able to set the width and relief of the Adjuster "line"
210and the presence/absence of the "blob" on the Adjuster.
211
212Tk::Adjuster works theoretically with the grid geometry manager but there
213are currently some problems which seem to be due to bugs in grid:
214
215 a) There's never an Unmap event for the adjuster, so the "restore"
216 functionality has no effect.
217 b) After adjusting, widgets protrude into the border of the master.
218 c) grid('Propagate', 0) on MainWindow has no effect - window shrinks/grows
219 when widgets are adjusted.
220 d) Widgets shuffle to correct position on startup
221
222=cut
223