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.

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

### Contents -

1. Software documentation for the NSOutlineView class
2. Software documentation for the NSObject(NSOutlineViewDataSource) informal protocol
3. Software documentation for the NSObject(NSOutlineViewDelegate) informal 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:
- -indentationMarkerFollowsCell
- -indentationPerLevel
- -isExpandable:
- -isItemExpanded:
- -itemAtRow:
- -levelForItem:
- -levelForRow:
- -outlineTableColumn
- -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).

### indentationMarkerFollowsCell

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

### indentationPerLevel

- (float) 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.

### isItemExpanded:

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

### itemAtRow:

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

### levelForItem:

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

### levelForRow:

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

### outlineTableColumn

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

### 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:

- (int) 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: (int)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: (float)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 float _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 NSObject(NSOutlineViewDataSource) informal protocol

## NSObject(NSOutlineViewDataSource)

> Declared in:
>   AppKit/NSOutlineView.h

Availability: OpenStep
Informal protocol NSOutlineViewDataSource
Method summary

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

### outlineView: acceptDrop: item: childIndex:

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

### outlineView: child: ofItem:

- (id) outlineView: (NSOutlineView*)outlineView child: (int)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: numberOfChildrenOfItem:

- (int) 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: validateDrop: proposedItem: proposedChildIndex:

- (NSDragOperation) outlineView: (NSOutlineView*)outlineView validateDrop: (id)info proposedItem: (id)item proposedChildIndex: (int)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 NSObject(NSOutlineViewDelegate) informal protocol

## NSObject(NSOutlineViewDelegate)

> Declared in:
>   AppKit/NSOutlineView.h

Availability: OpenStep
Description forthcoming.
Method summary

- -outlineView:shouldCollapseItem:
- -outlineView:shouldEditTableColumn:item:
- -outlineView:shouldExpandItem:
- -outlineView:shouldSelectItem:
- -outlineView:shouldSelectTableColumn:
- -outlineView:willDisplayCell:forTableColumn:item:
- -outlineView:willDisplayOutlineCell:forTableColumn:item:
- -outlineViewColumnDidMove:
- -outlineViewColumnDidResize:
- -outlineViewItemDidCollapse:
- -outlineViewItemDidExpand:
- -outlineViewItemWillCollapse:
- -outlineViewItemWillExpand:
- -outlineViewSelectionDidChange:
- -outlineViewSelectionIsChanging:
- -selectionShouldChangeInOutlineView:

### 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: 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