本文整理汇总了C++中ZLTextWordCursor::nextParagraph方法的典型用法代码示例。如果您正苦于以下问题:C++ ZLTextWordCursor::nextParagraph方法的具体用法?C++ ZLTextWordCursor::nextParagraph怎么用?C++ ZLTextWordCursor::nextParagraph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZLTextWordCursor
的用法示例。
在下文中一共展示了ZLTextWordCursor::nextParagraph方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findStart
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;
}
示例2: 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;
}
示例3: text
// Added by John to enable caller to get text from current visible page.
void ZLTextSelectionModel::text(std::string & text, int max)
{
text.clear();
ZLTextWordCursor start = myView.startCursor();
ZLTextWordCursor end = myView.endCursor();
ZLTextWordCursor cursor = start;
while (cursor < end)
{
if (cursor.isEndOfParagraph())
{
cursor.nextParagraph();
continue;
}
const ZLTextElement &element = cursor.element();
switch (element.kind())
{
case ZLTextElement::WORD_ELEMENT:
{
const ZLTextWord &word = (const ZLTextWord&)element;
if (cursor.sameElementAs(end))
{
if (start.sameElementAs(end))
{
int skip = ZLUnicodeUtil::length(word.Data, start.charIndex());
int length = ZLUnicodeUtil::length(word.Data, end.charIndex()) - skip;
text.append(word.Data + skip, length);
}
else
{
text.append(word.Data, ZLUnicodeUtil::length(word.Data, end.charIndex()));
}
}
else if (cursor.charIndex() == 0)
{
text.append(word.Data, word.Size);
}
else /* cursor == start */
{
int skip = ZLUnicodeUtil::length(word.Data, cursor.charIndex());
text.append(word.Data + skip, word.Size - skip);
}
}
break;
case ZLTextElement::HSPACE_ELEMENT:
case ZLTextElement::NB_HSPACE_ELEMENT:
{
text += ' ';
}
break;
}
cursor.nextWord();
if (text.size() >= max)
{
return;
}
}
}
示例4: 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);
}
示例5: getFirstInternalHyperlinkId
std::string BookTextView::getFirstInternalHyperlinkId(int x0, int y0, int x1, int y1) {
std::string id;
std::string type;
const ZLTextElementArea * area = elementByCoordinates(x0, y0);
const ZLTextElementArea * stop_area = elementByCoordinates(x1, y1);
if ( !area || ((area->Kind != ZLTextElement::WORD_ELEMENT) &&
(area->Kind != ZLTextElement::IMAGE_ELEMENT))) {
return id;
}
ZLTextWordCursor cursor = startCursor();
cursor.moveToParagraph(area->ParagraphIndex);
int paragraphs = area->ParagraphIndex;
int end_paragraphs = stop_area ? stop_area->ParagraphIndex : 0;
do
{
cursor.moveToParagraphStart();
ZLTextKind hyperlinkKind = REGULAR;
for ( ; !cursor.isEndOfParagraph();) {
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();
if (type == "internal")
{
return id;
}
} else if (!control.isStart() && (control.kind() == hyperlinkKind)) {
hyperlinkKind = REGULAR;
}
}
cursor.nextWord();
}
} while( ++paragraphs <= end_paragraphs && cursor.nextParagraph());
return std::string();
}
示例6: sizeOfTextBeforeCursor
void ZLTextView::PositionIndicator::draw() {
ZLPaintContext &context = this->context();
ZLTextWordCursor endCursor = myTextView.textArea().endCursor();
bool isEndOfText = false;
if (endCursor.isEndOfParagraph()) {
isEndOfText = !endCursor.nextParagraph();
}
myExtraWidth = 0;
if (myInfo.isTimeShown()) {
drawExtraText(timeString());
}
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.textArea().endCursor()), sizeOfTextBeforeParagraph(endTextIndex()));
}
context.setColor(myTextView.color());
context.setFillColor(myInfo.color());
context.fillRectangle(left + 1, top + 1, left + fillWidth + 1, bottom - 1);
context.drawLine(left, top, right, top);
context.drawLine(left, bottom, right, bottom);
context.drawLine(left, bottom, left, top);
context.drawLine(right, bottom, right, top);
}
示例7: preparePaintInfo
bool ZLTextAreaController::preparePaintInfo() {
if ((myPaintState == NOTHING_TO_PAINT) || (myPaintState == READY)) {
return false;
}
myArea.myLineInfoCache.insert(myArea.myLineInfos.begin(), myArea.myLineInfos.end());
switch (myPaintState) {
default:
break;
case TO_SCROLL_FORWARD:
if (!myArea.myEndCursor.paragraphCursor().isLast() ||
!myArea.myEndCursor.isEndOfParagraph()) {
ZLTextWordCursor startCursor;
switch (myScrollingMode) {
case NO_OVERLAPPING:
break;
case KEEP_LINES:
startCursor = findLineFromEnd(myOverlappingValue);
break;
case SCROLL_LINES:
startCursor = findLineFromStart(myOverlappingValue);
if (startCursor.isEndOfParagraph()) {
startCursor.nextParagraph();
}
break;
case SCROLL_PERCENTAGE:
startCursor = findPercentFromStart(myOverlappingValue);
break;
}
if (!startCursor.isNull() && (startCursor == myArea.myStartCursor)) {
startCursor = findLineFromStart(1);
}
if (!startCursor.isNull()) {
ZLTextWordCursor endCursor = buildInfos(startCursor);
if (!visiblePageIsEmpty() && ((myScrollingMode != KEEP_LINES) || (endCursor != myArea.myEndCursor))) {
myArea.myStartCursor = startCursor;
myArea.myEndCursor = endCursor;
break;
}
}
myArea.myStartCursor = myArea.myEndCursor;
myArea.myEndCursor = buildInfos(myArea.myStartCursor);
}
break;
case TO_SCROLL_BACKWARD:
if (!myArea.myStartCursor.paragraphCursor().isFirst() || !myArea.myStartCursor.isStartOfParagraph()) {
switch (myScrollingMode) {
case NO_OVERLAPPING:
myArea.myStartCursor = findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height());
break;
case KEEP_LINES:
{
ZLTextWordCursor endCursor = findLineFromStart(myOverlappingValue);
if (!endCursor.isNull() && (endCursor == myArea.myEndCursor)) {
endCursor = findLineFromEnd(1);
}
if (!endCursor.isNull()) {
ZLTextWordCursor startCursor = findStart(endCursor, PIXEL_UNIT, myArea.height());
myArea.myStartCursor =
(startCursor != myArea.myStartCursor) ?
startCursor : findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height());
} else {
myArea.myStartCursor = findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height());
}
break;
}
case SCROLL_LINES:
myArea.myStartCursor = findStart(myArea.myStartCursor, LINE_UNIT, myOverlappingValue);
break;
case SCROLL_PERCENTAGE:
myArea.myStartCursor =
findStart(myArea.myStartCursor, PIXEL_UNIT, myArea.height() * myOverlappingValue / 100);
break;
}
myArea.myEndCursor = buildInfos(myArea.myStartCursor);
if (visiblePageIsEmpty()) {
myArea.myStartCursor = findStart(myArea.myStartCursor, LINE_UNIT, 1);
myArea.myEndCursor = buildInfos(myArea.myStartCursor);
}
}
break;
case START_IS_KNOWN:
myArea.myEndCursor = buildInfos(myArea.myStartCursor);
if (visiblePageIsEmpty()) {
ZLTextWordCursor startCursor = findLineFromStart(1);
//.........这里部分代码省略.........
示例8: createData
void ZLTextSelectionModel::createData() const {
if (!myTextIsUpToDate && !isEmpty()) {
Range r = internalRange();
ZLTextWordCursor start = myArea.startCursor();
start.moveToParagraph(r.first.ParagraphIndex);
start.moveTo(r.first.ElementIndex, r.first.CharIndex);
ZLTextWordCursor end = myArea.startCursor();
end.moveToParagraph(r.second.ParagraphIndex);
end.moveTo(r.second.ElementIndex, r.second.CharIndex);
std::set<ZLTextParagraphCursorPtr> pcursors;
pcursors.insert(start.paragraphCursorPtr());
ZLTextWordCursor cursor = start;
while (cursor < end) {
if (cursor.isEndOfParagraph()) {
cursor.nextParagraph();
pcursors.insert(cursor.paragraphCursorPtr());
myText.append(ZLibrary::EndOfLine);
continue;
}
const ZLTextElement &element = cursor.element();
switch (element.kind()) {
case ZLTextElement::WORD_ELEMENT:
{
const ZLTextWord &word = (const ZLTextWord&)element;
if (cursor.sameElementAs(end)) {
if (start.sameElementAs(end)) {
int skip = ZLUnicodeUtil::length(word.Data, start.charIndex());
int length = ZLUnicodeUtil::length(word.Data, end.charIndex()) - skip;
myText.append(word.Data + skip, length);
} else {
myText.append(word.Data, ZLUnicodeUtil::length(word.Data, end.charIndex()));
}
} else if (cursor.charIndex() == 0) {
myText.append(word.Data, word.Size);
} else /* cursor == start */ {
int skip = ZLUnicodeUtil::length(word.Data, cursor.charIndex());
myText.append(word.Data + skip, word.Size - skip);
}
break;
}
case ZLTextElement::IMAGE_ELEMENT:
if (myImage.isNull()) {
myImage = ((const ZLTextImageElement&)element).image();
}
break;
case ZLTextElement::HSPACE_ELEMENT:
case ZLTextElement::NB_HSPACE_ELEMENT:
myText += ' ';
break;
default:
break;
}
cursor.nextWord();
}
if ((cursor == end) && !cursor.isEndOfParagraph() && myImage.isNull()) {
const ZLTextElement &element = cursor.element();
if (element.kind() == ZLTextElement::IMAGE_ELEMENT) {
myImage = ((const ZLTextImageElement&)element).image();
}
}
myCursors.swap(pcursors);
myTextIsUpToDate = true;
}
}