1pod::Prima::Widget::pacUks(e3r)Contributed Perl Documentpaotdi:o:nPrima::Widget::pack(3)
2
3
4

NAME

6       Prima::Widget::pack - Geometry manager that packs around edges of
7       cavity
8

SYNOPSIS

10         $widget-> pack( args);
11
12         $widget-> packInfo( args);
13         $widget-> geometry( gt::Pack);
14

DESCRIPTION

16       The pack method is used to communicate with the packer, a geometry
17       manager that arranges the children of a owner by packing them in order
18       around the edges of the owner.
19
20       In this port of Tk::pack it is normal to pack widgets one-at-a-time
21       using the widget object to be packed to invoke a method call.  This is
22       a slight distortion of the original Tcl-Tk interface (which can handle
23       lists of windows to one pack method call) but Tk reports that it has
24       proven effective in practice.
25
26       The pack method can have any of several forms, depending on Option:
27
28       pack %OPTIONS
29           The options consist of pairs of arguments that specify how to
30           manage the slave.  See "The packer algorithm" below for details on
31           how the options are used by the packer.  The following options are
32           supported:
33
34           after => $other
35                   $other must be another window.  Use its master as the
36                   master for the slave, and insert the slave just after
37                   $other in the packing order.
38
39           anchor => anchor
40                   Anchor must be a valid anchor position such as n or sw; it
41                   specifies where to position each slave in its parcel.
42                   Defaults to center.
43
44           before => $other
45                   $other must be another window.  Use its master as the
46                   master for the slave, and insert the slave just before
47                   $other in the packing order.
48
49           expand => boolean
50                   Specifies whether the slave should be expanded to consume
51                   extra space in their master.  Boolean may have any proper
52                   boolean value, such as 1 or no.  Defaults to 0.
53
54           fill => style
55                   If a slave's parcel is larger than its requested
56                   dimensions, this option may be used to stretch the slave.
57                   Style must have one of the following values:
58
59                   none        Give the slave its requested dimensions plus
60                               any internal padding requested with -ipadx or
61                               -ipady.  This is the default.
62
63                   x           Stretch the slave horizontally to fill the
64                               entire width of its parcel (except leave
65                               external padding as specified by -padx).
66
67                   y           Stretch the slave vertically to fill the entire
68                               height of its parcel (except leave external
69                               padding as specified by -pady).
70
71                   both        Stretch the slave both horizontally and
72                               vertically.
73
74           in => $master
75                   Insert the slave(s) at the end of the packing order for the
76                   master window given by $master. Currently, only the
77                   immediate owner can be accepted as master.
78
79           ipad => amount
80                   Amount specifies how much both horizontal and vertical
81                   internal padding to leave on each side of the slave(s).
82                   Amount must be a valid screen distance, such as 2 or .5c.
83                   It defaults to 0.
84
85           ipadx => amount
86                   Amount specifies how much horizontal internal padding to
87                   leave on each side of the slave(s).  Amount must be a valid
88                   screen distance, such as 2 or .5c.  It defaults to 0.
89
90           ipady => amount
91                   Amount specifies how much vertical internal padding to
92                   leave on each side of the slave(s).  Amount  defaults to 0.
93
94           pad => amount
95                   Amount specifies how much horizontal and vertical external
96                   padding to leave on each side of the slave(s).  Amount
97                   defaults to 0.
98
99           padx => amount
100                   Amount specifies how much horizontal external padding to
101                   leave on each side of the slave(s).  Amount defaults to 0.
102
103           pady => amount
104                   Amount specifies how much vertical external padding to
105                   leave on each side of the slave(s).  Amount defaults to 0.
106
107           side => side
108                   Specifies which side of the master the slave(s) will be
109                   packed against.  Must be left, right, top, or bottom.
110                   Defaults to top.
111
112       If no in, after or before option is specified then slave will be
113       inserted at the end of the packing list for its owner unless it is
114       already managed by the packer (in which case it will be left where it
115       is).  If one of these options is specified then slave will be inserted
116       at the specified point.  If the slave are already managed by the
117       geometry manager then any unspecified options for them retain their
118       previous values rather than receiving default values.
119
120       packForget
121           Removes slave from the packing order for its master and unmaps its
122           window.  The slave will no longer be managed by the packer.
123
124       packInfo [ %OPTIONS ]
125           In get-mode, returns a list whose elements are the current
126           configuration state of the slave given by $slave.  The first two
127           elements of the list are ``in=>$master'' where $master is the
128           slave's master.
129
130           In set-mode, sets all pack parameters, but does not set widget
131           geometry property to "gt::Pack".
132
133       packPropagate BOOLEAN
134           If boolean has a true boolean value then propagation is enabled for
135           $master, (see "Geometry propagation" below).  If boolean has a
136           false boolean value then propagation is disabled for $master.  If
137           boolean is omitted then the method returns 0 or 1 to indicate
138           whether propagation is currently enabled for $master.
139
140           Propagation is enabled by default.
141
142       packSlaves
143           Returns a list of all of the slaves in the packing order for
144           $master.  The order of the slaves in the list is the same as their
145           order in the packing order.  If $master has no slaves then an empty
146           list/string is returned in array/scalar context, respectively
147

