void
GLFitDescriptionList::SyncWithManager()
{
	RemoveAllRows();
	
	const JSize count = GetFitManager()->GetFitCount();
	AppendRows(count);

	itsNameList->DeleteAll();
	
	for (JIndex i=1; i<=count; i++)
		{
		const GLFitDescription& fd	= GetFitManager()->GetFitDescription(i);
		JString* str	= jnew JString(fd.GetFnName());
		assert(str != NULL);
		itsNameList->Append(str);

		const JCoordinate width = 2*kHMarginWidth + kIconWidth + 
			GetFontManager()->GetDefaultFont().GetStringWidth(*str);
		if (width > itsMinColWidth)
			{
			itsMinColWidth = width;
			}
		}

	AdjustColWidth();
}
void
GLFitParameterTable::SetFitDescription
	(
	const GLFitDescription& fit
	)
{
	RemoveAllRows();
	itsNameList->DeleteAll();
	itsStartValues->RemoveAll();
	itsFitValues->RemoveAll();
	itsErrorValues->RemoveAll();

	GLFitDescription::FitType type = fit.GetType();
	if (fit.RequiresStartValues())
		{
		if (!itsHasStartValues)
			{
			InsertCols(kStartColIndex, 1, kDefColWidth);
			itsColHeaderWidget->SetColTitle(2, kParmStartTitle);
			itsHasStartValues	= kJTrue;
			AdjustColWidth();
			}
		}
	else
		{
		if (itsHasStartValues)
			{
			RemoveCol(kStartColIndex);
			itsHasStartValues	= kJFalse;
			AdjustColWidth();
			}
		}

	const JSize count	= fit.GetParameterCount();
	AppendRows(count);
	for (JIndex i = 1; i <= count; i++)
		{
		JString* str = new JString("");
		fit.GetParameterName(i, str);
		itsNameList->Append(str);
		itsStartValues->AppendElement(0);
		itsFitValues->AppendElement(0);
		itsErrorValues->AppendElement(0);
		}			
}
void
GMAccountList::ApertureResized
	(
	const JCoordinate dw,
	const JCoordinate dh
	)
{
	JXTable::ApertureResized(dw,dh);
	AdjustColWidth();
}
void
GLFitParameterTable::ApertureResized
	(
	const JCoordinate dw,
	const JCoordinate dh
	)
{
	JXEditTable::ApertureResized(dw,dh);
	AdjustColWidth();
}
void
JX2DCurveNameList::ApertureResized
	(
	const JCoordinate dw,
	const JCoordinate dh
	)
{
	JXEditTable::ApertureResized(dw,dh);
	AdjustColWidth();
}
void
GLFitDescriptionList::ApertureResized
	(
	const JCoordinate dw,
	const JCoordinate dh
	)
{
	JXEditTable::ApertureResized(dw,dh);
	AdjustColWidth();
}
JX2DCurveNameList::JX2DCurveNameList
	(
	const JArray<J2DCurveInfo>&	curveInfo,
	const JIndex				startIndex,
	JXScrollbarSet*				scrollbarSet,
	JXContainer*				enclosure,
	const HSizingOption			hSizing,
	const VSizingOption			vSizing,
	const JCoordinate			x,
	const JCoordinate			y,
	const JCoordinate			w,
	const JCoordinate			h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth +
		fontMgr->GetDefaultFont().GetLineHeight();
	SetDefaultRowHeight(rowHeight);

	const JSize count = curveInfo.GetElementCount();

	itsNameList = jnew JPtrArray<JString>(JPtrArrayT::kForgetAll, count);
	assert(itsNameList != NULL);

	AppendRows(count);
	for (JIndex i=1; i<=count; i++)
		{
		const J2DCurveInfo info = curveInfo.GetElement(i);
		itsNameList->Append(info.name);

		const JCoordinate width = 2*kHMarginWidth +
			fontMgr->GetDefaultFont().GetStringWidth(*(info.name));
		if (width > itsMinColWidth)
			{
			itsMinColWidth = width;
			}
		}

	AppendCols(1);
	AdjustColWidth();

	JXColormap* colormap = GetColormap();
	SetRowBorderInfo(0, colormap->GetBlackColor());
	SetColBorderInfo(0, colormap->GetBlackColor());

	BeginEditing(JPoint(1, startIndex));
}
void
GLFitParameterTable::ShowStartCol
	(
	const JBoolean show
	)
{
	if (itsHasStartValues == show)
		{
		return;
		}
	if (itsHasStartValues)
		{
		RemoveCol(kStartColIndex);
		itsHasStartValues	= kJFalse;
		AdjustColWidth();
		}
	else
		{
		InsertCols(kStartColIndex, 1, kDefColWidth);
		itsColHeaderWidget->SetColTitle(2, kParmStartTitle);
		itsHasStartValues	= kJTrue;
		AdjustColWidth();
		}
}
GLFitParameterTable::GLFitParameterTable
	(
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1, kDefColWidth, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h),
	itsInput(NULL),
	itsHasStartValues(kJTrue),
	itsColHeaderWidget(NULL)
{
	itsMinColWidth = 1;

	const JFontManager* fontMgr = GetFontManager();
	const JSize rowHeight = 2*kVMarginWidth +
		fontMgr->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle());
	SetDefaultRowHeight(rowHeight);

	itsNameList = new JPtrArray<JString>(JPtrArrayT::kDeleteAll);
	assert(itsNameList != NULL);

	itsStartValues	= new JArray<JFloat>;
	assert(itsStartValues != NULL);

	itsFitValues	= new JArray<JFloat>;
	assert(itsFitValues != NULL);

	itsErrorValues	= new JArray<JFloat>;
	assert(itsErrorValues != NULL);

	AppendCols(4, kDefColWidth);
	AdjustColWidth();

	JXColormap* colormap = GetColormap();
