{***********************************************}
{   TPVOFunction (Percentage Volume Oscillator) }
{   Copyright (c) 2002-2020 by Steema Software  }
{***********************************************}
unit TeePVOFunction;
{$I TeeDefs.inc}

interface

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

  Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls,

  TeEngine, TeCanvas, Chart, TeeBaseFuncEdit, StatChar, ExtCtrls;

type
  TPVOFuncEditor = class(TBaseFunctionEditor)
    Label2: TLabel;
    EPeriod: TEdit;
    UDPeriod: TUpDown;
    Label1: TLabel;
    Edit1: TEdit;
    UDPeriod2: TUpDown;
    CBPercent: TCheckBox;
    procedure EPeriodChange(Sender: TObject);
    procedure CBPercentClick(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}

uses TeeProCo, TeeConst;

{ TPVOFuncEditor }
procedure TPVOFuncEditor.ApplyFormChanges;
begin
  inherited;

  with TPVOFunction(IFunction) do
  begin
    BeginUpdate;
    try
      Period:=UDPeriod.Position;
      Period2:=UDPeriod2.Position;
      Percentage:=CBPercent.Checked;
    finally
      EndUpdate;
    end;
  end;
end;

procedure TPVOFuncEditor.SetFunction;
begin
  inherited;
  with TPVOFunction(IFunction) do
  begin
    UDPeriod.Position:=Round(Period);
    UDPeriod2.Position:=Round(Period2);
    CBPercent.Checked:=Percentage;
  end;
end;

procedure TPVOFuncEditor.EPeriodChange(Sender: TObject);
begin
  EnableApply;
end;

procedure TPVOFuncEditor.CBPercentClick(Sender: TObject);
begin
  EnableApply;
end;

initialization
  RegisterClass(TPVOFuncEditor);
end.
