#include "wx/app.h"
#include "wx/gtk/win_gtk.h"
+//-----------------------------------------------------------------------------
+
+extern wxList wxPendingDelete;
+
//-----------------------------------------------------------------------------
// delete
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 );
};
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 );
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
{
if (IsModal())
+ {
EndModal(wxID_CANCEL);
+ }
else
{
SetReturnCode(wxID_CANCEL);
if ( Validate() && TransferDataFromWindow())
{
if (IsModal())
+ {
EndModal(wxID_OK);
+ }
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
};
};
- EndModal( wxID_OK );
};
void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
static wxList closing;
if (closing.Member(this)) return FALSE; // no loops
-
+
closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
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())
};
};
-bool wxDialog::Show( const bool show )
+bool wxDialog::Show( bool show )
{
- if (!show && m_modalShowing)
+ if (!show && IsModal() && m_modalShowing)
{
EndModal( wxID_CANCEL );
};
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)