Print Preview / Zooming

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
Shane Stump
Posts: 54
Joined: Mon Jul 31, 2006 2:10 am

Print Preview / Zooming

Post by Shane Stump »

I am implementing a Print Preview dialog by using TScaleRichView.

Once the control is in preview mode, I would like to trap MouseDown so I can handle zooming (via the ViewPropery ZoomPercent).

That is, I want the mouse button events instead of TScaleRichView handling them.

Best regards,

Shane
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It can be implemented simpler, by changing SRichViewEdit1.ViewProperty.ViewMode.
This code switches editor to preview mode and back:

Code: Select all

  if SRichViewEdit1.ViewProperty.ViewMode = srvvmEditMode then
    SRichViewEdit1.ViewProperty.ViewMode := srvvmPreviewMode
  else
    SRichViewEdit1.ViewProperty.ViewMode := srvvmEditMode;
Shane Stump
Posts: 54
Joined: Mon Jul 31, 2006 2:10 am

Post by Shane Stump »

I saw that but I want zooming to work in +/- 5 % increments. What properties do I set to make that happen?

Best Regards,

Shane
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

The code below will work in the next update. In the current version, event OnClickPage works only for ViewMode = srvvmEditMode.

Code: Select all

{event OnClick on CheckBox}
procedure TFZoomPage.PreviewModeClick(Sender: TObject);
begin
  srv.ViewProperty.ZoomPercentIN := srv.ViewProperty.ZoomPercent;
  if PreviewMode.Checked then
    srv.ViewProperty.ViewMode := srvvmPreviewMode
  else
    srv.ViewProperty.ViewMode := srvvmEditMode;
end;

{Event OnClickPage on ScaleRichView}
procedure TFZoomPage.srvClickPage(Sender: TSRichViewEdit;
  Button: TMouseButton; Shift: TShiftState; X, Y, PageNo: Integer);
var
     zpB, zpE, delta : Single;
begin
  if srv.ViewProperty.ViewMode = srvvmEditMode then exit;

  if (srv.ViewProperty.ZoomPercent = srv.ViewProperty.ZoomPercentIN) then
    zpE := srv.ViewProperty.ZoomPercentOUT
  else
    zpE := srv.ViewProperty.ZoomPercentIN;
  zpB := srv.ViewProperty.ZoomPercent;

  delta := (zpE - zpB) / 20; {count of incrementations}

  while ((zpB < zpE) and (delta > 0)) or
        ((zpB > zpE) and (delta < 0)) do
    begin
      zpB := zpB + delta;
      srv.ViewProperty.ZoomPercent := zpB;
    end;
end;
Post Reply