unit FMXTee.Editor.Series.Area;

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  FMX.Edit, FMX.ListBox, FMX.Dialogs, FMX.TabControl, FMXTee.Series,
  FMXTee.RadioGroup;

type
  TAreaSeriesEditor = class(TForm)
    PageControl1: TTabControl;
    TabSheet1: TTabItem;
    GroupBox2: TGroupBox;
    CBStairs: TCheckBox;
    BAreaLinesPen: TButton;
    BAreaLinePen: TButton;
    CBInvStairs: TCheckBox;
    BPattern: TButton;
    Button1: TButton;
    CBSmoothed: TCheckBox;
    GroupBox5: TGroupBox;
    UDTransp: TSpinBox;
    CBDark3D: TCheckBox;
    GroupBox1: TGroupBox;
    CBColorEach: TCheckBox;
    BAreaColor: TButton;
    GroupBox4: TGroupBox;
    CBNulls: TComboBox;
    TabSheet2: TTabItem;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    CBUseOrigin: TCheckBox;
    UDOrigin: TSpinBox;
    GroupBox6: TGroupBox;
    UDGroup: TSpinBox;
    RGMultiArea: TRadioGroup;
    procedure BPatternClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure CBNullsChange(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BAreaColorClick(Sender: TObject);
    procedure BAreaLinesPenClick(Sender: TObject);
    procedure BAreaLinePenClick(Sender: TObject);
    procedure CBColorEachChange(Sender: TObject);
    procedure CBDark3DChange(Sender: TObject);
    procedure CBSmoothedChange(Sender: TObject);
    procedure CBInvStairsChange(Sender: TObject);
    procedure CBStairsChange(Sender: TObject);
    procedure UDTranspChange(Sender: TObject);
    procedure CBUseOriginChange(Sender: TObject);
    procedure UDOriginChange(Sender: TObject);
    procedure UDGroupChange(Sender: TObject);
    procedure RGMultiAreaChange(Sender: TObject);
    procedure UDTranspApplyStyleLookup(Sender: TObject);
  private
   { Private declarations }
    Area : TAreaSeries;

    procedure RefreshArea(AArea:TAreaSeries);
  public
   { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Procs, FMXTee.Canvas, FMXTee.Engine, FMXTee.Editor.Brush, FMXTee.Editor.Stroke;

procedure TAreaSeriesEditor.FormActivate(Sender: TObject);
begin
  if not Assigned(Area) then
     RefreshArea(TAreaSeries(TagObject));
end;

procedure TAreaSeriesEditor.CBStairsChange(Sender: TObject);
begin
  Area.Stairs:=CBStairs.IsChecked;
end;

procedure TAreaSeriesEditor.CBInvStairsChange(Sender: TObject);
begin
  Area.InvertedStairs:=CBInvStairs.IsChecked;
end;

procedure TAreaSeriesEditor.BAreaColorClick(Sender: TObject);
begin
  Area.Color:=EditColor(Self, Area.Color);
end;

procedure TAreaSeriesEditor.BAreaLinePenClick(Sender: TObject);
begin
  TStrokeEditor.Edit(Self, Area.LinePen);
end;

procedure TAreaSeriesEditor.BAreaLinesPenClick(Sender: TObject);
begin
  TStrokeEditor.Edit(Self, Area.AreaLinesPen);
end;

procedure TAreaSeriesEditor.BPatternClick(Sender: TObject);
begin
  TBrushEditor.Edit(Self, Area.Brush);
end;

procedure TAreaSeriesEditor.Button1Click(Sender: TObject);
begin
  TBrushEditor.Edit(Self, Area.AreaChartBrush);
end;

procedure TAreaSeriesEditor.CBSmoothedChange(Sender: TObject);
begin
  {$IFNDEF TEELITEEMB}
  Area.Smoothed:=CBSmoothed.IsChecked;
  {$ENDIF}
end;

procedure TAreaSeriesEditor.CBDark3DChange(Sender: TObject);
begin
  Area.Dark3D:=CBDark3D.IsChecked;
end;

procedure TAreaSeriesEditor.CBColorEachChange(Sender: TObject);
begin
  Area.ColorEachPoint:=CBColorEach.IsChecked;
end;

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

procedure TAreaSeriesEditor.RefreshArea(AArea: TAreaSeries);
begin
  Area:=AArea;

  CBStairs.IsChecked:=Area.Stairs;
  CBInvStairs.IsChecked:=Area.InvertedStairs;

  {$IFDEF TEELITEEMB}
  CBSmoothed.Visible:=False;
  {$ELSE}
  CBSmoothed.IsChecked:=Area.Smoothed;
  {$ENDIF}

  CBDark3D.IsChecked:=Area.Dark3D;
  CBColorEach.IsChecked:=Area.ColorEachPoint;
  CBUseOrigin.IsChecked:=Area.UseYOrigin;
  CBNulls.ItemIndex:=Ord(Area.TreatNulls);

  UDTransp.Value:=Area.Transparency;
  UDGroup.Value:=Area.StackGroup;
  UDOrigin.Value:=Area.YOrigin;

  RGMultiArea.ItemIndex:=Ord(Area.MultiArea);
end;

procedure TAreaSeriesEditor.RGMultiAreaChange(Sender: TObject);
begin
  Area.MultiArea:=TMultiArea(RGMultiArea.ItemIndex);
end;

procedure TAreaSeriesEditor.UDGroupChange(Sender: TObject);
begin
  Area.StackGroup:=Round(UDGroup.Value);
end;

procedure TAreaSeriesEditor.UDOriginChange(Sender: TObject);
begin
  Area.YOrigin:=UDOrigin.Value;
end;

procedure TAreaSeriesEditor.UDTranspApplyStyleLookup(Sender: TObject);
begin
  TStrokeEditor.SetRepeatClick(UDTransp,True);
end;

procedure TAreaSeriesEditor.UDTranspChange(Sender: TObject);
begin
  Area.Transparency:=Round(UDTransp.Value);
end;

procedure TAreaSeriesEditor.CBUseOriginChange(Sender: TObject);
begin
  Area.UseYOrigin:=CBUseOrigin.IsChecked;
end;

initialization
  RegisterSeriesEditor(TAreaSeriesEditor);
end.
