X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e181c7a2c32193fc8138cc32ed07984eadd4a21..f941a30bef665561d96d29c4cee07471dbbd497f:/src/osx/cocoa/msgdlg.mm diff --git a/src/osx/cocoa/msgdlg.mm b/src/osx/cocoa/msgdlg.mm index 2189cdf610..504e019070 100644 --- a/src/osx/cocoa/msgdlg.mm +++ b/src/osx/cocoa/msgdlg.mm @@ -30,40 +30,8 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& caption, long style, const wxPoint& WXUNUSED(pos)) - : wxMessageDialogBase(parent, message, caption, style) + : wxMessageDialogWithCustomLabels(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() @@ -113,10 +81,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(), GetFont().GetEncoding() ); + wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() ); + wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding()) ; + wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() ); int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ }; @@ -165,18 +133,18 @@ int wxMessageDialog::ShowModal() else { NSAlert* alert = [[NSAlert alloc] init]; - - 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(), GetFont().GetEncoding() ); + wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() ); + wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding() ); + wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() ); wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() ); wxCFStringRef cfText( msgtext, GetFont().GetEncoding() ); [alert setMessageText:cfTitle.AsNSString()]; [alert setInformativeText:cfText.AsNSString()]; - + int buttonId[3] = { 0, 0, 0 }; int buttonCount = 0; @@ -215,10 +183,34 @@ int wxMessageDialog::ShowModal() } } - int button = [alert runModal]; - + + wxNonOwnedWindow* parentWindow = NULL; + int button = -1; + + if (GetParent()) + { + parentWindow = dynamic_cast(wxGetTopLevelParent(GetParent())); + } + + /* + if (parentWindow) + { + NSWindow* nativeParent = parentWindow->GetWXWindow(); + ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; + [alert beginSheetModalForWindow: nativeParent modalDelegate: sheetDelegate + didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo: nil]; + [sheetDelegate waitForSheetToFinish]; + button = [sheetDelegate code]; + [sheetDelegate release]; + } + else +*/ + { + button = [alert runModal]; + } [alert release]; - + if ( button < NSAlertFirstButtonReturn ) resultbutton = wxID_CANCEL; else