Up

# NSOutlineView

### Authors

Gregory John Casamento (`greg_casamento@yahoo.com`)

> This class is a subclass of NSTableView which provides the user with a way to display tree structured data in an outline format. It is particularly useful for show hierarchical data such as a class inheritance tree or any other set of relationships.
> NB. While it its illegal to have the same item in the view more than once, it is possible to have multiple equal items since tests for pointer equality are used rather than calls to the -isEqual: method.

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

### Contents -

1. Software documentation for the NSOutlineView class
2. Software documentation for the NSOutlineViewDataSource protocol
3. Software documentation for the NSOutlineViewDelegate protocol

# Software documentation for the NSOutlineView class

## NSOutlineView : NSTableView

> Declared in:
>   AppKit/NSOutlineView.h

Availability: OpenStep
Description forthcoming.

Instance Variables
Method summary

- -autoResizesOutlineColumn
- -autosaveExpandedItems
- -collapseItem:
- -collapseItem:collapseChildren:
- -expandItem:
- -expandItem:expandChildren:
- -frameOfOutlineCellAtRow:
- -indentationMarkerFollowsCell
- -indentationPerLevel
- -isExpandable:
- -isItemExpanded:
- -itemAtRow:
- -levelForItem:
- -levelForRow:
- -outlineTableColumn
- -parentForItem:
- -reloadItem:
- -reloadItem:reloadChildren:
- -rowForItem:
- -setAutoresizesOutlineColumn:
- -setAutosaveExpandedItems:
- -setDropItem:dropChildIndex:
- -setIndentationMarkerFollowsCell:
- -setIndentationPerLevel:
- -setOutlineTableColumn:
- -shouldCollapseAutoExpandedItemsForDeposited:

### autoResizesOutlineColumn

- (BOOL) autoResizesOutlineColumn;
Availability: OpenStep
Causes the outline column, the column containing the expand/collapse gadget, to resize based on the amount of space needed by widest content.

### autosaveExpandedItems

- (BOOL) autosaveExpandedItems;
Availability: OpenStep
Causes the outline column, the column containing the expand/collapse gadget, to resize based on the amount of space needed by widest content.

### collapseItem:

- (void) collapseItem: (id)item;
Availability: OpenStep
Collapses the given item only. This is the equivalent of calling [NSOutlineView -collapseItem:collapseChildren:] with `NO`.

### collapseItem: collapseChildren:

- (void) collapseItem: (id)item collapseChildren: (BOOL)collapseChildren;
Availability: OpenStep
Collapses the specified item. If collapseChildren is set to `YES`, then all of the expandable children of this item all also collapsed in a recursive fashion (i.e. all children, grandchildren and etc).

### expandItem:

- (void) expandItem: (id)item;
Availability: OpenStep
Expands the given item only. This is the equivalent of calling [NSOutlineView -expandItem:expandChildren:] with `NO`.

### expandItem: expandChildren:

- (void) expandItem: (id)item expandChildren: (BOOL)expandChildren;
Availability: OpenStep
Expands the specified item. If expandChildren is set to `YES`, then all of the expandable children of this item all also expanded in a recursive fashion (i.e. all children, grandchildren and etc).

### frameOfOutlineCellAtRow:

- (NSRect) frameOfOutlineCellAtRow: (NSInteger)row;
Availability: MacOS-X 10.5.0
Description forthcoming.

### indentationMarkerFollowsCell

- (BOOL) indentationMarkerFollowsCell;
Availability: OpenStep
Returns whether or not the indentation marker or "knob" is indented along with the content inside the cell.

### indentationPerLevel

- (CGFloat) indentationPerLevel;
Availability: OpenStep
Returns the amount of indentation, in points, for each level of the tree represented by the outline view.

### isExpandable:

- (BOOL) isExpandable: (id)item;
Availability: OpenStep
Returns `YES`, if the item is able to be expanded, `NO` otherwise. Returns `NO` when the item is `nil` (as Cocoa does).

### isItemExpanded:

- (BOOL) isItemExpanded: (id)item;
Availability: OpenStep
Returns `YES` if the item is expanded or open, `NO` otherwise. Returns `YES` when the item is `nil` (as Cocoa does).

### itemAtRow:

- (id) itemAtRow: (NSInteger)row;
Availability: OpenStep
Returns the item at a given row. If no item exists for the given row, returns `nil`.

### levelForItem:

- (NSInteger) levelForItem: (id)item;
Availability: OpenStep
Returns the level for a given item.

### levelForRow:

- (NSInteger) levelForRow: (NSInteger)row;
Availability: OpenStep
Returns the level for the given row.

### outlineTableColumn

