{**********************************************}
{   TArrowSeries Editor Dialog                 }
{   Copyright (c) 1996-2020 by Steema Software }
{**********************************************}
unit TeeArrowEdi;
{$I TeeDefs.inc}

interface

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

  Graphics, Controls,  Forms, Dialogs, StdCtrls, ComCtrls, Buttons,
  ArrowCha, TeCanvas;

type
  TArrowSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabFormat: TTabSheet;
    TabBorder: TTabSheet;
    TabPattern: TTabSheet;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    LPercent: TLabel;
    Label4: TLabel;
    SEArrowWidth: TEdit;
    SEArrowHeight: TEdit;
    GroupBox1: TGroupBox;
    CBColorEach: TCheckBox;
    BArrowColor: TButtonColor;
    UDArrowWidth: TUpDown;
    UDArrowHeight: TUpDown;
    SBPercent: TScrollBar;
    ETransp: TEdit;
    UDTransp: TUpDown;
    CBFill2D: TCheckBox;
    procedure CBColorEachClick(Sender: TObject);
    procedure SEArrowWidthChange(Sender: TObject);
    procedure SEArrowHeightChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SBPercentChange(Sender: TObject);
    procedure ETranspChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure CBFill2DClick(Sender: TObject);
  private
    { Private declarations }
    Arrow : TArrowSeries;
    procedure SetLPercent;
  public
    { Public declarations }
  end;

implementation

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

Uses
  TeePenDlg, TeeProcs, TeeBrushDlg, TeEngine;

procedure TArrowSeriesEditor.CBColorEachClick(Sender: TObject);
begin
  Arrow.ColorEachPoint:=CBColorEach.Checked;
  BArrowColor.Enabled:=not Arrow.ColorEachPoint;

  if Arrow.ColorEachPoint then
     Arrow.Pointer.Color:=clTeeColor;
end;

procedure TArrowSeriesEditor.SEArrowWidthChange(Sender: TObject);
begin
  if Showing then
     Arrow.ArrowWidth:=UDArrowWidth.Position;
end;

procedure TArrowSeriesEditor.SEArrowHeightChange(Sender: TObject);
begin
  if Showing then
     Arrow.ArrowHeight:=UDArrowHeight.Position;
end;

procedure TArrowSeriesEditor.SetLPercent;
begin
  LPercent.Caption:=IntToStr(Arrow.ArrowPercent)+'%'; // Do not localize
end;

procedure TArrowSeriesEditor.FormShow(Sender: TObject);
begin
  Arrow:=TArrowSeries(Tag);

  if Assigned(Arrow) then
  begin
    With Arrow do
    begin
      CBColorEach.Checked:=ColorEachPoint;
      UDArrowWidth.Position:=ArrowWidth;
      UDArrowHeight.Position:=ArrowHeight;
      SBPercent.Position:=ArrowPercent;
      SetLPercent;
      UDTransp.Position:=Transparency;
      CBFill2D.Checked:=Fill2D;
    end;

    BArrowColor.LinkProperty(Arrow,'SeriesColor'); // Do not localize
  end;
end;

procedure TArrowSeriesEditor.FormCreate(Sender: TObject);
begin
  BorderStyle:=TeeBorderStyle;
end;

procedure TArrowSeriesEditor.SBPercentChange(Sender: TObject);
begin
  if Showing then
  begin
    Arrow.ArrowPercent:=SBPercent.Position;
    SetLPercent;
  end;
end;

procedure TArrowSeriesEditor.ETranspChange(Sender: TObject);
begin
  if Showing then
     Arrow.Transparency:=UDTransp.Position;
end;

procedure TArrowSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePage.ControlCount=0 then
     if PageControl1.ActivePage=TabBorder then
        TPenDialog.InsertForm(Arrow.Pointer.Pen,TabBorder)
     else
     if PageControl1.ActivePage=TabPattern then
        TBrushDialog.AddDialog(Arrow.Pointer.Brush,TabPattern);
end;

procedure TArrowSeriesEditor.CBFill2DClick(Sender: TObject);
begin
  Arrow.Fill2D:=CBFill2D.Checked;
end;

initialization
  RegisterClass(TArrowSeriesEditor);
end.
