wxWindowGTK::~wxWindowGTK()
{
SendDestroyEvent();
src/common/wincmn.cppwxWindowBase::SendDestroyEvent
void wxWindowBase::SendDestroyEvent()
{
wxWindowDestroyEvent event;
event.SetEventObject(this);
event.SetId(GetId());
GetEventHandler()->ProcessEvent(event);
}
src/common/event.cpp
#if wxUSE_GUI
...
IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent)
...
#endif // wxUSE_GUI
...
// System events
...
DEFINE_EVENT_TYPE(wxEVT_DESTROY)
...
wxWindowDestroyEvent::wxWindowDestroyEvent(wxWindow *win)
{
SetEventType(wxEVT_DESTROY);
SetEventObject(win);
}
で、IMPLEMENT_DYNAMIC_CLASSはなにか?というとRTTI 関数なんですよ。Run Time Type Identificationだっけ?RTTIとSWIGの関係がどうなっているのかを追うのも面白そうですが脱線なのでしません。
wx/object.h
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject) \
wxObject* name::wxCreateObject() \
{ return new name; }
wx/event.h
で、wxEVT_DESTROYは何者か?というと
DECLARE_EVENT_TYPE(wxEVT_DESTROY, 411)
...
// Window creation/destruction events: the first is sent as soon as window is
// created (i.e. the underlying GUI object exists), but when the C++ object is
// fully initialized (so virtual functions may be called). The second,
// wxEVT_DESTROY, is sent right before the window is destroyed - again, it's
// still safe to call virtual functions at this moment
/*
wxEVT_CREATE
wxEVT_DESTROY
*/
...
#define EVT_WINDOW_DESTROY(func) wx__DECLARE_EVT0(wxEVT_DESTROY, wxWindowDestroyEventHandler(func))
...
WindowDestroyEventのドキュメント(wxPython)
The EVT_WINDOW_DESTROY event is sent from the wx.Window destructor when the GUI window is destroyed.
When a class derived from wx.Window is destroyed its destructor will have already run by the time this event is sent. Therefore this event will not usually be received at all by the window itself. Since it is received after the destructor has run, an object should not try to handle its own wx.WindowDestroyEvent, but it can be used to get notification of the destruction of another window.
src/common/toplvcmn.cpp
これだけブランチじゃなくてトランクから持ってきてます。トランクとブランチでなんか内容が違う。
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
EVT_SIZE(wxTopLevelWindowBase::OnSize)
EVT_WINDOW_DESTROY(wxTopLevelWindowBase::OnChildDestroy)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxTopLevelWindowBase)
END_EVENT_TABLE()
...
void wxTopLevelWindowBase::OnChildDestroy(wxWindowDestroyEvent& event)
{
event.Skip();
wxWindow * const win = event.GetWindow();
if ( win == m_winDefault )
m_winDefault = NULL;
if ( win == m_winTmpDefault )
m_winTmpDefault = NULL;
}
ブランチでの内容
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
EVT_SIZE(wxTopLevelWindowBase::OnSize)
END_EVENT_TABLE()
0 件のコメント:
コメントを投稿