unit uViewControlesBase_TreeView;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewBase, cxGraphics, cxCustomData, cxStyles, cxTL,
  cxImageComboBox, cxMaskEdit, cxTextEdit, cxInplaceContainer, cxDBTL,
  cxControls, cxTLData, Menus, uBizControlesBase, DB, uDADataTable,
  ImgList, PngImageList;

type
  IViewControlesBase = interface(IViewBase)
  ['{D991FCEC-08DB-4F77-BD57-FA04B3C88788}']
    function GetDblClick: TNotifyEvent;
    procedure SetDblClick(const Value: TNotifyEvent);
    property OnDblClick: TNotifyEvent read GetDblClick write SetDblClick;

    function GetPopupMenu: TPopupMenu;
    procedure SetPopupMenu(const Value: TPopupMenu); 
    property PopupMenu: TPopupMenu read GetPopupMenu write SetPopupMenu;

    function GetControl: IBizControlBase;
    procedure SetControl(const Value: IBizControlBase);
    property Control: IBizControlBase read GetControl write SetControl;

    procedure Refresh;
  end;

  TfrViewControlesBase = class(TfrViewBase, IViewControlesBase)
    cxTreeList: TcxDBTreeList;
    cxDBTreeListICONO: TcxDBTreeListColumn;
    cxDBTreeListORDEN: TcxDBTreeListColumn;
    cxDBTreeListNOMBRE: TcxDBTreeListColumn;
    cxDBTreeListDESCRIPCION: TcxDBTreeListColumn;
    cxDBTreeListDUMMY: TcxDBTreeListColumn;
    cxStyleRepository1: TcxStyleRepository;
    cxStyleTITULO: TcxStyle;
    cxStyleDESCRIPCION: TcxStyle;
    cxStyle1: TcxStyle;
    ReportImages: TPngImageList;
    dsDataTable: TDADataSource;
  protected
    FControl : IBizControlBase;
    FOnDblClick: TNotifyEvent;
    FPopupMenu: TPopupMenu;
    
    function GetDblClick: TNotifyEvent; virtual;
    procedure SetDblClick(const Value: TNotifyEvent); virtual;

    function GetPopupMenu: TPopupMenu; virtual;
    procedure SetPopupMenu(const Value: TPopupMenu); virtual;

    function GetControl: IBizControlBase; virtual;
    procedure SetControl(const Value: IBizControlBase); virtual;
  public
    procedure Refresh; override;  
    property Control: IBizControlBase read GetControl write SetControl;
    property OnDblClick: TNotifyEvent read GetDblClick write SetDblClick;
    property PopupMenu: TPopupMenu read GetPopupMenu write SetPopupMenu;
  end;

implementation

{$R *.dfm}

{ TfrViewControlesBase }

function TfrViewControlesBase.GetControl: IBizControlBase;
begin
  Result := FControl;
end;

function TfrViewControlesBase.GetDblClick: TNotifyEvent;
begin
  Result := FOnDblClick;
end;

function TfrViewControlesBase.GetPopupMenu: TPopupMenu;
begin
  Result := FPopupMenu;
end;

procedure TfrViewControlesBase.Refresh;
begin
  inherited;
  cxTreeList.Refresh;
end;

procedure TfrViewControlesBase.SetControl(const Value: IBizControlBase);
begin
  FControl := Value;
  dsDataTable.DataTable := Value.DataTable;
end;

procedure TfrViewControlesBase.SetDblClick(const Value: TNotifyEvent);
begin
  FOnDblClick := Value;
end;

procedure TfrViewControlesBase.SetPopupMenu(const Value: TPopupMenu);
begin
  FPopupMenu := Value;
  cxTreeList.PopupMenu := FPopupMenu;
end;

end.

