Inherits from: NSTableView : NSView : NSResponder : NSObject
Package: com.apple.yellow.application
Interface Builder | |
initWithFrame: | Designated initializer. |
- dataSource | Returns the object that provides the data to be displayed (method of NSTableView). |
- numberOfRows: | Returns the number of rows in the NSOutlineView (method of NSTableView). |
collapseItem | Causes an item to be collapsed. |
expandItem | Causes an item to be expanded. |
reloadItemAndChildren | Informs the NSOutlineView that data for an item has changed and needs to be retrieved and redisplayed. |
Note: The NSOutlineView class and its supporting informal protocol NSOutlineDataSource are under development and Interface Builder does not yet include support for working with it. If you want to use an NSOutlineView, you can instantiate it programmatically, or, in Interface Builder, you can drag a table view onto your interface and change its class name to NSOutlineView.
Before reading about NSOutlineView, you should read the documentation for its parent class, NSTableView. An NSOutlineView displays data for a set of related items, with rows representing individual items and columns representing the attributes of those items. As with an NSTableView, each item in an outline view represents a set of values for a particular real-world entity, such as an employee or a bank account. In addition, NSOutlineView provides the ability to expand or collapse rows containing hierarchical data.
An item in an NSOutlineView is expandable if it can contain other items. An expandable item is distinguished visually by an expansion symbol that varies according to the operating system. On the Macintosh, for example, an expandable item contains an outline triangle, which points to the right when the item is collapsed and points down when the item is expanded. Clicking on the outline triangle causes it to change position. It also causes the item to be expanded or collapsed, depending on the new state of the outline triangle. An item can be expanded even if it contains no items.
Items inside an expanded item are indented. By default, as a user expands or collapses nested items, the width of the column is resized so that it is just wide enough to display the widest item, based on the width of the items and their indentation in the hierarchy. Justification follows the current system justification. To turn off automatic resizing, use setAutoResizesOutlineColumn:. Note that an item may consist of text, an image, or anything else that can be drawn by a subclass of NSCell.
An NSOutlineView is typically displayed in an NSScrollView, as shown below.
In this illustration, the NSOutlineView consists of just the rows and columns that display values. The header is drawn by two auxiliary views: a header view that draws the column headers and a corner view that draws the blank square above the vertical scroller. These auxiliary views are described in the documentation for NSTableView.
An outline view inherits much of its behavior from its parent class, NSTableView. As a result, many operations supported by a table view, such as selecting rows or columns, repositioning columns by dragging column headers, and so on, are also supported by an outline view. Your application has control of these features, and can configure the view's parameters to allow or disallow certain operations. For example, you might choose not to allow editing or rearranging for specific columns.
The NSTableView class also provides methods for working with data, responding to mouse clicks, setting grid attributes, editing cells, and performing other operations. For full information on these methods, see the documentation for NSTableView.
For more information on NSOutlineView's data source methods, see "Methods Implemented By the Data Source.".
NSOutlineView adds several delegate messages to those defined by its superclass, NSTableView. In addition, it redefines certain NSTableView delegate methods to be item-based instead of row-based. Together, these methods give the delegate control over the appearance of individual cells in the table, over changes in selection, and over editing of cells.
Delegate methods that request permission to alert the selection or edit a value are invoked during user actions that affect the NSOutlineView, but are not invoked by programmatic changes to the view. When making changes programmatically, you decide whether you want the delegate to intervene and, if so, you send the appropriate message (checking first that the delegate responds to that message). Because the delegate methods involve the actual data displayed by the NSOutlineView, the delegate is typically the same object as the data source, though this is not a requirement.
NSOutlineView redefines these delegate messages based on similar messages in NSTableView:
NSOutlineView defines these additional delegate messages:
In addition to these methods, the delegate is automatically registered to receive messages corresponding to NSOutlineView notifications. These inform the delegate when the selection changes or is about to change, when a column is moved or resized, and when an item is expanded or collapsed:
Delegate Message | Notification |
outlineViewColumnDidMove: | NSOutlineViewColumnDidMoveNotification |
outlineViewColumnDidResize: | NSOutlineViewColumnDidResizeNotification |
outlineViewSelectionDidChange: | NSOutlineViewSelectionDidChangeNotification |
outlineViewSelectionIsChanging: | NSOutlineViewSelectionIsChangingNotification |
outlineViewItemDidExpand: | NSOutlineViewItemDidExpandNotification |
outlineViewItemDidCollapse: | NSOutlineViewItemDidCollapseNotification |
- Creating an instance
- initWithFrame:
- Expanding and collapsing the outline
- isExpandable
- expandItem
- expandItemAndChildren
- collapseItem
- collapseItemAndChildren
- isItemExpanded
- Redisplaying information
- reloadItem
- reloadItemAndChildren
- Converting between items and rows
- itemAtRow
- rowForItem
- Setting the outline column
- setOutlineTableColumn
- outlineTableColumn
- Setting the indentation
- levelForItem
- levelForRow
- setIndentationPerLevel
- indentationPerLevel
- setIndentationMarkerFollowsCell
- indentationMarkerFollowsCell
- Persistence
- autosaveExpandedItems
- setAutosaveName:
- setAutosaveExpandedItems
public NSOutlineView()
public NSOutlineView(NSRect aNSRect)
public boolean autoresizesOutlineColumn()
public boolean autosaveExpandedItems()
The
outline view information is saved separately for each user and for
each application that user uses. Note that if autosaveName returns null
,
this setting is ignored and outline information isn't saved.
See Also: - autosaveName (NSTableView) - autosaveTableColumns (NSTableView), setAutosaveExpandedItems
public void collapseItem(Object item)
See Also: expandItem
public void collapseItemAndChildren(Object item, boolean collapseChildren)
See Also: collapseItem
public void expandItem(Object item)
See Also: collapseItem
public void expandItemAndChildren(Object item, boolean expandChildren)
See Also: collapseItemAndChildren
public boolean indentationMarkerFollowsCell()
See Also: setIndentationMarkerFollowsCell
public float indentationPerLevel()
See Also: setIndentationPerLevel
public boolean isExpandable(Object item)
See Also: expandItem, isItemExpanded
public boolean isItemExpanded(Object item)
See Also: expandItem, isExpandable
public Object itemAtRow(int row)
See Also: rowForItem
public int levelForItem(Object item)
See Also: indentationPerLevel, levelForRow
public int levelForRow(int row)
See Also: indentationPerLevel, levelForItem
public NSTableColumn outlineTableColumn()
See Also: setOutlineTableColumn
public void reloadItem(Object item)
See Also: reloadItemAndChildren
public void reloadItemAndChildren(Object item, boolean reloadChildren)
See Also: reloadItem
public int rowForItem(Object anObject)
See Also: itemAtRow
public void setAutoresizesOutlineColumn(boolean aBoolean)
public void setAutosaveExpandedItems(boolean flag)
The outline information is saved separately for each user and for each application that user uses.
If autosaveName returns null
or
if you haven't implemented the data source methods outlineView:itemForPersistentObject: and outlineView:persistentObjectForItem:,
this setting is ignored and expanded item information isn't saved.
Note that you can have separate settings for autosaveExpandedItems and autosaveTableColumns, so you could, for example, save expanded item information, but not table column positions.
See Also: setAutosaveName:autosaveExpandedItems, - setAutosaveTableColumns: (NSTableView)
public void setIndentationMarkerFollowsCell(boolean drawInCell)
See Also: indentationMarkerFollowsCell
public void setIndentationPerLevel(float newIndentLevel)
See Also: indentationPerLevel
public void setOutlineTableColumn(NSTableColumn outlineTableColumn)
See Also: outlineTableColumn
Methods Implemented By the Data Source.
- (id)outlineView:(NSOutlineView
*)outlineView
child:(int)index
ofItem:(id)item
null
,
this method should return the appropriate child item of the root
object.See Also: outlineView:numberOfChildrenOfItem:
- (BOOL)outlineView:(NSOutlineView
*)outlineView isItemExpandable:(id)item
- (id)outlineView:(NSOutlineView
*)outlineView itemForPersistentObject:(id)object;
See Also:
- (int)outlineView:(NSOutlineView
*)outlineView numberOfChildrenOfItem:(id)item
null
,
this method should return the number of children for the top-level
item.- (id)outlineView:(NSOutlineView
*)outlineView
objectValueForTableColumn:(NSTableColumn
*)tableColumn
byItem:(id)item
- (id)outlineView:(NSOutlineView
*)outlineView persistentObjectForItem:(id)item;
- (void)outlineView:(NSOutlineView
*)outlineView
setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn
byItem:(id)item
Outline views support a data-source delegate in addition to the regular delegate object. The data-source delegate provides data and information about that data to the outline view. The regular delegate object handles all other delegate responsibilities for the outline view.
- (void)outlineViewColumnDidMove:(NSNotification
*)notification
See Also: NSOutlineViewColumnDidMoveNotification (notification)
- (void)outlineViewColumnDidResize:(NSNotification
*)notification
See Also: NSOutlineViewColumnDidResizeNotification (notification)
- (void)outlineViewItemDidCollapse:(NSNotification
*)notification
See Also: NSOutlineViewItemDidCollapseNotification (notification)
- (void)outlineViewItemDidExpand:(NSNotification
*)notification
See Also: NSOutlineViewItemDidExpandNotification (notification)
- (void)outlineViewItemWillCollapse:(NSNotification
*)notification
- (void)outlineViewItemWillExpand:(NSNotification
*)notification
- (void)outlineViewSelectionDidChange:(NSNotification
*)notification
See Also: NSOutlineViewSelectionDidChangeNotification (notification)
- (void)outlineViewSelectionIsChanging:(NSNotification
*)notification
See Also: NSOutlineViewSelectionIsChangingNotification (notification)
- (BOOL)outlineView:(NSOutlineView
*)outlineView
shouldCollapseItem:(id)item
- (BOOL)outlineView:(NSOutlineView
*)outlineView
shouldEditTableColumn:(NSTableColumn *)tableColumn
item:(id)item
- (BOOL)outlineView:(NSOutlineView
*)outlineView
shouldExpandItem:(id)item
- (BOOL)outlineView:(NSOutlineView
*)outlineView
shouldSelectItem:(id)item
- (BOOL)outlineView:(NSOutlineView
*)outlineView
shouldSelectTableColumn:(NSTableColumn
*)tableColumn
- (void)outlineView:(NSOutlineView
*)outlineView
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
item:(id)item
- (BOOL)outlineView:(NSOutlineView
*)outlineView
willDisplayOutlineCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
item:(id)item
- (BOOL)selectionShouldChangeInOutlineView:(NSOutlineView
*)outlineView
Posted whenever a column is moved by user action in the NSOutlineView.
This notification contains a notification object and a userInfo dictionary. The notification object is the NSOutlineView in which a column moved. The userInfo dictionary contains these keys and values:
Key | Value |
NSOldColumn | The column's original index (an NSNumber) |
NSNewColumn | The column's present index (an NSNumber) |
See Also: - moveColumn:toColumn: (NSTableView)
Posted whenever a column is resized in the NSOutlineView.
This notification contains a notification object and a userInfo dictionary. The notification object is the NSOutlineView in which a column was resized. The userInfo dictionary contains these keys and values:
Key | Value |
NSOldWidth | The column's original width (an NSNumber) |
Posted whenever an item is collapsed.
This notification contains a notification object and a userInfo dictionary. The notification object is the NSOutlineView in which an item was collapsed. The userInfo dictionary contains these keys and values:
Key | Value |
NSObject | The item that was collapsed (an id) |
Posted whenever an item is expanded.
This notification contains a notification object and a userInfo dictionary. The notification object is the NSOutlineView in which an item was expanded. The userInfo dictionary contains these keys and values:
Key | Value |
NSObject | The item that was expanded (an id) |
Posted after the NSOutlineView's selection changes.
This notification contains a notification object but no userInfo dictionary. The notification object is the NSOutlineView whose selection changed.
Posted as the NSOutlineView's selection changes (while the mouse is still down).
This notification contains a notification object but no userInfo dictionary. The notification object is the NSOutlineView whose selection is changing.