Fixed caret sizing problem around large objects by clipping the caret to the margins
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
82614b1a72
commit
423b9ba554
@ -3377,13 +3377,26 @@ void wxRichTextCtrl::PositionCaret(wxRichTextParagraphLayoutBox* container)
|
||||
if (GetCaret()->GetSize() != newSz)
|
||||
GetCaret()->SetSize(newSz);
|
||||
|
||||
int halfSize = newSz.y/2;
|
||||
// If the caret is beyond the margin, hide it by moving it out of the way
|
||||
if (((pt.y + halfSize) < GetBuffer().GetTopMargin()) || ((pt.y + halfSize) > (GetClientSize().y - GetBuffer().GetBottomMargin())))
|
||||
// Adjust size so the caret size and position doesn't appear in the margins
|
||||
if (((pt.y + newSz.y) <= GetBuffer().GetTopMargin()) || (pt.y >= (GetClientSize().y - GetBuffer().GetBottomMargin())))
|
||||
{
|
||||
pt.x = -200;
|
||||
pt.y = -200;
|
||||
}
|
||||
else if (pt.y < GetBuffer().GetTopMargin() && (pt.y + newSz.y) > GetBuffer().GetTopMargin())
|
||||
{
|
||||
newSz.y -= (GetBuffer().GetTopMargin() - pt.y);
|
||||
if (newSz.y > 0)
|
||||
{
|
||||
pt.y = GetBuffer().GetTopMargin();
|
||||
GetCaret()->SetSize(newSz);
|
||||
}
|
||||
}
|
||||
else if (pt.y < (GetClientSize().y - GetBuffer().GetBottomMargin()) && (pt.y + newSz.y) > (GetClientSize().y - GetBuffer().GetBottomMargin()))
|
||||
{
|
||||
newSz.y = GetClientSize().y - GetBuffer().GetBottomMargin() - pt.y;
|
||||
GetCaret()->SetSize(newSz);
|
||||
}
|
||||
|
||||
GetCaret()->Move(pt);
|
||||
GetCaret()->Show();
|
||||
|
Loading…
Reference in New Issue
Block a user