stk/Help/place.n.html

224 lines
11 KiB
HTML
Raw Normal View History

1996-09-27 06:29:02 -04:00
<HTML><HEAD><TITLE>Tk Built-In Commands - place manual page</TITLE></HEAD>
1998-04-10 06:59:06 -04:00
<BR>
1996-09-27 06:29:02 -04:00
<BODY bgcolor = #c3c3ff>
<H2><IMG ALIGN=BOTTOM SRC="./Img/ManPageBlue.gif"> place</H2>
<I>Geometry manager for fixed or rubber-sheet placement</I><P><IMG ALIGN=TOP SRC="./Img/line-red.gif">
<H3><A NAME="M2">SYNOPSIS</A></H3>
(<B>place </B><I>window option value </I>?<I>option value ...</I>?)<BR>
(<B>place 'configure </B><I>window option value </I>?<I>option value ...</I>?)<BR>
(<B>place 'forget </B><I>window</I>)<BR>
(<B>place 'info </B><I>window</I>)<BR>
(<B>place 'slaves </B><I>window</I>)<BR>
<H3><A NAME="M3">DESCRIPTION</A></H3>
The placer is a geometry manager for Tk.
It provides simple fixed placement of windows, where you specify
the exact size and location of one window, called the <I>slave</I>,
within another window, called the <I>master</I>.
The placer also provides rubber-sheet placement, where you specify the
size and location of the slave in terms of the dimensions of
the master, so that the slave changes size and location
in response to changes in the size of the master.
Lastly, the placer allows you to mix these styles of placement so
that, for example, the slave has a fixed width and height but is
centered inside the master.
<P>
If the first argument to the <B>place</B> procedure is a window path
name or <B>configure</B> then the procedure arranges for the placer
to manage the geometry of a slave whose path name is <I>window</I>.
The remaining arguments consist of one or more <I>option:value</I>
pairs that specify the way in which <I>window</I>'s
geometry is managed.
If the placer is already managing <I>window</I>, then the
<I>option:value</I> pairs modify the configuration for <I>window</I>.
In this form the <B>place</B> procedure returns an empty string as result.
The following <I>option:value</I> pairs are supported:
<P>
<DL>
<DT><A NAME="M4"><B>:in </B><I>master</I></A><DD>
<I>Master</I> specifes the path name of the window relative
to which <I>window</I> is to be placed.
<I>Master</I> must either be <I>window</I>'s parent or a descendant
of <I>window</I>'s parent.
In addition, <I>master</I> and <I>window</I> must both be descendants
of the same top-level window.
These restrictions are necessary to guarantee
that <I>window</I> is visible whenever <I>master</I> is visible.
If this option isn't specified then the master defaults to
<I>window</I>'s parent.
<P>
<DT><A NAME="M5"><B>:x </B><I>location</I></A><DD>
<I>Location</I> specifies the x-coordinate within the master window
of the anchor point for <I>window</I>.
The location is specified in screen units (i.e. any of the forms
accepted by <B>Tk_GetPixels</B>) and need not lie within the bounds
of the master window.
<P>
<DT><A NAME="M6"><B>:relx </B><I>location</I></A><DD>
<I>Location</I> specifies the x-coordinate within the master window
of the anchor point for <I>window</I>.
In this case the location is specified in a relative fashion
as a floating-point number: 0.0 corresponds to the left edge
of the master and 1.0 corresponds to the right edge of the master.
<I>Location</I> need not be in the range 0.0-1.0.
If both <B>:x</B> and <B>:relx</B> are specified for a slave
then their values are summed. For example, <B>:relx 0.5 :x -2</B>
positions the left edge of the slave 2 pixels to the left of the
center of its master.
<P>
<DT><A NAME="M7"><B>:y </B><I>location</I></A><DD>
<I>Location</I> specifies the y-coordinate within the master window
of the anchor point for <I>window</I>.
The location is specified in screen units (i.e. any of the forms
accepted by <B>Tk_GetPixels</B>) and need not lie within the bounds
of the master window.
<P>
<DT><A NAME="M8"><B>:rely </B><I>location</I></A><DD>
<I>Location</I> specifies the y-coordinate within the master window
of the anchor point for <I>window</I>.
In this case the value is specified in a relative fashion
as a floating-point number: 0.0 corresponds to the top edge
of the master and 1.0 corresponds to the bottom edge of the master.
<I>Location</I> need not be in the range 0.0-1.0.
If both <B>:y</B> and <B>:rely</B> are specified for a slave
then their values are summed. For example, <B>:rely 0.5 :x 3</B>
positions the top edge of the slave 3 pixels below the
center of its master.
<P>
<DT><A NAME="M9"><B>:anchor </B><I>where</I></A><DD>
<I>Where</I> specifies which point of <I>window</I> is to be positioned
at the (x,y) location selected by the <B>:x</B>, <B>:y</B>,
<B>:relx</B>, and <B>:rely</B> options.
The anchor point is in terms of the outer area of <I>window</I>
including its border, if any.
Thus if <I>where</I> is <B>se</B> then the lower-right corner of
<I>window</I>'s border will appear at the given (x,y) location
in the master.
The anchor position defaults to <B>nw</B>.
<P>
<DT><A NAME="M10"><B>:width </B><I>size</I></A><DD>
<I>Size</I> specifies the width for <I>window</I> in screen units
(i.e. any of the forms accepted by <B>Tk_GetPixels</B>).
The width will be the outer width of <I>window</I> including its
border, if any.
If <I>size</I> is an empty string, or if no <B>:width</B>
or <B>:relwidth</B> option is specified, then the width requested
internally by the window will be used.
<P>
<DT><A NAME="M11"><B>:relwidth </B><I>size</I></A><DD>
<I>Size</I> specifies the width for <I>window</I>.
In this case the width is specified as a floating-point number
relative to the width of the master: 0.5 means <I>window</I> will
be half as wide as the master, 1.0 means <I>window</I> will have
the same width as the master, and so on.
If both <B>:width</B> and <B>:relwidth</B> are specified for a slave,
their values are summed. For example, <B>:relwidth 1.0 :width 5</B>
makes the slave 5 pixels wider than the master.
<P>
<DT><A NAME="M12"><B>:height </B><I>size</I></A><DD>
<I>Size</I> specifies the height for <I>window</I> in screen units
(i.e. any of the forms accepted by <B>Tk_GetPixels</B>).
The height will be the outer dimension of <I>window</I> including its
border, if any.
If <I>size</I> is an empty string, or if no <B>:height</B> or
<B>:relheight</B> option is specified, then the height requested
internally by the window will be used.
<P>
<DT><A NAME="M13"><B>:relheight </B><I>size</I></A><DD>
<I>Size</I> specifies the height for <I>window</I>.
In this case the height is specified as a floating-point number
relative to the height of the master: 0.5 means <I>window</I> will
be half as high as the master, 1.0 means <I>window</I> will have
the same height as the master, and so on.
If both <B>:height</B> and <B>:relheight</B> are specified for a slave,
their values are summed. For example, <B>:relheight 1.0 :height :2</B>
makes the slave 2 pixels shorter than the master.
<P>
<DT><A NAME="M14"><B>:bordermode </B><I>mode</I></A><DD>
<I>Mode</I> determines the degree to which borders within the
master are used in determining the placement of the slave.
The default and most common value is <B>inside</B>.
In this case the placer considers the area of the master to
be the innermost area of the master, inside any border:
an option of <B>:x 0</B> corresponds to an x-coordinate just
inside the border and an option of <B>:relwidth 1.0</B>
means <I>window</I> will fill the area inside the master's
border.
If <I>mode</I> is <B>outside</B> then the placer considers
the area of the master to include its border;
this mode is typically used when placing <I>window</I>
outside its master, as with the options <B>:x 0 :y 0 :anchor 'ne</B>.
Lastly, <I>mode</I> may be specified as <B>ignore</B>, in which
case borders are ignored: the area of the master is considered
to be its official X area, which includes any internal border but
no external border. A bordermode of <B>ignore</B> is probably
not very useful.
<P>
</DL>
<P>
If the same value is specified separately with
two different options, such as <B>:x</B> and <B>:relx</B>, then
the most recent option is used and the older one is ignored.
<P>
The <B>place slaves</B> procedure returns a list of all the slave
windows for which <I>window</I> is the master.
If there are no slaves for <I>window</I> then an empty string is
returned.
<P>
The <B>place forget</B> procedure causes the placer to stop managing
the geometry of <I>window</I>. As a side effect of this procedure
<I>window</I> will be unmapped so that it doesn't appear on the
screen.
If <I>window</I> isn't currently managed by the placer then the
procedure has no effect.
<B>Place forget</B> returns an empty string as result.
<P>
The <B>place info</B> procedure returns a list giving the current
configuration of <I>window</I>.
The list consists of <I>option-value</I> pairs in exactly the
same form as might be specified to the <B>place configure</B>
procedure.
If the configuration of a window has been retrieved with
<B>place info</B>, that configuration can be restored later by
first using <B>place forget</B> to erase any existing information
for the window and then invoking <B>place configure</B> with
the saved information.
<H3><A NAME="M15">FINE POINTS</A></H3>
It is not necessary for the master window to be the parent
of the slave window.
This feature is useful in at least two situations.
First, for complex window layouts it means you can create a
hierarchy of subwindows whose only purpose
is to assist in the layout of the parent.
The ``real children'' of the parent (i.e. the windows that
are significant for the application's user interface) can be
children of the parent yet be placed inside the windows
of the geometry-management hierarchy.
This means that the path names of the ``real children''
don't reflect the geometry-management hierarchy and users
can specify options for the real children
without being aware of the structure of the geometry-management
hierarchy.
<P>
A second reason for having a master different than the slave's
parent is to tie two siblings together.
For example, the placer can be used to force a window always to
be positioned centered just below one of its
siblings by specifying the configuration
<PRE><B>:in </B><I>sibling</I><B> :relx 0.5 :rely 1.0 :anchor 'n :bordermode 'outside</B></PRE>
Whenever the sibling is repositioned in the future, the slave
will be repositioned as well.
<P>
Unlike many other geometry managers (such as the packer)
the placer does not make any attempt to manipulate the geometry of
the master windows or the parents of slave windows (i.e. it doesn't
set their requested sizes).
To control the sizes of these windows, make them windows like
frames and canvases that provide configuration options for this purpose.
<H3><A NAME="M16">SEE ALSO</A></H3>
<B><A HREF="./grid.n.html">grid</A></B>, <B><A HREF="./pack.n.html">pack</A></B>
1998-04-10 06:59:06 -04:00
<P><IMG ALIGN=TOP SRC="./Img/line-red.gif"><P>
1996-09-27 06:29:02 -04:00
<A HREF=./STk-hlp.html><IMG ALIGN=BOTTOM SRC="./Img/RefBookBlue.gif"> Back to the <B>STk</B> main page</A>
</BODY></HTML>