//---------------------------------------------------------------------------
/*
Remote Train Control Program for Windows

© Copyright 2021 by Mark DiVecchio

    This file is part of Remote Train Control.

    Remote Train Control 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.

    Remote Train Control 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 Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

*/
// Home Page : http://www.silogic.com/trains/RTC_Running.html
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef SignalH
#define SignalH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "HideButton.h"
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <Grids.hpp>
#include <Menus.hpp>
#include "_GClass.hpp"
#include "AbLED.hpp"

#include "LED3Panel.h"
#include "LED2Panel.h"
#include "LED1Panel.h"
#include "RTC_Help.h"



// Signal Head Types
#define Hd3LED 3
#define Hd2LED 2
#define Hd1LED 1

// maximum number of Signals
#define SIGNALLIMIT 200
// special meaning flags
#define SIGNALFLAG SIGNALLIMIT	// this is the Signal Aspect when set manually on the Signal Window

// Flaggrid File Rows
#define SIGNAL_LABEL_ROW 0
#define SIGNAL_TOPROW 1

// columns in SignalGrid
#define SIGNALNUM 0
#define SIGNALCOL 1
#define SIGNALROW 2
#define SIGNALASPECT 3
#define SIGNALNUMLIGHTS 4
#define SIGNALNUMBERPLATE 5
#define SIGNALNAME 6
#define SIGNALCURRENT 7
#define SIGNALHOME 8
#define SIGNALDISTANT 9

//---------------------------------------------------------------------------
class TFixedSignalFormX : public TForm
{
__published:	// IDE-managed Components
	TPanel *TopPanel;
	TStringGrid *SignalGrid;
	TButton *EditGridButton;
	TLabel *SignalN;
	TPopupMenu *SignalPopupMenu;
	TMenuItem *CopytoClipboard1;
	TImage *Copyright;
	THideButton *HideButton1;
	TShape *Shape1;
	TShape *Shape2;
	TMenuItem *Info;
	TMemo *Information;
	TCheckBox *ShowText;
	TLabel *WBLabel;
	TLabel *EBLabel;
	TCheckBox *Absolute;
	void __fastcall FormActivate(TObject *Sender);
	void __fastcall FormDeactivate(TObject *Sender);
	void __fastcall FormClick(TObject *Sender);
	void __fastcall HideButton1Click(TObject *Sender);
	void __fastcall CopyrightClick(TObject *Sender);
	void __fastcall EditGridButtonClick(TObject *Sender);
	void __fastcall SignalGridKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
	void __fastcall SignalGridMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
	void __fastcall CopytoClipboard1Click(TObject *Sender);
	void __fastcall InfoClick(TObject *Sender);
	void __fastcall ShowTextClick(TObject *Sender);

private:	// User declarations

    bool LocalTransparencyOverride;
    String RegFileRootKey;
    String SignalDataFile;

    void __fastcall LoadSignalData(void);
	void __fastcall ConstructSignal(int SignalNo, int Col, int Row, String SignalName, int Heads, int Aspect,
	    int NumPlate, int Current, int Home, int Distant);
    String INIFileName;

public:		// User declarations
	__fastcall TFixedSignalFormX(TComponent* Owner);
    __fastcall ~TFixedSignalFormX(void);

    void __fastcall ShowIt();
    String __fastcall GetSignalName(int SignalNo, int &iNumberPlate);
    bool Corrupt;	// data file is corrupt

    int __fastcall CreateSignal(int SignalNo, int Col, int Row, String SignalName, int Aspect, int Heads, int NumberPlate);
    int __fastcall SetAspect(int SignalNo, int Aspect);
    int __fastcall GetAspect(int SignalNo);
    void __fastcall DeleteAllSignals(void);

    HWND ParentHandle; 		// accessed by Train_Control.cpp

    bool __fastcall Lights(TPanel * Head, int Aspect);
    bool __fastcall Reset(TPanel * Head);
    bool __fastcall SignalName(TPanel * Head, String sName, int iNumberPlate);

    TRTCHelp *SignalHelp;

protected:


};
//---------------------------------------------------------------------------
extern PACKAGE TFixedSignalFormX *FixedSignalFormX;
//---------------------------------------------------------------------------
#endif
