{**********************************************}
{   TOBVFunction (On Balance Volume)           }
{   Copyright (c) 2002-2020 by Steema Software }
{**********************************************}
unit TeeOBVFunction;
{$I TeeDefs.inc}

interface

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

  Graphics, Controls, Forms, Dialogs, StdCtrls,

  OHLChart, TeEngine, TeeProcs, TeCanvas, Chart, TeeBaseFuncEdit, ExtCtrls;

type
  TOBVFuncEditor = class(TBaseFunctionEditor)
    Label1: TLabel;
    CBVolume: TComboFlat;
    procedure CBVolumeChange(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;

procedure TOBVFuncEditor.ApplyFormChanges;
begin
  inherited;
  TOBVFunction(IFunction).Volume:=TChartSeries(CBVolume.SelectedObject);
end;

procedure TOBVFuncEditor.SetFunction;
begin
  inherited;

  FillSeries(CBVolume.Items);

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

procedure TOBVFuncEditor.CBVolumeChange(Sender: TObject);
begin
  EnableApply;
end;

initialization
  RegisterClass(TOBVFuncEditor);
end.
