{
===============================================================================
  Copyright (©) 2002. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 31-12-2002
  Versión actual: 1.0.0
  Fecha versión actual: 31-12-2002
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
===============================================================================
}

unit VistaPrevia;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  RDXFRAME, StdCtrls, RdxComboBox, RdxBotones, RdxCampos, Configuracion,
  ExtCtrls, RdxBarras, RdxTitulos, Grids, DBGrids, RdxPaneles, RdxRadioButton,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  FR_View, cxImageComboBox;

type
  TfrVistaPrevia = class(TRdxFrame)
    RdxPanel1: TRdxPanel;
    pnlBarraGrid: TRdxPanel;
    bUnaPagina: TRdxBoton;
    bDosPaginas: TRdxBoton;
    eCodigo: TLabel;
    bAnchoPagina: TRdxBoton;
    cbxZoom: TcxImageComboBox;
    brSimple: TRdxBarraInferior;
    bImprimir: TRdxBoton;
    bCancelar: TRdxBoton;
    procedure bUnaPaginaClick(Sender: TObject);
    procedure bDosPaginasClick(Sender: TObject);
    procedure bAnchoPaginaClick(Sender: TObject);
    procedure cxImageComboBox1PropertiesEditValueChanged(Sender: TObject);
    procedure bCancelarClick(Sender: TObject);
    procedure bImprimirClick(Sender: TObject);
  private
    FPreview : TfrPreview;
  protected
    function CloseFrame : Boolean; override;
  public
    constructor Create (AOwner : TComponent); override;
  published
    property Preview : TfrPreview read FPreview;
  end;

var
  frVistaPrevia: TfrVistaPrevia;

implementation

{$R *.DFM}

uses
  Mensajes;


procedure TfrVistaPrevia.bUnaPaginaClick(Sender: TObject);
begin
  FPreview.OnePage;
  cbxZoom.EditValue := FPreview.Zoom;
end;

procedure TfrVistaPrevia.bDosPaginasClick(Sender: TObject);
begin
  FPreview.TwoPages;
  cbxZoom.EditValue := FPreview.Zoom;
end;

procedure TfrVistaPrevia.bAnchoPaginaClick(Sender: TObject);
begin
  FPreview.PageWidth;
  cbxZoom.EditValue := FPreview.Zoom;
end;

procedure TfrVistaPrevia.cxImageComboBox1PropertiesEditValueChanged(
  Sender: TObject);
begin
  FPreview.Zoom := cbxZoom.EditValue;
end;

function TfrVistaPrevia.CloseFrame: Boolean;
begin
  TForm(GetParentForm(Self)).OnMouseWheelUp := NIL;
  TForm(GetParentForm(Self)).OnMouseWheelDown := NIL;
  FPreview.Parent := NIL;
  FPreview.Free;
  Result := inherited CloseFrame;
end;

constructor TfrVistaPrevia.Create(AOwner: TComponent);
begin
  inherited;
  FPreview := TfrPreview.Create(Self);
  FPreview.Parent := RdxPanel1;
  FPreview.Align := alClient;
  FPreview.PageWidth;
end;

procedure TfrVistaPrevia.bCancelarClick(Sender: TObject);
begin
  if not IsModal then
    (Owner as TRdxFrame).CloseFrame
  else
    CloseFrame;
end;

procedure TfrVistaPrevia.bImprimirClick(Sender: TObject);
begin
  FPreview.Print;
end;

end.
