+
+ // handle selection update:
+ if ( m_makingSelection )
+ {
+ bool goingDown = m_tmpSelFromPos.y < y ||
+ m_tmpSelFromPos.y == y && m_tmpSelFromPos.x < x;
+
+ if ( !m_tmpSelFromCell )
+ {
+ if (goingDown)
+ {
+ m_tmpSelFromCell = m_Cell->FindCellByPos(x, y,
+ wxHTML_FIND_NEAREST_BEFORE);
+ if (!m_tmpSelFromCell)
+ m_tmpSelFromCell = m_Cell->GetFirstTerminal();
+ }
+ else
+ {
+ m_tmpSelFromCell = m_Cell->FindCellByPos(x, y,
+ wxHTML_FIND_NEAREST_AFTER);
+ if (!m_tmpSelFromCell)
+ m_tmpSelFromCell = m_Cell->GetLastTerminal();
+ }
+ }
+
+ wxHtmlCell *selcell = cell;
+ if (!selcell)
+ {
+ if (goingDown)
+ {
+ selcell = m_Cell->FindCellByPos(x, y,
+ wxHTML_FIND_NEAREST_AFTER);
+ if (!selcell)
+ selcell = m_Cell->GetLastTerminal();
+ }
+ else
+ {
+ selcell = m_Cell->FindCellByPos(x, y,
+ wxHTML_FIND_NEAREST_BEFORE);
+ if (!selcell)
+ selcell = m_Cell->GetFirstTerminal();
+ }
+ }
+
+ // NB: it may *rarely* happen that the code above didn't find one
+ // of the cells, e.g. if wxHtmlWindow doesn't contain any
+ // visible cells.
+ if ( selcell && m_tmpSelFromCell )
+ {
+ if ( !m_selection )
+ {
+ // start selecting only if mouse movement was big enough
+ // (otherwise it was meant as mouse click, not selection):
+ const int PRECISION = 2;
+ wxPoint diff = m_tmpSelFromPos - wxPoint(x,y);
+ if (abs(diff.x) > PRECISION || abs(diff.y) > PRECISION)
+ {
+ m_selection = new wxHtmlSelection();
+ }
+ }
+ if ( m_selection )
+ {
+ if (goingDown)
+ {
+ m_selection->Set(m_tmpSelFromPos, m_tmpSelFromCell,
+ wxPoint(x,y), selcell);
+ }
+ else
+ {
+ m_selection->Set(wxPoint(x,y), selcell,
+ m_tmpSelFromPos, m_tmpSelFromCell);
+ }
+ Refresh(); // FIXME - optimize!
+ }
+ }
+ }
+
+ // handle cursor and status bar text changes: