- const unsigned count = GetColumnCount();
- wxArrayInt order(count);
- if ( !Header_GetOrderArray(GetHwnd(), count, &order[0]) )
+ // we don't use Header_GetOrderArray() here because it doesn't return
+ // information about the hidden columns, instead we just save the columns
+ // order array in DoSetColumnsOrder() and update it when they're reordered
+ return m_colIndices;
+}
+
+// ----------------------------------------------------------------------------
+// wxHeaderCtrl indexes and positions translation
+// ----------------------------------------------------------------------------
+
+int wxHeaderCtrl::MSWToNativeIdx(int idx)
+{
+ // don't check for GetColumn(idx).IsShown() as it could have just became
+ // false and we may be called from DoUpdate() to delete the old column
+ wxASSERT_MSG( !m_isHidden[idx],
+ "column must be visible to have an "
+ "index in the native control" );
+
+ int item = idx;
+ for ( int i = 0; i < idx; i++ )
+ {
+ if ( GetColumn(i).IsHidden() )
+ item--; // one less column the native control knows about
+ }
+
+ wxASSERT_MSG( item >= 0 && item <= GetShownColumnsCount(), "logic error" );
+
+ return item;
+}
+
+int wxHeaderCtrl::MSWFromNativeIdx(int item)
+{
+ wxASSERT_MSG( item >= 0 && item < GetShownColumnsCount(),
+ "column index out of range" );
+
+ // reverse the above function
+
+ unsigned idx = item;
+ for ( unsigned n = 0; n < m_numColumns; n++ )