// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "univdialog.h"
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
#endif
#include "wx/dialog.h"
-#include "wx/utils.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/utils.h"
+ #include "wx/app.h"
+#endif
+
#include "wx/evtloop.h"
-#include "wx/app.h"
//-----------------------------------------------------------------------------
// wxDialog
EVT_CLOSE (wxDialog::OnCloseWindow)
END_EVENT_TABLE()
-IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow)
-
void wxDialog::Init()
{
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);
}
}
}
// if we had disabled other app windows, reenable them back now because
// if they stay disabled Windows will activate another window (one
// which is enabled, anyhow) and we will lose activation
- if ( m_windowDisabler )
- {
- delete m_windowDisabler;
- m_windowDisabler = NULL;
- }
+ wxDELETE(m_windowDisabler);
if ( IsModal() )
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() )
// use the apps top level window as parent if none given unless explicitly
// forbidden
- if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
+ wxWindow * const parent = GetParentForModalDialog();
+ if ( parent && parent != this )
{
- wxWindow *parent = wxTheApp->GetTopWindow();
- if ( parent && parent != this )
- {
- m_parent = parent;
- }
+ m_parent = parent;
}
- wxBusyCursorSuspender cs; // temporarily suppress the busy cursor
+ Show(true);
- Show(TRUE);
+ m_isShowingModal = true;
- m_isShowingModal = TRUE;
+ wxASSERT_MSG( !m_windowDisabler, wxT("disabling windows twice?") );
- wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") );
+#if defined(__WXGTK__) || defined(__WXMGL__)
+ wxBusyCursorSuspender suspender;
+ // FIXME (FIXME_MGL) - make sure busy cursor disappears under MSW too
+#endif
m_windowDisabler = new wxWindowDisabler(this);
if ( !m_eventLoop )
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);
}