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

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  FMX.ListBox, FMX.Dialogs, FMXTee.Series, FMXTee.Editor.Stroke, FMX.Edit,
  FMX.Colors, FMX.TabControl, FMXTee.Engine;

type
  TFastLineSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabItem1: TTabItem;
    TabStroke: TTabItem;
    Label2: TLabel;
    CBDrawAll: TCheckBox;
    GBStair: TGroupBox;
    CBStairs: TCheckBox;
    CBInvStairs: TCheckBox;
    CBNulls: TComboBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    CBDrawAllStyle: TComboBox;
    ListBoxItem4: TListBoxItem;
    ListBoxItem5: TListBoxItem;
    Label1: TLabel;
    CBDrawStyle: TComboBox;
    procedure CBNullsChange(Sender: TObject);
    procedure CBDrawAllStyleChange(Sender: TObject);
    procedure CBDrawAllChange(Sender: TObject);
    procedure CBStairsChange(Sender: TObject);
    procedure CBInvStairsChange(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CBDrawStyleChange(Sender: TObject);
  private
   { Private declarations }
    Fast : TFastLineSeries;
    StrokeEditor : TStrokeEditor;

    procedure RefreshFast(const AFast:TFastLineSeries);
  public
   { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Procs;

procedure TFastLineSeriesEditor.CBDrawAllChange(Sender: TObject);
begin
  Fast.DrawAllPoints:=CBDrawAll.IsChecked;
end;

procedure TFastLineSeriesEditor.CBStairsChange(Sender: TObject);
begin
  Fast.Stairs:=CBStairs.IsChecked;
end;

procedure TFastLineSeriesEditor.FormActivate(Sender: TObject);
begin
  RefreshFast(TFastLineSeries(TagObject));
end;

procedure TFastLineSeriesEditor.FormCreate(Sender: TObject);
begin
  StrokeEditor:=TStrokeEditor.Create(Self);

  StrokeEditor.CBVisible.Visible:=False;
  StrokeEditor.Panel1.Visible:=False;

  EmbeddForm(StrokeEditor,TabStroke);

  TabControl1.ActiveTab:=TabItem1;
end;

procedure TFastLineSeriesEditor.RefreshFast(const AFast: TFastLineSeries);
begin
  if Fast<>AFast then
  begin
    Fast:=AFast;

    StrokeEditor.RefreshPen(Fast.Pen);

    CBStairs.IsChecked:=Fast.Stairs;
    CBInvStairs.IsChecked:=Fast.InvertedStairs;
    CBDrawAll.IsChecked:=Fast.DrawAllPoints;
    CBDrawAllStyle.ItemIndex:=Ord(Fast.DrawAllPointsStyle);
    CBDrawStyle.ItemIndex:=Ord(Fast.DrawStyle);
    CBNulls.ItemIndex:=Ord(Fast.TreatNulls);
  end;
end;

procedure TFastLineSeriesEditor.CBInvStairsChange(Sender: TObject);
begin
  Fast.InvertedStairs:=CBInvStairs.IsChecked;
end;

procedure TFastLineSeriesEditor.CBNullsChange(Sender: TObject);
begin
  Fast.TreatNulls:=TTreatNullsStyle(CBNulls.ItemIndex);
end;

procedure TFastLineSeriesEditor.CBDrawAllStyleChange(Sender: TObject);
begin
  Fast.DrawAllPointsStyle:=TDrawAllPointsStyle(CBDrawAllStyle.ItemIndex);
end;

procedure TFastLineSeriesEditor.CBDrawStyleChange(Sender: TObject);
begin
  Fast.DrawStyle:=TFastLineDrawStyle(CBDrawStyle.ItemIndex);
end;

initialization
  RegisterSeriesEditor(TFastLineSeriesEditor);
end.
