-
Notifications
You must be signed in to change notification settings - Fork 0
Tables
Namespace: ParentElement.RichText.Core.Tables
The tables subsystem provides inline tables that flow with document text. Tables are created through IDocumentController.InsertTable, managed via InlineTable, and their cells' content is written via ICellWriter.
Configuration passed to IDocumentController.InsertTable to define a new table's initial structure and appearance.
public class TableOptions| Property | Type | Default | Description |
|---|---|---|---|
Rows |
int |
0 |
Number of rows |
Columns |
int |
0 |
Number of columns |
BorderStyle |
TableBorderStyle |
Solid |
Style applied to all borders |
BorderWidth |
float |
1 |
Border thickness in pixels |
BorderColor |
SKColor |
#C0C0C0 |
Border color |
HeaderBackgroundColor |
SKColor |
White |
Background color of header row cells |
IncludeHeader |
bool |
false |
Whether row 0 should be treated as a header row |
var table = editor.InsertTable(new TableOptions
{
Rows = 4,
Columns = 3,
BorderStyle = TableBorderStyle.Solid,
BorderWidth = 1f,
BorderColor = SKColors.Gray,
IncludeHeader = true,
HeaderBackgroundColor = new SKColor(0xE0, 0xE0, 0xFF),
});Controls how table borders are rendered.
public enum TableBorderStyle { None, Solid, Dashed, Dotted }| Value | Description |
|---|---|
None |
No borders drawn |
Solid |
Solid lines |
Dashed |
Dashed lines |
Dotted |
Dotted lines |
Represents a live inline table that flows with the document text. Returned by IDocumentController.InsertTable and accessible through the document's internal structure.
public class InlineTable : IInlineObject| Property | Type | Description |
|---|---|---|
Width |
float |
Total rendered width in pixels (read-only) |
Height |
float |
Total rendered height in pixels (computed from row heights) |
Rows |
int |
Number of rows |
Cols |
int |
Number of columns |
ColWidths |
IReadOnlyList<float> |
Per-column content widths in pixels |
RowHeights |
IReadOnlyList<float> |
Per-row heights in pixels (recomputed on demand) |
BorderWidth |
float |
Effective border width |
BorderStyle |
TableBorderStyle |
Border render style |
BorderColor |
SKColor |
Border color |
IsEmpty |
bool |
true when no primary cells remain (e.g. after all rows are deleted) |
HasMultiSelection |
bool |
true when a multi-cell selection is active |
NeedsGhostBorders |
bool |
true when the border width is less than 1px and ghost borders should be painted |
OnHeightChanged |
Action? |
Callback invoked when the table height changes |
| Method | Returns | Description |
|---|---|---|
GetCell(int row, int col) |
TableCell? |
Get the cell at the given position, or null for spanned slots |
| Method | Returns | Description |
|---|---|---|
WriteToCell(int row, int col, Action<ICellWriter>) |
void |
Populate a cell's content via an ICellWriter callback |
| Method | Returns | Description |
|---|---|---|
RecalcRowHeights() |
void |
Recompute all row heights from cell content |
GetRowTop(int row) |
float |
Y offset of a row's top edge relative to the table origin |
GetColumnMinWidth(int col) |
float |
Minimum content width for a column |
GetCellBounds(int row, int col) |
SKRect |
Bounding rectangle of a cell in table-local coordinates |
GetRowSplitIndex(float availableHeight) |
int |
Row index where the table would split given a page height limit |
| Method | Returns | Description |
|---|---|---|
HitTestCell(SKPoint) |
(int row, int col)? |
Row/col of the cell at a table-local point, or null
|
HitTestColumnDivider(SKPoint, float tolerance) |
int |
Index of the column divider nearest the point, or -1
|
IsPointInSelection(SKPoint) |
bool |
Whether the table-local point is within the multi-cell selection |
| Method | Returns | Description |
|---|---|---|
ResizeDivider(int dividerIdx, float newLeftWidth, float newRightWidth) |
void |
Resize adjacent columns by setting their new widths |
| Method | Returns | Description |
|---|---|---|
AddRow() |
void |
Append a new row at the bottom |
InsertRow(int insertAt) |
void |
Insert a row before the given index |
InsertColumn(int insertAt) |
void |
Insert a column before the given index |
DeleteRow(int row) |
void |
Remove a row by index |
DeleteColumn(int col) |
void |
Remove a column by index |
| Method | Returns | Description |
|---|---|---|
SetMultiSelection(int r1, int c1, int r2, int c2) |
void |
Define a multi-cell selection rectangle |
ClearMultiSelection() |
void |
Clear the multi-cell selection |
CanMergeSelection() |
bool |
true if the current selection can be merged |
MergeSelection() |
(int row, int col) |
Merge the current selection; returns the primary cell position |
MergeRange(int minRow, int minCol, int maxRow, int maxCol) |
void |
Merge a specific rectangular range |
| Method | Returns | Description |
|---|---|---|
Paint(SKCanvas, SKPoint origin) |
void |
Render the table at the given origin |
PaintGhostBorders(SKCanvas, SKPoint origin) |
void |
Paint low-opacity guide lines when border width is below 1px |
PaintSplitBorders(SKCanvas, SKPoint origin, float splitLocalY) |
void |
Paint borders up to a page-split Y position |
A single cell in a live InlineTable, exposing its spanning and header state.
public class TableCellpublic TableCell(float cellContentWidth, IStyle defaultStyle, bool isHeader,
Action invalidate, Action contentChanged,
SKColor? backgroundOverride = null)| Parameter | Type | Description |
|---|---|---|
cellContentWidth |
float |
Available content width for this cell |
defaultStyle |
IStyle |
Default character style |
isHeader |
bool |
Whether this cell is a header cell |
invalidate |
Action |
Callback to request a redraw |
contentChanged |
Action |
Callback invoked when content is modified |
backgroundOverride |
SKColor? |
Optional explicit background color |
| Property | Type | Description |
|---|---|---|
IsHeader |
bool |
Whether this is a header cell |
RowSpan |
int |
Number of rows spanned (set internally by the table) |
ColSpan |
int |
Number of columns spanned (set internally by the table) |
BackgroundColor |
SKColor? |
Background color override, or null for default |
The internal document controller scoped to a single table cell. Provides editing operations equivalent to DocumentController but applied to the cell's TextDocument.
public class CellController| Property | Type | Description |
|---|---|---|
Selection |
TextRange |
Current text selection within the cell |
MeasuredHeight |
float |
Measured content height in pixels |
Invalidate |
Action? |
Callback to request a redraw |
ContentChanged |
Action? |
Callback invoked when content changes |
| Method | Description |
|---|---|
Insert(string) |
Insert text at the caret |
Backspace() |
Delete the character before the caret |
Delete() |
Delete the character after the caret |
Navigate(NavigationKind, bool extend) |
Move the caret or extend the selection |
ApplyStyle(IStyle) |
Apply a style to the selection |
ApplyBold(), ApplyItalic(), ApplyUnderline(), etc. |
Toggle character formatting |
ApplyAlignment(TextAlignment) |
Set paragraph alignment |
SetWidth(float) |
Update the cell content width and re-layout |
GetContentReader() |
Return a DocumentReader for this cell's content |
Paint(SKCanvas, float availableHeight, TextPaintOptions?) |
Render cell content |
PaintCaret(SKCanvas) |
Render the caret if this cell has focus |
Click(SKPoint) |
Handle a pointer click in cell-local coordinates |
DragTo(SKPoint) |
Extend the selection to a cell-local point |
See also: ICellWriter · IDocumentController · Content-Model