- (NSTableColumn*) outlineTableColumn;
Availability: OpenStep
Returns the outline table column.

### parentForItem:

- (id) parentForItem: (id)item;
Availability: MacOS-X 10.5.0
Returns the parent of the given item or `nil` if the item is not found.

### reloadItem:

- (void) reloadItem: (id)item;
Availability: OpenStep
Causes an item to be reloaded. This is the equivalent of calling [NSOutlineView -reloadItem:reloadChildren:] with reloadChildren set to `NO`.

### reloadItem: reloadChildren:

- (void) reloadItem: (id)item reloadChildren: (BOOL)reloadChildren;
Availability: OpenStep
Causes an item and all of it's children to be reloaded if reloadChildren is set to `YES`, if it's set to `NO`, then only the item itself is refreshed from the datasource.

### rowForItem:

- (NSInteger) rowForItem: (id)item;
Availability: OpenStep
Returns the corresponding row in the outline view for the given item. Returns -1 if item is `nil` or not found.

### setAutoresizesOutlineColumn:

- (void) setAutoresizesOutlineColumn: (BOOL)resize;
Availability: OpenStep
When set to `YES` this causes the outline column, the column containing the expand/collapse gadget, to resize based on the amount of space needed by widest content.

### setAutosaveExpandedItems:

- (void) setAutosaveExpandedItems: (BOOL)flag;
Availability: OpenStep
When set to `YES`, the outline view will save the state of all expanded or collapsed items in the view to the users defaults for the application the outline view is running in.

### setDropItem: dropChildIndex:

- (void) setDropItem: (id)item dropChildIndex: (NSInteger)childIndex;
Availability: OpenStep
Description forthcoming.

### setIndentationMarkerFollowsCell:

- (void) setIndentationMarkerFollowsCell: (BOOL)followsCell;
Availability: OpenStep
If set to `YES`, the indentation marker will follow the content at each level. Otherwise, the indentation marker will remain at the left most position of the view regardless of how many levels in the content is indented.

### setIndentationPerLevel:

- (void) setIndentationPerLevel: (CGFloat)newIndentLevel;
Availability: OpenStep
Sets the amount, in points, that each level is to be indented by.

### setOutlineTableColumn:

- (void) setOutlineTableColumn: (NSTableColumn*)outlineTableColumn;
Availability: OpenStep
Sets the outline table column in which to place the indentation marker.

### shouldCollapseAutoExpandedItemsForDeposited:

- (BOOL) shouldCollapseAutoExpandedItemsForDeposited: (BOOL)deposited;
Availability: OpenStep
Returns `YES`, by default. Subclasses should override this method if a different behaviour is required.

## Instance Variables for NSOutlineView Class

### _autoResizesOutlineColumn

@protected BOOL _autoResizesOutlineColumn;
Availability: OpenStep
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.

### _autosaveExpandedItems

@protected BOOL _autosaveExpandedItems;
Availability: OpenStep
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.

### _expandedItems

@protected NSMutableArray* _expandedItems;
Availability: OpenStep
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.

### _indentationMarkerFollowsCell

@protected BOOL _indentationMarkerFollowsCell;
Availability: OpenStep
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.

### _indentationPerLevel

@protected CGFloat _indentationPerLevel;
Availability: OpenStep
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.

### _itemDict

@protected NSMapTable* _itemDict;
Availability: OpenStep
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.

### _items

@protected NSMutableArray* _items;
Availability: OpenStep
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.

### _levelOfItems

@protected NSMapTable* _levelOfItems;
Availability: OpenStep
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.

### _outlineTableColumn

@protected NSTableColumn* _outlineTableColumn;
Availability: OpenStep
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.

### _selectedItems

@protected NSMutableArray* _selectedItems;
Availability: OpenStep
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.

# Software documentation for the NSOutlineViewDataSource protocol

## NSOutlineViewDataSource

> Declared in:
>   AppKit/NSOutlineView.h

Availability: OpenStep
protocol NSOutlineViewDataSource
Method summary

- -outlineView:acceptDrop:item:childIndex:
- -outlineView:child:ofItem:
- -outlineView:isItemExpandable:
- -outlineView:itemForPersistentObject:
- -outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:
- -outlineView:numberOfChildrenOfItem:
- -outlineView:objectValueForTableColumn:byItem:
- -outlineView:persistentObjectForItem:
- -outlineView:setObjectValue:forTableColumn:byItem:
- -outlineView:sortDescriptorsDidChange:
- -outlineView:validateDrop:proposedItem:proposedChildIndex:
- -outlineView:writeItems:toPasteboard:

### outlineView: acceptDrop: item: childIndex:

