From 423b9ba5543a9a54112accdba995928cb073e389 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 29 Sep 2011 12:05:21 +0000 Subject: [PATCH] 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 --- src/richtext/richtextctrl.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 43d636458b..dbc9ea9080 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -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(); -- 2.45.2