{**********************************************}
{   TeeChart HighLow Series Editor             }
{   Copyright (c) 1999-2020 by Steema Software }
{**********************************************}
unit TeeHighLowEdit;
{$I TeeDefs.inc}

interface

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

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

     ErrorBar, TeCanvas, TeePenDlg, TeeProcs;

type
  THighLowEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabHigh: TTabSheet;
    TabLow: TTabSheet;
    PageHigh: TPageControl;
    TabHighBorder: TTabSheet;
    TabHighPattern: TTabSheet;
    PageLow: TPageControl;
    TabLowBorder: TTabSheet;
    TabLowPattern: TTabSheet;
    TabLines: TTabSheet;
    Label1: TLabel;
    CBColorEach: TCheckBox;
    BColor: TButtonColor;
    TBTransp: TTrackBar;
    LTransp: TLabel;
    procedure FormShow(Sender: TObject);
    procedure CBColorEachClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
    procedure PageHighChange(Sender: TObject);
    procedure PageLowChange(Sender: TObject);
  private
    { Private declarations }
    HighLow : THighLowSeries;
  public
    { Public declarations }
  end;

implementation

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

Uses TeeBrushDlg;

procedure THighLowEditor.FormShow(Sender: TObject);
begin
  HighLow:=THighLowSeries(Tag);

  if Assigned(HighLow) then
  begin
    with HighLow do
    begin
      CBColorEach.Checked:=ColorEachPoint;
      TBTransp.Position:=Transparency;
      LTransp.Caption:=IntToStr(TBTransp.Position);
    end;

    BColor.LinkProperty(HighLow,'SeriesColor'); // Do not localize
  end;
end;

procedure THighLowEditor.CBColorEachClick(Sender: TObject);
begin
  HighLow.ColorEachPoint:=CBColorEach.Checked;
end;

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

procedure THighLowEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabLines) and (TabLines.ControlCount=0) then
     TPenDialog.InsertForm(HighLow.Pen,TabLines)
  else
  if PageControl1.ActivePage=TabHigh then
     PageHighChange(Self)
  else
  if PageControl1.ActivePage=TabLow then
     PageLowChange(Self);
end;

procedure THighLowEditor.TBTranspChange(Sender: TObject);
begin
  if Showing then
  begin
    HighLow.Transparency:=TBTransp.Position;
    LTransp.Caption:=IntToStr(TBTransp.Position);
  end;
end;

procedure THighLowEditor.PageHighChange(Sender: TObject);
begin
  if (PageHigh.ActivePage=TabHighBorder) and (TabHighBorder.ControlCount=0) then
     TPenDialog.InsertForm(HighLow.HighPen,TabHighBorder)
  else
  if (PageHigh.ActivePage=TabHighPattern) and (TabHighPattern.ControlCount=0) then
     TBrushDialog.AddDialog(HighLow.HighBrush,TabHighPattern);
end;

procedure THighLowEditor.PageLowChange(Sender: TObject);
begin
  if (PageLow.ActivePage=TabLowBorder) and (TabLowBorder.ControlCount=0) then
     TPenDialog.InsertForm(HighLow.LowPen,TabLowBorder)
  else
  if (PageLow.ActivePage=TabLowPattern) and (TabLowPattern.ControlCount=0) then
     TBrushDialog.AddDialog(HighLow.LowBrush,TabLowPattern);
end;

initialization
  RegisterClass(THighLowEditor);
end.
