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:
@@ -606,6 +606,8 @@ The function returns one of the following values:
|
|||||||
#define wxRICHTEXT_HITTEST_AFTER 0x04
|
#define wxRICHTEXT_HITTEST_AFTER 0x04
|
||||||
// The point was on the position returned from HitTest
|
// The point was on the position returned from HitTest
|
||||||
#define wxRICHTEXT_HITTEST_ON 0x08
|
#define wxRICHTEXT_HITTEST_ON 0x08
|
||||||
|
// The point was on space outside content
|
||||||
|
#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,6 +139,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
|
|||||||
#define wxRICHTEXT_HITTEST_AFTER 0x04
|
#define wxRICHTEXT_HITTEST_AFTER 0x04
|
||||||
// The point was on the position returned from HitTest
|
// The point was on the position returned from HitTest
|
||||||
#define wxRICHTEXT_HITTEST_ON 0x08
|
#define wxRICHTEXT_HITTEST_ON 0x08
|
||||||
|
// The point was on space outside content
|
||||||
|
#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Flags for GetRangeSize
|
* Flags for GetRangeSize
|
||||||
|
@@ -3668,12 +3668,12 @@ int wxRichTextParagraph::HitTest(wxDC& dc, const wxPoint& pt, long& textPosition
|
|||||||
if (pt.x < linePos.x)
|
if (pt.x < linePos.x)
|
||||||
{
|
{
|
||||||
textPosition = lineRange.GetStart();
|
textPosition = lineRange.GetStart();
|
||||||
return wxRICHTEXT_HITTEST_BEFORE;
|
return wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_OUTSIDE;
|
||||||
}
|
}
|
||||||
else if (pt.x >= (linePos.x + lineSize.x))
|
else if (pt.x >= (linePos.x + lineSize.x))
|
||||||
{
|
{
|
||||||
textPosition = lineRange.GetEnd();
|
textPosition = lineRange.GetEnd();
|
||||||
return wxRICHTEXT_HITTEST_AFTER;
|
return wxRICHTEXT_HITTEST_AFTER|wxRICHTEXT_HITTEST_OUTSIDE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -438,7 +438,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
|
|||||||
// See if we need to change the cursor
|
// See if we need to change the cursor
|
||||||
|
|
||||||
{
|
{
|
||||||
if (hit != wxRICHTEXT_HITTEST_NONE)
|
if (hit != wxRICHTEXT_HITTEST_NONE & !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
|
||||||
{
|
{
|
||||||
wxTextAttrEx attr;
|
wxTextAttrEx attr;
|
||||||
if (GetStyle(position, attr))
|
if (GetStyle(position, attr))
|
||||||
@@ -453,6 +453,8 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
SetCursor(m_textCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.Dragging())
|
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,
|
// 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.
|
// so we view the caret at the start of the line.
|
||||||
bool caretLineStart = false;
|
bool caretLineStart = false;
|
||||||
if (hitTest == wxRICHTEXT_HITTEST_BEFORE)
|
if (hitTest & wxRICHTEXT_HITTEST_BEFORE)
|
||||||
{
|
{
|
||||||
wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
|
wxRichTextLine* thisLine = GetBuffer().GetLineAtPosition(newPos-1);
|
||||||
wxRichTextRange lineRange;
|
wxRichTextRange lineRange;
|
||||||
@@ -1975,17 +1977,14 @@ wxRichTextCtrl::HitTest(const wxPoint& pt,
|
|||||||
|
|
||||||
int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
|
int hit = ((wxRichTextCtrl*)this)->GetBuffer().HitTest(dc, pt2, *pos);
|
||||||
|
|
||||||
switch ( hit )
|
if ((hit & wxRICHTEXT_HITTEST_BEFORE) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
|
||||||
{
|
return wxTE_HT_BEFORE;
|
||||||
case wxRICHTEXT_HITTEST_BEFORE:
|
else if ((hit & wxRICHTEXT_HITTEST_AFTER) && (hit & wxRICHTEXT_HITTEST_OUTSIDE))
|
||||||
return wxTE_HT_BEFORE;
|
return wxTE_HT_BEYOND;
|
||||||
|
else if (hit & wxRICHTEXT_HITTEST_BEFORE|wxRICHTEXT_HITTEST_AFTER)
|
||||||
case wxRICHTEXT_HITTEST_AFTER:
|
return wxTE_HT_ON_TEXT;
|
||||||
return wxTE_HT_BEYOND;
|
else
|
||||||
|
return wxTE_HT_UNKNOWN;
|
||||||
case wxRICHTEXT_HITTEST_ON:
|
|
||||||
return wxTE_HT_ON_TEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxTE_HT_UNKNOWN;
|
return wxTE_HT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user