EekBoek
view release on metacpan or search on metacpan
lib/EB/Wx/Shell/MainFrame.pm view on Meta::CPAN
$self->__set_properties();
$self->__do_layout();
Wx::Event::EVT_BUTTON($self, $self->{b_edit}->GetId, \&OnEdit);
Wx::Event::EVT_TEXT_ENTER($self, $self->{t_input}->GetId, \&OnTextEnter);
Wx::Event::EVT_BUTTON($self, $self->{b_send}->GetId, \&OnSend);
# end wxGlade
Wx::Event::EVT_MENU($self, wxID_OPEN, \&OnOpen);
Wx::Event::EVT_MENU($self, wxID_PREFERENCES, \&OnPrefs);
Wx::Event::EVT_MENU($self, wxID_EXIT, \&OnQuit);
Wx::Event::EVT_MENU($self, wxID_CLEAR, \&OnClear);
Wx::Event::EVT_MENU($self, MENU_INPUTEDIT, \&OnEdit);
Wx::Event::EVT_MENU($self, MENU_INPUTEXEC, \&OnSend);
Wx::Event::EVT_MENU($self, MENU_REP_TRIAL, \&OnTrial);
my $i = -1;
for ( MENU_REP_BAL_ACT, MENU_REP_BAL_MGP,
MENU_REP_BAL_GRP, MENU_REP_BAL_GAC,) {
my $sub = $i++;
Wx::Event::EVT_MENU($self, $_, sub { push(@_, $sub); &OnMenuBal });
}
$i = -1;
for ( MENU_REP_RES_ACT, MENU_REP_RES_MGP,
MENU_REP_RES_GRP, MENU_REP_RES_GAC,) {
my $sub = $i++;
Wx::Event::EVT_MENU($self, $_, sub { push(@_, $sub); &OnMenuRes });
}
Wx::Event::EVT_MENU($self, MENU_REP_JNL, \&OnJournal);
Wx::Event::EVT_MENU($self, MENU_REP_UN, \&OnMenuUns);
Wx::Event::EVT_MENU($self, MENU_REP_AP, \&OnMenuAP);
Wx::Event::EVT_MENU($self, MENU_REP_AR, \&OnMenuAR);
Wx::Event::EVT_MENU($self, MENU_REP_VAT, \&OnMenuVAT);
Wx::Event::EVT_MENU($self, wxID_HELP, \&OnHelp);
Wx::Event::EVT_MENU($self, MENU_HELP_SUPPORT, \&OnSupport);
Wx::Event::EVT_MENU($self, wxID_ABOUT, \&OnAbout);
#### End of MenuBar
Wx::Event::EVT_CLOSE($self, \&OnQuit);
Wx::Event::EVT_CHAR($self->{t_input}, sub { $self->OnChar(@_) });
# Wx::Event::EVT_IDLE($self, \&OnIdle);
# On MacOS, we cannot open arbitrary files due to sandboxing
# constraints.
if ( $is_macos ) {
$self->{menubar}->FindItem(wxID_OPEN) ->Enable(0);
}
$prefctl ||=
{
repwin => 0,
errorpopup => 1,
warnpopup => 1,
infopopup => 0,
histlines => 200,
};
$self->SetSize(801, 551);
$self->sizepos_restore("main");
return $self;
}
sub __set_menubar {
my $self = shift;
# Unfortunately, due to an error in wxGlade sub-menu
# generation we need to do it ourselves. All...
$self->{menubar} = Wx::MenuBar->new();
my $wxglade_tmp_menu;
$wxglade_tmp_menu = Wx::Menu->new();
$wxglade_tmp_menu->Append(wxID_OPEN, _T("&Open\tCtrl-O"), "");
$wxglade_tmp_menu->AppendSeparator();
$wxglade_tmp_menu->Append(wxID_PREFERENCES, _T("Voorkeuren..."), "");
$wxglade_tmp_menu->AppendSeparator();
$wxglade_tmp_menu->Append(wxID_EXIT, _T("Afsluiten\tCtrl-Q"), "");
$self->{menubar}->Append($wxglade_tmp_menu, _T("&Bestand"));
$wxglade_tmp_menu = Wx::Menu->new();
$wxglade_tmp_menu->Append(MENU_INPUTEDIT, _T("&Edit invoerregel\tCtrl+Enter"), "");
$wxglade_tmp_menu->Append(MENU_INPUTEXEC, _T("&Uitvoeren invoerregel\tEnter"), "");
$wxglade_tmp_menu->AppendSeparator();
$wxglade_tmp_menu->Append(wxID_CLEAR, _T("Uitvoer schoonmaken"), "");
$self->{menubar}->Append($wxglade_tmp_menu, _T("B&ewerken"));
$self->{Reports} = Wx::Menu->new();
$self->{Reports}->Append(MENU_REP_TRIAL, _T("Proef- en Saldibalans"), "");
$self->{Reports_bal} = Wx::Menu->new();
$self->{Reports_bal}->Append(MENU_REP_BAL_ACT, _T("Op grootboekrekening"), "");
$self->{Reports_bal}->AppendSeparator();
$self->{Reports_bal}->Append(MENU_REP_BAL_MGP, _T("Op hoofdverdichting"), "");
$self->{Reports_bal}->Append(MENU_REP_BAL_GRP, _T("Op verdichting"), "");
$self->{Reports_bal}->Append(MENU_REP_BAL_GAC, _T("Gedetailleerd"), "");
$self->{Reports}->Append(Wx::NewId(), _T("Balans"), $self->{Reports_bal}, "");
$self->{Reports_res} = Wx::Menu->new();
$self->{Reports_res}->Append(MENU_REP_RES_ACT, _T("Op grootboekrekening"), "");
$self->{Reports_res}->AppendSeparator();
$self->{Reports_res}->Append(MENU_REP_RES_MGP, _T("Op hoofdverdichting"), "");
$self->{Reports_res}->Append(MENU_REP_RES_GRP, _T("Op verdichting"), "");
$self->{Reports_res}->Append(MENU_REP_RES_GAC, _T("Gedetailleerd"), "");
$self->{Reports}->Append(Wx::NewId(), _T("Verlies/Winst"), $self->{Reports_res}, "");
$self->{Reports}->AppendSeparator();
$self->{Reports}->Append(MENU_REP_JNL, _T("Journaal"), "");
$self->{Reports}->AppendSeparator();
$self->{Reports}->Append(MENU_REP_UN, _T("Openstaande posten"), "");
$self->{Reports}->AppendSeparator();
$self->{Reports}->Append(MENU_REP_AP, _T("Crediteuren"), "");
$self->{Reports}->Append(MENU_REP_AR, _T("Debiteuren"), "");
$self->{Reports}->AppendSeparator();
$self->{Reports}->Append(MENU_REP_VAT, _T("BTW Aangifte"), "");
$self->{menubar}->Append($self->{Reports}, _T("&Rapporten"));
$wxglade_tmp_menu = Wx::Menu->new();
$wxglade_tmp_menu->Append(wxID_HELP, _T("&Hulp..."), "");
$wxglade_tmp_menu->AppendSeparator();
$wxglade_tmp_menu->Append(MENU_HELP_SUPPORT, _T("Ondersteuning..."), "");
$wxglade_tmp_menu->AppendSeparator();
lib/EB/Wx/Shell/MainFrame.pm view on Meta::CPAN
sub ShowText {
my ($self, $text, $colour) = @_;
if ( $colour ) {
my $t = Wx::TextAttr->new;
$t->SetTextColour($colour);
my $x0 = $self->{t_output}->GetLastPosition;
$self->{t_output}->AppendText($text."\n");
$self->{t_output}->SetStyle($x0, $self->{t_output}->GetLastPosition, $t);
}
else {
$self->{t_output}->AppendText($text."\n");
}
}
my $capturing;
sub process_stdout {
my ($self, $text) = @_;
my $out = decode("utf-8", $text);
# warn("app: $out\n");
if ( $capturing || $out eq "<html>" ) {
$capturing .= $out . "\n";
if ( $out eq "<html>" ) {
$self->SetCursor(wxHOURGLASS_CURSOR);
}
elsif ( $out eq "</html>" ) {
$self->SetCursor(wxNullCursor);
my ($title) = ($capturing =~ m{<title>(.+?)</title>});
#warn("captured $title: ", length($capturing), " characters\n");
my $panel = $self->{prefs_repwin} ? "d_htmlpanel" : "d_htmlpanel_$title";
$self->{$panel} ||= EB::Wx::Shell::HtmlViewer->new
($self, -1, $title);
$self->{$panel}->Show(0);
$self->{$panel}->html->SetPage($capturing);
$self->{$panel}->htmltext = $capturing;
$self->{$panel}->SetTitle($title);
$self->{$panel}->Show(1);
$capturing = "";
}
}
else {
$self->{t_output}->AppendText($out."\n");
}
}
sub process_stderr {
my ($self, $text) = @_;
my $out = decode("utf-8", $text);
# warn("err: $out\n");
$self->ProcessMessages($out);
}
sub ProcessMessages {
my ($self, $err) = @_;
return unless $err;
my @err = split(/\n+/, $err);
while ( @err ) {
$err = shift(@err);
my @i;
if ( $err =~ /^\?+(.*)/ ) {
$self->ShowText($err, wxRED);
next unless $self->{prefs_errorpopup};
@i = ($1, _T("Fout"), wxOK|wxICON_ERROR);
}
elsif ( $err =~ /^\!+(.*)/ ) {
$self->ShowText($err, Wx::Colour->new("magenta"));
next unless $self->{prefs_warnpopup};
@i = ($1, _T("Waarschuwing"), wxOK|wxICON_WARNING);
}
else {
$self->ShowText($err, wxGREEN);
next unless $self->{prefs_infopopup};
@i = ($err, _T("Mededeling"), wxOK|wxICON_INFORMATION);
}
my $md = Wx::MessageDialog->new($self, @i, wxDefaultPosition);
$md->ShowModal;
$md->Destroy;
}
}
sub OnTextEnter {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnTextEnter <event_handler>
my $cmd = $self->{t_input}->GetValue;
return unless $cmd;
push(@{$self->{_cmd}}, $cmd)
unless $cmd eq $self->{_cmd}->[-1];
$self->{_cmdptr} = $#{$self->{_cmd}} + 1;
$self->{t_input}->SetValue("");
$cmd =~ s/ *\t */ /g;
$self->RunCommand($cmd);
$self->{t_input}->SetFocus();
# end wxGlade
}
sub OnSend {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnSend <event_handler>
&OnTextEnter;
# end wxGlade
}
sub OnEdit {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnEdit <event_handler>
my $d = $self->{d_editdialog} ||= EB::Wx::Shell::EditDialog->new;
my $t = $self->{t_input}->GetValue;
$t =~ s/\t/\n/g;
$d->{t_input}->SetValue($t);
$d->{t_input}->SetInsertionPoint( $self->{t_input}->GetInsertionPoint );
$d->{t_input}->SetFocus;
my $ret = $d->ShowModal;
$d->Show(0);
return unless $ret == wxID_APPLY;
$t = $d->{t_input}->GetValue;
$t =~ s/\n/\t/g;
$self->{t_input}->SetValue($t);
&OnTextEnter;
# end wxGlade
( run in 2.204 seconds using v1.01-cache-2.11-cpan-364913b4093 )