void ZLTextView::paint() { preparePaintInfo(); myTextElementMap.clear(); myTreeNodeMap.clear(); context().clear(ZLTextStyleCollection::instance().baseStyle().BackgroundColorOption.value()); if (empty()) { return; } std::vector<size_t> labels; labels.reserve(myLineInfos.size() + 1); labels.push_back(0); int y = topMargin(); for (std::vector<ZLTextLineInfoPtr>::const_iterator it = myLineInfos.begin(); it != myLineInfos.end(); ++it) { const ZLTextLineInfo &info = **it; prepareTextLine(info, y); y += info.Height + info.Descent + info.VSpaceAfter; labels.push_back(myTextElementMap.size()); } mySelectionModel.update(); y = topMargin(); int index = 0; for (std::vector<ZLTextLineInfoPtr>::const_iterator it = myLineInfos.begin(); it != myLineInfos.end(); ++it) { const ZLTextLineInfo &info = **it; drawTextLine(info, y, labels[index], labels[index + 1]); y += info.Height + info.Descent + info.VSpaceAfter; ++index; } fb::shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull() && (indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR)) { positionIndicator()->draw(); } if (myDoUpdateScrollbar && !indicatorInfo.isNull()) { myDoUpdateScrollbar = false; const size_t full = positionIndicator()->sizeOfTextBeforeParagraph(positionIndicator()->endTextIndex()); const size_t from = positionIndicator()->sizeOfTextBeforeCursor(startCursor()); const size_t to = positionIndicator()->sizeOfTextBeforeCursor(endCursor()); bool showScrollbar = (indicatorInfo->type() == ZLTextPositionIndicatorInfo::OS_SCROLLBAR) && (to - from < full); if (showScrollbar) { setScrollbarEnabled(VERTICAL, true); setScrollbarParameters(VERTICAL, full, from, to); } else { setScrollbarEnabled(VERTICAL, false); } } ZLTextParagraphCursorCache::cleanup(); }
void ZLTextView::paint() { context().clear(backgroundColor()); // PB // myTextAreaController.area().setOffsets( // textArea().isRtl() ? rightMargin() : leftMargin(), topMargin() // ); myTextAreaController.area().setOffsets(0, 0); // if (!) preparePaintInfo(); ////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<, if (textArea().isEmpty()) { return; } if (!ZLNXPaintContext::lock_drawing) myTextAreaController.area().paint(); /////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull() && (indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR)) { positionIndicator()->draw(); } if (myDoUpdateScrollbar && !indicatorInfo.isNull()) { myDoUpdateScrollbar = false; const size_t full = positionIndicator()->sizeOfTextBeforeParagraph(positionIndicator()->endTextIndex()); const size_t from = positionIndicator()->sizeOfTextBeforeCursor(textArea().startCursor()); const size_t to = positionIndicator()->sizeOfTextBeforeCursor(textArea().endCursor()); bool showScrollbar = (indicatorInfo->type() == ZLTextPositionIndicatorInfo::OS_SCROLLBAR) && (to - from < full); if (showScrollbar) { setScrollbarEnabled(VERTICAL, true); setScrollbarParameters(VERTICAL, full, from, to); } else { setScrollbarEnabled(VERTICAL, false); } } ZLTextParagraphCursorCache::cleanup(); }
void ZLTextView::gotoCharIndex(size_t charIndex) { shared_ptr<ZLTextModel> model = textArea().model(); if (model.isNull() || positionIndicator().isNull()) { return; } std::vector<size_t>::const_iterator i = nextBreakIterator(); const size_t startParagraphIndex = (i != myTextBreaks.begin()) ? *(i - 1) + 1 : 0; const size_t endParagraphIndex = (i != myTextBreaks.end()) ? *i : model->paragraphsNumber(); const size_t fullTextSize = myTextSize[endParagraphIndex] - myTextSize[startParagraphIndex]; charIndex = std::min(charIndex, fullTextSize - 1); std::vector<size_t>::const_iterator j = std::lower_bound(myTextSize.begin(), myTextSize.end(), charIndex + myTextSize[startParagraphIndex]); size_t paragraphIndex = j - myTextSize.begin(); if ((*model)[paragraphIndex]->kind() == ZLTextParagraph::END_OF_SECTION_PARAGRAPH) { gotoParagraph(paragraphIndex, true); return; } if (paragraphIndex > startParagraphIndex) { --paragraphIndex; } gotoParagraph(paragraphIndex, false); preparePaintInfo(); if (!positionIndicator().isNull()) { size_t endCharIndex = positionIndicator()->sizeOfTextBeforeCursor(textArea().endCursor()); if (endCharIndex > charIndex) { while (endCharIndex > charIndex) { scrollPage(false, ZLTextAreaController::SCROLL_LINES, 1); preparePaintInfo(); if (positionIndicator()->sizeOfTextBeforeCursor(textArea().startCursor()) <= myTextSize[startParagraphIndex]) { break; } endCharIndex = positionIndicator()->sizeOfTextBeforeCursor(textArea().endCursor()); } if (endCharIndex < charIndex) { scrollPage(true, ZLTextAreaController::SCROLL_LINES, 1); } } else { int startCharIndex = positionIndicator()->sizeOfTextBeforeCursor(textArea().startCursor()); while (endCharIndex < charIndex) { scrollPage(true, ZLTextAreaController::SCROLL_LINES, 1); preparePaintInfo(); const int newStartCharIndex = positionIndicator()->sizeOfTextBeforeCursor(textArea().startCursor()); if (newStartCharIndex <= startCharIndex) { break; } startCharIndex = newStartCharIndex; endCharIndex = positionIndicator()->sizeOfTextBeforeCursor(textArea().endCursor()); } if (endCharIndex > charIndex) { scrollPage(false, ZLTextAreaController::SCROLL_LINES, 1); } } } }
bool ZLTextView::onStylusPress(int x, int y) { mySelectionModel.deactivate(); if (myModel.isNull()) { return false; } shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull() && indicatorInfo->isVisible() && 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 paragraphNumber = it->ParagraphNumber; ZLTextTreeParagraph *paragraph = (ZLTextTreeParagraph*)(*myModel)[paragraphNumber]; paragraph->open(!paragraph->isOpen()); rebuildPaintInfo(true); preparePaintInfo(); if (paragraph->isOpen()) { int nextParagraphNumber = paragraphNumber + paragraph->fullSize(); int lastParagraphNumber = endCursor().paragraphCursor().index(); if (endCursor().isEndOfParagraph()) { ++lastParagraphNumber; } if (lastParagraphNumber < nextParagraphNumber) { gotoParagraph(nextParagraphNumber, true); preparePaintInfo(); } } int firstParagraphNumber = startCursor().paragraphCursor().index(); if (startCursor().isStartOfParagraph()) { --firstParagraphNumber; } if (firstParagraphNumber >= paragraphNumber) { gotoParagraph(paragraphNumber); preparePaintInfo(); } application().refreshWindow(); return true; } } return false; }
void ZLTextView::paint() { context().clear(backgroundColor()); myTextAreaController.area().setOffsets( textArea().isRtl() ? rightMargin() : leftMargin(), topMargin() + headerHeight() ); preparePaintInfo(); if (textArea().isEmpty()) { return; } myTextAreaController.area().paint(); shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo(); if (!indicatorInfo.isNull()) { switch (indicatorInfo->type()) { default: break; case ZLTextPositionIndicatorInfo::PAGE_FOOTER: positionIndicator()->draw(); break; case ZLTextPositionIndicatorInfo::PAGE_HEADER: paintHeader(); break; } } if (myDoUpdateScrollbar && !indicatorInfo.isNull()) { myDoUpdateScrollbar = false; const std::size_t full = sizeOfTextBeforeParagraph(endTextIndex()); const std::size_t from = sizeOfTextBeforeCursor(textArea().startCursor()); const std::size_t to = sizeOfTextBeforeCursor(textArea().endCursor()); bool showScrollbar = (indicatorInfo->type() == ZLTextPositionIndicatorInfo::OS_SCROLLBAR) && (to - from < full); if (showScrollbar) { setScrollbarEnabled(VERTICAL, true); setScrollbarParameters(VERTICAL, full, from, to); } else { setScrollbarEnabled(VERTICAL, false); } } ZLTextParagraphCursorCache::cleanup(); }
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; }
size_t ZLTextView::pageIndex() { if (empty() || positionIndicator().isNull() || endCursor().isNull()) { return 0; } return positionIndicator()->sizeOfTextBeforeCursor(endCursor()) / 2048 + 1; }
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; }