Tk
view release on metacpan or search on metacpan
demos/demos/widtrib/all.pl view on Meta::CPAN
}
$row++;
if ($separator) {
$f->Label(-text => $separator,
-font => 'Helvetica 18',
-pady => 5,
)->grid(-row => $row,
-column => 0,
-columnspan => 3,
);
next;
}
my $bgcolor = $row%2==0 ? '#c0c0c0' : '#a0a0a0';
my $ff = $f->Frame(-background => $bgcolor,
)->grid(-row => $row,
-column => 1,
-sticky => 'news',
);
examples/tkfontsel view on Meta::CPAN
my $weight = $mw->Optionmenu(-width => 3, -variable => \$fopt{-weight},
-options => [qw(medium bold)],
-command => [\&SetFont,$font,\%fopt]);
Tk::grid($mw->Label(-text => 'Family:',-justify => 'right'), $family,
$mw->Label(-text => 'Size:',-justify => 'right'), $size,
$mw->Label(-text => 'Weight:',-justify => 'right'), $weight,
-sticky => 'ew',
);
my $text = $mw->Scrolled(Text => -font => $font, -width => 40, -height => 20)->grid(-sticky => 'nsew', -columnspan => 6);
my $l = '';
for my $ch (0x20..0x7E,0xa0..0xff)
{
$l .= chr($ch);
if (length($l) == 16)
{
$text->insert(end => "$l\n");
$l = '';
}
pTk/mTk/generic/tkGrid.c view on Meta::CPAN
return TCL_OK;
}
Tcl_AppendElement(interp, "-in");
Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),
LangWidgetObj(interp, slavePtr->masterPtr->tkwin));
Tcl_AppendElement(interp, "-column");
Tcl_IntResults(interp, 1, 1, slavePtr->column);
Tcl_AppendElement(interp, "-row");
Tcl_IntResults(interp, 1, 1, slavePtr->row);
Tcl_AppendElement(interp, "-columnspan");
Tcl_IntResults(interp, 1, 1, slavePtr->numCols);
Tcl_AppendElement(interp, "-rowspan");
Tcl_IntResults(interp, 1, 1, slavePtr->numRows);
TkPrintPadAmount(interp, "ipadx", slavePtr->iPadX/2, slavePtr->iPadX);
TkPrintPadAmount(interp, "ipady", slavePtr->iPadY/2, slavePtr->iPadY);
TkPrintPadAmount(interp, "padx", slavePtr->padLeft, slavePtr->padX);
TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY);
StickyToString(slavePtr->sticky,buffer);
Tcl_AppendElement(interp, "-sticky");
pTk/mTk/generic/tkGrid.c view on Meta::CPAN
int i, j, tmp;
int length;
int numWindows;
int width;
int defaultColumn = 0; /* default column number */
int defaultColumnSpan = 1; /* default number of columns */
char *lastWindow; /* use this window to base current
* Row/col on */
int numSkip; /* number of 'x' found */
static CONST char *optionStrings[] = {
"-column", "-columnspan", "-in", "-ipadx", "-ipady",
"-padx", "-pady", "-row", "-rowspan", "-sticky",
(char *) NULL };
enum options {
CONF_COLUMN, CONF_COLUMNSPAN, CONF_IN, CONF_IPADX, CONF_IPADY,
CONF_PADX, CONF_PADY, CONF_ROW, CONF_ROWSPAN, CONF_STICKY };
int index;
char *string;
char firstChar, prevChar;
/*
pTk/mTk/generic/tkGrid.c view on Meta::CPAN
Tcl_AppendResult(interp, "bad column value \"",
Tcl_GetString(objv[i+1]),
"\": must be a non-negative integer", (char *)NULL);
return TCL_ERROR;
}
slavePtr->column = tmp;
} else if (index == CONF_COLUMNSPAN) {
if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK ||
tmp <= 0) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "bad columnspan value \"",
Tcl_GetString(objv[i+1]),
"\": must be a positive integer", (char *)NULL);
return TCL_ERROR;
}
slavePtr->numCols = tmp;
} else if (index == CONF_IN) {
if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) !=
TCL_OK) {
return TCL_ERROR;
}
pod/grid.pod view on Meta::CPAN
=item B<-column> => I<n>
Insert the I<$slave> so that it occupies the I<n>th column in the grid.
Column numbers start with 0. If this option is not supplied, then the
I<$slave> is arranged just to the right of previous slave specified on this
call to B<grid>, or column "0" if it is the first slave. For each
B<x> that immediately precedes the I<$slave>, the column position
is incremented by one. Thus the B<x> represents a blank column
for this row in the grid.
=item B<-columnspan> => I<n>
Insert the slave so that it occupies I<n> columns in the grid.
The default is one column, unless the window name is followed by a
B<->, in which case the columnspan is incremented once for each immediately
following B<->.
=item B<-in> => I<$other>
Insert the slave(s) in the master
window given by I<$other>. The default is the first slave's
parent window.
=item B<-ipadx> => I<amount>
pod/grid.pod view on Meta::CPAN
=head1 RELATIVE PLACEMENT
The B<grid> 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 I<$slave>,
default values are chosen for
B<-column>, B<-row>, B<-columnspan> and B<-rowspan>
at the time the I<$slave> is managed. The values are chosen
based upon the current layout of the grid, the position of the I<$slave>
relative to other I<$slave>s in the same grid method, and the presence
of the characters B<->, B<^>, and B<^> in B<grid>
method where I<$slave> names are normally expected.
=over 4
=item B<->
This increases the columnspan of the I<$slave> to the left. Several
B<->'s in a row will successively increase the columnspan. A B<->
may not follow a B<^> or a B<x>.
=item B<x>
This leaves an empty column between the I<$slave> on the left and
the I<$slave> on the right.
=item B<^>
This extends the B<-rowspan> of the I<$slave> above the B<^>'s
pod/grid.pod view on Meta::CPAN
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 I<sticky> flag.
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
I<minsize> for that row or column, or the sum of the I<pad>ding
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 I<weight>. For each
group whose weights are all zero, the additional space is apportioned
equally.
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 B<-weight 1 -uniform> a will have exactly the same size
##
{
print "grid and rel. placements\n";
my $b = $mw->Button();
#eval { $b->grid('-'); };
$b->grid('-');
ok ($@, '', "Problem with relative extent the column span by 1");
my %opt;
%opt = $b->gridInfo;
ok ($opt{-columnspan}, 2, "'-' gives wrong column span");
$b->destroy;
}
1;
__END__
( run in 0.260 second using v1.01-cache-2.11-cpan-a5abf4f5562 )