App-InvestSim
view release on metacpan or search on metacpan
lib/App/InvestSim/GUI.pm view on Meta::CPAN
$display_table->m_heading("#${c}", -text => $headings[$c]);
$display_table->m_column("#${c}", -width => $width, -anchor => 'e');
}
}
# Finally, we create a small menu.
{
my $menu = $root->new_menu;
$root->configure(-menu => $menu);
my $file = $menu->new_menu;
$menu->m_add_cascade(-menu => $file, -label => "Fichier", -underline => 0);
$file->m_add_command(-label => "Nouveau", -accelerator => 'Ctrl+N', -underline => 0,
-command => sub { init_values(); refresh_all_fields() });
$root->g_bind('<Control-n>', sub { init_values(); refresh_all_fields() });
$file->m_add_command(-label => "Ouvrir...", -accelerator => 'Ctrl+O', -underline => 0,
-command => sub { open_values(); refresh_all_fields() });
$root->g_bind('<Control-o>', sub { open_values(); refresh_all_fields() });
$file->m_add_command(-label => "Enregistrer", -accelerator => 'Ctrl+S', -underline => 0, -command => \&save_values);
$root->g_bind('<Control-s>', \&save_values);
$file->m_add_command(-label => "Enregistrer sous...", -accelerator => 'Ctrl+Alt+S', -underline => 12,-command => \&save_values_as);
$root->g_bind('<Control-Alt-s>', \&save_values_as);
$file->add_separator();
$file->m_add_command(-label => "Quitter", -accelerator => 'Alt+F4', -underline => 0,-command => sub { $root->g_destroy() });
# The binding for Alt-F4 is automatically supplied by Windows and can't be
# overriden. It will destroy the window. We catch it as well as the menu entry
# using the following bind command.
# If we bind to $root, then the event triggers for all contained widget.
$root->g_bind('<Destroy>', [sub { autosave() if $_[0] eq '.' }, Tkx::Ev('%W')]);
my $options = $menu->new_menu;
$menu->m_add_cascade(-menu => $options, -label => "Options", -underline => 0);
my $automatic_duration = \$values{automatic_duration};
$options->m_add_checkbutton(-label => "Durée automatique", -variable => $automatic_duration, -onvalue => 1, -offvalue => 0, -accelerator => 'Ctrl+D');
$root->g_bind('<Control-d>', sub { $$automatic_duration = 1 - $$automatic_duration });
my $taxes = $menu->new_menu;
$menu->m_add_cascade(-menu => $taxes, -label => "Fiscalité", -underline => 1);
my $pinel_menu = $taxes->new_menu;
my @pinel_zone = ('Zone A bis', 'Zone A', 'Zone B1', 'Zone B2');
my $disable_pinel_zone = sub {
for my $z (@pinel_zone) {
$pinel_menu->m_entryconfigure($z, -state => 'disabled');
}
};
my $enable_pinel_zone = sub {
for my $z (@pinel_zone) {
$pinel_menu->m_entryconfigure($z, -state => 'normal');
}
};
$taxes->m_add_cascade(-menu => $pinel_menu, -label => "Loi Pinel", -underline => 4);
my $pinel_duration = \$values{pinel_duration};
# TODO: test if loading a file with pinel duration 0 results in having the zone disabled correctly.
$pinel_menu->add_radiobutton(-label => "Non", -variable => $pinel_duration, -value => 0, -command => sub { $disable_pinel_zone->(); calculate_all() });
$pinel_menu->add_radiobutton(-label => "6 ans", -variable => $pinel_duration, -value => 6, -command => sub { $enable_pinel_zone->(); calculate_all() });
$pinel_menu->add_radiobutton(-label => "9 ans", -variable => $pinel_duration, -value => 9, -command => sub { $enable_pinel_zone->(); calculate_all() });
$pinel_menu->add_radiobutton(-label => "12 ans", -variable => $pinel_duration, -value => 12, -command => sub { $enable_pinel_zone->(); calculate_all() });
$pinel_menu->add_separator();
my $pinel_zone = \$values{pinel_zone};
for my $i (0..$#pinel_zone) {
( run in 0.763 second using v1.01-cache-2.11-cpan-49f99fa48dc )