📄 pswindow.pas
字号:
begin
if Value<>FWindowLeft then
begin
FWindowLeft:=Value;
if Assigned(Form) then Form.Left:=FWindowLeft;
end;
end;
procedure TCustomPreviewWindow.SetWindowTop(const Value: Integer);
begin
if Value<>FWindowTop then
begin
FWindowTop:=Value;
if Assigned(Form) then Form.Top:=FWindowTop;
end;
end;
procedure TCustomPreviewWindow.SetWindowWidth(const Value: Integer);
begin
if Value<>FWindowWidth then
begin
FWindowWidth:=Value;
if Assigned(Form) then Form.Width:=FWindowWidth;
end;
end;
procedure TCustomPreviewWindow.SetWindowHeight(const Value: Integer);
begin
if Value<>FWindowHeight then
begin
FWindowHeight:=Value;
if Assigned(Form) then Form.Height:=FWindowHeight;
end;
end;
procedure TCustomPreviewWindow.SetColor(const Value: TColor);
begin
if Value<>FColor then
begin
FColor:=Value;
if Assigned(Preview) then Preview.Color:=FColor;
end;
end;
procedure TCustomPreviewWindow.SetShadowColor(const Value: TColor);
begin
if Value<>FShadowColor then
begin
FShadowColor:=Value;
if Assigned(Preview) then Preview.ShadowColor:=FShadowColor;
end;
end;
procedure TCustomPreviewWindow.SetShadowSize(const Value: Integer);
begin
if Value<>FShadowSize then
begin
FShadowSize:=Value;
if Assigned(Preview) then Preview.ShadowSize:=FShadowSize;
end;
end;
procedure TCustomPreviewWindow.SetPageIndex(const Value: Integer);
begin
if Assigned(Preview) then Preview.PageIndex:=Value;
end;
function TCustomPreviewWindow.GetPageIndex: Integer;
begin
if Assigned(Preview) then Result:=Preview.PageIndex
else Result:=1;
end;
procedure TCustomPreviewWindow.SetDragScroll(const Value: Boolean);
begin
if Value<>FDragScroll then
begin
FDragScroll:=Value;
if Assigned(Preview) then Preview.DragScroll:=FDragScroll;
end;
end;
procedure TCustomPreviewWindow.SetScrollTracking(const Value: Boolean);
begin
if Value<>FScrollTracking then
begin
FScrollTracking:=Value;
if Assigned(Preview) then Preview.ScrollTracking:=FScrollTracking;
end;
end;
procedure TCustomPreviewWindow.SetViewMode(const Value: TViewMode);
begin
if Value<>FViewMode then
begin
FViewMode:=Value;
if Assigned(Preview) then Preview.ViewMode:=FViewMode;
end;
end;
procedure TCustomPreviewWindow.SetViewScale(const Value: Integer);
begin
if Value<>FViewScale then
begin
FViewScale:=Value;
if Assigned(Preview) then Preview.ViewScale:=FViewScale;
end;
end;
procedure TCustomPreviewWindow.SetButtons(const Value: TButtons);
begin
if Value<>FButtons then
begin
FButtons:=Value;
if Assigned(Toolbar) then Toolbar.Buttons:=FButtons;
end;
end;
procedure TCustomPreviewWindow.SetFlat(const Value: Boolean);
begin
if Value<>FFlat then
begin
FFlat:=Value;
if Assigned(Toolbar) then Toolbar.Flat:=FFlat;
end;
end;
procedure TCustomPreviewWindow.SetScaleBox(const Value: Boolean);
begin
if Value<>FScaleBox then
begin
FScaleBox:=Value;
if Assigned(Toolbar) then Toolbar.ScaleBox:=FScaleBox;
end;
end;
procedure TCustomPreviewWindow.SetScaleBoxPos(const Value: TButtonKind);
begin
if Value<>FScaleBoxPos then
begin
FScaleBoxPos:=Value;
if Assigned(Toolbar) then Toolbar.ScaleBoxPos:=FScaleBoxPos;
end;
end;
procedure TCustomPreviewWindow.SetShowHint(const Value: Boolean);
begin
if Value<>FShowHint then
begin
FShowHint:=Value;
if Assigned(Toolbar) then Toolbar.ShowHint:=FShowHint;
end;
end;
procedure TCustomPreviewWindow.SetUserButtonEnabled(const Value: Boolean);
begin
if Value<>FUserButtonEnabled then
begin
FUserButtonEnabled:=Value;
if Assigned(Toolbar) then Toolbar.UserButtonEnabled:=FUserButtonEnabled;
end;
end;
procedure TCustomPreviewWindow.SetUserButtonGlyph(const Value: TBitmap);
begin
if Value<>FUserButtonGlyph then
begin
FUserButtonGlyph.Assign(Value);
if Assigned(Toolbar) then Toolbar.UserButtonGlyph:=FUserButtonGlyph;
end;
end;
procedure TCustomPreviewWindow.SetUserButtonHint(const Value: string);
begin
if Value<>FUserButtonHint then
begin
FUserButtonHint:=Value;
if Assigned(Toolbar) then Toolbar.UserButtonHint:=FUserButtonHint;
end;
end;
procedure TCustomPreviewWindow.SetOnUserButtonClick(const Value: TNotifyEvent);
begin
FOnUserButtonClick:=Value;
if Assigned(Toolbar) then Toolbar.OnUserButtonClick:=FOnUserButtonClick;
end;
procedure TCustomPreviewWindow.SetPagePanelWidth(const Value: Integer);
begin
if Value<>FPagePanelWidth then
begin
FPagePanelWidth:=Value;
if Assigned(StatusBar) then StatusBar.PagePanelWidth:=FPagePanelWidth;
end;
end;
procedure TCustomPreviewWindow.SetPanels(const Value: TPanels);
begin
if Value<>FPanels then
begin
FPanels:=Value;
if Assigned(StatusBar) then StatusBar.Panels:=FPanels;
end;
end;
procedure TCustomPreviewWindow.SetScalePanelWidth(const Value: Integer);
begin
if Value<>FScalePanelWidth then
begin
FScalePanelWidth:=Value;
if Assigned(StatusBar) then StatusBar.ScalePanelWidth:=FScalePanelWidth;
end;
end;
procedure TCustomPreviewWindow.SetUserText(const Value: string);
begin
if Value<>FUserText then
begin
FUserText:=Value;
if Assigned(StatusBar) then StatusBar.UserText:=FUserText;
end;
end;
procedure TCustomPreviewWindow.SetSizeGrip(const Value: Boolean);
begin
if Value<>FSizeGrip then
begin
FSizeGrip:=Value;
if Assigned(StatusBar) then StatusBar.SizeGrip:=FSizeGrip;
end;
end;
function TCustomPreviewWindow.GetPreview: TPreview;
begin
Result:=nil;
if Assigned(FForm) and Assigned(FForm.FPreview) then Result:=FForm.FPreview;
end;
function TCustomPreviewWindow.GetToolbar: TPreviewToolbar;
begin
Result:=nil;
if Assigned(FForm) and Assigned(FForm.FToolbar) then Result:=FForm.FToolbar;
end;
function TCustomPreviewWindow.GetStatusBar: TPreviewStatusBar;
begin
Result:=nil;
if Assigned(FForm) and Assigned(FForm.FStatusBar) then Result:=FForm.FStatusBar;
end;
procedure TCustomPreviewWindow.PreviewPageChanged(Sender: TObject);
begin
if Assigned(FOnPageChanged) then FOnPageChanged(Self);
end;
procedure TCustomPreviewWindow.Update;
begin
if Assigned(FPrintJob) and Assigned(FForm) and Assigned(FForm.FPreview) then
FForm.FPreview.Update;
inherited;
end;
procedure TCustomPreviewWindow.CopyProperties;
begin
with Form do
begin
BorderIcons:=FBorderIcons;
BorderStyle:=FBorderStyle;
Caption:=FCaption;
Ctl3D:=FCtl3D;
Font.Assign(FFont);
Icon.Assign(FIcon);
Position:=FPosition;
WindowState:=FWindowState;
Left:=FWindowLeft;
Top:=FWindowTop;
Width:=FWindowWidth;
Height:=FWindowHeight;
OnClose:=OnCloseForm;
end;
with Preview do
begin
PageIndex:=1;
DragScroll:=FDragScroll;
ScrollTracking:=FScrollTracking;
ViewMode:=FViewMode;
ViewScale:=FViewScale;
PrintJob:=FPrintJob;
OnPageChanged:=PreviewPageChanged;
end;
with Toolbar do
begin
Buttons:=FButtons;
Flat:=FFlat;
ScaleBox:=FScaleBox;
ScaleBoxPos:=FScaleBoxPos;
ShowHint:=FShowHint;
UserButtonEnabled:=FUserButtonEnabled;
UserButtonGlyph:=FUserButtonGlyph;
UserButtonHint:=FUserButtonHint;
OnUserButtonClick:=FOnUserButtonClick;
end;
with StatusBar do
begin
PagePanelWidth:=FPagePanelWidth;
Panels:=FPanels;
ScalePanelWidth:=FScalePanelWidth;
UserText:=FUserText;
end;
end;
constructor TCustomPreviewWindow.Create(AOwner: TComponent);
begin
inherited;
FBorderIcons:=[biSystemMenu,biMinimize,biMaximize];
FBorderStyle:=bsSizeable;
FFont:=TFont.Create;
FIcon:=TIcon.Create;
FUserButtonGlyph:=TBitmap.Create;
// form properties
FCtl3D:=True;
FWindowWidth:=400;
FWindowHeight:=500;
// preview properties
FColor:=clGray;
FShadowColor:=$00404040;
FShadowSize:=8;
FDragScroll:=True;
// toolbar properties
FButtons:=[btnPrint,btnPrinterSetupDialog,btnFirstPage,btnPrevPage,btnNextPage,btnLastPage,btnZoomIn,btnZoomOut];
FFlat:=True;
FScaleBox:=True;
FScaleBoxPos:=btnZoomOut;
FShowHint:=True;
FUserButtonEnabled:=True;
// statusbar properties
FPagePanelWidth:=100;
FPanels:=[pnPage,pnScale];
FScalePanelWidth:=100;
FSizeGrip:=True;
if Assigned(FOnCreate) then FOnCreate(Self);
end;
destructor TCustomPreviewWindow.Destroy;
begin
if Assigned(FOnDestroy) then FOnDestroy(Self);
FFont.Free;
FIcon.Free;
FUserButtonGlyph.Free;
inherited;
end;
procedure TCustomPreviewWindow.Show;
begin
if not Assigned(Form) then Form:=TPreviewForm.CreateWindow(Self);
CopyProperties;
if Assigned(FOnShow) then FOnShow(Self);
Form.Show;
end;
procedure TCustomPreviewWindow.ShowModal;
begin
if not Assigned(Form) then Form:=TPreviewForm.CreateWindow(Self);
CopyProperties;
if Assigned(FOnShow) then FOnShow(Self);
Form.ShowModal;
end;
procedure TCustomPreviewWindow.Close;
begin
if Assigned(Form) then
begin
if Assigned(FOnClose) then FOnClose(Self);
Form.Close;
end;
end;
procedure Register;
begin
RegisterComponents('Print Suite', [TPreviewWindow]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -