You've already forked lazarus-ccr
tvplanit: Fix scrolling in VpContactGrid.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8528 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,7 +4,7 @@ unit VpContactGridPainter;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uses lazlogger,
|
||||
LCLType, LCLIntf, SysUtils,
|
||||
Types, Classes, Graphics,
|
||||
VpConst, VPBase, VpData, VpBasePainter, VpContactGrid;
|
||||
@ -453,7 +453,7 @@ begin
|
||||
if newCol then
|
||||
begin
|
||||
CalcNextColumnAnchor(ABitmap, AWholeRect, Anchor);
|
||||
if DisplayOnly and NewPageNeeded(Anchor) then
|
||||
if NewPageNeeded(Anchor) then
|
||||
begin
|
||||
// Return value FALSE signals that a new page must be created.
|
||||
Result := false;
|
||||
@ -463,7 +463,7 @@ begin
|
||||
// New columns Increment the column counter. Store the counter of records
|
||||
// in the 1st column and reset it for the new column.
|
||||
if ACol = 1 then
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := ARecsInCol;
|
||||
FContactGrid.Col1RecCount := ARecsInCol;
|
||||
Inc(ACol);
|
||||
ARecsInCol := 0;
|
||||
end else
|
||||
@ -498,7 +498,7 @@ end;
|
||||
procedure TVpContactGridPainter.DrawContacts;
|
||||
var
|
||||
Anchor: TPoint;
|
||||
I: Integer;
|
||||
I, J: Integer;
|
||||
TmpBmp: TBitmap;
|
||||
contact: TVpContact;
|
||||
Col, RecsInCol: Integer;
|
||||
@ -507,6 +507,7 @@ var
|
||||
CR: TVpContactRec;
|
||||
HeadRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
contactCount: Integer;
|
||||
newPage: Boolean;
|
||||
px4: Integer; // Scaled 4 pixels
|
||||
begin
|
||||
// If the component is sufficiently small then no sense in painting it
|
||||
@ -522,9 +523,9 @@ begin
|
||||
|
||||
// Some initializations
|
||||
contactCount := FContactGrid.DataStore.Resource.Contacts.Count;
|
||||
oldCol1RecCount := TVpContactGridOpener(FContactGrid).cgCol1RecCount;
|
||||
TVpContactGridOpener(FContactGrid).FVisibleContacts := 0;
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := 0;
|
||||
oldCol1RecCount := FContactGrid.Col1RecCount;
|
||||
FContactGrid.VisibleContacts := 0;
|
||||
FContactGrid.Col1RecCount := 0;
|
||||
px4 := Round(4 * Scale);
|
||||
CR := Default(TVpContactRec);
|
||||
|
||||
@ -559,6 +560,7 @@ begin
|
||||
RecsInCol := 0;
|
||||
|
||||
for I := StartContact to pred(contactCount) do begin
|
||||
J := I; // Do not use the loop index outside a for loop!
|
||||
contact := FContactGrid.DataStore.Resource.Contacts.GetContact(I);
|
||||
if contact = nil then
|
||||
Continue;
|
||||
@ -576,6 +578,7 @@ begin
|
||||
WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height);
|
||||
if DrawContactRows(TmpBmp, contact, Anchor, WholeRect, Col, RecsInCol, CR) then
|
||||
begin
|
||||
newPage := false;
|
||||
CR.Index := I;
|
||||
CR.Contact := contact;
|
||||
// Move rectangles in ContactGridRec to final position on rendering canvas.
|
||||
@ -594,22 +597,10 @@ begin
|
||||
ra180 : Anchor.Y := Anchor.Y - HeightOf(WholeRect);
|
||||
ra270 : Anchor.X := Anchor.X + WholeRect.Right;
|
||||
end;
|
||||
with TVpContactGridOpener(FContactGrid) do
|
||||
begin
|
||||
FVisibleContacts := contactCount - StartContact;
|
||||
FContactsAfter := contactCount - 1;
|
||||
if I = contactCount-1 then
|
||||
FLastPrintLine := -2;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
// New page required.
|
||||
with TVpContactGridOpener(FContactGrid) do
|
||||
begin
|
||||
FContactsAfter := contactCount - I;
|
||||
FVisibleContacts := contactCount - StartContact - FContactsAfter;
|
||||
FLastPrintLine := I; // Strangely named, but this is the contact index beginning the next page
|
||||
end;
|
||||
newPage := true;
|
||||
break;
|
||||
end;
|
||||
end; // for I := StartCont to ...
|
||||
@ -617,12 +608,20 @@ begin
|
||||
TmpBmp.Free;
|
||||
end;
|
||||
|
||||
with TVpContactGridOpener(FContactGrid) do begin
|
||||
if (FContactsAfter = 0) or (FLastPrintLine >= contactCount) then
|
||||
FLastPrintLine := -2;
|
||||
if (oldCol1RecCount > 0) and (cgCol1RecCount = 0) then
|
||||
cgCol1RecCount := oldCol1RecCount;
|
||||
if newPage then
|
||||
begin
|
||||
FContactGrid.ContactsAfter := contactCount - J;
|
||||
TVpContactGridOpener(FContactGrid).FLastPrintLine := J;
|
||||
end else
|
||||
begin
|
||||
// All contacts printed
|
||||
FContactGrid.ContactsAfter := 0;
|
||||
TVpContactGridOpener(FContactGrid).FLastPrintLine := -2; // -2 = no more data available
|
||||
end;
|
||||
FContactGrid.VisibleContacts := contactCount - StartContact - FContactGrid.ContactsAfter;
|
||||
|
||||
if (oldCol1RecCount > 0) and (FContactGrid.Col1RecCount = 0) then
|
||||
FContactGrid.Col1RecCount := oldCol1RecCount;
|
||||
end;
|
||||
|
||||
procedure TVpContactGridPainter.DrawVerticalBars;
|
||||
@ -858,7 +857,7 @@ begin
|
||||
SelectClipRgn(RenderCanvas.Handle, Rgn);
|
||||
|
||||
if StartLine = -1 then
|
||||
StartContact := TVpContactGridOpener(FContactGrid).FContactsBefore
|
||||
StartContact := FContactGrid.ContactsBefore
|
||||
else
|
||||
StartContact := StartLine;
|
||||
|
||||
@ -877,7 +876,7 @@ begin
|
||||
// Draw the borders
|
||||
DrawBorders;
|
||||
|
||||
TVpContactGridOpener(FContactGrid).SetHScrollPos;
|
||||
FContactGrid.UpdateScrollbar;
|
||||
|
||||
finally
|
||||
SelectClipRgn(RenderCanvas.Handle, 0);
|
||||
|
Reference in New Issue
Block a user