don't duplicate the column reordering in generic wxHeaderCtrl and wxGrid, extract it into a (public) helper function
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -147,6 +147,38 @@ unsigned int wxHeaderCtrlBase::GetColumnPos(unsigned int idx) const
|
||||
return wxNO_COLUMN;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void wxHeaderCtrlBase::MoveColumnInOrderArray(wxArrayInt& order,
|
||||
unsigned int idx,
|
||||
unsigned int pos)
|
||||
{
|
||||
const unsigned count = order.size();
|
||||
|
||||
wxArrayInt orderNew;
|
||||
orderNew.reserve(count);
|
||||
for ( unsigned n = 0; ; n++ )
|
||||
{
|
||||
// NB: order of checks is important for this to work when the new
|
||||
// column position is the same as the old one
|
||||
|
||||
// insert the column at its new position
|
||||
if ( orderNew.size() == pos )
|
||||
orderNew.push_back(idx);
|
||||
|
||||
if ( n == count )
|
||||
break;
|
||||
|
||||
// delete the column from its old position
|
||||
const unsigned idxOld = order[n];
|
||||
if ( idxOld == idx )
|
||||
continue;
|
||||
|
||||
orderNew.push_back(idxOld);
|
||||
}
|
||||
|
||||
order.swap(orderNew);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxHeaderCtrlSimple implementation
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user