本文整理汇总了C++中ZLTextWordCursor类的典型用法代码示例。如果您正苦于以下问题:C++ ZLTextWordCursor类的具体用法?C++ ZLTextWordCursor怎么用?C++ ZLTextWordCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZLTextWordCursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startCursor
bool ZLTextArea::_getHyperlinkInfo(const ZLTextElementRectangle &rectangle, std::string &id, std::string &type, ZLTextKind& hyperlinkKind, int& x1, int&y1, int& x2, int& y2) const {
if ((rectangle.Kind != ZLTextElement::WORD_ELEMENT) &&
(rectangle.Kind != ZLTextElement::IMAGE_ELEMENT)) {
return false;
}
ZLTextWordCursor cursor = startCursor();
cursor.moveToParagraph(rectangle.ParagraphIndex);
cursor.moveToParagraphStart();
hyperlinkKind = REGULAR;
for (int i = 0; i < rectangle.ElementIndex; ++i) {
const ZLTextElement &element = cursor.element();
if (element.kind() == ZLTextElement::CONTROL_ELEMENT) {
const ZLTextControlEntry &control = ((const ZLTextControlElement&)element).entry();
if (control.isHyperlink()) {
hyperlinkKind = control.kind();
id = ((const ZLTextHyperlinkControlEntry&)control).label();
type = ((const ZLTextHyperlinkControlEntry&)control).hyperlinkType();
x1 = rectangle.XStart;
y1 = rectangle.YStart;
x2 = rectangle.XEnd;
y2 = rectangle.YEnd;
} else if (!control.isStart() && (control.kind() == hyperlinkKind)) {
hyperlinkKind = REGULAR;
}
}
cursor.nextWord();
}
return hyperlinkKind != REGULAR;
}
示例2: paragraphHeight
ZLTextWordCursor ZLTextAreaController::findStart(const ZLTextWordCursor &end, SizeUnit unit, int size) {
ZLTextWordCursor start = end;
size -= paragraphHeight(start, true, unit);
bool positionChanged = !start.isStartOfParagraph();
start.moveToParagraphStart();
while (size > 0) {
if (positionChanged && start.paragraphCursor().isEndOfSection()) {
break;
}
if (!start.previousParagraph()) {
break;
}
if (!start.paragraphCursor().isEndOfSection()) {
positionChanged = true;
}
size -= paragraphHeight(start, false, unit);
}
skip(start, unit, -size);
if (unit != LINE_UNIT) {
bool sameStart = start == end;
if (!sameStart && start.isEndOfParagraph() && end.isStartOfParagraph()) {
ZLTextWordCursor startCopy = start;
startCopy.nextParagraph();
sameStart = startCopy == end;
}
if (sameStart) {
start = findStart(end, LINE_UNIT, 1);
}
}
return start;
}
示例3: isEnabled
bool ScrollToHomeAction::isEnabled() const {
if (!isVisible()) {
return false;
}
ZLTextWordCursor cursor = FBReader::Instance().bookTextView().textArea().startCursor();
return cursor.isNull() || !cursor.isStartOfParagraph() || !cursor.paragraphCursor().isFirst();
}
示例4: textArea
bool BookTextView::getHyperlinkInfo(const ZLTextElementRectangle &rectangle, std::string &id, ZLHyperlinkType &type) const {
if ((rectangle.Kind != ZLTextElement::WORD_ELEMENT) &&
(rectangle.Kind != ZLTextElement::IMAGE_ELEMENT)) {
return false;
}
ZLTextWordCursor cursor = textArea().startCursor();
cursor.moveToParagraph(rectangle.ParagraphIndex);
cursor.moveToParagraphStart();
ZLTextKind hyperlinkKind = REGULAR;
for (int i = 0; i < rectangle.ElementIndex; ++i) {
const ZLTextElement &element = cursor.element();
if (element.kind() == ZLTextElement::CONTROL_ELEMENT) {
const ZLTextControlEntry &control = ((const ZLTextControlElement&)element).entry();
if (control.isHyperlink()) {
hyperlinkKind = control.kind();
id = ((const ZLTextHyperlinkControlEntry&)control).label();
type = ((const ZLTextHyperlinkControlEntry&)control).hyperlinkType();
} else if (!control.isStart() && (control.kind() == hyperlinkKind)) {
hyperlinkKind = REGULAR;
}
}
cursor.nextWord();
}
return hyperlinkKind != REGULAR;
}
示例5: startCursor
bool BookTextView::getHyperlinkId(const ZLTextElementArea &area, std::string &id, bool &isExternal) const {
if ((area.Kind != ZLTextElement::WORD_ELEMENT) &&
(area.Kind != ZLTextElement::IMAGE_ELEMENT)) {
return false;
}
ZLTextWordCursor cursor = startCursor();
cursor.moveToParagraph(area.ParagraphNumber);
cursor.moveToParagraphStart();
ZLTextKind hyperlinkKind = REGULAR;
for (int i = 0; i < area.TextElementNumber; ++i) {
const ZLTextElement &element = cursor.element();
if (element.kind() == ZLTextElement::CONTROL_ELEMENT) {
const ZLTextControlEntry &control = ((const ZLTextControlElement&)element).entry();
if (control.isHyperlink()) {
hyperlinkKind = control.kind();
id = ((const ZLTextHyperlinkControlEntry&)control).label();
} else if (!control.isStart() && (control.kind() == hyperlinkKind)) {
hyperlinkKind = REGULAR;
}
}
cursor.nextWord();
}
isExternal = hyperlinkKind == EXTERNAL_HYPERLINK;
return hyperlinkKind != REGULAR;
}
示例6: startCursor
std::string FBView::word(const ZLTextElementArea &area) const {
std::string txt;
if (area.Kind == ZLTextElement::WORD_ELEMENT) {
ZLTextWordCursor cursor = startCursor();
cursor.moveToParagraph(area.ParagraphIndex);
cursor.moveTo(area.ElementIndex, 0);
const ZLTextWord &word = (ZLTextWord&)cursor.element();
ZLUnicodeUtil::Ucs4String ucs4;
ZLUnicodeUtil::utf8ToUcs4(ucs4, word.Data, word.Size);
ZLUnicodeUtil::Ucs4String::iterator it = ucs4.begin();
while ((it != ucs4.end()) && !ZLUnicodeUtil::isLetter(*it)) {
++it;
}
if (it != ucs4.end()) {
ucs4.erase(ucs4.begin(), it);
it = ucs4.end() - 1;
while (!ZLUnicodeUtil::isLetter(*it)) {
--it;
}
ucs4.erase(it + 1, ucs4.end());
ZLUnicodeUtil::ucs4ToUtf8(txt, ucs4);
}
}
return txt;
}
示例7: endCursor
std::vector<size_t>::const_iterator ZLTextView::nextBreakIterator() const {
ZLTextWordCursor cursor = endCursor();
if (cursor.isNull()) {
cursor = startCursor();
}
if (cursor.isNull()) {
return myTextBreaks.begin();
}
return std::lower_bound(myTextBreaks.begin(), myTextBreaks.end(), cursor.paragraphCursor().index());
}
示例8: if
void ZLTextView::ViewStyle::applyControls(const ZLTextWordCursor &begin, const ZLTextWordCursor &end) {
for (ZLTextWordCursor cursor = begin; !cursor.equalWordNumber(end); cursor.nextWord()) {
const ZLTextElement &element = cursor.element();
if (element.kind() == ZLTextElement::CONTROL_ELEMENT) {
applyControl((ZLTextControlElement&)element);
} else if (element.kind() == ZLTextElement::FORCED_CONTROL_ELEMENT) {
applyControl((ZLTextForcedControlElement&)element);
}
}
}
示例9: strongContains
bool strongContains(const ZLTextSelectionModel::Range &range, const ZLTextWordCursor &cursor) {
const int pn = cursor.paragraphCursor().index();
const int wn = cursor.elementIndex();
return
((range.first.ParagraphIndex < pn) ||
((range.first.ParagraphIndex == pn) &&
(range.first.ElementIndex < wn))) &&
((range.second.ParagraphIndex > pn) ||
((range.second.ParagraphIndex == pn) &&
(range.second.ElementIndex > wn)));
}
示例10: sizeOfTextBeforeParagraph
size_t ZLTextView::PositionIndicator::sizeOfTextBeforeCursor(const ZLTextWordCursor &cursor) const {
const size_t paragraphIndex = cursor.paragraphCursor().index();
const size_t paragraphLength = cursor.paragraphCursor().paragraphLength();
if (paragraphLength == 0) {
return sizeOfTextBeforeParagraph(paragraphIndex);
} else {
return
sizeOfTextBeforeParagraph(paragraphIndex) +
muldiv(sizeOfParagraph(paragraphIndex), cursor.elementIndex(), paragraphLength);
}
}
示例11: buildInfos
ZLTextWordCursor ZLTextAreaController::buildInfos(const ZLTextWordCursor &start) {
myArea.myLineInfos.clear();
ZLTextWordCursor cursor = start;
int textHeight = myArea.height();
int counter = 0;
do {
ZLTextWordCursor paragraphEnd = cursor;
paragraphEnd.moveToParagraphEnd();
ZLTextWordCursor paragraphStart = cursor;
paragraphStart.moveToParagraphStart();
ZLTextArea::Style style(myArea, myArea.myProperties.baseStyle());
style.applyControls(paragraphStart, cursor);
ZLTextLineInfoPtr info = new ZLTextLineInfo(cursor, style.textStyle(), style.bidiLevel());
while (!info->End.isEndOfParagraph()) {
info = myArea.processTextLine(style, info->End, paragraphEnd);
textHeight -= info->Height + info->Descent;
if ((textHeight < 0) && (counter > 0)) {
break;
}
textHeight -= info->VSpaceAfter;
cursor = info->End;
myArea.myLineInfos.push_back(info);
if (textHeight < 0) {
break;
}
++counter;
}
} while (cursor.isEndOfParagraph() && cursor.nextParagraph() && !cursor.paragraphCursor().isEndOfSection() && (textHeight >= 0));
return cursor;
}
示例12: skip
void ZLTextAreaController::skip(ZLTextWordCursor &cursor, SizeUnit unit, int size) {
ZLTextWordCursor paragraphStart = cursor;
paragraphStart.moveToParagraphStart();
ZLTextWordCursor paragraphEnd = cursor;
paragraphEnd.moveToParagraphEnd();
ZLTextArea::Style style(myArea, myArea.myProperties.baseStyle());
style.applyControls(paragraphStart, cursor);
while (!cursor.isEndOfParagraph() && (size > 0)) {
const ZLTextLineInfoPtr info =
myArea.processTextLine(style, cursor, paragraphEnd);
cursor = info->End;
size -= infoHeight(*info, unit);
}
}
示例13: fbreader
bool CollectionView::_onStylusPress(int x, int y) {
fbreader().setHyperlinkCursor(false);
const ZLTextElementArea *imageArea = elementByCoordinates(x, y);
if ((imageArea != 0) && (imageArea->Kind == ZLTextElement::IMAGE_ELEMENT)) {
ZLTextWordCursor cursor = startCursor();
cursor.moveToParagraph(imageArea->ParagraphIndex);
cursor.moveTo(imageArea->ElementIndex, 0);
const ZLTextElement &element = cursor.element();
if (element.kind() != ZLTextElement::IMAGE_ELEMENT) {
return false;
}
const ZLTextImageElement &imageElement = (ZLTextImageElement&)element;
const std::string &id = imageElement.id();
if (id == CollectionModel::BookInfoImageId) {
editBookInfo(collectionModel().bookByParagraphIndex(imageArea->ParagraphIndex));
return true;
} else if (id == CollectionModel::RemoveBookImageId) {
removeBook(collectionModel().bookByParagraphIndex(imageArea->ParagraphIndex));
return true;
} else if (id == CollectionModel::RemoveTagImageId) {
removeTag(collectionModel().tagByParagraphIndex(imageArea->ParagraphIndex));
return true;
} else if (id == CollectionModel::TagInfoImageId) {
editTagInfo(collectionModel().tagByParagraphIndex(imageArea->ParagraphIndex));
return true;
} else {
return false;
}
}
int index = paragraphIndexByCoordinates(x, y);
if (index == -1) {
return false;
}
BookDescriptionPtr book = collectionModel().bookByParagraphIndex(index);
if (!book.isNull()) {
fbreader().openBook(book);
fbreader().showBookTextView();
return true;
}
return false;
}
示例14: sizeOfTextBeforeCursor
void ZLTextView::PositionIndicator::draw() {
ZLTextBaseStyle &baseStyle = ZLTextStyleCollection::instance().baseStyle();
ZLPaintContext &context = this->context();
ZLTextWordCursor endCursor = myTextView.endCursor();
bool isEndOfText = false;
if (endCursor.isEndOfParagraph()) {
isEndOfText = !endCursor.nextParagraph();
}
myExtraWidth = 0;
if (myInfo.isTimeShown()) {
drawExtraText(timeString());
}
if (myInfo.isBatteryShown()) {
drawExtraText(batteryString());
}
if (myInfo.isTextPositionShown()) {
drawExtraText(textPositionString());
}
const long bottom = this->bottom();
const long top = this->top();
const long left = this->left();
const long right = this->right();
if (left >= right) {
return;
}
size_t fillWidth = right - left - 1;
if (!isEndOfText) {
fillWidth =
muldiv(fillWidth, sizeOfTextBeforeCursor(myTextView.endCursor()), sizeOfTextBeforeParagraph(endTextIndex()));
}
context.setColor(baseStyle.RegularTextColorOption.value());
context.setFillColor(myInfo.color());
context.fillRectangle(myTextView.visualX(left + 1), top + 1, myTextView.visualX(left + fillWidth + 1), bottom - 1);
context.drawLine(myTextView.visualX(left), top, myTextView.visualX(right), top);
context.drawLine(myTextView.visualX(left), bottom, myTextView.visualX(right), bottom);
context.drawLine(myTextView.visualX(left), bottom, myTextView.visualX(left), top);
context.drawLine(myTextView.visualX(right), bottom, myTextView.visualX(right), top);
}
示例15: sizeOfParagraph
size_t ZLTextView::PositionIndicator::sizeOfTextBeforeParagraph(size_t paragraphIndex) const {
if (myTextView.myModel->kind() == ZLTextModel::TREE_MODEL) {
ZLTextWordCursor cursor = myTextView.startCursor();
if (cursor.isNull()) {
cursor = myTextView.endCursor();
}
if (!cursor.isNull()) {
const ZLTextTreeModel &treeModel = (const ZLTextTreeModel&)*myTextView.myModel;
size_t sum = 0;
for (size_t i = 0; i < paragraphIndex; ++i) {
const ZLTextTreeParagraph *para = (const ZLTextTreeParagraph*)treeModel[i];
if (para->parent()->isOpen()) {
sum += sizeOfParagraph(i);
}
}
return sum;
}
}
return myTextView.myTextSize[paragraphIndex] - myTextView.myTextSize[startTextIndex()];
}