The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Layout::Manager - 2D Layout Management

SYNOPSIS

Layout::Manager provides a simple interface for creating layout managers, or classes that size and position components withing a container.

A few managers are provided for reference, but this module is primarily meant to serve as a base for outside implementations.

    use Layout::Manager;

    my $foo = Layout::Manager->new();
    ...

USING A LAYOUT MANAGER

Various implementations of Layout::Manager will require you do add components with slightly different second arguments, but the general case will be:

  $lm->add_component($comp, $constraints);

The contents of $constraints must be discerned by reading the documentation for the layout manager you are using.

The $comp argument must be a class that implements the Layout::Manager::Component role. For more information on Roles please read the Moose::Role documentation on the CPAN.

When you are ready to lay out your container, you'll need to call the do_layout method with a single argument: the component in which you are laying things out. This object is also expected to implement aforementioned Layout::Manager::Component role. When do_layout returns all of the components should be resized and repositioned according to the rules of the Layout::Manager implementation.

WRITING A LAYOUT MANAGER

Layout::Manager provides all the methods necessary for your implementation, save the do_layout method. This method will be called when it is time to layout the components.

The add_component method takes two arguments: the component and a second, abritrary piece of data. If your layout manager is simple, like Compass, you may only require a simple variable like "NORTH". If you create something more complex the second argument may be a hashref or an object.

The value of the components method is an arrayref of hashrefs. The hashrefs have two keys:

component

The component to be laid out.

args

The argument provided to add_component.

METHODS

add_component

Add a component to the layout manager. Returns a true value if the component was added successfully. A second argument may be required, please consult the POD for your specific layout manager implementation.

Before the component is added, it is passed to the validate_component method. If validate_component does not return a true value, then the component is not added.

clear_components

Remove all components from the layout manager.

count_components

Returns the number of components in this layout manager.

do_layout

Lays out this managers components in the specified container.

do_prepare

Calls prepare on all this layout manager's child components.

get_component

Get the component at the specified index.

remove_component

Removes a component. Components must have names to be removed.

validate_component

Optionally overriden by an implementation, allows it to deem

AUTHOR

Cory Watson, <gphat@cpan.org>

Infinity Interactive, http://www.iinteractive.com

SEE ALSO

perl(1)

COPYRIGHT & LICENSE

Copyright 2008 by Infinity Interactive, Inc.

http://www.iinteractive.com

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