#ifndef NamesEditor_INCLUDED
	#define NamesEditor_INCLUDED

#include <bncs_script_helper.h>

#ifdef WIN32
	#ifdef DOEXPORT_SCRIPT
		#define EXPORT_SCRIPT __declspec(dllexport) 
	#else
		#define EXPORT_SCRIPT 
	#endif
#else 
	#define EXPORT_SCRIPT
#endif
 
class NamesEditor : public bncs_script_helper
{
public:
	NamesEditor( bncs_client_callback * parent, const char* path );
	virtual ~NamesEditor();

	void buttonCallback( buttonNotify *b );
	int revertiveCallback( revertiveNotify * r );
	void databaseCallback( revertiveNotify * r );
	bncs_string parentCallback( parentNotify *p );
	void timerCallback( int );
	
private:
	enum editLevels {None, Video, Audio, Key, Timecode};

	bncs_string m_myParam;
	bncs_string m_instance;
	
	bncs_config myVals;			// Used when reading paramters from Instances.xml

	bncs_string	myTemp;			// Used durng various string processing operations
	bncs_string returnBtnID;	// Used in processing of short or long name edit
	bncs_string RestoreName;	// Holds the pre-edit name
	bncs_string editedName;		// Holds teh edited name
	bncs_string srcPkg;			// Holds the last polled value for source package string
	bncs_string dstPkg;			// Holds the last polled value for the destination string
	bncs_string newPkg;			// Used to build a new package for storage in infodriver.

	bncs_stringlist elements;	// Used when splitting levels string into individual levels.
	
	char myFile[MAX_PATH];		// Used by the code that finds package source and destination infodriver ids

	int cta_sdi_id;				// CTA SDI router BNCS device ID
	int cta_audio_id;			// CTA audio router BNCS device ID
	int cta_tc_id;				// CTA timecode router BNCS device ID
	int cta_camstat_id;			// CTA camera status router BNCS device ID
	int cta_spare_id;
	int sta_pal_id;				// Studio A PAL matrix id
	int cta_pkg_id;				// CTA BNCS packager device id
	int cta_pkg_src_info_id;	// CTA BNCS packager source content infodriver
	int cta_pkg_dst_info_id;	// CTA BNCS packager destination content infodriver

	// data about the current edit session
	int current_mtx;
	int current_dbase;			// Has the value of 0 (source) or 1 (destination)
	int dbase_offset;			// Holds the database undergoing edit, including the length property (0 to 3) 
	int edit_index;
	int maxlength;				// Maximum name length during edit
	int timeout_counter;		// Counter used to measure timeout period
	int pkg_index;				// Which package number is being edited
	int pkg_dbase;				// Which database (sources=0, destinations=1) is being edited
	int sep_posn;				// Used during preperation of display of package group on edit detail panel. Line seperator character is removed
	int mtxid;					// Holds matrix id that will be updated when user puses a source select button in package editor.

	int src_v;					// Used by revertives from package sources infodriver
	int src_a;
	int src_k;
	int src_t;
	int dst_v;					// Used by revertives from package destinations infodriver
	int dst_a;
	int dst_k;
	int dst_t;
	int idx_v;					// Used by the package edit process to hold current selections
	int idx_a;
	int idx_k;
	int idx_t;

	editLevels curLevel;

	bool timer_enabled;			// Set true when the update/restore timer is active
	bool elementsEnabled;		// Set true when the level selectors on the package edit panel are active
	bool edit_active;			// Set true when the package edit process is active
	bool pkg_update_enable;		// Set true when the package update button is enabled.

	// Local Methods
	void MatrixSelector(buttonNotify *b);		// Process button push revertives from function select panel
	void EditButtonProcess(buttonNotify *b);	// Process button push revertives from source/destination name panel
	void pkgEditProcess(buttonNotify *b);		// Process button push revertives from package content editor
	void SetEditButtons(void);					// Sets the device numbers, databases, offsets etc ready to start the edit.
	void hideElementSelector(void);				// Hide the background, group and element selectors in package content edit
	void showElementSelector(void);				// Show the background, group and element selectors in package content edit
	void disableElementChose(void);				// Disable the level edit buttons on package content editor panel
	void enableElementChose(void);				// Enable the level edit buttons on package content editor panel
	void use_level(editLevels myLevel);			// Set up the edit selectors for selected edit level (eg show sdi selector for video level)
	void no_element_selected(void);				// Hide any selections in the element group and source names selector.
};

#endif // NamesEditor_INCLUDED