G
Messenger
G::Messenger.pm G-language GAE Messaging API
|
Globals (from use vars definitions) |
@EXPORT |
$VERSION |
@EXPORT_OK |
Privates (from my definitions) |
$progress; |
$gimv = 'gimv' |
$term; |
%data; |
$console; |
use G::Messenger;
&msg_send("this is an output"); #prints message to STDOUT &msg_error("this is an error"); #prints message to STDERR &msg_gimv("graph.png"); #shows the image via gimv (G-language IMage Viewer)
|
Methods used in Odyssey:
msg_send(<message, can be an array of messages>) Prints out a regular output message. The output is STDOUT in CUI mode, and text output in Gtk+, wxWindows, and INSPIRE modes. Synonym of "print".
msg_error(<message, can be an array of messages>) Prints out an error or system message. The output is STDERR in CUI mode, and system console in Gtk+, wxWindows, and INSPIRE modes. Synonym of "print STDOUT".
msg_gimv(<image file name>) Shows the image via gimv (G-language IMage Viewer). The gimv program will startup in Gtk+ and wxWindows mode, and only the file path is passed on in INSPIRE mode. Synonym of "system('gimv image.png')".
Methods used in Engines:
msg_percent(<decimal>) Sets the progress bar to the given percentage.
Methods used in User Interfaces (INSPIRE):
msg_interface(<interface>) Sets the interface that the system currently uses. 'GUI' for Gtk+ mode, 'Wx' for wxWindows mode, 'Inspire' for INSPIRE mode, and none or 'STDOUT' for CUI mode. All Messenger output bases the interpretation of the current user interface on the value set with this function.
msg_system_console(<reference of system console>) In Gtk+ and wxWindows mode, system console widget instance should be supplied. In INSPIRE mode, the reference to a subroutine that interpret the job of system console should be supplied. Messages sent with msg_error() are passed to the given reference.
msg_term_console(<reference of term console>) In Gtk+ and wxWindows mode, term console widget instance should be supplied. In INSPIRE mode, the reference to a subroutine that interpret the job of term console should be supplied. Messages sent with msg_send() are passed to the given reference.
msg_progress(<reference of progress bar>) In Gtk+ and wxWindows mode, progress bar widget instance should be supplied. In INSPIRE mode, the reference to a subroutine that interpret the job of progress bar may be supplied. Messages sent with msg_percent() are passed to the given reference.
msg_set_gimv(<reference of gimv subroutine>) In INSPIRE mode, the reference to a subroutine that interpret the job of gimv should be supplied. Messages sent with msg_gimv() are passed to the given reference.
msg_ask_interface() Returns the current mode.
|
msg_ask_interface | No description | Code |
msg_error | No description | Code |
msg_gimv | No description | Code |
msg_interface | No description | Code |
msg_percent | No description | Code |
msg_progress | No description | Code |
msg_send | No description | Code |
msg_set_gimv | No description | Code |
msg_system_console | No description | Code |
msg_term_console | No description | Code |
Methods description
Methods code
msg_ask_interface | description | top | prev | next |
sub msg_ask_interface
{ return $data{"interface"};
}
sub msg_error
{ my @msg = @_;
if ($data{"interface"} eq 'STDOUT'){
print STDERR @msg;
}elsif ($data{"interface"} eq 'GUI'){
$data{"system"} .= join('', @msg);
$console->insert('','','',join('', @msg));
}elsif ($data{"interface"} eq 'Wx'){
my $tmp = join('', @msg);
$data{"system"} .= $tmp;
$console->WriteText(scalar($tmp));
}elsif ($data{'interface'} eq 'Inspire'){
my $tmp = join('', @msg);
$data{"system"} .= $tmp;
&$console($tmp);
}
}
sub msg_gimv
{ my $file = shift;
my $time = 'gimv' . time();
if ($data{"interface"} eq 'Inspire'){
&$gimv($file);
}else{
if('MSWin32' eq $^O){
my $dir = getcwd() unless (substr($file, 0, 1) eq '/');
my $filename = $dir . '/' . $file;
if ($filename =~ /[htm|html]$/){
$data{$time} = Win32::InternetExplorer::Window->new();
}else{
my ($x, $y) = Image::Size::imgsize($filename);
$data{$time} = Win32::InternetExplorer::Window->new(
height=>$y+60,
width=>$x+50
);
}
$data{$time}->display('\G-language\title.jpg');
$data{$time}->display_wait($filename);
}else{
$gimv = 'mozilla' if ($file =~ /html$/ && $gimv eq 'gimv');
$gimv = 'mozilla' if ($file =~ /svg$/ && $gimv eq 'gimv');
$file = 'file://' . getcwd() . '/' . $file if ($gimv eq 'mozilla');
system("$gimv $file &");
}
}
}
sub msg_interface
{ $data{"interface"} = shift;
}
sub msg_percent
{ my $percent = shift;
if ($data{"interface"} eq 'GUI'){
$progress->update($percent);
}elsif ($data{"interface"} eq 'Wx'){
$progress->SetValue($percent);
$progress->Refresh();
}
}
sub msg_progress
{ $progress = shift;
}
sub msg_send
{ my @msg = @_;
if ($data{"interface"} eq 'STDOUT'){
print STDOUT @msg;
}elsif ($data{"interface"} eq 'GUI'){
$data{"term"} .= join('',@msg);
$term->insert('','','',join('',@msg));
}elsif ($data{"interface"} eq 'Wx'){
my $tmp = join('', @msg);
$data{"term"} .= $tmp;
$term->WriteText(scalar($tmp));
}elsif ($data{'interface'} eq 'Inspire'){
my $tmp = join('', @msg);
$data{"term"} .= $tmp;
&$term($tmp);
}
}
sub msg_set_gimv
{ $gimv = shift;
}
sub msg_system_console
{ $console = shift;
}
msg_term_console | description | top | prev | next |
sub msg_term_console
{ $term = shift;
}
General documentation
INTRODUCTION |
top |
One of the key features of the G-language Genome Analysis Environment is the ease of use and development of different user interfaces. With very little modification, a script intended for commandline Perl use can be transformed into a cross-platform GUI application using wxWindows, or a web application using INSPIRE. The Messaging API G::Messenger.pm is what makes this possible. All output in the software system is passed to the interface provided by this API, and Messenger interprets the current user interface to give correct form of output. It is essential to create Odyssey Subroutines using this API, and to create new user interfaces.
|
AUTHOR |
top |
Kazuharu Gaou Arakawa, gaou@g-language.org
|
SEE ALSO |
top |
perl(1).
|