/*
    CaPriCe Forever - Amstrad CPC 464/664/6128 emulator
    Copyright (C) 2014-2016 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 TFormDiskCatalogH
#define TFormDiskCatalogH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.StdCtrls.hpp>
#include "..\Settings\TSettings.h"
#include "..\Emulator\TEmulator.h"
//---------------------------------------------------------------------------
class TFormDiskCatalog : public TForm
{
__published:	// Composants gérés par l'EDI
  TGroupBox *GroupBoxCatalogue;
  TListBox *ListBoxCatalogEntries;
  TPanel *PanelRUN;
  TPanel *PanelCancel;
  TPanel *PanelLOAD;
  TPanel *PanelCPM;
  TLabel *LabelUser;
  TPanel *PanelFormatUser;
  TPanel *PanelUser;
  TEdit *EditUser;
  TCheckBox *CheckBoxReset;
  void __fastcall FormShow(TObject *Sender);
  void __fastcall ListBoxCatalogEntriesDblClick(TObject *Sender);
  void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
  void __fastcall ListBoxCatalogEntriesDrawItem(TWinControl *Control, int Index,
          TRect &Rect, TOwnerDrawState State);
  void __fastcall FormMouseWheelUp(TObject *Sender, TShiftState Shift, TPoint &MousePos,
          bool &Handled);
  void __fastcall FormMouseWheelDown(TObject *Sender, TShiftState Shift, TPoint &MousePos,
          bool &Handled);
  void __fastcall PanelCancelClick(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 PanelRUNClick(TObject *Sender);
  void __fastcall PanelLOADClick(TObject *Sender);
  void __fastcall PanelCPMClick(TObject *Sender);
  void __fastcall FormKeyPress(TObject *Sender, System::WideChar &Key);
  void __fastcall PanelFormatUserClick(TObject *Sender);
  void __fastcall EditUserChange(TObject *Sender);
  
private:	// Déclarations utilisateur
  //
  // Members
  //
  TSettings* mSettingsP;
  TEmulator* mEmulatorP;
  bool mRUNRequested;
  bool mLOADRequested;
  bool mCPMRequested;
  int mNbMinEntries;
  int mSizeDiff;
  tUChar mUser;

  //
  // Methods
  //
  void __fastcall SetSettings(TSettings* Value);
  inline void __fastcall SetEmulator(TEmulator* Value) { mEmulatorP=Value; };
  AnsiString __fastcall GetSelectedFilename(void);
  inline bool __fastcall GetRUNRequested(void) { return mRUNRequested; };
  inline bool __fastcall GetLOADRequested(void) { return mLOADRequested; };
  inline bool __fastcall GetCPMRequested(void) { return mCPMRequested; };
  inline void __fastcall SetLOADVisible(bool Value) { PanelLOAD->Visible = Value; };
  inline void __fastcall SetUser(tUChar Value) { mUser=Value; };
  inline tUChar __fastcall GetUser(void) { return mUser; };
  inline bool __fastcall GetReset(void) { return CheckBoxReset->Checked; };
  inline void __fastcall SetReset(bool Value) { CheckBoxReset->Checked = Value; };
  void __fastcall PopulateCatalogue(void);

public:		// Déclarations utilisateur
  //
  // Properties
  //
  __property TSettings* Settings = { write=SetSettings };
  __property TEmulator* Emulator = { write=SetEmulator };
  __property AnsiString SelectedFilename = { read=GetSelectedFilename };
  __property bool RUNRequested = { read=GetRUNRequested };
  __property bool LOADRequested = { read=GetLOADRequested };
  __property bool CPMRequested = { read=GetCPMRequested };
  __property bool LOADVisible = { write=SetLOADVisible };
  __property tUChar User = { read=GetUser, write=SetUser };
  __property bool Reset = { read=GetReset, write=SetReset };

  //
  // API
  //
  __fastcall TFormDiskCatalog(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormDiskCatalog *FormDiskCatalog;
//---------------------------------------------------------------------------
#endif
