{********************************************}
{ TeeChart Pro Charting Library              }
{ Custom TeeFunction Editor                  }
{ Copyright (c) 2002-2020 by Steema Software }
{ All Rights Reserved                        }
{********************************************}
unit TeeCustomFuncEditor;
{$I TeeDefs.inc}

interface

uses
  {$IFNDEF LINUX}
  Windows, Messages,
  {$ENDIF}
  SysUtils, Classes,

  Graphics, Controls, Forms, Dialogs, StdCtrls,

  TeEngine, TeeFunci, TeeBaseFuncEdit, ExtCtrls;

type
  TCustomFunctionEditor = class(TBaseFunctionEditor)
    Label1: TLabel;
    EStart: TEdit;
    Label2: TLabel;
    EStep: TEdit;
    ENum: TEdit;
    Label3: TLabel;
    procedure EStartChange(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 TCustomFunctionEditor.EStartChange(Sender: TObject);
begin
  EnableApply;
end;

procedure TCustomFunctionEditor.ApplyFormChanges;
begin
  inherited;

  with TCustomTeeFunction(IFunction) do
  begin
    BeginUpdate;
    try
      StartX:=StrToFloat(EStart.Text);
      Period:=StrToFloat(EStep.Text);
      NumPoints:=StrToInt(ENum.Text);
    finally
      EndUpdate;
    end;
  end;
end;

procedure TCustomFunctionEditor.SetFunction;
begin
  inherited;

  with TCustomTeeFunction(IFunction) do
  begin
    EStart.Text:=FloatToStr(StartX);
    EStep.Text:=FloatToStr(Period);
    ENum.Text:=IntToStr(NumPoints);
  end;
end;

initialization
  RegisterClass(TCustomFunctionEditor);
end.

