{**********************************************}
{   TeeChart Gantt Series Mouse Tool           }
{   Copyright (c) 2000-2020 by Steema Software }
{**********************************************}
unit TeeGanttToolEditor;
{$I TeeDefs.inc}

interface

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

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

  TeEngine, TeCanvas, TeeTools, GanttCh, Chart, TeeGanttTool, TeeToolSeriesEdit,
  TeeProcs;

type
  TGanttToolEditor = class(TSeriesToolEditor)
    Label2: TLabel;
    Edit1: TEdit;
    UpDown1: TUpDown;
    CBAllowDrag: TCheckBox;
    CBAllowResize: TCheckBox;
    Label3: TLabel;
    CBCursorDrag: TComboFlat;
    Label4: TLabel;
    CBCursorResize: TComboFlat;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    procedure Edit1Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CBAllowDragClick(Sender: TObject);
    procedure CBAllowResizeClick(Sender: TObject);
    procedure CBCursorDragChange(Sender: TObject);
    procedure CBCursorResizeChange(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
    CreatingForm : Boolean;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeProCo, TeePenDlg, TeeMouseCursor;

procedure TGanttToolEditor.Edit1Change(Sender: TObject);
begin
  if not CreatingForm then
    TGanttTool(Tool).MinPixels:=UpDown1.Position;
end;

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

  if Assigned(Tool) then
  with TGanttTool(Tool) do
  begin
    FillSeries(CBSeries,TGanttSeries,Series);

    UpDown1.Position:=MinPixels;
    CBAllowDrag.Checked:=AllowDrag;
    CBAllowResize.Checked:=AllowResize;
    TeeFillCursors(CBCursorDrag,CursorDrag);
    TeeFillCursors(CBCursorResize,CursorResize);
  end;

  CreatingForm:=False;
end;

procedure TGanttToolEditor.FormCreate(Sender: TObject);
begin
  inherited;
  CreatingForm:=True;
end;

procedure TGanttToolEditor.CBAllowDragClick(Sender: TObject);
begin
  TGanttTool(Tool).AllowDrag:=CBAllowDrag.Checked;
end;

procedure TGanttToolEditor.CBAllowResizeClick(Sender: TObject);
begin
  TGanttTool(Tool).AllowResize:=CBAllowResize.Checked;
end;

procedure TGanttToolEditor.CBCursorDragChange(Sender: TObject);
begin
  with TGanttTool(Tool) do
       CursorDrag:=TeeSetCursor(CursorDrag,CBCursorDrag.CurrentItem);
end;

procedure TGanttToolEditor.CBCursorResizeChange(Sender: TObject);
begin
  with TGanttTool(Tool) do
       CursorResize:=TeeSetCursor(CursorResize,CBCursorResize.CurrentItem);
end;

procedure TGanttToolEditor.SpeedButton1Click(Sender: TObject);
begin
  with TGanttTool(Tool) do
       CursorDrag:=TMouseCursorEdit.Choose(Tool,TGanttTool(Tool).CursorDrag);
end;

procedure TGanttToolEditor.SpeedButton2Click(Sender: TObject);
begin
  with TGanttTool(Tool) do
       CursorResize:=TMouseCursorEdit.Choose(Tool,TGanttTool(Tool).CursorResize);
end;

initialization
  RegisterClass(TGanttToolEditor);
end.

