{********************************************}
{ TAxisScrollBarTool Editor Dialog           }
{ Copyright (c) 2000-2020 by Steema Software }
{********************************************}
unit TeeAxisScrollBarEdit;
{$I TeeDefs.inc}

interface

uses
  {$IFDEF MSWINDOWS}
  Windows, Messages,
  {$ENDIF}
  SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, TeeAxisToolEdit, StdCtrls, TeCanvas, TeePenDlg, ExtCtrls,
  TeeLegendScrollBarEditor, TeEngine, ComCtrls;

type
  TAxisScrollBarEditor = class(TAxisToolEditor)
    PageControl1: TPageControl;
    TabScrollOptions: TTabSheet;
    TabScrollFormat: TTabSheet;
    CBAllowResize: TCheckBox;
    Label6: TLabel;
    EMargin: TEdit;
    UDMargin: TUpDown;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CBAllowResizeClick(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure EMarginChange(Sender: TObject);
  private
    { Private declarations }
    IEditor : TScrollbarEditor;
  protected
    function GetAxis:TChartAxis; override;
    procedure SetAxis(const AAxis:TChartAxis); override;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeTools, TeeProcs;

procedure TAxisScrollBarEditor.FormCreate(Sender: TObject);
begin
  inherited;

  PageControl1.ActivePage:=TabScrollOptions;

  IEditor:=TScrollbarEditor.Create(Self);
  IEditor.Align:=alClient;
end;

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

  CBAllowResize.Checked:=TAxisScrollBarTool(AxisTool).AllowResize;
  UDMargin.Position:=TAxisScrollBarTool(AxisTool).Margin;
end;

procedure TAxisScrollBarEditor.CBAllowResizeClick(Sender: TObject);
begin
  TAxisScrollBarTool(AxisTool).AllowResize:=CBAllowResize.Checked;
end;

procedure TAxisScrollBarEditor.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePage=TabScrollFormat then
     if TabScrollFormat.ControlCount=0 then
     begin
       IEditor.HideThumbSize;
       TeeTranslateControl(IEditor);

       AddFormTo(IEditor,TabScrollFormat,TAxisScrollBarTool(AxisTool));
     end;
end;

procedure TAxisScrollBarEditor.EMarginChange(Sender: TObject);
begin
  if AxisTool<>nil then
     TAxisScrollBarTool(AxisTool).Margin:=UDMargin.Position;
end;

function TAxisScrollBarEditor.GetAxis: TChartAxis;
begin
  result:=TAxisScrollBarTool(AxisTool).Axis;
end;

procedure TAxisScrollBarEditor.SetAxis(const AAxis: TChartAxis);
begin
  TAxisScrollBarTool(AxisTool).Axis:=AAxis;
end;

initialization
  RegisterClass(TAxisScrollBarEditor);
end.
