pack.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:11k
- '"
- '" Copyright (c) 1990-1994 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: pack.n,v 1.3.6.1 2004/10/28 12:25:22 dkf Exp $
- '"
- .so man.macros
- .TH pack n 4.0 Tk "Tk Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- pack - Geometry manager that packs around edges of cavity
- .SH SYNOPSIS
- fBpack fIoption arg fR?fIarg ...fR?
- .BE
- .SH DESCRIPTION
- .PP
- The fBpackfR command 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.
- The fBpackfR command can have any of several forms, depending
- on the fIoptionfR argument:
- .TP
- fBpack fIslave fR?fIslave ...fR? ?fIoptionsfR?
- If the first argument to fBpackfR is a window name (any value
- starting with ``.''), then the command is processed in the same
- way as fBpack configurefR.
- .TP
- fBpack configure fIslave fR?fIslave ...fR? ?fIoptionsfR?
- The arguments consist of the names of one or more slave windows
- followed by pairs of arguments that specify how
- to manage the slaves.
- See ``THE PACKER ALGORITHM'' below for details on how the options
- are used by the packer.
- The following options are supported:
- .RS
- .TP
- fB-after fIotherfR
- fIOtherfR must the name of another window.
- Use its master as the master for the slaves, and insert
- the slaves just after fIotherfR in the packing order.
- .TP
- fB-anchor fIanchorfR
- fIAnchorfR must be a valid anchor position such as fBnfR
- or fBswfR; it specifies where to position each slave in its
- parcel.
- Defaults to fBcenterfR.
- .TP
- fB-before fIotherfR
- fIOtherfR must the name of another window.
- Use its master as the master for the slaves, and insert
- the slaves just before fIotherfR in the packing order.
- .TP
- fB-expand fIbooleanfR
- Specifies whether the slaves should be expanded to consume
- extra space in their master.
- fIBooleanfR may have any proper boolean value, such as fB1fR
- or fBnofR.
- Defaults to 0.
- .TP
- fB-fill fIstylefR
- If a slave's parcel is larger than its requested dimensions, this
- option may be used to stretch the slave.
- fIStylefR must have one of the following values:
- .RS
- .TP
- fBnonefR
- Give the slave its requested dimensions plus any internal padding
- requested with fB-ipadxfR or fB-ipadyfR. This is the default.
- .TP
- fBxfR
- Stretch the slave horizontally to fill the entire width of its
- parcel (except leave external padding as specified by fB-padxfR).
- .TP
- fByfR
- Stretch the slave vertically to fill the entire height of its
- parcel (except leave external padding as specified by fB-padyfR).
- .TP
- fBbothfR
- Stretch the slave both horizontally and vertically.
- .RE
- .TP
- fB-in fIotherfR
- Insert the slave(s) at the end of the packing order for the master
- window given by fIotherfR.
- .TP
- fB-ipadx fIamountfR
- fIAmountfR specifies how much horizontal internal padding to
- leave on each side of the slave(s).
- fIAmountfR must be a valid screen distance, such as fB2fR or fB.5cfR.
- It defaults to 0.
- .TP
- fB-ipady fIamountfR
- fIAmountfR specifies how much vertical internal padding to
- leave on each side of the slave(s).
- fIAmountfR defaults to 0.
- .TP
- fB-padx fIamountfR
- fIAmountfR specifies how much horizontal external padding to
- leave on each side of the slave(s). fIAmountfR may be a list
- of two values to specify padding for left and right separately.
- fIAmountfR defaults to 0.
- .TP
- fB-pady fIamountfR
- fIAmountfR specifies how much vertical external padding to
- leave on each side of the slave(s). fIAmountfR may be a list
- of two values to specify padding for top and bottom separately.
- fIAmountfR defaults to 0.
- .TP
- fB-side fIsidefR
- Specifies which side of the master the slave(s) will be packed against.
- Must be fBleftfR, fBrightfR, fBtopfR, or fBbottomfR.
- Defaults to fBtopfR.
- .LP
- If no fB-infR, fB-afterfR or fB-beforefR option is specified
- then each of the slaves 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 all the slaves will be
- inserted at the specified point.
- If any of the slaves are already managed by the geometry manager
- then any unspecified options for them retain their previous values rather
- than receiving default values.
- .RE
- .TP
- fBpack forget fIslave fR?fIslave ...fR?
- Removes each of the fIslavefRs from the packing order for its
- master and unmaps their windows.
- The slaves will no longer be managed by the packer.
- .TP
- fBpack info fIslavefR
- Returns a list whose elements are the current configuration state of
- the slave given by fIslavefR in the same option-value form that
- might be specified to fBpack configurefR.
- The first two elements of the list are ``fB-in fImasterfR'' where
- fImasterfR is the slave's master.
- .TP
- fBpack propagate fImasterfR ?fIbooleanfR?
- If fIbooleanfR has a true boolean value such as fB1fR or fBonfR
- then propagation is enabled for fImasterfR, which must be a window
- name (see ``GEOMETRY PROPAGATION'' below).
- If fIbooleanfR has a false boolean value then propagation is
- disabled for fImasterfR.
- In either of these cases an empty string is returned.
- If fIbooleanfR is omitted then the command returns fB0fR or
- fB1fR to indicate whether propagation is currently enabled
- for fImasterfR.
- Propagation is enabled by default.
- .TP
- fBpack slaves fImasterfR
- Returns a list of all of the slaves in the packing order for fImasterfR.
- The order of the slaves in the list is the same as their order in
- the packing order.
- If fImasterfR has no slaves then an empty string is returned.
- .SH "THE PACKER ALGORITHM"
- .PP
- For each master the packer maintains an ordered list of slaves
- called the fIpacking listfR.
- The fB-infR, fB-afterfR, and fB-beforefR 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.
- .PP
- 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 fIcavityfR; for the first slave it
- is the entire area of the master.
- .PP
- For each slave the packer carries out the following steps:
- .IP [1]
- The packer allocates a rectangular fIparcelfR for the slave
- along the side of the cavity given by the slave's fB-sidefR 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 fB-ipadyfR and fB-padyfR 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 fB-ipadxfR and fB-padxfR options.
- The parcel may be enlarged further because of the fB-expandfR
- option (see ``EXPANSION'' below)
- .IP [2]
- The packer chooses the dimensions of the slave.
- The width will normally be the slave's requested width plus
- twice its fB-ipadxfR option and the height will normally be
- the slave's requested height plus twice its fB-ipadyfR
- option.
- However, if the fB-fillfR option is fBxfR or fBbothfR
- then the width of the slave is expanded to fill the width of the parcel,
- minus twice the fB-padxfR option.
- If the fB-fillfR option is fByfR or fBbothfR
- then the height of the slave is expanded to fill the width of the parcel,
- minus twice the fB-padyfR option.
- .IP [3]
- The packer positions the slave over its parcel.
- If the slave is smaller than the parcel then the fB-anchorfR
- option determines where in the parcel the slave will be placed.
- If fB-padxfR or fB-padyfR is non-zero, then the given
- amount of external padding will always be left between the
- slave and the edges of the parcel.
- .PP
- 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.
- .SH "EXPANSION"
- .PP
- 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 fB-expandfR option is set.
- Extra horizontal space is distributed among the expandable
- slaves whose fB-sidefR is fBleftfR or fBrightfR,
- and extra vertical space is distributed among the expandable
- slaves whose fB-sidefR is fBtopfR or fBbottomfR.
- .SH "GEOMETRY PROPAGATION"
- .PP
- 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 fBpack propagatefR command 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.
- .SH "RESTRICTIONS ON MASTER WINDOWS"
- .PP
- 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.
- .SH "PACKING ORDER"
- .PP
- 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 fBraisefR and fBlowerfR commands to change
- the stacking order of either the master or the slave.
- .SH EXAMPLE
- .CS
- # Make the widgets
- label .t -text "This widget is at the top" -bg red
- label .b -text "This widget is at the bottom" -bg green
- label .l -text "Left\nHand\nSide"
- label .r -text "Right\nHand\nSide"
- text .mid
- .mid insert end "This layout is like Java's BorderLayout"
- # Lay them out
- fBpackfR .t -side top -fill x
- fBpackfR .b -side bottom -fill x
- fBpackfR .l -side left -fill y
- fBpackfR .r -side right -fill y
- fBpackfR .mid -expand 1 -fill both
- .CE
- .SH "SEE ALSO"
- grid(n), place(n)
- .SH KEYWORDS
- geometry manager, location, packer, parcel, propagation, size