Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

NSLayoutManagerMBS.addTextContainer(container as NSTextContainerMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.4 Yes No No Yes, macOS only No
Function: Appends the given text container to the series of text containers where the receiver arranges text.
Notes:
container: The text container to append.

Invalidates glyphs and layout as needed, but doesn't perform glyph generation or layout.

Feedback, Comments & Corrections

NSLayoutManagerMBS.characterIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS, byref partialFraction as Double) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the index of the character falling under the given point, expressed in the given container's coordinate system.
Notes:
point: The point to test.
container: The text container within which the point is tested.
partialFraction: A fraction of the distance from the insertion point, logically before the given character to the next one.

Returns the index of the character falling under point.

Analogous to glyphIndexForPoint:inTextContainer, but expressed in character index terms. The method returns the index of the character falling under point, expressed in coordinate system of container; if no character is under the point, the nearest character is returned, where nearest is defined according to the requirements of selection by mouse. However, this is not simply equivalent to taking the result of the corresponding glyph index method and converting it to a character index, because in some cases a single glyph represents more than one selectable character, for example an fi ligature glyph. In that case, there is an insertion point within the glyph, and this method returns one character or the other, depending on whether the specified point lies to the left or the right of that insertion point.

In general, this method returns only character indexes for which there is an insertion point. The partialFraction is a fraction of the distance from the insertion point, logically before the given character to the next one, which may be either to the right or to the left depending on directionality.

Available in OS X v10.6 and later.

Feedback, Comments & Corrections

NSLayoutManagerMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.1 Yes No No Yes, macOS only No
Function: Creates new NSLayoutManager object.

Feedback, Comments & Corrections

NSLayoutManagerMBS.glyphIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: This method is a primitive for glyphIndexForPoint. You should always call the main method, not the primitives.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.glyphIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS, byref partialFraction as Double) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the index of the glyph falling under the given point, expressed in the given container's coordinate system.
Notes:
point: The point for which to return the glyph, in coordinates of container.
container: The container in which the returned glyph is laid out.
partialFraction: On output, the fraction of the distance between the location of the glyph returned and the location of the next glyph.

Returns the index of the glyph falling under the given point, expressed in the given container's coordinate system.

If no glyph is under point, the nearest glyph is returned, where nearest is defined according to the requirements of selection by mouse. Clients who wish to determine whether the the point actually lies within the bounds of the glyph returned should follow this with a call to boundingRectForGlyphRange and test whether the point falls in the rectangle returned by that method. If partialFraction is non-NULL, it returns by reference the fraction of the distance between the location of the glyph returned and the location of the next glyph.

For purposes such as dragging out a selection or placing the insertion point, a partial percentage less than or equal to 0.5 indicates that point should be considered as falling before the glyph index returned; a partial percentage greater than 0.5 indicates that it should be considered as falling after the glyph index returned. If the nearest glyph doesn't lie under point at all (for example, if point is beyond the beginning or end of a line), this ratio is 0 or 1.

If the glyph stream contains the glyphs "A" and "b", with the width of "A" being 13 points, and the user clicks at a location 8 points into "A", partialFraction is 8/13, or 0.615. In this case, the point given should be considered as falling between "A" and "b" for purposes such as dragging out a selection or placing the insertion point.

Performs glyph generation and layout if needed.

As part of its implementation, this method calls fractionOfDistanceThroughGlyphForPoint and glyphIndexForPoint. To change this method's behavior, override those two methods instead of this one.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.glyphRangeForTextContainer(container as NSTextContainerMBS) as NSRangeMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the range of glyphs laid out within the given text container.
Notes:
This is a less efficient method than the similar textContainerForGlyphAtIndex.
Performs glyph generation and layout if needed.

Feedback, Comments & Corrections

NSLayoutManagerMBS.InvisibleCharMapping(character as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Cocoa MBS MacCocoa Plugin 12.5 Yes No No Yes, macOS only No
Function: Sets/gets character mapping for invisible character.
Example:
dim l as new NSLayoutManagerMBS
// ...
// set tab to map to plus sign
l.InvisibleCharMapping(9) = "+"
// set space to map to star sign
l.InvisibleCharMapping(asc(" ")) = "*"
Notes:
By default characters are set for endofline, tab and spaces.
Set showInvisibleCharacters to true and put here all the characters you need.
(Read and Write computed property)

Feedback, Comments & Corrections

NSLayoutManagerMBS.lineFragmentRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the rectangle for the line fragment in which the given glyph is laid out and (optionally), by reference, the whole range of glyphs that are in that fragment.
Notes:
glyphIndex: The glyph for which to return the line fragment rectangle.
effectiveGlyphRange: On output, the range for all glyphs in the line fragment.

Retuns the line fragment in which the given glyph is laid out.

This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, for all of the text up to and including that line fragment.

Line fragment rectangles are always in container coordinates.

Overriding this method is not recommended. If the the line fragment rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect:forGlyphRange.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.lineFragmentRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS, withoutAdditionalLayout as boolean) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the line fragment rectangle containing the glyph at the given glyph index.
Notes:
glyphIndex: The glyph for which to return the line fragment rectangle.
effectiveGlyphRange: On output, the range for all glyphs in the line fragment.
withoutAdditionalLayout: If true, glyph generation and layout are not performed, so this option should not be used unless layout is known to be complete for the range in question, or unless noncontiguous layout is enabled; if false, both are performed as needed.

