math-image
view release on metacpan or search on metacpan
lib/App/MathImage/Prima/Main.pm view on Meta::CPAN
# [], # separator to put Help at the right
[ "~Help" =>
[ [ __('~About'), 'help_about' ],
[ __('~Program POD'), 'help_program' ],
[ __('Pa~th POD'), 'help_path' ],
[ __('~Values POD'), 'help_values' ],
(defined (Module::Util::find_installed('Browser::Open'))
? [ 'help-oeis', __('~OEIS Web Page'), 'help_oeis' ]
: ()),
],
],
],
};
}
# together with transparent=>1 for no clear background underneath draw widget
sub on_paint {
}
sub init {
my ($self, %profile) = @_;
### Prima Main init() ...
my $visible = (exists $profile{'visible'} ? $profile{'visible'} : 1);
$profile{'visible'} = 0;
%profile = $self-> SUPER::init(%profile);
my $gui_options = delete $profile{'gui_options'};
my $gen_options = delete $profile{'gen_options'} || {};
{
my %default_gen_options = %{App::MathImage::Generator->default_options};
delete @default_gen_options{'width','height'}; # hash slice
$gen_options = { %default_gen_options,
%$gen_options };
}
### $gen_options
my $toolbar = $self->{'toolbar'}
= $self->insert ('Widget',
pack => { in => $self,
side => 'top',
fill => 'x',
expand => 0,
anchor => 'n',
},
);
$toolbar->insert ('Button',
text => __('Randomize'),
pack => { side => 'left' },
hint => __('Choose a random path, values, scale, etc.
Click repeatedly to see interesting things.'),
onClick => sub {
my ($button) = @_;
$self->{'draw'}->gen_options (App::MathImage::Generator->random_options);
_update($self);
},
);
my $combobox_height = do {
my $combo = Prima::ComboBox->create;
my $height = $combo->editHeight;
$combo->destroy;
$height
};
my $path_combo = $self->{'path_combo'}
= $toolbar->insert ('ComboBox',
pack => { side => 'left',
fill => 'none',
expand => 0 },
hint => __('The path for where to place values in the plane.'),
style => cs::DropDown,
# override dodgy height when style set
height => $combobox_height,
items => [ map { $_ } App::MathImage::Generator->path_choices ],
onChange => sub {
my ($combo) = @_;
### Main path_combo onChange
my $path = $combo->text;
$self->{'draw'}->gen_options (path => $path);
_update ($self);
},
);
$self->{'values_combo'}
= $toolbar->insert ('ComboBox',
pack => { side => 'left',
fill => 'none',
expand => 0 },
style => cs::DropDown,
# override dodgy height when style set
height => $combobox_height,
hint => __('The values to display.'),
items => [ map { $_ } App::MathImage::Generator->values_choices ],
onChange => sub {
my ($combo) = @_;
### Main values combo onChange
my $values = $combo->text;
$self->{'draw'}->gen_options (values => $values);
_update ($self);
},
);
# {
# my $max = 0;
# foreach (0 .. $self->{'values_combo'}->{list}->count() - 1) {
# ### wid: $self->{'values_combo'}->{list}->get_item_width($_)
# $max = max ($max, $self->{'values_combo'}->{list}->get_item_width($_));
# }
# ### $max
# $self->{'values_combo'}->width($max+10);
# }
{
$toolbar->insert ('Label',
text => __('Scale'),
pack => { side => 'left' },);
$self->{'scale_spin'}
= $toolbar->insert ('SpinEdit',
pack => { side => 'left' },
min => 1,
step => 1,
pageStep => 10,
onChange => sub {
my ($spin) = @_;
### Prima-Main scale onChange: $spin->value
my $scale = $spin->value;
$self->{'draw'}->gen_options (scale => $scale);
},
);
}
$self->{'draw'} = $self->insert
('App::MathImage::Prima::Drawing',
name => 'Drawing',
width => (defined $gen_options->{'width'} ? $gen_options->{'width'} :-1),
height => (defined $gen_options->{'height'}? $gen_options->{'height'}:-1),
pack => { expand => 1, fill => 'both' },
delegations => ['MouseMove'],
gen_options => $gen_options,
);
my $statusbar = $self->{'statusbar'} = $self->insert
('Label',
text => '',
pack => { in => $self,
side => 'top',
fill => 'x',
expand => 0,
anchor => 'n',
});
( run in 0.871 second using v1.01-cache-2.11-cpan-59e3e3084b8 )