mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
synchronization with 'selection' branch
This commit is contained in:
parent
73001aa5fe
commit
f88bb3b9d5
1 changed files with 27 additions and 0 deletions
|
@ -58,6 +58,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
|
||||
public ZLTextView(ZLApplication application) {
|
||||
super(application);
|
||||
mySelection = new ZLTextSelection(this);
|
||||
}
|
||||
|
||||
public synchronized void setModel(ZLTextModel model) {
|
||||
|
@ -533,6 +534,31 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
final ZLTextParagraphCursor paragraph = info.ParagraphCursor;
|
||||
final ZLPaintContext context = myContext;
|
||||
|
||||
if (!mySelection.isEmpty() && from != to) {
|
||||
final ZLTextElementArea fromArea = page.TextElementMap.get(from);
|
||||
final ZLTextElementArea toArea = page.TextElementMap.get(to - 1);
|
||||
final ZLTextElementArea selectionStartArea = mySelection.getStartArea();
|
||||
final ZLTextElementArea selectionEndArea = mySelection.getEndArea();
|
||||
if (fromArea.compareTo(selectionEndArea) <= 0
|
||||
&& toArea.compareTo(selectionStartArea) >= 0) {
|
||||
final int top = y + 1;
|
||||
int left, right, bottom = y + info.Height + info.Descent;
|
||||
if (selectionStartArea.compareTo(fromArea) < 0) {
|
||||
left = getLeftMargin();
|
||||
} else {
|
||||
left = selectionStartArea.XStart;
|
||||
}
|
||||
if (selectionEndArea.compareTo(toArea) > 0) {
|
||||
right = getRightLine();
|
||||
bottom += info.VSpaceAfter;
|
||||
} else {
|
||||
right = selectionEndArea.XEnd;
|
||||
}
|
||||
context.setFillColor(getSelectedBackgroundColor());
|
||||
context.fillRectangle(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
int index = from;
|
||||
final int endElementIndex = info.EndElementIndex;
|
||||
int charIndex = info.RealStartCharIndex;
|
||||
|
@ -1189,6 +1215,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
|||
}
|
||||
|
||||
private ZLTextRegion mySelectedRegion;
|
||||
private ZLTextSelection mySelection;
|
||||
private boolean myHighlightSelectedRegion = true;
|
||||
|
||||
public void hideSelectedRegionBorder() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue