/*
    CaPriCe Forever - Amstrad CPC 464/664/6128 emulator
    Copyright (C) 2014-2015 by Frédéric Coste

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef TFormEmulatorSettingsH
#define TFormEmulatorSettingsH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.Grids.hpp>
#include <Vcl.StdCtrls.hpp>
#include "..\Settings\TSettings.h"
#include <Vcl.Dialogs.hpp>
#include <Vcl.ComCtrls.hpp>

//---------------------------------------------------------------------------
class TFormEmulatorSettings : public TForm
{
__published:	// Composants gérés par l'EDI
  TGroupBox *GroupBoxMachine;
  TLabel *LabelDevice;
  TComboBox *ComboBoxDevices;
  TLabel *LabelBrand;
  TComboBox *ComboBoxBrands;
  TCheckBox *CheckBoxUse64kMemoryExtension;
  TCheckBox *CheckBoxUse256kMemoryExtension;
  TCheckBox *CheckBoxUse256kSiliconDisc;
  TCheckBox *CheckBoxUseTechniMusique;
  TLabel *LabelCRTCType;
  TComboBox *ComboBoxCRTCType;
  TCheckBox *CheckBoxUseFloppyDrive;
  TCheckBox *CheckBoxUseFastFDC;
  TCheckBox *CheckBoxUsePlayCity;
  TCheckBox *CheckBoxUseMultiface2;
  TCheckBox *CheckBoxUse4MMemoryExtension;
  TCheckBox *CheckBoxUseDigiblaster;
  TGroupBox *GroupBoxSettings;
  TComboBox *ComboBoxSettings;
	TPanel *PanelButtonSettingsSave;
	TPanel *PanelButtonApply;
	TPanel *PanelButtonCancel;
	TCheckBox *CheckBoxUseXMEM;
	TCheckBox *CheckBoxBootXMEM;
	TSaveDialog *SaveDialog;
	TGroupBox *GroupBoxROMMapping;
	TStringGrid *StringGridROMMapping;
	TComboBox *ComboBoxAvailableROM;
	TCheckBox *CheckBoxUseXMASS;
	TPageControl *PageControlPeripherals;
	TTabSheet *TabSheetMultiface2;
	TTabSheet *TabSheetXMEM;
	TTabSheet *TabSheetXMass;
	TLabel *LabelMF2SelectROM;
	TComboBox *ComboBoxMF2Rom;
	TPanel *PanelButtonXMemView;
	TPanel *PanelButtonXMemRename;
	TPanel *PanelButtonXMemDelete;
	TPanel *PanelButtonXMassFile;
	TLabel *LabelXMassFilename;
	TOpenDialog *OpenDialog;
	TPanel *PanelButtonXMassCreate;
	TRadioButton *RadioButtonXMASSCreate512Mo;
	TRadioButton *RadioButtonXMASSCreate128Mo;
	TRadioButton *RadioButtonXMEM_Winbond;
	TRadioButton *RadioButtonXMEM_SST;
	TPanel *PanelButtonXMemCreate;
	TPanel *PanelButtonXMemFile;
	TLabel *LabelXMemFilename;
	TPanel *PanelButtonROMFile;
  void __fastcall FormShow(TObject *Sender);
  void __fastcall FormResize(TObject *Sender);
  void __fastcall StringGridROMMappingMouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
  void __fastcall FormHide(TObject *Sender);
  void __fastcall ComboBoxAvailableROMChange(TObject *Sender);
  void __fastcall StringGridROMMappingSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect);
  void __fastcall StringGridROMMappingKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
  void __fastcall CheckBoxUseFloppyDriveClick(TObject *Sender);
  void __fastcall ComboBoxDevicesChange(TObject *Sender);
  void __fastcall CheckBoxUse256kSiliconDiscClick(TObject *Sender);
  void __fastcall StringGridDrawCell(TObject *Sender, int ACol, int ARow,
          TRect &Rect, TGridDrawState State);
  void __fastcall ComboBoxCRTCTypeDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall ComboBoxDevicesDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall ComboBoxBrandsDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall ComboBoxDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall ComboBoxSettingsDrawItem(TWinControl *Control, int Index,
          TRect &Rect, TOwnerDrawState State);
  void __fastcall ComboBoxSettingsChange(TObject *Sender);
  void __fastcall CheckBoxUse4MMemoryExtensionClick(TObject *Sender);
  void __fastcall PanelButtonSettingsSaveClick(TObject *Sender);
  void __fastcall PanelButtonMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
  void __fastcall PanelButtonMouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
  void __fastcall PanelButtonApplyClick(TObject *Sender);
  void __fastcall PanelButtonCancelClick(TObject *Sender);
  void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
	void __fastcall CheckBoxUseXMEMClick(TObject *Sender);
	void __fastcall CheckBoxBootXMEMClick(TObject *Sender);
	void __fastcall PanelButtonXMemDeleteClick(TObject *Sender);
	void __fastcall PanelButtonXMemViewClick(TObject *Sender);
	void __fastcall PanelButtonXMemRenameClick(TObject *Sender);
	void __fastcall PageControlPeripheralsDrawTab(TCustomTabControl *Control, int TabIndex,
          const TRect &Rect, bool Active);
	void __fastcall PanelButtonXMassFileClick(TObject *Sender);
	void __fastcall PanelButtonXMassCreateClick(TObject *Sender);
	void __fastcall PanelButtonXMemCreateClick(TObject *Sender);
	void __fastcall PanelButtonXMemFileClick(TObject *Sender);
	void __fastcall PanelButtonROMFileClick(TObject *Sender);

private:	// Déclarations utilisateur
  //
  // Members
  //
	TSettings* mSettingsP;
	TEmulator* mEmulatorP;
	AnsiString mLowerROMFilename;
	AnsiString mXMemDirectory;
	AnsiString mXMemFilename;
	AnsiString mXMassDirectory;
	AnsiString mXMassFilename;
	AnsiString mLastAddedROMDirectory;
	AnsiString mSelectedROMDirectory;
	AnsiString mSelectedROMFilename;
	TStringList* mUpperROMFilenames;
	tUChar* mXMEMRomP;
	bool mXMEMRomModified;

  //
  // Methods
  //
  void __fastcall FillROMMapping(void);
  void __fastcall UpdateAvailableROMList(int Index);
  void __fastcall UpdateAvailableSettings(AnsiString SelectedFilename);
  inline void __fastcall SetSettings(TSettings* Value) { mSettingsP = Value; };
	inline void __fastcall SetEmulator(TEmulator* Value) { mEmulatorP = Value; };
	void __fastcall StoreSettings(TSettings* SettingsP);
  void __fastcall DisplaySettings(TSettings* SettingsP);
	void __fastcall UpdateSiliconDisc(void);
	void __fastcall UpdateXMEMROM(void);

public:		// Déclarations utilisateur
  __property TSettings* Settings = { write=SetSettings };
  __property TEmulator* Emulator = { write=SetEmulator };

  __fastcall TFormEmulatorSettings(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormEmulatorSettings *FormEmulatorSettings;
//---------------------------------------------------------------------------
#endif
