C# Class SIL.FieldWorks.SharpViews.Paragraphs.ParaBuilder

This class is responsible for laying out the components of a paragraph. It may do a complete layout, or redo the layout of a previously laid out paragraph that is being adjusted, typically because its contents have changed. Its primary organization is a process of assembling lines by adding stuff to them until they are full or there is nothing more to add. Initially, and after each line has been successfully added, its state may be thought of as follows: 1. We are trying to build a box sequence which will be stored in m_para.FirstBox. A chain of boxes built so far begins at m_firstBox (which may initially be null) and continues to m_lastBox. These boxes are organized into lines, stored in m_lines. They correspond to the text from the RenderRuns before m_renderRunIndex, plus the text from RenderRuns[m_renderRunIndex] == m_currentRenderRun, up to m_ichRendered. 2. There may also be a group of lines at the end of the paragraph which we hope to be able to reuse (though they will currently be relative to another, old, TextSource). These lines are stored in m_oldLines, and we have deduced that they correspond to the text in our current source from m_ichStartReusing onwards. If, after completing a line, we find that m_ichRendered == m_ichStartReusing, then we have resynchronized and can reuse the old lines, after adjusting their source and source offset. 3. Otherwise, we have to build a new line, starting with the material at m_ichRendered. Before doing this, if m_ichStartReusing > m_ichRendered, we must discard one (or more) lines of m_oldLines, since we are already past its position. The process of constructing a line is basically to add boxes and text runs (which become string boxes) to the line until it is full. At that point, it may be determined that the current end of the line is not a valid place to break the line. This typically comes about because the last thing on the line is a text box which terminated at a writing system change rather than at a point where the RenderEngine said we could break. When this happens we must backtrack, replacing the last (string) box with a shortened version ending at a good break, or removing it altogether if it is not the first box on the line. (We must always put something on a line, or we get an infinite loop.)
Datei anzeigen Open project: sillsdev/FieldWorks Class Usage Examples

Private Properties

Property Type Description
AddBoxToLine void
AddBoxToLine void
AddSomethingToLine bool
AdvanceRenderRunIndexToIch int
Backtrack bool
BuildALine void
ComputeHeight int
ComputeWidth int
Fetch string
FinalizeLine bool
FullLayout void
GetLimitOfRunWithSameRenderer int
GetNextTwsh LgTrailingWsHandling
Relayout void
SetParaInfo void
TopOfNextLine int
WsInSource int

Public Methods

Method Description
ParaBuilder ( ParaBox para, LayoutInfo layoutInfo ) : System

Private Methods

Method Description
AddBoxToLine ( Box boxToAdd, LgEndSegmentType est ) : void
AddBoxToLine ( ILgSegment seg, int ichMin, int dichLim, LgEndSegmentType est, int spaceLeftOnCurrentLine ) : void
AddSomethingToLine ( ) : bool

Add something to the line. Return true if we should keep trying to add more. (That is, all of the current thing fit, and there is still room left; this routine is not responsible to determine whether there IS anything else to add.) If there is not yet anything in the line, this routine MUST add something; otherwise, it is allowed to fail, returning false without changing anything.

AdvanceRenderRunIndexToIch ( int ich, int startIndex ) : int
Backtrack ( ) : bool

Shorten the current line. Currently this is only called when the last thing on the line is a string box. If possible, replace its segment with a shorter one. If this is not possible, and it is not the first thing on the line, remove it altogether. If it IS the first thing on the line, do nothing. We'll live with the bad break, because there is nothing better we know how to do. Returns true if successful, which means FinalizeLine should be called again. False if unsuccessful, to prevent infinite loop.

BuildALine ( ) : void
ComputeHeight ( ) : int

Compute the height of the box, not counting surrounding gaps, once its lines have been laid out.

ComputeWidth ( ) : int

Compute the width of the box, not counting surrounding gaps, once its lines have been laid out.

Fetch ( int ichMin, int ichLim ) : string

Get the specified range of (rendered) characters from the text source.

FinalizeLine ( ) : bool

This is called when we have put all we can on the current line. Sometimes we may have put too much! If so, return false, to indicate we can't finalize a line in this state, and trigger backtracking.

FullLayout ( ) : void
GetLimitOfRunWithSameRenderer ( IRenderEngine renderer, int startIndex ) : int
GetNextTwsh ( ) : LgTrailingWsHandling
Relayout ( SourceChangeDetails details, LayoutCallbacks lcb ) : void

Redo layout. Should produce the same segments as FullLayout, but assume that segments for text up to details.StartChange may be reused (if not affected by changing line breaks), and segments after details.StartChange+details.DeleteCount may be re-used if a line break works out (and after adjusting their begin offset).

SetParaInfo ( ) : void
TopOfNextLine ( ParaLine previous, int nextAscent ) : int
WsInSource ( int ich, IVwTextSource source ) : int

Return the writing system of the character at the specified offset in the source.

Method Details

ParaBuilder() public method

public ParaBuilder ( ParaBox para, LayoutInfo layoutInfo ) : System
para ParaBox
layoutInfo LayoutInfo
return System