Release 2.5, Copyright ã1997 by Sean Luke.  All Rights Reserved.

ModuleMenuNode

Subclass Of:	Object

Declared In:	ModuleMenuNode.h

Class Description

This object stores menu information to be passed to Resound from modules.  Future versions will eliminate this node (I hope), when IB is able to generate menus without an application (or I learn to).

The Module Menu Node is a tree node.  The root (top) node of the tree should be set with a blank name.  This node contains all the menu items to be added directly to Resound's Modules menu.  Children nodes have names, and the menu items they contain are for custom submenus off of the Modules Menu.

Let's say you want to make two menu options in the Modules menu.  One is just a standard menu option, called "Tweak".  The other displays a submenu, called "Twist", with submenu items "Bend", "Break", and "Bust".  You'd generate a tree like this:

(Root Node)
	Name	"" 	(empty string)
	Receiver	NULL	(indicates this node has submenus)
	Message	(not set)
	Length	2	(for Tweak and Twist)
	Submenu[0]	points to the node Tweak
	Submenu[1]	points to the node Twist
	
Tweak
	Name	"Tweak"
	Receiver	object that will receive the Tweak message
	Message	selector of message sent to Tweak's receiver
	Length	0
	Submenu...	(not set)
	
Twist
	Name	"Twist"
	Receiver	NULL	(indicates this node has submenus)
	Message	(not set)
	Length	3	(for Bend, Break, and Bust)
	Submenu[0]	points to the node Bend
	Submenu[1]	points to the node Break
	Submenu[2]	points to the node Bust	

Bend
	Name	"Bend"
	Receiver	object that will receive the Bend message
	Message	selector of message sent to Bend's receiver
	Length	0
	Submenu...	(not set)
	
Break
	Name	"Break"
	Receiver	object that will receive the Break message
	Message	selector of message sent to Break's receiver
	Length	0
	Submenu...	(not set)
	
Bust
	Name	"Bust"
	Receiver	object that will receive the Bust message
	Message	selector of message sent to Bust's receiver
	Length	0
	Submenu...	(not set)
	
 To do this, you might  write write the init method of your module to look like:
 
 -	init
	{
	id returnVal=[super init];   
	  // ABSOLUTELY CALL [super init] FIRST!!!

	ModuleMenuNode* tweak= [[ModuleMenuNode alloc] init];
	ModuleMenuNode* twist= [[ModuleMenuNode alloc] init];
	ModuleMenuNode* bend= [[ModuleMenuNode alloc] init];
	ModuleMenuNode* break= [[ModuleMenuNode alloc] init];
	ModuleMenuNode* bust= [[ModuleMenuNode alloc] init];
	
	[TheModuleMenuNode setReceiver:NULL];
	[TheModuleMenuNode setLength:2];
	[TheModuleMenuNode setSubmenu: 0 : tweak];
	[TheModuleMenuNode setSubmenu: 1 : twist];
	
	[tweak setName: "Tweak"];
	[tweak setReceiver: self];
	[tweak setMessage:@selector(tweakMe:)];
	[tweak setLength:0];
	
	[twist setReceiver:NULL];
	[twist setLength:3];
	[twist setSubmenu: 0 : bend];
	[twist setSubmenu: 1 : break];
	[twist setSubmenu: 2 : bust];
	
	[bend setName: "Bend"];
	[bend setReceiver: self];
	[bend setMessage:@selector(bendMe:)];
	[bend setLength:0];
	
	[break setName: "Break"];
	[break setReceiver: self];
	[break setMessage:@selector(breakMe:)];
	[break setLength:0];
	
	[bust setName: "Bust"];
	[bust setReceiver: self];
	[bust setMessage:@selector(bustMe:)];
	[bust setLength:0];
	
	return returnVal;
	}

As a result, Resound would create menus in its Modules menu as such:

¬

Resound attaches the appropriate receiver to as the target of Tweak, Bend, Break, and Bust, and sets them to call the appropriate message.  In the example above, the receivers of all menus have been set to your own module, and the modules will call, respectively, tweakMe:, bendMe:, breakMe:, or bustMe:.

You don't need to free the nodesÐthat's taken care of for you by Module's free method. 

Instance Variables
char[256] 	Name;
id	Receiver;
id	Message;
int	Length;
id[256]	submenu;

Name 	The name to put in the menu.

Receiver 	The target of the method sent when the menu is selected.
	If Reciever is NULL, then the menu has submenus.

Message 	The selector for the method sent when the menu is selected.

Length 	The number of items in the submenu.  If Receiver is NULL,
	then Length should not be 0.

Submenu 	The array of submenu ModuleMenuNodes.

Method Types

Object Maintenance	± init
	± free
	
Data Retrieval	± getName
	± getReceiver
	± getMessage
	± getLength
	± getSubmenu:
	
Setting Data	± setName:
	± setReceiver:
	± setMessage:
	± setLength:
	± setSubmenu::

Instance Methods

free
- free

Frees the ModuleMenuNode.  You should not need to call this method; it is called by Module's free method for you. 

getLength
-  (int) getLength

Returns the length of the ModuleMenuNode's submenu array. 

getMessage
-  (SEL) getMessage

Returns the ModuleMenuNode's receiving message. 

getName
- (char*) getName

Returns the ModuleMenuNode's name. 

getReceiver
-  getReceiver

Returns the ModuleMenuNode's receiver (target). 

getSubmenu:
-  getSubmenu:(int)this_index

Returns the subsidiary ModuleMenuNode that is at this_index position of the parent ModuleMenuNode's submenu array . 

init
- init

Initializes the ModuleMenuNode.

setLength:
-  setLength:(int)this_length

Sets the length of the ModuleMenuNode's submenu array to this_length. 

setMessage:
-  setMessage:(SEL)this_message

Sets the ModuleMenuNode's receiving message to this_message, which should be a selector for a method of one id argument (which will be the menu whose menu item had been selected).

setName:
- setName:(char*)this_name

Sets the ModuleMenuNode's name to this_name.

setReceiver:
-  setReceiver:this_receiver

Sets the ModuleMenuNode's receiver (target).   This will be the object sent the message defined in setMessage when the ModuleMenuNode's menu item is selected by the user.

setSubmenu::
-  setSubmenu:(int)this_index : this_node

Sets (as this_node) the subsidiary ModuleMenuNode that is at this_index position of the parent ModuleMenuNode's submenu array.