+void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical)
+{
+ wxClientDC dc(this);
+
+ wxDCOverlay dcover(m_overlay, &dc);
+ dcover.Clear();
+
+ dc.SetPen(*wxBLUE);
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+
+ // draw the phantom position of the column being dragged
+ int x = xPhysical - m_dragOffset;
+ int y = GetClientSize().y;
+ dc.DrawRectangle(x, 0,
+ GetColumn(m_colBeingReordered).GetWidth(), y);
+
+ // and also a hint indicating where it is going to be inserted if it's
+ // dropped now
+ unsigned int col = FindColumnAtPoint(xPhysical);
+ if ( col != COL_NONE )
+ {
+ static const int DROP_MARKER_WIDTH = 4;
+
+ dc.SetBrush(*wxBLUE);
+ dc.DrawRectangle(GetColEnd(col) - DROP_MARKER_WIDTH/2, 0,
+ DROP_MARKER_WIDTH, y);
+ }
+}
+
+void wxHeaderCtrl::StartReordering(unsigned int col, int xPhysical)
+{
+ wxHeaderCtrlEvent event(wxEVT_HEADER_BEGIN_REORDER, GetId());
+ event.SetEventObject(this);
+ event.SetColumn(col);
+
+ if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
+ {
+ // don't start dragging it, nothing to do otherwise
+ return;
+ }
+
+ m_dragOffset = xPhysical - GetColStart(col);
+
+ m_colBeingReordered = col;
+ SetCursor(wxCursor(wxCURSOR_HAND));
+ CaptureMouse();
+
+ // do not call UpdateReorderingMarker() here: we don't want to give
+ // feedback for reordering until the user starts to really move the mouse
+ // as he might want to just click on the column and not move it at all
+}
+
+bool wxHeaderCtrl::EndReordering(int xPhysical)
+{
+ wxASSERT_MSG( IsReordering(), "shouldn't be called if we're not reordering" );
+
+ EndDragging();
+
+ ReleaseMouse();
+
+ const int colOld = m_colBeingReordered,
+ colNew = FindColumnAtPoint(xPhysical);
+
+ m_colBeingReordered = COL_NONE;
+
+ if ( xPhysical - GetColStart(colOld) == m_dragOffset )
+ return false;
+
+ if ( colNew != colOld )
+ {
+ wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId());
+ event.SetEventObject(this);
+ event.SetColumn(colOld);
+
+ const unsigned pos = GetColumnPos(FindColumnAtPoint(xPhysical));
+ event.SetNewOrder(pos);
+
+ if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+ {
+ // do reorder the columns
+ DoMoveCol(colOld, pos);
+ }
+ }
+
+ // whether we moved the column or not, the user did move the mouse and so
+ // did try to do it so return true
+ return true;
+}
+