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

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.ListBox, FMX.TabControl,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  {$IFDEF D21}
  FMX.SpinBox,
  {$ENDIF}
  FMX.Edit, FMX.Layouts, FMX.Memo, FMXTee.Tools.Banner,
  FMXTee.Procs, FMXTee.Editor.Tools.Annotation;

type
  TBannerEditor = class(TAnnotationToolEdit)
    TabBanner: TTabItem;
    CBScroll: TCheckBox;
    Label20: TLabel;
    UDDelay: TSpinBox;
    CBDirection: TComboBox;
    ListBoxItem17: TListBoxItem;
    ListBoxItem18: TListBoxItem;
    Label17: TLabel;
    Label18: TLabel;
    UDStep: TSpinBox;
    CBBlink: TCheckBox;
    Label19: TLabel;
    UDBlinkOn: TSpinBox;
    UDBlinkOff: TSpinBox;
    Label21: TLabel;
    procedure FormActivate(Sender: TObject);
    procedure CBScrollChange(Sender: TObject);
    procedure UDDelayChange(Sender: TObject);
    procedure UDStepChange(Sender: TObject);
    procedure CBBlinkChange(Sender: TObject);
    procedure UDBlinkOnChange(Sender: TObject);
    procedure UDBlinkOffChange(Sender: TObject);
    procedure CBDirectionChange(Sender: TObject);
  private
    { Private declarations }
    Banner : TBannerTool;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

procedure TBannerEditor.CBBlinkChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.Blink:=CBBlink.IsChecked;
end;

procedure TBannerEditor.CBDirectionChange(Sender: TObject);
begin
  if CBDirection.ItemIndex=0 then
     Banner.ScrollDirection:=sdRightLeft
  else
     Banner.ScrollDirection:=sdLeftRight;
end;

procedure TBannerEditor.CBScrollChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.Scroll:=CBScroll.IsChecked;
end;

procedure TBannerEditor.FormActivate(Sender: TObject);
begin
  inherited;

  if not Assigned(Banner) then
  begin
    Banner:=TBannerTool(TagObject);

    if Assigned(Banner) then
    With Banner do
    begin
      CBScroll.IsChecked:=Scroll;
      UDDelay.Value:=ScrollDelay;
      UDStep.Value:=ScrollStep;

      CBBlink.IsChecked:=Blink;
      UDBlinkOn.Value:=BlinkDelayOn;
      UDBlinkOff.Value:=BlinkDelayOff;
      CBDirection.ItemIndex:=Ord(ScrollDirection);
    end;
  end;
end;

procedure TBannerEditor.UDBlinkOffChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.BlinkDelayOff:=Round(UDBlinkOff.Value);
end;

procedure TBannerEditor.UDBlinkOnChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.BlinkDelayOn:=Round(UDBlinkOn.Value);
end;

procedure TBannerEditor.UDDelayChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.ScrollDelay:=Round(UDDelay.Value);
end;

procedure TBannerEditor.UDStepChange(Sender: TObject);
begin
  if Assigned(Banner) then
     Banner.ScrollStep:=Round(UDStep.Value);

end;

initialization
  RegisterSeriesEditor(TBannerEditor);
end.
