From 057945a5cdea8eae70d6f8877fbe787a261e3614 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 22 Sep 2013 20:34:16 +0000 Subject: [PATCH] Partial fix for #15196: wxRichTextCell caret issues (dghart) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74857 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextbuffer.h | 4 ++++ interface/wx/richtext/richtextbuffer.h | 4 ++++ src/richtext/richtextbuffer.cpp | 33 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index 4c80c1e497..4ac47931de 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -5569,6 +5569,8 @@ public: virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); + virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); + virtual wxString GetXMLNodeName() const { return wxT("cell"); } virtual bool CanEditProperties() const { return true; } @@ -5628,6 +5630,8 @@ public: virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); + virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); + virtual wxString GetXMLNodeName() const { return wxT("table"); } virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); diff --git a/interface/wx/richtext/richtextbuffer.h b/interface/wx/richtext/richtextbuffer.h index 2426e696c8..a345f04c05 100644 --- a/interface/wx/richtext/richtextbuffer.h +++ b/interface/wx/richtext/richtextbuffer.h @@ -5403,6 +5403,8 @@ public: virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); + virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); + virtual wxString GetXMLNodeName() const { return wxT("cell"); } virtual bool CanEditProperties() const { return true; } @@ -5499,6 +5501,8 @@ public: virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); + virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); + virtual wxString GetXMLNodeName() const { return wxT("table"); } virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 352a85a00b..a5a35b1c07 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9227,6 +9227,22 @@ bool wxRichTextCell::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxR return wxRichTextBox::Draw(dc, context, range, selection, rect, descent, style); } +int wxRichTextCell::HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags) +{ + int ret = wxRichTextParagraphLayoutBox::HitTest(dc, context, pt, textPosition, obj, contextObj, flags); + if (ret != wxRICHTEXT_HITTEST_NONE) + { + return ret; + } + else + { + textPosition = m_ownRange.GetEnd()-1; + *obj = this; + *contextObj = this; + return wxRICHTEXT_HITTEST_AFTER|wxRICHTEXT_HITTEST_OUTSIDE; + } +} + /// Copy void wxRichTextCell::Copy(const wxRichTextCell& obj) { @@ -10482,6 +10498,23 @@ wxPosition wxRichTextTable::GetFocusedCell() const return position; } +int wxRichTextTable::HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags) +{ + for (int row = 0; row < GetRowCount(); ++row) + { + for (int col = 0; col < GetColumnCount(); ++col) + { + wxRichTextCell* cell = GetCell(row, col); + if (cell->wxRichTextObject::HitTest(dc, context, pt, textPosition, obj, contextObj, flags) != wxRICHTEXT_HITTEST_NONE) + { + return cell->HitTest(dc, context, pt, textPosition, obj, contextObj, flags); + } + } + } + + return wxRICHTEXT_HITTEST_NONE; +} + bool wxRichTextTable::DeleteRows(int startRow, int noRows) { wxASSERT((startRow + noRows) <= m_rowCount); -- 2.45.2