X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/489468feaa08b8f504735eecca522fb8d0f825d2..bb996f289574defb0ae4339ae8e46ff3cf6fa54c:/src/osx/carbon/msgdlg.cpp diff --git a/src/osx/carbon/msgdlg.cpp b/src/osx/carbon/msgdlg.cpp index 830efb6f27..b0671595c9 100644 --- a/src/osx/carbon/msgdlg.cpp +++ b/src/osx/carbon/msgdlg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/msgdlg.cpp +// Name: src/osx/carbon/msgdlg.cpp // Purpose: wxMessageDialog // Author: Stefan Csomor // Modified by: @@ -19,7 +19,7 @@ #endif #include "wx/thread.h" -#include "wx/mac/uma.h" +#include "wx/osx/uma.h" IMPLEMENT_CLASS(wxMessageDialog, wxDialog) @@ -32,38 +32,6 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxPoint& WXUNUSED(pos)) : wxMessageDialogBase(parent, message, caption, style) { - m_yes = _("Yes"); - m_no = _("No"); - m_ok = _("OK"); - m_cancel = _("Cancel"); -} - -bool wxMessageDialog::SetYesNoLabels(const wxString& yes,const wxString& no) -{ - m_yes = yes; - m_no = no; - return true; -} - -bool wxMessageDialog::SetYesNoCancelLabels(const wxString& yes, const wxString& no, const wxString& cancel) -{ - m_yes = yes; - m_no = no; - m_cancel = cancel; - return true; -} - -bool wxMessageDialog::SetOKLabel(const wxString& ok) -{ - m_ok = ok; - return true; -} - -bool wxMessageDialog::SetOKCancelLabels(const wxString& ok, const wxString& cancel) -{ - m_ok = ok; - m_cancel = cancel; - return true; } int wxMessageDialog::ShowModal() @@ -72,30 +40,47 @@ int wxMessageDialog::ShowModal() const long style = GetMessageDialogStyle(); - wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") ); + wxASSERT_MSG( (style & 0x3F) != wxYES, + "this style is not supported on Mac" ); AlertType alertType = kAlertPlainAlert; - if (style & wxICON_EXCLAMATION) - alertType = kAlertCautionAlert; - else if (style & wxICON_HAND) - alertType = kAlertStopAlert; - else if (style & wxICON_INFORMATION) - alertType = kAlertNoteAlert; - else if (style & wxICON_QUESTION) - alertType = kAlertNoteAlert; - - - // work out what to display - // if the extended text is empty then we use the caption as the title - // and the message as the text (for backwards compatibility) - // but if the extended message is not empty then we use the message as the title - // and the extended message as the text because that makes more sense + + switch ( GetEffectiveIcon() ) + { + case wxICON_ERROR: + alertType = kAlertStopAlert; + break; + + case wxICON_WARNING: + alertType = kAlertCautionAlert; + break; + + case wxICON_QUESTION: + case wxICON_INFORMATION: + alertType = kAlertNoteAlert; + break; + } + + // (the standard alert has two slots [title, text] + // for the three wxStrings [caption, message, extended message]) + // + // if the extended text is empty we use the caption and + // the message (for backwards compatibility) + // + // if the extended text is not empty we ignore the caption + // and use the message and the extended message + wxString msgtitle,msgtext; if(m_extendedMessage.IsEmpty()) { - msgtitle = m_caption; - msgtext = m_message; + if ( m_caption.IsEmpty() ) + msgtitle = m_message; + else + { + msgtitle = m_caption; + msgtext = m_message; + } } else { @@ -113,10 +98,10 @@ int wxMessageDialog::ShowModal() wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() ); wxCFStringRef cfText( msgtext, GetFont().GetEncoding() ); - wxCFStringRef cfNoString( m_no.c_str(), GetFont().GetEncoding() ); - wxCFStringRef cfYesString( m_yes.c_str(), GetFont().GetEncoding() ); - wxCFStringRef cfOKString( m_ok.c_str() , GetFont().GetEncoding()) ; - wxCFStringRef cfCancelString( m_cancel.c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfOKString( GetOKLabel().c_str() , GetFont().GetEncoding()) ; + wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() ); int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ }; @@ -167,13 +152,13 @@ int wxMessageDialog::ShowModal() short result; AlertStdCFStringAlertParamRec param; - wxCFStringRef cfNoString( m_no.c_str(), GetFont().GetEncoding() ); - wxCFStringRef cfYesString( m_yes.c_str(), GetFont().GetEncoding() ); - wxCFStringRef cfOKString( m_ok.c_str(), GetFont().GetEncoding() ); - wxCFStringRef cfCancelString( m_cancel.c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfOKString( GetOKLabel().c_str(), GetFont().GetEncoding() ); + wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() ); wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() ); - wxCFStringRef cfText( msgtext, GetFont().GetEncoding() ); + wxCFStringRef cfText = msgtext.IsEmpty() ? NULL : wxCFStringRef( msgtext, GetFont().GetEncoding() ); param.movable = true; param.flags = 0; @@ -231,7 +216,9 @@ int wxMessageDialog::ShowModal() { DialogRef alertRef; CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef ); + wxDialog::OSXBeginModalDialog(); RunStandardAlert( alertRef, NULL, &result ); + wxDialog::OSXEndModalDialog(); } else { @@ -280,5 +267,7 @@ int wxMessageDialog::ShowModal() } } + SetReturnCode(resultbutton); + return resultbutton; }