home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tk::pack - Geometry manager that packs around edges of cavity</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::pack - Geometry manager that packs around edges of cavity</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#the packer algorithm">THE PACKER ALGORITHM</A></LI>
- <LI><A HREF="#expansion">EXPANSION</A></LI>
- <LI><A HREF="#geometry propagation">GEOMETRY PROPAGATION</A></LI>
- <LI><A HREF="#restrictions on master windows">RESTRICTIONS ON MASTER WINDOWS</A></LI>
- <LI><A HREF="#packing order">PACKING ORDER</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#keywords">KEYWORDS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tk::pack - Geometry manager that packs around edges of cavity</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P> <EM>$widget</EM>-><STRONG>pack</STRONG>?(<EM>args</EM>)?</P>
- <P> <EM>$widget</EM>-><STRONG>pack</STRONG><EM>Option</EM>?(<EM>args</EM>)?</P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>The <STRONG>pack</STRONG> method is used to communicate with the packer,
- a geometry manager that arranges the children of a parent by
- packing them in order around the edges of the parent.</P>
- <P>In this <STRONG>perl</STRONG> port of Tk it is normal to pack widgets one-at-a-time
- using the widget object to be packed to invoke a method call.
- This is a slight distortion of underlying Tk interface (which
- can handle lists of windows to one pack method call) but has proven
- effective in practice.</P>
- <P>The <STRONG>pack</STRONG> method can have any of several forms, depending
- on <EM>Option</EM>:</P>
- <DL>
- <DT><STRONG><A NAME="item_pack"><EM>$slave</EM>-><STRONG>pack</STRONG>?(<EM>options</EM>)?</A></STRONG><BR>
- <DD>
- The options consist of pairs of arguments that specify how
- to manage the slave.
- See <A HREF="#the packer algorithm">THE PACKER ALGORITHM</A> below for details on how the options
- are used by the packer.
- The following options are supported:
- <DL>
- <DT><STRONG><A NAME="item_%2Dafter_%3D%3E_%24other"><STRONG>-after</STRONG> => <EM>$other</EM></A></STRONG><BR>
- <DD>
- <EM>$other</EM> must be another window.
- Use its master as the master for the slave, and insert
- the slave just after <EM>$other</EM> in the packing order.
- <P></P>
- <DT><STRONG><A NAME="item_%2Danchor_%3D%3E_anchor"><STRONG>-anchor</STRONG> => <EM>anchor</EM></A></STRONG><BR>
- <DD>
- <EM>Anchor</EM> must be a valid anchor position such as <STRONG>n</STRONG>
- or <STRONG>sw</STRONG>; it specifies where to position each slave in its
- parcel.
- Defaults to <STRONG>center</STRONG>.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dbefore_%3D%3E_%24other"><STRONG>-before</STRONG> => <EM>$other</EM></A></STRONG><BR>
- <DD>
- <EM>$other</EM> must be another window.
- Use its master as the master for the slave, and insert
- the slave just before <EM>$other</EM> in the packing order.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dexpand_%3D%3E_boolean"><STRONG>-expand</STRONG> => <EM>boolean</EM></A></STRONG><BR>
- <DD>
- Specifies whether the slave should be expanded to consume
- extra space in their master.
- <EM>Boolean</EM> may have any proper boolean value, such as <STRONG>1</STRONG>
- or <STRONG>no</STRONG>.
- Defaults to 0.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dfill_%3D%3E_style"><STRONG>-fill</STRONG> => <EM>style</EM></A></STRONG><BR>
- <DD>
- If a slave's parcel is larger than its requested dimensions, this
- option may be used to stretch the slave.
- <EM>Style</EM> must have one of the following values:
- <DL>
- <DT><STRONG><A NAME="item_none"><STRONG>none</STRONG></A></STRONG><BR>
- <DD>
- Give the slave its requested dimensions plus any internal padding
- requested with <STRONG>-ipadx</STRONG> or <STRONG>-ipady</STRONG>. This is the default.
- <P></P>
- <DT><STRONG><A NAME="item_x"><STRONG>x</STRONG></A></STRONG><BR>
- <DD>
- Stretch the slave horizontally to fill the entire width of its
- parcel (except leave external padding as specified by <STRONG>-padx</STRONG>).
- <P></P>
- <DT><STRONG><A NAME="item_y"><STRONG>y</STRONG></A></STRONG><BR>
- <DD>
- Stretch the slave vertically to fill the entire height of its
- parcel (except leave external padding as specified by <STRONG>-pady</STRONG>).
- <P></P>
- <DT><STRONG><A NAME="item_both"><STRONG>both</STRONG></A></STRONG><BR>
- <DD>
- Stretch the slave both horizontally and vertically.
- <P></P></DL>
- <DT><STRONG><A NAME="item_%2Din_%3D%3E_%24master"><STRONG>-in</STRONG> => <EM>$master</EM></A></STRONG><BR>
- <DD>
- Insert the <CODE>slave(s)</CODE> at the end of the packing order for the master
- window given by <EM>$master</EM>.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dipadx_%3D%3E_amount"><STRONG>-ipadx</STRONG> => <EM>amount</EM></A></STRONG><BR>
- <DD>
- <EM>Amount</EM> specifies how much horizontal internal padding to
- leave on each side of the slave(s).
- <EM>Amount</EM> must be a valid screen distance, such as <STRONG>2</STRONG> or <STRONG>.5c</STRONG>.
- It defaults to 0.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dipady_%3D%3E_amount"><STRONG>-ipady</STRONG> => <EM>amount</EM></A></STRONG><BR>
- <DD>
- <EM>Amount</EM> specifies how much vertical internal padding to
- leave on each side of the slave(s).
- <EM>Amount</EM> defaults to 0.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dpadx_%3D%3E_amount"><STRONG>-padx</STRONG> => <EM>amount</EM></A></STRONG><BR>
- <DD>
- <EM>Amount</EM> specifies how much horizontal external padding to
- leave on each side of the slave(s).
- <EM>Amount</EM> defaults to 0.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dpady_%3D%3E_amount"><STRONG>-pady</STRONG> => <EM>amount</EM></A></STRONG><BR>
- <DD>
- <EM>Amount</EM> specifies how much vertical external padding to
- leave on each side of the slave(s).
- <EM>Amount</EM> defaults to 0.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dside_%3D%3E_side"><STRONG>-side</STRONG> => <EM>side</EM></A></STRONG><BR>
- <DD>
- Specifies which side of the master the <CODE>slave(s)</CODE> will be packed against.
- Must be <STRONG>left</STRONG>, <STRONG>right</STRONG>, <STRONG>top</STRONG>, or <STRONG>bottom</STRONG>.
- Defaults to <STRONG>top</STRONG>.
- <P></P></DL>
- </DL>
- <P>If no <STRONG>-in</STRONG>, <STRONG>-after</STRONG> or <STRONG>-before</STRONG> option is specified
- then slave will be inserted at the end of the packing list
- for its parent unless it is already managed by the packer (in which
- case it will be left where it is).
- If one of these options is specified then slave will be
- inserted at the specified point.
- If the slave are already managed by the geometry manager
- then any unspecified options for them retain their previous values rather
- than receiving default values.</P>
- <DL>
- <DT><STRONG><A NAME="item_packForget"><EM>$slave</EM>-><STRONG>packForget</STRONG></A></STRONG><BR>
- <DD>
- Removes <EM>slave</EM> from the packing order for its
- master and unmaps its window.
- The slave will no longer be managed by the packer.
- <P></P>
- <DT><STRONG><A NAME="item_packInfo"><EM>$slave</EM>-><STRONG>packInfo</STRONG></A></STRONG><BR>
- <DD>
- Returns a list whose elements are the current configuration state of
- the slave given by <EM>$slave</EM> in the same option-value form that
- might be specified to <STRONG>packConfigure</STRONG>.
- The first two elements of the list are ``<STRONG>-in</STRONG>=><EM>$master</EM>'' where
- <EM>$master</EM> is the slave's master.
- <P></P>
- <DT><STRONG><A NAME="item_packPropagate"><EM>$master</EM>-><STRONG>packPropagate</STRONG>?(<EM>boolean</EM>)?</A></STRONG><BR>
- <DD>
- If <EM>boolean</EM> has a true boolean value such as <STRONG>1</STRONG> or <STRONG>on</STRONG>
- then propagation is enabled for <EM>$master</EM>,
- (see <A HREF="#geometry propagation">GEOMETRY PROPAGATION</A> below).
- If <EM>boolean</EM> has a false boolean value then propagation is
- disabled for <EM>$master</EM>.
- In either of these cases an empty string is returned.
- If <EM>boolean</EM> is omitted then the method returns <STRONG>0</STRONG> or
- <STRONG>1</STRONG> to indicate whether propagation is currently enabled
- for <EM>$master</EM>.
- Propagation is enabled by default.
- <P></P>
- <DT><STRONG><A NAME="item_packSlaves"><EM>$master</EM>-><STRONG>packSlaves</STRONG></A></STRONG><BR>
- <DD>
- Returns a list of all of the slaves in the packing order for <EM>$master</EM>.
- The order of the slaves in the list is the same as their order in
- the packing order.
- If <EM>$master</EM> has no slaves then an empty list/string is returned in
- array/scalar context, respectively
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="the packer algorithm">THE PACKER ALGORITHM</A></H1>
- <P>For each master the packer maintains an ordered list of slaves
- called the <EM>packing list</EM>.
- The <STRONG>-in</STRONG>, <STRONG>-after</STRONG>, and <STRONG>-before</STRONG> configuration
- options are used to specify the master for each slave and the slave's
- position in the packing list.
- If none of these options is given for a slave then the slave
- is added to the end of the packing list for its parent.</P>
- <P>The packer arranges the slaves for a master by scanning the
- packing list in order.
- At the time it processes each slave, a rectangular area within
- the master is still unallocated.
- This area is called the <EM>cavity</EM>; for the first slave it
- is the entire area of the master.</P>
- <P>For each slave the packer carries out the following steps:</P>
- <DL>
- <DT><STRONG><A NAME="item_%5B1%5D">[1]</A></STRONG><BR>
- <DD>
- The packer allocates a rectangular <EM>parcel</EM> for the slave
- along the side of the cavity given by the slave's <STRONG>-side</STRONG> option.
- If the side is top or bottom then the width of the parcel is
- the width of the cavity and its height is the requested height
- of the slave plus the <STRONG>-ipady</STRONG> and <STRONG>-pady</STRONG> options.
- For the left or right side the height of the parcel is
- the height of the cavity and the width is the requested width
- of the slave plus the <STRONG>-ipadx</STRONG> and <STRONG>-padx</STRONG> options.
- The parcel may be enlarged further because of the <STRONG>-expand</STRONG>
- option (see <A HREF="#expansion">EXPANSION</A> below)
- <P></P>
- <DT><STRONG><A NAME="item_%5B2%5D">[2]</A></STRONG><BR>
- <DD>
- The packer chooses the dimensions of the slave.
- The width will normally be the slave's requested width plus
- twice its <STRONG>-ipadx</STRONG> option and the height will normally be
- the slave's requested height plus twice its <STRONG>-ipady</STRONG>
- option.
- However, if the <STRONG>-fill</STRONG> option is <STRONG>x</STRONG> or <STRONG>both</STRONG>
- then the width of the slave is expanded to fill the width of the parcel,
- minus twice the <STRONG>-padx</STRONG> option.
- If the <STRONG>-fill</STRONG> option is <STRONG>y</STRONG> or <STRONG>both</STRONG>
- then the height of the slave is expanded to fill the width of the parcel,
- minus twice the <STRONG>-pady</STRONG> option.
- <P></P>
- <DT><STRONG><A NAME="item_%5B3%5D">[3]</A></STRONG><BR>
- <DD>
- The packer positions the slave over its parcel.
- If the slave is smaller than the parcel then the <STRONG>-anchor</STRONG>
- option determines where in the parcel the slave will be placed.
- If <STRONG>-padx</STRONG> or <STRONG>-pady</STRONG> is non-zero, then the given
- amount of external padding will always be left between the
- slave and the edges of the parcel.
- <P>Once a given slave has been packed, the area of its parcel
- is subtracted from the cavity, leaving a smaller rectangular
- cavity for the next slave.
- If a slave doesn't use all of its parcel, the unused space
- in the parcel will not be used by subsequent slaves.
- If the cavity should become too small to meet the needs of
- a slave then the slave will be given whatever space is
- left in the cavity.
- If the cavity shrinks to zero size, then all remaining slaves
- on the packing list will be unmapped from the screen until
- the master window becomes large enough to hold them again.</P>
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="expansion">EXPANSION</A></H1>
- <P>If a master window is so large that there will be extra space
- left over after all of its slaves have been packed, then the
- extra space is distributed uniformly among all of the slaves
- for which the <STRONG>-expand</STRONG> option is set.
- Extra horizontal space is distributed among the expandable
- slaves whose <STRONG>-side</STRONG> is <STRONG>left</STRONG> or <STRONG>right</STRONG>,
- and extra vertical space is distributed among the expandable
- slaves whose <STRONG>-side</STRONG> is <STRONG>top</STRONG> or <STRONG>bottom</STRONG>.</P>
- <P>
- <HR>
- <H1><A NAME="geometry propagation">GEOMETRY PROPAGATION</A></H1>
- <P>The packer normally computes how large a master must be to
- just exactly meet the needs of its slaves, and it sets the
- requested width and height of the master to these dimensions.
- This causes geometry information to propagate up through a
- window hierarchy to a top-level window so that the entire
- sub-tree sizes itself to fit the needs of the leaf windows.
- However, the <STRONG>packPropagate</STRONG> method may be used to
- turn off propagation for one or more masters.
- If propagation is disabled then the packer will not set
- the requested width and height of the packer.
- This may be useful if, for example, you wish for a master
- window to have a fixed size that you specify.</P>
- <P>
- <HR>
- <H1><A NAME="restrictions on master windows">RESTRICTIONS ON MASTER WINDOWS</A></H1>
- <P>The master for each slave must either be the slave's parent
- (the default) or a descendant of the slave's parent.
- This restriction is necessary to guarantee that the
- slave can be placed over any part of its master that is
- visible without danger of the slave being clipped by its parent.</P>
- <P>
- <HR>
- <H1><A NAME="packing order">PACKING ORDER</A></H1>
- <P>If the master for a slave is not its parent then you must make sure
- that the slave is higher in the stacking order than the master.
- Otherwise the master will obscure the slave and it will appear as
- if the slave hasn't been packed correctly.
- The easiest way to make sure the slave is higher than the master is
- to create the master window first: the most recently created window
- will be highest in the stacking order.
- Or, you can use the <STRONG>raise</STRONG> and <STRONG>lower</STRONG> methods to change
- the stacking order of either the master or the slave.</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../../site/lib/Tk/form.html">Tk::form</A>
- <A HREF="../../../site/lib/Tk/grid.html">Tk::grid</A>
- <A HREF="../../../site/lib/Tk/place.html">Tk::place</A></P>
- <P>
- <HR>
- <H1><A NAME="keywords">KEYWORDS</A></H1>
- <P>geometry manager, location, packer, parcel, propagation, size</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::pack - Geometry manager that packs around edges of cavity</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-