]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/msgdlg.mm
wiring OnInit on osx to a later point in event processing
[wxWidgets.git] / src / osx / cocoa / msgdlg.mm
index ad44f5560058760d57947ba283a4ebfadc735d99..40ed938450cc39086eef58770f64eb8d3a2283f8 100644 (file)
     #include "wx/app.h"
 #endif
 
+#include "wx/control.h"
 #include "wx/thread.h"
+#include "wx/evtloop.h"
+#include "wx/modalhook.h"
 #include "wx/osx/private.h"
 
 
@@ -60,6 +63,10 @@ wxMessageDialog::~wxMessageDialog()
 
 int wxMessageDialog::ShowModal()
 {
+    WX_HOOK_MODAL_DIALOG();
+
+    wxCFEventLoopPauseIdleEvents pause;
+    
     int resultbutton = wxID_CANCEL;
 
     const long style = GetMessageDialogStyle();
@@ -94,10 +101,10 @@ int wxMessageDialog::ShowModal()
         wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
         wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
 
-        wxCFStringRef cfNoString( GetNoLabel(), GetFont().GetEncoding() );
-        wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() );
-        wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding()) ;
-        wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() );
+        wxCFStringRef cfNoString( wxControl::GetLabelText(GetNoLabel()), GetFont().GetEncoding() );
+        wxCFStringRef cfYesString( wxControl::GetLabelText(GetYesLabel()), GetFont().GetEncoding() );
+        wxCFStringRef cfOKString( wxControl::GetLabelText(GetOKLabel()), GetFont().GetEncoding()) ;
+        wxCFStringRef cfCancelString( wxControl::GetLabelText(GetCancelLabel()), GetFont().GetEncoding() );
 
         NSAlertStyle alertType = GetAlertStyleFromWXStyle(style);
                 
@@ -138,6 +145,8 @@ int wxMessageDialog::ShowModal()
             }
         }
 
+        wxASSERT_MSG( !(style & wxHELP), "wxHELP not supported in non-GUI thread" );
+
         CFOptionFlags exitButton;
         OSStatus err = CFUserNotificationDisplayAlert(
             0, alertType, NULL, NULL, NULL, cfTitle, cfText,
@@ -225,10 +234,10 @@ void* wxMessageDialog::ConstructNSAlert()
     NSAlert* alert = [[NSAlert alloc] init];
     NSAlertStyle alertType = GetAlertStyleFromWXStyle(style);
 
-    wxCFStringRef cfNoString( GetNoLabel(), GetFont().GetEncoding() );
-    wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() );
-    wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding() );
-    wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() );
+    wxCFStringRef cfNoString( wxControl::GetLabelText(GetNoLabel()), GetFont().GetEncoding() );
+    wxCFStringRef cfYesString( wxControl::GetLabelText(GetYesLabel()), GetFont().GetEncoding() );
+    wxCFStringRef cfOKString( wxControl::GetLabelText(GetOKLabel()), GetFont().GetEncoding() );
+    wxCFStringRef cfCancelString( wxControl::GetLabelText(GetCancelLabel()), GetFont().GetEncoding() );
 
     wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
     wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
@@ -285,5 +294,15 @@ void* wxMessageDialog::ConstructNSAlert()
         }
 
     }
+
+    if ( style & wxHELP )
+    {
+        wxCFStringRef cfHelpString( GetHelpLabel(), GetFont().GetEncoding() );
+        [alert addButtonWithTitle:cfHelpString.AsNSString()];
+        m_buttonId[ m_buttonCount++ ] = wxID_HELP;
+    }
+
+    wxASSERT_MSG( m_buttonCount <= WXSIZEOF(m_buttonId), "Too many buttons" );
+
     return alert;
 }