diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index e3adf20e6e..d95fe95a2e 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -329,7 +329,12 @@ public: // Returns absolute position of the cell on HTML canvas. // If rootCell is provided, then it's considered to be the root of the // hierarchy and the returned value is relative to it. - wxPoint GetAbsPos(wxHtmlCell *rootCell = NULL) const; + wxPoint GetAbsPos(const wxHtmlCell *rootCell = NULL) const; + + // Returns minimum bounding rectangle of this cell in coordinates, relative + // to the rootCell, if it is provided, or relative to the result of + // GetRootCell() if the rootCell is NULL. + wxRect GetRect(const wxHtmlCell *rootCell = NULL) const; // Returns root cell of the hierarchy (i.e. grand-grand-...-parent that // doesn't have a parent itself) diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 0ce3a3e8a3..a559df99f2 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -221,10 +221,10 @@ wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y, } -wxPoint wxHtmlCell::GetAbsPos(wxHtmlCell *rootCell) const +wxPoint wxHtmlCell::GetAbsPos(const wxHtmlCell *rootCell) const { wxPoint p(m_PosX, m_PosY); - for (wxHtmlCell *parent = m_Parent; parent && parent != rootCell; + for (const wxHtmlCell *parent = m_Parent; parent && parent != rootCell; parent = parent->m_Parent) { p.x += parent->m_PosX; @@ -233,6 +233,11 @@ wxPoint wxHtmlCell::GetAbsPos(wxHtmlCell *rootCell) const return p; } +wxRect wxHtmlCell::GetRect(const wxHtmlCell* rootCell) const +{ + return wxRect(GetAbsPos(rootCell), wxSize(m_Width, m_Height)); +} + wxHtmlCell *wxHtmlCell::GetRootCell() const { wxHtmlCell *c = wxConstCast(this, wxHtmlCell);