.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "grid 3" .TH grid 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::grid \- Geometry manager that arranges widgets in a grid .SH SYNOPSIS .IX Header "SYNOPSIS" \ \ \ \ \fR\f(CI$widget\fR\fI\fR\->\fBgrid\fR?(?\fIwidget\fR ...,? ?\fIarg\fR ?...>?)? .PP \ \ \ \ \fR\f(CI$widget\fR\fI\fR\->\fBgrid\fR\fIOption\fR?(\fIarg\fR ?,\fIarg\fR ...?)? .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBgrid\fR method is used to communicate with the grid geometry manager that arranges widgets in rows and columns inside of another window, called the geometry master (or master window). The \fBgrid\fR method can have any of several forms, depending on the \fIoption\fR argument: .ie n .IP "\fR\fI$slave\fR\fI\fR\->\fBgrid\fR(?\fI\fR\fI$slave\fR\fI, ...\fR??, \fIoptions\fR?)" 4 .el .IP "\fR\f(CI$slave\fR\fI\fR\->\fBgrid\fR(?\fI\fR\f(CI$slave\fR\fI, ...\fR??, \fIoptions\fR?)" 4 .IX Item "$slave->grid(?$slave, ...??, options?)" The arguments consist of the optional references to more slave windows followed by pairs of arguments that specify how to manage the slaves. The characters \fB\-\fR, \fBx\fR and \fB^\fR, can be specified instead of a window reference to alter the default location of a \fR\f(CI$slave\fR\fI\fR, as described in "RELATIVE PLACEMENT", below. .Sp 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. .Sp The following options are supported: .RS 4 .IP "\fB\-column\fR => \fIn\fR" 8 .IX Item "-column => n" Insert the \fR\f(CI$slave\fR\fI\fR so that it occupies the \fIn\fRth column in the grid. Column numbers start with 0. If this option is not supplied, then the \&\fI\fR\f(CI$slave\fR\fI\fR is arranged just to the right of previous slave specified on this call to \fBgrid\fR, or column "0" if it is the first slave. For each \&\fBx\fR that immediately precedes the \fI\fR\f(CI$slave\fR\fI\fR, the column position is incremented by one. Thus the \fBx\fR represents a blank column for this row in the grid. .IP "\fB\-columnspan\fR => \fIn\fR" 8 .IX Item "-columnspan => n" Insert the slave so that it occupies \fIn\fR columns in the grid. The default is one column, unless the window name is followed by a \&\fB\-\fR, in which case the columnspan is incremented once for each immediately following \fB\-\fR. .ie n .IP "\fB\-in\fR => \fR\fI$other\fR\fI\fR" 8 .el .IP "\fB\-in\fR => \fR\f(CI$other\fR\fI\fR" 8 .IX Item "-in => $other" Insert the slave(s) in the master window given by \fR\f(CI$other\fR\fI\fR. The default is the first slave's parent window. .IP "\fB\-ipadx\fR => \fIamount\fR" 8 .IX Item "-ipadx => amount" The \fIamount\fR specifies how much horizontal internal padding to leave on each side of the slave(s). This is space is added inside the slave(s) border. The \fIamount\fR must be a valid screen distance, such as \fB2\fR or \fB'.5c'\fR. It defaults to 0. .IP "\fB\-ipady\fR => \fIamount\fR" 8 .IX Item "-ipady => amount" The \fIamount\fR specifies how much vertical internal padding to leave on on the top and bottom of the slave(s). This space is added inside the slave(s) border. The \fIamount\fR defaults to 0. .IP "\fB\-padx\fR => \fIamount\fR" 8 .IX Item "-padx => amount" The \fIamount\fR specifies how much horizontal external padding to leave on each side of the slave(s), in screen units. The \fIamount\fR defaults to 0. This space is added outside the slave(s) border. .IP "\fB\-pady\fR => \fIamount\fR" 8 .IX Item "-pady => amount" The \fIamount\fR specifies how much vertical external padding to leave on the top and bottom of the slave(s), in screen units. The \fIamount\fR defaults to 0. This space is added outside the slave(s) border. .IP "\fB\-row\fR => \fIn\fR" 8 .IX Item "-row => n" Insert the slave so that it occupies the \fIn\fRth row in the grid. Row numbers start with 0. If this option is not supplied, then the slave is arranged on the same row as the previous slave specified on this call to \fBgrid\fR, or the first unoccupied row if this is the first slave. .IP "\fB\-rowspan\fR => \fIn\fR" 8 .IX Item "-rowspan => n" Insert the slave so that it occupies \fIn\fR rows in the grid. The default is one row. If the next \fBgrid\fR method contains \&\fB^\fR characters instead of \fR\f(CI$slave\fR\fI\fRs that line up with the columns of this \fI\fR\f(CI$slave\fR\fI\fR, then the \fBrowspan\fR of this \fI\fR\f(CI$slave\fR\fI\fR is extended by one. .IP "\fB\-sticky\fR => \fIstyle\fR" 8 .IX Item "-sticky => style" If a slave's cell is larger than its requested dimensions, this option may be used to position (or stretch) the slave within its cell. \&\fIStyle\fR is a string that contains zero or more of the characters \&\fBn\fR, \fBs\fR, \fBe\fR or \fBw\fR. The string can optionally contain spaces or commas, but they are ignored. Each letter refers to a side (north, south, east, or west) that the slave will "stick" to. If both \fBn\fR and \fBs\fR (or \&\fBe\fR and \fBw\fR) are specified, the slave will be stretched to fill the entire height (or width) of its cavity. The \fBsticky\fR option subsumes the combination of \fB\-anchor\fR and \fB\-fill\fR that is used by pack. The default is \fB''\fR, which causes the slave to be centered in its cavity, at its requested size. .RE .RS 4 .RE .ie n .IP "\fR\fI$master\fR\fI\fR\->\fBgridBbox\fR(?\fIcolumn, row\fR,? ?\fIcolumn2, row2\fR?)" 4 .el .IP "\fR\f(CI$master\fR\fI\fR\->\fBgridBbox\fR(?\fIcolumn, row\fR,? ?\fIcolumn2, row2\fR?)" 4 .IX Item "$master->gridBbox(?column, row,? ?column2, row2?)" With no arguments, the bounding box (in pixels) of the grid is returned. The return value consists of 4 integers. The first two are the pixel offset from the master window (x then y) of the top-left corner of the grid, and the second two integers are the width and height of the grid, also in pixels. If a single \fIcolumn\fR and \fIrow\fR is specified on the command line, then the bounding box for that cell is returned, where the top left cell is numbered from zero. If both \fIcolumn\fR and \fIrow\fR arguments are specified, then the bounding box spanning the rows and columns indicated is returned. .ie n .IP "\fR\fI$master\fR\fI\fR\->\fBgridColumnconfigure\fR(\fIindex\fR?, \fI\-option\fR=>\fIvalue, ...\fR?)" 4 .el .IP "\fR\f(CI$master\fR\fI\fR\->\fBgridColumnconfigure\fR(\fIindex\fR?, \fI\-option\fR=>\fIvalue, ...\fR?)" 4 .IX Item "$master->gridColumnconfigure(index?, -option=>value, ...?)" Query or set the column properties of the \fIindex\fR column of the geometry master, \fR\f(CI$master\fR\fI\fR. The valid options are \fB\-minsize\fR, \fB\-weight\fR and \fB\-pad\fR. If one or more options are provided, then \fIindex\fR may be given as a list of column indices to which the configuration options will operate on. The \fB\-minsize\fR option sets the minimum size, in screen units, that will be permitted for this column. The \fB\-weight\fR option (an integer value) sets the relative weight for apportioning any extra spaces among columns. A weight of zero (0) indicates the column will not deviate from its requested size. A column whose weight is two will grow at twice the rate as a column of weight one when extra space is allocated to the layout. The \fB\-uniform\fR option, when a non-empty value is supplied, places the column in a \fIuniform group\fR with other columns that have the same value for \fB\-uniform\fR. The space for columns belonging to a uniform group is allocated so that their sizes are always in strict proportion to their \&\fB\-weight\fR values. See \fITHE GRID ALGORITHM\fR below for further details. The \fB\-pad\fR option specifies the number of screen units that will be added to the largest window contained completely in that column when the grid geometry manager requests a size from the containing window. If only an option is specified, with no value, the current value of that option is returned. If only the master window and index is specified, all the current settings are returned in an list of "\-option value" pairs. .ie n .IP "\fR\fI$slave\fR\fI\fR\->\fBgridConfigure\fR(?\fI\fR\fI$slave\fR\fI, ...\fR?, \fIoptions\fR?)" 4 .el .IP "\fR\f(CI$slave\fR\fI\fR\->\fBgridConfigure\fR(?\fI\fR\f(CI$slave\fR\fI, ...\fR?, \fIoptions\fR?)" 4 .IX Item "$slave->gridConfigure(?$slave, ...?, options?)" The same as \fBgrid\fR method. .ie n .IP "\fR\fI$slave\fR\fI\fR\->\fBgridForget\fR?(\fI\fR\fI$slave\fR\fI, ...\fR)?" 4 .el .IP "\fR\f(CI$slave\fR\fI\fR\->\fBgridForget\fR?(\fI\fR\f(CI$slave\fR\fI, ...\fR)?" 4 .IX Item "$slave->gridForget?($slave, ...)?" Removes each of the \fR\f(CI$slave\fR\fI\fRs from grid for its master and unmaps their windows. The slaves will no longer be managed by the grid geometry manager. The configuration options for that window are forgotten, so that if the slave is managed once more by the grid geometry manager, the initial default settings are used. .ie n .IP \fR\fI$slave\fR\fI\fR\->\fBgridInfo\fR 4 .el .IP \fR\f(CI$slave\fR\fI\fR\->\fBgridInfo\fR 4 .IX Item "$slave->gridInfo" Returns a list whose elements are the current configuration state of the slave given by \fR\f(CI$slave\fR\fI\fR in the same option-value form that might be specified to \fBgridConfigure\fR. The first two elements of the list are ``\fB\-in\fR=>\fI\fR\f(CI$master\fR\fI\fR'' where \&\fI\fR\f(CI$master\fR\fI\fR is the slave's master. .ie n .IP "\fR\fI$master\fR\fI\fR\->\fBgridLocation\fR(\fIx, y\fR)" 4 .el .IP "\fR\f(CI$master\fR\fI\fR\->\fBgridLocation\fR(\fIx, y\fR)" 4 .IX Item "$master->gridLocation(x, y)" Given \fIx\fR and \fIy\fR values in screen units relative to the master window, the column and row number at that \fIx\fR and \fIy\fR location is returned. For locations that are above or to the left of the grid, \fB\-1\fR is returned. .ie n .IP \fR\fI$master\fR\fI\fR\->\fBgridPropagate\fR?(\fIboolean\fR)? 4 .el .IP \fR\f(CI$master\fR\fI\fR\->\fBgridPropagate\fR?(\fIboolean\fR)? 4 .IX Item "$master->gridPropagate?(boolean)?" If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR then propagation is enabled for \fR\f(CI$master\fR\fI\fR, which must be a window name (see "GEOMETRY PROPAGATION" below). If \fIboolean\fR has a false boolean value then propagation is disabled for \fI\fR\f(CI$master\fR\fI\fR. In either of these cases an empty string is returned. If \fIboolean\fR is omitted then the method returns \fB0\fR or \&\fB1\fR to indicate whether propagation is currently enabled for \fI\fR\f(CI$master\fR\fI\fR. Propagation is enabled by default. .ie n .IP "\fR\fI$master\fR\fI\fR\->\fBgridRowconfigure\fR(\fIindex\fR?, \fI\-option\fR=>\fIvalue, ...\fR?)" 4 .el .IP "\fR\f(CI$master\fR\fI\fR\->\fBgridRowconfigure\fR(\fIindex\fR?, \fI\-option\fR=>\fIvalue, ...\fR?)" 4 .IX Item "$master->gridRowconfigure(index?, -option=>value, ...?)" Query or set the row properties of the \fIindex\fR row of the geometry master, \fR\f(CI$master\fR\fI\fR. The valid options are \fB\-minsize\fR, \fB\-weight\fR and \fB\-pad\fR. If one or more options are provided, then \fIindex\fR may be given as a list of row indeces to which the configuration options will operate on. The \fB\-minsize\fR option sets the minimum size, in screen units, that will be permitted for this row. The \fB\-weight\fR option (an integer value) sets the relative weight for apportioning any extra spaces among rows. A weight of zero (0) indicates the row will not deviate from its requested size. A row whose weight is two will grow at twice the rate as a row of weight one when extra space is allocated to the layout. The \fB\-uniform\fR option, when a non-empty value is supplied, places the row in a \fIuniform group\fR with other rows that have the same value for \fB\-uniform\fR. The space for rows belonging to a uniform group is allocated so that their sizes are always in strict proportion to their \fB\-weight\fR values. See \fITHE GRID ALGORITHM\fR below for further details. The \fB\-pad\fR option specifies the number of screen units that will be added to the largest window contained completely in that row when the grid geometry manager requests a size from the containing window. If only an option is specified, with no value, the current value of that option is returned. If only the master window and index is specified, all the current settings are returned in an list of "option-value" pairs. .ie n .IP "\fR\fI$slave\fR\fI\fR\->\fBgridRemove\fR?(\fI\fR\fI$slave\fR\fI, ...\fR)?" 4 .el .IP "\fR\f(CI$slave\fR\fI\fR\->\fBgridRemove\fR?(\fI\fR\f(CI$slave\fR\fI, ...\fR)?" 4 .IX Item "$slave->gridRemove?($slave, ...)?" Removes each of the \fR\f(CI$slave\fR\fI\fRs from grid for its master and unmaps their windows. The slaves will no longer be managed by the grid geometry manager. However, the configuration options for that window are remembered, so that if the slave is managed once more by the grid geometry manager, the previous values are retained. .ie n .IP \fR\fI$master\fR\fI\fR\->\fBgridSize\fR 4 .el .IP \fR\f(CI$master\fR\fI\fR\->\fBgridSize\fR 4 .IX Item "$master->gridSize" Returns the size of the grid (in columns then rows) for \fR\f(CI$master\fR\fI\fR. The size is determined either by the \fI\fR\f(CI$slave\fR\fI\fR occupying the largest row or column, or the largest column or row with a \fB\-minsize\fR, \&\fB\-weight\fR, or \fB\-pad\fR that is non-zero. .ie n .IP \fR\fI$master\fR\fI\fR\->\fBgridSlaves\fR?(\fI\-option\fR=>\fIvalue\fR)? 4 .el .IP \fR\f(CI$master\fR\fI\fR\->\fBgridSlaves\fR?(\fI\-option\fR=>\fIvalue\fR)? 4 .IX Item "$master->gridSlaves?(-option=>value)?" If no options are supplied, a list of all of the slaves in \fR\f(CI$master\fR\fI\fR are returned, most recently manages first. \&\fI\-option\fR can be either \fB\-row\fR or \fB\-column\fR which causes only the slaves in the row (or column) specified by \fIvalue\fR to be returned. .SH "RELATIVE PLACEMENT" .IX Header "RELATIVE PLACEMENT" The \fBgrid\fR method contains a limited set of capabilities that permit layouts to be created without specifying the row and column information for each slave. This permits slaves to be rearranged, added, or removed without the need to explicitly specify row and column information. When no column or row information is specified for a \fR\f(CI$slave\fR\fI\fR, default values are chosen for \&\fB\-column\fR, \fB\-row\fR, \fB\-columnspan\fR and \fB\-rowspan\fR at the time the \fI\fR\f(CI$slave\fR\fI\fR is managed. The values are chosen based upon the current layout of the grid, the position of the \fI\fR\f(CI$slave\fR\fI\fR relative to other \fI\fR\f(CI$slave\fR\fI\fRs in the same grid method, and the presence of the characters \fB\-\fR, \fB^\fR, and \fB^\fR in \fBgrid\fR method where \fI\fR\f(CI$slave\fR\fI\fR names are normally expected. .IP \fB\-\fR 4 .IX Item "-" This increases the columnspan of the \fR\f(CI$slave\fR\fI\fR to the left. Several \&\fB\-\fR's in a row will successively increase the columnspan. A \fB\-\fR may not follow a \fB^\fR or a \fBx\fR. .IP \fBx\fR 4 .IX Item "x" This leaves an empty column between the \fR\f(CI$slave\fR\fI\fR on the left and the \fI\fR\f(CI$slave\fR\fI\fR on the right. .IP \fB^\fR 4 .IX Item "^" This extends the \fB\-rowspan\fR of the \fR\f(CI$slave\fR\fI\fR above the \fB^\fR's in the grid. The number of \fB^\fR's in a row must match the number of columns spanned by the \fI\fR\f(CI$slave\fR\fI\fR above it. .SH "THE GRID ALGORITHM" .IX Header "THE GRID ALGORITHM" The grid geometry manager lays out its slaves in three steps. In the first step, the minimum size needed to fit all of the slaves is computed, then (if propagation is turned on), a request is made of the master window to become that size. In the second step, the requested size is compared against the actual size of the master. If the sizes are different, then space is added to or taken away from the layout as needed. For the final step, each slave is positioned in its row(s) and column(s) based on the setting of its \fIsticky\fR flag. .PP To compute the minimum size of a layout, the grid geometry manager first looks at all slaves whose columnspan and rowspan values are one, and computes the nominal size of each row or column to be either the \&\fIminsize\fR for that row or column, or the sum of the \fIpad\fRding plus the size of the largest slave, whichever is greater. Then the slaves whose rowspans or columnspans are greater than one are examined. If a group of rows or columns need to be increased in size in order to accommodate these slaves, then extra space is added to each row or column in the group according to its \fIweight\fR. For each group whose weights are all zero, the additional space is apportioned equally. .PP When multiple rows or columns belong to a uniform group, the space allocated to them is always in proportion to their weights. (A weight of zero is considered to be 1.) In other words, a row or column configured with \fB\-weight 1 \-uniform\fR a will have exactly the same size as any other row or column configured with \fB\-weight 1 \-uniform a\fR. A row or column configured with \fB\-weight 2 \-uniform b\fR will be exactly twice as large as one that is configured with \fB\-weight 1 \-uniform b\fR. .PP More technically, each row or column in the group will have a size equal to \fIk*weight\fR for some constant k. The constant k is chosen so that no row or column becomes smaller than its minimum size. For example, if all rows or columns in a group have the same weight, then each row or column will have the same size as the largest row or column in the group. .PP For masters whose size is larger than the requested layout, the additional space is apportioned according to the row and column weights. If all of the weights are zero, the layout is centered within its master. For masters whose size is smaller than the requested layout, space is taken away from columns and rows according to their weights. However, once a column or row shrinks to its minsize, its weight is taken to be zero. If more space needs to be removed from a layout than would be permitted, as when all the rows or columns are at there minimum sizes, the layout is clipped on the bottom and right. .SH "GEOMETRY PROPAGATION" .IX Header "GEOMETRY PROPAGATION" The grid geometry manager 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 \fBgridPropagate\fR method may be used to turn off propagation for one or more masters. If propagation is disabled then grid will not set the requested width and height of the master window. 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" .IX Header "RESTRICTIONS ON MASTER WINDOWS" 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. In addition, all slaves in one call to \fBgrid\fR must have the same master. .SH "STACKING ORDER" .IX Header "STACKING ORDER" 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 managed 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. .SH CREDITS .IX Header "CREDITS" The \fBgrid\fR method is based on ideas taken from the \fIGridBag\fR geometry manager written by Doug. Stein, and the \fBblt_table\fR geometry manager, written by George Howlett. .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::form Tk::pack Tk::place .SH KEYWORDS .IX Header "KEYWORDS" geometry manager, location, grid, cell, propagation, size, pack, master, slave