Classes

NSActionCell
NSAlert
NSApplication
NSArrayController
NSBezierPath
NSBitmapImageRep
NSBox
NSBrowser
NSBrowserCell
NSButton
NSButtonCell
NSCachedImageRep
NSCell
NSClipView
NSCollectionView
NSCollectionViewItem
NSColor
NSColorList
NSColorPanel
NSColorPicker
NSColorWell
NSComboBox
NSComboBoxCell
NSControl
NSController
NSCursor
NSCustomImageRep
NSDataLink
NSDataLinkManager
NSDataLinkPanel
NSDatePicker
NSDatePickerCell
NSDocument
NSDocumentController
NSDrawer
NSDrawerDelegate
NSEPSImageRep
NSEvent
NSFont
NSFontDescriptor
NSFontManager
NSFontPanel
NSForm
NSFormCell
NSGraphicsContext
NSHelpManager
NSHelpPanel
NSImage
NSImageCell
NSImageRep
NSImageView
NSInputServer
NSMatrix
NSMenu
NSMenuItem
NSMenuItemCell
NSMenuView
NSMovie
NSMovieView
NSMutableParagraphStyle
NSNib
NSObjectController
NSOpenGLContext
NSOpenGLPixelFormat
NSOpenGLView
NSOpenPanel
NSOutlineView
NSPageLayout
NSPanel
NSParagraphStyle
NSPasteboard
NSPasteboardItem
NSPopUpButton
NSPopUpButtonCell
NSPredicateEditor
NSPredicateEditorRowTemplate
NSPrintInfo
NSPrintOperation
NSPrintPanel
NSPrinter
NSProgressIndicator
NSResponder
NSRuleEditor
NSRulerMarker
NSSavePanel
NSScreen
NSScrollView
NSScroller
NSSecureTextField
NSSecureTextFieldCell
NSSelection
NSSharingService
NSSharingServicePicker
NSSlider
NSSliderCell
NSSound
NSSpeechSynthesizer
NSSpellChecker
NSSplitView
NSStepper
NSStepperCell
NSTabView
NSTabViewItem
NSTableColumn
NSTableHeaderCell
NSTableHeaderView
NSTableView
NSText
NSTextAttachment
NSTextAttachmentCell
NSTextContainer
NSTextField
NSTextFieldCell
NSTextStorage
NSTextTab
NSTextView
NSTokenField
NSTokenFieldCell
NSUserDefaultsController
NSView
NSWindow
NSWindowController
NSWorkspace

Protocols

<GSImageDelegateProtocol>
<NSAlertDelegate>
<NSApplicationDelegate>
<NSBrowserDelegate>
<NSCollectionViewDataSource>
<NSCollectionViewDelegate>
<NSCollectionViewElement>
<NSCollectionViewPrefetching>
<NSComboBoxCellDataSource>
<NSComboBoxDataSource>
<NSComboBoxDelegate>
<NSControlTextEditingDelegate>
<NSInputServerMouseTracker>
<NSInputServiceProvider>
<NSMatrixDelegate>
<NSMenuDelegate>
<NSMenuItem>
<NSMenuValidation>
<NSMenuView>
<NSOpenSavePanelDelegate>
<NSOutlineViewDataSource>
<NSOutlineViewDelegate>
<NSPasteboardItemDataProvider>
<NSPasteboardReading>
<NSPasteboardWriting>
<NSPrintPanelAccessorizing>
<NSRuleEditorDelegate>
<NSSharingServiceDelegate>
<NSSharingServicePickerDelegate>
<NSSpeechSynthesizerDelegate>
<NSSplitViewDelegate>
<NSTabViewDelegate>
<NSTableViewDataSource>
<NSTableViewDelegate>
<NSTextAttachmentCell>
<NSTextFieldDelegate>
<NSTextViewDelegate>
<NSWindowDelegate>
(NSAlertDelegate)
(NSApplicationDelegate)
(NSBrowserDelegate)
(NSComboBoxCellDataSource)
(NSControlDelegate)
(NSControlTextEditingDelegate)
(NSDataLinkManagerDelegate)
(NSDataPickerCellDelegate)
(NSEditor)
(NSEditorRegistration)
(NSFontManagerDelegate)
(NSFontPanelValidation)
(NSMenuActionResponder)
(NSMenuDelegate)
(NSOpenSavePanelDelegate)
(NSPasteboardItemDataProvider)
(NSPasteboardOwner)
(NSPasteboardReading)
(NSPasteboardWriting)
(NSPlaceholder)
(NSSavePanelDelegate)
(NSServicesRequests)
(NSSoundDelegate)
(NSSpeechSynthesizerDelegate)
(NSSplitViewDelegate)
(NSTableDataSource)
(NSTableViewDelegate)
(NSTextDelegate)
(NSTextStorageDelegate)
(NSTextViewDelegate)
(NSWindowDelegate)
(NSWindowDelegateAdditions)

