unit FMXTee.Editor.Series.Bar.Stack;

interface

uses
  SysUtils, Types, Classes, Variants, FMX.Types, FMX.Controls, FMX.Forms,
  FMX.Edit, FMX.Dialogs, FMXTee.Series, FMXTee.RadioGroup;

type
  TStackBarSeriesEditor = class(TForm)
    Label1: TLabel;
    CBYOrigin: TCheckBox;
    EYOrigin: TEdit;
    UDGroup: TSpinBox;
    RGMultiBar: TRadioGroup;
    procedure FormCreate(Sender: TObject);
    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(AOwner:TComponent; ABar:TCustomBarSeries):TForm;
    procedure RefreshBar(ABar:TCustomBarSeries);
  end;

implementation

{$R *.fmx}

procedure TStackBarSeriesEditor.FormCreate(Sender: TObject);
begin
// TODO
end;

class function TStackBarSeriesEditor.CreateEditor(AOwner: TComponent;
  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(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.
