more wxCloseEvent changes: now the behaviour should be conforming to the one
described in the docs (i.e. like Julian wants it) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -762,10 +762,17 @@ public:
|
|||||||
void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
|
void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
|
||||||
bool GetLoggingOff() const { return m_loggingOff; }
|
bool GetLoggingOff() const { return m_loggingOff; }
|
||||||
|
|
||||||
void Veto(bool veto = TRUE) { wxASSERT( m_canVeto ); m_veto = veto; }
|
void Veto(bool veto = TRUE)
|
||||||
|
{
|
||||||
|
// GetVeto() will return FALSE anyhow...
|
||||||
|
wxCHECK_RET( m_canVeto,
|
||||||
|
"call to Veto() ignored (can't veto this event)" );
|
||||||
|
|
||||||
|
m_veto = veto;
|
||||||
|
}
|
||||||
void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
|
void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
|
||||||
bool CanVeto() const { return m_canVeto; }
|
bool CanVeto() const { return m_canVeto; }
|
||||||
bool GetVeto() const { wxASSERT( m_canVeto ); return m_veto; }
|
bool GetVeto() const { return m_canVeto && m_veto; }
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
// This is probably obsolete now, since we use CanVeto instead, in
|
// This is probably obsolete now, since we use CanVeto instead, in
|
||||||
|
@@ -63,12 +63,12 @@ public:
|
|||||||
void OnOK( wxCommandEvent &event );
|
void OnOK( wxCommandEvent &event );
|
||||||
void OnPaint( wxPaintEvent& event );
|
void OnPaint( wxPaintEvent& event );
|
||||||
void OnSize( wxSizeEvent &event );
|
void OnSize( wxSizeEvent &event );
|
||||||
|
void OnCloseWindow( wxCloseEvent& event );
|
||||||
/*
|
/*
|
||||||
void OnCharHook( wxKeyEvent& event );
|
void OnCharHook( wxKeyEvent& event );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool Destroy();
|
bool Destroy();
|
||||||
void OnCloseWindow( wxCloseEvent& event );
|
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO );
|
int sizeFlags = wxSIZE_AUTO );
|
||||||
|
@@ -64,13 +64,13 @@ public:
|
|||||||
|
|
||||||
virtual void GetClientSize( int *width, int *height ) const;
|
virtual void GetClientSize( int *width, int *height ) const;
|
||||||
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
||||||
|
|
||||||
virtual void SetClientSize( int const width, int const height );
|
virtual void SetClientSize( int const width, int const height );
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO );
|
int sizeFlags = wxSIZE_AUTO );
|
||||||
virtual void SetSize( int width, int height );
|
virtual void SetSize( int width, int height );
|
||||||
|
|
||||||
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
|
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
|
||||||
const wxString& name = "statusBar");
|
const wxString& name = "statusBar");
|
||||||
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
||||||
@@ -99,14 +99,14 @@ public:
|
|||||||
virtual void Maximize(bool WXUNUSED(maximize)) {}
|
virtual void Maximize(bool WXUNUSED(maximize)) {}
|
||||||
virtual void Restore() {}
|
virtual void Restore() {}
|
||||||
|
|
||||||
|
void OnCloseWindow( wxCloseEvent& event );
|
||||||
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
|
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
|
||||||
void OnSize( wxSizeEvent &event );
|
void OnSize( wxSizeEvent &event );
|
||||||
void OnCloseWindow( wxCloseEvent& event );
|
|
||||||
|
|
||||||
void OnMenuHighlight( wxMenuEvent& event );
|
void OnMenuHighlight( wxMenuEvent& event );
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
void DoMenuUpdates();
|
void DoMenuUpdates();
|
||||||
|
@@ -63,12 +63,12 @@ public:
|
|||||||
void OnOK( wxCommandEvent &event );
|
void OnOK( wxCommandEvent &event );
|
||||||
void OnPaint( wxPaintEvent& event );
|
void OnPaint( wxPaintEvent& event );
|
||||||
void OnSize( wxSizeEvent &event );
|
void OnSize( wxSizeEvent &event );
|
||||||
|
void OnCloseWindow( wxCloseEvent& event );
|
||||||
/*
|
/*
|
||||||
void OnCharHook( wxKeyEvent& event );
|
void OnCharHook( wxKeyEvent& event );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool Destroy();
|
bool Destroy();
|
||||||
void OnCloseWindow( wxCloseEvent& event );
|
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO );
|
int sizeFlags = wxSIZE_AUTO );
|
||||||
|
@@ -64,13 +64,13 @@ public:
|
|||||||
|
|
||||||
virtual void GetClientSize( int *width, int *height ) const;
|
virtual void GetClientSize( int *width, int *height ) const;
|
||||||
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
||||||
|
|
||||||
virtual void SetClientSize( int const width, int const height );
|
virtual void SetClientSize( int const width, int const height );
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO );
|
int sizeFlags = wxSIZE_AUTO );
|
||||||
virtual void SetSize( int width, int height );
|
virtual void SetSize( int width, int height );
|
||||||
|
|
||||||
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
|
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
|
||||||
const wxString& name = "statusBar");
|
const wxString& name = "statusBar");
|
||||||
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
||||||
@@ -99,14 +99,14 @@ public:
|
|||||||
virtual void Maximize(bool WXUNUSED(maximize)) {}
|
virtual void Maximize(bool WXUNUSED(maximize)) {}
|
||||||
virtual void Restore() {}
|
virtual void Restore() {}
|
||||||
|
|
||||||
|
void OnCloseWindow( wxCloseEvent& event );
|
||||||
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
|
void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp
|
||||||
void OnSize( wxSizeEvent &event );
|
void OnSize( wxSizeEvent &event );
|
||||||
void OnCloseWindow( wxCloseEvent& event );
|
|
||||||
|
|
||||||
void OnMenuHighlight( wxMenuEvent& event );
|
void OnMenuHighlight( wxMenuEvent& event );
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
void DoMenuUpdates();
|
void DoMenuUpdates();
|
||||||
|
@@ -224,15 +224,15 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
|||||||
if (closing.Member(this))
|
if (closing.Member(this))
|
||||||
return; // no loops
|
return; // no loops
|
||||||
|
|
||||||
|
if ( event.GetVeto() )
|
||||||
|
return;
|
||||||
|
|
||||||
closing.Append(this);
|
closing.Append(this);
|
||||||
|
|
||||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||||
cancelEvent.SetEventObject( this );
|
cancelEvent.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||||
closing.DeleteObject(this);
|
closing.DeleteObject(this);
|
||||||
|
|
||||||
if ( event.CanVeto() )
|
|
||||||
event.Veto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDialog::Destroy()
|
bool wxDialog::Destroy()
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "frame.h"
|
#pragma implementation "frame.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
@@ -104,6 +104,7 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
||||||
EVT_SIZE(wxFrame::OnSize)
|
EVT_SIZE(wxFrame::OnSize)
|
||||||
|
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||||
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -474,6 +475,13 @@ void wxFrame::OnInternalIdle()
|
|||||||
DoMenuUpdates();
|
DoMenuUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFrame::OnCloseWindow( wxCloseEvent& event )
|
||||||
|
{
|
||||||
|
// close the window if it wasn't vetoed by the application
|
||||||
|
if ( !event.GetVeto() )
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
|
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||||
|
@@ -1718,13 +1718,9 @@ bool wxWindow::Close( bool force )
|
|||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetCanVeto(!force);
|
event.SetCanVeto(!force);
|
||||||
|
|
||||||
(void)GetEventHandler()->ProcessEvent(event);
|
// return FALSE if window wasn't closed because the application vetoed the
|
||||||
|
// close event
|
||||||
// when we're forced to close we do it anyhow, otherwise only if the
|
return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
|
||||||
// application didn't forbid it (if the event wasn't processed, GetVeto()
|
|
||||||
// will return FALSE too)
|
|
||||||
if ( force || !event.GetVeto() )
|
|
||||||
Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindow::Destroy()
|
bool wxWindow::Destroy()
|
||||||
|
@@ -224,15 +224,15 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
|||||||
if (closing.Member(this))
|
if (closing.Member(this))
|
||||||
return; // no loops
|
return; // no loops
|
||||||
|
|
||||||
|
if ( event.GetVeto() )
|
||||||
|
return;
|
||||||
|
|
||||||
closing.Append(this);
|
closing.Append(this);
|
||||||
|
|
||||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||||
cancelEvent.SetEventObject( this );
|
cancelEvent.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||||
closing.DeleteObject(this);
|
closing.DeleteObject(this);
|
||||||
|
|
||||||
if ( event.CanVeto() )
|
|
||||||
event.Veto();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDialog::Destroy()
|
bool wxDialog::Destroy()
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "frame.h"
|
#pragma implementation "frame.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
@@ -104,6 +104,7 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
|
||||||
EVT_SIZE(wxFrame::OnSize)
|
EVT_SIZE(wxFrame::OnSize)
|
||||||
|
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||||
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -474,6 +475,13 @@ void wxFrame::OnInternalIdle()
|
|||||||
DoMenuUpdates();
|
DoMenuUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFrame::OnCloseWindow( wxCloseEvent& event )
|
||||||
|
{
|
||||||
|
// close the window if it wasn't vetoed by the application
|
||||||
|
if ( !event.GetVeto() )
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
|
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||||
|
@@ -1718,13 +1718,9 @@ bool wxWindow::Close( bool force )
|
|||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
event.SetCanVeto(!force);
|
event.SetCanVeto(!force);
|
||||||
|
|
||||||
(void)GetEventHandler()->ProcessEvent(event);
|
// return FALSE if window wasn't closed because the application vetoed the
|
||||||
|
// close event
|
||||||
// when we're forced to close we do it anyhow, otherwise only if the
|
return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
|
||||||
// application didn't forbid it (if the event wasn't processed, GetVeto()
|
|
||||||
// will return FALSE too)
|
|
||||||
if ( force || !event.GetVeto() )
|
|
||||||
Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindow::Destroy()
|
bool wxWindow::Destroy()
|
||||||
|
Reference in New Issue
Block a user