{********************************************}
{   TeeChart Surface Series Nearest Tool     }
{ Copyright (c) 2003-2020 by Steema Software }
{        All Rights Reserved                 }
{********************************************}
unit TeeSurfaceToolEditor;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,

     TeeTools, TeCanvas, TeEngine, Chart, TeeSurfa, TeeToolSeriesEdit,
     TeeSurfaceTool, TeeProcs;

type
  TSurfaceNearest = class(TSeriesToolEditor)
    ButtonColor1: TButtonColor;
    ButtonColor2: TButtonColor;
    ButtonColor3: TButtonColor;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    procedure CheckBox1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure ButtonColor1Click(Sender: TObject);
    procedure ButtonColor2Click(Sender: TObject);
    procedure ButtonColor3Click(Sender: TObject);
    procedure CBSeriesChange(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure CheckBox6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeProCo;

procedure TSurfaceNearest.CheckBox1Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).CellColor:=clTeeColor;
  ButtonColor1.Invalidate;
end;

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

  if Assigned(Tool) then
  with TSurfaceNearestTool(Tool) do
  begin
    FillSeries(CBSeries,TSurfaceSeries,Series);

    ButtonColor1.LinkProperty(Tool,'CellColor');
    ButtonColor2.LinkProperty(Tool,'RowColor');
    ButtonColor3.LinkProperty(Tool,'ColumnColor');

    CheckBox1.Checked:=CellColor=clTeeColor;
    CheckBox2.Checked:=RowColor=clTeeColor;
    CheckBox3.Checked:=ColumnColor=clTeeColor;

    CheckBox4.Checked:=CellColor=clNone;
    CheckBox5.Checked:=RowColor=clNone;
    CheckBox6.Checked:=ColumnColor=clNone;
  end;

  Label1.Caption:=TeeMsg_GallerySurface;
end;

procedure TSurfaceNearest.CheckBox2Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).RowColor:=clTeeColor;
  ButtonColor2.Invalidate;
end;

procedure TSurfaceNearest.CheckBox3Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).ColumnColor:=clTeeColor;
  ButtonColor3.Invalidate;
end;

procedure TSurfaceNearest.ButtonColor1Click(Sender: TObject);
begin
  CheckBox1.Checked:=False;
end;

procedure TSurfaceNearest.ButtonColor2Click(Sender: TObject);
begin
  CheckBox2.Checked:=False;
end;

procedure TSurfaceNearest.ButtonColor3Click(Sender: TObject);
begin
  CheckBox3.Checked:=False;
end;

procedure TSurfaceNearest.CBSeriesChange(Sender: TObject);
begin
  TTeeCustomToolSeries(Tool).Series:=TChartSeries(CBSeries.SelectedObject);
end;

procedure TSurfaceNearest.CheckBox4Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).CellColor:=clNone;
end;

procedure TSurfaceNearest.CheckBox5Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).RowColor:=clNone;
end;

procedure TSurfaceNearest.CheckBox6Click(Sender: TObject);
begin
  TSurfaceNearestTool(Tool).ColumnColor:=clNone;
end;

initialization
  RegisterClass(TSurfaceNearest);
end.
