Wx::Perl::SmartWx::Perl::Smart
Schneller
Bessere
GUI's
Wx::Perl::Wx::Perl::SmartSmart
Wx::Perl::Wx::Perl::SmartSmart
~~
Wx::Perl::Wx::Perl::SmartSmart
~~
Wx::Perl::Wx::Perl::SmartSmart
$var ~~ @list
Wx::Perl::Smart
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Harmonogra
ph
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Harmonogra
ph
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Harmonogra
ph
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Harmonogra
ph
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Wx::Perl::Smart
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Wx::Perl::Smart
sub OnInit {
my $app = shift;
# load localisation texts in chosen language
my ($v, $dir, $f) = File::Spec->splitpath(__FILE__);
$l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir;
die "localisation file $l18n_file is missing!" unless -e $l18n_file;
my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}};
$app->{'l18n'} = %l18n;
# loading the numbers of the remembered favorites
$app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new;
my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : ();
# making UI
my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size');
$frame->SubscribeStrings( $app->{'l18n'} );
my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()};
my $repaint = sub { $app->Repaint() };
my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250;
my $origin_offset = $app->{'origin_offset'} = $boardsize / 2;
my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude
my %range_defaults = (# label, min, max, init
frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30],
amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360],
rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200],
length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100],
thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10],
start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60],
scale_colour=> [$l18n{'scale'}, 1, 1, 4],
);
$frame->SubscribeWidgets
({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults;
$frame->SubscribeWidgets({
drawboard => Wx::Perl::DrawMap->new($frame, $boardsize),
fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember],
format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ],
save => [-Button => '~save', sub {$app->Save() }],
save_all => [-Button => '~all', sub {$app->SaveAll() }],
remember => [-Button => '~remember', sub {$app->Remember()}],
forget => [-Button => '~forget', sub {$app->Forget() }],
no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}],
closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}],
open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}],
y_invers => [-CheckBox => '~y_inverse', 0, $repaint],
rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint),
app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}),
});
$frame->SetSmartLayout(
{flags => &Wx::wxGROW|&Wx::wxALL},
[ # left part
'<drawboard>',
10,
{border => 10, flags => &Wx::wxALL|&Wx::wxGROW},
'<fav_select>',
['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'],
],[ # right half
-TabbedBox => [
'~oscillators' =>[
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
['~mode :', '<app_mode>'],
-LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers>
-LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>),
{border => 5, flags => &Wx::wxALL|&Wx::wxGROW},
['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'],
]],
-LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]],
{border => 10}, '<friction>',
],
'~visuals' => [
{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
-LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness>
-LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]],
{border => 10},'<zoom>',
],
],
]);
$frame->ResetValues();
$app->Repaint();
$app->SetTopWindow($frame);
1;
Wx::Perl::Smart
Wx::Perl::Smart::Frame
Wx::Perl::Smart::Dialog
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::WidgetFactory
Nucleus
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Sizer
aus Kephra
Kephra::App::Panel
Kephra::App::Sizer
KephraXP
K. GUI Libs
Kephra::App::Editor
Kephra::App::Dialog
Kephra::App::DocBar
Kephra::App::Focus
Kephra::App::Panel
Kephra::App::Sizer
Kephra::App::Splitter
Kephra::App::Window
Kephra::App::Util
'kleine Projekte'
App::Harmonograph
App::Spirograph
Trigon
Fraktalzeichner
Games:Sudoku::Algosolver
Wx::Perl::Smart
In 5 Schritten
zur Intelligenz
Wx::Perl::Smart
Widgets
Komposition
Abstraktion
Das sind nur 3
Widgets
Komposition
Abstraktion
Jetzt sind es 5
Wid gets
Komposition
Abstr aktion
Wx::Perl::Smart
Wid gets
Komposition
Abstr aktion
Nummer 1
einfach & sichere
Widgeterzeugung
Nummer 2
mächtige Widgets
Wx::Perl::*
mächtige Widgets
Nummer 3
leicht änderbar,
kompakte
Komposition
Nummer 4
Trennung von
Daten & Layout
Nummer 5
MVC – GUI Layer
GUI Comp. Lang.
MVC – GUI Layer
Wx::Perl::Smart
Wid gets
Komposition
Abstr aktion
Schritt 1
Einzelne
Widgets
Einzelne Widgets
Wx::Button
Wx::Button->
new(..., ..., ...)
Erzeugen
$parent $frame
ID -1
$label wxEmptyString,
wxPoint wxDefaultPosition, [-1,-1]
wxSize& size = wxDefaultSize, [-1,-1]
style 0,
wxValidator,
wxString $name
New Parameter
$button = Wx::Button->new(
$parent, -1, 'label', [-1,-1], [30,-1]);
Wx::Event::EVT_BUTTON
($frame, $button, &callback);
Button Erzeugen
Wx::Perl::Button
($parent, 'label', &callback, 30);
Smart Button
Wx::Perl::Button
($parent, 'label', &callback, 30);
# required , opt
Smart Button
wxWindow* parent,
wxWindowID id,
wxString& value,
wxPoint& pos,
wxSize& size,
long style,
wxValidator& (validator),
wxString& name,
Textc. Parameter
$txt = Wx::TextCtrl->new(
$parent, -1, 'content', [-1,-1], [30,-1],
&Wx::wxTE_MULTILINE
Wx::Perl::TextValidator->new (qr//));
Wx::Event::EVT_KEY_DOWN
($txt, -1, &callback);
Wx::Event::EVT_TEXT
($frame, $txt, &callback);
TextCtrlErzeugen
$txt = Wx::Perl::TextEdit->new(
$pa,'content',&callback,qr/.../,[30,-1]);
Smart TextEdit
$txt = Wx::Perl::TextEdit->new(
$pa,'content',&callback,qr/.../,[30,-1]);
# required ,opt
Smart TextEdit
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als Code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
weglassen was nicht wichtig ist
Einzelne Widgets
weglassen was nicht wichtig ist
Perl hat besseres
ObjRef statt WxID | WidgetName
Einzelne Widgets
weglassen was nicht wichtig ist
Weil du es nicht kontrollieren willst
Position und Größe regeln Sizer
Einzelne Widgets
weglassen was nicht wichtig ist
Weil es Probleme macht
auf undef gesetzte parents
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
callbacks (coderef)
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
callbacks (coderef) & zus. styles
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als Code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als Code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
weglassen was nicht wichtig ist
nimmt hinzu was wichtig wäre
optional auch mit benannten Param.
Def als code oder String (compilien)
alles normalen Widgets (Moose)
Wx::Perl::Button ... kommt vielleicht
Einzelne Widgets
Wx::Perl::Button
($parent, 'label', &callback, 30);
neues Modul für den einen Aufruf
Softwarearchitektur: factory method
Smart Button ?
Wx::Perl::Button
($parent, 'label', &callback, 30);
neues Modul für den einen Aufruf
Softwarearchitektur: factory method
Smart Button ?
@widgets = factory method([
[-Button => 'label', &callback, 30],
…
]);
Smart Factory
@widgets = $factory->MakeWidget([
[-Button => 'label', &callback, 30],
{widget => 'Button', label =>'...', },
]);
Benannte Param.
$factory = Wx::Perl::Smart::
WidgetFactory->new($parent);
Kürzt Aufruf
$factory = Wx::Perl::Smart::
WidgetFactory->new($parent);
Wx::Perl::Smart::WidgetFactory->
MakeWidget([ ….
Und vermeidet
im Sinne einer Factory Method
erzeugt normale Widgets & weitere
Smart Factory
Schritt 2
Zusammen-
gesetzte
Widgets
Zusam. Widgets
RadioButtons
TextSliders
Zusam. Widgets
sammle mehrere Einzelwidgets
und deren Daten & Event-
handling in ein Widget
einfacherer Umgang,
Layout wird übersichtlicher
Schritt 3
Komposition
Komposition
Wx::Perl::Smart::Util
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
Wx::Perl::Smart::Dialog
Komposition
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
:WidgetFactory
einfache, robuste Erzeugung
in Tabellenanordnung
Trennung vom GUI-Layout
keine Daten ins Layout
strukturierte Programme
:WidgetFactory
einfache, robuste Erzeugung
in Tabellenanordnung
Trennung vom GUI-Layout
keine Daten ins Layout
strukturierte Programme
Komposition
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
einfache und robuste Erzeugung
$sizer = Wx::Perl::Smart::Sizer-
>new([$widget, $widget, ...]);
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
Erzeugung von Deko-Widgets
$sizer = Wx::Perl::Smart::Sizer-
>new([$widget, '---', $widget, ...]);
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
$sizer = Wx::Perl::Smart::Sizer-
>new(-TabbedBox =>
[ [$widget, ...], [...]]);
mehr Abstraktion (tabs = Sizer)
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
::Smart::Sizer
einfache und robuste Erzeugung
Erzeugung von Deko-Widgets
Kommentare
mehr Abstraktion (tabs = Sizer)
einfache und effektive Benutzung
Komposition
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
::Smart::Panel
Panel mit Smart::Sizer
::Smart::Panel
Panel mit Smart::Sizer
$panel = Wx::Perl::Smart::Panel-
>new([$widget, $widget, ...]);
::Smart::Panel
Panel mit Smart::Sizer
Sichbarkeit und Verwandschaft
wird automatisch geregelt
Komposition
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
::Smart::Frame
Hauptenster einer App
noch eine Abstraktion
vereinfachter Zugriff auf Panel,
Sizer und WidgetFactory
verwaltet auch Widgets und
Localisationstrings
Widgets mit ID
$frame->MakeWidgets({
drawboard => Wx::Perl::Draw...
fav_select => [-ComboBox => ..]
def Layout
$frame->EvalSmartLayout (
{flags => &Wx::wxGROW|&Wx::wxALL},
[ '<drawboard>',
10,
'<fav_select>',
['<format_select>', 10,'<save>', 10,
'<save_all>', 1, '<forget>', 10,...],
ohne Ränder
$frame->EvalSmartLayout (
[ '<drawboard>',
'<fav_select>',
['<format_select>', '<save>',
'<save_all>', 1, '<forget>', ...],
Panel mit ID
$frame->EvalSmartPanel ( 'my_panel' =>
[ '<drawboard>',
10,
'<fav_select>',
['<format_select>', 10,'<save>', 10,
'<save_all>', 1, '<forget>', 10,...],
NutzewieWidget
$frame->EvalSmartLayout (
[ '<my_panel>',
'<fav_select>',
['<format_select>', '<save>',
'<save_all>', 1, '<forget>', ...],
Smart>GUIDesigner
''can't touch this'
Smart>GUIDesigner
Designercode darf nicht
berührt werden
Smart>GUIDesigner
Brauch mehrere
Programme / Formate
Smart>GUIDesigner
Smart ist schneller
effektiver als GUI
Smart>GUIDesigner
Smart ist schneller
effektiver als GUI
änder Abstandsklassen
Smart>GUIDesigner
Smart ist schneller
effektiver als GUI
denk in Proportionen
Komponenten
Wx::Perl::Smart::Util
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
Wx::Perl::Smart::Dialog
Gen Comp Abstr
Wx::Perl::Smart::Util
Wx::Perl::*
Wx::Perl::Smart::WidgetFactory
Wx::Perl::Smart::Sizer
Wx::Perl::Smart::Panel
Wx::Perl::Smart::Frame
Wx::Perl::Smart::Dialog
Zukunft
Templates
Schablonen
Werte
Events
Schritt 5
Abstraktion
GCL
GUI
Composition
Lang
Abstraktion
Wikiformat für's layout
(oft besser als GUI designer)
kompiliert zu Datenstruktur
(jedes Format funktioniert)
kompiliert zu GUI
andere Backends denkbar
(GCL::Prima, GCL::GTK)
Abstraktion
Wikiformat für's layout
(oft besser als GUI designer)
kompiliert zu Datenstruktur
(jedes Format funktioniert)
kompiliert zu GUI
andere Backends denkbar
(GCL::Prima, GCL::GTK)
Abstraktion
Wikiformat für's layout
(oft besser als GUI designer)
kompiliert zu Datenstruktur
(jedes Format funktioniert)
kompiliert zu GUI
andere Backends denkbar
(GCL::Prima, GCL::GTK)
Abstraktion
Wikiformat für's layout
(oft besser als GUI designer)
kompiliert zu Datenstruktur
(jedes Format funktioniert)
kompiliert zu GUI
andere Backends denkbar
(GCL::Prima, GCL::GTK)
Danke

Wx::Perl::Smart

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
    Wx::Perl::Smart sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 7.
    Harmonogra ph sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 8.
    Harmonogra ph sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 9.
    Harmonogra ph sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 10.
    Harmonogra ph sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 11.
    Wx::Perl::Smart sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 12.
    Wx::Perl::Smart sub OnInit { my$app = shift; # load localisation texts in chosen language my ($v, $dir, $f) = File::Spec->splitpath(__FILE__); $l18n_file = File::Spec->catfile($dir, $l18n_file) if $dir; die "localisation file $l18n_file is missing!" unless -e $l18n_file; my %l18n = %{YAML::Tiny->read( $l18n_file )->[0]{$language}}; $app->{'l18n'} = %l18n; # loading the numbers of the remembered favorites $app->{'favorites'} = -e $fav_file ? YAML::Tiny->read( $fav_file ) : YAML::Tiny->new; my @remembered_pic_names = ref $app->{'favorites'}->[0] eq 'HASH' ? keys $app->{'favorites'}->[0] : (); # making UI my $frame = $app->{'frame'} = Wx::Perl::Smart::Frame->new(__PACKAGE__." $VERSION", 'fixed_size'); $frame->SubscribeStrings( $app->{'l18n'} ); my $remember= sub { $frame->SetValues( $app->{'favorites'}[0]{ $_[0]->GetValue() } ); $app->Repaint()}; my $repaint = sub { $app->Repaint() }; my $boardsize = Wx::GetDisplaySize()->GetHeight() - 250; my $origin_offset = $app->{'origin_offset'} = $boardsize / 2; my $max_amp = $app->{'max_amp'} = $origin_offset - 10; # max amplitude my %range_defaults = (# label, min, max, init frequency_x => ['X', 1, 1, 30], frequency_y => ['Y', 1, 1, 30], amplitude_x => ['X', 0, 0, 360], amplitude_y => ['Y', 0, 0, 360], rotation => [$l18n{'amount'}, 1, 0, 30], friction => [$l18n{'friction'}, 0, 0, 200], length => [$l18n{'length'}, 12, 1, 100], density => [$l18n{'density'},100, 1, 100], thickness => [$l18n{'thickness'},1, 1, 12], zoom => [$l18n{'zoom'}, 0,-10, 10], start_colour=> [$l18n{'start'}, 0, 0,1500], flow_colour => [$l18n{'flow'}, 0, 0, 60], scale_colour=> [$l18n{'scale'}, 1, 1, 4], ); $frame->SubscribeWidgets ({$_ => Wx::Perl::DisplaySlider->new($frame, @{$range_defaults{$_}}, $repaint)}) for keys %range_defaults; $frame->SubscribeWidgets({ drawboard => Wx::Perl::DrawMap->new($frame, $boardsize), fav_select => [-ComboBox => @remembered_pic_names, 0, -1, $remember], format_select=> [-ComboBox => [qw(PNG JPG TIFF BMP XPM)], 0, 70 ], save => [-Button => '~save', sub {$app->Save() }], save_all => [-Button => '~all', sub {$app->SaveAll() }], remember => [-Button => '~remember', sub {$app->Remember()}], forget => [-Button => '~forget', sub {$app->Forget() }], no_phase => [-Button => '~no', sub {$frame->SetValues(amplitude_x => 0, amplitude_y => 0);$app->Repaint()}], closed_phase => [-Button => '~closed', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 90);$app->Repaint()}], open_phase => [-Button => '~open', sub {$frame->SetValues(amplitude_x => 90, amplitude_y => 180);$app->Repaint()}], y_invers => [-CheckBox => '~y_inverse', 0, $repaint], rotation_dir => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(no left right)}], 0, &Wx::wxHORIZONTAL, $repaint), app_mode => Wx::Perl::RadioGroup->new($frame, [@l18n{qw(lateral rotary free)}], 0, &Wx::wxHORIZONTAL, sub{}), }); $frame->SetSmartLayout( {flags => &Wx::wxGROW|&Wx::wxALL}, [ # left part '<drawboard>', 10, {border => 10, flags => &Wx::wxALL|&Wx::wxGROW}, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10, '<remember>'], ],[ # right half -TabbedBox => [ '~oscillators' =>[ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, ['~mode :', '<app_mode>'], -LabeledBox =>['~frequency' =>[qw( <frequency_x> <frequency_y>)]], #<y_invers> -LabeledBox =>['~start_amp' =>[qw( <amplitude_x> <amplitude_y>), {border => 5, flags => &Wx::wxALL|&Wx::wxGROW}, ['~phase :', 1, '<no_phase>', 1,'<closed_phase>', 1, '<open_phase>'], ]], -LabeledBox =>[ '~rotation ' =>[qw( <rotation_dir> <rotation> )]], {border => 10}, '<friction>', ], '~visuals' => [ {border => 5, flags => &Wx::wxGROW|&Wx::wxALL}, -LabeledBox =>['~line' =>[qw( <length> <density> )]], #<thickness> -LabeledBox =>['~color' =>[qw( <start_colour> <flow_colour> <scale_colour>)]], {border => 10},'<zoom>', ], ], ]); $frame->ResetValues(); $app->Repaint(); $app->SetTopWindow($frame); 1;
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
    Das sind nur3 Widgets Komposition Abstraktion
  • 22.
    Jetzt sind es5 Wid gets Komposition Abstr aktion
  • 23.
  • 24.
    Nummer 1 einfach &sichere Widgeterzeugung
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
    GUI Comp. Lang. MVC– GUI Layer
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
    $parent $frame ID -1 $labelwxEmptyString, wxPoint wxDefaultPosition, [-1,-1] wxSize& size = wxDefaultSize, [-1,-1] style 0, wxValidator, wxString $name New Parameter
  • 36.
    $button = Wx::Button->new( $parent,-1, 'label', [-1,-1], [30,-1]); Wx::Event::EVT_BUTTON ($frame, $button, &callback); Button Erzeugen
  • 37.
  • 38.
    Wx::Perl::Button ($parent, 'label', &callback,30); # required , opt Smart Button
  • 39.
    wxWindow* parent, wxWindowID id, wxString&value, wxPoint& pos, wxSize& size, long style, wxValidator& (validator), wxString& name, Textc. Parameter
  • 40.
    $txt = Wx::TextCtrl->new( $parent,-1, 'content', [-1,-1], [30,-1], &Wx::wxTE_MULTILINE Wx::Perl::TextValidator->new (qr//)); Wx::Event::EVT_KEY_DOWN ($txt, -1, &callback); Wx::Event::EVT_TEXT ($frame, $txt, &callback); TextCtrlErzeugen
  • 41.
  • 42.
  • 43.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als Code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 44.
    weglassen was nichtwichtig ist Einzelne Widgets
  • 45.
    weglassen was nichtwichtig ist Perl hat besseres ObjRef statt WxID | WidgetName Einzelne Widgets
  • 46.
    weglassen was nichtwichtig ist Weil du es nicht kontrollieren willst Position und Größe regeln Sizer Einzelne Widgets
  • 47.
    weglassen was nichtwichtig ist Weil es Probleme macht auf undef gesetzte parents Einzelne Widgets
  • 48.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre callbacks (coderef) Einzelne Widgets
  • 49.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre callbacks (coderef) & zus. styles Einzelne Widgets
  • 50.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als Code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 51.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als Code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 52.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 53.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 54.
    weglassen was nichtwichtig ist nimmt hinzu was wichtig wäre optional auch mit benannten Param. Def als code oder String (compilien) alles normalen Widgets (Moose) Wx::Perl::Button ... kommt vielleicht Einzelne Widgets
  • 55.
    Wx::Perl::Button ($parent, 'label', &callback,30); neues Modul für den einen Aufruf Softwarearchitektur: factory method Smart Button ?
  • 56.
    Wx::Perl::Button ($parent, 'label', &callback,30); neues Modul für den einen Aufruf Softwarearchitektur: factory method Smart Button ?
  • 57.
    @widgets = factorymethod([ [-Button => 'label', &callback, 30], … ]); Smart Factory
  • 58.
    @widgets = $factory->MakeWidget([ [-Button=> 'label', &callback, 30], {widget => 'Button', label =>'...', }, ]); Benannte Param.
  • 59.
  • 60.
  • 61.
    im Sinne einerFactory Method erzeugt normale Widgets & weitere Smart Factory
  • 62.
  • 63.
  • 64.
    Zusam. Widgets sammle mehrereEinzelwidgets und deren Daten & Event- handling in ein Widget einfacherer Umgang, Layout wird übersichtlicher
  • 65.
  • 66.
  • 67.
  • 68.
    :WidgetFactory einfache, robuste Erzeugung inTabellenanordnung Trennung vom GUI-Layout keine Daten ins Layout strukturierte Programme
  • 69.
    :WidgetFactory einfache, robuste Erzeugung inTabellenanordnung Trennung vom GUI-Layout keine Daten ins Layout strukturierte Programme
  • 70.
  • 71.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 72.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 73.
    ::Smart::Sizer einfache und robusteErzeugung $sizer = Wx::Perl::Smart::Sizer- >new([$widget, $widget, ...]);
  • 74.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 75.
    ::Smart::Sizer Erzeugung von Deko-Widgets $sizer= Wx::Perl::Smart::Sizer- >new([$widget, '---', $widget, ...]);
  • 76.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 77.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 78.
    ::Smart::Sizer $sizer = Wx::Perl::Smart::Sizer- >new(-TabbedBox=> [ [$widget, ...], [...]]); mehr Abstraktion (tabs = Sizer)
  • 79.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 80.
    ::Smart::Sizer einfache und robusteErzeugung Erzeugung von Deko-Widgets Kommentare mehr Abstraktion (tabs = Sizer) einfache und effektive Benutzung
  • 81.
  • 82.
  • 83.
    ::Smart::Panel Panel mit Smart::Sizer $panel= Wx::Perl::Smart::Panel- >new([$widget, $widget, ...]);
  • 84.
    ::Smart::Panel Panel mit Smart::Sizer Sichbarkeitund Verwandschaft wird automatisch geregelt
  • 85.
  • 86.
    ::Smart::Frame Hauptenster einer App nocheine Abstraktion vereinfachter Zugriff auf Panel, Sizer und WidgetFactory verwaltet auch Widgets und Localisationstrings
  • 87.
    Widgets mit ID $frame->MakeWidgets({ drawboard=> Wx::Perl::Draw... fav_select => [-ComboBox => ..]
  • 88.
    def Layout $frame->EvalSmartLayout ( {flags=> &Wx::wxGROW|&Wx::wxALL}, [ '<drawboard>', 10, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10,...],
  • 89.
    ohne Ränder $frame->EvalSmartLayout ( ['<drawboard>', '<fav_select>', ['<format_select>', '<save>', '<save_all>', 1, '<forget>', ...],
  • 90.
    Panel mit ID $frame->EvalSmartPanel( 'my_panel' => [ '<drawboard>', 10, '<fav_select>', ['<format_select>', 10,'<save>', 10, '<save_all>', 1, '<forget>', 10,...],
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
    Abstraktion Wikiformat für's layout (oftbesser als GUI designer) kompiliert zu Datenstruktur (jedes Format funktioniert) kompiliert zu GUI andere Backends denkbar (GCL::Prima, GCL::GTK)
  • 105.
    Abstraktion Wikiformat für's layout (oftbesser als GUI designer) kompiliert zu Datenstruktur (jedes Format funktioniert) kompiliert zu GUI andere Backends denkbar (GCL::Prima, GCL::GTK)
  • 106.
    Abstraktion Wikiformat für's layout (oftbesser als GUI designer) kompiliert zu Datenstruktur (jedes Format funktioniert) kompiliert zu GUI andere Backends denkbar (GCL::Prima, GCL::GTK)
  • 107.
    Abstraktion Wikiformat für's layout (oftbesser als GUI designer) kompiliert zu Datenstruktur (jedes Format funktioniert) kompiliert zu GUI andere Backends denkbar (GCL::Prima, GCL::GTK)
  • 108.