App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/Wx/PanelRole.pm view on Meta::CPAN
sub { $self->OnWindowMessages($_[1]) } );
}
$self->{w_infobar}->ShowMessage( $message, wxICON_INFORMATION);
}
method setup_webview() {
my $try;
$wv = $self->{webview};
return unless eval { require Wx::WebView; 1 };
# WebView can only handle PDF on Windows with Edge backend.
# Wx::WebView::IsBackendAvailable requires Wx 3.002.
return if is_msw
&& ( $Wx::VERSION < 3.002 || !Wx::WebView::IsBackendAvailable("wxWebViewEdge") );
$state{have_webview} = 1; # Note: too early
$wv = Wx::WebView::New( $self->{p_right},
wxID_ANY, "",
wxDefaultPosition, wxDefaultSize,
is_msw ? "wxWebViewEdge" : ()
);
$self->{sz_preview}->Replace( $self->{webview}, $wv, 1 );
$self->{webview}->Destroy;
$self->{webview} = $wv;
$self->{sz_preview}->Layout;
}
method setup_messages_ctxmenu() {
# Context menu for message area.
my $menu = Wx::Menu->new;
my $id = Wx::NewId;
$menu->Append( $id, "Clear the message area", "", Wx::wxITEM_NORMAL );
Wx::Event::EVT_MENU( $self, $id, $self->can("OnMessagesClear") );
$id = Wx::NewId;
$menu->Append( $id, "Save the messages to a file", "", Wx::wxITEM_NORMAL );
Wx::Event::EVT_MENU( $self, $id, $self->can("OnMessagesSave") );
Wx::Event::EVT_CONTEXT_MENU( $self->{t_messages},
sub { $_[0]->PopupMenu( $menu,
Wx::wxDefaultPosition ) } );
}
method unsplit() {
$self->{sw_lr}->Unsplit(undef);
$self->{sw_tb}->Unsplit(undef);
}
method prepare_annotations() {
return unless $state{have_stc};
$self->{t_editor}->prepare_annotations;
}
method add_annotation( $line, $msg ) {
return unless $state{have_stc};
$self->{t_editor}->add_annotation( $line, $msg );
}
method refresh_messages {
$self->{t_messages}->SetFont( Wx::Font->new($preferences{msgsfont}) );
}
################ Virtual Methods ################
method name();
method check_source_saved();
method check_preview_saved();
method save_preferences();
method update_preferences();
################ Event Handlers (alphabetic order) ################
method OnHelp_DebugInfo($event) {
$state{debuginfo} = wxTheApp->GetTopWindow->GetMenuBar->FindItem($event->GetId)->IsChecked;
}
#method OnNew($event) {
# return unless $self->GetParent->check_saved;
# $self->GetParent->select_mode("initial");
#}
method OnOpen($event) {
# Let the parent handle this one.
# I would have expected a Skip to be sufficient, but then nothing happens.
# Explicitly posting an event, e.g.
# Wx::PostEvent( wxTheApp->GetTopWindow,
# Wx::CommandEvent->new( wxEVT_COMMAND_MENU_SELECTED,
# wxID_OPEN ) );
# ends up here, not in the parent, so we have a nice loop.
# This is the only place where we violate our principle to not call
# event handlers explicitly...
$self->GetParent->OnOpen($event);
}
method OnPreferences($event) {
# Dispatch to Main.
Wx::PostEvent( $self->GetParent,
Wx::CommandEvent->new
( wxEVT_COMMAND_MENU_SELECTED, wxID_PREFERENCES) );
}
method OnPreview($event) { # for menu
$self->preview( [] );
$self->previewtooltip;
}
method OnPreviewClose($event) {
return unless $self->{sw_lr}->IsSplit;
$self->{sw_lr}->Unsplit(undef);
$self->previewtooltip;
}
method OnPreviewLyricsOnly($event) {
$self->preview( [ '--lyrics-only' ] );
$self->previewtooltip;
}
method OnPreviewMore($event) {
# C D E F G A B C
( run in 0.436 second using v1.01-cache-2.11-cpan-5735350b133 )