our
$VERSION
=
'0.01'
;
name
=>
'header'
,
function
=>
sub
{
my
$self
=
shift
;
my
$header
= Lorem::Element::Header->new(
parent
=>
$self
,
@_
);
$self
->set_header(
$header
);
return
$header
;
}
};
name
=>
'page'
,
function
=>
sub
{
my
$self
=
shift
;
my
$new
= Lorem::Element::Page->new(
parent
=>
$self
,
width
=>
$self
->width,
style
=>
$self
->style->clone );
$new
->set_margin_top(
$self
->margin_top );
$new
->set_margin_left(
$self
->margin_left );
$new
->set_margin_right(
$self
->margin_right );
$new
->set_margin_bottom(
$self
->margin_bottom );
$new
->set_header_margin(
$self
->header_margin );
$new
->set_footer_margin(
$self
->footer_margin );
$new
->set_header(
$self
->header->clone )
if
$self
->header;
$self
->append_element(
$new
);
return
$new
;
}
};
has
'+parent'
=> (
required
=> 0,
);
has
'builder_func'
=> (
is
=>
'rw'
,
isa
=>
'CodeRef'
,
writer
=>
'build'
,
reader
=>
'builder_func'
,
);
sub
doc {
$_
[0] }
sub
inner_width {
$_
[0]->width -
$_
[0]->margin_left -
$_
[0]->margin_right;
}
sub
inner_height {
$_
[0]->height -
$_
[0]->margin_top -
$_
[0]->margin_bottom;
}
sub
margin_left_pos {
$_
[0]->margin_left;
}
sub
margin_right_pos {
$_
[0]->width -
$_
[0]->margin_right;
}
sub
margin_top_pos {
$_
[0]->margin_top;
}
sub
margin_bottom_pos {
$_
[0]->height -
$_
[0]->margin_bottom;
}
sub
margin_center_pos {
$_
[0]->margin_left_pos + (
$_
[0]->inner_width / 2 );
}
sub
imprint_header {
my
(
$self
,
@args
) =
@_
;
$_
[0]->header->imprint(
$_
[0],
@args
)
if
$_
[0]->header;
}
sub
imprint_footer {
$_
[0]->footer->imprint(
$_
[0] )
if
$_
[0]->footer;
}
sub
draw_page{
my
(
$self
,
$cr
,
$i
) =
@_
;
$_
[0]->children->[
$i
]->imprint(
$cr
);
}
1;