{**************************************************}
{   TPointFigureSeries (derived from TOHLCSeries)  }
{   Copyright (c) 2002-2020 by Steema Software     }
{**************************************************}
unit TeePointFigure;
{$I TeeDefs.inc}

interface

uses {$IFNDEF LINUX}
     Windows,
     {$ENDIF}

     Forms, Controls, StdCtrls, Graphics, Classes, SysUtils,
     TeeProcs, OHLChart, TeEngine, Series;

type
  TPointFigureEditor = class(TForm)
    Label1: TLabel;
    EBoxSize: TEdit;
    Label2: TLabel;
    EReversal: TEdit;
    procedure FormShow(Sender: TObject);
    procedure EBoxSizeChange(Sender: TObject);
    procedure EReversalChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    UpForm      : TCustomForm;
    DownForm    : TCustomForm;
    PointFigure : TPointFigureSeries;
  public
    { Public declarations }
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

uses
  Chart, TeeProCo, TeePoEdi, TeCanvas;

procedure TPointFigureEditor.FormShow(Sender: TObject);
begin
  PointFigure:=TPointFigureSeries(Tag);

  if Assigned(PointFigure) then
  begin
    with PointFigure do
    begin
      EReversal.Text:=FloatToStr(ReversalAmount);
      EBoxSize.Text:=FloatToStr(BoxSize);
    end;

    if Assigned(Parent) then
    begin
      if not Assigned(UpForm) then
         UpForm:=TeeInsertPointerForm(Parent,PointFigure.UpSymbol,TeeMsg_Up);

      if not Assigned(DownForm) then
         DownForm:=TeeInsertPointerForm(Parent,PointFigure.DownSymbol,TeeMsg_Down);
    end;
  end;
end;

procedure TPointFigureEditor.EBoxSizeChange(Sender: TObject);
begin
  if Showing then
     PointFigure.BoxSize:=StrToFloatDef(EBoxSize.Text,PointFigure.BoxSize);
end;

procedure TPointFigureEditor.EReversalChange(Sender: TObject);
begin
  if Showing then
     PointFigure.ReversalAmount:=StrToFloatDef(EReversal.Text,PointFigure.ReversalAmount);
end;

procedure TPointFigureEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(DownForm);
  FreeAndNil(UpForm);
end;

initialization
  RegisterClass(TPointFigureEditor);
end.
