unit TeeEqualizerEdit;

interface

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

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

   Chart, Series, TeeEqualizerSeries, TeeProcs, TeCanvas, TeePoEdi;

type
  TEqualizerSeriesEditor = class(TForm)
    lblDegradeInterval: TLabel;
    UDDegradeInt: TUpDown;
    edDegradeInt: TEdit;
    LblDownStep: TLabel;
    EdDownStep: TEdit;
    cbxDegradeHigh: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure edDegradeIntChange(Sender: TObject);
    procedure EdDownStepChange(Sender: TObject);
    procedure cbxDegradeHighClick(Sender: TObject);
  private
    { Private declarations }
    EqualizerSeries : TEqualizerSeries;
    FBarForm : TCustomForm;
    FPointerForm : TCustomForm;
  public
    { Public declarations }
  end;

var
  EqualizerSeriesEditor : TEqualizerSeriesEditor;

implementation

Uses TeeConst, TeeProCo, TeeBarEdit, TeeEdiSeri, TeePenDlg, TeeCustEdit;

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

procedure TEqualizerSeriesEditor.FormCreate(Sender: TObject);
begin
  BorderStyle:=TeeBorderStyle;
end;

Type TEQBarEditor = class(TBarSeriesEditor);

procedure TEqualizerSeriesEditor.FormShow(Sender: TObject);
begin
  EqualizerSeries:=TEqualizerSeries(Tag);

  if Assigned(EqualizerSeries) then
  begin
    if not Assigned(FBarForm) then
    begin
      FBarForm:=TFormTeeSeries.InsertSeriesForm(Parent,TBarSeriesEditor,
                                                 1,TeeMsg_GalleryBar,
                                                 EqualizerSeries);
      TEQBarEditor(FBarForm).FIncludeStackEditor := False;
    end;

    if not Assigned(FPointerForm) then
    begin
      FPointerForm:=TeeInsertPointerForm(Parent,EqualizerSeries.HighMarker.Pointer,TeeMsg_GalleryPoint);
    end;
  end;

  UDDegradeInt.Position := EqualizerSeries.DegradeInterval;
  edDegradeInt.Text:= IntToStr(UDDegradeInt.Position);
  EdDownStep.Text := FloatToStr(EqualizerSeries.DownStep);
  cbxDegradeHigh.Checked := EqualizerSeries.DegradeHigh;
end;

procedure TEqualizerSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FBarForm);
end;

procedure TEqualizerSeriesEditor.edDegradeIntChange(Sender: TObject);
begin
  if assigned(EqualizerSeries) then
  Begin
    EqualizerSeries.DegradeInterval := StrToInt(edDegradeInt.Text);
    UDDegradeInt.Position := EqualizerSeries.DegradeInterval;
  end;
end;

procedure TEqualizerSeriesEditor.EdDownStepChange(Sender: TObject);
begin
  if assigned(EqualizerSeries) then
    EqualizerSeries.DownStep := StrToFloat(EdDownStep.Text);
end;

procedure TEqualizerSeriesEditor.cbxDegradeHighClick(Sender: TObject);
begin
  if assigned(EqualizerSeries) then
    EqualizerSeries.DegradeHigh := cbxDegradeHigh.Checked;
end;

initialization
  RegisterClass(TEqualizerSeriesEditor);
end.
