{**************************************************************}
{                                                              }
{ Purpose  : The Editor dialog for the Volume Pipeline Series  }
{ Author   : Marc Meumann, marc@steema.com                     }
{                                                              }
{ Copyright (c) 2006-2020 by Marc Meumann                      }
{        All Rights Reserved                                   }
{**************************************************************}
unit TeeVolumePipeEditor;
{$I TeeDefs.inc}

interface

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

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

     TeeVolumePipe, TeCanvas, TeePenDlg, TeeProcs;

type
  TVolumePipeSeriesEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabBorder: TTabSheet;
    TabLines: TTabSheet;
    TabPattern: TTabSheet;
    Label1: TLabel;
    Edit2: TEdit;
    UpDown1: TUpDown;
    CheckGradient: TCheckBox;
    Label2: TLabel;
    CBDirection: TComboFlat;
    CheckBox1: TCheckBox;
    LHeight: TLabel;
    TBTransp: TTrackBar;
    LTransp: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure CheckGradientClick(Sender: TObject);
    procedure CBDirectionChange(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure TBTranspChange(Sender: TObject);
  private
    { Private declarations }
    VolumePipe : TVolumePipeSeries;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeBrushDlg, TeeEdiGrad;

procedure TVolumePipeSeriesEditor.FormShow(Sender: TObject);
begin
  VolumePipe:=TVolumePipeSeries(Tag);

  if Assigned(VolumePipe) then
  begin
    Edit2.Text:=IntToStr(VolumePipe.ConePercent);

    CheckGradient.Checked:=VolumePipe.Gradient.Visible;

    if VolumePipe.Gradient.Direction=gdTopBottom then
       CBDirection.ItemIndex:=0
    else
       CBDirection.ItemIndex:=1;

    TBTransp.Position:=VolumePipe.Transparency;
    LTransp.Caption:=IntToStr(TBTransp.Position);
  end;
end;

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

procedure TVolumePipeSeriesEditor.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then
     VolumePipe.Brush.Style:=bsClear
  else
     VolumePipe.Brush.Style:=bsSolid;
end;

procedure TVolumePipeSeriesEditor.Edit2Change(Sender: TObject);
begin
  if Assigned(VolumePipe) then
     VolumePipe.ConePercent:=StrToInt(Edit2.Text);
end;

procedure TVolumePipeSeriesEditor.CheckGradientClick(Sender: TObject);
begin
  VolumePipe.Gradient.Visible:=CheckGradient.Checked;
end;

procedure TVolumePipeSeriesEditor.CBDirectionChange(Sender: TObject);
begin
  if CBDirection.ItemIndex=0 then
     VolumePipe.Gradient.Direction:=gdTopBottom
  else
     VolumePipe.Gradient.Direction:=gdRightLeft;
end;

procedure TVolumePipeSeriesEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabBorder) and (TabBorder.ControlCount=0) then
     TPenDialog.InsertForm(VolumePipe.Pen,TabBorder)
  else
  if (PageControl1.ActivePage=TabLines) and (TabLines.ControlCount=0) then
     TPenDialog.InsertForm(VolumePipe.LinesPen,TabLines)
  else
  if (PageControl1.ActivePage=TabPattern) and (TabPattern.ControlCount=0) then
     TBrushDialog.AddDialog(VolumePipe.Brush,TabPattern);
end;

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

initialization
  RegisterClass(TVolumePipeSeriesEditor);
end.
