unit StandardLibsFme;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, JimPages, JimTabs, StandardBillsFme, UtilMethods, StandardLibs;

type
  TStandardLibsFrame = class(TFrame)
    jtsStandardLibs: TJimTabSet;
    jpStandardLibs: TJimPages;
    jpStandardLibsXm: TJimPage;
    jpStandardLibsGcl: TJimPage;
    procedure jtsStandardLibsChange(Sender: TObject; NewTab: Integer;
      var AllowChange: Boolean);
  private
    FGclBillsFrame: TStandardBillsFrame;
    FXmBillsFrame: TStandardBillsFrame;
    FStandardLibs: TStandardLibs;

    function CreateBillsFrame(AParent: TWinControl; ABillsType: TBillsType): TStandardBillsFrame;
  public
    constructor Create(AStandardLibs: TStandardLibs);
    destructor Destroy; override;

    procedure ConnectStandardLibs;

    property StandardLibs: TStandardLibs read FStandardLibs;

    property XmBillsFrame: TStandardBillsFrame read FXmBillsFrame;
    property GclBillsFrame: TStandardBillsFrame read FGclBillsFrame;
  end;

implementation

{$R *.dfm}

{ TFrame1 }

procedure TStandardLibsFrame.ConnectStandardLibs;
begin
  FXmBillsFrame.ConnectStandardLib;
  FGclBillsFrame.ConnectStandardLib;
end;

constructor TStandardLibsFrame.Create(AStandardLibs: TStandardLibs);
begin
  inherited Create(nil);
  FStandardLibs := AStandardLibs;
  FXmBillsFrame := CreateBillsFrame(jpStandardLibsXm, btXm);
  FGclBillsFrame := CreateBillsFrame(jpStandardLibsGcl, btGcl);
  ConnectStandardLibs;
end;

function TStandardLibsFrame.CreateBillsFrame(AParent: TWinControl;
  ABillsType: TBillsType): TStandardBillsFrame;
begin
  Result := TStandardBillsFrame.Create(FStandardLibs);
  Result.BillsType := ABillsType;
  AlignControl(Result, AParent, alClient);
end;

destructor TStandardLibsFrame.Destroy;
begin
  FXmBillsFrame.Free;
  FGclBillsFrame.Free;
  inherited;
end;

procedure TStandardLibsFrame.jtsStandardLibsChange(Sender: TObject;
  NewTab: Integer; var AllowChange: Boolean);
begin
  jpStandardLibs.ActivePageIndex := NewTab;
end;

end.
