{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Series.Tower;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMXTee.Chart.ListBox,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  {$IFDEF D21}
  FMX.SpinBox,
  {$ENDIF}
  FMX.TabControl, FMXTee.Series.Surface, FMX.Edit, FMX.ListBox, FMX.Colors,
  FMXTee.Procs, FMX.Layouts, FMX.Grid, FMXTee.Chart.Grid;

type
  TTowerSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabGlobal: TTabItem;
    BPen: TButton;
    BBrush: TButton;
    UDTowerTransp: TSpinBox;
    Label6: TLabel;
    TabGrid3D: TTabItem;
    CBDark3D: TCheckBox;
    CBStyle: TComboBox;
    Label1: TLabel;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    ListBoxItem5: TListBoxItem;
    ListBoxItem6: TListBoxItem;
    ListBoxItem7: TListBoxItem;
    ListBoxItem8: TListBoxItem;
    ListBoxItem9: TListBoxItem;
    CBOrigin: TCheckBox;
    EOrigin: TEdit;
    GroupBox1: TGroupBox;
    UDDepth: TSpinBox;
    Label2: TLabel;
    UDWidth: TSpinBox;
    Label3: TLabel;
    procedure FormActivate(Sender: TObject);
    procedure BPenClick(Sender: TObject);
    procedure BBrushClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CBDark3DChange(Sender: TObject);
    procedure UDTowerTranspChange(Sender: TObject);
    procedure CBOriginChange(Sender: TObject);
    procedure EOriginChange(Sender: TObject);
    procedure CBStyleChange(Sender: TObject);
    procedure UDDepthChange(Sender: TObject);
    procedure UDWidthChange(Sender: TObject);
  private
    { Private declarations }
  protected
    Grid3DForm : TCustomForm;
    Tower      : TTowerSeries;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Editor.Stroke, FMXTee.Editor.Brush,
  FMXTee.Editor.Series.Grid;

procedure TTowerSeriesEditor.CBDark3DChange(Sender: TObject);
begin
  if assigned(Tower) then
    Tower.Dark3D:=CBDark3D.IsChecked;
end;

procedure TTowerSeriesEditor.CBOriginChange(Sender: TObject);
begin
  if assigned(Tower) then
    Tower.UseOrigin:=CBOrigin.IsChecked;
end;

procedure TTowerSeriesEditor.CBStyleChange(Sender: TObject);
begin
  if Assigned(Tower) then
    Tower.TowerStyle:=TTowerStyle(CBStyle.ItemIndex);
end;

procedure TTowerSeriesEditor.EOriginChange(Sender: TObject);
begin
  if Assigned(Tower) then
    Tower.Origin:=StrToFloatDef(EOrigin.Text,Tower.Origin);
end;

procedure TTowerSeriesEditor.BBrushClick(Sender: TObject);
begin
  if Assigned(Tower) then
    TBrushEditor.Edit(Self, Tower.Brush)
end;

procedure TTowerSeriesEditor.BPenClick(Sender: TObject);
begin
  if Assigned(Tower) then
    TStrokeEditor.Edit(Self, Tower.Pen);
end;

procedure TTowerSeriesEditor.FormActivate(Sender: TObject);
begin
  if not Assigned(Tower) then
  begin
    Tower:=TTowerSeries(TagObject);

    if Assigned(Tower) then
    With Tower do
    begin
      CBDark3D.IsChecked:=Dark3D;
      CBOrigin.IsChecked:=UseOrigin;
      EOrigin.Text:=FloatToStr(Origin);
      CBStyle.ItemIndex:=Ord(TowerStyle);
      UDDepth.Value:=PercentDepth;
      UDWidth.Value:=PercentWidth;
      UDTowerTransp.Value:=Transparency;

      TGrid3DSeriesEditor.CreateEmbedd(Self,Tower,TabGrid3D);
    end;
  end;
end;

procedure TTowerSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(Grid3DForm);
end;

procedure TTowerSeriesEditor.UDDepthChange(Sender: TObject);
begin
  if Assigned(Tower) then
    Tower.PercentDepth:=Round(UDDepth.Value);
end;

procedure TTowerSeriesEditor.UDTowerTranspChange(Sender: TObject);
begin
  if Assigned(Tower) then
    Tower.Transparency:=Round(UDTowerTransp.Value);
end;

procedure TTowerSeriesEditor.UDWidthChange(Sender: TObject);
begin
  if Assigned(Tower) then
    Tower.PercentWidth:=Round(UDWidth.Value);
end;

initialization
  RegisterSeriesEditor(TTowerSeriesEditor);
end.
