Debian Codegraph @

info/gcl-tk/pack.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>pack (GCL TK Manual)</title>
7
8 <meta name="description" content="pack (GCL TK Manual)">
9 <meta name="keywords" content="pack (GCL TK Manual)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents">
15 <link href="Control.html" rel="up" title="Control">
16 <link href="place.html" rel="next" title="place">
17 <link href="pack_002dold.html" rel="prev" title="pack-old">
18 <style type="text/css">
19 <!--
20 a.summary-letter {text-decoration: none}
21 blockquote.indentedblock {margin-right: 0em}
22 div.display {margin-left: 3.2em}
23 div.example {margin-left: 3.2em}
24 div.lisp {margin-left: 3.2em}
25 kbd {font-style: oblique}
26 pre.display {font-family: inherit}
27 pre.format {font-family: inherit}
28 pre.menu-comment {font-family: serif}
29 pre.menu-preformatted {font-family: serif}
30 span.nolinebreak {white-space: nowrap}
31 span.roman {font-family: initial; font-weight: normal}
32 span.sansserif {font-family: sans-serif; font-weight: normal}
33 ul.no-bullet {list-style: none}
34 -->
35 </style>
36
37
38 </head>
39
40 <body lang="en">
41 <span id="pack"></span><div class="header">
42 <p>
43 Next: <a href="place.html" accesskey="n" rel="next">place</a>, Previous: <a href="pack_002dold.html" accesskey="p" rel="prev">pack-old</a>, Up: <a href="Control.html" accesskey="u" rel="up">Control</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
44 </div>
45 <hr>
46 <span id="pack-1"></span><h3 class="section">3.14 pack</h3>
47
48 <p>pack \- Geometry manager that packs around edges of cavity
49 </p><span id="Synopsis-27"></span><h4 class="unnumberedsubsec">Synopsis</h4>
50 <p><b>pack </b><i>option arg </i><span class="roman">?</span><i>arg ...</i>?
51 </p>
52 <span id="Description-25"></span><h4 class="unnumberedsubsec">Description</h4>
53
54 <p>The <b>pack</b> command is used to communicate with the packer,
55 a geometry manager that arranges the children of a parent by
56 packing them in order around the edges of the parent.
57 The <b>pack</b> command can have any of several forms, depending
58 on the <i>option</i> argument:
59 </p>
60 <dl compact="compact">
61 <dt><b>pack </b><i>slave </i><span class="roman">?</span><i>slave ...</i><span class="roman">? ?</span><i>options</i>?</dt>
62 <dd><p>If the first argument to <b>pack</b> is a window name (any value
63 starting with &ldquo;.&rdquo;), then the command is processed in the same
64 way as <b>pack configure</b>.
65 </p></dd>
66 <dt><b>pack configure </b><i>slave </i><span class="roman">?</span><i>slave ...</i><span class="roman">? ?</span><i>options</i>?</dt>
67 <dd><p>The arguments consist of the names of one or more slave windows
68 followed by pairs of arguments that specify how
69 to manage the slaves.
70 See &ldquo;THE PACKER ALGORITHM&rdquo; below for details on how the options
71 are used by the packer.
72 The following options are supported:
73 </p></dd>
74 <dt><b>:after </b><i>other</i></dt>
75 <dd><p><i>Other</i> must the name of another window.
76 Use its master as the master for the slaves, and insert
77 the slaves just after <i>other</i> in the packing order.
78 </p></dd>
79 <dt><b>:anchor </b><i>anchor</i></dt>
80 <dd><p><i>Anchor</i><span class="roman"> must be a valid anchor position such as </span><b>n</b>
81 or <b>sw</b>; it specifies where to position each slave in its
82 parcel.
83 Defaults to <b>center</b>.
84 </p></dd>
85 <dt><b>:before </b><i>other</i></dt>
86 <dd><p><i>Other</i> must the name of another window.
87 Use its master as the master for the slaves, and insert
88 the slaves just before <i>other</i> in the packing order.
89 </p></dd>
90 <dt><b>:expand </b><i>boolean</i></dt>
91 <dd><p>Specifies whether the slaves should be expanded to consume
92 extra space in their master.
93 <i>Boolean</i><span class="roman"> may have any proper boolean value, such as </span><b>1</b>
94 or <b>no</b>.
95 Defaults to 0.
96 </p></dd>
97 <dt><b>:fill </b><i>style</i></dt>
98 <dd><p>If a slave&rsquo;s parcel is larger than its requested dimensions, this
99 option may be used to stretch the slave.
100 <i>Style</i> must have one of the following values:
101 </p><dl compact="compact">
102 <dt><b>none</b></dt>
103 <dd><p>Give the slave its requested dimensions plus any internal padding
104 requested with <b>:ipadx</b><span class="roman"> or </span><b>:ipady</b>. This is the default.
105 </p></dd>
106 <dt><b>x</b></dt>
107 <dd><p>Stretch the slave horizontally to fill the entire width of its
108 parcel (except leave external padding as specified by <b>:padx</b>).
109 </p></dd>
110 <dt><b>y</b></dt>
111 <dd><p>Stretch the slave vertically to fill the entire height of its
112 parcel (except leave external padding as specified by <b>:pady</b>).
113 </p></dd>
114 <dt><b>both</b></dt>
115 <dd><p>Stretch the slave both horizontally and vertically.
116 </p></dd>
117 </dl>
118 </dd>
119 <dt><b>:in </b><i>other</i></dt>
120 <dd><p>Insert the slave(s) at the end of the packing order for the master
121 window given by <i>other</i>.
122 </p></dd>
123 <dt><b>:ipadx </b><i>amount</i></dt>
124 <dd><p><i>Amount</i> specifies how much horizontal internal padding to
125 leave on each side of the slave(s).
126 <i>Amount</i><span class="roman"> must be a valid screen distance, such as </span><b>2</b><span class="roman"> or </span><b>.5c</b>.
127 It defaults to 0.
128 </p></dd>
129 <dt><b>:ipady </b><i>amount</i></dt>
130 <dd><p><i>Amount</i> specifies how much vertical internal padding to
131 leave on each side of the slave(s).
132 <i>Amount</i> defaults to 0.
133 </p></dd>
134 <dt><b>:padx </b><i>amount</i></dt>
135 <dd><p><i>Amount</i> specifies how much horizontal external padding to
136 leave on each side of the slave(s).
137 <i>Amount</i> defaults to 0.
138 </p></dd>
139 <dt><b>:pady </b><i>amount</i></dt>
140 <dd><p><i>Amount</i> specifies how much vertical external padding to
141 leave on each side of the slave(s).
142 <i>Amount</i> defaults to 0.
143 </p></dd>
144 <dt><b>:side </b><i>side</i></dt>
145 <dd><p>Specifies which side of the master the slave(s) will be packed against.
146 Must be <b>left</b><span class="roman">, </span><b>right</b><span class="roman">, </span><b>top</b><span class="roman">, or </span><b>bottom</b>.
147 Defaults to <b>top</b>.
148 </p></dd>
149 </dl>
150
151
152 <p>If no <b>:in</b><span class="roman">, </span><b>:after</b><span class="roman"> or </span><b>:before</b> option is specified
153 then each of the slaves will be inserted at the end of the packing list
154 for its parent unless it is already managed by the packer (in which
155 case it will be left where it is).
156 If one of these options is specified then all the slaves will be
157 inserted at the specified point.
158 If any of the slaves are already managed by the geometry manager
159 then any unspecified options for them retain their previous values rather
160 than receiving default values.
161 .RE
162 </p>
163 <dl compact="compact">
164 <dt><b>pack :forget </b><i>slave </i><span class="roman">?</span><i>slave ...</i>?</dt>
165 <dd><p>Removes each of the <i>slave</i>s from the packing order for its
166 master and unmaps their windows.
167 The slaves will no longer be managed by the packer.
168 </p></dd>
169 <dt><b>pack :newinfo </b><i>slave</i></dt>
170 <dd><p>Returns a list whose elements are the current configuration state of
171 the slave given by <i>slave</i> in the same option-value form that
172 might be specified to <b>pack configure</b>.
173 The first two elements of the list are &ldquo;<b>:in </b><i>master</i>&rdquo; where
174 <i>master</i> is the slave&rsquo;s master.
175 Starting with Tk 4.0 this option will be renamed &quot;pack info&quot;.
176 </p></dd>
177 <dt><b>pack :propagate </b><i>master</i><span class="roman"> ?</span><i>boolean</i>?</dt>
178 <dd><p>If <i>boolean</i><span class="roman"> has a true boolean value such as </span><b>1</b><span class="roman"> or </span><b>on</b>
179 then propagation is enabled for <i>master</i>, which must be a window
180 name (see &ldquo;GEOMETRY PROPAGATION&rdquo; below).
181 If <i>boolean</i> has a false boolean value then propagation is
182 disabled for <i>master</i>.
183 In either of these cases an empty string is returned.
184 If <i>boolean</i><span class="roman"> is omitted then the command returns </span><b>0</b> or
185 <b>1</b> to indicate whether propagation is currently enabled
186 for <i>master</i>.
187 Propagation is enabled by default.
188 </p></dd>
189 <dt><b>pack :slaves </b><i>master</i></dt>
190 <dd><p>Returns a list of all of the slaves in the packing order for <i>master</i>.
191 The order of the slaves in the list is the same as their order in
192 the packing order.
193 If <i>master</i> has no slaves then an empty string is returned.
194 </p>
195 </dd>
196 </dl>
197 <span id="g_t_0022The-Packer-Algorithm_0022"></span><h4 class="unnumberedsubsec">&quot;The Packer Algorithm&quot;</h4>
198
199 <p>For each master the packer maintains an ordered list of slaves
200 called the <i>packing list</i>.
201 The <b>:in</b><span class="roman">, </span><b>:after</b><span class="roman">, and </span><b>:before</b> configuration
202 options are used to specify the master for each slave and the slave&rsquo;s
203 position in the packing list.
204 If none of these options is given for a slave then the slave
205 is added to the end of the packing list for its parent.
206 </p>
207 <p>The packer arranges the slaves for a master by scanning the
208 packing list in order.
209 At the time it processes each slave, a rectangular area within
210 the master is still unallocated.
211 This area is called the <i>cavity</i>; for the first slave it
212 is the entire area of the master.
213 </p>
214 <p>For each slave the packer carries out the following steps:
215 </p><ul class="no-bullet">
216 <li> [1]
217 The packer allocates a rectangular <i>parcel</i> for the slave
218 along the side of the cavity given by the slave&rsquo;s <b>:side</b> option.
219 If the side is top or bottom then the width of the parcel is
220 the width of the cavity and its height is the requested height
221 of the slave plus the <b>:ipady</b><span class="roman"> and </span><b>:pady</b> options.
222 For the left or right side the height of the parcel is
223 the height of the cavity and the width is the requested width
224 of the slave plus the <b>:ipadx</b><span class="roman"> and </span><b>:padx</b> options.
225 The parcel may be enlarged further because of the <b>:expand</b>
226 option (see &ldquo;EXPANSION&rdquo; below)
227 </li><li> [2]
228 The packer chooses the dimensions of the slave.
229 The width will normally be the slave&rsquo;s requested width plus
230 twice its <b>:ipadx</b> option and the height will normally be
231 the slave&rsquo;s requested height plus twice its <b>:ipady</b>
232 option.
233 However, if the <b>:fill</b><span class="roman"> option is </span><b>x</b><span class="roman"> or </span><b>both</b>
234 then the width of the slave is expanded to fill the width of the parcel,
235 minus twice the <b>:padx</b> option.
236 If the <b>:fill</b><span class="roman"> option is </span><b>y</b><span class="roman"> or </span><b>both</b>
237 then the height of the slave is expanded to fill the width of the parcel,
238 minus twice the <b>:pady</b> option.
239 </li><li> [3]
240 The packer positions the slave over its parcel.
241 If the slave is smaller than the parcel then the <b>:anchor</b>
242 option determines where in the parcel the slave will be placed.
243 If <b>:padx</b><span class="roman"> or </span><b>:pady</b> is non-zero, then the given
244 amount of external padding will always be left between the
245 slave and the edges of the parcel.
246 </li></ul>
247
248
249 <p>Once a given slave has been packed, the area of its parcel
250 is subtracted from the cavity, leaving a smaller rectangular
251 cavity for the next slave.
252 If a slave doesn&rsquo;t use all of its parcel, the unused space
253 in the parcel will not be used by subsequent slaves.
254 If the cavity should become too small to meet the needs of
255 a slave then the slave will be given whatever space is
256 left in the cavity.
257 If the cavity shrinks to zero size, then all remaining slaves
258 on the packing list will be unmapped from the screen until
259 the master window becomes large enough to hold them again.
260 </p>
261 <span id="g_t_0022Expansion_0022"></span><h4 class="unnumberedsubsec">&quot;Expansion&quot;</h4>
262
263 <p>If a master window is so large that there will be extra space
264 left over after all of its slaves have been packed, then the
265 extra space is distributed uniformly among all of the slaves
266 for which the <b>:expand</b> option is set.
267 Extra horizontal space is distributed among the expandable
268 slaves whose <b>:side</b><span class="roman"> is </span><b>left</b><span class="roman"> or </span><b>right</b>,
269 and extra vertical space is distributed among the expandable
270 slaves whose <b>:side</b><span class="roman"> is </span><b>top</b><span class="roman"> or </span><b>bottom</b>.
271 </p>
272 <span id="g_t_0022Geometry-Propagation_0022"></span><h4 class="unnumberedsubsec">&quot;Geometry Propagation&quot;</h4>
273
274 <p>The packer normally computes how large a master must be to
275 just exactly meet the needs of its slaves, and it sets the
276 requested width and height of the master to these dimensions.
277 This causes geometry information to propagate up through a
278 window hierarchy to a top-level window so that the entire
279 sub-tree sizes itself to fit the needs of the leaf windows.
280 However, the <b>pack propagate</b> command may be used to
281 turn off propagation for one or more masters.
282 If propagation is disabled then the packer will not set
283 the requested width and height of the packer.
284 This may be useful if, for example, you wish for a master
285 window to have a fixed size that you specify.
286 </p>
287 <span id="g_t_0022Restrictions-On-Master-Windows_0022"></span><h4 class="unnumberedsubsec">&quot;Restrictions On Master Windows&quot;</h4>
288
289 <p>The master for each slave must either be the slave&rsquo;s parent
290 (the default) or a descendant of the slave&rsquo;s parent.
291 This restriction is necessary to guarantee that the
292 slave can be placed over any part of its master that is
293 visible without danger of the slave being clipped by its parent.
294 </p>
295 <span id="g_t_0022Packing-Order_0022"></span><h4 class="unnumberedsubsec">&quot;Packing Order&quot;</h4>
296
297 <p>If the master for a slave is not its parent then you must make sure
298 that the slave is higher in the stacking order than the master.
299 Otherwise the master will obscure the slave and it will appear as
300 if the slave hasn&rsquo;t been packed correctly.
301 The easiest way to make sure the slave is higher than the master is
302 to create the master window first: the most recently created window
303 will be highest in the stacking order.
304 Or, you can use the <b>raise</b><span class="roman"> and </span><b>lower</b> commands to change
305 the stacking order of either the master or the slave.
306 </p>
307 <span id="Keywords-28"></span><h4 class="unnumberedsubsec">Keywords</h4>
308 <p>geometry manager, location, packer, parcel, propagation, size
309 </p><hr>
310 <div class="header">
311 <p>
312 Next: <a href="place.html" accesskey="n" rel="next">place</a>, Previous: <a href="pack_002dold.html" accesskey="p" rel="prev">pack-old</a>, Up: <a href="Control.html" accesskey="u" rel="up">Control</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
313 </div>
314
315
316
317 </body>
318 </html>