# $Revision$ on $Date$
# The above revision line needs to be the first line for all techtk files
# Copyright (c) 2006 Ansys Inc



proc ::AIEnv::GUIManagement::enterWizardRootBuild {NodeID} {
	BeginTypeDefinition Wizard
}

proc ::AIEnv::GUIManagement::leaveWizardRootBuild {NodeID} {
	EndTypeDefinition
}


proc ::AIEnv::GUIManagement::enterWizardBuild {NodeID} {
	variable CATRootDir
	variable IconDir
	set GUITree [TreeStack peek]
	set Name [$GUITree get $NodeID -key "Name"]
	
	BeginObjectDefinition $Name
	
	set Title [$GUITree get $NodeID -key "Title"]
	set ImageName [$GUITree get $NodeID -key "Image"]
	
	if { $ImageName != "" } {
		# Check the file name to see if it is a valid file (Nocase compare)
		set FileName [GetFileName [file join $CATRootDir $IconDir $ImageName]]
		set im [image create photo -format GIF -file $FileName]
		$Name create -title $Title -image $im
	} else {
		$Name create -title $Title
	}
}

proc ::AIEnv::GUIManagement::leaveWizardBuild {NodeID} {
	set GUITree [TreeStack peek]
	set Name [$GUITree get $NodeID -key "Name"]
	$Name compute_size
	EndObjectDefinition
}

proc ::AIEnv::GUIManagement::enterWizardPageBuild {NodeID} {
	variable ItemNameMap
	set GUITree [TreeStack peek]
	set Name [$GUITree get $NodeID -key "Name"]
	set Title [$GUITree get $NodeID -key "Title"]
	set Wizard [GetObject]
	if { $Title != "" } {
		$Wizard addpage $Name -title $Title
	} else {
		$Wizard addpage $Name
	}
	set PageFrame [$Wizard getpageframe $Name]
	

	set ChildColumnNodeIDs [$GUITree children $NodeID]
	set ColumnCount 0
	foreach Child $ChildColumnNodeIDs {
		# Look up the nodeID associated with the Name of
		# the child column 
		set ChildName [$GUITree get $Child -key "Name"]
		if { [array names ItemNameMap $ChildName] != ""} {
			set ChildNodeID $ItemNameMap($ChildName)
		} else {
			::InitError "Unknown wizard column named: \"$ChildName\" encountered while building wizard named: \"$Wizard\""
		}
		
		# Create a new frame for this child
		set ChildFrame [frame $PageFrame.$Child-frame]
		# Grid in the new frame
		grid $ChildFrame -row 0 -column $ColumnCount -sticky nsew -padx 5
		grid columnconfigure $PageFrame $ColumnCount -weight 0
		
		WindowPathStack push $ChildFrame
		DEZRowCountStack push 0
		# Preform a nested traversal of the GUITree beginning with the child frame node
#		$GUITree walk $ChildNodeID -order both -type dfs -command "BuildGUIItem %n %a" 
		# Nested traverse commented out as it is taken care in MainTree walk within BuildGUI.
		# Pop this frame off the stack
#		WindowPathStack pop
		# Pop moved to leaveWizardPageBuild..
		# Move to the next column
		incr ColumnCount
	}
	# Make sure all of the columns in this page are pushed as far left as possible
	grid columnconfigure $PageFrame $ColumnCount -weight 1
	grid rowconfigure $PageFrame 1 -weight 1

}

proc ::AIEnv::GUIManagement::leaveWizardPageBuild {NodeID} {
	WindowPathStack pop
}

proc ::AIEnv::GUIManagement::enterWizardColumnBuild {NodeID} {
	# Intentionally empty	
}

proc ::AIEnv::GUIManagement::leaveWizardColumnBuild {NodeID} {
	# Intentionally empty	
}

proc ::AIEnv::GUIManagement::enterWizardColumnNameBuild {NodeID} {
	# Intentionally empty	
}

proc ::AIEnv::GUIManagement::leaveWizardColumnNameBuild {NodeID} {
	# Intentionally empty	
}
