You've already forked lazarus-ccr
tvplanit: Fix centering of vertical dividing lines between contacts in print-out
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8522 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -13,7 +13,6 @@ type
|
||||
TVpContactGridPainter = class(TVpBasePainter)
|
||||
private
|
||||
FContactGrid: TVpContactGrid;
|
||||
// FScaledRowHeight: Integer;
|
||||
FScaledTextMargin: Integer;
|
||||
|
||||
// local variables of the original TVpContactGrid method
|
||||
@ -234,9 +233,9 @@ var
|
||||
contactCount: Integer;
|
||||
baseTextHeight: Integer;
|
||||
maxTextWidth: Integer;
|
||||
px2: Integer; // Scaled 2, 3, 4 pixels
|
||||
px3: Integer;
|
||||
px4: Integer;
|
||||
anchorMargin: Integer;
|
||||
px2, px4: Integer; // Scaled 2, 4 pixels
|
||||
px3: Integer; // 3 pixels scaled for high-dpi
|
||||
begin
|
||||
// If the component is sufficiently small then no sense in painting it
|
||||
if (FContactGrid.Height < 20) then
|
||||
@ -257,8 +256,13 @@ begin
|
||||
TextXOffset := 0;
|
||||
TextYOffset := 0;
|
||||
px2 := Round(2 * Scale);
|
||||
px3 := Round(3 * Scale);
|
||||
px4 := Round(4 * Scale);
|
||||
{$IF VP_LCL_SCALING > 0}
|
||||
px3 := FContactGrid.Scale96ToFont(3);
|
||||
{$ELSE}
|
||||
px3 := ScaleY(3, DesigntimeDPI);
|
||||
{$IFEND}
|
||||
|
||||
|
||||
// Create a temporary bitmap for painting the items
|
||||
TmpBmp := TBitmap.Create;
|
||||
@ -280,8 +284,6 @@ begin
|
||||
{$ENDIF}
|
||||
baseTextHeight := TmpBmp.Canvas.TextHeight(VpProductName);
|
||||
|
||||
DebugLn('baseTextHeight: ' + IntToStr(baseTextHeight));
|
||||
|
||||
// Calculate max phone label width
|
||||
PhoneLblWidth := TmpBmp.Canvas.TextWidth(RSEmail);
|
||||
for I := 0 to 7 do begin
|
||||
@ -291,34 +293,23 @@ begin
|
||||
PhoneLblWidth := w;
|
||||
end;
|
||||
|
||||
Col := 1;
|
||||
|
||||
// Clear the bitmap /// wp: this is done in the loop also?
|
||||
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
||||
|
||||
// Set the anchor starting point
|
||||
anchorMargin := px2 + FScaledTextMargin * 2;
|
||||
case Angle of
|
||||
ra0:
|
||||
Anchor := Point(2 + FScaledTextMargin * 2, px2 + FScaledTextMargin * 2);
|
||||
ra90:
|
||||
Anchor := Point(2 + FScaledTextMargin * 2, px2 + FScaledTextMargin * 2);
|
||||
ra0, ra90:
|
||||
Anchor := Point(anchorMargin, anchorMargin);
|
||||
ra180:
|
||||
Anchor := Point(
|
||||
RenderIn.Right - RenderIn.Left - TmpBmp.Width - px2 - FScaledTextMargin * 2,
|
||||
TmpBmp.Height - px2 - FScaledTextMargin * 2
|
||||
);
|
||||
Anchor := Point(WidthOf(RenderIn) - TmpBmp.Width - anchorMargin, TmpBmp.Height - anchorMargin);
|
||||
ra270:
|
||||
Anchor := Point(
|
||||
px2 + FScaledTextMargin * 2,
|
||||
RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - px2 - FScaledTextMargin * 2
|
||||
);
|
||||
Anchor := Point(anchorMargin, HeightOf(RenderIn) - TmpBmp.Height - anchorMargin);
|
||||
end;
|
||||
RecsInCol := 0;
|
||||
|
||||
// Sort the records
|
||||
FContactGrid.DataStore.Resource.Contacts.Sort;
|
||||
|
||||
// Iterate over all contacts
|
||||
Col := 1;
|
||||
RecsInCol := 0;
|
||||
for I := StartContact to pred(contactCount) do begin
|
||||
TmpCon := FContactGrid.DataStore.Resource.Contacts.GetContact(I);
|
||||
if (TmpCon <> nil) then begin
|
||||
@ -554,28 +545,36 @@ begin
|
||||
cgContactArray[I].Phone5Rect := MoveRect(Phone5Rect, Anchor);
|
||||
end;
|
||||
|
||||
{ move the drawn record from the bitmap to the component canvas }
|
||||
// Move the drawn record from the bitmap to the component canvas.
|
||||
case Angle of
|
||||
ra0 : R := Rect(Anchor.X + WholeRect.Left + RenderIn.Left,
|
||||
Anchor.Y + WholeRect.Top + RenderIn.Top,
|
||||
Anchor.X + TmpBmp.Width + RenderIn.Left,
|
||||
Anchor.Y + WholeRect.Bottom + RenderIn.Top);
|
||||
Anchor.Y + WholeRect.Bottom + RenderIn.Top
|
||||
);
|
||||
ra90 : R := Rect(WholeRect.Left + RenderIn.Left - Anchor.X,
|
||||
Anchor.Y + WholeRect.Top + RenderIn.Top,
|
||||
WholeRect.Right + RenderIn.Left - Anchor.X,
|
||||
Anchor.Y + WholeRect.Bottom + RenderIn.Top);
|
||||
Anchor.Y + WholeRect.Bottom + RenderIn.Top
|
||||
);
|
||||
ra180 : R := Rect(Anchor.X + WholeRect.Left + RenderIn.Left,
|
||||
Anchor.Y - (WholeRect.Bottom - WholeRect.Top) + RenderIn.Top,
|
||||
Anchor.Y - HeightOf(WholeRect) + RenderIn.Top,
|
||||
Anchor.X + TmpBmp.Width + RenderIn.Left,
|
||||
Anchor.Y + RenderIn.Top);
|
||||
Anchor.Y + RenderIn.Top
|
||||
);
|
||||
ra270 : R := Rect(Anchor.X + RenderIn.Left,
|
||||
Anchor.Y + RenderIn.Top,
|
||||
Anchor.X + RenderIn.Left + (WholeRect.Right - WholeRect.Left),
|
||||
Anchor.Y + RenderIn.Top + (WholeRect.Bottom - WholeRect.Top));
|
||||
Anchor.X + RenderIn.Left + WidthOf(WholeRect),
|
||||
Anchor.Y + RenderIn.Top + HeightOf(WholeRect)
|
||||
);
|
||||
end;
|
||||
|
||||
//debugln(['wholerect: ', wholerect.left, ' ', wholerect.top, ' ', wholerect.right, ' ', wholerect.bottom]);
|
||||
//debugLn(['scaledtextmargin: ', fscaledtextmargin]);
|
||||
|
||||
RenderCanvas.CopyRect(R, TmpBmp.Canvas, WholeRect);
|
||||
|
||||
{ draw focusrect around selected record }
|
||||
// Draw focus rect around selected record
|
||||
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then begin
|
||||
with TVpContactGridOpener(FContactGrid).cgContactArray[I] do begin
|
||||
R := WholeRect;
|
||||
@ -594,7 +593,7 @@ begin
|
||||
end;
|
||||
|
||||
Inc(RecsInCol);
|
||||
end; // for I := StartCont to ...
|
||||
end;
|
||||
|
||||
if not DisplayOnly then
|
||||
case Angle of
|
||||
@ -647,7 +646,7 @@ begin
|
||||
FVisibleContacts := contactCount - StartContact;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end; // for I := StartCont to ...
|
||||
finally
|
||||
TmpBmp.Free;
|
||||
end;
|
||||
@ -667,7 +666,6 @@ procedure TVpContactGridPainter.DrawVerticalBars;
|
||||
var
|
||||
BarPos, BarCount, I: Integer;
|
||||
scaledExtraBarWidth: Integer;
|
||||
scaledPenWidth: Integer;
|
||||
px2: Integer; // scaled 2 pixels
|
||||
begin
|
||||
// If the component is sufficiently small then no sense in painting it.
|
||||
@ -675,13 +673,15 @@ begin
|
||||
exit;
|
||||
|
||||
scaledExtraBarWidth := round(ExtraBarWidth * Scale);
|
||||
scaledPenWidth := round(1 * Scale);
|
||||
//scaledPenWidth := round(1 * Scale);
|
||||
px2 := round(2 * Scale);
|
||||
|
||||
debugln([Realcolumnwidth]);
|
||||
|
||||
// Draw vertical bars.
|
||||
RenderCanvas.Pen.Color := RealBarColor;
|
||||
RenderCanvas.Pen.Style := psSolid;
|
||||
RenderCanvas.Pen.Width := scaledPenWidth;
|
||||
RenderCanvas.Pen.Width := 1; //scaledPenWidth;
|
||||
BarPos := RealLeft + px2 + RealColumnWidth + scaledExtraBarWidth;
|
||||
BarCount := 0;
|
||||
while (BarPos < RealRight) and (BarCount < Pred(MaxColumns)) do begin
|
||||
@ -784,8 +784,6 @@ end;
|
||||
procedure TVpContactGridPainter.RenderToCanvas(ARenderIn: TRect;
|
||||
AAngle: TVpRotationAngle; AScale: Extended; ARenderDate: TDateTime;
|
||||
AStartLine, AStopLine: Integer; AUseGran: TVpGranularity; ADisplayOnly: Boolean);
|
||||
var
|
||||
nc: Integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
@ -805,12 +803,6 @@ begin
|
||||
|
||||
SetMeasurements;
|
||||
|
||||
nc := FContactGrid.PrintNumColumns;
|
||||
if DisplayOnly and (nc > 0) then
|
||||
RealColumnWidth := (RealWidth - (2 + ExtraBarWidth) * (nc - 1)) div nc
|
||||
else
|
||||
RealColumnWidth := FContactGrid.ColumnWidth;
|
||||
|
||||
{ clear the control }
|
||||
Clear;
|
||||
|
||||
@ -836,10 +828,17 @@ begin
|
||||
end;
|
||||
|
||||
procedure TVpContactGridPainter.SetMeasurements;
|
||||
var
|
||||
numCols: Integer;
|
||||
begin
|
||||
inherited;
|
||||
// FScaledRowHeight := round(FContactGrid.RowHeight * Scale);
|
||||
FScaledTextMargin := round(FContactGrid.TextMargin * Scale);
|
||||
|
||||
numCols := FContactGrid.PrintNumColumns;
|
||||
if DisplayOnly and (numCols > 0) then
|
||||
RealColumnWidth := (RealWidth - round((2 + ExtraBarWidth) * Scale * (numCols - 1))) div numCols
|
||||
else
|
||||
RealColumnWidth := FContactGrid.ColumnWidth;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user