Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005814 [JEDI VCL] 00 JVCL Components minor always 2012-02-28 16:46 2012-09-10 14:15
Reporter uholeschak View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0005814: JvPrvwDoc hides some pages
Description In page mode it could happen that the last page after scrolling down is not displayed because the calculation of the page size in UpdateSizes() is incorrect.

Solution:
In TJvCustomPreviewControl.UpdateSizes() change
--------------------------------------------------------
    // TODO: this just isn't right...
    FMaxHeight := TotalRows * (FPageHeight + Integer(Options.VertSpacing)) + Integer(Options.VertSpacing);
--------------------------------------------------------
to
--------------------------------------------------------
    FMaxHeight := TotalRows * (FPageHeight + Integer(Options.VertSpacing));
    if IsPageMode then
      FMaxHeight := FMaxHeight + Max((ClientHeight - ((FPageHeight + Integer(Options.VertSpacing)) * VisibleRows)) div 2,
      FOptions.VertSpacing) * 2
    else
      FMaxHeight := FMaxHeight + Integer(Options.VertSpacing) * 2;
--------------------------------------------------------

and
--------------------------------------------------------
    FMaxWidth := TotalCols * (FPageWidth + Integer(Options.HorzSpacing)) +
Integer(Options.HorzSpacing);
--------------------------------------------------------
to
--------------------------------------------------------
    FMaxWidth := TotalCols * (FPageWidth + Integer(Options.HorzSpacing));
    FMaxWidth := FMaxWidth + Max((ClientWidth - ((FPageWidth + Integer(Options.HorzSpacing)) * TotalCols)) div 2,
--------------------------------------------------------

This modification adds the correct page overhead used in DrawPages() to the page size.

But there is still another problem.
With very large paper sizes (e.g. A0) the automatically calculated page scale is sometimes a bit too large and the page gets invisible.
This is due to a minor bug in TJvCustomPreviewControl.GetLesserScale().
The function MulDiv() is rounding the result of the calculation, but this is not what we need here because the scale could get larger as it should be.

Replacing
--------------------------------------------------------
    if AWidth > 0 then
      AWidth := MulDiv(AWidth, 100, MulDiv(DeviceInfo.PhysicalWidth,
        GetDeviceCaps(DC, LOGPIXELSX), DeviceInfo.LogPixelsX));
    if AHeight > 0 then
      AHeight := MulDiv(AHeight, 100, MulDiv(DeviceInfo.PhysicalHeight,
        GetDeviceCaps(DC, LOGPIXELSY), DeviceInfo.LogPixelsY));
--------------------------------------------------------
with
--------------------------------------------------------
    if AWidth > 0 then
      AWidth := AWidth * Int64(100) div
        MulDiv(DeviceInfo.PhysicalWidth, GetDeviceCaps(DC, LOGPIXELSX), DeviceInfo.LogPixelsX);
    if AHeight > 0 then
      AHeight := AHeight * Int64(100) div
        MulDiv(DeviceInfo.PhysicalHeight, GetDeviceCaps(DC, LOGPIXELSY), DeviceInfo.LogPixelsY);
--------------------------------------------------------

solves this problem because we avoid the rounding effect.

Additionally there is a small problem when painting previews too large for the paper size
(happens with very small paper).
Clipping the drawing area to the paper size in DrawPreview() solves this problem.
Change:
--------------------------------------------------------
procedure TJvCustomPreviewControl.DrawPreview(PageIndex: Integer;
  APageRect, APrintRect: TRect);
var
  SaveIndex: Integer;
begin
  FBuffer.Canvas.StretchDraw(APageRect, Pages[PageIndex]);
  DoDrawPreviewPage(PageIndex, FBuffer.Canvas, APageRect, APrintRect);
end;
--------------------------------------------------------
to
--------------------------------------------------------
procedure TJvCustomPreviewControl.DrawPreview(PageIndex: Integer;
  APageRect, APrintRect: TRect);
var
  SaveIndex: Integer;
begin
  // [UH] prevent painting outside page
  SaveIndex := SaveDC(FBuffer.Canvas.Handle);
  IntersectClipRect(FBuffer.Canvas.Handle, APageRect.Left, APageRect.Top, APageRect.Right, APageRect.Bottom);
  FBuffer.Canvas.StretchDraw(APageRect, Pages[PageIndex]);
  DoDrawPreviewPage(PageIndex, FBuffer.Canvas, APageRect, APrintRect);
  RestoreDC(FBuffer.Canvas.Handle, SaveIndex);
end;
--------------------------------------------------------

Thanks,
Ulrich
Additional Information
Tags No tags attached.
Attached Files 7z file icon PrvwDoc.7z [^] (2,183,043 bytes) 2012-03-01 19:53

- Relationships
related to 0005817resolvedobones JvPrvwDoc Hint hide issues 

-  Notes
(0019615)
obones (administrator)
2012-02-28 16:49

Please provide the zipped sources of a sample application showing this
(0019617)
uholeschak (reporter)
2012-02-28 17:41

You could simply use the existing JvPrevwDemo and open a multi page text file.
(Scale Mode Full Page).
Now change the size of the application in such a way, that it's width is larger than the height (so the size of the preview only depends from the application height).
Scroll down to the last page of the preview. It should be invisible (if not change the application height a bit or use a larger file).
When scrolling back the pages only get visible if you scroll up to the first page.
Also try with A0 paper setting ...
(0019622)
uholeschak (reporter)
2012-02-29 01:19

Sorry, my last note was incorrect.
The size of the application has to be changes in such a way,
that it's width is very much smaller than it's hight.
In the full page mode there must be a free gray area on top and below the preview page, but not on the side (The preview page size must be specified by the width of the previewer)!
Now scroll down to the last page and it will be invisible, because it's bottom is outside of the viewer ...
(0019634)
obones (administrator)
2012-03-01 16:50

Could you use Wink (http://www.debugmode.com/wink/) [^] to create a video of how to proceed?
I have a hard time reproducing the issue
(0019635)
uholeschak (reporter)
2012-03-01 19:56

Hello,
i have added a wink package of the scrolling problem.
As you could see, when reaching page 11 the the page vanishes.
When scrolling pack, the pages get only visible when reaching page 1 again.

Additionally you can see the hint artifacts on the right side
fixed in bug report 5817.

Ulrich
(0019636)
obones (administrator)
2012-03-02 09:58

Thanks for the wink package I now see how you do it.

Ok, one needs a very high display to have this happen. Or, like I did, change the minimal width for the window and after that one can see it.
(0019637)
obones (administrator)
2012-03-02 10:16

This is now in SVN

- Issue History
Date Modified Username Field Change
2012-02-28 16:46 uholeschak New Issue
2012-02-28 16:49 obones Note Added: 0019615
2012-02-28 16:49 obones Status new => feedback
2012-02-28 17:41 uholeschak Note Added: 0019617
2012-02-29 01:19 uholeschak Note Added: 0019622
2012-03-01 16:50 obones Note Added: 0019634
2012-03-01 19:53 uholeschak File Added: PrvwDoc.7z
2012-03-01 19:56 uholeschak Note Added: 0019635
2012-03-02 09:58 obones Note Added: 0019636
2012-03-02 10:15 obones Relationship added related to 0005817
2012-03-02 10:16 obones Note Added: 0019637
2012-03-02 10:16 obones Status feedback => resolved
2012-03-02 10:16 obones Fixed in Version => Daily / SVN
2012-03-02 10:16 obones Resolution open => fixed
2012-03-02 10:16 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker