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

interface

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

type
  TAxisArrowToolEditor = class(TAxisToolEditor)
    Label2: TLabel;
    CBPos: TComboBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    CBInv: TCheckBox;
    Label3: TLabel;
    UDLength: TSpinBox;
    Label5: TLabel;
    UDWidth: TSpinBox;
    BBrush: TButton;
    Label4: TLabel;
    UDSize: TSpinBox;
    Label6: TLabel;
    Label7: TLabel;
    UDScroll: TSpinBox;
    Label8: TLabel;
    procedure FormActivate(Sender: TObject);
    procedure CBPosChange(Sender: TObject);
    procedure CBInvChange(Sender: TObject);
    procedure UDLengthChange(Sender: TObject);
    procedure UDWidthChange(Sender: TObject);
    procedure UDSizeChange(Sender: TObject);
    procedure UDScrollChange(Sender: TObject);
    procedure BBrushClick(Sender: TObject);
  private
    { Private declarations }
    AxisArrow : TAxisArrowTool;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Editor.Brush;

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

  if not Assigned(AxisArrow) then
  begin
    AxisArrow:=TAxisArrowTool(TagObject);

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

procedure TAxisArrowToolEditor.BBrushClick(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    TBrushEditor.Edit(Self,AxisArrow.Brush);
end;

procedure TAxisArrowToolEditor.CBInvChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.ScrollInverted:=CBInv.IsChecked;
end;

procedure TAxisArrowToolEditor.UDLengthChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.Length:=Round(UDLength.Value);
end;

procedure TAxisArrowToolEditor.UDScrollChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.ScrollPercent:=Round(UDScroll.Value);
end;

procedure TAxisArrowToolEditor.UDSizeChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.SizePercent:=Round(UDSize.Value);
end;

procedure TAxisArrowToolEditor.UDWidthChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.HeadWidth:=Round(UDWidth.Value);
end;

procedure TAxisArrowToolEditor.CBPosChange(Sender: TObject);
begin
  if Assigned(AxisArrow) then
    AxisArrow.Position:=TAxisArrowToolPosition(CBPos.ItemIndex);
end;

initialization
  RegisterSeriesEditor(TAxisArrowToolEditor);
end.
