{*******************************************}
{ TeeChart Animations Gallery               }
{ Copyright (c) 2000-2020 by Steema Sofware }
{*******************************************}
unit TeeAnimationsGallery;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,
     TeEngine, TeeToolsGallery, TeeAnimations;

type
  TTeeAnimationsGallery = class(TTeeToolsGallery)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure FillTools; override;
    Function FilterTool(Index:Integer):Boolean; override;
  public
    { Public declarations }
    function AddNewAnimation(const Animations:TChartAnimations):TTeeAnimationTool;
  end;

var
  AnimationsGalleryHook : TToolsGalleryHook=nil;

implementation

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

{$R TeeAnimations.res}

uses
  Chart, TeeEditTools, TeeAnimate;

procedure TTeeAnimationsGallery.FillTools;
var tmp : TObject;
    tmpClass : TTeeAnimationClass;
    t   : Integer;
begin
  inherited;

  tmp:=TObject(TeeAnimationTypes[TeeAnimationTypes.IndexOf(TTeeAnimationTool)]);

  for t:=0 to TeeAnimationClasses.Count-1 do
  begin
    tmpClass:=TTeeAnimationClass(GetClass(TeeAnimationClasses[t]));
    AddTool(tmpClass.Description,tmp);
  end;
end;

function TTeeAnimationsGallery.AddNewAnimation(const Animations:TChartAnimations):TTeeAnimationTool;
var tmp : String;
    t   : Integer;
    tmpClass : TTeeAnimationClass;
begin
  tmp:=TeeMsg_DefaultAnimationName;
  result:=TFormTeeTools.AddNewTool(Animations,SelectedTool,tmp) as TTeeAnimationTool;

  tmp:=LBTool.Items[LBTool.ItemIndex];

  for t:=0 to TeeAnimationClasses.Count-1 do
  begin
    tmpClass:=TTeeAnimationClass(GetClass(TeeAnimationClasses[t]));

    if tmp=tmpClass.Description then
    begin
      result.Animations.Add(tmpClass.Create(Animations.Owner));
      break;
    end;
  end;

end;

Function TTeeAnimationsGallery.FilterTool(Index:Integer):Boolean;
begin
  result:=True;
end;

procedure TTeeAnimationsGallery.FormCreate(Sender: TObject);
begin
  inherited;

  AddTabs:=False;
  TypesToShow:=TeeAnimationTypes;
  TheGalleryHook:=AnimationsGalleryHook;
  AllowEditButton:=False;
end;

initialization
  AnimationsGalleryHook:=nil;
end.
