SpanLayoutBox
Represents a measured fragment of a document span, with text positions used by paragraph layout and navigation.
Definition
Namespace:Telerik.WinForms.Documents.Layout
Assembly:Telerik.WinControls.RichTextEditor.dll
Syntax:
public class SpanLayoutBox : InlineLayoutBox, IDisposable, ICustomTypeDescriptor, INotifyPropertyChanged
Inheritance: objectDisposableObjectRadObjectLayoutElementLayoutBoxInlineLayoutBoxSpanLayoutBox...
Derived Classes:
Implements:
Inherited Members
Constructors
Initializes a span layout box and specifies whether it is a fragment of the document element.
public SpanLayoutBox(DocumentElement parentElement, DocumentStructureCollection collection, bool isFragment)
The span document element represented by the box.
collectionDocumentStructureCollectionThe document structure collection that owns the box.
isFragmentbooltrue when the box is a fragment of the span.
Initializes a non-fragment span layout box with the specified text.
public SpanLayoutBox(DocumentElement parentElement, DocumentStructureCollection collection, string text)
The span document element represented by the box.
collectionDocumentStructureCollectionThe document structure collection that owns the box.
textstringThe text stored in the box.
Initializes a non-fragment span layout box.
public SpanLayoutBox(DocumentElement parentElement, DocumentStructureCollection collection)
The span document element represented by the box.
collectionDocumentStructureCollectionThe document structure collection that owns the box.
Properties
Gets or sets the document span represented by this box.
public Span AssociatedSpan { get; set; }
Gets the measured text baseline offset, or zero before text measurement is available.
public override float BaselineOffset { get; }
Overrides:
Gets whether this box creates child layout boxes directly from its content. Span boxes do not create such children.
protected override bool CanCreateLayoutBoxesFromContent { get; }
Overrides:
Gets the size returned by measuring this fragment's text.
public SizeF DesiredTextSize { get; }
Gets whether the text width participates in line-end width calculations.
public override bool HasWidthAtTheEndOfLine { get; }
Overrides:
Gets whether this span box is a leaf rather than a container in the layout tree.
public override bool IsContainerBox { get; }
Overrides:
Gets or sets whether paragraph layout classified this span fragment as part of a decimal number. This flag affects right-to-left positioning and whether adjacent fragments can be merged.
public bool IsDecimal { get; set; }
Gets whether this box represents a paragraph-ending Enter symbol.
public bool IsParagraphSymbol { get; }
Gets whether the span text can be edited; ordinary text fragments are not read-only.
public override bool IsReadonly { get; }
Overrides:
Gets whether this box contains more than one character and can therefore be split.
public override bool IsSplittable { get; }
Overrides:
Gets the number of text positions in this fragment, equal to Text.Length.
public override int PositionsCountInBox { get; }
Overrides:
Methods
Creates a layout fragment for the same document span.
public override LayoutElement CreateLayoutElement()
A new span layout box marked as a fragment.
Overrides:
Splits this span after the longest prefix that fits the available width, keeping that prefix in this box and returning a new box for the remaining text. If this is the first box in a line and no character fits, one character is kept in this box so layout can continue.
public override LayoutBox CreateNewFragment(float availableWidth, bool isFirstBoxInLine)
The maximum width for the prefix retained in this box; the returned suffix is not constrained to this width.
isFirstBoxInLinebooltrue when this is the first box in the line.
Returns:A new box containing the remaining suffix, or null when no split is produced.
Overrides:
Creates a span box, using a formatting-symbol box when text encodes a supported symbol.
public static SpanLayoutBox CreateSpanLayoutBox(DocumentElement parentElement, DocumentStructureCollection collection, string text)
The document element represented by the new box.
collectionDocumentStructureCollectionThe document structure collection that owns the new box.
textstringThe text or formatting-symbol representation to store.
Returns:A span layout box or a formatting-symbol layout box.
Creates a position handler that maps document positions to character positions in this span.
public override PositionHandler GetPositionHandler()
A span-box position handler.
Overrides:
Marks the cached text measurement invalid so it is recalculated on the next measurement request.
public void InvalidateTextMeasure()
Measures the associated span text using its document formatting.
protected virtual BoxMeasurementInfo MeasureTextOverride(SubStringPosition subStringPosition = SubStringPosition.None)
The substring position context passed to the text measurer.
Returns:The measurement result for the span text.
Appends the next span box's text to this box.
public override void MergeWithNext(LayoutBox nextSpanBox)
The adjacent span box whose text is appended.
Overrides:
Invalidates cached text measurement when the associated document element changes.
protected override void OnAssociateDocumentElementChanged()
Overrides:
Raises PropertyChanged for the specified property. The Text setter invokes this method when the text changes.
protected virtual void OnPropertyChanged(string propName)
The name of the changed property.
Splits this text box at a character index and inserts the new fragment before or after it.
public void SplitSpanByIndex(int splitIndex, bool isBefore)
The index between the two resulting text fragments; it must be greater than zero and less than the text length.
isBeforebooltrue to insert the prefix before this box; otherwise, insert the suffix after it.
Exceptions: ArgumentOutOfRangeExceptionsplitIndex is not strictly inside the text.
Returns the text surrounded by quotation marks.
Rebuilds this span's layout boxes from the specified text, then invalidates its layout and word-fragmentation state.
public void Update(string text)
The replacement text used to create the span's layout boxes.
Events
Occurs when this box raises a property-change notification. The Text setter raises it when the text changes.
public event PropertyChangedEventHandler PropertyChanged
Implements: