{********************************************}
{     TeeChart Pro Charting Library          }
{ Copyright (c) 1995-2020 by Steema Software }
{         All Rights Reserved                }
{********************************************}
unit TeeTransposeToolEditor;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons,

     TeEngine, TeeSurfa, TeeProcs, TeCanvas, TeeTransposeTool;

type
  TGridTransposeToolEdit = class(TForm)
    Label1: TLabel;
    CBSeries: TComboFlat;
    BTranspose: TButton;
    procedure CBSeriesChange(Sender: TObject);
    procedure BTransposeClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    Tool : TGridTransposeTool;
  public
    { Public declarations }
  end;

implementation

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

uses
  Chart, TeeProCo;

procedure TGridTransposeToolEdit.CBSeriesChange(Sender: TObject);
begin
  Tool.Series:=TCustom3DGridSeries(CBSeries.SelectedObject);
  BTranspose.Enabled:=True;
end;

procedure TGridTransposeToolEdit.BTransposeClick(Sender: TObject);
begin
  Tool.Transpose;
end;

procedure TGridTransposeToolEdit.FormShow(Sender: TObject);
var tmp : TChartSeriesList;
    t   : Integer;
begin
  Tool:=TGridTransposeTool(Tag);

  if Assigned(Tool) and Assigned(Tool.ParentChart) then
  begin
    tmp:=Tool.ParentChart.SeriesList;

    with CBSeries do
    begin
      Items.Clear;
      for t:=0 to tmp.Count-1 do
      if tmp[t] is TCustom3DGridSeries then
          Items.AddObject(SeriesTitleOrName(tmp[t]),tmp[t]);

      ItemIndex:=Items.IndexOfObject(Tool.Series);

      BTranspose.Enabled:=ItemIndex<>-1;
    end;
  end;
end;

initialization
  RegisterClass(TGridTransposeToolEdit);
end.

