It is now available that each cell can have its own alignment.
The combination is (left, center, right) && (top,center,bottom).
The only stipulation is that the module be give the height and width
of the widget *** BEFORE ** it is placed in the cell.
$win->AddLabel(
-name => "label2",
-width => $grid->width(35),
-height => $grid->height(11),
-left => $grid->column(2, "c"),
-top => $grid->row(1, "c"),
-text => "Label 2",
);
this tells the module that the widget is 35 pixels wide and 11 wide.
Then
it puts the widget in cell 2 horizontally centered and row 1 vertically
centered.
QUESTION:
Are the widgets and the window both measured in pixels?
Because when i declared the the window was 400x300 to
the gridLayout and made the window 400x300 in the Win32::GUI
my bottom row cell rolled off the bottom. I played with the window
width and height and found that the widget pixels seem larger than the
window pixels.
Is this true or is my algebra off?
I have not done anything with compensating for the padding or if the
width and height are not predeclared. I will do this as i continue to
develop this.
Hope you find it useful.
Michael Kangas
[EMAIL PROTECTED]
test3.pl
package GridLayout;
sub new {
my($c, $r, $w, $h, $xpad, $ypad) = @_;
my $r_grid = {
"cols" => $c,
"rows" => $r,
"width" => $w,
"height" => $h,
"xPad" => $xpad,
"yPad" => $ypad,
};
bless $r_grid, 'GridLayout';
return $r_grid;
}
sub column {
my ($grid_param, $col, $align) = @_;
$col--;
$colWidth = int($grid_param->{'width'} / $grid_param->{'cols'});
$x = ($col * $colWidth) + ($grid_param->{'xPad'});
$x = int((($colWidth - $widgetWidth) / 2) + $x) if $align =~ /c/i;
$x = int((($colWidth - $widgetWidth) - $grid_param->{'xPad'}) + $x) if $align =~
/r/i;
$widgetWidth=0; #in case a width declaration is missed or not used
return $x;
}
sub row {
my ($grid_param,$row, $align) = @_;
$row--;
$rowHeight = int($grid_param->{'height'} / $grid_param->{'rows'});
$y = ($row * $rowHeight) + ($grid_param->{'yPad'});
$y = int((($rowHeight - $widgetHeight) / 2) + $y) if $align =~ /c/i;
$y = int((($rowHeight - $widgetHeight) - ($grid_param->{'yPad'})) + $y) if $align
=~ /b/i;
$widgetHeight=0; #same reason as coment in &column
return $y;
}
sub width {
my ($grid_param,$w) = @_;
$widgetWidth = $w;
return $widgetWidth;
}
sub height {
my ($grid_param,$h) = @_;
$widgetHeight = $h;
return $widgetHeight;
}
1;