{**********************************************}
{   TDrawLineTool Editor                       }
{   Copyright (c) 1999-2020 by Steema Software }
{**********************************************}
unit TeeDrawLineEditor;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,

     TeCanvas, TeePenDlg, TeeProcs, TeeTools, TeeToolSeriesEdit;

type
  TDrawLineEdit = class(TSeriesToolEditor)
    PageControl1: TPageControl;
    TabBorder: TTabSheet;
    TabSheet2: TTabSheet;
    Label11: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    CBButton: TComboFlat;
    CBEnable: TCheckBox;
    CBSelect: TCheckBox;
    EPixels: TEdit;
    UDClick: TUpDown;
    CBSelectNew: TCheckBox;
    Label4: TLabel;
    CBStyle: TComboFlat;
    CBFullRepaint: TCheckBox;
    procedure FormShow(Sender: TObject);
    procedure CBButtonChange(Sender: TObject);
    procedure CBEnableClick(Sender: TObject);
    procedure CBSelectClick(Sender: TObject);
    procedure EPixelsChange(Sender: TObject);
    procedure CBSelectNewClick(Sender: TObject);
    procedure CBStyleChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure CBFullRepaintClick(Sender: TObject);
  private
    { Private declarations }
    Draw : TDrawLineTool;
  public
    { Public declarations }
  end;

implementation

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

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

  Draw:=TDrawLineTool(Tag);

  if Assigned(Draw) then
  with Draw do
  begin
    CBButton.ItemIndex:=Ord(Button);
    CBEnable.Checked:=EnableDraw;
    CBSelect.Checked:=EnableSelect;
    CBSelectNew.Checked:=SelectNewLines;
    UDClick.Position:=ClickTolerance;
    CBStyle.ItemIndex:=Ord(Style);
    CBFullRepaint.Checked:=FullRepaint;
  end;
end;

procedure TDrawLineEdit.CBButtonChange(Sender: TObject);
begin
  Draw.Button:=TMouseButton(CBButton.ItemIndex);
end;

procedure TDrawLineEdit.CBEnableClick(Sender: TObject);
begin
  Draw.EnableDraw:=CBEnable.Checked
end;

procedure TDrawLineEdit.CBSelectClick(Sender: TObject);
begin
  Draw.EnableSelect:=CBSelect.Checked
end;

procedure TDrawLineEdit.EPixelsChange(Sender: TObject);
begin
  if Assigned(Draw) then
     Draw.ClickTolerance:=UDClick.Position;
end;

procedure TDrawLineEdit.CBSelectNewClick(Sender: TObject);
begin
  Draw.SelectNewLines:=CBSelectNew.Checked
end;

procedure TDrawLineEdit.CBStyleChange(Sender: TObject);
begin
  Draw.Style:=TDrawLineStyle(CBStyle.ItemIndex);
end;

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

  if (PageControl1.ActivePage=TabBorder) and (TabBorder.ControlCount=0) then
     TPenDialog.InsertForm(Draw.Pen,TabBorder);
end;

procedure TDrawLineEdit.CBFullRepaintClick(Sender: TObject);
begin
  Draw.FullRepaint:=CBFullRepaint.Checked;
end;

initialization
  RegisterClass(TDrawLineEdit);
end.
