X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..bd0df01f3f59940fdbca7a3472c256be2d034ab9:/src/gtk/dialog.cpp diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 1756334f0c..6411ba1930 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -17,6 +17,10 @@ #include "wx/app.h" #include "wx/gtk/win_gtk.h" +//----------------------------------------------------------------------------- + +extern wxList wxPendingDelete; + //----------------------------------------------------------------------------- // delete @@ -50,7 +54,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxWindow) wxDialog::wxDialog(void) { m_title = ""; - m_modalShowing = TRUE; + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); }; @@ -59,6 +63,7 @@ wxDialog::wxDialog( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); }; @@ -72,8 +77,6 @@ bool wxDialog::Create( wxWindow *parent, PreCreation( parent, id, pos, size, style, name ); - m_modalShowing = ((m_windowStyle & wxDIALOG_MODAL) == wxDIALOG_MODAL); - m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); @@ -120,7 +123,9 @@ void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { if (IsModal()) + { EndModal(wxID_CANCEL); + } else { SetReturnCode(wxID_CANCEL); @@ -133,14 +138,15 @@ void wxDialog::OnOk( wxCommandEvent &WXUNUSED(event) ) if ( Validate() && TransferDataFromWindow()) { if (IsModal()) + { EndModal(wxID_OK); + } else { SetReturnCode(wxID_OK); this->Show(FALSE); }; }; - EndModal( wxID_OK ); }; void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) @@ -153,7 +159,7 @@ bool wxDialog::OnClose(void) static wxList closing; if (closing.Member(this)) return FALSE; // no loops - + closing.Append(this); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); @@ -164,6 +170,14 @@ bool wxDialog::OnClose(void) return FALSE; } +bool wxDialog::Destroy(void) +{ + if (!wxPendingDelete.Member(this)) + wxPendingDelete.Append(this); + + return TRUE; +} + void wxDialog::OnCloseWindow(wxCloseEvent& event) { if (GetEventHandler()->OnClose() || event.GetForce()) @@ -174,7 +188,7 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) bool wxDialog::Show( bool show ) { - if (!show && m_modalShowing) + if (!show && IsModal() && m_modalShowing) { EndModal( wxID_CANCEL ); }; @@ -183,26 +197,32 @@ bool wxDialog::Show( bool show ) if (show) InitDialog(); - if (show && m_modalShowing) - { - gtk_grab_add( m_widget ); - gtk_main(); - gtk_grab_remove( m_widget ); - }; - return TRUE; }; int wxDialog::ShowModal(void) { + if (m_modalShowing) return GetReturnCode(); + Show( TRUE ); + + m_modalShowing = TRUE; + + gtk_grab_add( m_widget ); + gtk_main(); + gtk_grab_remove( m_widget ); + return GetReturnCode(); }; void wxDialog::EndModal( int retCode ) { - gtk_main_quit(); SetReturnCode( retCode ); + + if (!m_modalShowing) return; + m_modalShowing = FALSE; + + gtk_main_quit(); }; void wxDialog::InitDialog(void)