void GroupCell::SelectRectInOutput(wxRect& rect, wxPoint& one, wxPoint& two, MathCell **first, MathCell **last) { if (m_hide) return; MathCell* tmp; wxPoint start, end; if (one.y < two.y || (one.y == two.y && one.x < two.x)) { start = one; end = two; } else { start = two; end = one; } // Lets select a rectangle tmp = m_output; *first = *last = NULL; while (tmp != NULL && !rect.Intersects(tmp->GetRect())) tmp = tmp->m_nextToDraw; *first = tmp; *last = tmp; while (tmp != NULL) { if (rect.Intersects(tmp->GetRect())) *last = tmp; tmp = tmp->m_nextToDraw; } if (*first != NULL && *last != NULL) { // If selection is on multiple lines, we need to correct it if ((*first)->GetCurrentY() != (*last)->GetCurrentY()) { tmp = *last; MathCell *curr; // Find the first cell in selection while (*first != tmp && ((*first)->GetCurrentX() + (*first)->GetWidth() < start.x || (*first)->GetCurrentY() + (*first)->GetDrop() < start.y)) *first = (*first)->m_nextToDraw; // Find the last cell in selection curr = *last = *first; while (1) { curr = curr->m_nextToDraw; if (curr == NULL) break; if (curr->GetCurrentX() <= end.x && curr->GetCurrentY() - curr->GetMaxCenter() <= end.y) *last = curr; if (curr == tmp) break; } } if (*first == *last) (*first)->SelectInner(rect, first, last); } }