Debian Codegraph @

pod/place.pod

raw
1 # Copyright (c) 1992 The Regents of the University of California.
2 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
3 # See the file "license.terms" for information on usage and redistribution
4 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5 #
6 #
7
8 =head1 NAME
9
10 Tk::place - Geometry manager for fixed or rubber-sheet placement
11
12 =for category Tk Geometry Management
13
14 =head1 SYNOPSIS
15
16 S< >I<$widget>->B<place>?(I<-option>=>I<value>?, I<-option>=>I<value>, ...)?
17
18 S< >I<$widget>->B<placeForget>
19
20 S< >I<$widget>->B<placeInfo>
21
22 S< >I<$master>->B<placeSlaves>
23
24 =head1 DESCRIPTION
25
26 The placer is a geometry manager for Tk.
27 It provides simple fixed placement of windows, where you specify
28 the exact size and location of one window, called the I<slave>,
29 within another window, called the I<master>.
30 The placer also provides rubber-sheet placement, where you specify the
31 size and location of the slave in terms of the dimensions of
32 the master, so that the slave changes size and location
33 in response to changes in the size of the master.
34 Lastly, the placer allows you to mix these styles of placement so
35 that, for example, the slave has a fixed width and height but is
36 centered inside the master.
37
38 =over 4
39
40 =item I<$slave>->B<place>?(I<-option>=>I<value>?, I<-option>=>I<value>, ...?)?
41
42 The B<place> method arranges for the placer
43 to manage the geometry of I<$slave>.
44 The remaining arguments consist of one or more I<-option>=>I<value>
45 pairs that specify the way in which I<$slave>'s
46 geometry is managed. I<-option> may have any of the values accepted
47 by the L<< placeConfigure|/$slave->placeConfigure >> method.
48
49 The B<place> method returns I<$slave>.
50
51 =item I<$slave>->B<placeConfigure>?(I<-option>=>I<value>?, I<-option>=>I<value>, ...?)?
52
53 Query or modify the geometry options of the I<$slave>. If no option is
54 specified, this method returns a list describing the available
55 options (see Tk_ConfigureInfo for information on the format of this
56 list). If option is specified with no value, then the command returns
57 a list describing the one named option (this list will be identical to
58 the corresponding sublist of the value returned if no option is
59 specified). If one or more option-value pairs are specified, then the
60 method modifies the given option(s) to have the given value(s); in
61 this case the command returns C<undef>.
62
63 The following I<-option>=>I<value> pairs are supported:
64
65 =over 8
66
67 =item B<-anchor> => I<where>
68
69 I<Where> specifies which point of I<$slave> is to be positioned
70 at the (x,y) location selected by the B<-x>, B<-y>,
71 B<-relx>, and B<-rely> options.
72 The anchor point is in terms of the outer area of I<$slave>
73 including its border, if any.
74 Thus if I<where> is B<se> then the lower-right corner of
75 I<$slave>'s border will appear at the given (x,y) location
76 in the master.
77 The anchor position defaults to B<nw>.
78
79 =item B<-bordermode> => I<mode>
80
81 I<Mode> determines the degree to which borders within the
82 master are used in determining the placement of the slave.
83 The default and most common value is B<inside>.
84 In this case the placer considers the area of the master to
85 be the innermost area of the master, inside any border:
86 an option of B<-x>=>B<0> corresponds to an x-coordinate just
87 inside the border and an option of B<-relwidth>=>1.0
88 means I<$slave> will fill the area inside the master's
89 border.
90 If I<mode> is B<outside> then the placer considers
91 the area of the master to include its border;
92 this mode is typically used when placing I<$slave>
93 outside its master, as with the options
94 B<-x>=>B<0>, B<-y>=>B<0>, B<-anchor>=>B<ne>.
95 Lastly, I<mode> may be specified as B<ignore>, in which
96 case borders are ignored: the area of the master is considered
97 to be its official X area, which includes any internal border but
98 no external border. A bordermode of B<ignore> is probably
99 not very useful.
100
101 =item B<-height> => I<size>
102
103 I<Size> specifies the height for I<$slave> in screen units
104 (i.e. any of the forms accepted by B<Tk_GetPixels>).
105 The height will be the outer dimension of I<$slave> including its
106 border, if any.
107 If I<size> is an empty string, or if no B<-height> or
108 B<-relheight> option is specified, then the height requested
109 internally by the window will be used.
110
111 =item B<-in> => I<$master>
112
113 I<$master> is the reference to the window relative
114 to which I<$slave> is to be placed.
115 I<$master> must either be I<$slave>'s parent or a descendant
116 of I<$slave>'s parent.
117 In addition, I<$master> and I<$slave> must both be descendants
118 of the same top-level window.
119 These restrictions are necessary to guarantee
120 that I<$slave> is visible whenever I<$master> is visible.
121 If this option isn't specified then the master defaults to
122 I<$slave>'s parent.
123
124 =item B<-relheight> => I<size>
125
126 I<Size> specifies the height for I<$slave>.
127 In this case the height is specified as a floating-point number
128 relative to the height of the master: 0.5 means I<$slave> will
129 be half as high as the master, 1.0 means I<$slave> will have
130 the same height as the master, and so on.
131 If both B<-height> and B<-relheight> are specified for a slave,
132 their values are summed. For example, B<-relheight>=>1.0, B<-height>=>-2
133 makes the slave 2 pixels shorter than the master.
134
135 =item B<-relwidth> => I<size>
136
137 I<Size> specifies the width for I<$slave>.
138 In this case the width is specified as a floating-point number
139 relative to the width of the master: 0.5 means I<$slave> will
140 be half as wide as the master, 1.0 means I<$slave> will have
141 the same width as the master, and so on.
142 If both B<-width> and B<-relwidth> are specified for a slave,
143 their values are summed. For example, B<-relwidth>=>1.0, B<-width>=>5
144 makes the slave 5 pixels wider than the master.
145
146 =item B<-relx> => I<location>
147
148 I<Location> specifies the x-coordinate within the master window
149 of the anchor point for I<$slave> widget.
150 In this case the location is specified in a relative fashion
151 as a floating-point number: 0.0 corresponds to the left edge
152 of the master and 1.0 corresponds to the right edge of the master.
153 I<Location> need not be in the range 0.0-1.0.
154 If both B<-x> and B<-relx> are specified for a slave
155 then their values are summed. For example, "B<-relx>=>0.5, B<-x>=-2"
156 positions the left edge of the slave 2 pixels to the left of the
157 center of its master.
158
159 =item B<-rely> => I<location>
160
161 I<Location> specifies the y-coordinate within the master window
162 of the anchor point for I<$slave> widget.
163 In this case the value is specified in a relative fashion
164 as a floating-point number: 0.0 corresponds to the top edge
165 of the master and 1.0 corresponds to the bottom edge of the master.
166 I<Location> need not be in the range 0.0-1.0.
167 If both B<-y> and B<-rely> are specified for a slave
168 then their values are summed. For example, B<-rely>=>0.5, B<-x>=>3
169 positions the top edge of the slave 3 pixels below the
170 center of its master.
171
172 =item B<-width> => I<size>
173
174 I<Size> specifies the width for I<$slave> in screen units
175 (i.e. any of the forms accepted by B<Tk_GetPixels>).
176 The width will be the outer width of I<$slave> including its
177 border, if any.
178 If I<size> is an empty string, or if no B<-width>
179 or B<-relwidth> option is specified, then the width requested
180 internally by the window will be used.
181
182 =item B<-x> => I<location>
183
184 I<Location> specifies the x-coordinate within the master window
185 of the anchor point for I<$slave> widget.
186 The location is specified in screen units (i.e. any of the forms
187 accepted by B<Tk_GetPixels>) and need not lie within the bounds
188 of the master window.
189
190 =item B<-y> => I<location>
191
192 I<Location> specifies the y-coordinate within the master window
193 of the anchor point for I<$slave> widget.
194 The location is specified in screen units (i.e. any of the forms
195 accepted by B<Tk_GetPixels>) and need not lie within the bounds
196 of the master window.
197
198 =back
199
200 If the same value is specified separately with
201 two different options, such as B<-x> and B<-relx>, then
202 the most recent option is used and the older one is ignored.
203
204 =item I<$slave>->B<placeForget>
205
206 The B<placeForget> method causes the placer to stop managing
207 the geometry of I<$slave>. As a side effect of this method call
208 I<$slave> will be unmapped so that it doesn't appear on the
209 screen.
210 If I<$slave> isn't currently managed by the placer then the
211 method call has no effect.
212 B<placeForget> returns an empty string as result.
213
214 =item I<$slave>->B<placeInfo>
215
216 The B<placeInfo> method returns a list giving the current
217 configuration of I<$slave>.
218 The list consists of I<-option>=>I<value> pairs in exactly the
219 same form as might be specified to the B<place>
220 method.
221
222 =item I<$slave>->B<placeSlaves>
223
224 The B<placeSlaves> method returns a list of all the slave
225 windows for which I<$master> is the master.
226 If there are no slaves for I<$master> then an empty list is
227 returned.
228
229 =back
230
231 If the configuration of a window has been retrieved with
232 B<placeInfo>, that configuration can be restored later by
233 first using B<placeForget> to erase any existing information
234 for the window and then invoking B<place> with
235 the saved information.
236
237 =head1 FINE POINTS
238
239 It is not necessary for the master window to be the parent
240 of the slave window.
241 This feature is useful in at least two situations.
242 First, for complex window layouts it means you can create a
243 hierarchy of subwindows whose only purpose
244 is to assist in the layout of the parent.
245 The ``I<real children>'' of the parent (i.e. the windows that
246 are significant for the application's user interface) can be
247 children of the parent yet be placed inside the windows
248 of the geometry-management hierarchy.
249 This means that the path names of the ``I<real children>''
250 don't reflect the geometry-management hierarchy and users
251 can specify options for the real children
252 without being aware of the structure of the geometry-management
253 hierarchy.
254
255 A second reason for having a master different than the slave's
256 parent is to tie two siblings together.
257 For example, the placer can be used to force a window always to
258 be positioned centered just below one of its
259 siblings by specifying the configuration
260
261 S< >B<-in>=>I<$sibling>, B<-relx>=>0.5, B<-rely>=>1.0,
262 B<-anchor>=>'n', B<-bordermode>=>'outside'
263
264 Whenever the I<$sibling> widget is repositioned in the future, the slave
265 will be repositioned as well.
266
267 Unlike many other geometry managers (such as the packer)
268 the placer does not make any attempt to manipulate the geometry of
269 the master windows or the parents of slave windows (i.e. it doesn't
270 set their requested sizes).
271 To control the sizes of these windows, make them windows like
272 frames and canvases that provide configuration options for this purpose.
273
274 =head1 SEE ALSO
275
276 L<Tk::form>, L<Tk::grid>, L<Tk::pack>
277
278 =head1 KEYWORDS
279
280 geometry manager, height, location, master, place, rubber sheet, slave, width
281
282 =cut
283