@Override protected void releaseSelectionCursor() { super.releaseSelectionCursor(); if (getCountOfSelectedWords() > 0) { myReader.runAction(ActionCode.SELECTION_SHOW_PANEL); } }
private void addBookmark() { final FBReader fbreader = (FBReader) FBReader.Instance(); final ZLTextView textView = fbreader.getTextView(); final ZLTextWordCursor cursor = textView.getStartCursor(); if (cursor.isNull()) { // TODO: implement return; } // TODO: text edit dialog final Bookmark bookmark = new Bookmark( fbreader.Model.Book, createBookmarkText(cursor), textView.getModel().getId(), cursor); myThisBookBookmarks.add(0, bookmark); AllBooksBookmarks.add(0, bookmark); invalidateAllViews(); }
boolean start(int x, int y) { clear(); final ZLTextRegion region = myView.findRegion(x, y, ZLTextView.MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter); if (region == null) { return false; } myRightMostRegionSoul = myLeftMostRegionSoul = region.getSoul(); return true; }
@Override public ZLTextPosition getEndPosition() { if (isEmpty()) { return null; } final ZLTextParagraphCursor cursor = ZLTextParagraphCursor.cursor(myView.getModel(), myRightMostRegionSoul.ParagraphIndex); final ZLTextElement element = cursor.getElement(myRightMostRegionSoul.EndElementIndex); return new ZLTextFixedPosition( myRightMostRegionSoul.ParagraphIndex, myRightMostRegionSoul.EndElementIndex, element instanceof ZLTextWord ? ((ZLTextWord) element).Length : 0); }
public void traverse(ZLTextPosition from, ZLTextPosition to) { final int fromParagraph = from.getParagraphIndex(); final int toParagraph = to.getParagraphIndex(); ZLTextParagraphCursor cursor = ZLTextParagraphCursor.cursor(myView.getModel(), fromParagraph); for (int i = fromParagraph; i <= toParagraph; ++i) { final int fromElement = i == fromParagraph ? from.getElementIndex() : 0; final int toElement = i == toParagraph ? to.getElementIndex() : cursor.getParagraphLength() - 1; for (int j = fromElement; j <= toElement; j++) { final ZLTextElement element = cursor.getElement(j); if (element == ZLTextElement.HSpace) { processSpace(); } else if (element instanceof ZLTextWord) { processWord((ZLTextWord) element); } } if (i < toParagraph) { processEndOfParagraph(); cursor = cursor.next(); } } }
void expandTo(int x, int y) { if (isEmpty()) { return; } final ZLTextElementAreaVector vector = myView.myCurrentPage.TextElementMap; final ZLTextElementArea firstArea = vector.getFirstArea(); final ZLTextElementArea lastArea = vector.getLastArea(); if (firstArea != null && y < firstArea.YStart) { if (myScroller != null && myScroller.scrollsForward()) { myScroller.stop(); myScroller = null; } if (myScroller == null) { myScroller = new Scroller(false, x, y); return; } } else if (lastArea != null && y + ZLTextSelectionCursor.getHeight() / 2 + ZLTextSelectionCursor.getAccent() / 2 > lastArea.YEnd) { if (myScroller != null && !myScroller.scrollsForward()) { myScroller.stop(); myScroller = null; } if (myScroller == null) { myScroller = new Scroller(true, x, y); return; } } else { if (myScroller != null) { myScroller.stop(); myScroller = null; } } if (myScroller != null) { myScroller.setXY(x, y); } ZLTextRegion region = myView.findRegion(x, y, ZLTextView.MAX_SELECTION_DISTANCE, ZLTextRegion.AnyRegionFilter); if (region == null && myScroller != null) { region = myView.findRegion(x, y, ZLTextRegion.AnyRegionFilter); } if (region == null) { return; } final ZLTextRegion.Soul soul = region.getSoul(); if (myCursorInMovement == ZLTextSelectionCursor.Right) { if (myLeftMostRegionSoul.compareTo(soul) <= 0) { myRightMostRegionSoul = soul; } else { myRightMostRegionSoul = myLeftMostRegionSoul; myLeftMostRegionSoul = soul; myCursorInMovement = ZLTextSelectionCursor.Left; } } else { if (myRightMostRegionSoul.compareTo(soul) >= 0) { myLeftMostRegionSoul = soul; } else { myLeftMostRegionSoul = myRightMostRegionSoul; myRightMostRegionSoul = soul; myCursorInMovement = ZLTextSelectionCursor.Right; } } if (myCursorInMovement == ZLTextSelectionCursor.Right) { if (hasAPartAfterPage(myView.myCurrentPage)) { myView.scrollPage(true, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.Application.getViewWidget().reset(); myView.preparePaintInfo(); } } else { if (hasAPartBeforePage(myView.myCurrentPage)) { myView.scrollPage(false, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.Application.getViewWidget().reset(); myView.preparePaintInfo(); } } }
@Override public synchronized void onScrollingFinished(PageIndex pageIndex) { super.onScrollingFinished(pageIndex); myReader.storePosition(); }
public void setModel(ZLTextModel model) { super.setModel(model); if (myFooter != null) { myFooter.resetTOCMarks(); } }
@Override public ZLColor getBackgroundColor() { return myView.getSelectionBackgroundColor(); }