| 1 | package Khonsu::Page::Header; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use parent 'Khonsu::Text'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | sub attributes { | ||||||||||||
| 6 | 4 | ▶ | my ($a) = shift; | ||||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 7 | return ( | ||||||||||||
| 8 | $a->SUPER::attributes(), | ||||||||||||
| 9 | 4 | ▶ | active => {$a->RW, $a->BOOL, default => sub { 1 }}, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 4 | 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 | 121 | ▶ | my ($self, $file) = @_; | ||||||||||
|
Subroutine
render: called CC=6 SCAR=18.6
Pod
undocumented
| |||||||||||||
| 19 | 121 | ▶ | return unless $self->active; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 120 | my $y = ($self->h / 2) - ($self->font->size / 2); | |||||||||||
| 21 | 120 | ▶ | my $w = $file->page->w - ($self->padding ? ( $self->padding * 2 ) : $self->padding); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 120 | ▶ | my $x = $self->padding || 0; | ||||||||||
|
Condition50%1/2
$self->padding || 0
MC/DC0%0/1
$self->padding || 0
$self->padding
Truth table50%1/2
A
A= $self->padding
| |||||||||||||
| 23 | |||||||||||||
| 24 | 120 | ▶ | if ($self->show_page_num) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 120 | $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 | 120 | ▶ | $self->cb->( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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 | 240 | ▶ | my ($self, $file) = @_; | ||||||||||
|
Subroutine
process_page_num_text: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||
| 46 | 240 | ▶ | if ($self->page_num_text) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | 240 | my $num = $file->page->num; | |||||||||||
| 48 | 240 | (my $text = $self->page_num_text) =~ s/\{num\}/$num/g; | |||||||||||
| 49 | 240 | return $text; | |||||||||||
| 50 | } | ||||||||||||
| 51 | 0 | return $file->page->num; | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | sub clone { | ||||||||||||
| 55 | 238 | ▶ | my ($self) = @_; | ||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 56 | 238 | $self = $self->SUPER::clone(); | |||||||||||
| 57 | 238 | $self->active(1); | |||||||||||
| 58 | 238 | 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 | 3 | 1; | |||||||||||