From: Robert Roebling Date: Sun, 12 Nov 2006 13:27:13 +0000 (+0000) Subject: Send delete item event just before the item is actually X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a95d5751f91676b031a294bb3b700d006af68549 Send delete item event just before the item is actually deleted (as per wxMSW). Also include the client data (long value) in the event. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 9f9a2df9d8..24f1a18861 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -822,6 +822,7 @@ void MyListCtrl::OnEndLabelEdit(wxListEvent& event) void MyListCtrl::OnDeleteItem(wxListEvent& event) { LogEvent(event, _T("OnDeleteItem")); + wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() ); } void MyListCtrl::OnDeleteAllItems(wxListEvent& event) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 4cce420c0f..08e3146d1e 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -697,7 +697,7 @@ public: // send out a wxListEvent void SendNotify( size_t line, - wxEventType command, + wxEventType command, const wxPoint& point = wxDefaultPosition ); // override base class virtual to reset m_lineHeight when the font changes @@ -2842,6 +2842,7 @@ void wxListMainWindow::SendNotify( size_t line, { wxListEvent le( command, GetParent()->GetId() ); le.SetEventObject( GetParent() ); + le.m_itemIndex = line; // set only for events which have position @@ -2852,7 +2853,7 @@ void wxListMainWindow::SendNotify( size_t line, // program has it anyhow and if we did it would result in accessing all // the lines, even those which are not visible now and this is precisely // what we're trying to avoid - if ( !IsVirtual() && (command != wxEVT_COMMAND_LIST_DELETE_ITEM) ) + if ( !IsVirtual() ) { if ( line != (size_t)-1 ) { @@ -4332,11 +4333,11 @@ void wxListMainWindow::DeleteItem( long lindex ) if ( m_current != index || m_current == count - 1 ) m_current--; } - + if ( InReportView() ) { - // mark the Column Max Width cache as dirty if the items in the line - // we're deleting contain the Max Column Width + // mark the Column Max Width cache as dirty if the items in the line + // we're deleting contain the Max Column Width wxListLineData * const line = GetLine(index); wxListItemDataList::compatibility_iterator n; wxListItemData *itemData; @@ -4358,6 +4359,8 @@ void wxListMainWindow::DeleteItem( long lindex ) ResetVisibleLinesRange(); } + SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM, wxDefaultPosition ); + if ( IsVirtual() ) { m_countVirt--; @@ -4371,8 +4374,6 @@ void wxListMainWindow::DeleteItem( long lindex ) // we need to refresh the (vert) scrollbar as the number of items changed m_dirty = true; - SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM ); - RefreshAfter(index); }