X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bfa92264c07d094c05e5a07a17fd7f5bcee8e81f..6178debcd342963974dbdce6ac2ddb2fbe89e42a:/src/osx/cocoa/msgdlg.mm?ds=sidebyside diff --git a/src/osx/cocoa/msgdlg.mm b/src/osx/cocoa/msgdlg.mm index 75557ec715..830d855ccc 100644 --- a/src/osx/cocoa/msgdlg.mm +++ b/src/osx/cocoa/msgdlg.mm @@ -25,6 +25,23 @@ IMPLEMENT_CLASS(wxMessageDialog, wxDialog) +namespace +{ + NSAlertStyle GetAlertStyleFromWXStyle( long style ) + { + NSAlertStyle alertType = NSWarningAlertStyle; + if (style & wxICON_EXCLAMATION) + alertType = NSCriticalAlertStyle; + else if (style & wxICON_HAND) + alertType = NSWarningAlertStyle; + else if (style & wxICON_INFORMATION) + alertType = NSInformationalAlertStyle; + else if (style & wxICON_QUESTION) + alertType = NSInformationalAlertStyle; + return alertType; + } +} + wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, @@ -42,17 +59,6 @@ int wxMessageDialog::ShowModal() wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") ); - NSAlertStyle alertType = NSWarningAlertStyle; - if (style & wxICON_EXCLAMATION) - alertType = NSCriticalAlertStyle; - else if (style & wxICON_HAND) - alertType = NSWarningAlertStyle; - else if (style & wxICON_INFORMATION) - alertType = NSInformationalAlertStyle; - else if (style & wxICON_QUESTION) - alertType = NSInformationalAlertStyle; - - // 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) @@ -86,6 +92,8 @@ int wxMessageDialog::ShowModal() wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding()) ; wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() ); + NSAlertStyle alertType = GetAlertStyleFromWXStyle(style); + int m_buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ }; if (style & wxYES_NO) @@ -210,6 +218,7 @@ void* wxMessageDialog::ConstructNSAlert() } NSAlert* alert = [[NSAlert alloc] init]; + NSAlertStyle alertType = GetAlertStyleFromWXStyle(style); wxCFStringRef cfNoString( GetNoLabel(), GetFont().GetEncoding() ); wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() ); @@ -221,6 +230,7 @@ void* wxMessageDialog::ConstructNSAlert() [alert setMessageText:cfTitle.AsNSString()]; [alert setInformativeText:cfText.AsNSString()]; + [alert setAlertStyle:alertType]; m_buttonCount = 0;