{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Tools.PageNumber;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.ListBox, FMX.TabControl,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  FMX.Edit, FMX.Layouts, FMX.Memo, FMXTee.Tools.PageNumber,
  {$IFDEF D21}
  FMX.SpinBox,
  {$ENDIF}
  FMXTee.Procs, FMXTee.Editor.Tools.Annotation;

type
  TPageNumToolEdit = class(TAnnotationToolEdit)
    TabPaging: TTabItem;
    CBButtons: TCheckBox;
    Label20: TLabel;
    UDButtonWidth: TSpinBox;
    BEnabled: TButton;
    BDisabled: TButton;
    BBorder: TButton;
    procedure FormActivate(Sender: TObject);
    procedure CBButtonsChange(Sender: TObject);
    procedure BEnabledClick(Sender: TObject);
    procedure BDisabledClick(Sender: TObject);
    procedure BBorderClick(Sender: TObject);
    procedure UDButtonWidthChange(Sender: TObject);
  private
    { Private declarations }
    PageNum : TPageNumTool;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Editor.Stroke, FMXTee.Editor.Gradient;

procedure TPageNumToolEdit.BBorderClick(Sender: TObject);
begin
  if Assigned(PageNum) then
     TStrokeEditor.Edit(Self, PageNum.ButtonPen);
end;

procedure TPageNumToolEdit.BDisabledClick(Sender: TObject);
begin
  if Assigned(PageNum) then
    TGradientEditor.Edit(Self, PageNum.DisabledButton);
end;

procedure TPageNumToolEdit.BEnabledClick(Sender: TObject);
begin
  if Assigned(PageNum) then
    TGradientEditor.Edit(Self, PageNum.EnabledButton);
end;

procedure TPageNumToolEdit.CBButtonsChange(Sender: TObject);
begin
  if Assigned(PageNum) then
     PageNum.ShowButtons:=CBButtons.IsChecked;
end;

procedure TPageNumToolEdit.FormActivate(Sender: TObject);
begin
  inherited;

  if not Assigned(PageNum) then
  begin
    PageNum:=TPageNumTool(TagObject);

    if Assigned(PageNum) then
    With PageNum do
    begin
      CBButtons.IsChecked:=ShowButtons;
      UDButtonWidth.Value:=ButtonWidth;
    end;
  end;
end;

procedure TPageNumToolEdit.UDButtonWidthChange(Sender: TObject);
begin
  if Assigned(PageNum) then
     PageNum.ButtonWidth:=Round(UDButtonWidth.Value);
end;

initialization
  RegisterSeriesEditor(TPageNumToolEdit);
end.
