]> git.saurik.com Git - wxWidgets.git/commitdiff
Added extra hit test style for more accurate reporting
authorJulian Smart <julian@anthemion.co.uk>
Sun, 28 Jan 2007 16:57:07 +0000 (16:57 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 28 Jan 2007 16:57:07 +0000 (16:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/richtextbuffer.tex
include/wx/richtext/richtextbuffer.h
src/richtext/richtextbuffer.cpp
src/richtext/richtextctrl.cpp

index 7fae2b6e3a8a8acf6e2c42d1cf474e2367a2c460..0879b6a7641716ecc93152d669f7b7528a3b903f 100644 (file)
@@ -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}
 }
 
index c414e1394f9732eb3ab0769002feb32b59b65999..1eb2856bfab64068dab5daa77105c3e97b3856a2 100644 (file)
@@ -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
index dc91157cc32f6d67fe0c60fa9182a9111b59b43b..d0eaa2a810c042bb3fdc5452bdc94fb3065b408b 100644 (file)
@@ -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
             {
index 5995b29fb8d4dd597a7f6ca5c7f615ca8cfbd135..006122f0ae111ddbe5bbb7113bedaefa0311ddfa 100644 (file)
@@ -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;
 }