line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Boxer::Content::Column; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$PDF::Boxer::Content::Column::VERSION = '0.004'; |
4
|
|
|
|
|
|
|
} |
5
|
3
|
|
|
3
|
|
19
|
use Moose; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: a box of boxes stack one above the other |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19682
|
use namespace::autoclean; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
32
|
|
9
|
3
|
|
|
3
|
|
209
|
use Scalar::Util qw!weaken!; |
|
3
|
|
|
|
|
96
|
|
|
3
|
|
|
|
|
2098
|
|
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
|
|
|
|
|
|
$height+= $_->margin_height; |
19
|
0
|
0
|
|
|
|
|
$width = $width ? (sort { $b <=> $a } ($_->margin_width,$width))[0] : $_->margin_width; |
|
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_size{ |
35
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
36
|
0
|
|
|
|
|
|
my ($kids_width, $kids_height) = $self->get_default_size; |
37
|
0
|
|
|
|
|
|
my $kids = $self->children; |
38
|
0
|
0
|
|
|
|
|
if (@$kids){ |
39
|
0
|
|
|
|
|
|
my $space = $self->height - $kids_height; |
40
|
0
|
|
|
|
|
|
my ($has_grow,$grow,$grow_all); |
41
|
0
|
|
|
|
|
|
my $space_each = 0; |
42
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
43
|
0
|
0
|
|
|
|
|
$has_grow++ if $kid->grow; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
0
|
|
|
|
|
$space_each = int($space/$has_grow) if $has_grow; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $kwidth = $self->content_width; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
50
|
0
|
|
|
|
|
|
my $kheight = $kid->margin_height; |
51
|
0
|
0
|
0
|
|
|
|
if ($grow_all || $kid->grow){ |
52
|
0
|
|
|
|
|
|
$kheight += $space_each; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
|
$kid->set_margin_size($kwidth, $kheight); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub update_kids_position{ |
61
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
62
|
0
|
|
|
|
|
|
my $kids = $self->children; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if (@$kids){ |
65
|
0
|
|
|
|
|
|
my $top = $self->content_top; |
66
|
0
|
|
|
|
|
|
my $left = $self->content_left; |
67
|
0
|
|
|
|
|
|
foreach my $kid (@$kids){ |
68
|
0
|
|
|
|
|
|
$kid->move($left, $top); |
69
|
0
|
|
|
|
|
|
$top -= $kid->margin_height; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub child_adjusted_height{ |
76
|
0
|
|
|
0
|
0
|
|
my ($self, $child) = @_; |
77
|
0
|
0
|
|
|
|
|
weaken($child) if $child; |
78
|
0
|
|
|
|
|
|
$self->update_kids_position; |
79
|
0
|
0
|
|
|
|
|
unless($self->grow){ |
80
|
0
|
|
|
|
|
|
my $kid = $self->children->[-1]; |
81
|
0
|
|
|
|
|
|
my $kid_mb = $kid->margin_bottom; |
82
|
0
|
0
|
|
|
|
|
if ($self->content_bottom != $kid_mb){ |
83
|
0
|
|
|
|
|
|
my $height = $self->margin_height + $self->content_bottom - $kid_mb; |
84
|
0
|
0
|
|
|
|
|
if ($height > $self->boxer->max_height){ |
85
|
0
|
|
|
|
|
|
$self->update_kids_size; |
86
|
|
|
|
|
|
|
} else { |
87
|
0
|
|
|
|
|
|
$self->set_margin_height($height); |
88
|
0
|
0
|
|
|
|
|
$self->parent->child_adjusted_height($self) if $self->parent; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 NAME |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
PDF::Boxer::Content::Column - a box of boxes stack one above the other |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 VERSION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
version 0.004 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Jason Galea <lecstor@cpan.org> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Jason Galea. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
119
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|