blib/lib/Graphics/Primitive/Driver/TextLayout.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 15 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Graphics::Primitive::Driver::TextLayout;
2 use Moose::Role;
3  
4 requires 'slice';
5  
6 has 'component' => (
7 is => 'rw',
8 isa => 'Graphics::Primitive::TextBox',
9 required => 1,
10 weak_ref => 1
11 );
12 has 'height' => (
13 is => 'rw',
14 isa => 'Num',
15 default => sub { -1 }
16 );
17 has 'width' => (
18 is => 'rw',
19 isa => 'Num',
20 lazy => 1,
21 default => sub { my ($self) = @_; $self->component->width }
22 );
23  
24 no Moose;
25 1;
26 __END__;
27 =head1 NAME
28  
29 Graphics::Primitive::Driver::TextLayout - TextLayout role
30  
31 =head1 DESCRIPTION
32  
33 Graphics::Primitive::Driver::TextLayout is a role for Driver text layout
34 engines.
35  
36 =head1 SYNOPSIS
37  
38 package MyLayout;
39 use Moose;
40  
41 with 'Graphics::Primitive::Driver::TextLayout';
42  
43 ...
44  
45 =head1 METHODS
46  
47 =over 4
48  
49 =item I<component>
50  
51 Set/Get the component from which to draw layout information.
52  
53 =item I<height>
54  
55 Set/Get this layout's height
56  
57 =item I<slice>
58  
59 Implemented by role consumer. Given an offset and an optional size, returns a
60 TextBox containing lines from this layout that come as close to C<$size>
61 without exceeding it. This method is provided to allow incremental rendering
62 of text. For example, if you have a series of containers 80 units high, you
63 might write code like this:
64  
65 for(my $i = 0; $i < 3; $i++) {
66 $textbox = $layout->slice($i * 80, 80);
67 # render the text
68 }
69  
70 =item I<width>
71  
72 Set/Get this layout's width. Defaults to the width of the component supplied.
73  
74 =back
75  
76 =head1 AUTHOR
77  
78 Cory Watson, C<< <gphat@cpan.org> >>
79  
80 =head1 COPYRIGHT & LICENSE
81  
82 Copyright 2008-2010 by Cory G Watson.
83  
84 This program is free software; you can redistribute it and/or modify it
85 under the same terms as Perl itself.