{********************************************}
{ TeeChart Pro Charting Library              }
{ Copyright (c) 1995-2020 by Steema Software }
{ All Rights Reserved                        }
{********************************************}
unit EditChar;
{$I TeeDefs.inc}

interface

Uses Classes,
     Graphics, Forms,
     TeEngine, Chart;

Procedure EditChartLegend(const AOwner:TComponent; const AChart:TCustomChart);
Procedure EditSeries(const AOwner:TComponent; const ASeries:TChartSeries);
Procedure EditSeriesDataSource(const AOwner:TComponent; const ASeries:TChartSeries);
Procedure EditSeriesMarks(const AOwner:TComponent; const ASeries:TChartSeries; SymbolsTab:Boolean=False);
Procedure EditChart(const AOwner:TComponent; const AChart:TCustomChart);
Procedure EditChartAxis(const AOwner:TComponent; const Axis:TChartAxis);
Procedure EditChartWall(const AOwner:TComponent; const AWall:TCustomChartWall);
Procedure EditChartTitle(const AOwner:TComponent; const ATitle:TChartTitle);
Procedure EditChartPage(const AOwner:TComponent; const AChart:TCustomChart; PageIndex:Integer);
Procedure EditChartPart(const AOwner:TComponent; const AChart:TCustomChart; const Part:TChartClickedPart);
Procedure EditDSSChart(const AOwner:TComponent; const ADSSChart:TCustomChart);
Procedure EditChartTool(const AOwner:TComponent; const AChartTool:TTeeCustomTool);
Procedure EditChartAnimation(const AOwner:TComponent; const AChartAnimation:TTeeCustomAnimation);

implementation

Uses TeeEditCha, TeeProcs, TeeCustEdit, TeeAreaEdit, TeeBarEdit,
     TeePieEdit, TeeFLineEdi, TeeShapeEdi, TeeCustomFuncEditor, TeeAvgFuncEditor,
     {$IFNDEF TEEOCXSTD}
     GanttCh, TeeGanttEdi, TeeArrowEdi, BubbleCh, TeeBubbleEdit,
     {$ENDIF}
     TeeBrushDlg, StdCtrls,
     {$IFNDEF TEELITE}
     TeeEditTools, TeeEditAnimations,
     {$ENDIF}
     TeeEdiSeri;

Function GetChartEditClass(const AOwner:TComponent; const AChart:TCustomAxisPanel):TChartEditForm;
begin
  result:=TChartEditForm.Create(AOwner);
  result.Chart:=TCustomChart(AChart);
  result.CheckHelpFile;
  TeeTranslateControl(result,[result.LBSeries]);
end;

Procedure EditSeries(const AOwner:TComponent; const ASeries:TChartSeries);
begin
  With GetChartEditClass(AOwner, ASeries.ParentChart) do
  try
    TheEditSeries:=ASeries;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditSeriesMarks(const AOwner:TComponent; const ASeries:TChartSeries; SymbolsTab:Boolean=False);
begin
  With GetChartEditClass(AOwner, ASeries.ParentChart) do
  try
    TheEditSeries:=ASeries;
    MainPage.ActivePage:=TabSeries;
    SetTabSeries;

    With TheFormSeries do
    begin
      PageSeries.ActivePage:=TabMarks;
      PageSeriesChange(nil);

      if SymbolsTab then
         PageControlMarks.ActivePage:=TabSymbol;
    end;

    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditSeriesDataSource(const AOwner:TComponent; const ASeries:TChartSeries);
begin
  With GetChartEditClass(AOwner, ASeries.ParentChart) do
  try
    TheEditSeries:=ASeries;
    MainPage.ActivePage:=TabSeries;
    SetTabSeries;

    With TheFormSeries do
    begin
      PageSeries.ActivePage:=TabDataSource;
      PageSeriesChange(nil);
    end;

    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartPage(const AOwner:TComponent; const AChart:TCustomChart; PageIndex:Integer);
begin
  With GetChartEditClass(AOwner, AChart) do
  try
    TheActivePageIndex:=PageIndex;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartTitle(const AOwner:TComponent; const ATitle:TChartTitle);
Begin
  With GetChartEditClass(AOwner, TCustomChart(ATitle.ParentChart)) do
  try
    TheTitle:=ATitle;
    TheActivePageIndex:=teeEditTitlePage;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartWall(const AOwner:TComponent; const AWall:TCustomChartWall);
Begin
  With GetChartEditClass(AOwner, TCustomChart(AWall.ParentChart)) do
  try
    TheWall:=AWall;
    TheActivePageIndex:=teeEditWallsPage;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartAxis(const AOwner:TComponent; const Axis:TChartAxis);
Begin
  With GetChartEditClass(AOwner, Axis.ParentChart) do
  try
    TheAxis:=Axis;
    TheActivePageIndex:=teeEditAxisPage;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditDSSChart(const AOwner:TComponent; const ADSSChart:TCustomChart);
begin
  With GetChartEditClass(AOwner, ADSSChart) do
  try
    IsDssGraph:=True;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartTool(const AOwner:TComponent; const AChartTool:TTeeCustomTool);
begin
  With GetChartEditClass(AOwner, AChartTool.ParentChart) do
  try
    TheTool:=AChartTool;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChartAnimation(const AOwner:TComponent; const AChartAnimation:TTeeCustomAnimation);
begin
  With GetChartEditClass(AOwner, AChartAnimation.ParentChart) do
  try
    TheAnimation:=AChartAnimation;
    ShowModal;
  finally
    Free;
  end;
end;

Procedure EditChart(const AOwner:TComponent; const AChart:TCustomChart);
Begin
  EditChartPage(AOwner,AChart,teeEditMainPage);
end;

Procedure EditChartLegend(const AOwner:TComponent; const AChart:TCustomChart);
begin
  EditChartPage(AOwner,AChart,teeEditLegendPage);
end;

Procedure EditChartPart(const AOwner:TComponent; const AChart:TCustomChart; const Part:TChartClickedPart);
begin
  case Part.Part of
    cpLegend   : EditChartLegend(AOwner,AChart);
    cpAxis     : EditChartAxis(AOwner,Part.AAxis);
    cpSeries   : EditSeries(AOwner,Part.ASeries);
  cpSeriesMarks: EditSeriesMarks(AOwner,Part.ASeries);
    cpTitle    : EditChartTitle(AOwner,AChart.Title);
    cpFoot     : EditChartTitle(AOwner,AChart.Foot);
    cpSubTitle : EditChartTitle(AOwner,AChart.SubTitle);
    cpSubFoot  : EditChartTitle(AOwner,AChart.SubFoot);
  else
    EditChart(AOwner,AChart);
  end;
end;

end.
