unit PriceMarginFme;

interface

uses
  ProjectGLFme, PriceMarginBillsFme,
  ProjectData,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, JimPages, ComCtrls, ToolWin, XPMenu;

type
  TPriceMarginFrame = class(TFrame)
    pnlTopTag: TPanel;
    tbTopTag: TToolBar;
    tobtnBills: TToolButton;
    tobtnGL: TToolButton;
    jpsPriceMargin: TJimPages;
    jpsPriceMarginBills: TJimPage;
    jpsPriceMarginGL: TJimPage;
    xpm: TXPMenu;
    procedure tobtnBillsClick(Sender: TObject);
  private
    FProjectData: TProjectData;

    FProjectGLFrame: TProjectGLFrame;
    FPriceMarginBillsFrame: TPriceMarginBillsFrame;
  public
    constructor Create(AProjectData: TProjectData);
    destructor Destroy; override;

    procedure RefreshBills;

    procedure ResetViewControl;
  end;

implementation

uses
  UtilMethods;

{$R *.dfm}

{ TPriceMarginFrame }

constructor TPriceMarginFrame.Create(AProjectData: TProjectData);
begin
  inherited Create(nil);
  FProjectData := AProjectData;

  FProjectGLFrame := TProjectGLFrame.Create(FProjectData.ProjectGLData);
  AlignControl(FProjectGLFrame, jpsPriceMarginGL, alClient);

  FPriceMarginBillsFrame := TPriceMarginBillsFrame.Create(FProjectData.PriceMarginBillsData);
  AlignControl(FPriceMarginBillsFrame, jpsPriceMarginBills, alClient);
end;

destructor TPriceMarginFrame.Destroy;
begin
  FPriceMarginBillsFrame.Free;
  FProjectGLFrame.Free;
  inherited;
end;

procedure TPriceMarginFrame.RefreshBills;
begin
  FProjectData.PriceMarginBillsData.RefreshBills;
end;

procedure TPriceMarginFrame.ResetViewControl;
begin
  FProjectGLFrame.ResetViewControl;
  FPriceMarginBillsFrame.ResetViewControl;
end;

procedure TPriceMarginFrame.tobtnBillsClick(Sender: TObject);
begin
  tobtnGL.Down := tobtnGL.Tag = TToolButton(Sender).Tag;
  tobtnBills.Down := tobtnBills.Tag = TToolButton(Sender).Tag;
  jpsPriceMargin.ActivePageIndex := TToolButton(Sender).Tag;
end;

end.
