+ // 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++ )
+ {
+ if ( n > idx )
+ break;
+
+ if ( GetColumn(n).IsHidden() )
+ idx++;
+ }
+
+ wxASSERT_MSG( MSWToNativeIdx(idx) == item, "logic error" );
+
+ return idx;
+}
+
+int wxHeaderCtrl::MSWToNativeOrder(int pos)
+{
+ wxASSERT_MSG( pos >= 0 && static_cast<unsigned>(pos) < m_numColumns,
+ "column position out of range" );
+
+ int order = pos;
+ for ( int n = 0; n < pos; n++ )