Returns the line fragment in which the given glyph is laid out.

This method is primarily for use from within NSTypesetter, after layout is complete for the range in question, but before the layout manager's call to NSTypesetter has returned. In that case glyph and layout holes have not yet been recalculated, so the layout manager does not yet know that layout is complete for that range, and this variant must be used.

Overriding this method is not recommended. If the the line fragment rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.lineFragmentUsedRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the usage rectangle for the line fragment in which the given glyph is laid and (optionally) by reference the whole range of glyphs that are in that fragment.
Notes:
glyphIndex: The glyph for which to return the line fragment used rectangle.
effectiveGlyphRange: On output, the range for all glyphs in the line fragment.

Returns the used rectangle for the line fragment in which the given glyph is laid out.

This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

Line fragment used rectangles are always in container coordinates.

Overriding this method is not recommended. If the the line fragment used rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.lineFragmentUsedRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS, withoutAdditionalLayout as boolean) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the usage rectangle for the line fragment in which the given glyph is laid and (optionally) by reference the whole range of glyphs that are in that fragment.
Notes:
glyphIndex: The glyph for which to return the line fragment used rectangle.
effectiveGlyphRange: On output, the range for all glyphs in the line fragment.
withoutAdditionalLayout: If true, glyph generation and layout are not performed, so this option should not be used unless layout is known to be complete for the range in question, or unless noncontiguous layout is enabled; if false, both are performed as needed.

Returns the used rectangle for the line fragment in which the given glyph is laid out.

This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

Line fragment used rectangles are always in container coordinates.

Overriding this method is not recommended. If the the line fragment used rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect.

See also:

Feedback, Comments & Corrections

NSLayoutManagerMBS.locationForGlyphAtIndex(glyphIndex as Integer) as NSPointMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the location for the given glyph within its line fragment.
Notes:
glyphIndex: The glyph whose location is returned.

Returns the location of the given glyph.

If the given glyph does not have an explicit location set for it (for example, if it is part of (but not first in) a sequence of nominally spaced characters), the location is calculated by glyph advancements from the location of the most recent preceding glyph with a location set.

Glyph locations are relative to their line fragment rectangle's origin. The line fragment rectangle in turn is defined in the coordinate system of the text container where it resides.

This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

Feedback, Comments & Corrections

NSLayoutManagerMBS.rangeOfNominallySpacedGlyphsContainingIndex(glyphIndex as Integer) as NSRangeMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns the range for the glyphs around the given glyph that can be displayed using only their advancements from the font, without pairwise kerning or other adjustments to spacing.
Notes:
glyphIndex: Index of the glyph to test.

Returns the range of nominally spaced glyphs.

The range returned begins with the first glyph, counting back from glyphIndex, that has a location set, and it continues up to, but does not include, the next glyph that has a location set.

Performs glyph generation and layout if needed.

Feedback, Comments & Corrections

NSLayoutManagerMBS.rectArrayForCharacterRange(charRange as NSRangeMBS, selCharRange as NSRangeMBS, container as NSTextContainerMBS, byref rectCount as Integer) as NSRectMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given character range.
Notes:
charRange: The character range for which to return rectangles.
selCharRange: Selected characters within charRange, which can affect the size of the rectangles; it must be equal to or contain charRange. If the caller is interested in this more from an enclosing point of view rather than a selection point of view, pass {NSNotFound, 0} as the selected range.
container: The text container in which the text is laid out.
rectCount: The number of rectangles returned.

Returns the array of rectangles enclosing the given range.

These rectangles can be used to draw the text background or highlight for the given range of characters. If a selected range is given in selCharRange, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles and supplying a selected range is the clue this method uses to determine whether to go to the trouble of doing this special work.

The number of rectangles returned isn't necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.

These rectangles don't necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange to determine the area that contains all drawing performed for a range of glyphs.

Performs glyph generation and layout if needed.

Feedback, Comments & Corrections

NSLayoutManagerMBS.rectArrayForGlyphRange(glyphRange as NSRangeMBS, selGlyphRange as NSRangeMBS, container as NSTextContainerMBS, byref rectCount as Integer) as NSRectMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 13.1 Yes No No Yes, macOS only No
Function: Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given glyph range.
Notes:
glyphRange: The glyph range for which to return rectangles.
selGlyphRange: Selected glyphs within glyphRange, which can affect the size of the rectangles; it must be equal to or contain glyphRange. If the caller is interested in this more from an enclosing point of view rather than a selection point of view, pass {NSNotFound, 0} as the selected range.
container: The text container in which the text is laid out.
rectCount: The number of rectangles returned.

