#include "wx/wxprec.h"
#include "wx/dialog.h"
+#include "wx/evtloop.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/osx/private.h"
+static int s_openDialogs = 0;
+bool wxDialog::OSXHasModalDialogsOpen()
+{
+ return s_openDialogs > 0;
+}
-// Lists to keep track of windows, so we can disable/enable them
-// for modal dialogs
+void wxDialog::OSXBeginModalDialog()
+{
+ s_openDialogs++;
+}
+
+void wxDialog::OSXEndModalDialog()
+{
+ wxASSERT_MSG( s_openDialogs > 0, "incorrect internal modal dialog count");
+ s_openDialogs--;
+}
-wxList wxModalDialogs;
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
void wxDialog::Init()
{
m_modality = wxDIALOG_MODALITY_NONE;
+ m_eventLoop = NULL;
}
bool wxDialog::Create( wxWindow *parent,
// Replacement for Show(true) for modal dialogs - returns return code
int wxDialog::ShowModal()
{
- m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
+ m_modality = wxDIALOG_MODALITY_APP_MODAL;
Show();
- DoShowModal();
-
+ wxModalEventLoop modalLoop(this);
+ m_eventLoop = &modalLoop;
+
+ wxDialog::OSXBeginModalDialog();
+ modalLoop.Run();
+ wxDialog::OSXEndModalDialog();
+
+ m_eventLoop = NULL;
+
return GetReturnCode();
}
// dialogs and should work for both of them
void wxDialog::EndModal(int retCode)
{
+ if ( m_eventLoop )
+ m_eventLoop->Exit(retCode);
+
SetReturnCode(retCode);
Show(false);
}