bool ZLTextSelectionModel::extendTo(int x, int y) { if (!myIsActive || myView.myTextElementMap.empty()) { return false; } Range oldRange = internalRange(); setBound(mySecondBound, x, y); Range newRange = internalRange(); myStoredX = x; myStoredY = y; if (!mySecondBound.Before.Exists) { startSelectionScrolling(false); } else if (!mySecondBound.After.Exists) { startSelectionScrolling(true); } else { stopSelectionScrolling(); } if ((oldRange.first != newRange.first) || (oldRange.second != newRange.second)) { myTextIsUpToDate = false; clearData(); myRangeVectorIsUpToDate = false; myRanges.clear(); return true; } return false; }
void ZLTextSelectionModel::clear() { stopSelectionScrolling(); myIsEmpty = true; myIsActive = false; myDoUpdate = false; myCursors.clear(); clearData(); myTextIsUpToDate = true; myRanges.clear(); myRangeVectorIsUpToDate = true; }
bool ZLTextView::onStylusMovePressed(int x, int y) { switch (myTextAreaController.area().selectionModel().extendTo(textArea().realX(x), y)) { case ZLTextSelectionModel::BOUND_NOT_CHANGED: stopSelectionScrolling(); break; case ZLTextSelectionModel::BOUND_CHANGED: stopSelectionScrolling(); ZLApplication::Instance().refreshWindow(); break; case ZLTextSelectionModel::BOUND_OVER_BEFORE: startSelectionScrolling(false); ZLApplication::Instance().refreshWindow(); break; case ZLTextSelectionModel::BOUND_OVER_AFTER: startSelectionScrolling(true); ZLApplication::Instance().refreshWindow(); break; } return true; }
bool ZLTextView::onStylusRelease(int x, int y) { stopSelectionScrolling(); myDoubleClickInfo.update(x, y, false); AppLog("myDoubleClickInfo.Count 1 %d", myDoubleClickInfo.Count); shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull() && (indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR) && indicatorInfo->isSensitive() && positionIndicator()->isResponsibleFor(x, y)) { return true; } AppLog("myDoubleClickInfo.Count 2 %d", myDoubleClickInfo.Count); if (myDoubleClickInfo.Count > 0) { return onStylusClick(x, y, myDoubleClickInfo.Count); } AppLog("myDoubleClickInfo.Count 3 %d", myDoubleClickInfo.Count); myTextAreaController.area().selectionModel().deactivate(); return false; }
void ZLTextSelectionModel::deactivate() { stopSelectionScrolling(); myIsActive = false; myDoUpdate = false; }
bool ZLTextView::onStylusPress(int x, int y) { AppLog("ZLTextView::onStylusPress 1"); stopSelectionScrolling(); myDoubleClickInfo.update(x, y, true); if (myDoubleClickInfo.Count > 10) { return true; } myTextAreaController.area().selectionModel().deactivate(); shared_ptr<ZLTextModel> model = textArea().model(); if (model.isNull()) { return false; } AppLog("ZLTextView::onStylusPress 2"); shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull() && (indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR) && indicatorInfo->isSensitive()) { myTreeStateIsFrozen = true; bool indicatorAnswer = positionIndicator()->onStylusPress(x, y); myTreeStateIsFrozen = false; if (indicatorAnswer) { ZLApplication::Instance().refreshWindow(); return true; } } AppLog("ZLTextView::onStylusPress 3"); if (model->kind() == ZLTextModel::TREE_MODEL) { const ZLTextTreeNodeRectangle *node = textArea().treeNodeByCoordinates(x, y); if (node != 0) { int paragraphIndex = node->ParagraphIndex; ZLTextTreeParagraph *paragraph = (ZLTextTreeParagraph*)(*model)[paragraphIndex]; paragraph->open(!paragraph->isOpen()); myTextAreaController.rebuildPaintInfo(true); preparePaintInfo(); if (paragraph->isOpen()) { int nextParagraphIndex = paragraphIndex + paragraph->fullSize(); int lastParagraphIndex = textArea().endCursor().paragraphCursor().index(); if (textArea().endCursor().isEndOfParagraph()) { ++lastParagraphIndex; } if (lastParagraphIndex < nextParagraphIndex) { gotoParagraph(nextParagraphIndex, true); preparePaintInfo(); } } const ZLTextWordCursor &startCursor = textArea().startCursor(); int firstParagraphIndex = startCursor.paragraphCursor().index(); if (startCursor.isStartOfParagraph()) { --firstParagraphIndex; } if (firstParagraphIndex >= paragraphIndex) { gotoParagraph(paragraphIndex); preparePaintInfo(); } ZLApplication::Instance().refreshWindow(); AppLog("ZLTextView::onStylusPress 4"); return true; } } AppLog("ZLTextView::onStylusPress 5"); return false; }