More work

This commit is contained in:
Dianne Skoll
2022-01-27 10:23:30 -05:00
parent 2f8eaeacf0
commit 9d9bdabf79
2 changed files with 67 additions and 17 deletions
+49 -1
View File
@@ -2,6 +2,10 @@ package Remind::PDF::Entry;
use strict;
use warnings;
use Cairo;
use Pango;
use Encode;
sub new_from_hash
{
my ($class, $hash) = @_;
@@ -14,7 +18,7 @@ sub new_from_hash
$class = 'Remind::PDF::Entry::UNKNOWN';
}
}
bless($hash, $class);
bless $hash, $class;
$hash->adjust();
return $hash;
}
@@ -28,6 +32,32 @@ sub adjust
$self->{b} = 0;
}
sub render
{
my ($self, $month, $cr, $settings, $so_far, $day, $col, $height) = @_;
my ($x1, $y1, $x2, $y2) = $month->col_box_coordinates($so_far, $col, $height, $settings);
my $layout = Pango::Cairo::create_layout($cr);
$layout->set_width(1024 * ($x2 - $x1 - 2 * $settings->{border_size}));
$layout->set_wrap('word-char');
$layout->set_text(Encode::decode('UTF-8', $self->{body}));
my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . $settings->{entry_size});
$layout->set_font_description($desc);
my ($wid, $h) = $layout->get_pixel_size();
if ($height) {
$cr->save();
$cr->set_source_rgb($self->{r} / 255,
$self->{g} / 255,
$self->{b} / 255);
$cr->move_to($x1 + $settings->{border_size}, $so_far);
Pango::Cairo::show_layout($cr, $layout);
$cr->restore();
}
return $h;
}
package Remind::PDF::Entry::html;
use base 'Remind::PDF::Entry';
package Remind::PDF::Entry::htmlclass;
@@ -36,6 +66,24 @@ package Remind::PDF::Entry::week;
use base 'Remind::PDF::Entry';
package Remind::PDF::Entry::moon;
use base 'Remind::PDF::Entry';
sub adjust {
my ($self) = @_;
my ($phase, $size, $fontsize, $msg) = split(/\s+/, $self->{body}, 4);
$phase = '' unless defined($phase);
$size = -1 unless defined($size);
$fontsize = -1 unless defined($fontsize);
$msg = '' unless defined($msg);
$self->{phase} = $phase;
$self->{size} = $size;
$self->{fontsize} = $fontsize;
$self->{body} = $msg;
}
sub render
{
my ($self) = @_;
return 0;
}
package Remind::PDF::Entry::shade;
use base 'Remind::PDF::Entry';
sub adjust