1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

2 pages view

This commit is contained in:
Nikolay Pultsin 2013-04-28 18:50:18 +02:00
parent a6147ce43d
commit 4d7522a60d
5 changed files with 45 additions and 10 deletions

View file

@ -68,6 +68,7 @@ public final class FBReaderApp extends ZLApplication {
public final ZLIntegerRangeOption RightMarginOption; public final ZLIntegerRangeOption RightMarginOption;
public final ZLIntegerRangeOption TopMarginOption; public final ZLIntegerRangeOption TopMarginOption;
public final ZLIntegerRangeOption BottomMarginOption; public final ZLIntegerRangeOption BottomMarginOption;
public final ZLIntegerRangeOption IntercolumnSpaceOption;
{ {
final int dpi = ZLibrary.Instance().getDisplayDPI(); final int dpi = ZLibrary.Instance().getDisplayDPI();
final int x = ZLibrary.Instance().getPixelWidth(); final int x = ZLibrary.Instance().getPixelWidth();
@ -77,6 +78,7 @@ public final class FBReaderApp extends ZLApplication {
RightMarginOption = new ZLIntegerRangeOption("Options", "RightMargin", 0, 100, horMargin); RightMarginOption = new ZLIntegerRangeOption("Options", "RightMargin", 0, 100, horMargin);
TopMarginOption = new ZLIntegerRangeOption("Options", "TopMargin", 0, 100, 0); TopMarginOption = new ZLIntegerRangeOption("Options", "TopMargin", 0, 100, 0);
BottomMarginOption = new ZLIntegerRangeOption("Options", "BottomMargin", 0, 100, 4); BottomMarginOption = new ZLIntegerRangeOption("Options", "BottomMargin", 0, 100, 4);
IntercolumnSpaceOption = new ZLIntegerRangeOption("Options", "IntercolumnSpace", 0, 100, 4 * horMargin);
} }
public final ZLIntegerRangeOption ScrollbarTypeOption = public final ZLIntegerRangeOption ScrollbarTypeOption =

View file

@ -352,6 +352,11 @@ public final class FBView extends ZLTextView {
return myReader.BottomMarginOption.getValue(); return myReader.BottomMarginOption.getValue();
} }
@Override
public int getIntercolumnSpace() {
return myReader.IntercolumnSpaceOption.getValue();
}
@Override @Override
public ZLFile getWallpaperFile() { public ZLFile getWallpaperFile() {
final String filePath = myReader.getColorProfile().WallpaperOption.getValue(); final String filePath = myReader.getColorProfile().WallpaperOption.getValue();

View file

@ -25,6 +25,7 @@ final class ZLTextPage {
final ZLTextWordCursor StartCursor = new ZLTextWordCursor(); final ZLTextWordCursor StartCursor = new ZLTextWordCursor();
final ZLTextWordCursor EndCursor = new ZLTextWordCursor(); final ZLTextWordCursor EndCursor = new ZLTextWordCursor();
final ArrayList<ZLTextLineInfo> LineInfos = new ArrayList<ZLTextLineInfo>(); final ArrayList<ZLTextLineInfo> LineInfos = new ArrayList<ZLTextLineInfo>();
int Column0Height;
int PaintState = PaintStateEnum.NOTHING_TO_PAINT; int PaintState = PaintStateEnum.NOTHING_TO_PAINT;
final ZLTextElementAreaVector TextElementMap = new ZLTextElementAreaVector(); final ZLTextElementAreaVector TextElementMap = new ZLTextElementAreaVector();

View file

@ -433,12 +433,17 @@ public abstract class ZLTextView extends ZLTextViewBase {
final ArrayList<ZLTextLineInfo> lineInfos = page.LineInfos; final ArrayList<ZLTextLineInfo> lineInfos = page.LineInfos;
final int[] labels = new int[lineInfos.size() + 1]; final int[] labels = new int[lineInfos.size() + 1];
int x = getLeftMargin();
int y = getTopMargin(); int y = getTopMargin();
int index = 0; int index = 0;
for (ZLTextLineInfo info : lineInfos) { for (ZLTextLineInfo info : lineInfos) {
prepareTextLine(page, info, y); prepareTextLine(page, info, x, y);
y += info.Height + info.Descent + info.VSpaceAfter; y += info.Height + info.Descent + info.VSpaceAfter;
labels[++index] = page.TextElementMap.size(); labels[++index] = page.TextElementMap.size();
if (index == page.Column0Height) {
y = getTopMargin();
x += getTextColumnWidth() + getIntercolumnSpace();
}
} }
y = getTopMargin(); y = getTopMargin();
@ -447,6 +452,9 @@ public abstract class ZLTextView extends ZLTextViewBase {
drawTextLine(page, info, labels[index], labels[index + 1], y); drawTextLine(page, info, labels[index], labels[index + 1], y);
y += info.Height + info.Descent + info.VSpaceAfter; y += info.Height + info.Descent + info.VSpaceAfter;
++index; ++index;
if (index == page.Column0Height) {
y = getTopMargin();
}
} }
final ZLTextRegion selectedElementRegion = getSelectedRegion(page); final ZLTextRegion selectedElementRegion = getSelectedRegion(page);
@ -835,7 +843,8 @@ public abstract class ZLTextView extends ZLTextViewBase {
result.setCursor(start); result.setCursor(start);
int textAreaHeight = getTextAreaHeight(); int textAreaHeight = getTextAreaHeight();
page.LineInfos.clear(); page.LineInfos.clear();
int counter = 0; page.Column0Height = 0;
int columnCounter = 0;
do { do {
resetTextStyle(); resetTextStyle();
final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor(); final ZLTextParagraphCursor paragraphCursor = result.getParagraphCursor();
@ -846,16 +855,28 @@ public abstract class ZLTextView extends ZLTextViewBase {
while (info.EndElementIndex != endIndex) { while (info.EndElementIndex != endIndex) {
info = processTextLine(paragraphCursor, info.EndElementIndex, info.EndCharIndex, endIndex); info = processTextLine(paragraphCursor, info.EndElementIndex, info.EndCharIndex, endIndex);
textAreaHeight -= info.Height + info.Descent; textAreaHeight -= info.Height + info.Descent;
if (textAreaHeight < 0 && counter > 0) { if (textAreaHeight < 0 && page.LineInfos.size() > page.Column0Height) {
break; if (columnCounter == 0) {
++columnCounter;
textAreaHeight = getTextAreaHeight();
textAreaHeight -= info.Height + info.Descent;
page.Column0Height = page.LineInfos.size();
} else {
break;
}
} }
textAreaHeight -= info.VSpaceAfter; textAreaHeight -= info.VSpaceAfter;
result.moveTo(info.EndElementIndex, info.EndCharIndex); result.moveTo(info.EndElementIndex, info.EndCharIndex);
page.LineInfos.add(info); page.LineInfos.add(info);
if (textAreaHeight < 0) { if (textAreaHeight < 0) {
break; if (columnCounter == 0) {
++columnCounter;
textAreaHeight = getTextAreaHeight();
page.Column0Height = page.LineInfos.size();
} else {
break;
}
} }
counter++;
} }
} while (result.isEndOfParagraph() && result.nextParagraph() && !result.getParagraphCursor().isEndOfSection() && (textAreaHeight >= 0)); } while (result.isEndOfParagraph() && result.nextParagraph() && !result.getParagraphCursor().isEndOfSection() && (textAreaHeight >= 0));
resetTextStyle(); resetTextStyle();
@ -918,7 +939,8 @@ public abstract class ZLTextView extends ZLTextViewBase {
int newWidth = info.Width; int newWidth = info.Width;
int newHeight = info.Height; int newHeight = info.Height;
int newDescent = info.Descent; int newDescent = info.Descent;
int maxWidth = getTextAreaWidth() - getTextStyle().getRightIndent(); //int maxWidth = (getTextAreaWidth() - getTextStyle().getRightIndent()) / 2;
int maxWidth = getTextColumnWidth();
boolean wordOccurred = false; boolean wordOccurred = false;
boolean isVisible = false; boolean isVisible = false;
int lastSpaceWidth = 0; int lastSpaceWidth = 0;
@ -1058,7 +1080,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
return info; return info;
} }
private void prepareTextLine(ZLTextPage page, ZLTextLineInfo info, int y) { private void prepareTextLine(ZLTextPage page, ZLTextLineInfo info, int x, int y) {
y = Math.min(y + info.Height, getTopMargin() + getTextAreaHeight() - 1); y = Math.min(y + info.Height, getTopMargin() + getTextAreaHeight() - 1);
final ZLPaintContext context = getContext(); final ZLPaintContext context = getContext();
@ -1070,9 +1092,9 @@ public abstract class ZLTextView extends ZLTextViewBase {
final boolean endOfParagraph = info.isEndOfParagraph(); final boolean endOfParagraph = info.isEndOfParagraph();
boolean wordOccurred = false; boolean wordOccurred = false;
boolean changeStyle = true; boolean changeStyle = true;
x += info.LeftIndent;
int x = getLeftMargin() + info.LeftIndent; final int maxWidth = getTextAreaWidth() / 2;
final int maxWidth = getTextAreaWidth();
switch (getTextStyle().getAlignment()) { switch (getTextStyle().getAlignment()) {
case ZLTextAlignmentType.ALIGN_RIGHT: case ZLTextAlignmentType.ALIGN_RIGHT:
x += maxWidth - getTextStyle().getRightIndent() - info.Width; x += maxWidth - getTextStyle().getRightIndent() - info.Width;

View file

@ -81,6 +81,7 @@ abstract class ZLTextViewBase extends ZLView {
public abstract int getRightMargin(); public abstract int getRightMargin();
public abstract int getTopMargin(); public abstract int getTopMargin();
public abstract int getBottomMargin(); public abstract int getBottomMargin();
public abstract int getIntercolumnSpace();
public abstract ZLFile getWallpaperFile(); public abstract ZLFile getWallpaperFile();
public abstract ZLPaintContext.WallpaperMode getWallpaperMode(); public abstract ZLPaintContext.WallpaperMode getWallpaperMode();
@ -102,6 +103,10 @@ abstract class ZLTextViewBase extends ZLView {
return getContextWidth() - getLeftMargin() - getRightMargin(); return getContextWidth() - getLeftMargin() - getRightMargin();
} }
int getTextColumnWidth() {
return (getContextWidth() - getLeftMargin() - getRightMargin() - getIntercolumnSpace()) / 2;
}
final ZLTextStyle getTextStyle() { final ZLTextStyle getTextStyle() {
return myTextStyle; return myTextStyle;
} }