App-Music-ChordPro-Wx
view release on metacpan or search on metacpan
lib/App/Music/ChordPro/Wx/PreferencesDialog.pm view on Meta::CPAN
# App::Music::ChordPro::Wx::PreferencesDialog_wxg is generated by wxGlade and contains
# all UI associated code.
use base qw( App::Music::ChordPro::Wx::PreferencesDialog_wxg );
use Wx qw[:everything];
use Wx::Locale gettext => '_T';
use App::Packager;
# BUilt-in descriptions for some notation systems.
my $notdesc =
{ "common" => "C, D, E, F, G, A, B",
"dutch" => "C, D, E, F, G, A, B",
"german" => "C, ... A, Ais/B, H",
"latin" => "Do, Re, Mi, Fa, Sol, ...",
"scandinavian" => "C, ... A, A#/Bb, H",
"solfege" => "Do, Re, Mi, Fa, So, ...",
"solfège" => "Do, Re, Mi, Fa, So, ...",
"nashville" => "1, 2, 3, ...",
"roman" => "I, II, III, ...",
};
sub get_configfile {
my ( $self ) = @_;
# warn("CF: ", $self->GetParent->{prefs_configfile} || "");
$self->GetParent->{prefs_configfile} || ""
}
sub __set_properties {
my ( $self ) = @_;
$self->SUPER::__set_properties;
my $parent = $self->GetParent;
$self->{t_configfiledialog}->SetValue($parent->{prefs_configfile})
if $parent->{prefs_configfile};
$self->{t_pdfviewer}->SetValue($parent->{prefs_pdfviewer})
if $parent->{prefs_pdfviewer};
$self->{cb_skipstdcfg}->SetValue($parent->{prefs_skipstdcfg});
my $ctl = $self->{ch_config};
$ctl->Clear;
for ( @{ $parent->stylelist } ) {
my $t = ucfirst(lc($_));
$t =~ s/_/ /g;
$t =~ s/ (.)/" ".uc($1)/eg;
$ctl->Append($t);
}
my $p = $parent->{prefs_cfgpreset};
foreach ( @$p ) {
my $t = ucfirst(lc($_));
$t =~ s/_/ /g;
$t =~ s/ (.)/" ".uc($1)/eg;
my $n = $ctl->FindString($t);
unless ( $n == wxNOT_FOUND ) {
$ctl->Check( $n, 1 );
}
}
$self->_enablecustom;
$ctl = $self->{ch_editfont};
$ctl->SetSelection( $parent->{prefs_editfont} );
$ctl = $self->{sp_editfont};
$ctl->SetValue( $parent->{prefs_editsize} );
$ctl = $self->{ch_notation};
$ctl->Clear;
my $n = 0;
my $check = 0;
for ( @{ $parent->notationlist } ) {
my $s = ucfirst($_);
$check = $n if $_ eq lc $parent->{prefs_notation};
$s .= " (" . $notdesc->{lc($s)} .")" if $notdesc->{lc($s)};
$ctl->Append($s);
$ctl->SetClientData( $n, $_);
$n++;
}
$ctl->SetSelection($check);
$ctl = $self->{ch_transcode};
$ctl->Clear;
$ctl->Append("-----");
$n = 1;
for ( @{ $parent->notationlist } ) {
my $s = ucfirst($_);
$check = $n if $_ eq lc $parent->{prefs_xcode};
$s .= " (" . $notdesc->{lc($s)} .")" if $notdesc->{lc($s)};
$ctl->Append($s);
$ctl->SetClientData( $n, $_);
$n++;
}
$ctl->SetSelection($check);
}
sub _enablecustom {
my ( $self ) = @_;
my $ctl = $self->{ch_config};
my $n = $ctl->IsChecked( $ctl->GetCount - 1 );
for ( $self->{l_cfgfile}, $self->{t_configfiledialog}, $self->{b_configfiledialog} ) {
$_->Enable($n);
}
}
sub _enablexpose {
my ( $self, $n ) = @_;
for ( $self->{l_xpose},
$self->{l_xpose_from}, $self->{ch_xpose_from},
$self->{l_xpose_to}, $self->{ch_xpose_to},
$self->{rb_xpose_sharp}, $self->{rb_xpose_flat},
) {
$_->Enable($n);
}
}
################ Event handlers ################
# Event handlers override the subs generated by wxGlade in the _wxg class.
sub OnChConfig {
my ( $self, $event ) = @_;
my @n = $self->{ch_config}->GetSelections;
my $enablecustom;
foreach ( @n ) {
lib/App/Music/ChordPro/Wx/PreferencesDialog.pm view on Meta::CPAN
my ( $self, $event ) = @_;
$event->Skip;
}
sub OnSkipStdCfg {
my ( $self, $event ) = @_;
$event->Skip;
}
sub OnXposeFrom {
my ( $self, $event ) = @_;
$event->Skip;
}
sub OnXposeTo {
my ( $self, $event ) = @_;
my $sel = $self->{ch_xpose_to}->GetSelection;
my $sf = $sfmap[$sel];
if ( $sf < 0 ) {
$self->{rb_xpose_flat }->SetValue(1);
$self->{rb_xpose_sharp}->SetValue(0);
}
elsif ( $sf > 0 ) {
$self->{rb_xpose_flat }->SetValue(0);
$self->{rb_xpose_sharp}->SetValue(1);
}
else {
$self->{rb_xpose_flat }->SetValue(0);
$self->{rb_xpose_sharp}->SetValue(0);
}
$event->Skip;
}
sub OnXposeSharp {
my ( $self, $event ) = @_;
$self->{rb_xpose_flat }->SetValue(0);
$event->Skip;
}
sub onXposeFlat {
my ( $self, $event ) = @_;
$self->{rb_xpose_sharp}->SetValue(0);
$event->Skip;
}
sub OnChNotation {
my ( $self, $event ) = @_;
my $n = $self->{ch_notation}->GetSelection;
$event->Skip;
}
sub OnChTranscode {
my ( $self, $event ) = @_;
my $n = $self->{ch_transcode}->GetSelection;
$event->Skip;
}
sub OnChEditFont {
my ($self, $event) = @_;
my $p = $self->GetParent;
my $n = $self->{ch_editfont}->GetSelection;
my $ctl = $p->{t_source};
my $font = $p->fonts->[$n]->{font};
$font->SetPointSize($p->{prefs_editsize});
$ctl->SetFont($font);
$p->{prefs_editfont} = $n;
$event->Skip;
}
sub OnSpEditFont {
my ($self, $event) = @_;
my $p = $self->GetParent;
my $n = $self->{sp_editfont}->GetValue;
my $ctl = $p->{t_source};
my $font = $ctl->GetFont;
$font->SetPointSize($n);
$ctl->SetFont($font);
$p->{prefs_editsize} = $n;
$event->Skip;
}
1;
( run in 0.441 second using v1.01-cache-2.11-cpan-5735350b133 )