App-Asciio
view release on metacpan or search on metacpan
lib/App/Asciio/GTK/Asciio.pm view on Meta::CPAN
$drawing_area->signal_connect(key_press_event => \&key_press_event, $self);
$drawing_area->set_events
([qw/
exposure-mask
leave-notify-mask
button-press-mask
button-release-mask
pointer-motion-mask
key-press-mask
key-release-mask
/]);
$self->event_options_changed() ;
return($self) ;
}
#-----------------------------------------------------------------------------
sub destroy
{
my ($self) = @_;
$self->{widget}->get_toplevel()->destroy() ;
}
#-----------------------------------------------------------------------------
sub set_title
{
my ($self, $title) = @_;
$self->SUPER::set_title($title) ;
if(defined $title)
{
$self->{widget}->get_toplevel()->set_title($title . ' - asciio') ;
}
}
#-----------------------------------------------------------------------------
sub set_font
{
my ($self, $font_family, $font_size) = @_;
$self->SUPER::set_font($font_family, $font_size) ;
$self->{widget}->modify_font
(
Gtk2::Pango::FontDescription->from_string
(
$self->{FONT_FAMILY} . ' ' . $self->{FONT_SIZE}
)
);
}
#-----------------------------------------------------------------------------
sub update_display
{
my ($self) = @_;
$self->SUPER::update_display() ;
my $widget = $self->{widget} ;
$widget->queue_draw_area(0, 0, $widget->allocation->width,$widget->allocation->height);
}
#-----------------------------------------------------------------------------
sub configure_event
{
my ($widget, $event, $self) = @_;
$self->{PIXMAP} = Gtk2::Gdk::Pixmap->new
(
$widget->window,
$widget->allocation->width, $widget->allocation->height,
-1
);
$self->{WINDOW_SIZE} = [$widget->allocation->width, $widget->allocation->height] ;
$self->{PIXMAP}->draw_rectangle
(
$widget->get_style->base_gc ($widget->state),
TRUE, 0, 0, $widget->allocation->width,
$widget->allocation->height
);
return TRUE;
}
#-----------------------------------------------------------------------------
sub expose_event
{
my ($widget, $event, $self) = @_;
my $gc = Gtk2::Gdk::GC->new($self->{PIXMAP});
# draw background
$gc->set_foreground($self->get_color('background'));
$self->{PIXMAP}->draw_rectangle
(
$gc, TRUE,
0, 0,
$widget->allocation->width, $widget->allocation->height
);
my ($character_width, $character_height) = $self->get_character_size() ;
my ($widget_width, $widget_height) = $self->{PIXMAP}->get_size();
if($self->{DISPLAY_GRID})
{
$gc->set_foreground($self->get_color('grid'));
for my $horizontal (0 .. ($widget_height/$character_height) + 1)
( run in 0.633 second using v1.01-cache-2.11-cpan-3c2a17b8caa )