// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
- #pragma implementation "univdialog.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
+#include "wx/dialog.h"
+
#ifndef WX_PRECOMP
- #include "wx/dialog.h"
#include "wx/utils.h"
#include "wx/app.h"
#endif
m_returnCode = 0;
m_windowDisabler = NULL;
m_eventLoop = NULL;
- m_isShowingModal = FALSE;
+ m_isShowingModal = false;
}
wxDialog::~wxDialog()
{
+ // if the dialog is modal, this will end its event loop
+ Show(false);
+
delete m_eventLoop;
}
void wxDialog::OnApply(wxCommandEvent &WXUNUSED(event))
{
- if ( Validate() )
+ if ( Validate() )
TransferDataFromWindow();
}
else
{
SetReturnCode(wxID_CANCEL);
- Show(FALSE);
+ Show(false);
}
}
else
{
SetReturnCode(wxID_OK);
- Show(FALSE);
+ Show(false);
}
}
}
EndModal(wxID_CANCEL);
}
+ if (show && CanDoLayoutAdaptation())
+ DoLayoutAdaptation();
+
bool ret = wxDialogBase::Show(show);
- if ( show )
+ if ( show )
InitDialog();
return ret;
return m_isShowingModal;
}
-void wxDialog::SetModal(bool WXUNUSED(flag))
-{
- wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") );
-}
-
int wxDialog::ShowModal()
{
if ( IsModal() )
// forbidden
if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
{
- wxWindow *parent = wxTheApp->GetTopWindow();
+ wxWindow * const parent = GetParentForModalDialog();
if ( parent && parent != this )
{
m_parent = parent;
}
}
- Show(TRUE);
+ Show(true);
- m_isShowingModal = TRUE;
+ m_isShowingModal = true;
- wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") );
+ wxASSERT_MSG( !m_windowDisabler, wxT("disabling windows twice?") );
#if defined(__WXGTK__) || defined(__WXMGL__)
wxBusyCursorSuspender suspender;
void wxDialog::EndModal(int retCode)
{
- wxASSERT_MSG( m_eventLoop, _T("wxDialog is not modal") );
+ wxASSERT_MSG( m_eventLoop, wxT("wxDialog is not modal") );
SetReturnCode(retCode);
return;
}
- m_isShowingModal = FALSE;
-
+ m_isShowingModal = false;
+
m_eventLoop->Exit();
- Show(FALSE);
+ Show(false);
}