ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Palettes/MiscTreeBrowser/MiscTreeBrowser.subproj/MiscTreeBrowserProtocols.h

This is MiscTreeBrowserProtocols.h in view mode; [Download] [Up]

/* MiscTreeBrowserProtocols.h	-- TreeBrowser protocols
 *
 */

// MACROS

#define MTB_LASTCHILD(PARENT)	[(PARENT) childAt:[(PARENT) childCount] - 1]

// CLASSES

@class NXImage;

// PROTOCOLS

@protocol MiscTreeBrowserNodes
/*"

This is the base protocol that a MiscTreeBrowser node must support, to
allow the MiscTreeBrowser to manipulate it.  MiscTreeBrowser and its
associated classes will #only use methods in this protocol when
dealing with nodes.  No other classes should explicitly use this
protocol as it is subject to change.

A node must have a title (name to put in a cell displaying it) a
parent node (possibly nil) and zero or more child nodes, indexed from
0 upwards (and maintaining their ordering, just like a List object).

The methods are grouped as follows: creation, title, child access,
parent access, adding children, removing children.

"*/

/* creation */

- init;
/*"
Initialise and return a node, with a default (possibly NULL) string value
and parent set to nil.
"*/

/* title */

- setStringValue:(const char *)aString;
/*"
Set the string value of the node.  The string value of a node is used as
the title of the MiscTreeBrowserCell holding it.  Returns self.
"*/

- (const char *)stringValue;
/*"
Returns the string value of the node.  The string value of a node is used as
the title of the MiscTreeBrowserCell holding it.
"*/

/* child access */

- (unsigned int)childCount;
/*"
Returns the number of children in the node.
"*/

- (id <MiscTreeBrowserNodes>)childAt:(int)index;
/*"
Returns the child at index in the node, or nil if index is less than zero
or greater than or equal to the number of children.
"*/

/* parent access */

- (id <MiscTreeBrowserNodes>)parent;
/*"
Returns the parent of the node (possibly nil)
"*/

/* adding children */

- (BOOL)canAddChild:(id <MiscTreeBrowserNodes>)aNode
			  after:(id <MiscTreeBrowserNodes>)sibling;
/*"
Returns YES if the node can insert node aNode as a child after sibling.
if sibling is nil, the intention is that aNode should be inserted as the
first child.  If there are any problems (e.g. sibling is not a child of the
node) or it cannot be done for any reason, NO is returned.
"*/

- addChild:(id <MiscTreeBrowserNodes>)aNode
	 after:(id <MiscTreeBrowserNodes>)sibling;
/*"
This will only be called if #{-canAddChild:after:} has returned YES for the
same arguments.
Inserts aNode as a child of the node after sibling (or as the first child
if sibling is nil).  Returns self.
"*/

- (BOOL)canAddChild:(id <MiscTreeBrowserNodes>)aNode;
/*"
Returns YES if the node can insert node aNode as as its last (highest index)
child.  Otherwise , NO is returned.
"*/

- addChild:(id <MiscTreeBrowserNodes>)aNode;
/*"
This will only be called if #{-canAddChild:} has returned YES for the
same argument aNode.
Adds aNode as the last (highest index) child of the node.  Returns self.
"*/

/* removing children */

- (BOOL)canRemoveChild:(id <MiscTreeBrowserNodes>)aNode;
/*"
Returns YES if aNode is a child of the receiver, and it can be removed.
"*/

- removeChild:(id <MiscTreeBrowserNodes>)aNode;
/*"
This will only be called if #{-canAddChild:} has returned YES for the
same argument aNode.
Removes aNode from the children of the receiver.  aNode should not be
immediately freed because it may be added to another node in the
MiscTreeBrowser tree.  Returns aNode.
IMPLEMENTATION NOTE: perhaps we need a removeChild:canFree: method to
help in the implementation of node garbage collection -- comments anyone?  tjb
"*/

@end

@protocol MiscTreeBrowserDragging
/*"

This is the protocol that a MiscTreeBrowser node must support to 
allow the MiscTreeBrowser to pro.  MiscTreeBrowser and its
associated classes will #only use methods in this protocol when
dealing with nodes.  No other classes should explicitly use this
protocol as it is subject to change.

A node must have a dragImage; an NXImage small enough to fit in a
MiscTreeBrowserCell (e.g. no taller than a cell, around 18.0 pixels
depending on the font used) and a drag type, i.e. a Pasteboard
compatible NXAtom defining what is being dragged.

The methods are grouped as follows: 

"*/

- (NXImage *)dragImage;
/*"
Returns the image to be displayed to the right of the node title
in a MiscTreeBrowser cell, and also the image that can be dragged
from the cell.
"*/

- doubleClick:sender;
/*"
Sent to the node if the user double-clicks the dragImage; should
return self.
"*/

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.