{**********************************************}
{    TeePreviewPanelEditor                     }
{   Copyright (c) 1999-2020 by Steema Software }
{**********************************************}
unit TeePreviewPanelEditor;
{$I TeeDefs.inc}

interface

uses {$IFNDEF LINUX}
     Windows, Messages,
     {$ENDIF}
     SysUtils, Classes,

     Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons,

     TeePreviewPanel, TeeProcs, TeePenDlg, TeCanvas;

type
  TFormPreviewPanelEditor = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    CBAllowMove: TCheckBox;
    CBAllowResize: TCheckBox;
    CBDragImage: TCheckBox;
    CBAsBitmap: TCheckBox;
    CBShowImage: TCheckBox;
    RGOrientation: TRadioGroup;
    Panel1: TPanel;
    TabPanel: TTabSheet;
    TabMargins: TTabSheet;
    BPaperColor: TButtonColor;
    Panel2: TPanel;
    Button1: TButton;
    procedure FormShow(Sender: TObject);
    procedure CBAllowMoveClick(Sender: TObject);
    procedure CBAllowResizeClick(Sender: TObject);
    procedure CBDragImageClick(Sender: TObject);
    procedure CBAsBitmapClick(Sender: TObject);
    procedure CBShowImageClick(Sender: TObject);
    procedure RGOrientationClick(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
    TeePreviewPanel1 : TTeePreviewPanel;
  public
    { Public declarations }
    Constructor CreatePanel(AOwner:TComponent; APanel:TTeePreviewPanel);
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

uses
  TeeEdiPane;

Constructor TFormPreviewPanelEditor.CreatePanel(AOwner:TComponent; APanel:TTeePreviewPanel);
begin
  inherited Create(AOwner);
  TeePreviewPanel1:=APanel;
  TeeTranslateControl(Self);
end;

procedure TFormPreviewPanelEditor.FormShow(Sender: TObject);
begin
  if Assigned(TeePreviewPanel1) then
  begin
    With TeePreviewPanel1 do
    begin
      CBAllowMove.Checked   :=AllowMove;
      CBAllowResize.Checked :=AllowResize;
      CBDragImage.Checked   :=DragImage;
      CBAsBitmap.Checked    :=AsBitmap;
      CBShowImage.Checked   :=ShowImage;
      RGOrientation.ItemIndex:=Ord(Orientation);
    end;

    BPaperColor.LinkProperty(TeePreviewPanel1,'PaperColor');  { do not translate }
  end;

  PageControl1.ActivePage:=TabSheet1;
end;

procedure TFormPreviewPanelEditor.CBAllowMoveClick(Sender: TObject);
begin
  TeePreviewPanel1.AllowMove:=CBAllowMove.Checked
end;

procedure TFormPreviewPanelEditor.CBAllowResizeClick(Sender: TObject);
begin
  TeePreviewPanel1.AllowResize:=CBAllowResize.Checked
end;

procedure TFormPreviewPanelEditor.CBDragImageClick(Sender: TObject);
begin
  TeePreviewPanel1.DragImage:=CBDragImage.Checked
end;

procedure TFormPreviewPanelEditor.CBAsBitmapClick(Sender: TObject);
begin
  TeePreviewPanel1.AsBitmap:=CBAsBitmap.Checked
end;

procedure TFormPreviewPanelEditor.CBShowImageClick(Sender: TObject);
begin
  TeePreviewPanel1.ShowImage:=CBShowImage.Checked
end;

procedure TFormPreviewPanelEditor.RGOrientationClick(Sender: TObject);
begin
  With TeePreviewPanel1 do
  Case RGOrientation.ItemIndex of
    0: Orientation:=ppoDefault;
    1: Orientation:=ppoPortrait;
  else
    Orientation:=ppoLandscape;
  end;
end;

procedure TFormPreviewPanelEditor.PageControl1Change(Sender: TObject);
begin
  if (PageControl1.ActivePage=TabPanel) and (TabPanel.ControlCount=0) then
     TFormTeePanel.InsertAt(Self,TabPanel,TeePreviewPanel1)
  else
  if (PageControl1.ActivePage=TabMargins) and (TabMargins.ControlCount=0) then
     TPenDialog.InsertForm(TeePreviewPanel1.Margins,TabMargins);
end;

end.

