MOViewListViewItem instances represent the indivdual views inside a MOViewListView.
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.
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.
initWithView:andLabel: |
- ( id ) initWithView: (NSView *) view andLabel: (NSString *) label;
Designated Initializer. Initializes the receiver with the given view and label.
- 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.
isCollapsed |
- ( BOOL ) isCollapsed;
This method returns whether the item is collapsed. This state is managed by the MOViewListView and cannot be modified directly.
label |
- ( NSString *) label;
This method returns the item's label (if any).
labelYPosition |
- ( 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.
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.
setIdentifier: |
- ( 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.
- identifier
- The identifier.
setLabel: |
- ( 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.
- label
- The label.
setRepresentedObject: |
- ( 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.
- obj
- The representedObject.
setUserInfo: |
- ( 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.
- The
- userInfo.
setView: |
- ( 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.
- view
- The view.
setViewListView: |
- ( 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.
- viewListView
- owning MOViewListView.
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.
view |
- ( NSView *) view;
This method returns the item's view (if any).
viewListView |
- ( MOViewListView *) viewListView;
This method returns the MOViewListView that owns the receiver (or nil, if the item is not currently being managed by any MOViewListView).
(Last Updated 3/20/2005)