Constants

Functions

Macros

Types

Variables

Up

NSTextContainer

Authors

Alexander Malmberg (alexander@malmberg.org)
Jonathan Gapen (jagapen@smithlab.chem.wisc.edu)

Date: Generated at 2025-07-12 14:18:56 +0000

Copyright: (C) 1999 Free Software Foundation, Inc.

Software documentation for the NSTextContainer class

NSTextContainer : NSObject

Declared in:
AppKit/NSTextContainer.h
Availability: Gui 10.0.0

Description forthcoming.

Instance Variables

Method summary


containerSize 

- (NSSize) containerSize;
Availability: Gui 10.0.0

Description forthcoming.

containsPoint: 

- (BOOL) containsPoint: (NSPoint)aPoint;
Availability: Gui 10.0.0

Returns YES if aPoint is inside the region. Subclasses define regions by overriding this method.

heightTracksTextView 

- (BOOL) heightTracksTextView;
Availability: Gui 10.0.0

Description forthcoming.

initWithContainerSize: 

- (id) initWithContainerSize: (NSSize)aSize;
Availability: Gui 10.0.0

Initializes a new instance and sets the container size to aSize.

isSimpleRectangularTextContainer 

- (BOOL) isSimpleRectangularTextContainer;
Availability: Gui 10.0.0

Querying the region
Returns YES if the region for this container is a rectangle as large as the container size, otherwise NO. For simple rectangular regions, the text system can apply certain optimizations. NSTextContainer always returns YES. Subclasses that define more complex regions must return NO.

layoutManager 

- (GSLayoutManager*) layoutManager;
Availability: Gui 10.0.0

Returns the layout manager of this text container.

lineFragmentPadding 

- (CGFloat) lineFragmentPadding;
Availability: Gui 10.0.0

Description forthcoming.

lineFragmentRectForProposedRect: sweepDirection: movementDirection: remainingRect: 

- (NSRect) lineFragmentRectForProposedRect: (NSRect)proposedRect sweepDirection: (NSLineSweepDirection)sweepDir movementDirection: (NSLineMovementDirection)moveDir remainingRect: (NSRect*)remainingRect;
Availability: Gui 10.0.0

