unit uEditorConfiguracion;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,     
     
     
    
     
     StdCtrls,
  ExtCtrls, cxControls, dxNavBar, dxNavBarCollns, cxClasses, dxNavBarBase,
  ComCtrls, uViewConfiguracionBase;

type
  TfConfiguracionEditor = class(TForm)
    dxNavBar: TdxNavBar;
    Panel2: TPanel;
    bCancelar: TButton;
    bAceptar: TButton;
    GroupCategorias: TdxNavBarGroup;
    PageControlMain: TPageControl;
    procedure dxNavBarLinkClick(Sender: TObject; ALink: TdxNavBarItemLink);
    procedure FormShow(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    FListaVistas : TStringList;
  public
    procedure CargarValores;
    procedure GuardarValores;
    procedure AnadirVista(AVista : TfrViewConfiguracionBase; const AEtiqueta : String);
  end;


implementation

{$R *.dfm}

uses
  uDisplayUtils;

{ TfConfiguracionEditor }

procedure TfConfiguracionEditor.AnadirVista(AVista: TfrViewConfiguracionBase;
  const AEtiqueta: String);
var
  AItem : TdxNavBarItem;
  ATab : TTabSheet;
begin
  if Assigned(AVista) then
  begin
    ATab := TTabSheet.Create(PageControlMain);
    ATab.PageControl := PageControlMain;
    ATab.TabVisible := False;

    AVista.Parent := ATab;

    AItem := dxNavBar.Items.Add;
    AItem.Tag := ATab.PageIndex;
    AItem.Caption :=  AEtiqueta;
    AItem.Name := 'ItemName' + IntToStr(ATab.PageIndex);
    dxNavBar.Groups.Items[0].CreateLink(AItem);

    FListaVistas.AddObject(AEtiqueta, AVista);
  end;
end;

procedure TfConfiguracionEditor.CargarValores;
var
  I: Integer;
begin
  for I := 0 to FListaVistas.Count - 1 do
    TfrViewConfiguracionBase(FListaVistas.Objects[i]).CargarValores;
end;

procedure TfConfiguracionEditor.dxNavBarLinkClick(Sender: TObject;
  ALink: TdxNavBarItemLink);
var
  APageIndex : Integer;
begin
  APageIndex := ALink.Item.Tag;
  if (APageIndex > -1) and (APageIndex < PageControlMain.PageCount) then
    PageControlMain.ActivePageIndex := APageIndex;
end;

procedure TfConfiguracionEditor.FormCreate(Sender: TObject);
begin
  FListaVistas := TStringList.Create;
end;

procedure TfConfiguracionEditor.FormDestroy(Sender: TObject);
begin
  FreeANDNIL(FListaVistas);
end;

procedure TfConfiguracionEditor.FormShow(Sender: TObject);
begin
  ScaleFormFont(Self);
  PageControlMain.ActivePageIndex := 0;
  dxNavBar.Groups[0].Links[0].Selected := True;
end;

procedure TfConfiguracionEditor.GuardarValores;
var
  I: Integer;
begin
  for I := 0 to FListaVistas.Count - 1 do
    TfrViewConfiguracionBase(FListaVistas.Objects[i]).GuardarValores;
end;

end.



