Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / grid.pod
CommitLineData
86530b38
AT
1# Copyright (c) 1996 Sun Microsystems, Inc.
2# See the file "license.terms" for information on usage and redistribution
3# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
4#
5#
6
7=head1 NAME
8
9Tk::grid - Geometry manager that arranges widgets in a grid
10
11=for category Tk Geometry Management
12
13=head1 SYNOPSIS
14
15S< >I<$widget>-E<gt>B<grid>?(?I<widget> ...,? ?I<arg> ?...>?)?
16
17S< >I<$widget>-E<gt>B<grid>I<Option>?(I<arg> ?,I<arg> ...?)?
18
19=head1 DESCRIPTION
20
21The B<grid> method is used to communicate with the grid
22geometry manager that arranges widgets in rows and columns inside
23of another window, called the geometry master (or master window).
24The B<grid> method can have any of several forms, depending
25on the I<option> argument:
26
27=over 4
28
29=item I<$slave>-E<gt>B<grid>(?I<$slave, ...>??, I<options>?)
30
31The arguments consist of the optional references to more slave windows
32followed by pairs of arguments that specify how to manage the slaves.
33The characters B<->, B<x> and B<^>,
34can be specified instead of a window reference to alter the default
35location of a I<$slave>, as described in L<"RELATIVE PLACEMENT">, below.
36
37If any of the slaves are already managed by the geometry manager
38then any unspecified options for them retain their previous values rather
39than receiving default values.
40
41The following options are supported:
42
43=over 8
44
45=item B<-column> => I<n>
46
47Insert the I<$slave> so that it occupies the I<n>th column in the grid.
48Column numbers start with 0. If this option is not supplied, then the
49I<$slave> is arranged just to the right of previous slave specified on this
50call to B<grid>, or column "0" if it is the first slave. For each
51B<x> that immediately precedes the I<$slave>, the column position
52is incremented by one. Thus the B<x> represents a blank column
53for this row in the grid.
54
55=item B<-columnspan> => I<n>
56
57Insert the slave so that it occupies I<n> columns in the grid.
58The default is one column, unless the window name is followed by a
59B<->, in which case the columnspan is incremented once for each immediately
60following B<->.
61
62=item B<-in> => I<$other>
63
64Insert the slave(s) in the master
65window given by I<$other>. The default is the first slave's
66parent window.
67
68=item B<-ipadx> => I<amount>
69
70The I<amount> specifies how much horizontal internal padding to
71leave on each side of the slave(s). This is space is added
72inside the slave(s) border.
73The I<amount> must be a valid screen distance, such as B<2> or B<'.5c'>.
74It defaults to 0.
75
76=item B<-ipady> => I<amount>
77
78The I<amount> specifies how much vertical internal padding to
79leave on on the top and bottom of the slave(s).
80This space is added inside the slave(s) border.
81The I<amount> defaults to 0.
82
83=item B<-padx> => I<amount>
84
85The I<amount> specifies how much horizontal external padding to
86leave on each side of the slave(s), in screen units.
87The I<amount> defaults to 0.
88This space is added outside the slave(s) border.
89
90=item B<-pady> => I<amount>
91
92The I<amount> specifies how much vertical external padding to
93leave on the top and bottom of the slave(s), in screen units.
94The I<amount> defaults to 0.
95This space is added outside the slave(s) border.
96
97=item B<-row> => I<n>
98
99Insert the slave so that it occupies the I<n>th row in the grid.
100Row numbers start with 0. If this option is not supplied, then the
101slave is arranged on the same row as the previous slave specified on this
102call to B<grid>, or the first unoccupied row if this is the first slave.
103
104=item B<-rowspan> => I<n>
105
106Insert the slave so that it occupies I<n> rows in the grid.
107The default is one row. If the next B<grid> method contains
108B<^> characters instead of I<$slave>s that line up with the columns
109of this I<$slave>, then the B<rowspan> of this I<$slave> is
110extended by one.
111
112=item B<-sticky> => I<style>
113
114If a slave's cell is larger than its requested dimensions, this
115option may be used to position (or stretch) the slave within its cell.
116I<Style> is a string that contains zero or more of the characters
117B<n>, B<s>, B<e> or B<w>.
118The string can optionally contain spaces or
119commas, but they are ignored. Each letter refers to a side (north, south,
120east, or west) that the slave will "stick" to. If both B<n> and B<s> (or
121B<e> and B<w>) are specified, the slave will be stretched to fill the entire
122height (or width) of its cavity. The B<sticky> option subsumes the
123combination of B<-anchor> and B<-fill> that is used by L<pack|Tk::pack>.
124The default is B<''>, which causes the slave to be centered in its cavity,
125at its requested size.
126
127=back
128
129=item I<$master>-E<gt>B<gridBbox>(?I<column, row>,? ?I<column2, row2>?)
130
131With no arguments,
132the bounding box (in pixels) of the grid is returned.
133The return value consists of 4 integers. The first two are the pixel
134offset from the master window (x then y) of the top-left corner of the
135grid, and the second two integers are the width and height of the grid,
136also in pixels. If a single I<column> and I<row> is specified on
137the command line, then the bounding box for that cell is returned, where the
138top left cell is numbered from zero. If both I<column> and I<row>
139arguments are specified, then the bounding box spanning the rows and columns
140indicated is returned.
141
142=item I<$master>-E<gt>B<gridColumnconfigure>(I<index>?, I<-option>=>I<value, ...>?)
143
144Query or set the column properties of the I<index> column of the
145geometry master, I<$master>.
146The valid options are B<-minsize>, B<-weight> and B<-pad>.
147If one or more options are provided, then I<index> may be given as
148a list of column indices to which the configuration options will operate on.
149The B<-minsize> option sets the minimum size, in screen units,
150that will be permitted for this column.
151The B<-weight> option (an integer value)
152sets the relative weight for apportioning
153any extra spaces among
154columns.
155A weight of zero (0) indicates the column will not deviate from its requested
156size. A column whose weight is two will grow at twice the rate as a column
157of weight one when extra space is allocated to the layout.
158The B<-pad> option specifies the number of screen units that will be
159added to the largest window contained completely in that column when the
160grid geometry manager requests a size from the containing window.
161If only an option is specified, with no value,
162the current value of that option is returned.
163If only the master window and index is specified, all the current settings
164are returned in an list of "-option value" pairs.
165
166=item I<$slave>-E<gt>B<gridConfigure>(?I<$slave, ...>?, I<options>?)
167
168The same as B<grid> method.
169
170=item I<$slave>-E<gt>B<gridForget>?(I<$slave, ...>)?
171
172Removes each of the I<$slave>s from grid for its
173master and unmaps their windows.
174The slaves will no longer be managed by the grid geometry manager.
175The configuration options for that window are forgotten, so that if the
176slave is managed once more by the grid geometry manager, the initial
177default settings are used.
178
179=item I<$slave>-E<gt>B<gridInfo>
180
181Returns a list whose elements are the current configuration state of
182the slave given by I<$slave> in the same option-value form that
183might be specified to B<gridConfigure>.
184The first two elements of the list are ``B<-in>=>I<$master>'' where
185I<$master> is the slave's master.
186
187=item I<$master>-E<gt>B<gridLocation>(I<x, y>)
188
189Given I<x> and I<y> values in screen units relative to the master window,
190the column and row number at that I<x> and I<y> location is returned.
191For locations that are above or to the left of the grid, B<-1> is returned.
192
193=item I<$master>-E<gt>B<gridPropagate>?(I<boolean>)?
194
195If I<boolean> has a true boolean value such as B<1> or B<on>
196then propagation is enabled for I<$master>, which must be a window
197name (see L<"GEOMETRY PROPAGATION"> below).
198If I<boolean> has a false boolean value then propagation is
199disabled for I<$master>.
200In either of these cases an empty string is returned.
201If I<boolean> is omitted then the method returns B<0> or
202B<1> to indicate whether propagation is currently enabled
203for I<$master>.
204Propagation is enabled by default.
205
206=item I<$master>-E<gt>B<gridRowconfigure>(I<index>?, I<-option>=>I<value, ...>?)
207
208Query or set the row properties of the I<index> row of the
209geometry master, I<$master>.
210The valid options are B<-minsize>, B<-weight> and B<-pad>.
211If one or more options are provided, then I<index> may be given as
212a list of row indeces to which the configuration options will operate on.
213The B<-minsize> option sets the minimum size, in screen units,
214that will be permitted for this row.
215The B<-weight> option (an integer value)
216sets the relative weight for apportioning
217any extra spaces among
218rows.
219A weight of zero (0) indicates the row will not deviate from its requested
220size. A row whose weight is two will grow at twice the rate as a row
221of weight one when extra space is allocated to the layout.
222The B<-pad> option specifies the number of screen units that will be
223added to the largest window contained completely in that row when the
224grid geometry manager requests a size from the containing window.
225If only an option is specified, with no value,
226the current value of that option is returned.
227If only the master window and index is specified, all the current settings
228are returned in an list of "option-value" pairs.
229
230=item I<$slave>-E<gt>B<gridRemove>?(I<$slave, ...>)?
231
232Removes each of the I<$slave>s from grid for its
233master and unmaps their windows.
234The slaves will no longer be managed by the grid geometry manager.
235However, the configuration options for that window are remembered,
236so that if the
237slave is managed once more by the grid geometry manager, the previous
238values are retained.
239
240=item I<$master>-E<gt>B<gridSize>
241
242Returns the size of the grid (in columns then rows) for I<$master>.
243The size is determined either by the I<$slave> occupying the largest
244row or column, or the largest column or row with a B<-minsize>,
245B<-weight>, or B<-pad> that is non-zero.
246
247=item I<$master>-E<gt>B<gridSlaves>?(I<-option>=>I<value>)?
248
249If no options are supplied, a list of all of the slaves in I<$master>
250are returned, most recently manages first.
251I<-option> can be either B<-row> or B<-column> which
252causes only the slaves in the row (or column) specified by I<value>
253to be returned.
254
255=back
256
257=head1 RELATIVE PLACEMENT
258
259The B<grid> method contains a limited set of capabilities that
260permit layouts to be created without specifying the row and column
261information for each slave. This permits slaves to be rearranged,
262added, or removed without the need to explicitly specify row and
263column information.
264When no column or row information is specified for a I<$slave>,
265default values are chosen for
266B<-column>, B<-row>, B<-columnspan> and B<-rowspan>
267at the time the I<$slave> is managed. The values are chosen
268based upon the current layout of the grid, the position of the I<$slave>
269relative to other I<$slave>s in the same grid method, and the presence
270of the characters B<->, B<^>, and B<^> in B<grid>
271method where I<$slave> names are normally expected.
272
273=over 4
274
275=item B<->
276
277This increases the columnspan of the I<$slave> to the left. Several
278B<->'s in a row will successively increase the columnspan. A B<->
279may not follow a B<^> or a B<x>.
280
281=item B<x>
282
283This leaves an empty column between the I<$slave> on the left and
284the I<$slave> on the right.
285
286=item B<^>
287
288This extends the B<-rowspan> of the I<$slave> above the B<^>'s
289in the grid. The number of B<^>'s in a row must match the number of
290columns spanned by the I<$slave> above it.
291
292=back
293
294=head1 THE GRID ALGORITHM
295
296The grid geometry manager lays out its slaves in three steps.
297In the first step, the minimum size needed to fit all of the slaves
298is computed, then (if propagation is turned on), a request is made
299of the master window to become that size.
300In the second step, the requested size is compared against the actual size
301of the master. If the sizes are different, then space is added to or taken
302away from the layout as needed.
303For the final step, each slave is positioned in its row(s) and column(s)
304based on the setting of its I<sticky> flag.
305
306To compute the minimum size of a layout, the grid geometry manager
307first looks at all slaves whose columnspan and rowspan values are one,
308and computes the nominal size of each row or column to be either the
309I<minsize> for that row or column, or the sum of the I<pad>ding
310plus the size of the largest slave, whichever is greater. Then the
311slaves whose rowspans or columnspans are greater than one are
312examined. If a group of rows or columns need to be increased in size
313in order to accommodate these slaves, then extra space is added to each
314row or column in the group according to its I<weight>. For each
315group whose weights are all zero, the additional space is apportioned
316equally.
317
318For masters whose size is larger than the requested layout, the additional
319space is apportioned according to the row and column weights. If all of
320the weights are zero, the layout is centered within its master.
321For masters whose size is smaller than the requested layout, space is taken
322away from columns and rows according to their weights. However, once a
323column or row shrinks to its minsize, its weight is taken to be zero.
324If more space needs to be removed from a layout than would be permitted, as
325when all the rows or columns are at there minimum sizes, the layout is
326clipped on the bottom and right.
327
328=head1 GEOMETRY PROPAGATION
329
330The grid geometry manager normally computes how large a master must be to
331just exactly meet the needs of its slaves, and it sets the
332requested width and height of the master to these dimensions.
333This causes geometry information to propagate up through a
334window hierarchy to a top-level window so that the entire
335sub-tree sizes itself to fit the needs of the leaf windows.
336However, the B<gridPropagate> method may be used to
337turn off propagation for one or more masters.
338If propagation is disabled then grid will not set
339the requested width and height of the master window.
340This may be useful if, for example, you wish for a master
341window to have a fixed size that you specify.
342
343=head1 RESTRICTIONS ON MASTER WINDOWS
344
345The master for each slave must either be the slave's parent
346(the default) or a descendant of the slave's parent.
347This restriction is necessary to guarantee that the
348slave can be placed over any part of its master that is
349visible without danger of the slave being clipped by its parent.
350In addition, all slaves in one call to B<grid> must have the same master.
351
352=head1 STACKING ORDER
353
354If the master for a slave is not its parent then you must make sure
355that the slave is higher in the stacking order than the master.
356Otherwise the master will obscure the slave and it will appear as
357if the slave hasn't been managed correctly.
358The easiest way to make sure the slave is higher than the master is
359to create the master window first: the most recently created window
360will be highest in the stacking order.
361
362=head1 CREDITS
363
364The B<grid> method is based on ideas taken from the I<GridBag>
365geometry manager written by Doug. Stein, and the B<blt_table> geometry
366manager, written by George Howlett.
367
368=head1 SEE ALSO
369
370L<Tk::form|Tk::form>
371L<Tk::pack|Tk::pack>
372L<Tk::place|Tk::place>
373
374=head1 KEYWORDS
375
376geometry manager, location, grid, cell, propagation, size, pack,
377master, slave
378
379=cut
380