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 / pack.pod
CommitLineData
86530b38
AT
1# Copyright (c) 1990-1994 The Regents of the University of California.
2# Copyright (c) 1994-1996 Sun Microsystems, Inc.
3# See the file "license.terms" for information on usage and redistribution
4# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5#
6#
7
8=head1 NAME
9
10Tk::pack - Geometry manager that packs around edges of cavity
11
12=for category Tk Geometry Management
13
14=head1 SYNOPSIS
15
16S< >I<$widget>-E<gt>B<pack>?(I<args>)?
17
18S< >I<$widget>-E<gt>B<pack>I<Option>?(I<args>)?
19
20=head1 DESCRIPTION
21
22The B<pack> method is used to communicate with the packer,
23a geometry manager that arranges the children of a parent by
24packing them in order around the edges of the parent.
25
26In this B<perl> port of Tk it is normal to pack widgets one-at-a-time
27using the widget object to be packed to invoke a method call.
28This is a slight distortion of underlying Tk interface (which
29can handle lists of windows to one pack method call) but has proven
30effective in practice.
31
32The B<pack> method can have any of several forms, depending
33on I<Option>:
34
35=over 4
36
37=item I<$slave>-E<gt>B<pack>?(I<options>)?
38
39The options consist of pairs of arguments that specify how
40to manage the slave.
41See L<"THE PACKER ALGORITHM"> below for details on how the options
42are used by the packer.
43The following options are supported:
44
45=over 8
46
47=item B<-after> =E<gt> I<$other>
48
49I<$other> must be another window.
50Use its master as the master for the slave, and insert
51the slave just after I<$other> in the packing order.
52
53=item B<-anchor> =E<gt> I<anchor>
54
55I<Anchor> must be a valid anchor position such as B<n>
56or B<sw>; it specifies where to position each slave in its
57parcel.
58Defaults to B<center>.
59
60=item B<-before> =E<gt> I<$other>
61
62I<$other> must be another window.
63Use its master as the master for the slave, and insert
64the slave just before I<$other> in the packing order.
65
66=item B<-expand> =E<gt> I<boolean>
67
68Specifies whether the slave should be expanded to consume
69extra space in their master.
70I<Boolean> may have any proper boolean value, such as B<1>
71or B<no>.
72Defaults to 0.
73
74=item B<-fill> =E<gt> I<style>
75
76If a slave's parcel is larger than its requested dimensions, this
77option may be used to stretch the slave.
78I<Style> must have one of the following values:
79
80=over 12
81
82=item B<none>
83
84Give the slave its requested dimensions plus any internal padding
85requested with B<-ipadx> or B<-ipady>. This is the default.
86
87=item B<x>
88
89Stretch the slave horizontally to fill the entire width of its
90parcel (except leave external padding as specified by B<-padx>).
91
92=item B<y>
93
94Stretch the slave vertically to fill the entire height of its
95parcel (except leave external padding as specified by B<-pady>).
96
97=item B<both>
98
99Stretch the slave both horizontally and vertically.
100
101=back
102
103=item B<-in> =E<gt> I<$master>
104
105Insert the slave(s) at the end of the packing order for the master
106window given by I<$master>.
107
108=item B<-ipadx> =E<gt> I<amount>
109
110I<Amount> specifies how much horizontal internal padding to
111leave on each side of the slave(s).
112I<Amount> must be a valid screen distance, such as B<2> or B<.5c>.
113It defaults to 0.
114
115=item B<-ipady> =E<gt> I<amount>
116
117I<Amount> specifies how much vertical internal padding to
118leave on each side of the slave(s).
119I<Amount> defaults to 0.
120
121=item B<-padx> =E<gt> I<amount>
122
123I<Amount> specifies how much horizontal external padding to
124leave on each side of the slave(s).
125I<Amount> defaults to 0.
126
127=item B<-pady> =E<gt> I<amount>
128
129I<Amount> specifies how much vertical external padding to
130leave on each side of the slave(s).
131I<Amount> defaults to 0.
132
133=item B<-side> =E<gt> I<side>
134
135Specifies which side of the master the slave(s) will be packed against.
136Must be B<left>, B<right>, B<top>, or B<bottom>.
137Defaults to B<top>.
138
139=back
140
141=back
142
143If no B<-in>, B<-after> or B<-before> option is specified
144then slave will be inserted at the end of the packing list
145for its parent unless it is already managed by the packer (in which
146case it will be left where it is).
147If one of these options is specified then slave will be
148inserted at the specified point.
149If the slave are already managed by the geometry manager
150then any unspecified options for them retain their previous values rather
151than receiving default values.
152
153=over 4
154
155=item I<$slave>-E<gt>B<packForget>
156
157Removes I<slave> from the packing order for its
158master and unmaps its window.
159The slave will no longer be managed by the packer.
160
161=item I<$slave>-E<gt>B<packInfo>
162
163Returns a list whose elements are the current configuration state of
164the slave given by I<$slave> in the same option-value form that
165might be specified to B<packConfigure>.
166The first two elements of the list are ``B<-in>=E<gt>I<$master>'' where
167I<$master> is the slave's master.
168
169=item I<$master>-E<gt>B<packPropagate>?(I<boolean>)?
170
171If I<boolean> has a true boolean value such as B<1> or B<on>
172then propagation is enabled for I<$master>,
173(see L<"GEOMETRY PROPAGATION"> below).
174If I<boolean> has a false boolean value then propagation is
175disabled for I<$master>.
176In either of these cases an empty string is returned.
177If I<boolean> is omitted then the method returns B<0> or
178B<1> to indicate whether propagation is currently enabled
179for I<$master>.
180Propagation is enabled by default.
181
182=item I<$master>-E<gt>B<packSlaves>
183
184Returns a list of all of the slaves in the packing order for I<$master>.
185The order of the slaves in the list is the same as their order in
186the packing order.
187If I<$master> has no slaves then an empty list/string is returned in
188array/scalar context, respectively
189
190=back
191
192=head1 THE PACKER ALGORITHM
193
194For each master the packer maintains an ordered list of slaves
195called the I<packing list>.
196The B<-in>, B<-after>, and B<-before> configuration
197options are used to specify the master for each slave and the slave's
198position in the packing list.
199If none of these options is given for a slave then the slave
200is added to the end of the packing list for its parent.
201
202The packer arranges the slaves for a master by scanning the
203packing list in order.
204At the time it processes each slave, a rectangular area within
205the master is still unallocated.
206This area is called the I<cavity>; for the first slave it
207is the entire area of the master.
208
209For each slave the packer carries out the following steps:
210
211=over 4
212
213=item [1]
214
215The packer allocates a rectangular I<parcel> for the slave
216along the side of the cavity given by the slave's B<-side> option.
217If the side is top or bottom then the width of the parcel is
218the width of the cavity and its height is the requested height
219of the slave plus the B<-ipady> and B<-pady> options.
220For the left or right side the height of the parcel is
221the height of the cavity and the width is the requested width
222of the slave plus the B<-ipadx> and B<-padx> options.
223The parcel may be enlarged further because of the B<-expand>
224option (see L<"EXPANSION"> below)
225
226=item [2]
227
228The packer chooses the dimensions of the slave.
229The width will normally be the slave's requested width plus
230twice its B<-ipadx> option and the height will normally be
231the slave's requested height plus twice its B<-ipady>
232option.
233However, if the B<-fill> option is B<x> or B<both>
234then the width of the slave is expanded to fill the width of the parcel,
235minus twice the B<-padx> option.
236If the B<-fill> option is B<y> or B<both>
237then the height of the slave is expanded to fill the width of the parcel,
238minus twice the B<-pady> option.
239
240=item [3]
241
242The packer positions the slave over its parcel.
243If the slave is smaller than the parcel then the B<-anchor>
244option determines where in the parcel the slave will be placed.
245If B<-padx> or B<-pady> is non-zero, then the given
246amount of external padding will always be left between the
247slave and the edges of the parcel.
248
249Once a given slave has been packed, the area of its parcel
250is subtracted from the cavity, leaving a smaller rectangular
251cavity for the next slave.
252If a slave doesn't use all of its parcel, the unused space
253in the parcel will not be used by subsequent slaves.
254If the cavity should become too small to meet the needs of
255a slave then the slave will be given whatever space is
256left in the cavity.
257If the cavity shrinks to zero size, then all remaining slaves
258on the packing list will be unmapped from the screen until
259the master window becomes large enough to hold them again.
260
261=back
262
263=head1 EXPANSION
264
265If a master window is so large that there will be extra space
266left over after all of its slaves have been packed, then the
267extra space is distributed uniformly among all of the slaves
268for which the B<-expand> option is set.
269Extra horizontal space is distributed among the expandable
270slaves whose B<-side> is B<left> or B<right>,
271and extra vertical space is distributed among the expandable
272slaves whose B<-side> is B<top> or B<bottom>.
273
274=head1 GEOMETRY PROPAGATION
275
276The packer normally computes how large a master must be to
277just exactly meet the needs of its slaves, and it sets the
278requested width and height of the master to these dimensions.
279This causes geometry information to propagate up through a
280window hierarchy to a top-level window so that the entire
281sub-tree sizes itself to fit the needs of the leaf windows.
282However, the B<packPropagate> method may be used to
283turn off propagation for one or more masters.
284If propagation is disabled then the packer will not set
285the requested width and height of the packer.
286This may be useful if, for example, you wish for a master
287window to have a fixed size that you specify.
288
289=head1 RESTRICTIONS ON MASTER WINDOWS
290
291The master for each slave must either be the slave's parent
292(the default) or a descendant of the slave's parent.
293This restriction is necessary to guarantee that the
294slave can be placed over any part of its master that is
295visible without danger of the slave being clipped by its parent.
296
297=head1 PACKING ORDER
298
299If the master for a slave is not its parent then you must make sure
300that the slave is higher in the stacking order than the master.
301Otherwise the master will obscure the slave and it will appear as
302if the slave hasn't been packed correctly.
303The easiest way to make sure the slave is higher than the master is
304to create the master window first: the most recently created window
305will be highest in the stacking order.
306Or, you can use the B<raise> and B<lower> methods to change
307the stacking order of either the master or the slave.
308
309=head1 SEE ALSO
310
311L<Tk::form|Tk::form>
312L<Tk::grid|Tk::grid>
313L<Tk::place|Tk::place>
314
315=head1 KEYWORDS
316
317geometry manager, location, packer, parcel, propagation, size
318
319=cut
320