{***********************************************}
{   TErrorPoint3DSeries Component Editor Dialog }
{   Copyright (c) 1996-2020 by Steema Software  }
{***********************************************}
unit TeeErrorPoint3DEdit;
{$I TeeDefs.inc}

interface

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

     Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,
     TeCanvas, TeePenDlg, TeeErrorPoint, ErrorBar, TeePoEdi, TeeConst, TeeProcs;

type
  TErrorPoint3DSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabOptions: TTabSheet;
    TabBorders: TTabSheet;
    LBBorders: TListBox;
    Label1: TLabel;
    SEBarwidth: TEdit;
    RGWidthUnit: TRadioGroup;
    UDBarWidth: TUpDown;
    CBColorEach: TCheckBox;
    procedure FormShow(Sender: TObject);
    procedure SEBarwidthChange(Sender: TObject);
    procedure RGWidthUnitClick(Sender: TObject);
    procedure CBColorEachClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure LBBordersClick(Sender: TObject);
  private
    { Private declarations }
    ErrorPoint3DSeries : TCustomErrorPoint3DSeries;
    FPointForm : TCustomForm;
    IPenEditor : TPenDialog;
  public
    { Public declarations }
  end;

implementation

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

procedure TErrorPoint3DSeriesEditor.FormShow(Sender: TObject);
begin
  ErrorPoint3DSeries:=TCustomErrorPoint3DSeries(Tag);

  if Assigned(ErrorPoint3DSeries) then
  With ErrorPoint3DSeries do
  begin
    UDBarWidth.Position:=Errors.Size;

    if Errors.SizeUnits=ewuPercent then RGWidthUnit.ItemIndex:=0
                                  else RGWidthUnit.ItemIndex:=1;

    CBColorEach.Checked:=ColorEachPoint;

    if not Assigned(FPointForm) then
       FPointForm:=TeeInsertPointerForm(Parent,Pointer,TeeMsg_GalleryPoint);
  end;
end;

procedure TErrorPoint3DSeriesEditor.RGWidthUnitClick(Sender: TObject);
begin
  ErrorPoint3DSeries.Errors.SizeUnits:=TErrorWidthUnits(RGWidthUnit.ItemIndex);
end;

procedure TErrorPoint3DSeriesEditor.SEBarwidthChange(Sender: TObject);
begin
  if Showing then
     ErrorPoint3DSeries.Errors.Size:=UDBarWidth.Position;
end;

procedure TErrorPoint3DSeriesEditor.CBColorEachClick(Sender: TObject);
begin
  ErrorPoint3DSeries.ColorEachPoint:=CBColorEach.Checked;
end;

procedure TErrorPoint3DSeriesEditor.FormCreate(Sender: TObject);
begin
  PageControl1.ActivePage:=TabOptions;
  BorderStyle:=TeeBorderStyle;
  LBBorders.ItemIndex:=0;
end;

procedure TErrorPoint3DSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FPointForm);
end;

procedure TErrorPoint3DSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabBorders) and (TabBorders.ControlCount<2) then
  begin
    IPenEditor:=TPenDialog.InsertForm(ErrorPoint3DSeries.Errors.Format.Left,TabBorders);

    LBBordersClick(Self);
  end;
end;

procedure TErrorPoint3DSeriesEditor.LBBordersClick(Sender: TObject);
var tmp : TTeePen;
begin
  if Assigned(IPenEditor) then
  begin
    with ErrorPoint3DSeries.Errors.Format do
    case LBBorders.ItemIndex of
      0: tmp:=Left;
      1: tmp:=Top;
      2: tmp:=Right;
      3: tmp:=Bottom;
      4: tmp:=Front;
    else
      tmp:=Back;
    end;

    IPenEditor.RefreshPen(tmp);
  end;
end;

initialization
  RegisterClass(TErrorPoint3DSeriesEditor);
end.
