DESCRIPTION

Layout::Manager::Grid is a layout manager places components into evenly divided cells.

When you instantiate a Grid manager, you must supply it with a count of how many rows and columns it will have. For example, a Grid with 1 column and 2 rows would look like:

  +--------------------------------+
  |                                |
  |           component 1          |
  |                                |
  +--------------------------------+
  |                                |
  |           component 2          |
  |                                |
  +--------------------------------+

The container is divided into as many <rows> * <columns> cells, with each taking up an equal amount of space. A grid with 3 columns and 2 rows would create 6 cells that consume 33% of the width and 50% of the height.

Components are placed by specifying the cell they reside in via the row and column number.

$container->add_component($comp, { row => 0, column => 3 });

$container->add_component($comp, { row => 0, column => 2, height => 2 });

Optionally, you may choose to override the default \*(C`width\*(C' or \*(C`height\*(C' of 1. Setting it to a something else will cause the component to consume that many rows or columns worth of space.

Grid is similar to Java's GridLayout <http://java.sun.com/docs/books/tutorial/uiswing/layout/grid.html>.

SYNOPSIS

$cont->add_component($comp1, { row => 0, column => 1 }); $cont->add_component($comp2, { row => 0, column => 2 });

my $lm = Layout::Manager::Grid->new(rows => 1, columns => 2); $lm->do_layout($con);

\s-1DYNAMIC\s0 \s-1SIZING\s0

If the container that the Grid is manging does not have one or both of it's dimensions set, Grid will compute the appropriate sizes. The simple way for me to avoid writing a long explanation is to say it works similar to \s-1HTML\s0 tables. Rows will become as big as their biggest consituent, as will columns. It is common to add a Grid-managed component to a scene with only one of it's dimensions set.

ATTRIBUTES

columns

The number of columns in this Grid.

rows

The number of rows in this Grid.

METHODS

do_layout

Size and position the components in this layout.

AUTHOR

Cory Watson, \*(C`<[email protected]>\*(C'

COPYRIGHT & LICENSE

Copyright 2008 - 2010 Cory G Watson

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.