]> git.saurik.com Git - wxWidgets.git/commitdiff
Set mouse cursor correctly over image map links in wxHTML.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 17 Jul 2013 17:27:14 +0000 (17:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 17 Jul 2013 17:27:14 +0000 (17:27 +0000)
The cursor didn't change to a link one when the mouse was over link areas in
an image map.

Fix this by generalizing wxHtmlCell::GetMouseCursor() into GetMouseCursorAt().

Closes #15350.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74570 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/html/htmlcell.h
interface/wx/html/htmlcell.h
src/html/htmlcell.cpp
src/html/htmlwin.cpp

index 7c306a61f8da92fe3fed9b1b99c6d5da80fc56b5..98382778e2abf1c0062c57dd70f0d175d6302793 100644 (file)
@@ -563,6 +563,7 @@ Major new features in this release
 All (GUI):
 
 - Fix crash in wxHTML on mal-formed <area> elements (LukasK).
+- Set correct cursor when the mouse is over image map links in wxHTML (LukasK).
 
 
 2.9.5: (released 2013-07-15)
index c42299eb266df6b51b6b1f25ac5b73f67ad8d073..72bbeb1e2fd71ba15ebdc42ef822de405c673168 100644 (file)
@@ -207,9 +207,17 @@ public:
                                     int WXUNUSED(y) = 0) const
         { return m_Link; }
 
-    // Returns cursor to be used when mouse is over the cell:
+    // Returns cursor to be used when mouse is over the cell, can be
+    // overridden by the derived classes to use a different cursor whenever the
+    // mouse is over this cell.
     virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const;
 
+    // Returns cursor to be used when mouse is over the given point, can be
+    // overridden if the cursor should change depending on where exactly inside
+    // the cell the mouse is.
+    virtual wxCursor GetMouseCursorAt(wxHtmlWindowInterface *window,
+                                      const wxPoint& relPos) const;
+
 #if WXWIN_COMPATIBILITY_2_6
     // this was replaced by GetMouseCursor, don't use in new code!
     virtual wxCursor GetCursor() const;
index c44ec814a88e786c9ee15199c70b88a5074a8c0d..d84c683d750f57cd325de757b65701eeb01b2e23 100644 (file)
@@ -319,9 +319,25 @@ public:
 
         @param window
             interface to the parent HTML window
+
+        @see GetMouseCursorAt()
     */
     virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window) const;
 
+    /**
+        Returns cursor to show when mouse pointer is over the specified point.
+
+        This function should be overridden instead of GetMouseCursorAt() if
+        the cursor should depend on the exact position of the mouse in the
+        window.
+
+        @param window
+            interface to the parent HTML window
+
+        @since 3.0
+     */
+    virtual wxCursor GetMouseCursorAt(wxHtmlWindowInterface* window) const;
+
     /**
         Returns pointer to the next cell in list (see htmlcell.h if you're
         interested in details).
index 3d243b762f9f6e4d5d8736a2e6e6f91c89113c52..bfb558506f3bd0416ac11cc6e77ecad2f38653c4 100644 (file)
@@ -196,7 +196,17 @@ wxCursor wxHtmlCell::GetCursor() const
 }
 #endif // WXWIN_COMPATIBILITY_2_6
 
-wxCursor wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface *window) const
+wxCursor
+wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface* WXUNUSED(window)) const
+{
+    // This is never called directly, only from GetMouseCursorAt() and we
+    // return an invalid cursor by default to let it delegate to the window.
+    return wxNullCursor;
+}
+
+wxCursor
+wxHtmlCell::GetMouseCursorAt(wxHtmlWindowInterface *window,
+                             const wxPoint& relPos) const
 {
 #if WXWIN_COMPATIBILITY_2_6
     // NB: Older versions of wx used GetCursor() virtual method in place of
@@ -209,7 +219,11 @@ wxCursor wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface *window) const
         return cur;
 #endif // WXWIN_COMPATIBILITY_2_6
 
-    if ( GetLink() )
+    const wxCursor curCell = GetMouseCursor(window);
+    if ( curCell.IsOk() )
+      return curCell;
+
+    if ( GetLink(relPos.x, relPos.y) )
     {
         return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Link);
     }
index 0264befd05d932b24682d4e465a1e0ed4ac3dcb9..11086c4fe6765540c270ee0261091e52da76fb66 100644 (file)
@@ -206,7 +206,7 @@ void wxHtmlWindowMouseHelper::HandleIdle(wxHtmlCell *rootCell,
 
         wxCursor cur;
         if (cell)
-            cur = cell->GetMouseCursor(m_interface);
+            cur = cell->GetMouseCursorAt(m_interface, pos);
         else
             cur = m_interface->GetHTMLCursor(
                         wxHtmlWindowInterface::HTMLCursor_Default);
@@ -229,6 +229,11 @@ void wxHtmlWindowMouseHelper::HandleIdle(wxHtmlCell *rootCell,
     {
         if ( cell )
         {
+            // A single cell can have different cursors for different positions,
+            // so update cursor for this case as well.
+            wxCursor cur = cell->GetMouseCursorAt(m_interface, pos);
+            m_interface->GetHTMLWindow()->SetCursor(cur);
+
             OnCellMouseHover(cell, pos.x, pos.y);
         }
     }