{**********************************************}
{   TeeChart Link Tool Editor                  }
{   Copyright (c) 2007-2020 by Steema Software }
{**********************************************}
unit TeeLinkToolEditor;
{$I TeeDefs.inc}

interface

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

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

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

type
  TLinkToolEditor = class(TAnnotationToolEdit)
    TabLink: TTabSheet;
    Label16: TLabel;
    EURL: TEdit;
    Label17: TLabel;
    EHint: TEdit;
    Label18: TLabel;
    EText: TEdit;
    procedure FormShow(Sender: TObject);
    procedure EURLChange(Sender: TObject);
    procedure EHintChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure ETextChange(Sender: TObject);
  private
    { Private declarations }
    Link : TLinkTool;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeProCo;

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

  if Assigned(Tool) then
  begin
    Link:=TLinkTool(Tool);

    EText.Text:=Link.Text;
    EURL.Text:=Link.URL;
    EHint.Text:=Link.Hint;
  end;
end;

procedure TLinkToolEditor.EURLChange(Sender: TObject);
begin
  // Safe-check, when coming from TranslateControl
  if Assigned(Link) then
     Link.URL:=EURL.Text;
end;

procedure TLinkToolEditor.EHintChange(Sender: TObject);
begin
  // Safe-check, when coming from TranslateControl
  if Assigned(Link) then
     Link.Hint:=EHint.Text;
end;

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

  Timer1.Enabled:=True;
end;

procedure TLinkToolEditor.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled:=False;
  PageControl1.ActivePage:=TabLink;
end;

procedure TLinkToolEditor.ETextChange(Sender: TObject);
begin
  // Safe-check, when coming from TranslateControl
  if Assigned(Link) then
     Link.Text:=EText.Text;
end;

initialization
  RegisterClass(TLinkToolEditor);
end.
