line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Imager::DTP::Textbox::Vertical; |
2
|
1
|
|
|
1
|
|
2292
|
use base Imager::DTP::Textbox; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
3
|
1
|
|
|
1
|
|
526
|
use Imager::DTP::Line::Vertical; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use strict; |
5
|
|
|
|
|
|
|
use vars qw($VERSION); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _draw_drawLines { |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
my %o = @_; |
12
|
|
|
|
|
|
|
my $i=0; |
13
|
|
|
|
|
|
|
my $x=($o{x})? $o{x} : 0; |
14
|
|
|
|
|
|
|
my $y=($o{y})? $o{y} : 0; |
15
|
|
|
|
|
|
|
# draw box for debug |
16
|
|
|
|
|
|
|
if($o{debug}){ |
17
|
|
|
|
|
|
|
my $dbgx = $self->_draw_getAlignPos(x=>$x); |
18
|
|
|
|
|
|
|
my $width = ($self->getWrapWidth())? $self->getWrapWidth() : $self->_getWidth(); |
19
|
|
|
|
|
|
|
my $height = ($self->getWrapHeight())? $self->getWrapHeight() : $self->_getHeight(); |
20
|
|
|
|
|
|
|
$o{target}->box(filled=>1,color=>'#BBBBBB',xmin=>$dbgx-$width,ymin=>$y, |
21
|
|
|
|
|
|
|
xmax=>$dbgx,ymax=>$y+$height); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
my $lineWidth = $self->_getMaxLetterSize(); |
24
|
|
|
|
|
|
|
my $lineSpace = $self->_calcLineSpace(); |
25
|
|
|
|
|
|
|
foreach my $line (@{$self->getLines()}){ |
26
|
|
|
|
|
|
|
# line flaws from right to left |
27
|
|
|
|
|
|
|
$x -= $lineSpace if($i > 0); |
28
|
|
|
|
|
|
|
$x -= $lineWidth; |
29
|
|
|
|
|
|
|
# vertical align |
30
|
|
|
|
|
|
|
my $liney = $y; |
31
|
|
|
|
|
|
|
if($self->getValign() eq 'bottom'){ |
32
|
|
|
|
|
|
|
$liney += $self->_getHeight() - $line->getHeight(); |
33
|
|
|
|
|
|
|
}elsif($self->getValign() eq 'center'){ |
34
|
|
|
|
|
|
|
$liney += ( $self->_getHeight() - $line->getHeight() )/2; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
# horizontal align |
37
|
|
|
|
|
|
|
my $linex = $self->_draw_getAlignPos(x=>$x); |
38
|
|
|
|
|
|
|
# draw line |
39
|
|
|
|
|
|
|
$line->draw(target=>$o{target},x=>$linex,y=>$liney,leading=>$lineWidth, |
40
|
|
|
|
|
|
|
others=>$o{others},debug=>$o{debug}) or die $line->errstr; |
41
|
|
|
|
|
|
|
$i++; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
return 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _draw_getAlignPos { |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
my %o = @_; |
49
|
|
|
|
|
|
|
if($self->getHalign() eq 'left'){ |
50
|
|
|
|
|
|
|
$o{x} += $self->_getWidth(); |
51
|
|
|
|
|
|
|
}elsif($self->getHalign() eq 'center'){ |
52
|
|
|
|
|
|
|
$o{x} += $self->_getWidth()/2; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
return $o{x}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _draw_getStartPos { |
58
|
|
|
|
|
|
|
my $self = shift; |
59
|
|
|
|
|
|
|
my %o = @_; |
60
|
|
|
|
|
|
|
if($self->getValign() eq 'bottom'){ |
61
|
|
|
|
|
|
|
return ($o{x},$o{y}-$self->_getHeight()); |
62
|
|
|
|
|
|
|
}elsif($self->getValign() eq 'center'){ |
63
|
|
|
|
|
|
|
return ($o{x},$o{y} - ($self->_getHeight()/2) ); |
64
|
|
|
|
|
|
|
}else{ |
65
|
|
|
|
|
|
|
return ($o{x},$o{y}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _calcWidthHeight { |
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
return undef if($self->{isUpdated}); |
72
|
|
|
|
|
|
|
foreach my $line (@{$self->getLines()}){ |
73
|
|
|
|
|
|
|
$line->_calcWidthHeight(); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
my $lineWidth = $self->_getMaxLetterSize(); |
76
|
|
|
|
|
|
|
my $lineSpace = $self->_calcLineSpace(); |
77
|
|
|
|
|
|
|
my($w,$h,$i) = qw(0 0 0); |
78
|
|
|
|
|
|
|
foreach my $line (@{$self->getLines()}){ |
79
|
|
|
|
|
|
|
$w += $lineWidth; |
80
|
|
|
|
|
|
|
$w += $lineSpace if ($i < $#{$self->getLines()}); |
81
|
|
|
|
|
|
|
$h = ($line->getHeight() > $h) ? $line->getHeight() : $h; |
82
|
|
|
|
|
|
|
$i++; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
$self->{width} = $w; |
85
|
|
|
|
|
|
|
$self->{height} = $h; |
86
|
|
|
|
|
|
|
$self->{isUpdated} = 1; |
87
|
|
|
|
|
|
|
return 1; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _calcWrap_LetterStack_getWrapMax { |
91
|
|
|
|
|
|
|
return shift->getWrapHeight(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _calcWrap_LetterStack_getLineMax { |
95
|
|
|
|
|
|
|
my $self = shift; |
96
|
|
|
|
|
|
|
my %o = @_; |
97
|
|
|
|
|
|
|
return $o{line}->getHeight(); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _calcWrap_LetterStack_getLetterSize { |
101
|
|
|
|
|
|
|
my $self = shift; |
102
|
|
|
|
|
|
|
my %o = @_; |
103
|
|
|
|
|
|
|
return $o{letter}->getGlobalAscent() - $o{letter}->getGlobalDescent(); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _calcWrap_LineStack_getWrapMax { |
107
|
|
|
|
|
|
|
return shift->getWrapWidth(); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _setAlign_setDefault { |
111
|
|
|
|
|
|
|
my $self = shift; |
112
|
|
|
|
|
|
|
$self->{halign} = 'right' if(!$self->{halign}); |
113
|
|
|
|
|
|
|
$self->{valign} = 'top' if(!$self->{valign}); |
114
|
|
|
|
|
|
|
return 1; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _getMaxLetterSize { |
118
|
|
|
|
|
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
my $widest=0; |
120
|
|
|
|
|
|
|
foreach my $line (@{$self->getLines()}){ |
121
|
|
|
|
|
|
|
$widest = ($line->getWidth() > $widest)? $line->getWidth() : $widest; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
return $widest; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _getNewLineInstance { |
127
|
|
|
|
|
|
|
my $self = shift; |
128
|
|
|
|
|
|
|
return Imager::DTP::Line::Vertical->new(@_); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
__END__ |