From 57bf8a6f1efc2d58099f058bfd17579b147baac2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 7 Jul 2012 13:27:31 +0000 Subject: [PATCH] Return correct index from wxGenericListCtrl::InsertColumn(). It used to always return 0 in the generic version, return the correct index of the newly inserted column now. Closes #13677. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71971 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/private/listctrl.h | 2 +- src/generic/listctrl.cpp | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6b48cb59e6..f8534e00e2 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -565,6 +565,7 @@ All (GUI): - Added wxDataViewListCtrl::GetItemCount() (Kry). - Added support for Korean Johab and Vietnamese encodings (jank9201). - Fix off by 1 bug with setting font size in points in wxHTML (gevorg). +- Fix return value of wxGenericListCtrl::InsertColumn() (Sebastian Walderich). GTK: diff --git a/include/wx/generic/private/listctrl.h b/include/wx/generic/private/listctrl.h index 3145bd1b7d..48a1f016b8 100644 --- a/include/wx/generic/private/listctrl.h +++ b/include/wx/generic/private/listctrl.h @@ -644,7 +644,7 @@ public: long FindItem( const wxPoint& pt ); long HitTest( int x, int y, int &flags ) const; void InsertItem( wxListItem &item ); - void InsertColumn( long col, const wxListItem &item ); + long InsertColumn( long col, const wxListItem &item ); int GetItemWidthWithImage(wxListItem * item); void SortItems( wxListCtrlCompare fn, wxIntPtr data ); diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index de34935ced..e41e9ce95d 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4125,8 +4125,10 @@ void wxListMainWindow::InsertItem( wxListItem &item ) RefreshLines(id, GetItemCount() - 1); } -void wxListMainWindow::InsertColumn( long col, const wxListItem &item ) +long wxListMainWindow::InsertColumn( long col, const wxListItem &item ) { + long idx = -1; + m_dirty = true; if ( InReportView() ) { @@ -4143,9 +4145,11 @@ void wxListMainWindow::InsertColumn( long col, const wxListItem &item ) node = m_columns.Item( col ); m_columns.Insert( node, column ); m_aColWidths.Insert( colWidthInfo, col ); + idx = col; } else { + idx = m_aColWidths.GetCount(); m_columns.Append( column ); m_aColWidths.Add( colWidthInfo ); } @@ -4167,6 +4171,7 @@ void wxListMainWindow::InsertColumn( long col, const wxListItem &item ) // invalidate it as it has to be recalculated m_headerWidth = 0; } + return idx; } int wxListMainWindow::GetItemWidthWithImage(wxListItem * item) @@ -4947,14 +4952,14 @@ long wxGenericListCtrl::DoInsertColumn( long col, const wxListItem &item ) { wxCHECK_MSG( InReportView(), -1, wxT("can't add column in non report mode") ); - m_mainWin->InsertColumn( col, item ); + long idx = m_mainWin->InsertColumn( col, item ); // NOTE: if wxLC_NO_HEADER was given, then we are in report view mode but // still have m_headerWin==NULL if (m_headerWin) m_headerWin->Refresh(); - return 0; + return idx; } bool wxGenericListCtrl::ScrollList( int dx, int dy ) -- 2.45.2