MOViewListViewItem


Abstract

MOViewListViewItem instances represent the indivdual views inside a MOViewListView.

Discussion

MOViewListViewItem used to keep track of the individual views in a MOViewListView. MOViewListView uses them like NSTabView uses NSTabViewItems. MOViewListViewItem keeps track of the actual view, the label to use for it within the MOViewListView, and some computed state for the item.

In addition, MOViewListViewItem provides storage for several things that the client can use for any purpose. Each item has an identifier, a representedObject and a userInfo. Each of these can be any kind of object although NSStrings are traditional for identifiers and NSDictionaries are traditional for userInfo. representedObject would be ideal for storing a reference to the controller object responsible for the view owned by the item (if any).

One use for MOViewListViewItem is to preserve laziness of UI loading. By default, MOViewListViewItems are collapsed. Until an item is actually added to a MOViewListView and then expanded, there's no need for the view to be loaded and initialized. In this case, you can create a MOViewListViewItem with no view set it in and add it to the MOViewListView so that its label will appear appropriately. Then, the delegate of the MOViewListView can trigger the loading of the view when needed by implementing the -viewListView:willExpandViewListViewItem: method and making it load the view and use -setView: to set it into the item, if it has not been loaded yet.



Methods

initWithView:andLabel:
Initializes an instance.
viewListView
Returns the owning MOViewListView.
setViewListView:
Sets the owning MOViewListView.
view
Returns the item's view.
setView:
Sets the item's view.
label
Returns the item's label.
setLabel:
Sets the item's label.
identifier
Returns the item's identifier.
setIdentifier:
Sets the item's identifier.
representedObject
Returns the item's representedObject.
setRepresentedObject:
Sets the item's representedObject.
userInfo
Returns the item's userInfo.
setUserInfo:
Sets the item's userInfo.
isCollapsed
Returns whether the item is collapsed.
labelYPosition
Returns the y position of the top of the item's label rect within the MOViewListView.

identifier

Returns the item's identifier.
- ( id ) identifier;

This method returns the item's identifier (if any). MOViewListView does not ever look at or use this object. You can set any object as the identifier and use it however you like. Traditionally identifiers are NSStrings, but they need not be. The identifier is retained by the MOViewListViewItem.

method result
The item's identifier.

initWithView:andLabel:

Initializes an instance.
- ( id ) initWithView:
        (NSView *) view andLabel:
        (NSString *) label;

Designated Initializer. Initializes the receiver with the given view and label.

Parameter Descriptions
view
The view for this item. This can be nil, and will be in cases where lazy nib loading is desired.
label
The label to use in the MOViewListView for this item.
method result
The initialized instance.

isCollapsed

Returns whether the item is collapsed.
- ( BOOL ) isCollapsed;

This method returns whether the item is collapsed. This state is managed by the MOViewListView and cannot be modified directly.

method result
Whether the item is collapsed.

label

Returns the item's label.
- ( NSString *) label;

This method returns the item's label (if any).

method result
The item's label.

labelYPosition

Returns the y position of the top of the item's label rect within the MOViewListView.
- ( float ) labelYPosition;

This method returns the y position of the top of the item's label rect within the MOViewListView. This position is managed by the MOViewListView and cannot be modified directly.

method result
The y position of the top of the item's label rect within the MOViewListView.

representedObject

Returns the item's representedObject.
- ( id ) representedObject;

This method returns the item's representedObject (if any). MOViewListView does not ever look at or use this object. You can set any object as the representedObject and use it however you like. One good use for this is to keep a pointer to the controller object responsible for the item's view. The representedObject is retained by the MOViewListViewItem.

method result
The item's representedObject.

setIdentifier:

Sets the item's identifier.
- ( void ) setIdentifier:
        (id ) identifier;

This method sets the item's identifier. MOViewListView does not ever look at or use this object. You can set any object as the identifier and use it however you like. Traditionally identifiers are NSStrings, but they need not be. The identifier is retained by the MOViewListViewItem.

Parameter Descriptions
identifier
The identifier.

setLabel:

Sets the item's label.
- ( void ) setLabel:
        (NSString *) label;

Sets the item's label. If the item has a viewLisView, this method invalidates display for the item's label rect.

Parameter Descriptions
label
The label.

setRepresentedObject:

Sets the item's representedObject.
- ( void ) setRepresentedObject:
        (id ) obj;

This method sets the item's representedObject. MOViewListView does not ever look at or use this object. You can set any object as the representedObject and use it however you like. One good use for this is to keep a pointer to the controller object responsible for the item's view. The representedObject is retained by the MOViewListViewItem.

Parameter Descriptions
obj
The representedObject.

setUserInfo:

Sets the item's userInfo.
- ( void ) setUserInfo:
        (id ) userInfo;

This method sets the item's userInfo (if any). MOViewListView does not ever look at or use this object. You can set any object as the userInfo and use it however you like. Traditionally userInfos are NSDictionaries, but they need not be. The userInfo is retained by the MOViewListViewItem.

Parameter Descriptions
The
userInfo.

setView:

Sets the item's view.
- ( void ) setView:
        (NSView *) view;

Sets the item's view. This method can be called from the MOViewListView's delegate's -viewListView:willExpandViewListViewItem: method to implement lazy view loading. If the item has a viewListView then this method will stop the MOViewListView from observing the old view's frame and will start the MOViewListView observing the new view's frame.

Parameter Descriptions
view
The view.

setViewListView:

Sets the owning MOViewListView.
- ( void ) setViewListView:
        (MOViewListView *) viewListView;

Sets the owning MOViewListView. This method is automatically called by MOViewListView and should not be called directly, but it can be overridden by subclasses. Overriders should be sure to call super. If the item has a view then this method will stop the old MOViewListView from observing its frame and will start the new MOViewListView observing its frame.

Parameter Descriptions
viewListView
owning MOViewListView.

userInfo

Returns the item's userInfo.
- ( id ) userInfo;

This method returns the item's userInfo (if any). MOViewListView does not ever look at or use this object. You can set any object as the userInfo and use it however you like. Traditionally userInfos are NSDictionaries, but they need not be. The userInfo is retained by the MOViewListViewItem.

method result
The item's userInfo.

view

Returns the item's view.
- ( NSView *) view;

This method returns the item's view (if any).

method result
The item's view.

viewListView

Returns the owning MOViewListView.
- ( MOViewListView *) viewListView;

This method returns the MOViewListView that owns the receiver (or nil, if the item is not currently being managed by any MOViewListView).

method result
The owning MOViewListView.

(Last Updated 3/20/2005)