m_colIndices = colIndices;
}
+ else // count didn't really change
+ {
+ return;
+ }
m_numColumns = count;
+ InvalidateBestSize();
Refresh();
}
void wxHeaderCtrl::DoUpdate(unsigned int idx)
{
+ InvalidateBestSize();
+
// we need to refresh not only this column but also the ones after it in
// case it was shown or hidden or its width changed -- it would be nice to
// avoid doing this unnecessary by storing the old column width (TODO)
{
// the vertical size is rather arbitrary but it looks better if we leave
// some space around the text
- return wxSize(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
- : GetColEnd(GetColumnCount() - 1),
- (7*GetCharHeight())/4);
+ const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
+ : GetColEnd(GetColumnCount() - 1),
+ (7*GetCharHeight())/4);
+ CacheBestSize(size);
+ return size;
}
int wxHeaderCtrl::GetColStart(unsigned int idx) const
void wxHeaderCtrl::DoMoveCol(unsigned int idx, unsigned int pos)
{
- const unsigned count = m_colIndices.size();
-
- wxArrayInt colIndices;
- colIndices.reserve(count);
- for ( unsigned n = 0; n < count; 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 ( colIndices.size() == pos )
- colIndices.push_back(idx);
-
- // delete the column from its old position
- const unsigned idxOld = m_colIndices[n];
- if ( idxOld == idx )
- continue;
-
- colIndices.push_back(idxOld);
- }
-
- m_colIndices = colIndices;
+ MoveColumnInOrderArray(m_colIndices, idx, pos);
Refresh();
}