+wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y,
+ unsigned flags) const
+{
+ if ( flags & wxHTML_FIND_EXACT )
+ {
+ for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() )
+ {
+ int cx = cell->GetPosX(),
+ cy = cell->GetPosY();
+
+ if ( (cx <= x) && (cx + cell->GetWidth() > x) &&
+ (cy <= y) && (cy + cell->GetHeight() > y) )
+ {
+ return cell->FindCellByPos(x - cx, y - cy, flags);
+ }
+ }
+ }
+ else if ( flags & wxHTML_FIND_NEAREST_AFTER )
+ {
+ wxHtmlCell *c;
+ int y2;
+ for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() )
+ {
+ y2 = cell->GetPosY() + cell->GetHeight() - 1;
+ if (y2 < y || (y2 == y && cell->GetPosX()+cell->GetWidth()-1 < x))
+ continue;
+ c = cell->FindCellByPos(x - cell->GetPosX(), y - cell->GetPosY(),
+ flags);
+ if (c) return c;
+ }
+ }
+ else if ( flags & wxHTML_FIND_NEAREST_BEFORE )
+ {
+ wxHtmlCell *c;
+ for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() )
+ {
+ if (cell->GetPosY() > y ||
+ (cell->GetPosY() == y && cell->GetPosX() > x))
+ break;
+ c = cell->FindCellByPos(x - cell->GetPosX(), y - cell->GetPosY(),
+ flags);
+ if (c) return c;
+ }