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

#ifndef __PKR2EDITORFRM_H__
#define __PKR2EDITORFRM_H__

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

#ifdef __BORLANDC__
	#pragma hdrstop
#endif

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

#ifndef WX_PRECOMP
	#include <wx/wx.h>
	#include <wx/frame.h>
#else
	#include <wx/wxprec.h>
#endif

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

////Header Include Start
#include <wx/msgdlg.h>
#include <wx/dirdlg.h>
#include <wx/textdlg.h>
#include <wx/filedlg.h>
#include <wx/button.h>
#include <wx/html/htmlwin.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
////Header Include End

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

////Dialog Style Start
#undef PKR2EditorFrm_STYLE
#define PKR2EditorFrm_STYLE wxCAPTION | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxCLOSE_BOX
////Dialog Style End

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

using namespace std;

#include <cstdlib>
#include <cstring>
#include <wx/file.h>
#include <windows.h>
#include <mmsystem.h>

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

struct fileheader
{
    char fname[32];
    unsigned int fsize;
    unsigned char* fdata;
};

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

struct dirheader
{
    char dname[32];
    unsigned int dfiles_n;
    fileheader* dfiles;
};
		
/*******************************************************************************/

class PKR2EditorFrm : public wxFrame
{	
	public:
		PKR2EditorFrm(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("PKR2Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = PKR2EditorFrm_STYLE);
		virtual ~PKR2EditorFrm();
		unsigned short GetExtension(char*);
		void LoadBMP();
		void LoadTXT();
		void LoadWAV();
		void ClearMem();
		void Print(const wxChar*);
		void LSTFilesDoubleClicked(wxCommandEvent& event);
		void Print(unsigned int);
		void MakeFileList(unsigned short);
		void LSTDirsSelected(wxCommandEvent& event);
		void BTNOpenPkrClick(wxCommandEvent& event);
		void LSTFilesSelected(wxCommandEvent& event);
		void BTNReplaceFileClick(wxCommandEvent& event);
		void BTNExtractFileClick(wxCommandEvent& event);
		void BTNDeleteFileClick(wxCommandEvent& event);
		void BTNAddFileClick(wxCommandEvent& event);
		void BTNNewPkrClick(wxCommandEvent& event);
		void BTNDelDirClick(wxCommandEvent& event);
		void BTNAddDirClick(wxCommandEvent& event);
		void BTNExtDirClick(wxCommandEvent& event);
		void BTNSavePkrClick(wxCommandEvent& event);
	private:
        DECLARE_EVENT_TABLE();
		char pkrheader[5];
		unsigned int aux;
		unsigned int dirs_n;
		unsigned int files_n;
		dirheader* dirs;
		dirheader* exdir;
		fileheader* exfile;
		wxFile FHandler;
		wxString Str;
		////GUI Control Declaration Start
		wxButton *BTNNewPkr;
		wxMessageDialog *DLGNameInvalid;
		wxFileDialog *DLGAddFile;
		wxDirDialog *DLGExtFolder;
		wxFileDialog *DLGSavePkr;
		wxFileDialog *DLGExtFile;
		wxTextEntryDialog *DLGFileName;
		wxTextEntryDialog *DLGFolderName;
		wxFileDialog *DLGOpenPkr;
		wxFileDialog *DLGRepFile;
		wxButton *BTNSavePkr;
		wxButton *BTNOpenPkr;
		wxButton *BTNReplaceFile;
		wxButton *BTNDeleteFile;
		wxButton *BTNExtractFile;
		wxButton *BTNAddFile;
		wxButton *BTNExtDir;
		wxButton *BTNDelDir;
		wxButton *BTNAddDir;
		wxTextCtrl *EDTText;
		wxHtmlWindow *HTMLBmp;
		wxTextCtrl *EDTConsole;
		wxListBox *LSTFiles;
		wxListBox *LSTDirs;
		////GUI Control Declaration End
		enum
		{
			////GUI Enum Control ID Start
			ID_BTNNEWPKR = 1016,
			ID_BTNSAVEPKR = 1015,
			ID_BTNOPENPKR = 1014,
			ID_BTNREPLACEFILE = 1013,
			ID_BTNDELETEFILE = 1012,
			ID_BTNEXTRACTFILE = 1010,
			ID_BTNADDFILE = 1009,
			ID_BTNEXTDIR = 1008,
			ID_BTNDELDIR = 1007,
			ID_EDTADDDIR = 1006,
			ID_EDTTEXT = 1005,
			ID_HTMLBMP = 1004,
			ID_EDTCONSOLE = 1003,
			ID_LSTFILES = 1002,
			ID_LSTDIRS = 1001,
			////GUI Enum Control ID End
		};
		void OnClose(wxCloseEvent& event);
		void CreateGUIControls();
};

#endif

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