X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b02d42e37a2fc25e16644e5276ac3df22cd1690..059d234d4176165d975048eaa5436ef40af7d037:/src/msw/msgdlg.cpp diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 04e2e68262..108beb7d1b 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -30,6 +30,7 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/intl.h" #include "wx/utils.h" #include "wx/dialog.h" #if wxUSE_MSGBOX_HOOK @@ -200,9 +201,9 @@ void wxMessageDialog::ReplaceStaticWithEdit() // find the static control to replace: normally there are two of them, the // icon and the text itself so search for all of them and ignore the icon // ones - HWND hwndStatic = ::FindWindowEx(GetHwnd(), NULL, _T("STATIC"), NULL); + HWND hwndStatic = ::FindWindowEx(GetHwnd(), NULL, wxT("STATIC"), NULL); if ( ::GetWindowLong(hwndStatic, GWL_STYLE) & SS_ICON ) - hwndStatic = ::FindWindowEx(GetHwnd(), hwndStatic, _T("STATIC"), NULL); + hwndStatic = ::FindWindowEx(GetHwnd(), hwndStatic, wxT("STATIC"), NULL); if ( !hwndStatic ) { @@ -257,8 +258,8 @@ void wxMessageDialog::ReplaceStaticWithEdit() // do create the new control HWND hwndEdit = ::CreateWindow ( - _T("EDIT"), - wxTextBuffer::Translate(text), + wxT("EDIT"), + wxTextBuffer::Translate(text).wx_str(), WS_CHILD | WS_VSCROLL | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL, rc.left, rc.top, @@ -442,13 +443,41 @@ int wxMessageDialog::ShowModal() // use the top level window as parent if none specified if ( !m_parent ) - m_parent = FindSuitableParent(); + m_parent = GetParentForModalDialog(); HWND hWnd = m_parent ? GetHwndOf(m_parent) : NULL; +#if wxUSE_INTL + // native message box always uses the current user locale but the program + // may be using a different one and in this case we need to manually + // translate the button labels to avoid mismatch between the language of + // the message box text and its buttons + wxLocale * const loc = wxGetLocale(); + if ( loc && loc->GetLanguage() != wxLocale::GetSystemLanguage() ) + { + if ( m_dialogStyle & wxYES_NO ) + { + // use the strings with mnemonics here as the native message box + // does + SetYesNoLabels(_("&Yes"), _("&No")); + } + + // we may or not have the Ok/Cancel buttons but either we do have them + // or we already made the labels custom because we called + // SetYesNoLabels() above so doing this does no harm -- and is + // necessary in wxYES_NO | wxCANCEL case + // + // note that we don't use mnemonics here for consistency with the + // native message box (which probably doesn't use them because + // Enter/Esc keys can be already used to dismiss the message box + // using keyboard) + SetOKCancelLabels(_("OK"), _("Cancel")); + } +#endif // wxUSE_INTL + // translate wx style in MSW - unsigned int msStyle = MB_OK; + unsigned int msStyle; const long wxStyle = GetMessageDialogStyle(); - if (wxStyle & wxYES_NO) + if ( wxStyle & wxYES_NO ) { #if !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) if (wxStyle & wxCANCEL) @@ -457,17 +486,26 @@ int wxMessageDialog::ShowModal() #endif // !(__SMARTPHONE__ && __WXWINCE__) msStyle = MB_YESNO; - if (wxStyle & wxNO_DEFAULT) + if ( wxStyle & wxNO_DEFAULT ) msStyle |= MB_DEFBUTTON2; + else if ( wxStyle & wxCANCEL_DEFAULT ) + msStyle |= MB_DEFBUTTON3; } - - if (wxStyle & wxOK) + else // without Yes/No we're going to have an OK button { - if (wxStyle & wxCANCEL) + if ( wxStyle & wxCANCEL ) + { msStyle = MB_OKCANCEL; - else + + if ( wxStyle & wxCANCEL_DEFAULT ) + msStyle |= MB_DEFBUTTON2; + } + else // just "OK" + { msStyle = MB_OK; + } } + if (wxStyle & wxICON_EXCLAMATION) msStyle |= MB_ICONEXCLAMATION; else if (wxStyle & wxICON_HAND) @@ -519,7 +557,7 @@ int wxMessageDialog::ShowModal() switch (msAns) { default: - wxFAIL_MSG(_T("unexpected ::MessageBox() return code")); + wxFAIL_MSG(wxT("unexpected ::MessageBox() return code")); // fall through case IDCANCEL: