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

interface

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

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

     TeeProcs, TeeToolSeriesEdit, TeeTools, TeeEdiSeri, TeCanvas;

type
  TMarksTipToolEdit = class(TSeriesToolEditor)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabFormat: TTabSheet;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    CBMarkStyle: TComboFlat;
    RGMouseAction: TRadioGroup;
    EDelay: TEdit;
    UDDelay: TUpDown;
    Edit1: TEdit;
    UDHideDelay: TUpDown;
    CBSystem: TCheckBox;
    procedure FormShow(Sender: TObject);
    procedure CBMarkStyleChange(Sender: TObject);
    procedure RGMouseActionClick(Sender: TObject);
    procedure EDelayChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure CBSystemClick(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
    MarksTool : TMarksTipTool;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeConst, TeEngine, TeeBrushDlg, TeeTextShapeEditor;

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

  if Assigned(Tool) then
  begin
    MarksTool:=TMarksTipTool(Tool);

    { change "none" with "all" }
    with CBSeries do
    begin
      Items[0]:=TeeMsg_All;
      ItemIndex:=Items.IndexOfObject(TheSeries);
    end;

    { setup dialog }
    with MarksTool do
    begin
      RGMouseAction.ItemIndex:=Ord(MouseAction);
      CBMarkStyle.ItemIndex:=Ord(Style);
      UDDelay.Position:=MouseDelay;
      UDHideDelay.Position:=HideDelay;
      CBSystem.Checked:=SystemHints;
    end;
  end;
end;

procedure TMarksTipToolEdit.CBMarkStyleChange(Sender: TObject);
begin
  MarksTool.Style:=TSeriesMarksStyle(CBMarkStyle.ItemIndex);
end;

procedure TMarksTipToolEdit.RGMouseActionClick(Sender: TObject);
begin
  MarksTool.MouseAction:=TMarkToolMouseAction(RGMouseAction.ItemIndex);
end;

procedure TMarksTipToolEdit.EDelayChange(Sender: TObject);
begin
  if Showing then
     MarksTool.MouseDelay:=UDDelay.Position;
end;

procedure TMarksTipToolEdit.FormCreate(Sender: TObject);
begin
  inherited;
  TFormTeeSeries.FillMarksStyle(CBMarkStyle.Items);
end;

procedure TMarksTipToolEdit.Edit1Change(Sender: TObject);
begin
  if Showing then
     MarksTool.HideDelay:=UDHideDelay.Position;
end;

procedure TMarksTipToolEdit.CBSystemClick(Sender: TObject);
begin
  if Showing then
     MarksTool.SystemHints:=CBSystem.Checked;
end;

procedure TMarksTipToolEdit.PageControl1Change(Sender: TObject);
var IShapeEditor : TTextShapeEditor;
begin
  if (PageControl1.ActivePage=TabFormat) and (TabFormat.ControlCount=0) then
  begin
    IShapeEditor:=TTextShapeEditor.InsertForm(MarksTool.Format,TabFormat);
    IShapeEditor.TabText.TabVisible:=False;
  end;
end;

initialization
  RegisterClass(TMarksTipToolEdit);
end.
