/*************************************************************************\
* "$RCSfile: CDlg.hpp,v $"                                                *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2009/11/30 14:04:59 $                      *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.16 $                                 *
\*************************************************************************/
/*! \file CDlg.hpp
*	\brief Header CDlg Class
**************************************************************************/

/*************************************************************************/
/*! @brief Dialog class

	Virtual class. CDlg is the base class of all other CDlgXXX classes. It
	provides the basic functionality for handling focus, displaying on
	change or redrawing. All other CDlg* classes inherit the features and
	properties of this class.
**************************************************************************/
class CDlg
{
public:
	CDlg() {}
	CDlg(int x, int y, int Width, int Height, int Id=DialogId::APP);
	virtual ~CDlg();
	virtual void Update();
	virtual void Prepare();
	virtual void DynamicRedraw();
	void Show(CIMAGE *pImage = NULL);
	int OnUserIO(int nKey);
	int OnImage(YIMAGE *pSrc, CIMAGE *pDst);
	const char *GetIdString() const;
	static CIMAGE ReadIcon(char *pFilename, int Width, int Height);

	//! Forces redraw of dialog.
	void ForceRedraw() { m_bUpdate = true; }

	//! Sets focus.
	void SetFocus(int value) { m_Focus = value; }

	//! Sets visible state of dialog.
	void SetVisible(bool value) { m_bIsVisible = value; }

	//! Gets value indicating whether dialog is visible.
	bool GetVisible() const { return m_bIsVisible; }

	//! Sets dialog ID.
	void SetID(int value) { m_ID = value; }

	//! Enables dialog.
	void Enable(int nEnable) { GUI_DlgEnable(&m_Dlg, nEnable); }

	//! Refreshes dialog.
	void Refresh() { GUI_DlgRefresh(&m_Dlg); }

protected:
	Config		*m_pStrings;		//!< Instance of Config class in this class. The strings are stored there.
	CIMAGE		m_Icon[24];			//!< Icons for the buttons
	DLG_ITEMD	*m_pDlgItem[200];	//!< Handles for dynamic dialog items
	DLG_ITEMS	*m_pDlgSItem[64];	//!< Handles for static dialog items
	FILE		*m_fKB;				//!< Keyboard handle 
	int			m_ID;				//!< ID of dialog instance
	int			m_Activity;			//!< m_Activity is zero if nothing changed since the last call of the work function
	int			m_Focus;			//!< ID of the dialog instance that has the focus
	int			*m_pDlgFocus;		//!< Current focus
	int			*m_pDlgNewFocus;	//!< Focus in the next program cycle
	int			m_DlgOldFocus;		//!< Last active dialog
	bool		m_bIsVisible;		//!< Visibility flag
	bool		m_bUpdate;			//!< Flag forces the Show() function to redraw the dialog
	bool		m_bDynamicUpdate;	//!< Flag if the dialog items can change without user interaction
	GUI_DLG		m_Dlg;				//!< Dialog structure
	class CPSApp *m_pApp;			//!< Pointer to application class, which handles all global parameters
};

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