/******************************************************************************
 BindingsTable.h

	Interface for the BindingsTable class

	Copyright © 1997 by Glenn W. Bach. All rights reserved.

 ******************************************************************************/

#ifndef _H_BindingsTable
#define _H_BindingsTable

#include <JXEditTable.h>

class BindingsList;
class PatternBinding;
class JXInputField;

class BindingsTable : public JXEditTable
{
public:

	BindingsTable(BindingsList* list, 
				JXScrollbarSet* scrollbarSet, JXContainer* enclosure,
				const HSizingOption hSizing, const VSizingOption vSizing,
				const JCoordinate x, const JCoordinate y,
				const JCoordinate w, const JCoordinate h);

	virtual ~BindingsTable();
	void	DeletePattern();
	void	SyncWithList();
	
protected:

	virtual void ApertureResized(const JCoordinate dw, const JCoordinate dh);
	virtual void Receive(JBroadcaster* sender, const Message& message);
	virtual void TableDrawCell(JPainter& p, const JPoint& cell, 
								const JRect& rect);
	virtual void HandleKeyPress(const int key,				
								const JXKeyModifiers& modifiers);

	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 JBoolean 		ExtractInputData(const JPoint& cell);
	virtual void 			DeleteXInputField();

private:

	BindingsList*		itsList;				// We don't own this.
	JSize				itsLineHeight;
	JXInputField*		itsStringInputField;
	JIndex				itsFoundIndex;

private:

	void	UpdateColWidths();

	// not allowed

	BindingsTable(const BindingsTable& source);
	const BindingsTable& operator=(const BindingsTable& source);
	
public:

	// JBroadcaster messages

	static const JCharacter* kEditStarted;
	static const JCharacter* kEditStopped;
	static const JCharacter* kChanged;
	
	class EditStarted : public JBroadcaster::Message
		{
		public:
			EditStarted()
			:
			JBroadcaster::Message(kEditStarted)
			{ };
		};

	class EditStopped : public JBroadcaster::Message
		{
		public:
			EditStopped()
			:
			JBroadcaster::Message(kEditStopped)
			{ };
		};

	class Changed : public JBroadcaster::Message
		{
		public:
			Changed()
			:
			JBroadcaster::Message(kChanged)
			{ };
		};
};

#endif