line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Imager::DTP::Line::Horizontal; |
2
|
2
|
|
|
2
|
|
10
|
use base Imager::DTP::Line; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1140
|
|
3
|
|
|
|
|
|
|
use strict; |
4
|
|
|
|
|
|
|
use vars qw($VERSION); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub draw { |
9
|
|
|
|
|
|
|
my $self = shift; |
10
|
|
|
|
|
|
|
my %o = @_; |
11
|
|
|
|
|
|
|
my $y = ($o{y})? $o{y} : 0; |
12
|
|
|
|
|
|
|
my $x = ($o{x})? $o{x} : 0; |
13
|
|
|
|
|
|
|
# re-calculate bounding box |
14
|
|
|
|
|
|
|
$self->_calcWidthHeight(); |
15
|
|
|
|
|
|
|
my $l = ($o{leading})? $o{leading} : $self->getAscent(); |
16
|
|
|
|
|
|
|
# draw box - debug |
17
|
|
|
|
|
|
|
if($o{debug}){ |
18
|
|
|
|
|
|
|
$o{target}->box(filled=>1,color=>'#EFEFEF',xmin=>$x,ymin=>$y, |
19
|
|
|
|
|
|
|
xmax=>$x+$self->getWidth(),ymax=>$y+$l); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
foreach my $ltr (@{$self->getLetters()}){ |
22
|
|
|
|
|
|
|
my $nowy = $y + $l - $ltr->getGlobalAscent(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$ltr->draw(target=>$o{target},x=>$x,y=>$nowy,debug=>$o{debug}, |
25
|
|
|
|
|
|
|
others=>$o{others}) or die $ltr->errstr; |
26
|
|
|
|
|
|
|
$x += $ltr->getAdvancedWidth() + $self->getWspace(); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _calcWidthHeight { |
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
return undef if($self->{isUpdated}); |
34
|
|
|
|
|
|
|
return undef if(@{$self->getLetters()} == 0); |
35
|
|
|
|
|
|
|
my %o = @_; |
36
|
|
|
|
|
|
|
my ($w,$h,$a,$d) = qw(0 0 0 0); |
37
|
|
|
|
|
|
|
my $wspace = $self->getWspace(); |
38
|
|
|
|
|
|
|
foreach my $ltr (@{$self->getLetters()}){ |
39
|
|
|
|
|
|
|
$ltr->_calcWidthHeight(); |
40
|
|
|
|
|
|
|
$w += $ltr->getAdvancedWidth() + $wspace; |
41
|
|
|
|
|
|
|
$a = ($ltr->getGlobalAscent() > $a)? $ltr->getGlobalAscent() : $a; |
42
|
|
|
|
|
|
|
# remember, descent is a negative integer |
43
|
|
|
|
|
|
|
$d = ($ltr->getGlobalDescent() < $d)? $ltr->getGlobalDescent() : $d; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$w -= $wspace; # don't need the last wspace |
46
|
|
|
|
|
|
|
$self->{height} = $a+(-$d); |
47
|
|
|
|
|
|
|
$self->{width} = $w; |
48
|
|
|
|
|
|
|
$self->{ascent} = $a; |
49
|
|
|
|
|
|
|
$self->{descent} = $d; |
50
|
|
|
|
|
|
|
$self->{isUpdated} = 1; |
51
|
|
|
|
|
|
|
return 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _setText_parse { |
55
|
|
|
|
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
my %o = @_; |
57
|
|
|
|
|
|
|
my @text = split(//,$o{text}); |
58
|
|
|
|
|
|
|
foreach my $t (@text){ |
59
|
|
|
|
|
|
|
my $ltr = Imager::DTP::Letter->new(text=>$t,font=>$o{font}); |
60
|
|
|
|
|
|
|
push(@{$self->{letters}},$ltr); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |