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

> Standards:
> - MacOS-X
> - OpenStep
> - GNUstep

Description forthcoming.

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;

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;

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;

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;

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;

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;

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;

Returns whether or not the indentation marker or "knob" is indented along with the content inside the cell.

### indentationPerLevel

- (float) indentationPerLevel;

Returns the amount of indentation, in points, for each level of the tree represented by the outline view.

### isExpandable:

- (BOOL) isExpandable: (id)item;

Returns `YES`, if the item is able to be expanded, `NO` otherwise.

### isItemExpanded:

- (BOOL) isItemExpanded: (id)item;

Returns `YES` if the item is expanded or open, `NO` otherwise.

### itemAtRow:

- (id) itemAtRow: (int)row;

Returns the item at a given row.

### levelForItem:

- (int) levelForItem: (id)item;

Returns the level for a given item.

### levelForRow:

- (int) levelForRow: (int)row;

Returns the level for the given row.

### outlineTableColumn

- (NSTableColumn*) outlineTableColumn;

Returns the outline table column.

### reloadItem:

- (void) reloadItem: (id)item;

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;

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;

Returns the corresponding row in the outline view for the given item.

### setAutoresizesOutlineColumn:

- (void) setAutoresizesOutlineColumn: (BOOL)resize;

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;

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;

Description forthcoming.

### setIndentationMarkerFollowsCell:

- (void) setIndentationMarkerFollowsCell: (BOOL)followsCell;

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;

Sets the amount, in points, that each level is to be indented by.

### setOutlineTableColumn:

- (void) setOutlineTableColumn: (NSTableColumn*)outlineTableColumn;

Sets the outline table column in which to place the indentation marker.

### shouldCollapseAutoExpandedItemsForDeposited:

- (BOOL) shouldCollapseAutoExpandedItemsForDeposited: (BOOL)deposited;

Returns `YES`, by default. Subclasses should override this method if a different behaviour is required.

# Software documentation for the NSObject(NSOutlineViewDataSource) informal protocol

## NSObject(NSOutlineViewDataSource)

> Declared in:
>   AppKit/NSOutlineView.h

> Standards:
> - MacOS-X
> - OpenStep
> - GNUstep

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<NSDraggingInfo>)info item: (id)item childIndex: (int)index;

Returns whether or not the outline view should accept a drop into the indicated item.

### outlineView:child:ofItem:

- (id) outlineView: (NSOutlineView*)outlineView child: (int)index ofItem: (id)item;

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;

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;

Returns the item for the given persistent object.

### outlineView:numberOfChildrenOfItem:

- (int) outlineView: (NSOutlineView*)outlineView numberOfChildrenOfItem: (id)item;

Description forthcoming.

### outlineView:objectValueForTableColumn:byItem:

- (id) outlineView: (NSOutlineView*)outlineView objectValueForTableColumn: (NSTableColumn*)tableColumn byItem: (id)item;

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;

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;

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<NSDraggingInfo>)info proposedItem: (id)item proposedChildIndex: (int)index;

Used by the Drag and Drop system. Returns the drap operations which was performed on the given outline view.

### outlineView:writeItems:toPasteboard:

- (BOOL) outlineView: (NSOutlineView*)outlineView writeItems: (NSArray*)items toPasteboard: (NSPasteboard*)pboard;

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

> Standards:
> - MacOS-X
> - OpenStep
> - GNUstep

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;

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;

Returns whether or not the given table column should be allowed to be edited.

### outlineView:shouldExpandItem:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldExpandItem: (id)item;

Returns whether or not the specified item should be expanded.

### outlineView:shouldSelectItem:

- (BOOL) outlineView: (NSOutlineView*)outlineView shouldSelectItem: (id)item;

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;

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;

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;

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;

Called after the column has moved.

### outlineViewColumnDidResize:

- (void) outlineViewColumnDidResize: (NSNotification*)aNotification;

Called after the view column is resized.

### outlineViewItemDidCollapse:

- (void) outlineViewItemDidCollapse: (NSNotification*)aNotification;

Called after the item has collapsed.

### outlineViewItemDidExpand:

- (void) outlineViewItemDidExpand: (NSNotification*)aNotification;

Called after the item has expanded

### outlineViewItemWillCollapse:

- (void) outlineViewItemWillCollapse: (NSNotification*)aNotification;

Called before the item has collapsed.

### outlineViewItemWillExpand:

- (void) outlineViewItemWillExpand: (NSNotification*)aNotification;

Called before the item is expanded.

### outlineViewSelectionDidChange:

- (void) outlineViewSelectionDidChange: (NSNotification*)aNotification;

Called when the selection has changed.

### outlineViewSelectionIsChanging:

- (void) outlineViewSelectionIsChanging: (NSNotification*)aNotification;

Called when the selection is about to change.

### selectionShouldChangeInOutlineView:

- (BOOL) selectionShouldChangeInOutlineView: (NSOutlineView*)outlineView;

Called before the selection is modified. This method should return `YES` if the selection is allowed and `NO`, if not.

Up