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

interface

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

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

  TeCanvas, TeEngine, StatChar, TeeCLVFunction, TeeBaseFuncEdit, TeePenDlg,
  TeeProcs;

type
  TMoneyFlowFuncEditor = class(TCLVFuncEditor)
    Label2: TLabel;
    CBSeriesStyle: TComboFlat;
    GroupBox1: TGroupBox;
    BUpColor: TButtonColor;
    BDownColor: TButtonColor;
    ButtonPen1: TButtonPen;
    procedure FormShow(Sender: TObject);
    procedure CBSeriesStyleChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

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

procedure TMoneyFlowFuncEditor.FormShow(Sender: TObject);
begin
  inherited;

  CBAccumulate.Visible:=False;

  if Assigned(IFunction) then
  begin
    CBSeriesStyle.ItemIndex := Ord(TMoneyFlowFunction(IFunction).CMFStyle);
    BUpColor.LinkProperty(IFunction,'UpColor'); // Do not localize
    BDownColor.LinkProperty(IFunction,'DownColor'); // Do not localize

    CBSeriesStyleChange(Sender);
  end;
end;

procedure TMoneyFlowFuncEditor.CBSeriesStyleChange(Sender: TObject);
begin
  BUpColor.Enabled:=(CBSeriesStyle.ItemIndex=0);
  BDownColor.Enabled:=BUpColor.Enabled;

  (IFunction as TMoneyFlowFunction).CMFStyle:= TCMFStyle(CBSeriesStyle.ItemIndex);

  case CBSeriesStyle.ItemIndex of
    1 : begin
          ButtonPen1.Enabled:=True;
          ButtonPen1.LinkPen((IFunction as TMoneyFlowFunction).AreaPen);
        end;
    3 : begin
          ButtonPen1.Enabled:=True;
          ButtonPen1.LinkPen((IFunction as TMoneyFlowFunction).HistogramPen);
        end;
    else
        ButtonPen1.Enabled:=False;
  end;
end;

initialization
  RegisterClass(TMoneyFlowFuncEditor);
end.
