###########################################################################
#                                                                         #
#               Copyright (C) 1995, Silicon Graphics, Inc.                #
#                                                                         #
#   These coded instructions, statements, and computer programs  contain  #
#   unpublished  proprietary  information of Silicon Graphics, Inc., and  #
#   are protected by Federal copyright law.  They  may  not be disclosed  #
#   to  third  parties  or copied or duplicated in any form, in whole or  #
#   in part, without the prior written consent of Silicon Graphics, Inc.  #
#                                                                         #
###########################################################################

#%COMMENT_BEGIN
# Filename:	dkInfoDlg
# Version:	$Revision: 1.6 $
# Synopsis:	Encapsulates the dialog that displays disk information.
# Functions:	dkInfo:realize
#		dkInfo:manage
#		dkInfo:fill
#		dkInfo:_startDrop
#		dkInfo:_doTransfer
#
#%COMMENT_END

#########################################
#		Public			#
#########################################
#%COMMENT_BEGIN
# Function:	dkInfo:realize
# Synopsis:	Initializes any class-wide data and creates an instance of
#		the dialog. If an instance of this dialog already exists for
#		the given handle, no action is taken.
# Arguments:	- handle	An identifier that is used as a key for storing
#				(and later retrieving) the created widgets and
#				any instance specific data.
#		- parent	The parent for the created dialog.
#
#%COMMENT_END
proc dkInfo:realize { handle parent } \
{
	global		_GW_dki _GD_dki
	set name	dkInfo

	if {! [info exists _GW_dki($handle,dialog)]} {
		set _GD_dki($name,columns)	\
			"DISK_NAME DISK_TYPE DISK_MBSIZE \
			 DISK_DRIVECAP DISK_SEC_LEN"

		set _GD_dki($name,cwidths)	{9 4 9 9 6}
		set _GD_dki($name,buttons)	{close help}

		set _GW_dki($handle,dialog) \
			[iu:createDlg $handle $parent $name _GD_dki _GW_dki]
		$_GW_dki($handle,buttons).help activateCallback \
				"sgiHelpMsg $_GW_dki($handle,dialog)"
		$_GW_dki($handle,buttons).close activateCallback \
				"$_GW_dki($handle,dialog) unmanageChild"

		$_GW_dki($handle,matrix) dropSiteRegister -dropProc \
			"$name:_startDrop $handle %dragContext $_GW_dki($handle,matrix)" \
			-numImportTargets 1 \
			-importTargets "COMPOUND_TEXT"
	}
}

#%COMMENT_BEGIN
# Function:	dkInfo:manage
# Synopsis:	Manages an instance of the dialog.
# Arguments:	- handle	The identifier for the desired instance.
#
#%COMMENT_END
proc dkInfo:manage { handle } \
{
	global	_GW_dki; $_GW_dki($handle,dialog) manageChild
}

#%COMMENT_BEGIN
# Function:	dkInfo:fill
# Synopsis:	Given a list of object signatures, retrieve the data for those
#		objects and fill in the matrix.
# Arguments:	- handle	The identifier for the desired instance.
#		- mode		Reserved for future use.
#		- lst		A list of object signatures for which to
#				display information.
#
#%COMMENT_END
proc dkInfo:fill { handle mode lst } \
{
	global		_GW_dki _GD_dki
	set name	dkInfo
	set rval	0

	if {[llength $lst]} {
		foreach item $lst {
			if {[obj:isXfsmTemplate $item]} {
				continue
			}
			lappend nlst $item
		}
		if {[info exists nlst]} {
			set data [iu:getObjectInfo $nlst]
			if {[clength $data] != 0} {
				set data [iu:cookRawData $name $data _GD_dki]
				iu:setData $name $_GW_dki($handle,matrix) \
						$_GD_dki($name,cwidths) $data
				set rval 1
			}
		}
	}

	return $rval
}

#########################################
#		Private			#
#########################################
#%COMMENT_BEGIN
# Function:	dkInfo:_startDrop
# Synopsis:	The function that is called when icons are dropped on
#		the dialog.
# Arguments:	- handle	The identifier for the desired instance.
#		- dragContext	The Motif drag context widget id.
#		- w		The widget id for the matrix.
#
#%COMMENT_END
proc dkInfo:_startDrop { handle dragContext w } \
{
	set dts [concat COMPOUND_TEXT $w]
	$dragContext dropTransferStart \
		-dropTransfers [list $dts] \
		-numDropTransfers 1 \
		-transferProc "dkInfo:_doTransfer $handle %closure {%value}"
}

#%COMMENT_BEGIN
# Function:	dkInfo:_doTransfer
# Synopsis:	The function that is called when the drop transfer is
#		completed.  It converts the information to the proper
#		internal format and then calls dkInfo:fill() to fill
#		the matrix.
# Arguments:	- handle	The identifier for the desired instance.
#		- destination	Unused
#		- value		The data for the dropped objects.
#
#%COMMENT_END
proc dkInfo:_doTransfer { handle destination value } \
{
	if {! [ip:uniqueToObject $value objs]} {
		####	TODO
	} else {
		dkInfo:fill $handle replace $objs
	}
}
