// 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
//
//  Creation Date:	May 7, 1997
//
//  Procedure Name:
//	AEswatchDisplay
//
//  Description:
//	Creates swatches for all rendering nodes
//
//  Input Value:
//	nodeName
//
//  Output Value:
//	None
//


//
//  Procedure Name:
//	defineLabel
//
//

global proc string defineLabel ( string $nodeName )
{
	// check on the classification of the node
	// to give the swatch image the correct
	// label

	string $type = `nodeType $nodeName`;
	string $classification[] = `getClassification  $type`;
	string $allClass[];
	tokenize ( $classification[0], "/", $allClass );
	string $firstClass =  $allClass[0];

	string $label;
	switch ($firstClass)	{
		case "shader":
			$label = "Material Sample";
			break;
		case "texture":
			$label = "Texture Sample";
			break;
		case "light":
			$label = "Intensity Sample";
			break;
		case "utility":
			$label = "Utility Sample";
			break;
		case "camera":
			$label = "Camera Sample";
			break;
		case "imageplane":
			$label = "Image Plane Sample";
			break;
		case "postprocess":
			$label = "Post Process Sample";
			break;
		case "shadingEngine":
			$label = "Shading Group Sample";
			break;
		default:
			$label = "Sample";
			break;
		}
	
	return $label;
}

//
//  Procedure Name:
//	AEswatchDisplayNew
//
//

global proc AEswatchDisplayNew ( string $nodeName, string $msg )
{
	global int $gTextColumnWidthIndex;

	string $node[];
	tokenize($msg, ".", $node);
	string $label = `defineLabel $node[0]`;

	formLayout swatchDisplayForm;
		text -l $label swatchLabel;

		swatchDisplayPort -wh 64 64 -sn $node[0] swatchDisplay;
	
		setParent ..;
	formLayout -e 
		-af swatchLabel top 0 
		-af swatchLabel bottom 0 
		-an swatchLabel left 
		-aof swatchLabel right (-$gTextColumnWidthIndex) 

		-ac swatchDisplay left 5 swatchLabel
		-af swatchDisplay top 0
		-af swatchDisplay bottom 0
		-an swatchDisplay right
		swatchDisplayForm;
}

//
//  Procedure Name:
//	AEswatchDisplayReplace
//
//

global proc AEswatchDisplayReplace ( string $nodeName, string $msg )
{
	string $node[];
	tokenize($msg, ".", $node);

	swatchDisplayPort -edit -sn $node[0] swatchDisplay;
	string $label = `defineLabel $node[0]`;
	text -e -l $label swatchLabel;
}

//
//  Procedure Name:
//	AEswatchDisplay 
//
//

global proc AEswatchDisplay ( string $nodeName )
{
	editorTemplate -callCustom ("AEswatchDisplayNew " + $nodeName )
			("AEswatchDisplayReplace " + $nodeName ) "message";
}