- (BOOL) outlineView: (NSOutlineView*)outlineView acceptDrop: (id<NSDraggingInfo>)info item: (id)item childIndex: (NSInteger)index;
Availability: OpenStep
Called to perform drop operation and returns `YES` if successful, and `NO` otherwise.

### outlineView: child: ofItem:

- (id) outlineView: (NSOutlineView*)outlineView child: (NSInteger)index ofItem: (id)item;
Availability: OpenStep
Implementation of this method is required. Returns the child at the specified index for the given item.

### outlineView: isItemExpandable:

- (BOOL) outlineView: (NSOutlineView*)outlineView isItemExpandable: (id)item;
Availability: OpenStep
This is a required method. Returns whether or not the outline view item specified is expandable or not.

### outlineView: itemForPersistentObject:

- (id) outlineView: (NSOutlineView*)outlineView itemForPersistentObject: (id)object;
Availability: OpenStep
Returns the item for the given persistent object.

### outlineView: namesOfPromisedFilesDroppedAtDestination: forDraggedItems:

- (NSArray*) outlineView: (NSOutlineView*)outlineView namesOfPromisedFilesDroppedAtDestination: (NSURL*)dropDestination forDraggedItems: (NSArray*)items;
Availability: MacOS-X 10.4.0
Description forthcoming.

### outlineView: numberOfChildrenOfItem:

- (NSInteger) outlineView: (NSOutlineView*)outlineView numberOfChildrenOfItem: (id)item;
Availability: OpenStep
Description forthcoming.

### outlineView: objectValueForTableColumn: byItem:

- (id) outlineView: (NSOutlineView*)outlineView objectValueForTableColumn: (NSTableColumn*)tableColumn byItem: (id)item;
Availability: OpenStep
This is a required method. Returns the object corresponding to the item representing it in the outline view.

### outlineView: persistentObjectForItem:

- (id) outlineView: (NSOutlineView*)outlineView persistentObjectForItem: (id)item;
Availability: OpenStep
Returns the persistent object for the item specified.

### outlineView: setObjectValue: forTableColumn: byItem:

- (void) outlineView: (NSOutlineView*)outlineView setObjectValue: (id)object forTableColumn: (NSTableColumn*)tableColumn byItem: (id)item;
Availability: OpenStep
Sets the object value of the given item in the given table column to the object provided.

### outlineView: sortDescriptorsDidChange:

- (void) outlineView: (NSOutlineView*)outlineView sortDescriptorsDidChange: (NSArray*)oldSortDescriptors;
Availability: MacOS-X 10.3.0
Description forthcoming.

### outlineView: validateDrop: proposedItem: proposedChildIndex:

- (NSDragOperation) outlineView: (NSOutlineView*)outlineView validateDrop: (id<NSDraggingInfo>)info proposedItem: (id)item proposedChildIndex: (NSInteger)index;
Availability: OpenStep
Used by the Drag and Drop system. Returns the drag operation which should be used when -outlineView:acceptDrop:item:childIndex: is called.

### outlineView: writeItems: toPasteboard:

- (BOOL) outlineView: (NSOutlineView*)outlineView writeItems: (NSArray*)items toPasteboard: (NSPasteboard*)pboard;
Availability: OpenStep
Causes the outline view to write the specified items to the pastboard.

# Software documentation for the NSOutlineViewDelegate protocol

## NSOutlineViewDelegate

> Declared in:
>   AppKit/NSOutlineView.h

Availability: OpenStep
Description forthcoming.
Method summary

- -outlineView:dataCellForTableColumn:item:
- -outlineView:didAddRowView:forRow:
- -outlineView:didClickTableColumn:
- -outlineView:didRemoveRowView:forRow:
- -outlineView:rowViewForItem:
- -outlineView:shouldCollapseItem:
- -outlineView:shouldEditTableColumn:item:
- -outlineView:shouldExpandItem:
- -outlineView:shouldSelectItem:
- -outlineView:shouldSelectTableColumn:
- -outlineView:viewForTableColumn:item:
- -outlineView:willDisplayCell:forTableColumn:item:
- -outlineView:willDisplayOutlineCell:forTableColumn:item:
- -outlineViewColumnDidMove:
- -outlineViewColumnDidResize:
- -outlineViewItemDidCollapse:
- -outlineViewItemDidExpand:
- -outlineViewItemWillCollapse:
- -outlineViewItemWillExpand:
- -outlineViewSelectionDidChange:
- -outlineViewSelectionIsChanging:
- -selectionShouldChangeInOutlineView:

### outlineView: dataCellForTableColumn: item:

- (NSCell*) outlineView: (NSOutlineView*)outlineView dataCellForTableColumn: (NSTableColumn*)aTableColumn item: (id)item;
Availability: MacOS-X 10.5.0
Description forthcoming.