//	SetRowBorderInfo(0, colormap->GetBlackColor());
//	SetColBorderInfo(0, colormap->GetBlackColor());

}
void
GMAccountList::TableDrawCell
	(
	JPainter&		p,
	const JPoint&	cell,
	const JRect&	rect
	)
{
	HilightIfSelected(p, cell, rect);

	JFontStyle fontstyle;
	if (itsDialog->GetDefaultIndex() == (JIndex)cell.y)
		{
		fontstyle.bold	= kJTrue;
		}

	p.SetFont(JGetDefaultFontName(), kJDefaultFontSize, fontstyle);

	JString str = itsAccountInfo->NthElement(cell.y)->GetNickname();

	// check that column is wide enough

	const JCoordinate w = p.GetStringWidth(str) + 2*kHMarginWidth;
	if (w > GetColWidth(1))
		{
		itsMinColWidth = w;
		}

	// draw string

	JRect r = rect;
	r.left += kHMarginWidth;
	p.String(r, str, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
	if (cell.y == JCoordinate(itsAccountInfo->GetElementCount()))
		{
		AdjustColWidth();
		}
}
void
GLFitParameterTable::PrintOnPage
	(
	JPagePrinter& 		p, 
	JCoordinate* 		height
	)
{
	const JSize origWidth	= GetBoundsWidth();
	JSize printWidth		= JSize(p.GetPageWidth() * 0.9);

	AdjustSize(printWidth - origWidth, 0);
//	SetSize(printWidth, GetBoundsHeight());
	AdjustColWidth(printWidth);
	
	itsColHeaderWidget->PrintOnPage(p);
	p.ShiftOrigin(0, itsColHeaderWidget->GetBoundsHeight());

	TableDraw(p, GetBounds());

	AdjustSize(origWidth - printWidth, 0);
//	SetSize(origWidth, GetBoundsHeight());

	*height	= GetBoundsHeight() + itsColHeaderWidget->GetBoundsHeight();
}
void
GLFitParameterTable::AdjustColWidth()
{
	AdjustColWidth(GetApertureWidth());
}