You've already forked lazarus-ccr
GridPrinter: Improved selection of zoom factor and zoom modes in PrintPreviewDialog.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8617 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -159,7 +159,8 @@ object MainForm: TMainForm
|
|||||||
FormParams.Height = 800
|
FormParams.Height = 800
|
||||||
FormParams.Position = poDesigned
|
FormParams.Position = poDesigned
|
||||||
GridPrinter = GridPrinter1
|
GridPrinter = GridPrinter1
|
||||||
Zoom = gpzZoomHeight
|
Zoom = 199
|
||||||
|
ZoomMode = zmFitHeight
|
||||||
Left = 288
|
Left = 288
|
||||||
Top = 96
|
Top = 96
|
||||||
end
|
end
|
||||||
|
@ -10,8 +10,6 @@ uses
|
|||||||
type
|
type
|
||||||
TGridPrintPreviewDialog = class; // forward declaration
|
TGridPrintPreviewDialog = class; // forward declaration
|
||||||
|
|
||||||
TGridPrintPreviewZoom = (gpzOriginal, gpzZoomWidth, gpzZoomHeight);
|
|
||||||
|
|
||||||
TGridPrintPreviewFormParams = class(TPersistent)
|
TGridPrintPreviewFormParams = class(TPersistent)
|
||||||
private
|
private
|
||||||
FOwner: TGridPrintPreviewDialog;
|
FOwner: TGridPrintPreviewDialog;
|
||||||
@ -35,7 +33,8 @@ type
|
|||||||
FGridPrinter: TGridPrinter;
|
FGridPrinter: TGridPrinter;
|
||||||
FFormParams: TGridPrintPreviewFormParams;
|
FFormParams: TGridPrintPreviewFormParams;
|
||||||
FOptions: TGridPrintPreviewOptions;
|
FOptions: TGridPrintPreviewOptions;
|
||||||
FZoom: TGridPrintPreviewZoom;
|
FZoom: Integer;
|
||||||
|
FZoomMode: TGridPrintPreviewZoomMode;
|
||||||
protected
|
protected
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
public
|
public
|
||||||
@ -47,7 +46,9 @@ type
|
|||||||
property GridPrinter: TGridPrinter read FGridPrinter write FGridPrinter;
|
property GridPrinter: TGridPrinter read FGridPrinter write FGridPrinter;
|
||||||
property Options: TGridPrintPreviewOptions
|
property Options: TGridPrintPreviewOptions
|
||||||
read FOptions write FOptions default DEFAULT_GRIDPRN_OPTIONS;
|
read FOptions write FOptions default DEFAULT_GRIDPRN_OPTIONS;
|
||||||
property Zoom: TGridPrintPreviewZoom read FZoom write FZoom default gpzOriginal;
|
property Zoom: Integer read FZoom write FZoom default 100;
|
||||||
|
property ZoomMode: TGridPrintPreviewZoomMode
|
||||||
|
read FZoomMode write FZoomMode default zmCustom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -74,6 +75,7 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
FOptions := DEFAULT_GRIDPRN_OPTIONS;
|
FOptions := DEFAULT_GRIDPRN_OPTIONS;
|
||||||
FFormParams := TGridPrintPreviewFormParams.Create(self);
|
FFormParams := TGridPrintPreviewFormParams.Create(self);
|
||||||
|
FZoom := 100;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TGridPrintPreviewDialog.Destroy;
|
destructor TGridPrintPreviewDialog.Destroy;
|
||||||
@ -105,10 +107,11 @@ begin
|
|||||||
FFormParams.Top := R.Bottom - FFormParams.Height - GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYSIZEFRAME);
|
FFormParams.Top := R.Bottom - FFormParams.Height - GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYSIZEFRAME);
|
||||||
F.SetBounds(FFormParams.Left, FFormParams.Top, FFormParams.Width, FFormParams.Height);
|
F.SetBounds(FFormParams.Left, FFormParams.Top, FFormParams.Width, FFormParams.Height);
|
||||||
F.Position := FFormParams.Position;
|
F.Position := FFormParams.Position;
|
||||||
case FZoom of
|
F.ZoomMode := FZoomMode;
|
||||||
gpzOriginal: F.acZoom100.Checked := true;
|
case FZoomMode of
|
||||||
gpzZoomWidth: F.ZoomToFitWidth;
|
zmCustom: F.Zoom := FZoom;
|
||||||
gpzZoomHeight: F.ZoomToFitHeight;
|
zmFitWidth: F.ZoomToFitWidth;
|
||||||
|
zmFitHeight: F.ZoomToFitHeight;
|
||||||
end;
|
end;
|
||||||
if (F.ShowModal = mrOK) then
|
if (F.ShowModal = mrOK) then
|
||||||
FGridPrinter.Print;
|
FGridPrinter.Print;
|
||||||
@ -116,6 +119,8 @@ begin
|
|||||||
FFormParams.Top := F.RestoredTop;
|
FFormParams.Top := F.RestoredTop;
|
||||||
FFormParams.Width := F.RestoredWidth;
|
FFormParams.Width := F.RestoredWidth;
|
||||||
FormParams.Height := F.RestoredHeight;
|
FormParams.Height := F.RestoredHeight;
|
||||||
|
FZoom := F.Zoom;
|
||||||
|
FZoomMode := F.ZoomMode;
|
||||||
finally
|
finally
|
||||||
F.Free;
|
F.Free;
|
||||||
end;
|
end;
|
||||||
|
@ -175,13 +175,13 @@ type
|
|||||||
procedure UpdateStrings;
|
procedure UpdateStrings;
|
||||||
procedure ZoomToFitHeight;
|
procedure ZoomToFitHeight;
|
||||||
procedure ZoomToFitWidth;
|
procedure ZoomToFitWidth;
|
||||||
property PageNumber: Integer read FPageNumber write SetPageNumber;
|
|
||||||
|
|
||||||
published
|
|
||||||
property GridPrinter: TGridPrinter read FGridPrinter write SetGridPrinter;
|
property GridPrinter: TGridPrinter read FGridPrinter write SetGridPrinter;
|
||||||
property Options: TGridPrintPreviewOptions
|
property Options: TGridPrintPreviewOptions
|
||||||
read FOptions write SetOptions default DEFAULT_GRIDPRN_OPTIONS;
|
read FOptions write SetOptions default DEFAULT_GRIDPRN_OPTIONS;
|
||||||
|
property PageNumber: Integer read FPageNumber write SetPageNumber;
|
||||||
|
property Zoom: Integer read FZoom write FZoom;
|
||||||
|
property ZoomMode: TGridPrintPreviewZoomMode read FZoomMode write FZoomMode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -304,7 +304,11 @@ begin
|
|||||||
acLandscape.Caption := MarkAsChecked(RSLandscape, true);
|
acLandscape.Caption := MarkAsChecked(RSLandscape, true);
|
||||||
acPortrait.Caption := MarkAsChecked(RSPortrait, false);
|
acPortrait.Caption := MarkAsChecked(RSPortrait, false);
|
||||||
FGridPrinter.Orientation := poLandscape;
|
FGridPrinter.Orientation := poLandscape;
|
||||||
ShowPage(FPageNumber);
|
case FZoomMode of
|
||||||
|
zmCustom: ShowPage(FPageNumber);
|
||||||
|
zmFitWidth: ZoomToFitWidth;
|
||||||
|
zmFitHeight: ZoomToFitHeight;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -334,7 +338,11 @@ begin
|
|||||||
acPortrait.Caption := MarkAsChecked(RSPortrait, true);
|
acPortrait.Caption := MarkAsChecked(RSPortrait, true);
|
||||||
acLandscape.Caption := MarkAsChecked(RSLandscape, false);
|
acLandscape.Caption := MarkAsChecked(RSLandscape, false);
|
||||||
FGridPrinter.Orientation := poPortrait;
|
FGridPrinter.Orientation := poPortrait;
|
||||||
ShowPage(FPageNumber);
|
case FZoomMode of
|
||||||
|
zmCustom: ShowPage(FPageNumber);
|
||||||
|
zmFitWidth: ZoomToFitWidth;
|
||||||
|
zmFitHeight: ZoomToFitHeight;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -492,7 +500,7 @@ begin
|
|||||||
if FActivated then
|
if FActivated then
|
||||||
exit;
|
exit;
|
||||||
FUpdatePreviewHandler := FGridPrinter.OnUpdatePreview;
|
FUpdatePreviewHandler := FGridPrinter.OnUpdatePreview;
|
||||||
ShowPage(1);
|
ShowPage(1, FZoom, FZoomMode);
|
||||||
FActivated := true;
|
FActivated := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user