From c4a1a93b97df961be3bedfff3a634d2789026f0f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 28 Mar 2012 23:59:19 +0000 Subject: [PATCH] Center most of the message boxes over their parent windows Originally committed to SVN as r6629. --- aegisub/src/ass_file.cpp | 6 +++--- aegisub/src/command/app.cpp | 2 +- aegisub/src/command/audio.cpp | 8 ++++---- aegisub/src/command/recent.cpp | 2 +- aegisub/src/command/subtitle.cpp | 6 +++--- aegisub/src/command/video.cpp | 2 +- aegisub/src/dialog_export.cpp | 8 ++++---- aegisub/src/dialog_fonts_collector.cpp | 6 +++--- aegisub/src/dialog_selection.cpp | 2 +- aegisub/src/dialog_spellchecker.cpp | 4 ++-- aegisub/src/dialog_style_editor.cpp | 2 +- aegisub/src/dialog_style_manager.cpp | 4 ++-- aegisub/src/dialog_timing_processor.cpp | 2 +- aegisub/src/frame_main.cpp | 12 ++++++------ aegisub/src/main.cpp | 6 +++--- aegisub/src/subs_preview.cpp | 2 +- aegisub/src/video_context.cpp | 13 +++++++++---- 17 files changed, 46 insertions(+), 41 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 5c2eee457..661b0423e 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -83,7 +83,7 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent // Get proper format reader const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename); if (!reader) { - wxMessageBox("Unknown file type","Error loading file",wxICON_ERROR | wxOK); + wxMessageBox("Unknown file type","Error loading file",wxOK | wxICON_ERROR | wxCENTER); return; } @@ -114,12 +114,12 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent } // Real exception catch (agi::Exception &e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR|wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER); return; } // Other error catch (...) { - wxMessageBox("Unknown error","Error loading file",wxICON_ERROR | wxOK); + wxMessageBox("Unknown error","Error loading file",wxOK | wxICON_ERROR | wxCENTER); return; } diff --git a/aegisub/src/command/app.cpp b/aegisub/src/command/app.cpp index 9c4940b47..d858ac9e2 100644 --- a/aegisub/src/command/app.cpp +++ b/aegisub/src/command/app.cpp @@ -192,7 +192,7 @@ struct app_language : public Command { OPT_SET("App/Locale")->SetInt(newCode); // Ask to restart program - int result = wxMessageBox("Aegisub needs to be restarted so that the new language can be applied. Restart now?", "Restart Aegisub?", wxICON_QUESTION | wxYES_NO); + int result = wxMessageBox("Aegisub needs to be restarted so that the new language can be applied. Restart now?", "Restart Aegisub?", wxYES_NO | wxICON_QUESTION | wxCENTER); if (result == wxYES) { // Restart Aegisub if (wxGetApp().frame->Close()) { diff --git a/aegisub/src/command/audio.cpp b/aegisub/src/command/audio.cpp index ac5f63ffc..509ea2d00 100644 --- a/aegisub/src/command/audio.cpp +++ b/aegisub/src/command/audio.cpp @@ -105,7 +105,7 @@ struct audio_open : public Command { } catch (agi::UserCancelException const&) { } catch (agi::Exception const& e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } }; @@ -123,7 +123,7 @@ struct audio_open_blank : public Command { c->audioController->OpenAudio("dummy-audio:silence?sr=44100&bd=16&ch=1&ln=396900000"); } catch (agi::Exception const& e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } }; @@ -141,7 +141,7 @@ struct audio_open_noise : public Command { c->audioController->OpenAudio("dummy-audio:noise?sr=44100&bd=16&ch=1&ln=396900000"); } catch (agi::Exception const& e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } }; @@ -165,7 +165,7 @@ struct audio_open_video : public Command { } catch (agi::UserCancelException const&) { } catch (agi::Exception const& e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } }; diff --git a/aegisub/src/command/recent.cpp b/aegisub/src/command/recent.cpp index b8ec89106..ceb1390a6 100644 --- a/aegisub/src/command/recent.cpp +++ b/aegisub/src/command/recent.cpp @@ -75,7 +75,7 @@ struct recent_audio_entry : public Command { } catch (agi::UserCancelException const&) { } catch (agi::Exception const& e) { - wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } }; diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index 38053fdbf..bed2a8e1a 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -335,13 +335,13 @@ static void save_subtitles(agi::Context *c, wxString filename) { c->ass->Save(filename, true, true); } catch (const agi::Exception& err) { - wxMessageBox(lagi_wxString(err.GetMessage()), "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox(lagi_wxString(err.GetMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, c->parent); } catch (const char *err) { - wxMessageBox(err, "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, c->parent); } catch (...) { - wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, c->parent); } } diff --git a/aegisub/src/command/video.cpp b/aegisub/src/command/video.cpp index 99b867ab4..8ec459aaf 100644 --- a/aegisub/src/command/video.cpp +++ b/aegisub/src/command/video.cpp @@ -154,7 +154,7 @@ struct video_aspect_custom : public validator_video_loaded { } // Sanity check - if (numval < 0.5 || numval > 5.0) wxMessageBox(_("Invalid value! Aspect ratio must be between 0.5 and 5.0."),_("Invalid Aspect Ratio"),wxICON_ERROR|wxOK); + if (numval < 0.5 || numval > 5.0) wxMessageBox(_("Invalid value! Aspect ratio must be between 0.5 and 5.0."),_("Invalid Aspect Ratio"),wxOK | wxICON_ERROR | wxCENTER); // Set value else { diff --git a/aegisub/src/dialog_export.cpp b/aegisub/src/dialog_export.cpp index fd2ddabb4..dc72c5b8c 100644 --- a/aegisub/src/dialog_export.cpp +++ b/aegisub/src/dialog_export.cpp @@ -157,16 +157,16 @@ void DialogExport::OnProcess(wxCommandEvent &) { catch (agi::UserCancelException const&) { } catch (const char *error) { - wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR, this); + wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); } catch (wxString const& error) { - wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR, this); + wxMessageBox(error, "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); } catch (agi::Exception const& err) { - wxMessageBox(err.GetMessage(), "Error exporting subtitles", wxOK | wxICON_ERROR, this); + wxMessageBox(err.GetMessage(), "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); } catch (...) { - wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR, this); + wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this); } EndModal(0); diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index 7bea42a13..541f4bd0d 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -271,16 +271,16 @@ void DialogFontsCollector::OnStart(wxCommandEvent &) { } if (folder.FileExists()) - wxMessageBox(_("Invalid destination."), _("Error"), wxICON_EXCLAMATION | wxOK); + wxMessageBox(_("Invalid destination."), _("Error"), wxOK | wxICON_ERROR | wxCENTER, this); if (!folder.DirExists()) folder.Mkdir(0777, wxPATH_MKDIR_FULL); if (!folder.DirExists()) { - wxMessageBox(_("Could not create destination folder."), _("Error"), wxICON_EXCLAMATION | wxOK); + wxMessageBox(_("Could not create destination folder."), _("Error"), wxOK | wxICON_ERROR | wxCENTER, this); return; } } else if (folder.IsDir() || folder.GetName().empty()) { - wxMessageBox(_("Invalid path for .zip file."), _("Error"), wxICON_EXCLAMATION | wxOK); + wxMessageBox(_("Invalid path for .zip file."), _("Error"), wxOK | wxICON_ERROR | wxCENTER, this); return; } } diff --git a/aegisub/src/dialog_selection.cpp b/aegisub/src/dialog_selection.cpp index 934653557..5ecb64018 100644 --- a/aegisub/src/dialog_selection.cpp +++ b/aegisub/src/dialog_selection.cpp @@ -254,7 +254,7 @@ void DialogSelection::Process(wxCommandEvent&) { } if (count == 0) - wxMessageBox(message, _("Selection"), wxOK); + wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this); else wxGetApp().frame->StatusTimeout(message); diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index b43784b62..b5e497bdd 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -92,14 +92,14 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) // List of supported spellchecker languages { if (!spellchecker.get()) { - wxMessageBox("No spellchecker available.", "Error", wxICON_ERROR | wxOK); + wxMessageBox("No spellchecker available.", "Error", wxOK | wxICON_ERROR | wxCENTER); Destroy(); return; } dictionary_lang_codes = spellchecker->GetLanguageList(); if (dictionary_lang_codes.empty()) { - wxMessageBox("No spellchecker dictionaries available.", "Error", wxICON_ERROR | wxOK); + wxMessageBox("No spellchecker dictionaries available.", "Error", wxOK | wxICON_ERROR | wxCENTER); Destroy(); return; } diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 4af9ef2e8..c40546d85 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -428,7 +428,7 @@ void DialogStyleEditor::Apply(bool apply, bool close) { for (unsigned int i=0;iGetStyle(styles[i]) != style) || (!store && c->ass->GetStyle(styles[i]) != style)) { - wxMessageBox("There is already a style with this name. Please choose another name.", "Style name conflict.", wxICON_ERROR|wxOK); + wxMessageBox("There is already a style with this name. Please choose another name.", "Style name conflict.", wxOK | wxICON_ERROR | wxCENTER); return; } } diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 1368eb32e..4521b55e9 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -374,7 +374,7 @@ void DialogStyleManager::OnCatalogNew() { // Make sure that there is no storage with the same name (case insensitive search since Windows filenames are case insensitive) if (CatalogList->FindString(name, false) != wxNOT_FOUND) { - wxMessageBox(_("A catalog with that name already exists."), _("Catalog name conflict"), wxICON_ERROR|wxOK); + wxMessageBox(_("A catalog with that name already exists."), _("Catalog name conflict"), wxOK | wxICON_ERROR | wxCENTER); return; } @@ -746,7 +746,7 @@ static void do_move(Cont& styls, int type, int& first, int& last, bool storage) else if (type == 4) { // Get confirmation if (storage) { - int res = wxMessageBox(_("Are you sure? This cannot be undone!"), _("Sort styles"), wxYES_NO); + int res = wxMessageBox(_("Are you sure? This cannot be undone!"), _("Sort styles"), wxYES_NO | wxCENTER); if (res == wxNO) return; } diff --git a/aegisub/src/dialog_timing_processor.cpp b/aegisub/src/dialog_timing_processor.cpp index 35e02a395..fa8108558 100644 --- a/aegisub/src/dialog_timing_processor.cpp +++ b/aegisub/src/dialog_timing_processor.cpp @@ -324,7 +324,7 @@ std::vector DialogTimingProcessor::SortDialogues() { wxMessageBox( wxString::Format(_("One of the lines in the file (%i) has negative duration. Aborting."), i), _("Invalid script"), - wxICON_ERROR|wxOK); + wxOK | wxICON_ERROR | wxCENTER); sorted.clear(); break; } diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 2178467e4..e5788665c 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -214,7 +214,7 @@ FrameMain::FrameMain (wxArrayString args) StartupLog("Possibly perform automatic updates check"); if (OPT_GET("App/First Start")->GetBool()) { OPT_SET("App/First Start")->SetBool(false); - int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"),wxYES_NO); + int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER); OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES); } @@ -326,20 +326,20 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) { context->ass->Load(filename,charset); } catch (agi::FileNotFoundError const&) { - wxMessageBox(filename + " not found.", "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox(filename + " not found.", "Error", wxOK | wxICON_ERROR | wxCENTER, this); config::mru->Remove("Subtitle", STD_STR(filename)); return; } catch (const char *err) { - wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } catch (wxString const& err) { - wxMessageBox(err, "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } catch (...) { - wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR, NULL); + wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this); return; } } @@ -448,7 +448,7 @@ void FrameMain::OnVideoOpen() { LOG_D("video/open/audio") << "File " << context->videoController->GetVideoName() << " has no audio data: " << e.GetChainedMessage(); } catch (agi::AudioOpenError const& err) { - wxMessageBox(lagi_wxString(err.GetMessage()), "Error loading audio", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(err.GetMessage()), "Error loading audio", wxOK | wxICON_ERROR | wxCENTER); } } } diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index ae885bb8f..4414cf7b7 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -336,7 +336,7 @@ static void UnhandledExeception(bool stackWalk) { #endif // Inform user of crash. - wxMessageBox(wxString::Format(exception_message, filename), _("Program error"), wxOK | wxICON_ERROR, NULL); + wxMessageBox(wxString::Format(exception_message, filename), _("Program error"), wxOK | wxICON_ERROR | wxCENTER, NULL); } else if (LastStartupState) { #if wxUSE_STACKWALKER == 1 @@ -345,7 +345,7 @@ static void UnhandledExeception(bool stackWalk) { walker.WalkFromException(); } #endif - wxMessageBox(wxString::Format("Aegisub has crashed while starting up!\n\nThe last startup step attempted was: %s.", LastStartupState), _("Program error"), wxOK | wxICON_ERROR); + wxMessageBox(wxString::Format("Aegisub has crashed while starting up!\n\nThe last startup step attempted was: %s.", LastStartupState), _("Program error"), wxOK | wxICON_ERROR | wxCENTER); } #endif } @@ -362,7 +362,7 @@ void AegisubApp::OnFatalException() { } void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const { -#define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK|wxICON_ERROR|wxSTAY_ON_TOP) +#define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK | wxICON_ERROR | wxCENTER | wxSTAY_ON_TOP) try { wxApp::HandleEvent(handler, func, event); } diff --git a/aegisub/src/subs_preview.cpp b/aegisub/src/subs_preview.cpp index 82eabb3b7..c03832f00 100644 --- a/aegisub/src/subs_preview.cpp +++ b/aegisub/src/subs_preview.cpp @@ -141,7 +141,7 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) { wxMessageBox( "Could not get any subtitles provider for the preview box. Make " "sure that you have a provider installed.", - "No subtitles provider", wxICON_ERROR | wxOK); + "No subtitles provider", wxOK | wxICON_ERROR | wxCENTER); } subFile->SetScriptInfo("PlayResX", wxString::Format("%d", w)); diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 7e4677c05..21889b507 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -162,7 +162,12 @@ void VideoContext::SetVideo(const wxString &filename) { else if (sx % vx != 0 || sy % vy != 0) { switch (OPT_GET("Video/Check Script Res")->GetInt()) { case 1: // Ask to change on mismatch - if (wxMessageBox(wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy), _("Resolution mismatch"), wxYES_NO, context->parent) != wxYES) + if (wxYES != wxMessageBox( + wxString::Format(_("The resolution of the loaded video and the resolution specified for the subtitles don't match.\n\nVideo resolution:\t%d x %d\nScript resolution:\t%d x %d\n\nChange subtitles resolution to match video?"), vx, vy, sx, sy), + _("Resolution mismatch"), + wxYES_NO | wxCENTER, + context->parent)) + break; // Fallthrough to case 2 case 2: // Always change script res @@ -216,10 +221,10 @@ void VideoContext::SetVideo(const wxString &filename) { catch (agi::UserCancelException const&) { } catch (agi::FileNotAccessibleError const& err) { config::mru->Remove("Video", STD_STR(filename)); - wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } catch (VideoProviderError const& err) { - wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxICON_ERROR | wxOK); + wxMessageBox(lagi_wxString(err.GetMessage()), "Error setting video", wxOK | wxICON_ERROR | wxCENTER); } } @@ -417,7 +422,7 @@ void VideoContext::LoadKeyframes(wxString filename) { config::mru->Add("Keyframes", STD_STR(filename)); } catch (agi::keyframe::Error const& err) { - wxMessageBox(err.GetMessage(), "Error opening keyframes file", wxOK | wxICON_ERROR, NULL); + wxMessageBox(err.GetMessage(), "Error opening keyframes file", wxOK | wxICON_ERROR | wxCENTER, context->parent); config::mru->Remove("Keyframes", STD_STR(filename)); } catch (agi::FileSystemError const&) {