/******************************************************************************
 JXCurveNameList.h

	Interface for the JXCurveNameList class

	Copyright © 1998 by Glenn W. Bach.  All rights reserved.
	
 *****************************************************************************/

#ifndef _H_JXCurveNameList
#define _H_JXCurveNameList

#include <JXEditTable.h>

class JXInputField;

class JXCurveNameList : public JXEditTable
{
public:

	JXCurveNameList(JXScrollbarSet* scrollbarSet, JXContainer* enclosure,
					 const HSizingOption hSizing, const VSizingOption vSizing,
					 const JCoordinate x, const JCoordinate y,
					 const JCoordinate w, const JCoordinate h);
	virtual ~JXCurveNameList();

	void	AppendName(JString* name);
	void	SetCurrentName(const JIndex index);

	virtual void	HandleKeyPress(const int key, const JXKeyModifiers& modifiers);

protected:

	virtual void	TableDrawCell(JPainter& p, const JPoint& cell, const JRect& rect);
	virtual void	ApertureResized(const JCoordinate dw, const JCoordinate dh);
	virtual void	Receive(JBroadcaster* sender, const Message& message);
	virtual void	HandleMouseDown(const JPoint& pt, const JXMouseButton button,
									const JSize clickCount,
									const JXButtonStates& buttonStates,
									const JXKeyModifiers& modifiers);

	virtual JXInputField*	CreateXInputField(const JPoint& cell,
											  const JCoordinate x, const JCoordinate y,
											  const JCoordinate w, const JCoordinate h);
	virtual void			DeleteXInputField();
	virtual JBoolean		ExtractInputData(const JPoint& cell);

private:

	JPtrArray<JString>*	itsNameList;	// we don't own the strings
	JCoordinate			itsMinColWidth;
	JXInputField*		itsInput;
private:

	void	AdjustColWidth();

	// not allowed

	JXCurveNameList(const JXCurveNameList& source);
	const JXCurveNameList& operator=(const JXCurveNameList& source);

public:

	static const JCharacter* kNameSelected;	

	class NameSelected : public JBroadcaster::Message
	{
	public:
	
		NameSelected(const JIndex index)
			:
			JBroadcaster::Message(kNameSelected),
			itsIndex(index)
			{ };
			
		JIndex
		GetIndex() const
		{
			return itsIndex;
		};
		
	private:
	
		JIndex itsIndex;
		
	};

};

#endif
