public PositionedChunk(ITextChunkView <TDocument> chunk, int line, int x, float baseLine) { Chunk = chunk; Line = line; X = x; BaseLine = baseLine; EndOffsetWithoutLineBreaks = chunk.EndOffsetWithoutLineBreaks; }
public void BreakAtOffset(int breakPoint, out ITextChunkView <TDocument> first, out ITextChunkView <TDocument> second) { // is the break within the leading whitespace content? If so, dont break. if (breakPoint <= TrimmedStartOffset) { first = this; second = null; return; } // is the break within the trailing whitespace content? If so, dont break. if (breakPoint >= TrimmedEndOffset) { first = this; second = null; return; } first = SubChunk(OffsetPosition, Node.Document.CreatePosition(breakPoint, Bias.Backward)); second = SubChunk(Node.Document.CreatePosition(breakPoint, Bias.Forward), EndOffsetPosition); }
/// <summary> /// Computes the nearest valid break offset for the given width, and attempts to break this chunk /// into two independent text-chunks. The first chunk will contain the text that should remain on /// the current line, the second chunk contains the content that should be pushed to the next /// line. /// </summary> /// <param name="width">The width position.</param> /// <param name="first">The left hand chunk, never null.</param> /// <param name="second">The right hand chunk or null if the content did not break.</param> public void BreakAt(float width, out ITextChunkView <TDocument> first, out ITextChunkView <TDocument> second) { var breakPoint = FindWordBreakOffset(width); BreakAtOffset(breakPoint, out first, out second); }