From f262b25c93c89d2f2bd0b388bac293c8969a2d72 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Sun, 28 Jan 2007 16:57:07 +0000
Subject: [PATCH] Added extra hit test style for more accurate reporting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/richtextbuffer.tex     |  2 ++
 include/wx/richtext/richtextbuffer.h |  2 ++
 src/richtext/richtextbuffer.cpp      |  4 ++--
 src/richtext/richtextctrl.cpp        | 25 ++++++++++++-------------
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/docs/latex/wx/richtextbuffer.tex b/docs/latex/wx/richtextbuffer.tex
index 7fae2b6e3a..0879b6a764 100644
--- a/docs/latex/wx/richtextbuffer.tex
+++ b/docs/latex/wx/richtextbuffer.tex
@@ -606,6 +606,8 @@ The function returns one of the following values:
 #define wxRICHTEXT_HITTEST_AFTER    0x04
 // The point was on the position returned from HitTest
 #define wxRICHTEXT_HITTEST_ON       0x08
+// The point was on space outside content
+#define wxRICHTEXT_HITTEST_OUTSIDE  0x10
 \end{verbatim}
 }
 
diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h
index c414e1394f..1eb2856bfa 100644
--- a/include/wx/richtext/richtextbuffer.h
+++ b/include/wx/richtext/richtextbuffer.h
@@ -139,6 +139,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
 #define wxRICHTEXT_HITTEST_AFTER    0x04
 // The point was on the position returned from HitTest
 #define wxRICHTEXT_HITTEST_ON       0x08
+// The point was on space outside content
+#define wxRICHTEXT_HITTEST_OUTSIDE  0x10
 
 /*!
  * Flags for GetRangeSize
diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp
index dc91157cc3..d0eaa2a810 100644
--- a/src/richtext/richtextbuffer.cpp
+++ b/src/richtext/richtextbuffer.cpp
@@ -3668,12 +3668,12 @@ int wxRichTextParagraph::HitTest(wxDC& dc, const wxPoint& pt, long& textPosition
             if (pt.x < linePos.x)
             {
                 textPosition = lineRange.GetStart();
-                return wxRICHTEXT_HITTEST_BEFORE;
+                return wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_OUTSIDE;
             }
             else if (pt.x >= (linePos.x + lineSize.x))
             {
                 textPosition = lineRange.GetEnd();
-                return wxRICHTEXT_HITTEST_AFTER;
+                return wxRICHTEXT_HITTEST_AFTER|wxRICHTEXT_HITTEST_OUTSIDE;
             }
             else
             {
diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp
index 5995b29fb8..006122f0ae 100644
--- a/src/richtext/richtextctrl.cpp
+++ b/src/richtext/richtextctrl.cpp
@@ -438,7 +438,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
     // See if we need to change the cursor
     
     {
-        if (hit != wxRICHTEXT_HITTEST_NONE)
+        if (hit != wxRICHTEXT_HITTEST_NONE & !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
         {
             wxTextAttrEx attr;
             if (GetStyle(position, attr))
@@ -453,6 +453,8 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
                 }
             }
         }
+        else
+            SetCursor(m_textCursor);
     }
 
     if (!event.Dragging())
@@ -1331,7 +1333,7 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags)
         // we want to be at the end of the last line but with m_caretAtLineStart set to true,
         // so we view the caret at the start of the line.
         bool caretLineStart = false;
-        if (hitTest == wxRICHTEXT_HITTEST_BEFORE)
+        if (hitTest & wxRICHTEXT_HITTEST_BEFORE)
         {
             wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
             wxRichTextRange lineRange;
@@ -1975,17 +1977,14 @@ wxRichTextCtrl::HitTest(const wxPoint& pt,
 
     int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
 
-    switch ( hit )
-    {
-        case wxRICHTEXT_HITTEST_BEFORE:
-            return wxTE_HT_BEFORE;
-
-        case wxRICHTEXT_HITTEST_AFTER:
-            return wxTE_HT_BEYOND;
-
-        case wxRICHTEXT_HITTEST_ON:
-            return wxTE_HT_ON_TEXT;
-    }
+    if ((hit & wxRICHTEXT_HITTEST_BEFORE) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+        return wxTE_HT_BEFORE;
+    else if ((hit & wxRICHTEXT_HITTEST_AFTER) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
+        return wxTE_HT_BEYOND;
+    else if (hit & wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)
+        return wxTE_HT_ON_TEXT;
+    else
+        return wxTE_HT_UNKNOWN;
 
     return wxTE_HT_UNKNOWN;
 }
-- 
2.50.0

