{**********************************************}
{   TeeChart - Scrolling and blinking Banner   }
{   Copyright (c) 2006-2020 by Steema Software }
{**********************************************}
unit TeeBannerToolEditor;
{$I TeeDefs.inc}

interface

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

  Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Buttons,

  TeEngine, TeeTools, TeeAnnToolEdit, TeCanvas, TeePenDlg, Chart, TeeBannerTool,
  TeeProcs;

type
  TBannerEditor = class(TAnnotationToolEdit)
    TabBanner: TTabSheet;
    CBScroll: TCheckBox;
    Label21: TLabel;
    Edit2: TEdit;
    UDDelay: TUpDown;
    CBBlink: TCheckBox;
    Label17: TLabel;
    Edit3: TEdit;
    UDBlinkOn: TUpDown;
    Label18: TLabel;
    Edit4: TEdit;
    UDBlinkOff: TUpDown;
    Label19: TLabel;
    CBDirection: TComboFlat;
    Label20: TLabel;
    EStep: TEdit;
    UDStep: TUpDown;
    procedure CBScrollClick(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CBBlinkClick(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
    procedure Edit4Change(Sender: TObject);
    procedure CBDirectionChange(Sender: TObject);
    procedure EStepChange(Sender: TObject);
  private
    { Private declarations }
    Banner : TBannerTool;
  public
    { Public declarations }
  end;

implementation

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

Uses
  Math, TeeProCo;

procedure TBannerEditor.CBScrollClick(Sender: TObject);
begin
  Banner.Scroll:=CBScroll.Checked;
end;

procedure TBannerEditor.Edit2Change(Sender: TObject);
begin
  if Showing and Assigned(Banner) then
     Banner.ScrollDelay:=UDDelay.Position;
end;

procedure TBannerEditor.EStepChange(Sender: TObject);
begin
  if Showing and Assigned(Banner) then
     Banner.ScrollStep:=UDStep.Position;
end;

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

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

  Banner:=TBannerTool(Tag);

  if Assigned(Banner) then
  with Banner do
  begin
    CBScroll.Checked:=Scroll;
    UDDelay.Position:=ScrollDelay;
    UDStep.Position:=ScrollStep;

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

  TabBanner.PageIndex:=0;
  PageControl1.ActivePage:=TabBanner;
end;

procedure TBannerEditor.CBBlinkClick(Sender: TObject);
begin
  Banner.Blink:=CBBlink.Checked;
end;

procedure TBannerEditor.Edit3Change(Sender: TObject);
begin
  if Showing and Assigned(Banner) then
     Banner.BlinkDelayOn:=UDBlinkOn.Position;
end;

procedure TBannerEditor.Edit4Change(Sender: TObject);
begin
  if Showing and Assigned(Banner) then
     Banner.BlinkDelayOff:=UDBlinkOff.Position;
end;

initialization
  RegisterClass(TBannerEditor);
end.
