{********************************************}
{    TFramedBorder and TCircularFrame        }
{ For TCircularGauge, TPieSeries, etc        }
{ Copyright (c) 1995-2020 by Steema Software }
{        All Rights Reserved                 }
{********************************************}
unit TeeFrames;
{$I TeeDefs.inc}

interface

uses
  {$IFNDEF LINUX}
  Windows, Messages,
  {$ENDIF}
  SysUtils, Classes, Math,
  {$IFDEF D6}
  Types, StrUtils,
  {$ENDIF}

  Graphics, Forms, Controls, StdCtrls, ComCtrls, ExtCtrls,

  TeeProcs, TeEngine, Chart, Series, TeCanvas, TeeEdiGrad;

type
  TFramedBorderEditor = class(TForm)
    PageControl2: TPageControl;
    TabSheet8: TTabSheet;
    Label3: TLabel;
    CBFrameVisible: TCheckBox;
    EWidth: TEdit;
    UDWidth: TUpDown;
    TabSheet4: TTabSheet;
    TabSheet5: TTabSheet;
    TabSheet6: TTabSheet;
    TabShadow: TTabSheet;
    TabEmboss: TTabSheet;
    TabPattern: TTabSheet;
    RGStyle: TRadioGroup;
    procedure FormShow(Sender: TObject);
    procedure CBFrameVisibleClick(Sender: TObject);
    procedure EWidthChange(Sender: TObject);
    procedure PageControl2Change(Sender: TObject);
    procedure RGStyleClick(Sender: TObject);
  private
    { Private declarations }
    Frame : TFramedBorder;
  public
    { Public declarations }
    class function InsertDialog(AParent:TWinControl; AFrame:TFramedBorder):TFramedBorderEditor;
  end;

implementation

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

uses
  TeePenDlg, TeeBrushDlg, TeeShadowEditor;

type
  TFrameAccess=class(TFramedBorder);

procedure TFramedBorderEditor.FormShow(Sender: TObject);
begin
  if Assigned(Frame) then
  begin
    with Frame do
    begin
      TBrushDialog.AddDialog(OuterBrush,TabSheet4);
      TBrushDialog.AddDialog(MiddleBrush,TabSheet5);
      TBrushDialog.AddDialog(InnerBrush,TabSheet6);

      TTeeShadowEditor.InsertForm(Shadow,TabShadow);
      TTeeShadowEditor.InsertForm(Emboss,TabEmboss);

      CBFrameVisible.Checked:=Visible;
      UDWidth.Position:=Width;

      if Circled then
         RGStyle.ItemIndex:=0
      else
         RGStyle.ItemIndex:=1;

    end;

    if TFrameAccess(Frame).INoBrush then
       TabPattern.TabVisible:=False;
  end;
end;

class function TFramedBorderEditor.InsertDialog(AParent: TWinControl;
  AFrame: TFramedBorder): TFramedBorderEditor;
begin
  result:=TFramedBorderEditor.Create(AParent.Owner);
  result.Frame:=AFrame;
  result.Align:=alClient;
  TeeTranslateControl(result);
  AddFormTo(result,AParent);
end;

procedure TFramedBorderEditor.CBFrameVisibleClick(Sender: TObject);
begin
  Frame.Visible:=CBFrameVisible.Checked;
end;

procedure TFramedBorderEditor.EWidthChange(Sender: TObject);
begin
  if Showing then
     Frame.Width:=UDWidth.Position;
end;

procedure TFramedBorderEditor.PageControl2Change(Sender: TObject);
begin
  if (PageControl2.ActivePage=TabPattern) and (TabPattern.ControlCount=0) then
     TBrushDialog.AddDialog(Frame.Brush,TabPattern)
end;

procedure TFramedBorderEditor.RGStyleClick(Sender: TObject);
begin
  Frame.Circled:=RGStyle.ItemIndex=0;
end;

end.
