unit TeeDashBoardEdit;
{$I TeeDefs.inc}

interface

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

  {$IFDEF D6}
  Variants,
  {$ENDIF}

  Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls,
  TeeSubChartEditor, TeeSubChart;

type
  TDashBoardEditor = class(TSubChartEditor)
    procedure FormShow(Sender: TObject);
    procedure BAddClick(Sender: TObject);
    procedure BDeleteClick(Sender: TObject);
    procedure BDownClick(Sender: TObject);
    procedure BUpClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    ATool : TSubChartTool;
    procedure SetTool(ATool:TSubChartTool);
  end;

implementation

uses 
  Chart, TeeDashBoard;

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

procedure TDashBoardEditor.FormShow(Sender: TObject);
var t : Integer;
begin
  LBCharts.Items.Clear;

  if Assigned(Tool) then
  begin
    for t:=0 to Tool.Charts.Count-1 do
    if Tool.Charts[t].Chart.Name='' then
       LBCharts.Items.Add('Chart'+IntToStr(t+1))
    else
       LBCharts.Items.Add(Tool.Charts[t].Chart.Name);
  end;

  if LBCharts.Items.Count>0 then
     LBCharts.ItemIndex:=0;

  LBChartsClick(Self);
end;

procedure TDashBoardEditor.SetTool(ATool: TSubChartTool);
begin
  Tool:=ATool;
end;

procedure TDashBoardEditor.BAddClick(Sender: TObject);
begin
  inherited;
  // Set position, width and height depending on num of charts added
  with Tool.Charts[Tool.Charts.Count-1].Chart do
    (Tool.ParentChart as TDashBoard).ResetPositions;
end;

procedure TDashBoardEditor.BDeleteClick(Sender: TObject);
begin
  inherited;
  (ATool.ParentChart as TDashBoard).ResetPositions;
end;

procedure TDashBoardEditor.BDownClick(Sender: TObject);
begin
  inherited;
  (Tool.ParentChart as TDashBoard).ResetPositions;
end;

procedure TDashBoardEditor.BUpClick(Sender: TObject);
begin
  inherited;
  (Tool.ParentChart as TDashBoard).ResetPositions;
end;

end.
