View Issue Details

IDProjectCategoryView StatusLast Update
0005814JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporteruholeschakAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.46 
Summary0005814: JvPrvwDoc hides some pages
DescriptionIn 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
TagsNo tags attached.

Relationships

related to 0005817 resolvedobones JvPrvwDoc Hint hide issues 

Activities

obones

2012-02-28 16:49

administrator   ~0019615

Please provide the zipped sources of a sample application showing this

uholeschak

2012-02-28 17:41

reporter   ~0019617

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 ...

uholeschak

2012-02-29 01:19

reporter   ~0019622

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 ...

obones

2012-03-01 16:50

administrator   ~0019634

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

2012-03-01 19:53

 

PrvwDoc.7z (2,183,043 bytes)

uholeschak

2012-03-01 19:56

reporter   ~0019635

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

obones

2012-03-02 09:58

administrator   ~0019636

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.

obones

2012-03-02 10:16

administrator   ~0019637

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