/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			cmdtextfield.h
  \date			Dec 2011
  \author		TNick

  \brief		Contains the definition for CmdTextField class


*//*

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __CMDTEXTFIELD_INC__
#define __CMDTEXTFIELD_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<QPlainTextEdit>
#include	<QLabel>
#include	<QStringList>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	Gui		{

/**
*	@brief	class representing a plain text control that interprets commands
*/
class CmdTextField :public QPlainTextEdit				{
	Q_OBJECT

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:


	/**
	*	@brief	associated log panel
	*/
	QPlainTextEdit *		tx_Log;


	/**
	*	@brief	the label shown in front of text
	*/
	QLabel *				lbl_;


	/**
	*	@brief	previously inputted text
	*/
	QStringList				tx_prev_;


	/**
	*	@brief	index of previously inputted text
	*/
	int						prev_idx_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/**
	*	@brief	constructor;
	*/
	CmdTextField		( QWidget * parent = 0 );


	/**
	*	@brief	constructor;
	*/
	CmdTextField		( QPlainTextEdit * log_target, QWidget * parent = 0 );


	/**
	*	@brief	destructor;
	*/
	virtual				~CmdTextField		( void );


	/**
	*	@brief	get
	*/
	inline QPlainTextEdit *	assocLog				( void )
	{ return tx_Log; }


	/**
	*	@brief	set
	*/
	inline void			setAssocLog			( QPlainTextEdit * new_val )
	{ tx_Log = new_val; }


	/**
	*	@brief	change the text displayied at the left of the input box
	*/
	void				setLabelText		(
			const QString &			new_val = QString()
			);



protected:


	/**
	*	@brief	filter the keys
	*/
	void				keyPressEvent		( QKeyEvent *e );


	/**
	*	@brief	helps us keep the label in place
	*/
	void				resizeEvent			( QResizeEvent * );


private:



	/**
	*	@brief	common initialisation to all constructors
	*/
	void				init				( void );


	/**
	*	@brief	append a new string to the list
	*/
	void				appendCommand		( const QString & s_in );


	/**
	*	@brief	get previously entered string at index i
	*/
	QString				previousCommand		( int i = 0 );


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class CmdTextField	*/

/*  CLASS    =============================================================== */
//
//
//
//

} // namespace Gui

#endif // __CMDTEXTFIELD_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
