]> git.saurik.com Git - wxWidgets.git/commitdiff
update column highlight when mouse hovers over the control
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 8 Dec 2008 11:26:50 +0000 (11:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 8 Dec 2008 11:26:50 +0000 (11:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/headerctrlg.cpp

index 823ea60aac8254025f8dbb4cefe74e27f4afa2d3..072159590e27e344772ce0a17cf7d987f68703c5 100644 (file)
@@ -193,6 +193,12 @@ void wxHeaderCtrl::RefreshCol(unsigned int idx)
     RefreshRect(rect);
 }
 
+void wxHeaderCtrl::RefreshColIfNotNone(unsigned int idx)
+{
+    if ( idx != COL_NONE )
+        RefreshCol(idx);
+}
+
 void wxHeaderCtrl::RefreshColsAfter(unsigned int idx)
 {
     wxRect rect = GetClientRect();
@@ -283,7 +289,20 @@ void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent)
 
     // find if the event is over a column at all
     bool onSeparator;
-    const unsigned col = FindColumnAtPos(mevent.GetX(), onSeparator);
+    const unsigned col = mevent.Leaving()
+                            ? (onSeparator = false, COL_NONE)
+                            : FindColumnAtPos(mevent.GetX(), onSeparator);
+
+    // update the highlighted column if it changed
+    if ( col != m_hover )
+    {
+        const unsigned hoverOld = m_hover;
+        m_hover = col;
+
+        RefreshColIfNotNone(hoverOld);
+        RefreshColIfNotNone(m_hover);
+    }
+
     if ( col == COL_NONE )
         return;