The packer algorithm

149       For each master the packer maintains an ordered list of slaves called
150       the packing list.  The in, after, and before configuration options are
151       used to specify the master for each slave and the slave's position in
152       the packing list.  If none of these options is given for a slave then
153       the slave is added to the end of the packing list for its owner.
154
155       The packer arranges the slaves for a master by scanning the packing
156       list in order.  At the time it processes each slave, a rectangular area
157       within the master is still unallocated.  This area is called the
158       cavity;  for the first slave it is the entire area of the master.
159
160       For each slave the packer carries out the following steps:
161
162       ·   The packer allocates a rectangular parcel for the slave along the
163           side of the cavity given by the slave's side option.  If the side
164           is top or bottom then the width of the parcel is the width of the
165           cavity and its height is the requested height of the slave plus the
166           ipady and pady options.  For the left or right side the height of
167           the parcel is the height of the cavity and the width is the
168           requested width of the slave plus the ipadx and padx options.  The
169           parcel may be enlarged further because of the expand option (see
170           "Expansion" below)
171
172       ·   The packer chooses the dimensions of the slave.  The width will
173           normally be the slave's requested width plus twice its ipadx option
174           and the height will normally be the slave's requested height plus
175           twice its ipady option.  However, if the fill option is x or both
176           then the width of the slave is expanded to fill the width of the
177           parcel, minus twice the padx option.  If the fill option is y or
178           both then the height of the slave is expanded to fill the width of
179           the parcel, minus twice the pady option.
180
181       ·   The packer positions the slave over its parcel.  If the slave is
182           smaller than the parcel then the -anchor option determines where in
183           the parcel the slave will be placed.  If padx or pady is non-zero,
184           then the given amount of external padding will always be left
185           between the slave and the edges of the parcel.
186
187           Once a given slave has been packed, the area of its parcel is
188           subtracted from the cavity, leaving a smaller rectangular cavity
189           for the next slave.  If a slave doesn't use all of its parcel, the
190           unused space in the parcel will not be used by subsequent slaves.
191           If the cavity should become too small to meet the needs of a slave
192           then the slave will be given whatever space is left in the cavity.
193           If the cavity shrinks to zero size, then all remaining slaves on
194           the packing list will be unmapped from the screen until the master
195           window becomes large enough to hold them again.
196

Expansion

198       If a master window is so large that there will be extra space left over
199       after all of its slaves have been packed, then the extra space is
200       distributed uniformly among all of the slaves for which the expand
201       option is set.  Extra horizontal space is distributed among the
202       expandable slaves whose side is left or right, and extra vertical space
203       is distributed among the expandable slaves whose side is top or bottom.
204

Geometry propagation

206       The packer normally computes how large a master must be to just exactly
207       meet the needs of its slaves, and it sets the requested width and
208       height of the master to these dimensions.  This causes geometry
209       information to propagate up through a window hierarchy to a top-level
210       window so that the entire sub-tree sizes itself to fit the needs of the
211       leaf windows.  However, the packPropagate method may be used to turn
212       off propagation for one or more masters.  If propagation is disabled
213       then the packer will not set the requested width and height.  This may
214       be useful if, for example, you wish for a master window to have a fixed
215       size that you specify.
216

Restrictions on master windows

218       The master for each slave must not be a child of the slave, and must
219       not be present in any other list of slaves that directly or indirectly
220       refers to the slave.
221

Packing order

223       If the master for a slave is not its owner then you must make sure that
224       the slave is higher in the stacking order than the master.  Otherwise
225       the master will obscure the slave and it will appear as if the slave
226       hasn't been packed correctly.  The easiest way to make sure the slave
227       is higher than the master is to create the master window first:  the
228       most recently created window will be highest in the stacking order.
229       Or, you can use the bring_to_front and send_to_back methods to change
230       the stacking order of either the master or the slave.
231

SEE ALSO

233       Prima, Prima::Widget
234
235       Tk::pack Tk::place
236
237
238
239perl v5.32.0                      2020-07-28       pod::Prima::Widget::pack(3)
Impressum