wx::perl::smart

Post on 19-May-2015

143 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Vorstellung von Helfermodulen zu einfacheren ezwugung einer WxPerl GUI : https://bitbucket.org/lichtkind/wx-perl-smart

TRANSCRIPT

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::Smartsub OnInit {

my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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;

}

Harmonograph

sub OnInit {my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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;

}

Harmonograph

sub OnInit {my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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;

}

Harmonograph

sub OnInit {my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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;

}

Harmonograph

sub OnInit {my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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::Smartsub OnInit {

my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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::Smartsub OnInit {

my $app = shift;

# load localisation texts in chosen languagemy ($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 UImy $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 amplitudemy %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::FrameWx::Perl::Smart::DialogWx::Perl::Smart::PanelWx::Perl::Smart::SizerWx::Perl::Smart::WidgetFactory

Nucleus

Wx::Perl::Smart::PanelWx::Perl::Smart::Sizer

aus Kephra

Kephra::App::PanelKephra::App::Sizer

KephraXP

K. GUI LibsKephra::App::EditorKephra::App::DialogKephra::App::DocBarKephra::App::FocusKephra::App::PanelKephra::App::SizerKephra::App::SplitterKephra::App::WindowKephra::App::Util

'kleine Projekte'App::Harmonograph

App::Spirograph

Trigon

Fraktalzeichner

Games:Sudoku::Algosolver

Wx::Perl::Smart

In 5 Schrittenzur Intelligenz

Wx::Perl::Smart

WidgetsKompositionAbstraktion

Das sind nur 3

WidgetsKompositionAbstraktion

Jetzt sind es 5

Wid getsKompositionAbstr aktion

Wx::Perl::Smart

Wid getsKompositionAbstr aktion

Nummer 1

einfach & sichereWidgeterzeugung

Nummer 2

mächtige Widgets

Wx::Perl::*

mächtige Widgets

Nummer 3

leicht änderbar,kompakte

Komposition

Nummer 4

Trennung vonDaten & Layout

Nummer 5

MVC – GUI Layer

GUI Comp. Lang.

MVC – GUI Layer

Wx::Perl::Smart

Wid getsKompositionAbstr aktion

Schritt 1

EinzelneWidgets

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);

TextCtrl Erzeugen

$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 istnimmt hinzu was wichtig wäreoptional 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 istnimmt hinzu was wichtig wäre

callbacks (coderef)

Einzelne Widgets

weglassen was nicht wichtig istnimmt hinzu was wichtig wäre

callbacks (coderef) & zus. styles

Einzelne Widgets

weglassen was nicht wichtig istnimmt hinzu was wichtig wäreoptional 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 istnimmt hinzu was wichtig wäreoptional 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 istnimmt hinzu was wichtig wäreoptional 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 istnimmt hinzu was wichtig wäreoptional 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 istnimmt hinzu was wichtig wäreoptional 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 AufrufSoftwarearchitektur: factory method

Smart Button ?

Wx::Perl::Button ($parent, 'label', \&callback, 30);

neues Modul für den einen AufrufSoftwarearchitektur: 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 Methoderzeugt normale Widgets & weitere

Smart Factory

Schritt 2

Zusammen-gesetzteWidgets

Zusam. Widgets

RadioButtonsTextSliders

Zusam. Widgets

sammle mehrere Einzelwidgets und deren Daten & Event-handling in ein Widgeteinfacherer Umgang,Layout wird übersichtlicher

Schritt 3

Komposition

Komposition

Wx::Perl::Smart::UtilWx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::FrameWx::Perl::Smart::Dialog

Komposition

Wx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::Frame

:WidgetFactory

einfache, robuste Erzeugungin TabellenanordnungTrennung vom GUI-Layoutkeine Daten ins Layoutstrukturierte Programme

:WidgetFactory

einfache, robuste Erzeugungin TabellenanordnungTrennung vom GUI-Layoutkeine Daten ins Layoutstrukturierte Programme

Komposition

Wx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::Frame

::Smart::Sizer

einfache und robuste Erzeugung Erzeugung von Deko-Widgets Kommentaremehr Abstraktion (tabs = Sizer)einfache und effektive Benutzung

::Smart::Sizer

einfache und robuste Erzeugung Erzeugung von Deko-Widgets Kommentaremehr 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 Kommentaremehr 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 Kommentaremehr Abstraktion (tabs = Sizer)einfache und effektive Benutzung

::Smart::Sizer

einfache und robuste Erzeugung Erzeugung von Deko-Widgets Kommentaremehr 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 Kommentaremehr Abstraktion (tabs = Sizer)einfache und effektive Benutzung

::Smart::Sizer

einfache und robuste Erzeugung Erzeugung von Deko-Widgets Kommentaremehr Abstraktion (tabs = Sizer)einfache und effektive Benutzung

Komposition

Wx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::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::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::Frame

::Smart::Frame

Hauptenster einer Appnoch eine Abstraktionvereinfachter Zugriff auf Panel, Sizer und WidgetFactoryverwaltet 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,...],

Nutze wie Widget

$frame->EvalSmartLayout (

[ '<my_panel>','<fav_select>',

['<format_select>', '<save>', '<save_all>', \1, '<forget>', ...],

Smart > GUI Designer

''can't touch this'

Smart > GUI Designer

Designercode darf nicht berührt werden

Smart > GUI Designer

Brauch mehrere Programme / Formate

Smart > GUI Designer

Smart ist schneller effektiver als GUI

Smart > GUI Designer

Smart ist schneller effektiver als GUI

änder Abstandsklassen

Smart > GUI Designer

Smart ist schneller effektiver als GUI

denk in Proportionen

Komponenten

Wx::Perl::Smart::UtilWx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::FrameWx::Perl::Smart::Dialog

Gen Comp AbstrWx::Perl::Smart::UtilWx::Perl::*Wx::Perl::Smart::WidgetFactoryWx::Perl::Smart::SizerWx::Perl::Smart::PanelWx::Perl::Smart::FrameWx::Perl::Smart::Dialog

Zukunft

TemplatesSchablonen

WerteEvents

Schritt 5

Abstraktion

GCL

GUIComposition

Lang

AbstraktionWikiformat für's layout

(oft besser als GUI designer)kompiliert zu Datenstruktur(jedes Format funktioniert)

kompiliert zu GUIandere Backends denkbar(GCL::Prima, GCL::GTK)

AbstraktionWikiformat für's layout

(oft besser als GUI designer)kompiliert zu Datenstruktur(jedes Format funktioniert)

kompiliert zu GUIandere Backends denkbar(GCL::Prima, GCL::GTK)

AbstraktionWikiformat für's layout

(oft besser als GUI designer)kompiliert zu Datenstruktur(jedes Format funktioniert)

kompiliert zu GUIandere Backends denkbar(GCL::Prima, GCL::GTK)

AbstraktionWikiformat für's layout

(oft besser als GUI designer)kompiliert zu Datenstruktur(jedes Format funktioniert)

kompiliert zu GUIandere Backends denkbar(GCL::Prima, GCL::GTK)

Danke

top related