App-Guiio
view release on metacpan or search on metacpan
lib/App/Guiio.pm view on Meta::CPAN
[
[[250, 221, 190], [250, 245, 239]],
[[182, 250, 182], [241, 250, 241]],
[[185, 219, 250], [244, 247, 250]],
[[137, 250, 250], [235, 250, 250]],
[[198, 229, 198], [239, 243, 239]],
],
connection => 'Chocolate',
connection_point => [230, 198, 133],
connector_point => 'DodgerBlue',
extra_point => [230, 198, 133],
},
NEXT_GROUP_COLOR => 0,
WORK_DIRECTORY => '.guiio_work_dir',
CREATE_BACKUP => 1,
MODIFIED => 0,
DO_STACK_POINTER => 0,
DO_STACK => [] ,
}, __PACKAGE__ ;
$drawing_area->can_focus(TRUE) ;
$drawing_area->signal_connect(configure_event => \&configure_event, $self);
$drawing_area->signal_connect(expose_event => \&expose_event, $self);
$drawing_area->signal_connect(motion_notify_event => \&motion_notify_event, $self);
$drawing_area->signal_connect(button_press_event => \&button_press_event, $self);
$drawing_area->signal_connect(button_release_event => \&button_release_event, $self);
$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 event_options_changed
{
my ($self) = @_;
my $number_of_group_colors = scalar(@{$self->{COLORS}{group_colors}}) ;
$self->{GROUP_COLORS} = [0 .. $number_of_group_colors - 1] ,
$self->{CURRENT_ACTIONS} = $self->{ACTIONS} ;
$self->set_font($self->{FONT_FAMILY}, $self->{FONT_SIZE});
}
#-----------------------------------------------------------------------------
sub destroy
{
my ($self) = @_;
$self->{widget}->get_toplevel()->destroy() ;
}
#-----------------------------------------------------------------------------
sub set_title
{
my ($self, $title) = @_;
if(defined $title)
{
$self->{widget}->get_toplevel()->set_title($title . ' - guiio') ;
$self->{TITLE} = $title ;
}
}
sub get_title
{
my ($self) = @_;
$self->{TITLE} ;
}
#-----------------------------------------------------------------------------
sub set_font
{
my ($self, $font_family, $font_size) = @_;
$self->{FONT_FAMILY} = $font_family || 'Monospace';
$self->{FONT_SIZE} = $font_size || 10 ;
$self->{widget}->modify_font
(
Gtk2::Pango::FontDescription->from_string
(
$self->{FONT_FAMILY} . ' ' . $self->{FONT_SIZE}
)
);
}
sub get_font
{
my ($self) = @_;
return($self->{FONT_FAMILY}, $self->{FONT_SIZE}) ;
}
#-----------------------------------------------------------------------------
sub update_display
{
my ($self) = @_;
my $widget = $self->{widget} ;
$self->call_hook('CANONIZE_CONNECTIONS', $self->{CONNECTIONS}, $self->get_character_size()) ;
$widget->queue_draw_area(0, 0, $widget->allocation->width,$widget->allocation->height);
}
#-----------------------------------------------------------------------------
sub call_hook
{
my ($self, $hook_name, @arguments) = @_;
$self->{HOOKS}{$hook_name}->(@arguments) if (exists $self->{HOOKS}{$hook_name}) ;
}
#-----------------------------------------------------------------------------
sub configure_event
{
my ($widget, $event, $self) = @_;
$self->{PIXMAP} = Gtk2::Gdk::Pixmap->new
(
$widget->window,
$widget->allocation->width, $widget->allocation->height,
-1
);
$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'));
( run in 0.405 second using v1.01-cache-2.11-cpan-5735350b133 )