void ZLTextView::gotoParagraph(int num, bool last) { if (myModel.isNull()) { return; } if (myModel->kind() == ZLTextModel::TREE_MODEL) { if ((num >= 0) && (num < (int)myModel->paragraphsNumber())) { ZLTextTreeParagraph *tp = (ZLTextTreeParagraph*)(*myModel)[num]; if (myTreeStateIsFrozen) { int corrected = num; ZLTextTreeParagraph *parent = tp->parent(); while ((corrected > 0) && (parent != 0) && !parent->isOpen()) { for (--corrected; ((corrected > 0) && parent != (*myModel)[corrected]); --corrected); parent = parent->parent(); } if (last && (corrected != num)) { ++corrected; } num = corrected; } else { tp->openTree(); rebuildPaintInfo(true); } } } if (last) { if ((num > 0) && (num <= (int)myModel->paragraphsNumber())) { moveEndCursor(num); } } else { if ((num >= 0) && (num < (int)myModel->paragraphsNumber())) { moveStartCursor(num); } } }
void ZLTextTreeModel::removeParagraph(int index) { ZLTextTreeParagraph *p = (ZLTextTreeParagraph*)(*this)[index]; p->removeFromParent(); removeParagraphInternal(index); delete p; }
bool ZLTextView::onStylusPress(int x, int y) { myDoubleClickInfo.update(x, y, true); if (myDoubleClickInfo.Count > 10) { return true; } mySelectionModel.deactivate(); if (myModel.isNull()) { return false; } 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) { application().refreshWindow(); return true; } } if (myModel->kind() == ZLTextModel::TREE_MODEL) { ZLTextTreeNodeMap::const_iterator it = std::find_if(myTreeNodeMap.begin(), myTreeNodeMap.end(), ZLTextTreeNodeArea::RangeChecker(x, y)); if (it != myTreeNodeMap.end()) { int paragraphIndex = it->ParagraphIndex; ZLTextTreeParagraph *paragraph = (ZLTextTreeParagraph*)(*myModel)[paragraphIndex]; paragraph->open(!paragraph->isOpen()); rebuildPaintInfo(true); preparePaintInfo(); if (paragraph->isOpen()) { int nextParagraphIndex = paragraphIndex + paragraph->fullSize(); int lastParagraphIndex = endCursor().paragraphCursor().index(); if (endCursor().isEndOfParagraph()) { ++lastParagraphIndex; } if (lastParagraphIndex < nextParagraphIndex) { gotoParagraph(nextParagraphIndex, true); preparePaintInfo(); } } int firstParagraphIndex = startCursor().paragraphCursor().index(); if (startCursor().isStartOfParagraph()) { --firstParagraphIndex; } if (firstParagraphIndex >= paragraphIndex) { gotoParagraph(paragraphIndex); preparePaintInfo(); } application().refreshWindow(); return true; } } return 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; }