{********************************************}
{ TGridBandTool Editor Dialog                }
{ Copyright (c) 1999-2020 by Steema Software }
{********************************************}
unit TeeGridBandToolEdit;
{$I TeeDefs.inc}

interface

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

  {$IFDEF D16}
  System.UITypes,
  {$ENDIF}
  
  Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,

  {$IFDEF MSWINDOWS}
  TeeGDIPlus,
  {$ENDIF}

  TeeAxisToolEdit, TeCanvas, TeePenDlg, TeeProcs, TeeDraw3D, TeeTools, TeeEdiGrad;

type
  TGridBandToolEdit = class(TAxisToolEditor)
    PageControl1: TPageControl;
    TabBand1: TTabSheet;
    TabBand2: TTabSheet;
    Panel1: TPanel;
    Label2: TLabel;
    TBTransp1: TTrackBar;
    LTransp1: TLabel;
    Panel2: TPanel;
    Label3: TLabel;
    LTransp2: TLabel;
    TBTransp2: TTrackBar;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure TBTransp1Change(Sender: TObject);
    procedure TBTransp2Change(Sender: TObject);
  private
    { Private declarations }
    GridBand : TGridBandTool;
  public
    { Public declarations }
  end;

implementation

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

uses
  TeeBrushDlg;

procedure TGridBandToolEdit.FormCreate(Sender: TObject);
begin
  inherited;
  BPen.Visible:=False;
end;

procedure TGridBandToolEdit.FormShow(Sender: TObject);
begin
  inherited;
  GridBand:=TGridBandTool(Tag);
  PageControl1.ActivePageIndex:=0;
  PageControl1Change(Self);
end;

procedure TGridBandToolEdit.TabControl1Change(Sender: TObject);
begin
  if Assigned(GridBand) then
  begin
    TBTransp1.Position:=GridBand.Band1.Transparency;
    LTransp1.Caption:=IntToStr(TBTransp1.Position);

    TBTransp2.Position:=GridBand.Band2.Transparency;
    LTransp2.Caption:=IntToStr(TBTransp2.Position);
  end;
end;

procedure TGridBandToolEdit.PageControl1Change(Sender: TObject);
begin
  if Assigned(GridBand) then
  begin
    if (PageControl1.ActivePage=TabBand1) and (TabBand1.ControlCount<2) then
       TBrushDialog.AddDialog(GridBand.Band1,TabBand1)
    else
    if (PageControl1.ActivePage=TabBand2) and (TabBand2.ControlCount<2) then
       TBrushDialog.AddDialog(GridBand.Band2,TabBand2);
  end;
end;

procedure TGridBandToolEdit.TBTransp1Change(Sender: TObject);
begin
  if Showing then
  begin
    GridBand.Band1.Transparency:=TBTransp1.Position;
    LTransp1.Caption:=IntToStr(TBTransp1.Position);
  end;
end;

procedure TGridBandToolEdit.TBTransp2Change(Sender: TObject);
begin
  if Showing then
  begin
    GridBand.Band2.Transparency:=TBTransp2.Position;
    LTransp2.Caption:=IntToStr(TBTransp2.Position);
  end;
end;

initialization
  RegisterClass(TGridBandToolEdit);
end.
