{**********************************************}
{   TCLVFunction (Accumulation/Distribution)   }
{   Copyright (c) 2002-2020 by Steema Software }
{**********************************************}
unit TeeCLVFunction;
{$I TeeDefs.inc}

interface

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

  Graphics, Controls, Forms, Dialogs, StdCtrls,
  OHLChart, TeEngine, TeeProcs, TeCanvas, Chart, TeeBaseFuncEdit, StatChar,
  ExtCtrls;

type
  TCLVFuncEditor = class(TBaseFunctionEditor)
    Label1: TLabel;
    CBVolume: TComboFlat;
    CBAccumulate: TCheckBox;
    procedure CBAccumulateClick(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
  TeeConst;

procedure TCLVFuncEditor.ApplyFormChanges;
begin
  inherited;

  with TCLVFunction(IFunction) do
  begin
    BeginUpdate;
    try
      Volume:=TChartSeries(CBVolume.SelectedObject);
      Accumulate:=CBAccumulate.Checked;
    finally
      EndUpdate;
    end;
  end;
end;

procedure TCLVFuncEditor.CBAccumulateClick(Sender: TObject);
begin
  EnableApply;
end;

procedure TCLVFuncEditor.SetFunction;
begin
  inherited;

  with TCLVFunction(IFunction) do
  begin
    CBVolume.ItemIndex:=CBVolume.Items.IndexOfObject(Volume);
    CBAccumulate.Checked:=Accumulate;
  end;

  FillSeries(CBVolume.Items);

  with CBVolume do
  begin
    Items.InsertObject(0,TeeMsg_None,nil);
    Items.Delete(Items.IndexOfObject(IFunction.ParentSeries));
    ItemIndex:=Items.IndexOfObject(TCLVFunction(IFunction).Volume);
  end;
end;

initialization
  RegisterClass(TCLVFuncEditor);
end.
