{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Series.Bar.Stack;
{$I TeeDefs.inc}

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  {$IFDEF D21}
  FMX.SpinBox,
  {$ENDIF}
  FMX.Edit, FMX.Dialogs, FMXTee.Series, FMXTee.RadioGroup;

type
  TStackBarSeriesEditor = class(TForm)
    Label1: TLabel;
    CBYOrigin: TCheckBox;
    EYOrigin: TEdit;
    UDGroup: TSpinBox;
    RGMultiBar: TRadioGroup;
    procedure EYOriginChange(Sender: TObject);
    procedure UDGroupChange(Sender: TObject);
    procedure RGMultiBarChange(Sender: TObject);
    procedure EYOriginTyping(Sender: TObject);
  private
   { Private declarations }
    Bar : TCustomBarSeries;
  public
   { Public declarations }
    class function CreateEditor(const AOwner:TComponent; const ABar:TCustomBarSeries):TForm;
    procedure RefreshBar(const ABar:TCustomBarSeries);
  end;

implementation

{$R *.fmx}

class function TStackBarSeriesEditor.CreateEditor(const AOwner: TComponent;
  const ABar: TCustomBarSeries): TForm;
begin
  result:=TStackBarSeriesEditor.Create(AOwner);
  TStackBarSeriesEditor(result).RefreshBar(ABar);
end;

procedure TStackBarSeriesEditor.EYOriginChange(Sender: TObject);
begin
  if Assigned(Bar) then
     Bar.YOrigin:=StrToFloat(EYOrigin.Text);
end;

procedure TStackBarSeriesEditor.EYOriginTyping(Sender: TObject);
begin
  Bar.UseYOrigin:=CBYOrigin.IsChecked;
end;

procedure TStackBarSeriesEditor.RefreshBar(const ABar: TCustomBarSeries);
begin
  Bar:=ABar;

  CBYOrigin.IsChecked:=Bar.UseYOrigin;
  EYOrigin.Text:=FloatToStr(Bar.YOrigin);
  UDGroup.Value:=Bar.StackGroup;
  RGMultiBar.ItemIndex:=Ord(Bar.MultiBar);
end;

procedure TStackBarSeriesEditor.RGMultiBarChange(Sender: TObject);
begin
  Bar.MultiBar:=TMultiBar(RGMultiBar.ItemIndex);
end;

procedure TStackBarSeriesEditor.UDGroupChange(Sender: TObject);
begin
  Bar.StackGroup:=Round(UDGroup.Value);
end;

end.
