unit FMXTee.Editor.Series.Equalizer;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,  
  FMX.Types, FMX.Controls, FMX.Forms,FMX.Dialogs, FMXTee.Procs,
  {$IFNDEF UPTOXE3}  
  FMX.StdCtrls, 
  {$ENDIF}  
  {$IFNDEF UPTOXE7}
  FMX.SpinBox, FMX.Controls.Presentation, FMX.EditBox,
  {$ENDIF}
  {$IFDEF D19}
  FMX.Graphics,
  {$ENDIF}
  FMXTee.Series.Equalizer, FMXTee.Editor.Series.CustomBar,
  FMX.Colors, FMX.TabControl, FMX.Edit,FMXTee.Editor.Stroke,FMXTee.Editor.Series.Pointer;

type
  TEqualizerSeriesEditor = class(TForm)
    Label3: TLabel;
    TabControl1: TTabControl;
    TabOptions: TTabItem;
    Label1: TLabel;
    UDDInterval: TSpinBox;
    CBDHigh: TCheckBox;
    StyleBook1: TStyleBook;
    EDDownStep: TEdit;
    procedure FormActivate(Sender: TObject);
    procedure AddEditors;
    procedure UDDIntervalChange(Sender: TObject);
    procedure CBDHighChange(Sender: TObject);
    procedure EDDownStepChange(Sender: TObject);
  private
    EqualizerSeries : TEqualizerSeries;
    FBarEditor : TForm;
    FPointEditor : TForm;
  public
  end;

var
  EqualizerSeriesSeriesEditor: TEqualizerSeriesEditor;

implementation

{$R *.fmx}

uses
  FMXTee.Constants;

procedure TEqualizerSeriesEditor.AddEditors;
var TabBar, TabPoint : TTabItem;
begin

  if not Assigned(FBarEditor) then
  begin
    FBarEditor:=TBarSeriesEditor.CreateEditor(Self,EqualizerSeries);

    TabBar:=TTabItem.Create(Self);
    TabBar.Text:=TeeMsg_GalleryBar;
    TabControl1.AddObject(TabBar);

    EmbeddForm(FBarEditor,TabBar);

    TabBar.Index:=1;
  end;

  if not Assigned(FPointEditor) then
  begin
    FPointEditor:=TSeriesPointerEditor.CreateEditor(Self,EqualizerSeries.HighMarker.Pointer);

    TabPoint:=TTabItem.Create(Self);
    TabPoint.Text:=TeeMsg_GalleryPoint;
    TabControl1.AddObject(TabPoint);

    EmbeddForm(FPointEditor,TabPoint);

    TabPoint.Index:=2;
  end;

end;

procedure TEqualizerSeriesEditor.CBDHighChange(Sender: TObject);
begin
  EqualizerSeries.DegradeHigh := CBDHigh.IsChecked;
end;

procedure TEqualizerSeriesEditor.EDDownStepChange(Sender: TObject);
begin
  EqualizerSeries.DownStep := StrToFloat(EDDownStep.Text);
end;

procedure TEqualizerSeriesEditor.FormActivate(Sender: TObject);
begin
  EqualizerSeries:=TEqualizerSeries(TagObject);

  if Assigned(EqualizerSeries) then
  begin
    With EqualizerSeries do
    begin
      UDDInterval.Value := DegradeInterval;
      EDDownStep.Text := FloatToStr(DownStep);
      CBDHigh.IsChecked := EqualizerSeries.DegradeHigh;
    end;
  end;

  AddEditors;
end;

procedure TEqualizerSeriesEditor.UDDIntervalChange(Sender: TObject);
begin
  EqualizerSeries.DegradeInterval := Round(UDDInterval.Value);
end;

initialization
  RegisterSeriesEditor(TEqualizerSeriesEditor);

end.
