OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / doc / pack.n
1 '\"
2 '\" Copyright (c) 1990-1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH pack n 4.0 Tk "Tk Built-In Commands"
9 .so man.macros
10 .BS
11 '\" Note:  do not modify the .SH NAME line immediately below!
12 .SH NAME
13 pack \- Geometry manager that packs around edges of cavity
14 .SH SYNOPSIS
15 \fBpack \fIoption arg \fR?\fIarg ...\fR?
16 .BE
17 .SH DESCRIPTION
18 .PP
19 The \fBpack\fR command is used to communicate with the packer,
20 a geometry manager that arranges the children of a parent by
21 packing them in order around the edges of the parent.
22 The \fBpack\fR command can have any of several forms, depending
23 on the \fIoption\fR argument:
24 .TP
25 \fBpack \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
26 If the first argument to \fBpack\fR is a window name (any value
27 starting with
28 .QW . ),
29 then the command is processed in the same way as \fBpack configure\fR.
30 .TP
31 \fBpack configure \fIwindow \fR?\fIwindow ...\fR? ?\fIoptions\fR?
32 The arguments consist of the names of one or more content windows
33 followed by pairs of arguments that specify how
34 to manage the content.
35 See \fBTHE PACKER ALGORITHM\fR below for details on how the options
36 are used by the packer.
37 The following options are supported:
38 .RS
39 .TP
40 \fB\-after \fIother\fR
41 \fIOther\fR must the name of another window.
42 Use its container as the container for the content, and insert
43 the content just after \fIother\fR in the packing order.
44 .TP
45 \fB\-anchor \fIanchor\fR
46 \fIAnchor\fR must be a valid anchor position such as \fBn\fR
47 or \fBsw\fR; it specifies where to position each content in its
48 parcel.
49 Defaults to \fBcenter\fR.
50 .TP
51 \fB\-before \fIother\fR
52 \fIOther\fR must the name of another window.
53 Use its container as the container for the content, and insert
54 the content just before \fIother\fR in the packing order.
55 .TP
56 \fB\-expand \fIboolean\fR
57 Specifies whether the content should be expanded to consume
58 extra space in their container.
59 \fIBoolean\fR may have any proper boolean value, such as \fB1\fR
60 or \fBno\fR.
61 Defaults to 0.
62 .TP
63 \fB\-fill \fIstyle\fR
64 If a content's parcel is larger than its requested dimensions, this
65 option may be used to stretch the content.
66 \fIStyle\fR must have one of the following values:
67 .RS
68 .TP
69 \fBnone\fR
70 Give the content its requested dimensions plus any internal padding
71 requested with \fB\-ipadx\fR or \fB\-ipady\fR.  This is the default.
72 .TP
73 \fBx\fR
74 Stretch the content horizontally to fill the entire width of its
75 parcel (except leave external padding as specified by \fB\-padx\fR).
76 .TP
77 \fBy\fR
78 Stretch the content vertically to fill the entire height of its
79 parcel (except leave external padding as specified by \fB\-pady\fR).
80 .TP
81 \fBboth\fR
82 Stretch the content both horizontally and vertically.
83 .RE
84 .TP
85 \fB\-in \fIcontainer\fR
86 Insert the window at the end of the packing order for the container
87 window given by \fIcontainer\fR.
88 .TP
89 \fB\-ipadx \fIamount\fR
90 \fIAmount\fR specifies how much horizontal internal padding to
91 leave on each side of the content.
92 \fIAmount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR.
93 It defaults to 0.
94 .TP
95 \fB\-ipady \fIamount\fR
96 \fIAmount\fR specifies how much vertical internal padding to
97 leave on each side of the content.
98 \fIAmount\fR  defaults to 0.
99 .TP
100 \fB\-padx \fIamount\fR
101 \fIAmount\fR specifies how much horizontal external padding to
102 leave on each side of the content.  \fIAmount\fR may be a list
103 of two values to specify padding for left and right separately.
104 \fIAmount\fR defaults to 0.
105 .TP
106 \fB\-pady \fIamount\fR
107 \fIAmount\fR specifies how much vertical external padding to
108 leave on each side of the content.  \fIAmount\fR may be a list
109 of two values to specify padding for top and bottom separately.
110 \fIAmount\fR defaults to 0.
111 .TP
112 \fB\-side \fIside\fR
113 Specifies which side of the container the content will be packed against.
114 Must be \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR.
115 Defaults to \fBtop\fR.
116 .LP
117 If no \fB\-in\fR, \fB\-after\fR or \fB\-before\fR option is specified
118 then each of the content will be inserted at the end of the packing list
119 for its parent unless it is already managed by the packer (in which
120 case it will be left where it is).
121 If one of these options is specified then all the content will be
122 inserted at the specified point.
123 If any of the content are already managed by the geometry manager
124 then any unspecified options for them retain their previous values rather
125 than receiving default values.
126 .RE
127 .TP
128 \fBpack forget \fIwindow \fR?\fIwindow ...\fR?
129 Removes each of the \fIwindow\fRs from the packing order for its
130 container and unmaps their windows.
131 The content will no longer be managed by the packer.
132 .TP
133 \fBpack info \fIwindow\fR
134 Returns a list whose elements are the current configuration state of
135 the window given by \fIwindow\fR in the same option-value form that
136 might be specified to \fBpack configure\fR.
137 The first two elements of the list are
138 .QW "\fB\-in \fIcontainer\fR"
139 where \fIcontainer\fR is the window's container.
140 .TP
141 \fBpack propagate \fIcontainer\fR ?\fIboolean\fR?
142 If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR
143 then propagation is enabled for \fIcontainer\fR, which must be a window
144 name (see \fBGEOMETRY PROPAGATION\fR below).
145 If \fIboolean\fR has a false boolean value then propagation is
146 disabled for \fIcontainer\fR.
147 In either of these cases an empty string is returned.
148 If \fIboolean\fR is omitted then the command returns \fB0\fR or
149 \fB1\fR to indicate whether propagation is currently enabled
150 for \fIcontainer\fR.
151 Propagation is enabled by default.
152 .TP
153 \fBpack slaves \fIwindow\fR
154 Returns a list of all of the content windows in the packing order for \fIwindow\fR.
155 The order of the content windows in the list is the same as their order in
156 the packing order.
157 If \fIwindow\fR has no content then an empty string is returned.
158 .VS "TIP 581"
159 .TP
160 \fBpack content \fIwindow\fR
161 .
162 Synonym for \fBpack slaves \fIwindow\fR.
163 .VE "TIP 581"
164 .SH "THE PACKER ALGORITHM"
165 .PP
166 For each container the packer maintains an ordered list of content
167 windows called the \fIpacking list\fR.
168 The \fB\-in\fR, \fB\-after\fR, and \fB\-before\fR configuration
169 options are used to specify the container for each content and the content's
170 position in the packing list.
171 If none of these options is given for a content then the content
172 is added to the end of the packing list for its parent.
173 .PP
174 The packer arranges the content windows for a container by scanning the
175 packing list in order.
176 At the time it processes each content, a rectangular area within
177 the container is still unallocated.
178 This area is called the \fIcavity\fR;  for the first content it
179 is the entire area of the container.
180 .PP
181 For each content the packer carries out the following steps:
182 .IP [1]
183 The packer allocates a rectangular \fIparcel\fR for the content
184 along the side of the cavity given by the content's \fB\-side\fR option.
185 If the side is top or bottom then the width of the parcel is
186 the width of the cavity and its height is the requested height
187 of the content plus the \fB\-ipady\fR and \fB\-pady\fR options.
188 For the left or right side the height of the parcel is
189 the height of the cavity and the width is the requested width
190 of the content plus the \fB\-ipadx\fR and \fB\-padx\fR options.
191 The parcel may be enlarged further because of the \fB\-expand\fR
192 option (see \fBEXPANSION\fR below)
193 .IP [2]
194 The packer chooses the dimensions of the content.
195 The width will normally be the content's requested width plus
196 twice its \fB\-ipadx\fR option and the height will normally be
197 the content's requested height plus twice its \fB\-ipady\fR
198 option.
199 However, if the \fB\-fill\fR option is \fBx\fR or \fBboth\fR
200 then the width of the content is expanded to fill the width of the parcel,
201 minus twice the \fB\-padx\fR option.
202 If the \fB\-fill\fR option is \fBy\fR or \fBboth\fR
203 then the height of the content is expanded to fill the width of the parcel,
204 minus twice the \fB\-pady\fR option.
205 .IP [3]
206 The packer positions the content over its parcel.
207 If the content is smaller than the parcel then the \fB\-anchor\fR
208 option determines where in the parcel the content will be placed.
209 If \fB\-padx\fR or \fB\-pady\fR is non-zero, then the given
210 amount of external padding will always be left between the
211 content and the edges of the parcel.
212 .PP
213 Once a given content has been packed, the area of its parcel
214 is subtracted from the cavity, leaving a smaller rectangular
215 cavity for the next content.
216 If a content does not use all of its parcel, the unused space
217 in the parcel will not be used by subsequent content.
218 If the cavity should become too small to meet the needs of
219 a content then the content will be given whatever space is
220 left in the cavity.
221 If the cavity shrinks to zero size, then all remaining content
222 on the packing list will be unmapped from the screen until
223 the container window becomes large enough to hold them again.
224 .SS "EXPANSION"
225 .PP
226 If a container window is so large that there will be extra space
227 left over after all of its content have been packed, then the
228 extra space is distributed uniformly among all of the content
229 for which the \fB\-expand\fR option is set.
230 Extra horizontal space is distributed among the expandable
231 content whose \fB\-side\fR is \fBleft\fR or \fBright\fR,
232 and extra vertical space is distributed among the expandable
233 content whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR.
234 .SS "GEOMETRY PROPAGATION"
235 .PP
236 The packer normally computes how large a container must be to
237 just exactly meet the needs of its content, and it sets the
238 requested width and height of the container to these dimensions.
239 This causes geometry information to propagate up through a
240 window hierarchy to a top-level window so that the entire
241 sub-tree sizes itself to fit the needs of the leaf windows.
242 However, the \fBpack propagate\fR command may be used to
243 turn off propagation for one or more containers.
244 If propagation is disabled then the packer will not set
245 the requested width and height of the packer.
246 This may be useful if, for example, you wish for a container
247 window to have a fixed size that you specify.
248 .SH "RESTRICTIONS ON CONTAINER WINDOWS"
249 .PP
250 The container for each content must either be the content's parent
251 (the default) or a descendant of the content's parent.
252 This restriction is necessary to guarantee that the
253 content can be placed over any part of its container that is
254 visible without danger of the content being clipped by its parent.
255 .SH "PACKING ORDER"
256 .PP
257 If the container for a content is not its parent then you must make sure
258 that the content is higher in the stacking order than the container.
259 Otherwise the container will obscure the content and it will appear as
260 if the content has not been packed correctly.
261 The easiest way to make sure the content is higher than the container is
262 to create the container window first:  the most recently created window
263 will be highest in the stacking order.
264 Or, you can use the \fBraise\fR and \fBlower\fR commands to change
265 the stacking order of either the container or the content.
266 .SH EXAMPLE
267 .PP
268 .CS
269 # Make the widgets
270 label .t \-text "This widget is at the top"    \-bg red
271 label .b \-text "This widget is at the bottom" \-bg green
272 label .l \-text "Left\enHand\enSide"
273 label .r \-text "Right\enHand\enSide"
274 text .mid
275 \&.mid insert end "This layout is like Java's BorderLayout"
276 # Lay them out
277 \fBpack\fR .t   \-side top    \-fill x
278 \fBpack\fR .b   \-side bottom \-fill x
279 \fBpack\fR .l   \-side left   \-fill y
280 \fBpack\fR .r   \-side right  \-fill y
281 \fBpack\fR .mid \-expand 1    \-fill both
282 .CE
283 .SH "SEE ALSO"
284 grid(n), place(n)
285 .SH KEYWORDS
286 geometry manager, location, packer, parcel, propagation, size
287 '\" Local Variables:
288 '\" mode: nroff
289 '\" End: