Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Availability | Available in Mac OS X v10.4 and later. |
Companion guides |
NSTextBlock represents a block of text laid out in a subregion of the text container. Text blocks appear as attributes on paragraphs, as part of the paragraph style.
The most important subclass is NSTextTableBlock, which represents a block of text that appears as a cell in a table. The table itself is represented by a separate class, NSTextTable, which is referenced by all of its NSTextTableBlocks and which controls their sizing and positioning.
Returns the background color of the text block.
public NSColor backgroundColor
()
Returns the border color of the text block edge specified by edge.
public NSColor borderColorForEdge
(int edge)
Called by the typesetter after the text block is laid out to return the rectangle the text in the block actually occupies, including padding, borders, and margins.
public NSRect boundsRectForContentRect
(NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange)
The contentRect is the actual rectangle in which the text was laid out, as determined by rectForLayoutAtPoint
. The rect is the initial rectangle in textContainer proposed by the typesetter in which to lay out the glyphs for the characters in charRange.
Returns the width of the text block in points.
public float contentWidth
()
This is a convenience method that invokes valueForDimension:Width
.
Returns the type of value stored for the text block width.
public int contentWidthValueType
()
The value type is either an absolute value in points or a percentage.
Called by the layout manager to draw any colors and other decorations before the text is drawn.
public void drawBackgroundWithFrame
(NSRect frameRect, NSView controlView, NSRange charRange, NSLayoutManager layoutManager)
The frameRect is the bounds rectangle in view coordinates. The controlView is the view in which drawing occurs. The charRange describes the characters whose glyphs are to be drawn, and the layoutManager is the layout manager controlling the typesetting.
Called by the typesetter before the text block is laid out to return the rectangle within which glyphs should be laid out.
public NSRect rectForLayoutAtPoint
(NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange)
The startingPoint argument specifies the location, in container coordinates, where layout begins. The rect is the rectangle in which the block is constrained to lie: for top-level blocks, the container rectangle of textContainer; for nested blocks, the layout rectangle of the enclosing block. The charRange argument is the range of the characters to be laid out.
Sets the background color of the text block.
public void setBackgroundColor
(NSColor color)
Sets the color of one or more borders of the text block.
public void setBorderColor
(NSColor color)
Sets the color of one or more borders of the text block.
public void setBorderColor
(NSColor color, int edge)
If you specify an edge parameter, the color is applied to the specified edge; otherwise, it is applied to all edges. This setting has no visible effect unless the border width is larger than the default, which is 0.
Sets the width of the text block.
public void setContentWidth
(float val, int type)
The value val is either an absolute value in points or a percentage of the enclosing block, as specified by type.
Sets the value type for a dimension of the text block.
public void setValue
(float val, int type, int dimension)
The value val is either an absolute value in points or a percentage of the enclosing block, as specified by type. The dimension argument specifies which dimension’s value to set.
Sets the vertical alignment of the text block to alignment.
public void setVerticalAlignment
(int alignment)
Sets the width of one or more edges of a specified layer of the text block.
public void setWidthForLayer
(float val, int type, int layer)
The width is specified by val, which is interpreted as points or a percentage according to type, and the layer—border, padding, or margin—is specified by layer.
Sets the width of one or more edges of a specified layer of the text block.
public void setWidthForLayer
(float val, int type, int layer, int edge)
The edge is specified by edge. If you do not specify an edge parameter, the width is applied to all edges.
Returns the value of the text block dimension specified by dimension.
public float valueForDimension
(int dimension)
Returns the value type of the text block dimension specified by dimension.
public int valueTypeForDimension
(int dimension)
The value type determines whether the value is interpreted as an absolute value in points or a percentage of the enclosing block.
Returns the vertical alignment of the text block.
public int verticalAlignment
()
Returns the width of a layer for a given edge of the text block in points.
public float widthForLayer
(int layer, int edge)
The text block layer can be its border, padding, or margin.
Returns the value type of a layer for a given edge of the text block.
public int widthValueTypeForLayer
(int layer, int edge)
The text block layer can be its border, padding, or margin.
The following constants specify values used with method parameters used for specifying width types.
Constant | Description |
---|---|
AbsoluteValueType | Absolute value in points |
PercentageValueType | Percentage value (out of 100) |
The following constants specify values used with method parameters used for specifying dimensions.
The following constants specify values used with method parameters used for specifying layer information.
The following constants specify values used with method parameters used for specifying alignment.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)