Returns the array of rectangles enclosing the given range.

These rectangles can be used to draw the text background or highlight for the given range of characters. If a selected range is given in selGlyphRange, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles and supplying a selected range is the clue this method uses to determine whether to go to the trouble of doing this special work.

The number of rectangles returned isn't necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.

The purpose of this method is to calculate line rectangles for drawing the text background and highlighting. These rectangles don't necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange to determine the area that contains all drawing performed for a range of glyphs.

Performs glyph generation and layout if needed.

Feedback, Comments & Corrections

NSLayoutManagerMBS.removeTextContainerAtIndex(index as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.4 Yes No No Yes, macOS only No
Function: Removes the text container at the given index and invalidates the layout as needed.
Notes:
index: The index of the text container to remove.

This method invalidates glyph information as needed.

Feedback, Comments & Corrections

NSLayoutManagerMBS.replaceGlyphAtIndex(glyphIndex as Integer, newGlyph as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.4 Yes No No Yes, macOS only No
Function: Replaces the glyph at the given index with a new glyph.
Notes:
glyphIndex: Index of the glyph to replace.
newGlyph: The new glyph.

Doesn't alter the glyph-to-character mapping or invalidate layout information. The character index of the glyph is assumed to remain the same (although it can, of course, be set explicitly if needed).

This method is for use by the glyph-generation mechanism and doesn't perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

Feedback, Comments & Corrections

NSLayoutManagerMBS.replaceTextStorage(newTextStorage as NSTextStorageMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.1 Yes No No Yes, macOS only No
Function: Replaces the NSTextStorage object for the group of text-system objects containing the receiver with the given text storage object.
Notes: All NSLayoutManager objects sharing the original NSTextStorage object then share the new one. This method makes all the adjustments necessary to keep these relationships intact, unlike setting textStorage property.

Feedback, Comments & Corrections

NSLayoutManagerMBS.setCharacterIndex(charIndex as Integer, glyphIndex as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 12.4 Yes No No Yes, macOS only No
Function: Sets the index of the character corresponding to the glyph at the given glyph index.
Notes:
charIndex: The index to set.
glyphIndex: The glyph corresponding to the character whose index is set. The glyph must already be present.

This method is for use by the glyph-generation mechanism and doesn't perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

Feedback, Comments & Corrections

NSLayoutManagerMBS.setExtraLineFragmentRect(fragmentRect as NSRectMBS, usedRect as NSRectMBS, TextContainer as NSTextContainerMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 14.2 Yes No No Yes, macOS only No
Function: Sets the bounds and container for the extra line fragment.
Notes:
fragmentRect: The rectangle to set.
usedRect: Indicates where the insertion point is drawn.
TextContainer: The text container where the rectangle is to be laid out.

The extra line fragment is used when the text backing ends with a hard line break or when the text backing is totally empty, to define the extra line which needs to be displayed at the end of the text. If the text backing is not empty and does not end with a hard line break, this should be set to NSRectMBS.Zero and nil.

Line fragment rectangles and line fragment used rectangles are always in container coordinates.

This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

Feedback, Comments & Corrections

NSLayoutManagerMBS.setLineFragmentRect(fragmentRect as NSRectMBS, glyphRange as NSRangeMBS, usedRect as NSRectMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 14.2 Yes No No Yes, macOS only No
Function: Associates the given line fragment bounds with the given range of glyphs.
Notes:
fragmentRect: The rectangle of the line fragment.
glyphRange: The range of glyphs to be associated with fragmentRect.
usedRect: The portion of fragmentRect that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding. Must be equal to or contained within fragmentRect.

The typesetter must specify the text container first with setTextContainer, and it sets the exact positions of the glyphs afterwards with setLocation.

In the course of layout, all glyphs should end up being included in a range passed to this method, but only glyphs that start a new line fragment should be at the start of such ranges.

Line fragment rectangles and line fragment used rectangles are always in container coordinates.

This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

Feedback, Comments & Corrections

NSLayoutManagerMBS.usedRectForTextContainer(container as NSTextContainerMBS) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacCocoa Plugin 17.2 Yes No No Yes, macOS only No
Function: Returns the bounding rectangle for the glyphs laid out in the given text container.
Notes:
Returns the text container's currently used area, which determines the size that the view would need to be in order to display all the glyphs that are currently laid out in the container. This causes neither glyph generation nor layout.
Used rectangles are always in container coordinates.

Feedback, Comments & Corrections

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




Links
MBS Xojo Chart Plugins