diff --git a/rem2pdf/lib/Remind/PDF/Entry.pm b/rem2pdf/lib/Remind/PDF/Entry.pm index db7fc619..2236d818 100644 --- a/rem2pdf/lib/Remind/PDF/Entry.pm +++ b/rem2pdf/lib/Remind/PDF/Entry.pm @@ -64,6 +64,14 @@ package Remind::PDF::Entry::htmlclass; use base 'Remind::PDF::Entry'; package Remind::PDF::Entry::week; use base 'Remind::PDF::Entry'; + +sub render +{ + my ($self, $month, $cr, $settings, $so_far, $day, $col, $height) = @_; + # Do nothing in pre-render mode + return 0 unless $height; +} + package Remind::PDF::Entry::moon; use base 'Remind::PDF::Entry'; diff --git a/rem2pdf/lib/Remind/PDF/Month.pm b/rem2pdf/lib/Remind/PDF/Month.pm index 8354cab4..98e42bc0 100644 --- a/rem2pdf/lib/Remind/PDF/Month.pm +++ b/rem2pdf/lib/Remind/PDF/Month.pm @@ -169,6 +169,9 @@ sub render # Line under the days push(@{$self->{horiz_lines}}, $so_far); + # Remaining space on page + $self->{remaining_space} = $settings->{height} - $settings->{margin_bottom} - $so_far; + # First column my $first_col = $self->{firstwkday}; if ($self->{mondayfirst}) { @@ -185,7 +188,6 @@ sub render my $rows = 1; my $last_day_on_row = 7 - $first_col; while ($last_day_on_row < $self->{daysinmonth}) { - print STDERR "$rows $last_day_on_row\n"; $last_day_on_row += 7; $rows++; } @@ -195,6 +197,9 @@ sub render $rows++; } + # Row height if we are filling the page + $self->{row_height} = $self->{remaining_space} / $rows; + my ($start_col, $start_day); for (my $row = 0; $row < $rows; $row++) { if ($row == 0) { @@ -203,7 +208,6 @@ sub render } else { $start_col = 0; } - print STDERR "Drawing row $row $start_day $start_col\n"; $so_far = $self->draw_row($cr, $settings, $so_far, $row, $start_day, $start_col); $start_day += 7 - $start_col; push(@{$self->{horiz_lines}}, $so_far); @@ -234,17 +238,21 @@ sub draw_row my $height = 0; # Preview them to figure out the row height... - while ($col < 7) { - my $h = $self->draw_day($cr, $settings, $so_far, $day, $col, 0); - $height = $h if ($h > $height); - $day++; - $col++; - last if ($day > $self->{daysinmonth}); + if (!$settings->{fill_entire_page}) { + while ($col < 7) { + my $h = $self->draw_day($cr, $settings, $so_far, $day, $col, 0); + $height = $h if ($h > $height); + $day++; + $col++; + last if ($day > $self->{daysinmonth}); + } + $col = $start_col; + $day = $start_day; + } else { + $height = $self->{row_height} - $settings->{border_size}; } # Now draw for real - $col = $start_col; - $day = $start_day; while ($col < 7) { $self->draw_day($cr, $settings, $so_far, $day, $col, $height); $day++; @@ -314,11 +322,16 @@ sub draw_day my $entry_height = 0; my $done = 0; foreach my $entry (@{$self->{entries}->[$day]}) { - # Moon should not adjust height - if ($entry->isa('Remind::PDF::Entry::moon')) { + # Moon and week should not adjust height + if ($entry->isa('Remind::PDF::Entry::moon') || + $entry->isa('Remind::PDF::Entry::week')) { $entry->render($self, $cr, $settings, $top, $day, $col, $height); next; } + # Shade is done already + if ($entry->isa('Remind::PDF::Entry::shade')) { + next; + } if ($done) { $so_far += $settings->{border_size}; $entry_height += $settings->{border_size}; diff --git a/tests/scripts.rem b/tests/scripts.rem index c67fc82b..7e1e44d2 100644 --- a/tests/scripts.rem +++ b/tests/scripts.rem @@ -1,4 +1,5 @@ REM 1 MSG Përkujtues +REM 2 SPECIAL SHADE 128 128 255 REM 2 MSG تذكير REM 3 MSG 提醒 REM 4 MSG રીમાઇન્ડર @@ -6,11 +7,15 @@ REM 5 MSG Emlékeztető REM 6 MSG Áminning REM 7 MSG תִזכּוֹרֶת REM 8 MSG अनुस्मारक -REM 9 MSG Эскертүү -REM 10 MSG Напоминание -REM 11 MSG Υπενθύμιση +REM 9 SPECIAL COLOR 0 0 128 Эскертүү +REM 10 SPECIAL COLOR 0 128 0 Напоминание +REM 11 SPECIAL COLOR 128 0 0 Υπενθύμιση + +REM 1 SPECIAL SHADE 128 255 128 REM [moondate(0)] SPECIAL MOON 0 REM [moondate(1)] SPECIAL MOON 1 REM [moondate(2)] SPECIAL MOON 2 -1 -1 [moontime(2)] REM [moondate(3)] SPECIAL MOON 3 -1 -1 [moontime(3)] + +REM Mon SPECIAL WEEK [weekno(today())] \ No newline at end of file