unit FMXTee.Editor.Symbol;

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  FMX.Edit, FMX.ListBox, FMX.Dialogs, FMXTee.Chart;

type
  TSymbolEditor = class(TForm)
    L11: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    CBColWUnits: TComboBox;
    CBSymbolPos: TComboBox;
    CBContinuous: TCheckBox;
    CBVisible: TCheckBox;
    CBSymPen: TCheckBox;
    BSymPen: TButton;
    CBSquared: TCheckBox;
    BSymGradient: TButton;
    Button1: TButton;
    BEmboss: TButton;
    UDWidth: TSpinBox;
    procedure CBColWUnitsChange(Sender: TObject);
    procedure CBSymbolPosChange(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure BEmbossClick(Sender: TObject);
    procedure CBVisibleChange(Sender: TObject);
    procedure CBContinuousChange(Sender: TObject);
    procedure CBSquaredChange(Sender: TObject);
    procedure UDWidthChange(Sender: TObject);
    procedure BSymGradientClick(Sender: TObject);
    procedure BSymPenClick(Sender: TObject);
    procedure CBSymPenChange(Sender: TObject);
  private
   { Private declarations }
    Symbol : TLegendSymbol;
  public
   { Public declarations }
    procedure RefreshSymbol(ASymbol:TLegendSymbol);
    class function CreateEditor(AOwner:TComponent; ASymbol:TLegendSymbol):TSymbolEditor;
  end;

implementation

{$R *.fmx}

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

class function TSymbolEditor.CreateEditor(AOwner: TComponent;
  ASymbol:TLegendSymbol): TSymbolEditor;
begin
  result:=TSymbolEditor.Create(AOwner);
  result.RefreshSymbol(ASymbol);
end;

procedure TSymbolEditor.RefreshSymbol(ASymbol: TLegendSymbol);
begin
  Symbol:=ASymbol;

  CBColWUnits.ItemIndex:=Ord(Symbol.WidthUnits);
  CBSymbolPos.ItemIndex:=Ord(Symbol.Position);
  CBContinuous.IsChecked:=Symbol.Continuous;
  CBVisible.IsChecked:=Symbol.Visible;
  CBSymPen.IsChecked:=Symbol.DefaultPen;
  CBSquared.IsChecked:=Symbol.Squared;
  UDWidth.Value:=Symbol.Width;
end;

procedure TSymbolEditor.UDWidthChange(Sender: TObject);
begin
  Symbol.Width:=Round(UDWidth.Value);
end;

procedure TSymbolEditor.CBColWUnitsChange(Sender: TObject);
begin
  Symbol.WidthUnits:=TLegendSymbolSize(CBColWUnits.ItemIndex);
end;

procedure TSymbolEditor.CBSymbolPosChange(Sender: TObject);
begin
  Symbol.Position:=TLegendSymbolPosition(CBSymbolPos.ItemIndex);
end;

procedure TSymbolEditor.CBContinuousChange(Sender: TObject);
begin
  Symbol.Continuous:=CBContinuous.IsChecked;
end;

procedure TSymbolEditor.CBVisibleChange(Sender: TObject);
begin
  Symbol.Visible:=CBVisible.IsChecked;
end;

procedure TSymbolEditor.CBSymPenChange(Sender: TObject);
begin
  Symbol.DefaultPen:=CBSymPen.IsChecked;
end;

procedure TSymbolEditor.CBSquaredChange(Sender: TObject);
begin
  Symbol.Squared:=CBSquared.IsChecked;
end;

procedure TSymbolEditor.BSymGradientClick(Sender: TObject);
begin
  TGradientEditor.Edit(Self,Symbol.Gradient);
end;

procedure TSymbolEditor.BSymPenClick(Sender: TObject);
begin
  TStrokeEditor.Edit(Self,Symbol.Pen);
end;

procedure TSymbolEditor.Button1Click(Sender: TObject);
begin
  TShadowEditor.Edit(Self, Symbol.Shadow);
end;

procedure TSymbolEditor.BEmbossClick(Sender: TObject);
begin
  TShadowEditor.Edit(Self, Symbol.Emboss);
end;

end.
