// Copyright (C) 1997-2006 Autodesk, Inc., and/or its licensors.
// All rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its licensors,
// which is protected by U.S. and Canadian federal copyright law and by
// international treaties.
//
// The Data is provided for use exclusively by You. You have the right to use,
// modify, and incorporate this Data into other products for purposes authorized 
// by the Autodesk software license agreement, without fee.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. AUTODESK
// DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES
// INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF NON-INFRINGEMENT,
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ARISING FROM A COURSE 
// OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS
// LICENSORS BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL,
// DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS
// LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.

//
//  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 = (uiRes("m_AEswatchDisplay.kMaterialSample"));
			break;
		case "texture":
			$label = (uiRes("m_AEswatchDisplay.kTextureSample"));
			break;
		case "light":
			$label = (uiRes("m_AEswatchDisplay.kIntensitySample"));
			break;
		case "utility":
			$label = (uiRes("m_AEswatchDisplay.kUtilitySample"));
			break;
		case "camera":
			$label = (uiRes("m_AEswatchDisplay.kCameraSample"));
			break;
		case "imageplane":
			$label = (uiRes("m_AEswatchDisplay.kImagePlaneSample"));
			break;
		case "postprocess":
			$label = (uiRes("m_AEswatchDisplay.kPostProcessSample"));
			break;
		case "shadingEngine":
			$label = (uiRes("m_AEswatchDisplay.kShadingGroupSample"));
			break;
		default:
			$label = (uiRes("m_AEswatchDisplay.kSample"));
			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 -label $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 -label $label swatchLabel;
}

//
//  Procedure Name:
//	AEswatchDisplay 
//
//

global proc AEswatchDisplay ( string $nodeName )
{
	editorTemplate -callCustom ("AEswatchDisplayNew " + $nodeName )
			("AEswatchDisplayReplace " + $nodeName ) "message";
}
