{*********************************************}
{  TAxisArrowTool Editor                      }
{  Copyright (c) 1996-2020 by Steema Software }
{        All Rights Reserved                  }
{*********************************************}
unit TeeAxisArrowEdit;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,
     TeeAxisToolEdit, TeCanvas, TeePenDlg, TeeTools;

type
  TAxisArrowToolEditor = class(TAxisToolEditor)
    PageControl1: TPageControl;
    TabOptions: TTabSheet;
    TabBorder: TTabSheet;
    TabPattern: TTabSheet;
    LL: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    UDLength: TUpDown;
    ELength: TEdit;
    CBPos: TComboFlat;
    Edit1: TEdit;
    UDScroll: TUpDown;
    CBInv: TCheckBox;
    UDSize: TUpDown;
    ESize: TEdit;
    EWidth: TEdit;
    UDWidth: TUpDown;
    procedure FormShow(Sender: TObject);
    procedure ELC(Sender: TObject);
    procedure CBPosChange(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure CBInvClick(Sender: TObject);
    procedure ESizeChange(Sender: TObject);
    procedure EWidthChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    AxisArrowTool : TAxisArrowTool;
  public
    { Public declarations }
  end;

implementation

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

Uses
  TeeBrushDlg;

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

  AxisArrowTool:=TAxisArrowTool(Tag);

  if Assigned(AxisArrowTool) then
  begin
    With AxisArrowTool do
    begin
      UDLength.Position:=Length;
      CBPos.ItemIndex:=Ord(Position);
      UDScroll.Position:=ScrollPercent;
      CBInv.Checked:=ScrollInverted;
      UDSize.Position:=SizePercent;
      UDWidth.Position:=HeadWidth;
    end;
  end;
end;

procedure TAxisArrowToolEditor.ELC(Sender: TObject);
begin
  if Showing then AxisArrowTool.Length:=UDLength.Position;
end;

procedure TAxisArrowToolEditor.CBPosChange(Sender: TObject);
begin
  AxisArrowTool.Position:=TAxisArrowToolPosition(CBPos.ItemIndex);
end;

procedure TAxisArrowToolEditor.Edit1Change(Sender: TObject);
begin
  if Showing then AxisArrowTool.ScrollPercent:=UDScroll.Position
end;

procedure TAxisArrowToolEditor.CBInvClick(Sender: TObject);
begin
  AxisArrowTool.ScrollInverted:=TCheckBox(Sender).Checked;
end;

procedure TAxisArrowToolEditor.ESizeChange(Sender: TObject);
begin
  if Showing then
     AxisArrowTool.SizePercent:=UDSize.Position;
end;

procedure TAxisArrowToolEditor.EWidthChange(Sender: TObject);
begin
  if Showing then
     AxisArrowTool.HeadWidth:=UDWidth.Position;
end;

procedure TAxisArrowToolEditor.PageControl1Change(Sender: TObject);
begin
  inherited;

  if (PageControl1.ActivePage=TabBorder) and (TabBorder.ControlCount=0) then
     TPenDialog.InsertForm(AxisArrowTool.Pen,TabBorder)
  else
  if (PageControl1.ActivePage=TabPattern) and (TabPattern.ControlCount=0) then
     TBrushDialog.AddDialog(AxisArrowTool.Brush,TabPattern);
end;

procedure TAxisArrowToolEditor.FormCreate(Sender: TObject);
begin
  inherited;
  PageControl1.ActivePage:=TabOptions;
end;

initialization
  RegisterClass(TAxisArrowToolEditor);
end.
