/*************************************************************************\
* "$RCSfile: CDlgConfig.hpp,v $"                                          *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2011-10-20 07:58:08 $                      *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.15 $                                 *
\*************************************************************************/
/*! \file CDlgConfig.hpp
*	\brief Header CDlgConfig Class
**************************************************************************/

/*************************************************************************/
/*! @brief User interface class to \p Config class.

	Provides a user interface to the configuration class.\n
	The dialog is a full-screen dialog and therefore is modal.
	@image html CDlgConfig.png

	The dialog is not created in the constructor as in the other CDlg* 
	classes but in the Create() function. The dialog is created
	automatically depending on the content of the assigned instance of
	\p Config.\n
	After creation in the OnUserIO() function the user inputs are processed.\n
	When the OnUserIO() function is left the dialog has to be deleted with 
	the Delete() function.
**************************************************************************/
class CDlgConfig: public CDlg
{
protected:
	//! @brief Dialog identifier of CDlgConfig dialog.
	//!
	//! They are reused as array index together with the INDEX() and ICON() macros.
	enum eDlgConfig_ID
	{
		// 0x100 <= ICON <= 0x1FF
		ID_UP = 0x100,	//!< Up button
		ID_DOWN,		//!< Down button
		ID_LEFT,		//!< Left button
		ID_RIGHT,		//!< Right button
		ID_UPA,			//!< Up button (2)
		ID_DOWNA,		//!< Down button (2)
		ID_XXX,			//!< End marker

		ID_OK,			//!< OK button
		ID_BACK,		//!< Back button
		ID_SAVE,		//!< Save button

		ID_SBA,			//!< \p Config element \e SelectBox A
		ID_SBB,			//!< \p Config element \e SelectBox B
		ID_EDITBOX,		//!< \e EditBox for string or float values
		ID_VEDITBOX		//!< \e VEditBox for int values
	};

private:
	CDlgConfig(int x, int y, int Width, int Height);
	~CDlgConfig();
	static CDlgConfig *m_pThis;

public:
	static CDlgConfig *CreateInstance(int x, int y, int Width, int Height);
	//! Gets CDlgConfig instance.
	static CDlgConfig *GetInstance() { return m_pThis; }
	static void DisposeInstance();
	void Update();
	void Create(Config *pConfig, int Mode = 0);
	void Delete();
	int  OnUserIO(int nKey);

protected:
	int  ChangeValue();
	void ChangeParam();
	void PreDownUp();
	void BuildSelBoxText();
	void UpdateSelBox(bool Rebuild = false);
	void UpdateVEditBox();
	void GotoItem();

	Config	*m_pConfig;			//!< Instance of \p Config the user can edit
	ConfigParam *m_pParam;		//!< One element of the list of parameters stored in CDlgConfig::m_pConfig
	int		m_Value;			//!< Value of a integer element linked to the \e VEditBox
	double	m_dVal;				//!< Value of a double element read from the \e EditBox
	int		m_Sel;				//!< Current position in \e SelectBox
	int		m_SelOld;			//!< Previously selected element position in \e SelectBox
	int		m_FileSel;			//!< Current Line in \e FileSelectBox
	int		m_PreDownUp;		//!< Help variable for button down/up in Preset tool
	int		m_PosX;				//!< X-Position to draw the dialog
	int		m_PosY;				//!< Y-Position to draw the dialog
	int		m_Width;			//!< Width of dialog
	int		m_Height;			//!< Height of dialog
	int		m_EditPosX;			//!< X-Position of \e EditBox
	int		m_EditPosY;			//!< Y-Position of \e EditBox
	int		m_EditWidth;		//!< Width of \e EditBox
	int		m_PresetHelp;		//!< Help variable for preset
	int		m_ActiveBox;		//!< Active \e SelectBox
	char	*m_SelBoxText;		//!< Text for parameter \e SelectBox
	char	m_BoxTextC[256];	//!< Text for \e TextBox
	char	m_EditBoxText[256];	//!< Text in \e EditBox
	char	m_ParamName[32];	//!< Name of selected parameter
	char	m_ParamComment[80];	//!< Comment assigned to parameter
	char	m_ParamRange[64];	//!< String with allowed range of current parameter
	char	m_ParamKey[32];		//!< Name of selected preset key
	char	m_FileName[24];		//!< Name of selected file in \e SelectBox
	char	m_FileNameOld[24];	//!< Name of last selected file in \e SelectBox
	CIMAGE	m_SIcon[2];			//!< Save symbols
};

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