// Copyright (C) 1997-2004 Alias Systems Corp.
// 
// The information in this file is provided for the exclusive use of the
// licensees of Alias.  Such users have the right to use, modify,
// and incorporate this code into other products for purposes authorized
// by the Alias license agreement, without fee.
// 
// ALIAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
// INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
// EVENT SHALL ALIAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

//
// Alias Script File
// MODIFY THIS AT YOUR OWN RISK
//
// Creation Date:  28 June 1996
//
//
//  Procedure Name:
//      LayerMenu
//
//  Description:
//		This procedure creates a Layer menu in the
//		main menubar.  It controls things like
//		creating/deleting/hiding/showing of layers.
//
//  Input Arguments:
//      Parent to attach the menu to.
//
//  Return Value:
//      None.
//
	
global proc LayerMenu( string $parent ) {

	global int $gHideLayerSetting;
	global int $gTemplateLayerSetting;

	setParent -m $parent;

	if( `menu -q -ni $parent` == 0 ) {

		//	Build the menu items

		menuItem -l "New Layer..."
			-annotation "New Layer: Create a new layer"
			-c "createNewLayer"; 
		menuItem -l "Rename Layer..."
			-annotation "Rename Layer: Rename the current layer"
			-c "editLayerName"; 
		menuItem -l "Remove Current Layer"
			-annotation "Remove Current Layer: Remove the current layer"
			-c "removeCurrentLayer";
		menuItem -l "Layer Editor..."
			-annotation "Layer Editor Window: Open the layer editor window"
			-c "layerEditorWin";

		menuItem -divider true;

		menuItem -l "Transfer to Layer"
			-annotation "Transfer To Layer: Move selected items to the current layer"
			-c "transferToLayer";
		menuItem -l "Select All on Layer"
			-annotation "Select All on Layer: Select the contents of the current layer"
			-c "selectAllLayer";

		menuItem -divider true;

		menuItem -l "Hide Layer"
			-annotation "Hide Layer: Hide the contents of the current layer"
			-c "hideShowLayer -active hide";
		menuItem -l "Hide All Layers"
			-annotation "Hide All Layers: Hide the contents of all layers"
			-c "hideShowLayer -all hide";

		menuItem -divider true;

		menuItem -l "Show Layer"
			-annotation "Show Layer: Display the contents of the current layer" -c "hideShowLayer -active showHidden";
		menuItem -l "Show All Layers"
			-annotation "Show All Layers: Display the contents of all layers"
			-c "hideShowLayer -all showHidden";

		menuItem -divider true;

		menuItem -l "Template Layer"
			-annotation "Template Layer: Template the contents of the current layer"
			-c "templateLayer -active 1";
		menuItem -l "Untemplate Layer"
			-annotation "Untemplate Layer: Untemplate the contents of the current layer"			
			-c "templateLayer -active 0";

		menuItem -divider true;

		menuItem -cb $gHideLayerSetting
			-annotation "Hide Inactive Layers: Hide the contents of all layers except the current layer"
			-l "Hide Inactive Layers" 
			-c "updateLayerStates -hide (!$gHideLayerSetting)"
			hideNonCurrentLayersItem;

		menuItem -cb $gTemplateLayerSetting
			-annotation "Template Inactive Layers: Template the contents of all layers except the current layer"
			-l "Template Inactive Layers" 
			-c "updateLayerStates -template (!$gTemplateLayerSetting)"
			templateNonCurrentLayersItem;

		// Create a scripJob that is triggered
		// when something is added/remove/changed in the
		// layer partition, so that the layer UI updates
		// automatically.
		//
		scriptJob -p $parent -e "layerPartitionModified" "updateLayerUI";

	} else {
		//
		//  Set the state of check items
		//
		menuItem -e 
			-cb $gHideLayerSetting 
			($parent+"|hideNonCurrentLayersItem");

		menuItem -e 
			-cb $gTemplateLayerSetting 
			($parent+"|templateNonCurrentLayersItem");

	}
}
