unit FMXTee.Editor.Series.Circled;

interface

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

type
  TCircledSeriesEditor = class(TForm)
    PageControl1: TTabControl;
    TabOptions: TTabItem;
    Label1: TLabel;
    CBCircled: TCheckBox;
    CB3D: TCheckBox;
    BBack: TButton;
    CBTransp: TCheckBox;
    BGradient: TButton;
    UDRot: TSpinBox;
    TabRadius: TTabItem;
    GroupBox2: TGroupBox;
    Label4: TLabel;
    Label5: TLabel;
    CBAutoXR: TCheckBox;
    CBAutoYR: TCheckBox;
    UDY: TSpinBox;
    UDX: TSpinBox;
    TabShadow: TTabItem;
    TabEmboss: TTabItem;
    procedure BBackClick(Sender: TObject);
    procedure BGradientClick(Sender: TObject);
    procedure SEXRadiusChange(Sender: TObject);
    procedure SEYRadiusChange(Sender: TObject);
    procedure CBCircledChange(Sender: TObject);
    procedure CB3DChange(Sender: TObject);
    procedure CBTranspChange(Sender: TObject);
    procedure CBAutoXRChange(Sender: TObject);
    procedure CBAutoYRChange(Sender: TObject);
    procedure UDRotChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure UDXChange(Sender: TObject);
    procedure UDYChange(Sender: TObject);
  private
   { Private declarations }
    Circled : TCircledSeries;

    FShadowEditor,
    FEmbossEditor : TForm;
  public
   { Public declarations }
    procedure RefreshCircled(ACircled:TCircledSeries);
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Canvas, FMXTee.Editor.Shadow, FMXTee.Editor.Gradient;

procedure TCircledSeriesEditor.CBCircledChange(Sender: TObject);
begin
  Circled.Circled:=CBCircled.IsChecked;
end;

procedure TCircledSeriesEditor.CB3DChange(Sender: TObject);
begin
  Circled.ParentChart.View3D:=CB3D.IsChecked;
end;

procedure TCircledSeriesEditor.BBackClick(Sender: TObject);
begin
  Circled.Color:=EditColor(Self, Circled.Color);
end;

type
  TCircledAccess=class(TCircledSeries);

procedure TCircledSeriesEditor.CBTranspChange(Sender: TObject);
begin
  if CBTransp.IsChecked then
  begin
    Circled.CircleBackColor:=clDefault;
    TCircledAccess(Circled).CircleGradient.Visible:=False;
  end;

  CBTransp.Enabled:=not CBTransp.IsChecked;
end;

procedure TCircledSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActiveTab=TabShadow) and (not Assigned(FShadowEditor)) then
     FShadowEditor:=TShadowEditor.CreateEmbedd(Self,Circled.Shadow,TabShadow)
  else
  if (PageControl1.ActiveTab=TabEmboss) and (not Assigned(FEmbossEditor)) then
     FEmbossEditor:=TShadowEditor.CreateEmbedd(Self,Circled.Emboss,TabEmboss)
end;

procedure TCircledSeriesEditor.RefreshCircled(ACircled: TCircledSeries);
begin
  Circled:=ACircled;

  CBCircled.IsChecked:=Circled.Circled;
  CB3D.IsChecked:=Circled.ParentChart.View3D;
  CBTransp.IsChecked:=(Circled.CircleBackColor=clDefault);
  UDRot.Value:=Circled.RotationAngle;

  UDX.Value:=Circled.CustomXRadius;
  UDY.Value:=Circled.CustomYRadius;

  CBAutoXR.IsChecked:=Circled.XRadius=0;
  CBAutoYR.IsChecked:=Circled.YRadius=0;
end;

procedure TCircledSeriesEditor.BGradientClick(Sender: TObject);
begin
  TGradientEditor.Edit(Self, TCircledAccess(Circled).CircleGradient);
end;

procedure TCircledSeriesEditor.SEXRadiusChange(Sender: TObject);
begin
// TODO
end;

procedure TCircledSeriesEditor.CBAutoXRChange(Sender: TObject);
begin
  if CBAutoXR.IsChecked then UDX.Value:=0;
end;

procedure TCircledSeriesEditor.SEYRadiusChange(Sender: TObject);
begin
// TODO
end;

procedure TCircledSeriesEditor.UDRotChange(Sender: TObject);
begin
  Circled.RotationAngle:=Round(UDRot.Value);
end;

procedure TCircledSeriesEditor.UDXChange(Sender: TObject);
begin
  Circled.CustomXRadius:=Round(UDX.Value);
  CBAutoXR.IsChecked:=Circled.CustomXRadius=0;
end;

procedure TCircledSeriesEditor.UDYChange(Sender: TObject);
begin
  Circled.CustomYRadius:=Round(UDY.Value);
  CBAutoYR.IsChecked:=Circled.CustomYRadius=0;
end;

procedure TCircledSeriesEditor.CBAutoYRChange(Sender: TObject);
begin
  if CBAutoYR.IsChecked then UDY.Value:=0;
end;

end.