### outlineView: didAddRowView: forRow:

- (void) outlineView: (NSOutlineView*)outlineView didAddRowView: (NSTableRowView*)rowView forRow: (NSInteger)rowIndex;
Availability: MacOS-X 10.7.0
Description forthcoming.

### outlineView: didClickTableColumn:

- (void) outlineView: (NSOutlineView*)outlineView didClickTableColumn: (NSTableColumn*)aTableColumn;
Availability: MacOS-X 10.3.0
Description forthcoming.

### outlineView: didRemoveRowView: forRow:

- (void) outlineView: (NSOutlineView*)outlineView didRemoveRowView: (NSTableRowView*)rowView forRow: (NSInteger)rowIndex;
Availability: MacOS-X 10.7.0
Description forthcoming.

### outlineView: rowViewForItem:

- (NSTableRowView*) outlineView: (NSOutlineView*)outlineView rowViewForItem: (id)item;
Availability: MacOS-X 10.7.0
Description forthcoming.

### outlineView: shouldCollapseItem:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldCollapseItem: (id)item;
Availability: OpenStep
Returns whether or not the specified item should be allowed to collapse.

### outlineView: shouldEditTableColumn: item:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldEditTableColumn: (NSTableColumn*)tableColumn item: (id)item;
Availability: OpenStep
Returns whether or not the given table column should be allowed to be edited.

### outlineView: shouldExpandItem:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldExpandItem: (id)item;
Availability: OpenStep
Returns whether or not the specified item should be expanded.

### outlineView: shouldSelectItem:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldSelectItem: (id)item;
Availability: OpenStep
Returns `YES` or `NO` depending on if the given item is selectable. If `YES`, the item is selected, otherwise the outline view will reject the selection.

### outlineView: shouldSelectTableColumn:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldSelectTableColumn: (NSTableColumn*)tableColumn;
Availability: OpenStep
Returns `YES` or `NO` depending on if the given table column is selectable according to the delegate. If `NO` is returned the outline view will not allow the selection, if `YES` it will allow the selection.

### outlineView: viewForTableColumn: item:

- (NSView*) outlineView: (NSOutlineView*)outlineView viewForTableColumn: (NSTableColumn*)aTableColumn item: (id)item;
Availability: MacOS-X 10.7.0
Description forthcoming.

### outlineView: willDisplayCell: forTableColumn: item:

- (void) outlineView: (NSOutlineView*)outlineView willDisplayCell: (id)cell forTableColumn: (NSTableColumn*)tableColumn item: (id)item;
Availability: OpenStep
Called when the given cell is about to be displayed. This method is useful for making last second modifications to what will be shown.

### outlineView: willDisplayOutlineCell: forTableColumn: item:

- (void) outlineView: (NSOutlineView*)outlineView willDisplayOutlineCell: (id)cell forTableColumn: (NSTableColumn*)tableColumn item: (id)item;
Availability: OpenStep
Called when the given cell in the outline column is about to be displayed. This method is useful for making last second modifications to what will be shown.

### outlineViewColumnDidMove:

- (void) outlineViewColumnDidMove: (NSNotification*)aNotification;
Availability: OpenStep
Called after the column has moved.

### outlineViewColumnDidResize:

- (void) outlineViewColumnDidResize: (NSNotification*)aNotification;
Availability: OpenStep
Called after the view column is resized.

### outlineViewItemDidCollapse:

- (void) outlineViewItemDidCollapse: (NSNotification*)aNotification;
Availability: OpenStep
Called after the item has collapsed.

### outlineViewItemDidExpand:

- (void) outlineViewItemDidExpand: (NSNotification*)aNotification;
Availability: OpenStep
Called after the item has expanded

### outlineViewItemWillCollapse:

- (void) outlineViewItemWillCollapse: (NSNotification*)aNotification;
Availability: OpenStep
Called before the item has collapsed.

### outlineViewItemWillExpand:

- (void) outlineViewItemWillExpand: (NSNotification*)aNotification;
Availability: OpenStep
Called before the item is expanded.

### outlineViewSelectionDidChange:

- (void) outlineViewSelectionDidChange: (NSNotification*)aNotification;
Availability: OpenStep
Called when the selection has changed.

### outlineViewSelectionIsChanging:

- (void) outlineViewSelectionIsChanging: (NSNotification*)aNotification;
Availability: OpenStep
Called when the selection is about to change.

### selectionShouldChangeInOutlineView:

- (BOOL) selectionShouldChangeInOutlineView: (NSOutlineView*)outlineView;
Availability: OpenStep
Called before the selection is modified. This method should return `YES` if the selection is allowed and `NO`, if not.

Up