line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Boxer::Content::Row; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$PDF::Boxer::Content::Row::VERSION = '0.004'; |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
17
|
use Moose; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: a box of boxes laid out side by side |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
20461
|
use namespace::autoclean; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
34
|
|
9
|
3
|
|
|
3
|
|
320
|
use Scalar::Util qw!weaken!; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
2487
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'PDF::Boxer::Content::Box'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get_default_size{ |
14
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
15
|
0
|
|
|
|
|
|
my @kids = @{$self->children}; |
|
0
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my ($width, $height) = (0,0); |
17
|
0
|
|
|
|
|
|
foreach(@kids){ |
18
|
0
|
|
|
|
|
|
$width += $_->margin_width; |
19
|
0
|
0
|
|
|
|
|
$height = $height ? (sort { $b <=> $a } ($_->margin_height,$height))[0] : $_->margin_height; |
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
return ($width, $height); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub update_children{ |
25
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
26
|
0
|
0
|
|
|
|
|
$self->update_kids_size if $self->size_set; |
27
|
0
|
0
|
|
|
|
|
$self->update_kids_position if $self->position_set; |
28
|
0
|
|
|
|
|
|
foreach my $kid (@{$self->children}){ |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$kid->update; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
return 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub update_kids_position{ |
35
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $kids = $self->children; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if (@$kids){ |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $top = $self->content_top; |
42
|
0
|
|
|
|
|
|
my $left = $self->content_left; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
45
|
0
|
|
|
|
|
|
$kid->move($left, $top); |
46
|
0
|
|
|
|
|
|
$left += $kid->margin_width; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return 1; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub update_kids_size{ |
54
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $kids = $self->children; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my ($kids_width, $kids_height) = $self->get_default_size; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if (@$kids){ |
61
|
0
|
|
|
|
|
|
my $space = $self->width - $kids_width; |
62
|
0
|
|
|
|
|
|
my ($has_grow,$grow,$grow_all); |
63
|
0
|
|
|
|
|
|
my $space_each = 0; |
64
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
65
|
0
|
0
|
|
|
|
|
$has_grow++ if $kid->grow; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
|
if (!$has_grow){ |
68
|
0
|
|
|
|
|
|
$grow_all = 1; |
69
|
0
|
|
|
|
|
|
$has_grow = @$kids; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
$space_each = int($space/$has_grow); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $kheight = $self->content_height; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
76
|
0
|
|
|
|
|
|
my $kwidth = $kid->margin_width; |
77
|
0
|
0
|
0
|
|
|
|
if ($grow_all || $kid->grow){ |
78
|
0
|
|
|
|
|
|
$kwidth += $space_each; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
$kid->set_margin_size($kwidth, $kheight); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return 1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub set_kids_minimum_width{ |
88
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
89
|
0
|
|
|
|
|
|
my $kids = $self->children; |
90
|
0
|
0
|
0
|
|
|
|
if ($args->{min_widths} && @{$args->{min_widths}}){ |
|
0
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if (@$kids){ |
92
|
0
|
|
|
|
|
|
my @widths = @{$args->{min_widths}}; |
|
0
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
94
|
0
|
|
|
|
|
|
my $width = shift @widths; |
95
|
0
|
|
|
|
|
|
$kid->set_margin_width($width); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub child_adjusted_height{ |
103
|
0
|
|
|
0
|
0
|
|
my ($self, $child) = @_; |
104
|
0
|
0
|
|
|
|
|
weaken($child) if $child; |
105
|
0
|
|
|
|
|
|
my $low = 5000; |
106
|
0
|
|
|
|
|
|
foreach(@{$self->children}){ |
|
0
|
|
|
|
|
|
|
107
|
0
|
0
|
0
|
|
|
|
$low = $_->margin_bottom if defined $_->margin_bottom && $_->margin_bottom < $low; |
108
|
|
|
|
|
|
|
} |
109
|
0
|
0
|
|
|
|
|
if ($self->content_bottom != $low){ |
110
|
0
|
|
|
|
|
|
my $height = $self->margin_height + $self->content_bottom - $low; |
111
|
0
|
|
|
|
|
|
$self->set_height($height); |
112
|
0
|
|
|
|
|
|
$self->parent->child_adjusted_height($self); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |
124
|
|
|
|
|
|
|
=pod |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 NAME |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
PDF::Boxer::Content::Row - a box of boxes laid out side by side |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 VERSION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
version 0.004 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Jason Galea <lecstor@cpan.org> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Jason Galea. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
143
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|