This is the main method used by the text system for querying the region and flowing text in it. It takes a proposed line fragment rectangle and, if possible, splits it into a valid line fragment rectangle, and a remaining rectangle that can be used in subsequent calls to this method. sweepDir is the direction that text moves inside the lines, and moveDir is the direction lines move in, or NSLineDoesntMove if the line may not move. The line sweep and line movement may not both be in the same dimension, ie. both be vertical, or both be horizontal. The method returns the first (according to the sweep direction) valid line fragment rectangle in the proposed rectangle. This line fragment rectangle is a sub-rectangle of the proposed rectangle in the sweep direction, and has the same size in the other direction. (Ie. if the sweep direction is left, the line fragment rectangle must have the same height as the proposed rectangle.) If there is no valid line fragment rectangle in the proposed rectangle, the proposed rectangle may be moved in the line movement direction until there is one. If no valid line fragment rectangle can be returned, the method returns NSZeroRect. The remaining rectangle should be set to the potentially valid part of the proposed rectangle, after moving in the line movement direction, that remains after the first line fragment rectangle. The proposed rectangle may be any rectangle; in particular, it may extend outside the container size. The remaining rectangle does not have to be or contain a valid line fragment rectangle. Subclasses define regions by overriding this method. Note: The TextContainerExample in the text system example collection (TODO: link) contains an example implementation of an NSTextContainer subclass that defiens a non-trivial region, as well as an interactive demonstration of this method. It can also be used as a simple test of custom subclasses. Note: Although a correct NSTextContainer implementation must handle all line sweep and movement directions, the current standard typesetter will only call this method with sweep right, and no movement or movement down. Relying on this makes writing a subclass easier, but it is not safe.

replaceLayoutManager: 

- (void) replaceLayoutManager: (GSLayoutManager*)aLayoutManager;
Availability: Gui 10.0.0

Managing the text network
A text container may be attached to one layout manager and one text view. The text container is retained by the layout manager, and retains the text view.
Replaces the layout manager of this text container with aLayoutManager. This is done without changing the rest of the text network, so aLayoutManager will be connected to the text storage and text containers that the current layout manager is connected to.

setContainerSize: 

- (void) setContainerSize: (NSSize)aSize;
Availability: Gui 10.0.0

The container size
A text container has a container size. The region defined by the text container must be a subset of the rectangle of this size with it's top-left corner in the origin. Subclasses do not have to support arbitrary sizes, and may choose to ignore -setContainerSize: completely. However, the size returned by -containerSize must be valid.

setHeightTracksTextView: 

- (void) setHeightTracksTextView: (BOOL)flag;
Availability: Gui 10.0.0

Description forthcoming.

setLayoutManager: 

- (void) setLayoutManager: (GSLayoutManager*)aLayoutManager;
Availability: Gui 10.0.0

This method should not be called directly. It is called by the layout manager when the layout manager of a text container changes.

setLineFragmentPadding: 

- (void) setLineFragmentPadding: (CGFloat)aFloat;
Availability: Gui 10.0.0

Line fragment padding
The line fragment padding is an amount of space left empty at each end of a line fragment rectangle by the standard typesetter. The default is 0.0.

setTextView: 

- (void) setTextView: (NSTextView*)aTextView;
Availability: Gui 10.0.0

Sets the NSTextView for this text container. Note that a text view should be attached to a text container only if the text container is attached to a layout manager that can handle text views (eg. NSLayoutManager). The text view is retained by the text container.

setWidthTracksTextView: 

- (void) setWidthTracksTextView: (BOOL)flag;
Availability: Gui 10.0.0

Automatic resizing
A text container can be set to automatically track the width and/or height of its NSTextView (TODO: frame? bounds?). For more information, see the documentation on automatic resizing in NSTextView. (TODO: link) When enabled, the automatic resizing is done by calling [NSTextContainer -setContainerSize:] with the new size whenever the text view is resized.

textView 

- (NSTextView*) textView;
Availability: Gui 10.0.0

Returns the NSTextView attached to this text container, or nil if there is none.

widthTracksTextView 

- (BOOL) widthTracksTextView;
Availability: Gui 10.0.0

Description forthcoming.



Instance Variables for NSTextContainer Class

_containerRect

@protected NSRect _containerRect;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_heightTracksTextView

@protected BOOL _heightTracksTextView;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_layoutManager

@protected id _layoutManager;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_lineFragmentPadding

@protected CGFloat _lineFragmentPadding;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_observingFrameChanges

@protected BOOL _observingFrameChanges;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_textView

@protected id _textView;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_widthTracksTextView

@protected BOOL _widthTracksTextView;
Availability: Gui 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.





Up