Center most of the message boxes over their parent windows

Originally committed to SVN as r6629.
This commit is contained in:
Thomas Goyne 2012-03-28 23:59:19 +00:00
parent 31a0146df2
commit c4a1a93b97
17 changed files with 46 additions and 41 deletions

View File

@ -83,7 +83,7 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
// Get proper format reader // Get proper format reader
const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename); const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
if (!reader) { if (!reader) {
wxMessageBox("Unknown file type","Error loading file",wxICON_ERROR | wxOK); wxMessageBox("Unknown file type","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return; return;
} }
@ -114,12 +114,12 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
} }
// Real exception // Real exception
catch (agi::Exception &e) { 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; return;
} }
// Other error // Other error
catch (...) { catch (...) {
wxMessageBox("Unknown error","Error loading file",wxICON_ERROR | wxOK); wxMessageBox("Unknown error","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return; return;
} }

View File

@ -192,7 +192,7 @@ struct app_language : public Command {
OPT_SET("App/Locale")->SetInt(newCode); OPT_SET("App/Locale")->SetInt(newCode);
// Ask to restart program // 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) { if (result == wxYES) {
// Restart Aegisub // Restart Aegisub
if (wxGetApp().frame->Close()) { if (wxGetApp().frame->Close()) {

View File

@ -105,7 +105,7 @@ struct audio_open : public Command {
} }
catch (agi::UserCancelException const&) { } catch (agi::UserCancelException const&) { }
catch (agi::Exception const& e) { 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"); c->audioController->OpenAudio("dummy-audio:silence?sr=44100&bd=16&ch=1&ln=396900000");
} }
catch (agi::Exception const& e) { 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"); c->audioController->OpenAudio("dummy-audio:noise?sr=44100&bd=16&ch=1&ln=396900000");
} }
catch (agi::Exception const& e) { 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::UserCancelException const&) { }
catch (agi::Exception const& e) { 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);
} }
} }
}; };

View File

@ -75,7 +75,7 @@ struct recent_audio_entry : public Command {
} }
catch (agi::UserCancelException const&) { } catch (agi::UserCancelException const&) { }
catch (agi::Exception const& e) { 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);
} }
} }
}; };

View File

@ -335,13 +335,13 @@ static void save_subtitles(agi::Context *c, wxString filename) {
c->ass->Save(filename, true, true); c->ass->Save(filename, true, true);
} }
catch (const agi::Exception& err) { 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) { catch (const char *err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, c->parent);
} }
catch (...) { catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, c->parent);
} }
} }

View File

@ -154,7 +154,7 @@ struct video_aspect_custom : public validator_video_loaded {
} }
// Sanity check // 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 // Set value
else { else {

View File

@ -157,16 +157,16 @@ void DialogExport::OnProcess(wxCommandEvent &) {
catch (agi::UserCancelException const&) { catch (agi::UserCancelException const&) {
} }
catch (const char *error) { 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) { 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) { 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 (...) { catch (...) {
wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR, this); wxMessageBox("Unknown error", "Error exporting subtitles", wxOK | wxICON_ERROR | wxCENTER, this);
} }
EndModal(0); EndModal(0);

View File

@ -271,16 +271,16 @@ void DialogFontsCollector::OnStart(wxCommandEvent &) {
} }
if (folder.FileExists()) if (folder.FileExists())
wxMessageBox(_("Invalid destination."), _("Error"), wxICON_EXCLAMATION | wxOK); wxMessageBox(_("Invalid destination."), _("Error"), wxOK | wxICON_ERROR | wxCENTER, this);
if (!folder.DirExists()) if (!folder.DirExists())
folder.Mkdir(0777, wxPATH_MKDIR_FULL); folder.Mkdir(0777, wxPATH_MKDIR_FULL);
if (!folder.DirExists()) { 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; return;
} }
} }
else if (folder.IsDir() || folder.GetName().empty()) { 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; return;
} }
} }

View File

@ -254,7 +254,7 @@ void DialogSelection::Process(wxCommandEvent&) {
} }
if (count == 0) if (count == 0)
wxMessageBox(message, _("Selection"), wxOK); wxMessageBox(message, _("Selection"), wxOK | wxCENTER, this);
else else
wxGetApp().frame->StatusTimeout(message); wxGetApp().frame->StatusTimeout(message);

View File

