{********************************************}
{ TGanttSeries Editor Dialog                 }
{ Copyright (c) 1996-2020 by Steema Software }
{********************************************}
unit TeeGanttEdi;
{$I TeeDefs.inc}

interface

uses {$IFNDEF LINUX}
     Windows, Messages,
     {$ENDIF}
     SysUtils, Classes,

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
     Chart, GanttCh, TeCanvas, TeePenDlg, TeeProcs, TeePoEdi;

type
  TGanttSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabGanttOptions: TTabSheet;
    TabGanttCallout: TTabSheet;
    Label2: TLabel;
    Label1: TLabel;
    SEPointVertSize: TEdit;
    BConnLines: TButtonPen;
    UDPointVertSize: TUpDown;
    GPLine: TGroupBox;
    BColor: TButtonColor;
    CBColorEach: TCheckBox;
    TBTransp: TTrackBar;
    procedure FormShow(Sender: TObject);
    procedure SEPointVertSizeChange(Sender: TObject);
    procedure CBColorEachClick(Sender: TObject);
    procedure BColorClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }

    ICallout    : TSeriesPointerEditor;
    PointerForm : TCustomForm;
    TheSeries   : TGanttSeries;

    procedure RefreshShape;
  public
    { Public declarations }
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

uses
  TeEngine, Series, TeeConst;

procedure TGanttSeriesEditor.RefreshShape;
begin
  BColor.Enabled:=not TheSeries.ColorEachPoint;
end;

procedure TGanttSeriesEditor.FormShow(Sender: TObject);
begin
  TheSeries:=TGanttSeries(Tag);

  if Assigned(TheSeries) then
  begin
    With TheSeries do
    begin
      UDPointVertSize.Position:=Pointer.VertSize;
      CBColorEach.Checked:=ColorEachPoint;
      TBTransp.Position:=Transparency;
      BConnLines.LinkPen(ConnectingPen);
    end;

    BColor.LinkProperty(TheSeries,'SeriesColor'); // Do not localize
    RefreshShape;

    if not Assigned(PointerForm) then
    begin
      PointerForm:=TeeInsertPointerForm(Parent,TheSeries.Pointer,TeeMsg_GalleryGantt);

      (PointerForm as TSeriesPointerEditor).HideSizeOptions;
    end;
  end;
end;

procedure TGanttSeriesEditor.SEPointVertSizeChange(Sender: TObject);
begin
  if Showing then
     TheSeries.Pointer.VertSize:=UDPointVertSize.Position;
end;

procedure TGanttSeriesEditor.CBColorEachClick(Sender: TObject);
begin
  TheSeries.ColorEachPoint:=CBColorEach.Checked;
  RefreshShape;
end;

procedure TGanttSeriesEditor.BColorClick(Sender: TObject);
begin
  TheSeries.ColorEachPoint:=False;
end;

procedure TGanttSeriesEditor.FormCreate(Sender: TObject);
begin
  BorderStyle:=TeeBorderStyle;
end;

procedure TGanttSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(PointerForm);
end;

procedure TGanttSeriesEditor.TBTranspChange(Sender: TObject);
begin
  if Showing then
     TheSeries.Transparency:=TBTransp.Position;
end;

procedure TGanttSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabGanttCallout) and (ICallout=nil) then
     ICallout:=TSeriesPointerEditor.InsertForm(TheSeries.Callout,TabGanttCallout);
end;

initialization
  RegisterSeriesEditor(TGanttSeriesEditor);
end.
