X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6991087b08355e652866e97d3a8211103864ed8f..b0ad146aba58fae678c885a9bc5e30d79bffb494:/src/motif/dialog.cpp diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 95abbae57c..dde1f58290 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -4,7 +4,6 @@ // Author: Julian Smart // Modified by: // Created: 17/09/98 -// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,13 +11,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __VMS -#define XtDisplay XTDISPLAY -#define XtWindow XTWINDOW -#define XtParent XTPARENT -#define XtScreen XTSCREEN -#endif - #include "wx/dialog.h" #ifndef WX_PRECOMP @@ -28,6 +20,7 @@ #endif #include "wx/evtloop.h" +#include "wx/modalhook.h" #ifdef __VMS__ #pragma message disable nosimpint @@ -69,8 +62,6 @@ extern wxList wxModelessWindows; // Frames and modeless dialogs #define wxUSE_INVISIBLE_RESIZE 1 -IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow) - wxDialog::wxDialog() { m_modalShowing = false; @@ -188,7 +179,10 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { - m_isBeingDeleted = true; + SendDestroyEvent(); + + // if the dialog is modal, this will end its event loop + Show(false); delete m_eventLoop; @@ -248,10 +242,16 @@ bool wxDialog::Show( bool show ) if( !wxWindowBase::Show( show ) ) return false; + if ( !show && IsModal() ) + EndModal(wxID_CANCEL); + m_isShown = show; if (show) { + if (CanDoLayoutAdaptation()) + DoLayoutAdaptation(); + // this usually will result in TransferDataToWindow() being called // which will change the controls values so do it before showing as // otherwise we could have some flicker @@ -288,6 +288,8 @@ bool wxDialog::Show( bool show ) // Shows a dialog modally, returning a return code int wxDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + Show(true); // after the event loop ran, the widget might already have been destroyed @@ -305,8 +307,7 @@ int wxDialog::ShowModal() // Now process all events in case they get sent to a destroyed dialog wxFlushEvents( display ); - delete m_eventLoop; - m_eventLoop = NULL; + wxDELETE(m_eventLoop); // TODO: is it safe to call this, if the dialog may have been deleted // by now? Probably only if we're using delayed deletion of dialogs.