@ -92,14 +92,14 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context)
// List of supported spellchecker languages // List of supported spellchecker languages
{ {
if (!spellchecker.get()) { if (!spellchecker.get()) {
wxMessageBox("No spellchecker available.", "Error", wxICON_ERROR | wxOK); wxMessageBox("No spellchecker available.", "Error", wxOK | wxICON_ERROR | wxCENTER);
Destroy(); Destroy();
return; return;
} }
dictionary_lang_codes = spellchecker->GetLanguageList(); dictionary_lang_codes = spellchecker->GetLanguageList();
if (dictionary_lang_codes.empty()) { 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(); Destroy();
return; return;
} }

View File

@ -428,7 +428,7 @@ void DialogStyleEditor::Apply(bool apply, bool close) {
for (unsigned int i=0;i<styles.Count();i++) { for (unsigned int i=0;i<styles.Count();i++) {
if (newStyleName.CmpNoCase(styles[i]) == 0) { if (newStyleName.CmpNoCase(styles[i]) == 0) {
if ((store && store->GetStyle(styles[i]) != style) || (!store && c->ass->GetStyle(styles[i]) != style)) { if ((store && store->GetStyle(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; return;
} }
} }

View File

@ -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) // 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) { 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; return;
} }
@ -746,7 +746,7 @@ static void do_move(Cont& styls, int type, int& first, int& last, bool storage)
else if (type == 4) { else if (type == 4) {
// Get confirmation // Get confirmation
if (storage) { 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; if (res == wxNO) return;
} }

View File

@ -324,7 +324,7 @@ std::vector<AssDialogue*> DialogTimingProcessor::SortDialogues() {
wxMessageBox( wxMessageBox(
wxString::Format(_("One of the lines in the file (%i) has negative duration. Aborting."), i), wxString::Format(_("One of the lines in the file (%i) has negative duration. Aborting."), i),
_("Invalid script"), _("Invalid script"),
wxICON_ERROR|wxOK); wxOK | wxICON_ERROR | wxCENTER);
sorted.clear(); sorted.clear();
break; break;
} }

View File

@ -214,7 +214,7 @@ FrameMain::FrameMain (wxArrayString args)
StartupLog("Possibly perform automatic updates check"); StartupLog("Possibly perform automatic updates check");
if (OPT_GET("App/First Start")->GetBool()) { if (OPT_GET("App/First Start")->GetBool()) {
OPT_SET("App/First Start")->SetBool(false); 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); 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); context->ass->Load(filename,charset);
} }
catch (agi::FileNotFoundError const&) { 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)); config::mru->Remove("Subtitle", STD_STR(filename));
return; return;
} }
catch (const char *err) { catch (const char *err) {
wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }
catch (wxString const& err) { catch (wxString const& err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }
catch (...) { catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR, NULL); wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }
} }
@ -448,7 +448,7 @@ void FrameMain::OnVideoOpen() {
LOG_D("video/open/audio") << "File " << context->videoController->GetVideoName() << " has no audio data: " << e.GetChainedMessage(); LOG_D("video/open/audio") << "File " << context->videoController->GetVideoName() << " has no audio data: " << e.GetChainedMessage();
} }
catch (agi::AudioOpenError const& err) { 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);
} }
} }
} }

View File

@ -336,7 +336,7 @@ static void UnhandledExeception(bool stackWalk) {
#endif #endif
// Inform user of crash. // 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) { else if (LastStartupState) {
#if wxUSE_STACKWALKER == 1 #if wxUSE_STACKWALKER == 1
@ -345,7 +345,7 @@ static void UnhandledExeception(bool stackWalk) {
walker.WalkFromException(); walker.WalkFromException();
} }
#endif #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 #endif
} }
@ -362,7 +362,7 @@ void AegisubApp::OnFatalException() {
} }
void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const { 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 { try {
wxApp::HandleEvent(handler, func, event); wxApp::HandleEvent(handler, func, event);
} }

View File

@ -141,7 +141,7 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
wxMessageBox( wxMessageBox(
"Could not get any subtitles provider for the preview box. Make " "Could not get any subtitles provider for the preview box. Make "
"sure that you have a provider installed.", "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)); subFile->SetScriptInfo("PlayResX", wxString::Format("%d", w));

View File

@ -162,7 +162,12 @@ void VideoContext::SetVideo(const wxString &filename) {
else if (sx % vx != 0 || sy % vy != 0) { else if (sx % vx != 0 || sy % vy != 0) {
switch (OPT_GET("Video/Check Script Res")->GetInt()) { switch (OPT_GET("Video/Check Script Res")->GetInt()) {
case 1: // Ask to change on mismatch 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; break;
// Fallthrough to case 2 // Fallthrough to case 2
case 2: // Always change script res case 2: // Always change script res
@ -216,10 +221,10 @@ void VideoContext::SetVideo(const wxString &filename) {
catch (agi::UserCancelException const&) { } catch (agi::UserCancelException const&) { }
catch (agi::FileNotAccessibleError const& err) { catch (agi::FileNotAccessibleError const& err) {
config::mru->Remove("Video", STD_STR(filename)); 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) { 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)); config::mru->Add("Keyframes", STD_STR(filename));
} }
catch (agi::keyframe::Error const& err) { 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)); config::mru->Remove("Keyframes", STD_STR(filename));
} }
catch (agi::FileSystemError const&) { catch (agi::FileSystemError const&) {