Graphics::Primitive::Driver::TextLayout - TextLayout role


Graphics-Primitive documentation Contained in the Graphics-Primitive distribution.

Index


Code Index:

NAME

Top

Graphics::Primitive::Driver::TextLayout - TextLayout role

DESCRIPTION

Top

Graphics::Primitive::Driver::TextLayout is a role for Driver text layout engines.

SYNOPSIS

Top

    package MyLayout;
    use Moose;

    with 'Graphics::Primitive::Driver::TextLayout';

    ...

METHODS

Top

component

Set/Get the component from which to draw layout information.

height

Set/Get this layout's height

slice

Implemented by role consumer. Given an offset and an optional size, returns a TextBox containing lines from this layout that come as close to $size without exceeding it. This method is provided to allow incremental rendering of text. For example, if you have a series of containers 80 units high, you might write code like this:

  for(my $i = 0; $i < 3; $i++) {
      $textbox = $layout->slice($i * 80, 80);
      # render the text
  }

width

Set/Get this layout's width. Defaults to the width of the component supplied.

AUTHOR

Top

Cory Watson, <gphat@cpan.org>

COPYRIGHT & LICENSE

Top


Graphics-Primitive documentation Contained in the Graphics-Primitive distribution.

package Graphics::Primitive::Driver::TextLayout;
use Moose::Role;

requires 'slice';

has 'component' => (
    is => 'rw',
    isa => 'Graphics::Primitive::TextBox',
    required => 1
);
has 'height' => (
    is => 'rw',
    isa => 'Num',
    default => sub { -1 }
);
has 'width' => (
    is => 'rw',
    isa => 'Num',
    lazy => 1,
    default => sub { my ($self) = @_; $self->component->width }
);

no Moose;
1;
__END__;