{********************************************}
{     TeeChart Pro Charting Library          }
{ Copyright (c) 1995-2020 by Steema Software }
{         All Rights Reserved                }
{********************************************}
unit TeeMACDFuncEdit;
{$I TeeDefs.inc}

interface

uses
  {$IFNDEF LINUX}
  Windows, Messages,
  {$ENDIF}
  SysUtils, Classes,
  Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls,

  TeCanvas, TeePenDlg, StatChar, TeeBaseFuncEdit;

type
  TMACDFuncEditor = class(TBaseFunctionEditor)
    Label3: TLabel;
    ENum: TEdit;
    UpDown1: TUpDown;
    Label1: TLabel;
    Edit1: TEdit;
    UpDown2: TUpDown;
    Label2: TLabel;
    Edit2: TEdit;
    UpDown3: TUpDown;
    BHistogram: TButtonPen;
    BMACDExp: TButtonPen;
    BMACD: TButtonPen;
    procedure ENumChange(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure ApplyFormChanges; override;
    procedure SetFunction; override;
  public
    { Public declarations }
  end;

implementation

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

procedure TMACDFuncEditor.ApplyFormChanges;
begin
  inherited;

  with TMACDFunction(IFunction) do
  begin
    BeginUpdate;
    try
      Period:=UpDown1.Position;
      Period2:=UpDown2.Position;
      Period3:=UpDown3.Position;
    finally
      EndUpdate;
    end;
  end;
end;

procedure TMACDFuncEditor.ENumChange(Sender: TObject);
begin
  EnableApply;
end;

procedure TMACDFuncEditor.SetFunction;
begin
  inherited;
  with TMACDFunction(IFunction) do
  begin
    UpDown1.Position:=Round(Period);
    UpDown2.Position:=Round(Period2);
    UpDown3.Position:=Round(Period3);
    BHistogram.LinkPen(HistogramPen);
    BMACD.LinkPen(MACDPen);
    BMACDExp.LinkPen(MACDExpPen);
  end;
end;

initialization
  RegisterClass(TMACDFuncEditor);
end.
