Platforms to show: All Mac Windows Linux Cross-Platform

NSTextTableMBS class

Superclass: NSTextBlockMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Cocoa Text MBS MacBase Plugin 22.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
An object that represents a text table as a whole.
Example
// This example needs a window with TextArea1.
// show a table with 2 columns and 2 rows in a text area
Var table As New NSTextTableMBS
table.numberOfColumns = 2
table.collapsesBorders = True

Var cells() As String = Array("Name", "Price", "Apple", "0.50")
Var text As New NSMutableAttributedStringMBS

For i As Integer = 0 To cells.LastIndex
Var cell As New NSTextTableBlockMBS(table, i \ 2, 1, i Mod 2, 1) // row, row span, column, column span
cell.setWidth(1.0, NSTextBlockMBS.ValueTypeAbsolute, NSTextBlockMBS.LayerBorder)
cell.setWidth(4.0, NSTextBlockMBS.ValueTypeAbsolute, NSTextBlockMBS.LayerPadding)
cell.setBorderColor NSColorMBS.grayColor

Var blocks() As NSTextBlockMBS
blocks.Add cell
Var style As New NSMutableParagraphStyleMBS
style.setTextBlocks blocks

Var start As Integer = text.length
text.appendString cells(i) + EndOfLine // each cell is one paragraph
text.addAttribute(NSAttributedStringMBS.NSParagraphStyleAttributeName, style, New NSRangeMBS(start, text.length - start))
Next

TextArea1.NSTextViewMBS.textStorage.setAttributedString text

A text table is responsible for laying out and drawing the text table blocks it contains, and it maintains the basic parameters of the table.
Subclass of the NSTextBlockMBS class.

Text table layout algorithm

Constant Value Description
LayoutAlgorithmAutomatic 0 Specifies automatic layout algorithm
LayoutAlgorithmFixed 1 Specifies fixed layout algorithm

Superclass NSTextBlockMBS

Dimension

Constant Value Description
DimensionHeight 4 Height of the text block.
DimensionMaximumHeight 6 Maximum height of the text block.
DimensionMaximumWidth 2 Maximum width of the text block.
DimensionMinimumHeight 5 Minimum height of the text block.
DimensionMinimumWidth 1 Minimum width of the text block.
DimensionWidth 0 Width of the text block.

Layer

Constant Value Description
LayerBorder 0 The border of the text block.
LayerMargin 1 Margin of the text block: space surrounding the border.
LayerPadding -1 Padding of the text block: space surrounding the content area extending to the border.

Value Types

Constant Value Description
ValueTypeAbsolute 0 Absolute value in points.
ValueTypePercentage 1 Percentage value (out of 100).

Vertical Alignment

Constant Value Description
VerticalAlignmentBaseline 3 Aligns adjacent blocks at the baseline of the first line of text in the block.
VerticalAlignmentBottom 2 Aligns adjacent blocks at their bottom.
VerticalAlignmentMiddle 1 Aligns adjacent blocks at their middle.
VerticalAlignmentTop 0 Aligns adjacent blocks at their top.

This class has no subclasses.

Blog Entries

Release notes

Some methods using this class:

Some properties using this class:

Some related classes:


The items on this page are in the following plugins: MBS MacBase Plugin.


NSTextTableBlockMBS   -   NSTextTabMBS


The biggest plugin in space...