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

/*************************************************************************/
/*! @brief File-manager Dialog class.

	CDlgFileMgr is modal.
**************************************************************************/
class CDlgFileMgr
{
protected:
	enum eDlgFileMgr_ID
	{
		ID_LEFT_DEV = 1,
		ID_RIGHT_DEV,
		ID_LEFT_FS,
		ID_RIGHT_FS,
		ID_LEFT_B,
		ID_RIGHT_B,
		ID_XX
	};

	//! Actions
	enum eACTION
	{
		NOACTION = 0,
		CMD,
		HELP,
		RENAME,
		DELETE,
		DELETEALL,
		COPYFILE,
		COPY,
		PASTE,
		CREATEDIR,
		FINFO,
		DINFO,
		IMAGEBROWSER,
		IMAGEBROWSERD,
		CHDIRLEFT,
		CHDIRRIGHT,
		FILECMD,
		DIRCMD,
		SELLEFTDEVICE,
		SELRIGHTDEVICE
	};

	//! Left/Right directory list
	enum eSIDE
	{
		LEFT,	//!< Left side
		RIGHT	//!< Right side
	};

private:
	CDlgFileMgr();
	~CDlgFileMgr();
	static CDlgFileMgr *m_pThis;

public:
	static CDlgFileMgr *CreateInstance();
	//! Gets CDlgFileMgr instance.
	static CDlgFileMgr *GetInstance() { return m_pThis; };
	static void DisposeInstance();
	int Run();
	int DisplayBMPFile(const char *FName);
	int DisplayPNGFile(const char *FName);
	int DisplayJPGFile(const char *FName);

protected:
	void SetSide(int Side, char **ppFName, int *pFSize);
	void Update();
	void FileCommand(const char *FName);
	void RenameFile(const char *FName);
	void DeleteFile(const char *FName);
	void DeleteAllFiles();
	int  DeleteRecursive(const char *FName);
	void CreateDir();
	int  CopyFile(const char *FName);
	int  CopyFile2RAM(const char *FName);
	int  PasteFile();
	void FileInfoBox(const char *FName) const;
	void DriveInfoBox() const;
	void GetScrollKeys(int Width, int Height, int nKey, int *pxOff, int *pyOff);
	int  DisplayImage(CIMAGE *pShowImage, const char *FName, int Depth);
	void DisplayRBFFile(const char *FName);
	void DisplayTTFFile(const char *FName);
	void DisplayVBUFile(const char *FName);
	void DisplayAVIFile(const char *FName);
	void EditTextFile(const char *FName);
	void RecBackground();
	const char *SatInfo2String(int Type) const;
	int  SelectDevice();
	bool CheckForProtectedFlash() const;

	GUI_DLG *m_pDlg;			//!< File-manager dialog
	GUI_DLG *m_pDlgFC;			//!< File-command dialog
	GUI_DLG *m_pDlgDC;			//!< Dir-command dialog
	DLG_ITEMD *m_pDlgItem[ID_XX];	//!< Handles to dynamic dialog items
	CIMAGE *m_pImage;			//!< Pointer to background image
	CPSApp *m_pApp;				//!< Pointer to application
	FILE *m_fKB;				//!< Keyboard handle
	int m_Side;					//!< Current side
	int m_Device[2];			//!< Device left/right side
	int m_ActiveDevice;			//!< Active device
	int m_SelFC;				//!< \e SelectBox File menu
	int m_SelDC;				//!< \e SelectBox Directory menu
	int m_FSWidth;				//!< Width of \e FileSelectBox
	int m_FSHeight;				//!< Height of \e FileSelectBox
	int m_CopyFileSize;			//!< File size for copy/paste
	int m_PosX;					//!< X-Position for dialog
	int m_PosY;					//!< Y-Position of start
	bool m_bProtectFlash;		//!< Write protection for internal Flash memory
	char *m_ActivePath;			//!< Active path
	char m_Path[2][128];		//!< Path of left/right side
	char m_File[2][16];			//!< Selected file on left/right side
	char m_CopyFileName[16];	//!< File name for copy/paste
	unsigned char *m_pCopyMem;	//!< Buffer for copy/paste
};

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