EekBoek
view release on metacpan or search on metacpan
lib/EB/Wx/Shell/MainFrame.pm view on Meta::CPAN
use constant MENU_INPUTEXEC => Wx::NewId();
use constant MENU_REP_TRIAL => Wx::NewId();
use constant MENU_REP_BAL_ACT => Wx::NewId();
use constant MENU_REP_BAL_MGP => Wx::NewId();
use constant MENU_REP_BAL_GRP => Wx::NewId();
use constant MENU_REP_BAL_GAC => Wx::NewId();
use constant MENU_REP_RES_ACT => Wx::NewId();
use constant MENU_REP_RES_MGP => Wx::NewId();
use constant MENU_REP_RES_GRP => Wx::NewId();
use constant MENU_REP_RES_GAC => Wx::NewId();
use constant MENU_REP_JNL => Wx::NewId();
use constant MENU_REP_UN => Wx::NewId();
use constant MENU_REP_AP => Wx::NewId();
use constant MENU_REP_AR => Wx::NewId();
use constant MENU_REP_VAT => Wx::NewId();
use constant MENU_HELP_SUPPORT => Wx::NewId();
# ###WARNING: Re-generating will loose
# $self->__set_menubar();
# insert before $self->{s_input_staticbox} = ...
# begin wxGlade: EB::Wx::Shell::MainFrame::new
$style = wxDEFAULT_FRAME_STYLE
unless defined $style;
$self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name );
$self->{p_dummy} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, );
$self->__set_menubar();
$self->{s_input_staticbox} = Wx::StaticBox->new($self->{p_dummy}, -1, _T("Invoer") );
$self->{statusbar} = $self->CreateStatusBar(1, wxST_SIZEGRIP);
$self->{t_output} = Wx::TextCtrl->new($self->{p_dummy}, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL);
$self->{b_edit} = Wx::BitmapButton->new($self->{p_dummy}, -1, (Wx::Bitmap->new("edit.png", wxBITMAP_TYPE_ANY)));
$self->{t_input} = Wx::TextCtrl->new($self->{p_dummy}, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB);
$self->{b_send} = Wx::BitmapButton->new($self->{p_dummy}, -1, (Wx::Bitmap->new("button_ok.png", wxBITMAP_TYPE_ANY)));
$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();
$wxglade_tmp_menu->Append(wxID_ABOUT, _T("Over..."), "");
$self->{menubar}->Append($wxglade_tmp_menu, _T("&Hulp"));
$self->SetMenuBar($self->{menubar});
}
sub __set_properties {
my $self = shift;
# begin wxGlade: EB::Wx::Shell::MainFrame::__set_properties
$self->SetTitle(_T("EekBoek"));
$self->SetSize(Wx::Size->new(800, 550));
$self->{statusbar}->SetStatusWidths(-1);
my( @statusbar_fields ) = (
""
);
if( @statusbar_fields ) {
$self->{statusbar}->SetStatusText($statusbar_fields[$_], $_)
for 0 .. $#statusbar_fields ;
}
$self->{b_edit}->SetSize($self->{b_edit}->GetBestSize());
$self->{t_input}->SetFocus();
$self->{b_send}->SetSize($self->{b_send}->GetBestSize());
# end wxGlade
my $f = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
$self->{t_output}->SetFont(Wx::Font->new($f->GetPointSize, wxMODERN, wxNORMAL, wxNORMAL, 0, ""));
}
sub __do_layout {
my $self = shift;
# begin wxGlade: EB::Wx::Shell::MainFrame::__do_layout
$self->{sz_dummy} = Wx::BoxSizer->new(wxHORIZONTAL);
$self->{s_main} = Wx::BoxSizer->new(wxVERTICAL);
$self->{s_layout} = Wx::BoxSizer->new(wxVERTICAL);
$self->{s_input}= Wx::StaticBoxSizer->new($self->{s_input_staticbox}, wxHORIZONTAL);
$self->{s_output} = Wx::BoxSizer->new(wxHORIZONTAL);
$self->{s_output}->Add($self->{t_output}, 1, wxEXPAND|wxADJUST_MINSIZE, 0);
$self->{s_layout}->Add($self->{s_output}, 1, wxEXPAND, 0);
$self->{s_input}->Add($self->{b_edit}, 0, wxRIGHT|wxADJUST_MINSIZE, 5);
$self->{s_input}->Add($self->{t_input}, 1, wxEXPAND|wxADJUST_MINSIZE, 0);
$self->{s_input}->Add($self->{b_send}, 0, wxLEFT|wxADJUST_MINSIZE, 5);
$self->{s_layout}->Add($self->{s_input}, 0, wxEXPAND, 0);
$self->{s_main}->Add($self->{s_layout}, 1, wxALL|wxEXPAND, 5);
$self->{p_dummy}->SetSizer($self->{s_main});
$self->{sz_dummy}->Add($self->{p_dummy}, 1, wxEXPAND, 0);
$self->SetSizer($self->{sz_dummy});
$self->Layout();
$self->SetSize(Wx::Size->new(800, 550));
# end wxGlade
}
sub RunCommand {
my ($self, $cmd) = @_;
unless ( defined $self->{_shell} ) {
unless ( $self->{_ebcfg} && -s $self->{_ebcfg} ) {
lib/EB/Wx/Shell/MainFrame.pm view on Meta::CPAN
$self->{"prefs_$_"} = $self->{d_prefs}->{"spin_$_"}->GetValue;
}
}
}
# end wxGlade
}
sub FillHistory {
my ($self, $histfile) = @_;
$self->{_histfile} = $histfile;
$self->{_cmd} = [];
$self->{_cmdptr} = 0;
if ( -s $histfile ) {
my $fh;
return unless open($fh, "<:encoding(utf-8)", $histfile);
my $prev = '';
while ( <$fh> ) {
chomp;
next if $_ eq $prev;
$self->PutOnHistory($_);
$prev = $_;
}
close($fh);
}
$self->{_cmdinit} = $self->{_cmdptr} = $#{$self->{_cmd}} + 1;
}
sub GetPreferences {
my ( $self ) = @_;
my $conf = Wx::ConfigBase::Get;
for ( keys( %$prefctl ) ) {
$self->{"prefs_$_"} = $conf->ReadInt( "preferences/$_", $prefctl->{$_} );
}
}
sub SaveHistory {
my $self = shift;
my $fh;
my $histfile = $self->{_histfile};
$self->{_cmdinit} = $self->{_cmdptr} - $self->{prefs_histlines};
$self->{_cmdinit} = 0 if $self->{_cmdinit} < 0;
return unless open($fh, ">:encoding(utf-8)", $histfile);
while ( $self->{_cmdinit} < $self->{_cmdptr} ) {
print { $fh } ($self->{_cmd}->[$self->{_cmdinit}], "\n");
$self->{_cmdinit}++;
}
close($fh);
}
sub SavePreferences {
my ( $self ) = @_;
my $conf = Wx::ConfigBase::Get;
for ( keys( %$prefctl ) ) {
$conf->WriteInt( "preferences/$_", $self->{"prefs_$_"} );
}
}
sub OnMenuBal {
my ($self, $event, $sub) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuBal <event_handler>
if ( defined $sub && $sub >= 0 ) {
$self->_cmd("balans --verdicht --detail=$sub --gen-wxhtml\n");
}
else {
$self->_cmd("balans --gen-wxhtml\n");
}
# end wxGlade
}
sub OnMenuRes {
my ($self, $event, $sub) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuRes <event_handler>
if ( defined $sub && $sub >= 0 ) {
$self->_cmd("result --verdicht --detail=$sub --gen-wxhtml\n");
}
else {
$self->_cmd("result --gen-wxhtml\n");
}
# end wxGlade
}
sub OnMenuAP {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuAP <event_handler>
$self->_cmd("crediteuren --gen-wxhtml\n");
# end wxGlade
}
sub OnMenuAR {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuAR <event_handler>
$self->_cmd("debiteuren --gen-wxhtml\n");
# end wxGlade
}
sub OnMenuVAT {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuAR <event_handler>
$self->_cmd("btwaangifte --gen-wxhtml\n");
# end wxGlade
}
sub OnMenuUns {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnMenuUns <event_handler>
$self->_cmd("openstaand --gen-wxhtml\n");
# end wxGlade
}
sub OnTrial {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnTrial <event_handler>
$self->_cmd("proefensaldibalans --gen-wxhtml\n");
# end wxGlade
}
sub OnJournal {
my ($self, $event) = @_;
# wxGlade: EB::Wx::Shell::MainFrame::OnJournal <event_handler>
$self->_cmd("journaal --gen-wxhtml\n");
# end wxGlade
}
#### Callbacks from HTML links
sub _HTMLCallBack {
my ($self, $command, $args) = @_;
my $cmd = $command;
$cmd .= " " . delete($args->{select});
while ( my($k,$v) = each( %$args ) ) {
$cmd .= " --$k=$v";
}
$cmd .= " --gen-wxhtml";
$self->_cmd($cmd."\n");
}
sub ShowRJnl { shift->_HTMLCallBack( "journaal", @_ ) }
sub ShowRGbk { shift->_HTMLCallBack( "grootboek", @_ ) }
sub ShowRCrd { shift->_HTMLCallBack( "crediteuren", @_ ) }
sub ShowRDeb { shift->_HTMLCallBack( "debiteuren", @_ ) }
sub ShowRAtt {
my ( $self, $args ) = @_;
$self->_cmd("bijlage " . $args->{select});
}
# end of class EB::Wx::Shell::MainFrame
1;
( run in 0.624 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )