{**********************************************}
{   TPyramidSeries Editor dialog               }
{   Copyright (c) 2000-2020 by Steema Software }
{**********************************************}
unit TeePyramidEdit;
{$I TeeDefs.inc}

interface

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

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

     TeCanvas, TeePenDlg, TeePyramid, TeeProcs;

type
  TPyramidSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabOptions: TTabSheet;
    TabBorder: TTabSheet;
    TabPattern: TTabSheet;
    Label1: TLabel;
    CBColorEach: TCheckBox;
    BColor: TButtonColor;
    Edit1: TEdit;
    UDSize: TUpDown;
    CBDefColor: TCheckBox;
    Label2: TLabel;
    TBTransp: TTrackBar;
    procedure FormShow(Sender: TObject);
    procedure CBColorEachClick(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure CBDefColorClick(Sender: TObject);
    procedure BColorClick(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
  private
    { Private declarations }
    Pyramid : TPyramidSeries;

    procedure CheckDefColor;
  public
    { Public declarations }
  end;

implementation

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

Uses
  TeEngine, TeeBrushDlg;

procedure TPyramidSeriesEditor.FormShow(Sender: TObject);
begin
  Pyramid:=TPyramidSeries(Tag);

  if Assigned(Pyramid) then
  begin
    With Pyramid do
    begin
      UDSize.Position:=SizePercent;
      CBColorEach.Checked:=ColorEachPoint;
      BColor.Enabled:=not ColorEachPoint;
      TBTransp.Position:=Transparency;
    end;

    BColor.LinkProperty(Pyramid,'SeriesColor');

    CheckDefColor;
  end;
end;

procedure TPyramidSeriesEditor.CheckDefColor;
begin
  CBDefColor.Enabled:=Pyramid.Color<>clTeeColor;
  CBDefColor.Checked:=not CBDefColor.Enabled;
end;

procedure TPyramidSeriesEditor.CBColorEachClick(Sender: TObject);
begin
  Pyramid.ColorEachPoint:=CBColorEach.Checked;
  BColor.Enabled:=not Pyramid.ColorEachPoint;
end;

procedure TPyramidSeriesEditor.Edit1Change(Sender: TObject);
begin
  if Showing then Pyramid.SizePercent:=UDSize.Position;
end;

procedure TPyramidSeriesEditor.FormCreate(Sender: TObject);
begin
  Align:=alClient;
end;

procedure TPyramidSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabBorder) and (TabBorder.ControlCount=0) then
     TPenDialog.InsertForm(Pyramid.Pen,TabBorder)
  else
  if (PageControl1.ActivePage=TabPattern) and (TabPattern.ControlCount=0) then
     TBrushDialog.AddDialog(Pyramid.Brush,TabPattern);
end;

type
  TSeriesAccess=class(TChartSeries);

procedure TPyramidSeriesEditor.CBDefColorClick(Sender: TObject);
begin
  if CBDefColor.Checked then
  begin
    TSeriesAccess(Pyramid).SetDefaultColor;
    BColor.Invalidate;
    CBDefColor.Enabled:=False;
  end;
end;

procedure TPyramidSeriesEditor.BColorClick(Sender: TObject);
begin
  CheckDefColor;
end;

procedure TPyramidSeriesEditor.TBTranspChange(Sender: TObject);
begin
  if Showing then
     Pyramid.Transparency:=TBTransp.Position;
end;

initialization
  RegisterClass(TPyramidSeriesEditor);
end.
