/*
    CaPriCe Forever - Amstrad CPC 464/664/6128 emulator
    Copyright (C) 2014-2018 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 TFormFilesManagerH
#define TFormFilesManagerH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.Grids.hpp>
#include <Vcl.Menus.hpp>
#include <Vcl.StdCtrls.hpp>
#include "..\Emulator\TEmulator.h"
#include "..\Settings\TSettings.h"
#include <Vcl.Dialogs.hpp>


//---------------------------------------------------------------------------
class TFormFilesManager : public TForm
{
__published:	// Composants gérés par l'EDI
  TPanel *PanelSectorData;
  TPanel *PanelDrive;
  TComboBox *ComboBoxDrive;
  TStringGrid *StringGridSectors;
  TPanel *PanelSectorState;
  TComboBox *ComboBoxSides;
  TPageControl *PageControlData;
  TTabSheet *TabSheetCatalogue;
  TListBox *ListBoxCatalogueEntries;
  TPanel *PanelButtonViewer;
  TPanel *PanelButtonPreviousSector;
  TPanel *PanelButtonNextSector;
  TCheckBox *CheckBoxKeepHeader;
  TPanel *PanelButtonExport;
  TSaveDialog *SaveDialogFile;
  TPanel *PanelFreeSpace;
  TPanel *PanelButtonAdd;
  TOpenDialog *OpenDialogFile;
  TComboBox *ComboBoxFileSystem;
  TLabel *LabelFileSystem;
  TPanel *PanelButtonCopy;
  TPanel *PanelButtonDelete;
  TPanel *PanelButtonSectorViewExtent;
  void __fastcall FormShow(TObject *Sender);
  void __fastcall FormHide(TObject *Sender);
  void __fastcall ComboBoxDriveChange(TObject *Sender);
  void __fastcall StringGridSectorsDrawCell(TObject *Sender, int ACol,
          int ARow, TRect &Rect, TGridDrawState State);
  void __fastcall StringGridSectorsSelectCell(TObject *Sender, int ACol,
          int ARow, bool &CanSelect);
  void __fastcall ComboBoxSidesChange(TObject *Sender);
  void __fastcall FormResize(TObject *Sender);
  void __fastcall ComboBoxDriveDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall ComboBoxSidesDrawItem(TWinControl *Control, int Index, TRect &Rect,
          TOwnerDrawState State);
  void __fastcall PageControlDataDrawTab(TCustomTabControl *Control, int TabIndex,
          const TRect &Rect, bool Active);
  void __fastcall ListBoxCatalogueEntriesDrawItem(TWinControl *Control, int Index,
          TRect &Rect, TOwnerDrawState State);
  void __fastcall FormDestroy(TObject *Sender);
  void __fastcall ListBoxCatalogueEntriesClick(TObject *Sender);
  void __fastcall PanelButtonViewerClick(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 PanelButtonNextSectorClick(TObject *Sender);
  void __fastcall PanelButtonPreviousSectorClick(TObject *Sender);
  void __fastcall PanelButtonExportClick(TObject *Sender);
  void __fastcall ComboBoxFileSystemChange(TObject *Sender);
  void __fastcall ComboBoxFileSystemDrawItem(TWinControl *Control,
          int Index, TRect &Rect, TOwnerDrawState State);
  void __fastcall PanelButtonCopyClick(TObject *Sender);
  void __fastcall PanelButtonDeleteClick(TObject *Sender);
  void __fastcall PanelButtonSectorViewExtentClick(TObject *Sender);
  void __fastcall PanelButtonAddClick(TObject *Sender);
  void __fastcall ListBoxCatalogueEntriesKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);


private:	// Déclarations utilisateur
  //
  // Members
  //
  TEmulator* mEmulatorP;
  TSettings* mSettingsP;
  int mCurrentSide;
  tDrive* mStartDriveP;
  TColor mCellFrameColor;
  tDiskOperation* mDiskOperationP;
  TList* mSelectedEntryCHRNList;
  TList* mCatalogueCHRNList;
  bool mDiskViewerSynchro;
  //
  // Methods
  //
  AnsiString __fastcall GetTitle(void);
  void __fastcall WMMove(TMessage &Message);
  inline void __fastcall SetEmulator(TEmulator* Value) { mEmulatorP=Value; };
  void __fastcall SetSettings(TSettings* Value);
  inline void __fastcall SetStartDrive(tDrive* Value) { mStartDriveP=Value; };
  void __fastcall OnDiskEvent(tDrive* DriveP);
  void __fastcall ShowDriveContent(void);
  void __fastcall ShowSideContent(int TrackSelected);
  void __fastcall ShowSectorInfo(int TrackNumber, int SectorNumber);
  void __fastcall SelectSector(tULong CHRN);
  void __fastcall AddFile(AnsiString Filename);
  void __fastcall DropFile(TWMDropFiles &Message); // drag & drop handler


  //
  // Private Properties
  //
  __property AnsiString Title = { read=GetTitle };

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

  //
  // API
  //
  __fastcall TFormFilesManager(TComponent* Owner);

#pragma option push -vi-
BEGIN_MESSAGE_MAP
  MESSAGE_HANDLER(WM_MOVE, TMessage, WMMove);
  MESSAGE_HANDLER(WM_DROPFILES, TWMDropFiles, DropFile);
END_MESSAGE_MAP(TForm)
#pragma option pop
};
//---------------------------------------------------------------------------
extern PACKAGE TFormFilesManager *FormFilesManager;
//---------------------------------------------------------------------------
#endif
