//
//	Copyright (c) 2003 General Electric Medical Systems IT
//
//	Version control:
//		$Archive: /releases/FreeViewer_2.0/src/WebViewer/FreeViewer/HTML/layoutmn.js $
//		$Revision: 3 $
//		$Date: 3/04/03 11:38a $
//		$Author: Marceld $
//

DeriveFrom(ViewportLayoutManager, TableLayoutManager);

//
// ViewportLayoutManager C'tor
//
function ViewportLayoutManager(elemContainer, nSeriesIdx)
{
	this._nSeriesIndex = nSeriesIdx;
	this._activeviewport = 0;		// index of the viewport with the red border in the layout
	this._dicomdirseriesnr = 0;		// index of the series in the dicomdir
	this._dicomdirimagenr = 0;			// index of the first image of the series in the DDTV control
	this._rgViewports = null;
	this.CtorTableLayoutManager(this, elemContainer);
	this.SetViewportLayout(1, 1);
}

//
// CreateCellContent
//
function ViewportLayoutManager.prototype.CreateCellContent(iCell)
{ with(this) {
	var objViewport = new Viewport(iCell, _nSeriesIndex);
	_rgViewports[_rgViewports.length] = objViewport;
	return '<div class=\"classNoFocus">' + objViewport.GetObjectElementString() + '</div>';
}}

//
// SetViewportLayout
//
function ViewportLayoutManager.prototype.SetViewportLayout(newRowCnt, newColCnt)
{ with(this) {
	if (newRowCnt == GetRowCount() && newColCnt == GetColCount())
		return;

	_rgViewports = new Array();
	ChangeLayout(newRowCnt, newColCnt);
	InitViewports();
}}

//
// GetViewportCount
//
function ViewportLayoutManager.prototype.GetViewportCount()
{ with(this) {
	return GetCellCount();
}}

//
// SetActiveViewport
//
function ViewportLayoutManager.prototype.SetActiveViewport(nViewportIndex)
{ with(this) {
	var oActiveViewport = GetActiveViewport();
	if (oActiveViewport != null)
	{
		oActiveViewport.MakeInactive();
	}

	_activeviewport = nViewportIndex;

	oActiveViewport = GetActiveViewport();
	oActiveViewport.MakeActive();

	return oActiveViewport;
}}


//
// GetActiveViewport
//
function ViewportLayoutManager.prototype.GetActiveViewport()
{ with(this) {
	return GetViewport(_activeviewport);
}}

//
// GetViewport
//
function ViewportLayoutManager.prototype.GetViewport(iIdx)
{ with(this) {
	return _rgViewports[iIdx];
}}

//
// GetLayout
//
function ViewportLayoutManager.prototype.GetLayout()
{ with(this) {
	return GetRowCount().toString() + 'x' + GetColCount().toString();
}}

//
// InitViewports
//
function ViewportLayoutManager.prototype.InitViewports()
{ with(this) {
	var nViewportCnt = GetViewportCount();
	for (var i = 0; i < nViewportCnt; i++)
	{
		GetViewport(i).Init(GetTableCell(i).children[0].children[0]);
	}
}}

//
// SetImageNr
//
function ViewportLayoutManager.prototype.SetImageNr(nImageIndex)
{ with(this) {
	_dicomdirimagenr = nImageIndex;
}}

//
// GetImageNr
//
function ViewportLayoutManager.prototype.GetImageNr()
{ with(this) {
	return _dicomdirimagenr;
}}

//
// GetSeriesNr
//
function ViewportLayoutManager.prototype.GetSeriesNr()
{ with(this) {
	return _dicomdirseriesnr;
}}

//
// SetSeriesNr
//
function ViewportLayoutManager.prototype.SetSeriesNr(nSeriesIndex)
{ with(this) {
	_dicomdirseriesnr = nSeriesIndex
}}
