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

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  {$IFDEF D21}
  FMX.SpinBox,
  {$ENDIF}
  FMX.Edit, FMX.Dialogs, FMXTee.Series.Gantt, FMXTee.Editor.Series.Pointer,
  FMX.TabControl;

type
  TGanttSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabGanttOptions: TTabItem;
    TabCallout: TTabItem;
    Label2: TLabel;
    Label1: TLabel;
    BConnLines: TButton;
    UDPointVertSize: TSpinBox;
    GPLine: TGroupBox;
    BColor: TButton;
    CBColorEach: TCheckBox;
    UDTransp: TSpinBox;
    procedure BColorClick(Sender: TObject);
    procedure CBColorEachChange(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BConnLinesClick(Sender: TObject);
    procedure UDTranspChange(Sender: TObject);
    procedure UDPointVertSizeChange(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
  private
   { Private declarations }

    ICallout       : TSeriesPointerEditor;
    FGantt         : TGanttSeries;
    FPointerEditor : TSeriesPointerEditor;

    procedure RefreshGantt(const AGantt:TGanttSeries);
  public
   { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Canvas, FMXTee.Editor.Stroke,
  FMXTee.Editor.Series, FMXTee.Constants, FMXTee.Procs;

procedure TGanttSeriesEditor.FormActivate(Sender: TObject);
begin
  if not Assigned(FGantt) then
     RefreshGantt(TGanttSeries(TagObject));

  if not Assigned(FPointerEditor) then
  begin
    FPointerEditor:=TSeriesPointerEditor(TSeriesEditor(Owner).Embedd(
            TSeriesPointerEditor.CreateEditor(Self,FGantt.Pointer),
            TeeMsg_GalleryGantt));

    FPointerEditor.HideSizeOptions;
  end;
end;

procedure TGanttSeriesEditor.RefreshGantt(const AGantt: TGanttSeries);
begin
  FGantt:=AGantt;

  CBColorEach.IsChecked:=FGantt.ColorEachPoint;
  UDTransp.Value:=FGantt.Transparency;
  UDPointVertSize.Value:=FGantt.Pointer.VertSize;
end;

procedure TGanttSeriesEditor.TabControl1Change(Sender: TObject);
begin
  if (TabControl1.ActiveTab=TabCallout) and (ICallout=nil) then
     ICallout:=TSeriesPointerEditor.InsertForm(FGantt.Callout,TabCallout);
end;

procedure TGanttSeriesEditor.UDPointVertSizeChange(Sender: TObject);
begin
  FGantt.Pointer.VertSize:=Round(UDPointVertSize.Value);
end;

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

procedure TGanttSeriesEditor.BColorClick(Sender: TObject);
begin
  FGantt.Color:=EditColor(Self, FGantt.Color);
end;

procedure TGanttSeriesEditor.BConnLinesClick(Sender: TObject);
begin
  TStrokeEditor.Edit(Self, FGantt.ConnectingPen);
end;

procedure TGanttSeriesEditor.CBColorEachChange(Sender: TObject);
begin
  FGantt.ColorEachPoint:=CBColorEach.IsChecked;
end;

initialization
  RegisterSeriesEditor(TGanttSeriesEditor);
end.
