{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Series.Renko;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Colors, FMX.TabControl,
  FMX.StdCtrls,
  FMXTee.Editor.Stroke, FMXTee.Editor.Brush, FMXTee.Series.Renko;

type
  TRenkoSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabOptions: TTabItem;
    CBColorUp: TComboColorBox;
    CBDraw3D: TCheckBox;
    Label1: TLabel;
    TBBoxSize: TTrackBar;
    LSize: TLabel;
    Label2: TLabel;
    TBTransp: TTrackBar;
    LTransp: TLabel;
    TabBorder: TTabItem;
    TabPattern: TTabItem;
    Label3: TLabel;
    Label4: TLabel;
    CBColorDown: TComboColorBox;
    procedure FormActivate(Sender: TObject);
    procedure CBDraw3DChange(Sender: TObject);
    procedure TBBoxSizeChange(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
  private
    { Private declarations }
    FBorder : TStrokeEditor;
    FBrush : TBrushEditor;
    Renko : TRenkoSeries;
  public
    { Public declarations }
  end;

var
  RenkoSeriesEditor: TRenkoSeriesEditor;

implementation

{$R *.fmx}

procedure TRenkoSeriesEditor.CBDraw3DChange(Sender: TObject);
begin
  Renko.Draw3D:=CBDraw3D.IsChecked;
end;

procedure TRenkoSeriesEditor.FormActivate(Sender: TObject);
begin
  Renko:=TRenkoSeries(TagObject);

  if Assigned(Renko) then
  with Renko do
  begin
    CBDraw3D.IsChecked:=Draw3D;
    CBColorUp.Color:=UpSwingColor;
    CBColorDown.Color:=DownSwingColor;

    TBBoxSize.Value:=BoxSize;

    TBTransp.Value:=Renko.Transparency;
    LSize.Text:=floattostr(renko.BoxSize);
    LTransp.Text:=IntToStr(renko.Transparency);
  end;
end;

procedure TRenkoSeriesEditor.TabControl1Change(Sender: TObject);
begin
  if (TabControl1.ActiveTab=TabBorder) and (not Assigned(FBorder)) then
     FBorder:=TStrokeEditor.InsertForm(Renko.Pen,TabBorder)
  else
  if (TabControl1.ActiveTab=TabPattern) and (not Assigned(FBrush)) then
     FBrush:=TBrushEditor.InsertForm(Renko.Brush,TabPattern);
end;

procedure TRenkoSeriesEditor.TBBoxSizeChange(Sender: TObject);
begin
  Renko.BoxSize:=TBBoxSize.Value;
end;

procedure TRenkoSeriesEditor.TBTranspChange(Sender: TObject);
begin
  Renko.Transparency:=Round(TBTransp.Value);
  LTransp.Text:=IntToStr(Renko.Transparency);
end;

initialization
  RegisterClass(TRenkoSeriesEditor);
end.
