line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Khonsu::Page::Header; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
36
|
use parent 'Khonsu::Text'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub attributes { |
6
|
8
|
|
|
8
|
0
|
22
|
my ($a) = shift; |
7
|
|
|
|
|
|
|
return ( |
8
|
|
|
|
|
|
|
$a->SUPER::attributes(), |
9
|
8
|
|
|
8
|
|
22
|
active => {$a->RW, $a->BOOL, default => sub { 1 }}, |
10
|
8
|
|
|
|
|
40
|
show_page_num => {$a->RW, $a->STR}, |
11
|
|
|
|
|
|
|
page_num_text => {$a->RW, $a->STR}, |
12
|
|
|
|
|
|
|
padding => {$a->RW, $a->NUM}, |
13
|
|
|
|
|
|
|
cb => {$a->RW, $a->CODE}, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub render { |
18
|
89
|
|
|
89
|
0
|
249
|
my ($self, $file) = @_; |
19
|
89
|
100
|
|
|
|
393
|
return unless $self->active; |
20
|
86
|
|
|
|
|
407
|
my $y = ($self->h / 2) - ($self->font->size / 2); |
21
|
86
|
50
|
|
|
|
419
|
my $w = $file->page->w - ($self->padding ? ( $self->padding * 2 ) : $self->padding); |
22
|
86
|
|
50
|
|
|
457
|
my $x = $self->padding || 0; |
23
|
|
|
|
|
|
|
|
24
|
86
|
50
|
|
|
|
443
|
if ($self->show_page_num) { |
25
|
86
|
|
|
|
|
280
|
$self->add( |
26
|
|
|
|
|
|
|
$file, |
27
|
|
|
|
|
|
|
text => $self->process_page_num_text($file), |
28
|
|
|
|
|
|
|
y => $y, |
29
|
|
|
|
|
|
|
w => $w, |
30
|
|
|
|
|
|
|
x => $x, |
31
|
|
|
|
|
|
|
align => $self->show_page_num |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
86
|
50
|
|
|
|
586
|
$self->cb->( |
36
|
|
|
|
|
|
|
$self, |
37
|
|
|
|
|
|
|
$file, |
38
|
|
|
|
|
|
|
y => $y, |
39
|
|
|
|
|
|
|
w => $w, |
40
|
|
|
|
|
|
|
x => $x, |
41
|
|
|
|
|
|
|
) if ($self->cb); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub process_page_num_text { |
45
|
172
|
|
|
172
|
0
|
353
|
my ($self, $file) = @_; |
46
|
172
|
50
|
|
|
|
639
|
if ($self->page_num_text) { |
47
|
172
|
|
|
|
|
618
|
my $num = $file->page->num; |
48
|
172
|
|
|
|
|
741
|
(my $text = $self->page_num_text) =~ s/\{num\}/$num/g; |
49
|
172
|
|
|
|
|
1283
|
return $text; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
0
|
return $file->page->num; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub clone { |
55
|
170
|
|
|
170
|
0
|
401
|
my ($self) = @_; |
56
|
170
|
|
|
|
|
538
|
$self = $self->SUPER::clone(); |
57
|
170
|
|
|
|
|
1148
|
$self->active(1); |
58
|
170
|
|
|
|
|
860
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
show_page_num => 'right', |
63
|
|
|
|
|
|
|
page_num_text => 'page {num]', |
64
|
|
|
|
|
|
|
h => 20, |
65
|
|
|
|
|
|
|
cb => sub { |
66
|
|
|
|
|
|
|
my ($self, %atts) = @_; |
67
|
|
|
|
|
|
|
$self->add_text( |
68
|
|
|
|
|
|
|
text => 'Khonsu', |
69
|
|
|
|
|
|
|
align => 'center', |
70
|
|
|
|
|
|
|
%attrs, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |