From: Vadim Zeitlin Date: Mon, 31 Oct 2011 19:41:06 +0000 (+0000) Subject: Make wxTreeListEvent dynamically creatable. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f81ccc1148c5a1f4ca14e2ad25280f7a6731593c Make wxTreeListEvent dynamically creatable. This is unfortunately required by wxEvent::Clone() support unit test so provide the default ctor in this class even though it doesn't make any sense in normal use. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69619 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/treelist.h b/include/wx/treelist.h index bb27f9d8f9..6684a26bb3 100644 --- a/include/wx/treelist.h +++ b/include/wx/treelist.h @@ -456,6 +456,9 @@ private: class wxTreeListEvent : public wxNotifyEvent { public: + // Default ctor is provided for wxRTTI needs only but should never be used. + wxTreeListEvent() { Init(); } + // The item affected by the event. Valid for all events except // column-specific ones such as COLUMN_SORTED. wxTreeListItem GetItem() const { return m_item; } @@ -470,6 +473,14 @@ public: virtual wxEvent* Clone() const { return new wxTreeListEvent(*this); } private: + // Common part of all ctors. + void Init() + { + m_column = static_cast(-1); + + m_oldCheckedState = wxCHK_UNDETERMINED; + } + // Ctor is private, only wxTreeListCtrl can create events of this type. wxTreeListEvent(wxEventType evtType, wxTreeListCtrl* treelist, @@ -479,9 +490,7 @@ private: { SetEventObject(treelist); - m_column = static_cast(-1); - - m_oldCheckedState = wxCHK_UNDETERMINED; + Init(); } // Set the checkbox state before this event for ITEM_CHECKED events. @@ -505,7 +514,7 @@ private: friend class wxTreeListCtrl; - wxDECLARE_ABSTRACT_CLASS(wxTreeListEvent); + wxDECLARE_DYNAMIC_CLASS(wxTreeListEvent); }; // Event types and event table macros. diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index a82a2a9237..f7aca4aabb 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -1654,7 +1654,7 @@ wxWindow* wxTreeListCtrl::GetView() const // wxTreeListEvent implementation // ============================================================================ -wxIMPLEMENT_ABSTRACT_CLASS(wxTreeListEvent, wxNotifyEvent) +wxIMPLEMENT_DYNAMIC_CLASS(wxTreeListEvent, wxNotifyEvent) #define wxDEFINE_TREELIST_EVENT(name) \ wxDEFINE_EVENT(wxEVT_COMMAND_TREELIST_##name, wxTreeListEvent)