{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Tools.ColorLine;
{$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}
  FMXTee.Procs, FMX.ListBox, FMX.Edit, FMXTee.Tools, FMX.TabControl, FMX.Colors;

type
  TColorLineToolEditor = class(TAxisToolEditor)
    TabControl1: TTabControl;
    TabValues: TTabItem;
    TabOptions: TTabItem;
    Label3: TLabel;
    EValue: TEdit;
    CBDrawBehind: TCheckBox;
    CBDraw3D: TCheckBox;
    CBStyle: TComboBox;
    Label4: TLabel;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    ListBoxItem4: TListBoxItem;
    CBAllowDrag: TCheckBox;
    CBNoLimitDrag: TCheckBox;
    CBDragRepaint: TCheckBox;
    procedure FormActivate(Sender: TObject);
    procedure CBStyleChange(Sender: TObject);
    procedure EValueChange(Sender: TObject);
    procedure CBDrawBehindChange(Sender: TObject);
    procedure CBDraw3DChange(Sender: TObject);
    procedure CBAllowDragChange(Sender: TObject);
    procedure CBNoLimitDragChange(Sender: TObject);
    procedure CBDragRepaintChange(Sender: TObject);
  private
    { Private declarations }
    ColorLine : TColorLineTool;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

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

  if not Assigned(ColorLine) then
  begin
    ColorLine:=TColorLineTool(TagObject);

    if Assigned(ColorLine) then
    With ColorLine do
    begin
      EValue.Text:=FloatToStr(Value);
      CBAllowDrag.IsChecked:=AllowDrag;
      CBDragRepaint.IsChecked:=DragRepaint;
      CBNoLimitDrag.IsChecked:=NoLimitDrag;
      CBDraw3D.IsChecked:=Draw3D;
      CBDrawBehind.IsChecked:=DrawBehind;
      CBStyle.ItemIndex:=Ord(Style);
      EValue.Enabled:=Style=clCustom
    end;
  end;
end;

procedure TColorLineToolEditor.CBAllowDragChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.AllowDrag:=CBAllowDrag.IsChecked;
end;

procedure TColorLineToolEditor.CBDragRepaintChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.DragRepaint:=CBDragRepaint.IsChecked;
end;

procedure TColorLineToolEditor.CBDraw3DChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.Draw3D:=CBDraw3D.IsChecked;
end;

procedure TColorLineToolEditor.CBStyleChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
  begin
    ColorLine.Style:=TColorLineStyle(CBStyle.ItemIndex);
    EValue.Enabled:=ColorLine.Style=clCustom;
  end;
end;

procedure TColorLineToolEditor.CBDrawBehindChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.DrawBehind:=CBDrawBehind.IsChecked;
end;

procedure TColorLineToolEditor.CBNoLimitDragChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.NoLimitDrag:=CBNoLimitDrag.IsChecked;
end;

procedure TColorLineToolEditor.EValueChange(Sender: TObject);
begin
  if Assigned(ColorLine) then
    ColorLine.Value:=StrToFloatDef(EValue.Text,ColorLine.Value);
end;

initialization
  RegisterSeriesEditor(TColorLineToolEditor);
end.
