document column reordering in wxListCtrl; fix confusion between GetColumnOrder() and GetColumnIndexFromOrder() doing this discovered; show the use of these methods in the sample and added a unit test for them

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-11-26 19:11:22 +00:00
parent a5cc517ff6
commit 80cc5fc7ad
16 changed files with 366 additions and 36 deletions

View File

@@ -721,33 +721,32 @@ bool wxListCtrl::SetColumnWidth(int col, int width)
// columns order
// ----------------------------------------------------------------------------
int wxListCtrl::GetColumnOrder(int col) const
{
const int numCols = GetColumnCount();
wxCHECK_MSG( col >= 0 && col < numCols, -1, _T("Col index out of bounds") );
wxArrayInt indexArray(numCols);
if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
return -1;
return indexArray[col];
}
int wxListCtrl::GetColumnIndexFromOrder(int order) const
{
const int numCols = GetColumnCount();
wxASSERT_MSG( order >= 0 && order < numCols, _T("Col order out of bounds") );
wxCHECK_MSG( order >= 0 && order < numCols, -1,
_T("Column position out of bounds") );
wxArrayInt indexArray(numCols);
if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
return -1;
for ( int col = 0; col < numCols; col++ )
return indexArray[order];
}
int wxListCtrl::GetColumnOrder(int col) const
{
const int numCols = GetColumnCount();
wxASSERT_MSG( col >= 0 && col < numCols, _T("Column index out of bounds") );
wxArrayInt indexArray(numCols);
if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
return -1;
for ( int pos = 0; pos < numCols; pos++ )
{
if ( indexArray[col] == order )
return col;
if ( indexArray[pos] == col )
return pos;
}
wxFAIL_MSG( _T("no column with with given order?") );