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

View file

@ -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()) {

View file

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

View file

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

View file

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

View file

@ -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 {

View file

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

View file

@ -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;
}
}

View file

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

View file

@ -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;
}

View file

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

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

View file

@ -324,7 +324,7 @@ std::vector<AssDialogue*> 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;
}

View file

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

View file

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

View file

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

View file

@ -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&) {