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
This commit is contained in:
Julian Smart
2007-01-28 16:57:07 +00:00
parent cb6e26b88e
commit f262b25c93
4 changed files with 18 additions and 15 deletions

View 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}
}

View 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

View 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
{

View 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;
}