X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..86b29a6122ae09d47995bc8f8919cb96a6ca18c7:/src/gtk/dialog.cpp diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 0c63e39f11..4c394a33e5 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,15 +54,16 @@ IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxWindow) wxDialog::wxDialog(void) { m_title = ""; - m_modalShowing = TRUE; + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); }; wxDialog::wxDialog( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, - const long style, const wxString &name ) + long style, const wxString &name ) { + m_modalShowing = FALSE; wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); }; @@ -66,14 +71,12 @@ wxDialog::wxDialog( wxWindow *parent, bool wxDialog::Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, - const long style, const wxString &name ) + long style, const wxString &name ) { m_needParent = FALSE; 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 ); @@ -104,6 +107,7 @@ wxDialog::~wxDialog(void) void wxDialog::SetTitle(const wxString& title ) { m_title = title; + if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); }; @@ -120,7 +124,9 @@ void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) { if (IsModal()) + { EndModal(wxID_CANCEL); + } else { SetReturnCode(wxID_CANCEL); @@ -133,14 +139,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 +160,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 +171,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()) @@ -172,9 +187,9 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) }; }; -bool wxDialog::Show( const bool show ) +bool wxDialog::Show( bool show ) { - if (!show && m_modalShowing) + if (!show && IsModal() && m_modalShowing) { EndModal( wxID_CANCEL ); }; @@ -183,26 +198,37 @@ bool wxDialog::Show( const 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) + { + wxFAIL_MSG( "wxDialog: called EndModal twice" ); + return; + }; + + m_modalShowing = FALSE; + + gtk_main_quit(); }; void wxDialog::InitDialog(void)