You've already forked lazarus-ccr
tvplanit: More refactoring of TVpContactGridPainter
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8524 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -119,7 +119,9 @@ type
|
||||
FPendingDatastore: TVpCustomDatastore;
|
||||
// FRowHeight: Integer;
|
||||
FTextMargin: Integer;
|
||||
function GetDisplayEMailValue(AContact: TVpContact): String;
|
||||
procedure InternalSetDatastore(const Value: TVpCustomDatastore);
|
||||
procedure SetDisplayEMailValue(AContact: TVpContact; AEMail: String);
|
||||
procedure SetPopupMenu(AValue: TPopupMenu);
|
||||
procedure SetTextMargin(AValue: Integer);
|
||||
protected{ private }
|
||||
@ -195,8 +197,6 @@ type
|
||||
function GetContactIndexByCoord(Pnt: TPoint): Integer;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
function GetDisplayEMailField(AContact: TVpContact): String;
|
||||
function GetDisplayEMailValue(AContact: TVpContact): String;
|
||||
procedure SetDisplayEMailValue(AContact: TVpContact; AEMail: String);
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure MouseEnter; override;
|
||||
procedure MouseLeave; override;
|
||||
@ -278,6 +278,7 @@ type
|
||||
|
||||
property ActiveContact: TVpContact read FActiveContact;
|
||||
property ContactIndex: Integer read FContactIndex write SetContactIndex;
|
||||
property DisplayEMailValue[AContact: TVpContact]: String read GetDisplayEMailValue write SetDisplayEMailValue;
|
||||
|
||||
// Unscaled some dimensions
|
||||
// property RowHeight: Integer read FRowHeight;
|
||||
|
@ -13,10 +13,11 @@ type
|
||||
TVpContactGridPainter = class(TVpBasePainter)
|
||||
private
|
||||
FContactGrid: TVpContactGrid;
|
||||
FLabelWidth: Integer;
|
||||
FScaledTextMargin: Integer;
|
||||
|
||||
// local variables of the original TVpContactGrid method
|
||||
PhoneLblWidth: Integer;
|
||||
// PhoneLblWidth: Integer;
|
||||
StartContact: Integer;
|
||||
RealColumnWidth: Integer;
|
||||
RealColor: TColor;
|
||||
@ -28,14 +29,20 @@ type
|
||||
RealBarColor: TColor;
|
||||
RealContactHeadAttrColor: TColor;
|
||||
|
||||
protected
|
||||
function CalcHeaderRect(ABitmap: TBitmap): TRect;
|
||||
function CalcInitialAnchor(ABitmap: TBitmap): TPoint;
|
||||
function CalcLabelWidth(ABitmap: TBitmap): Integer;
|
||||
|
||||
protected
|
||||
procedure Clear;
|
||||
procedure DrawBorders;
|
||||
procedure DrawContactHeader(ABitmap: TBitmap; AContact: TVpContact;
|
||||
const ARect: TRect);
|
||||
procedure DrawContactRow(ABitmap: TBitmap; AText, ALabel: String;
|
||||
var AWholeRect, ATextRect: TRect);
|
||||
function DrawContactRows(ABitmap: TBitmap; AContact: TVpContact;
|
||||
var Anchor: TPoint; var AWholeRect: TRect; var ACol, ARecsInCol: Integer;
|
||||
var AContactRec: TVpContactRec): Boolean;
|
||||
procedure DrawContacts;
|
||||
procedure DrawVerticalBars;
|
||||
procedure FixFontHeights;
|
||||
@ -95,6 +102,43 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpContactGridPainter.CalcInitialAnchor(ABitmap: TBitmap): TPoint;
|
||||
var
|
||||
anchorMargin: Integer;
|
||||
px2: Integer;
|
||||
begin
|
||||
px2 := round(Scale*2);
|
||||
anchorMargin := px2 + FScaledTextMargin * 2;
|
||||
case Angle of
|
||||
ra0, ra90:
|
||||
Result := Point(anchorMargin, anchorMargin);
|
||||
ra180:
|
||||
Result := Point(WidthOf(RenderIn) - ABitmap.Width - anchorMargin, ABitmap.Height - anchorMargin);
|
||||
ra270:
|
||||
Result := Point(anchorMargin, HeightOf(RenderIn) - ABitmap.Height - anchorMargin);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Calculates the width of the longest label in each row of the contact display. }
|
||||
function TVpContactGridPainter.CalcLabelWidth(ABitmap: TBitmap): Integer;
|
||||
var
|
||||
s: String;
|
||||
i, w: Integer;
|
||||
begin
|
||||
ABitmap.Canvas.Font.Assign(FContactGrid.Font);
|
||||
ABitmap.Canvas.Font.PixelsPerInch := RenderCanvas.Font.PixelsPerInch;
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
ABitmap.Canvas.Font.Size := ScaleY(ABitmap.Canvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
Result := ABitmap.Canvas.TextWidth(RSEmail);
|
||||
for i := 0 to 7 do begin
|
||||
s := PhoneLabel(TVpPhoneType(i)) + ': ';
|
||||
w := ABitmap.Canvas.TextWidth(s);
|
||||
if w > Result then
|
||||
Result := w;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpContactGridPainter.Clear;
|
||||
var
|
||||
I: Integer;
|
||||
@ -261,7 +305,8 @@ begin
|
||||
ra180:
|
||||
begin
|
||||
ATextRect.Left := AWholeRect.Right - FScaledTextMargin * 2; // Shouldn't this be "div 2" ?
|
||||
ATextRect.Top := AWholeRect.Top - txtHeight - FScaledTextMargin;
|
||||
//ATextRect.Top := AWholeRect.Top - txtHeight - FScaledTextMargin;
|
||||
ATextRect.Top := AWholeRect.Top - txtHeight; // + FScaledTextMargin div 2;
|
||||
ATextRect.Right := AWholeRect.Left + FScaledTextMargin;
|
||||
ATextRect.Bottom := AWholeRect.Top - FScaledTextMargin div 2;
|
||||
AWholeRect.Top := ATextRect.Top;
|
||||
@ -292,10 +337,10 @@ begin
|
||||
|
||||
with ATextRect do
|
||||
case Angle of
|
||||
ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + FScaledTextMargin div 2);
|
||||
ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + FScaledTextMargin);
|
||||
ra180 : TopLeft := Point(Left - PhoneLblWidth, top + FScaledTextMargin div 2);
|
||||
ra270 : TopLeft := Point(Left + FScaledTextMargin div 2, Top - PhoneLblWidth);
|
||||
ra0 : TopLeft := Point(Left + FLabelWidth, Top + FScaledTextMargin div 2);
|
||||
ra90 : TopLeft := Point(Top + FLabelWidth, Left + FScaledTextMargin);
|
||||
ra180 : TopLeft := Point(Left - FLabelWidth, top + FScaledTextMargin div 2);
|
||||
ra270 : TopLeft := Point(Left + FScaledTextMargin div 2, Top - FLabelWidth);
|
||||
end;
|
||||
TPSTextOutAtPoint(
|
||||
ABitmap.Canvas,
|
||||
@ -316,6 +361,154 @@ begin
|
||||
);
|
||||
end;
|
||||
|
||||
{ Draws selected data for the specified contact on the auxiliary bitmap.
|
||||
Anchor ...... position at which the data will appear on the rendering canvas.
|
||||
AWholeRect .. rectangle covered by the data rows (header included). It is
|
||||
relative to the auxiliary bitmap.
|
||||
ACol ........ Column counter, advances when a new column is started
|
||||
ARecsInCol .. Counter for the records in the first column
|
||||
AContactRec . Record storing mostly the rectangles of the data elements to
|
||||
facilitate handling of clicks in the ContactGrid.
|
||||
Result ...... normally true. But when the size of the rendering canvas is
|
||||
exceeded becomes false to indicate an error condition. }
|
||||
function TVpContactGridPainter.DrawContactRows(ABitmap: TBitmap;
|
||||
AContact: TVpContact; var Anchor: TPoint; var AWholeRect: TRect;
|
||||
var ACol, ARecsInCol: Integer; var AContactRec: TVpContactRec): Boolean;
|
||||
var
|
||||
s: String;
|
||||
px2: Integer;
|
||||
textColWidth: Integer;
|
||||
newCol: Boolean;
|
||||
begin
|
||||
Result := true;
|
||||
|
||||
case Angle of
|
||||
ra0, ra180: textColWidth := ABitmap.Width;
|
||||
ra90, ra270: textColWidth := ABitmap.Height;
|
||||
end;
|
||||
px2 := Round(2 * Scale); // Size of two scaled pixels.
|
||||
|
||||
// Set font and colors for the contact data
|
||||
ABitmap.Canvas.Font.Assign(FContactGrid.Font);
|
||||
ABitmap.Canvas.Font.PixelsPerInch := RenderCanvas.Font.PixelsPerInch;
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
ABitmap.Canvas.Font.Size := ScaleY(ABitmap.Canvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
Abitmap.Canvas.Brush.Color := RealColor;
|
||||
|
||||
// Draw company
|
||||
DrawContactRow(ABitmap, AContact.Company, '', AWholeRect, AContactRec.CompanyRect);
|
||||
|
||||
// Draw address
|
||||
DrawContactRow(ABitmap, AContact.Address1, '', AWholeRect, AContactRec.AddressRect);
|
||||
|
||||
// Draw city, state, zip
|
||||
s := AssembleCSZ(AContact, 1, FContactGrid.GetCityStateZipFormat);
|
||||
DrawContactRow(ABitmap, s, '', AWholeRect, AContactRec.CSZRect);
|
||||
|
||||
// Draw phone1
|
||||
s := PhoneLabel(TVpPhoneType(AContact.PhoneType1)) + ': ';
|
||||
DrawContactRow(ABitmap, AContact.Phone1, s, AWholeRect, AContactRec.Phone1Rect);
|
||||
|
||||
// Draw phone2
|
||||
s := PhoneLabel(TVpPhoneType(AContact.PhoneType2)) + ': ';
|
||||
DrawContactRow(ABitmap, AContact.Phone2, s, AWholeRect, AContactRec.Phone2Rect);
|
||||
|
||||
// Draw phone3
|
||||
s := PhoneLabel(TVpPhoneType(AContact.PhoneType3)) + ': ';
|
||||
DrawContactRow(ABitmap, AContact.Phone3, s, AWholeRect, AContactRec.Phone3Rect);
|
||||
|
||||
// Draw phone4
|
||||
s := PhoneLabel(TVpPhoneType(AContact.PhoneType4)) + ': ';
|
||||
DrawContactRow(ABitmap, AContact.Phone4, s, AWholeRect, AContactRec.Phone4Rect);
|
||||
|
||||
// Draw phone5
|
||||
s := PhoneLabel(TVpPhoneType(AContact.PhoneType5)) + ': ';
|
||||
DrawContactRow(ABitmap, AContact.Phone5, s, AWholeRect, AContactRec.Phone5Rect);
|
||||
|
||||
// Draw EMail
|
||||
s := FContactGrid.DisplayEMailValue[AContact];
|
||||
DrawContactRow(ABitmap, s, RSEmail + ': ', AWholeRect, AContactRec.EMailRect);
|
||||
|
||||
// If this record is too big to fit in the remaining area of this column,
|
||||
// then slide over to the top of the next column }
|
||||
newCol := false;
|
||||
if ARecsInCol > 0 then
|
||||
case Angle of
|
||||
ra0:
|
||||
if (RenderIn.Top + Anchor.y + AWholeRect.Bottom >= RenderIn.Bottom - FScaledTextMargin * 3) then
|
||||
begin
|
||||
newCol := true;
|
||||
Anchor := Point(
|
||||
Anchor.x + AWholeRect.Right + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3,
|
||||
px2 + FScaledTextMargin * 2
|
||||
);
|
||||
if DisplayOnly and (Anchor.X + textColWidth >= RenderIn.Right) then
|
||||
Result := false;
|
||||
end;
|
||||
ra90:
|
||||
if (Anchor.x + RenderIn.Left + WidthOf(AWholeRect) > RenderIn.Right - FScaledTextMargin * 3) then
|
||||
begin
|
||||
newCol := true;
|
||||
Anchor.x := px2 + FScaledTextMargin * 2;
|
||||
Anchor.y := Anchor.y + AWholeRect.Bottom + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3;
|
||||
if DisplayOnly and (Anchor.y + textColWidth >= RenderIn.Bottom) then
|
||||
Result := false;
|
||||
end;
|
||||
ra180:
|
||||
if (Anchor.y + RenderIn.Top - HeightOf(AWholeRect) <= RenderIn.Top + FScaledTextMargin * 3) then
|
||||
begin
|
||||
newCol := true;
|
||||
Anchor.x := Anchor.x - (AWholeRect.Right + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3);
|
||||
Anchor.y := ABitmap.Height - px2 - FScaledTextMargin * 2;
|
||||
if DisplayOnly and (Anchor.x + textColWidth < RenderIn.Left) then
|
||||
Result := false;
|
||||
end;
|
||||
ra270:
|
||||
if (Anchor.x + RenderIn.Left + WidthOf(AWholeRect) >= RenderIn.Right - FScaledTextMargin * 3) then
|
||||
begin
|
||||
newCol := true;
|
||||
Anchor.x := px2 + FScaledTextMargin * 2;
|
||||
Anchor.y := Anchor.y - (AWholeRect.Bottom + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3);
|
||||
if DisplayOnly and (Anchor.y + textColWidth <= RenderIn.Top) then
|
||||
Result := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
if newCol then
|
||||
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;
|
||||
Inc(ACol);
|
||||
ARecsInCol := 0;
|
||||
end else
|
||||
// Still the same column: Increment the counter of records per column
|
||||
// (Is evaluated only when we are drawing the first column).
|
||||
inc(ARecsInCol);
|
||||
|
||||
// Add some spacing between records
|
||||
case Angle of
|
||||
ra0 : AWholeRect.Bottom := AWholeRect.Bottom + FScaledTextMargin * 2;
|
||||
ra90 : AWholeRect.Left := AWholeRect.Left - FScaledTextMargin * 2;
|
||||
ra180 : AWholeRect.Top := AWholeRect.Top - FScaledTextMargin * 2;
|
||||
ra270 : AWholeRect.Right := AWholeRect.Right + FScaledTextMargin * 2;
|
||||
end;
|
||||
|
||||
// Move data rectangles to the position at which they will appear on
|
||||
// the render canvas.
|
||||
OffsetRect(AContactRec.AddressRect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.CSZRect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.CompanyRect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.EMailRect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.Phone1Rect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.Phone2Rect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.Phone3Rect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.Phone4Rect, Anchor.X, Anchor.Y);
|
||||
OffsetRect(AContactRec.Phone5Rect, Anchor.X, Anchor.Y);
|
||||
end;
|
||||
|
||||
{ Draws all contacts. To simplify the layout each contact is drawn first into
|
||||
a temporary bitmap which is later copied to the rendering canvas. }
|
||||
procedure TVpContactGridPainter.DrawContacts;
|
||||
@ -327,18 +520,9 @@ var
|
||||
contact: TVpContact;
|
||||
Col, RecsInCol: Integer;
|
||||
WholeRect: TRect;
|
||||
TextColWidth: Integer;
|
||||
oldCol1RecCount: Integer;
|
||||
CR: TVpContactRec;
|
||||
HeadRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
AddrRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
CSZRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
CompanyRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
EMailRect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
Phone1Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
Phone2Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
Phone3Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
Phone4Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
Phone5Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
|
||||
contactCount: Integer;
|
||||
anchorMargin: Integer;
|
||||
px2, px4: Integer; // Scaled 2, 4 pixels
|
||||
@ -368,41 +552,19 @@ begin
|
||||
if (Angle = ra0) or (Angle = ra180) then begin
|
||||
TmpBmp.Width := RealColumnWidth - FScaledTextMargin * 4 + px4;
|
||||
TmpBmp.Height := RealHeight - FScaledTextMargin * 2;
|
||||
TextColWidth := TmpBmp.Width;
|
||||
end else begin
|
||||
TmpBmp.Height := RealColumnWidth - FScaledTextMargin * 4 + px4;
|
||||
TmpBmp.Width := RealHeight - FScaledTextMargin * 2;
|
||||
TextColWidth := TmpBmp.Height;
|
||||
end;
|
||||
|
||||
// Calculate max label width
|
||||
FLabelWidth := CalcLabelWidth(TmpBmp);
|
||||
|
||||
// Calculate the header rectangle. It is the same for all contacts.
|
||||
HeadRect := CalcHeaderRect(TmpBmp);
|
||||
|
||||
TmpBmp.Canvas.Font.Assign(FContactGrid.Font);
|
||||
TmpBmp.Canvas.Font.PixelsPerInch := RenderCanvas.Font.PixelsPerInch;
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
|
||||
// Calculate max phone label width
|
||||
PhoneLblWidth := TmpBmp.Canvas.TextWidth(RSEmail);
|
||||
for I := 0 to 7 do begin
|
||||
Str := PhoneLabel(TVpPhoneType(I)) + ': ';
|
||||
w := TmpBmp.Canvas.TextWidth(Str);
|
||||
if w > PhoneLblWidth then
|
||||
PhoneLblWidth := w;
|
||||
end;
|
||||
|
||||
// Set the anchor starting point for the very first (top/left) contact
|
||||
anchorMargin := px2 + FScaledTextMargin * 2;
|
||||
case Angle of
|
||||
ra0, ra90:
|
||||
Anchor := Point(anchorMargin, anchorMargin);
|
||||
ra180:
|
||||
Anchor := Point(WidthOf(RenderIn) - TmpBmp.Width - anchorMargin, TmpBmp.Height - anchorMargin);
|
||||
ra270:
|
||||
Anchor := Point(anchorMargin, HeightOf(RenderIn) - TmpBmp.Height - anchorMargin);
|
||||
end;
|
||||
Anchor := CalcInitialAnchor(TmpBmp);
|
||||
|
||||
// Sort the records
|
||||
FContactGrid.DataStore.Resource.Contacts.Sort;
|
||||
@ -412,154 +574,39 @@ begin
|
||||
RecsInCol := 0;
|
||||
for I := StartContact to pred(contactCount) do begin
|
||||
contact := FContactGrid.DataStore.Resource.Contacts.GetContact(I);
|
||||
if (contact <> nil) then begin
|
||||
TVpContactGridOpener(FContactGrid).cgContactArray[I].Contact := contact;
|
||||
if contact = nil then
|
||||
Continue;
|
||||
|
||||
// Clear bmp canvas
|
||||
TmpBmp.Canvas.Brush.Color := RealColor;
|
||||
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
||||
// Clear bmp canvas
|
||||
TmpBmp.Canvas.Brush.Color := RealColor;
|
||||
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
||||
|
||||
// Start building the WholeRect
|
||||
WholeRect := HeadRect;
|
||||
if Angle = ra180 then
|
||||
WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height);
|
||||
// Draw the contact header
|
||||
DrawContactHeader(TmpBmp, contact, HeadRect);
|
||||
|
||||
// Draw the contact header
|
||||
DrawContactHeader(TmpBmp, contact, HeadRect);
|
||||
// Draw the contact data
|
||||
WholeRect := HeadRect;
|
||||
if Angle = ra180 then
|
||||
WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height);
|
||||
if DrawContactRows(TmpBmp, contact, Anchor, WholeRect, Col, RecsInCol, CR) then
|
||||
begin
|
||||
CR.Index := I;
|
||||
CR.Contact := contact;
|
||||
CR.WholeRect := MoveRect(WholeRect, Anchor);
|
||||
CR.HeaderRect := MoveRect(HeadRect, Anchor);
|
||||
TVpContactGridOpener(FContactGrid).cgContactArray[I] := CR;
|
||||
end else
|
||||
exit; // to do: begin a new page here!
|
||||
|
||||
// Set font and colors for the contact data
|
||||
TmpBmp.Canvas.Font.Assign(FContactGrid.Font);
|
||||
TmpBmp.Canvas.Font.PixelsPerInch := RenderCanvas.Font.PixelsPerInch;
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
TmpBmp.Canvas.Brush.Color := RealColor;
|
||||
// Draw the contact bitmap on the rendering canvas
|
||||
PaintContactBitmap(TmpBmp, contact, Anchor, WholeRect);
|
||||
|
||||
// Draw company
|
||||
DrawContactRow(TmpBmp, contact.Company, '', WholeRect, CompanyRect);
|
||||
|
||||
// Draw address
|
||||
DrawContactRow(TmpBmp, contact.Address1, '', WholeRect, AddrRect);
|
||||
|
||||
// Draw city, state, zip
|
||||
Str := AssembleCSZ(contact, 1, FContactGrid.GetCityStateZipFormat);
|
||||
DrawContactRow(TmpBmp, Str, '', WholeRect, CSZRect);
|
||||
|
||||
// Draw phone1
|
||||
Str := PhoneLabel(TVpPhoneType(contact.PhoneType1)) + ': ';
|
||||
DrawContactRow(TmpBmp, contact.Phone1, Str, WholeRect, Phone1Rect);
|
||||
|
||||
// Draw phone2
|
||||
Str := PhoneLabel(TVpPhoneType(contact.PhoneType2)) + ': ';
|
||||
DrawContactRow(TmpBmp, contact.Phone2, Str, WholeRect, Phone2Rect);
|
||||
|
||||
// Draw phone3
|
||||
Str := PhoneLabel(TVpPhoneType(contact.PhoneType3)) + ': ';
|
||||
DrawContactRow(TmpBmp, contact.Phone3, Str, WholeRect, Phone3Rect);
|
||||
|
||||
// Draw phone4
|
||||
Str := PhoneLabel(TVpPhoneType(contact.PhoneType4)) + ': ';
|
||||
DrawContactRow(TmpBmp, contact.Phone4, Str, WholeRect, Phone4Rect);
|
||||
|
||||
// Draw phone5
|
||||
Str := PhoneLabel(TVpPhoneType(contact.PhoneType5)) + ': ';
|
||||
DrawContactRow(TmpBmp, contact.Phone5, Str, WholeRect, Phone5Rect);
|
||||
|
||||
// Draw EMail
|
||||
Str := TVpContactGridOpener(FContactGrid).GetDisplayEMailValue(contact);
|
||||
DrawContactRow(TmpBmp, Str, RSEmail + ': ', WholeRect, EMailRect);
|
||||
|
||||
// If this record's too big to fit in the remaining area of this column,
|
||||
// then slide over to the top of the next column }
|
||||
if RecsInCol > 0 then
|
||||
case Angle of
|
||||
ra0:
|
||||
if (RenderIn.Top + Anchor.y + WholeRect.Bottom >= RenderIn.Bottom - FScaledTextMargin * 3) then
|
||||
begin
|
||||
Anchor := Point(
|
||||
Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3,
|
||||
px2 + FScaledTextMargin * 2
|
||||
);
|
||||
if Col = 1 then
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
||||
Inc(Col);
|
||||
RecsInCol := 0;
|
||||
if DisplayOnly and (Anchor.X + TextColWidth >= RenderIn.Right) then
|
||||
Exit;
|
||||
end;
|
||||
ra90 :
|
||||
if (Anchor.x + RenderIn.Left + WholeRect.Right - WholeRect.Left > RenderIn.Right - FScaledTextMargin * 3) then
|
||||
begin
|
||||
Anchor.x := px2 + FScaledTextMargin * 2;
|
||||
Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3;
|
||||
if Col = 1 then
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
||||
Inc(Col);
|
||||
RecsInCol := 0;
|
||||
if DisplayOnly and (Anchor.y + TextColWidth >= RenderIn.Bottom) then
|
||||
Exit;
|
||||
end;
|
||||
ra180 :
|
||||
if (Anchor.y + RenderIn.Top - WholeRect.Bottom - WholeRect.Top <= RenderIn.Top + FScaledTextMargin * 3) then
|
||||
begin
|
||||
Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3);
|
||||
Anchor.y := TmpBmp.Height - px2 - FScaledTextMargin * 2;
|
||||
if Col = 1 then
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
||||
Inc(Col);
|
||||
RecsInCol := 0;
|
||||
if DisplayOnly and (Anchor.x + TextColWidth < RenderIn.Left) then
|
||||
Exit;
|
||||
end;
|
||||
ra270 :
|
||||
if (Anchor.x + RenderIn.Left + (WholeRect.Right - WholeRect.Left) >= RenderIn.Right - FScaledTextMargin * 3) then
|
||||
begin
|
||||
Anchor.x := px2 + FScaledTextMargin * 2;
|
||||
Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + FScaledTextMargin * 3);
|
||||
if Col = 1 then
|
||||
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
||||
Inc(Col);
|
||||
RecsInCol := 0;
|
||||
if DisplayOnly and (Anchor.y + TextColWidth <= RenderIn.Top) then
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Add some spacing between records
|
||||
case Angle of
|
||||
ra0 : WholeRect.Bottom := WholeRect.Bottom + FScaledTextMargin * 2;
|
||||
ra90 : WholeRect.Left := WholeRect.Left - FScaledTextMargin * 2;
|
||||
ra180 : WholeRect.Top := WholeRect.Top - FScaledTextMargin * 2;
|
||||
ra270 : WholeRect.Right := WholeRect.Right + FScaledTextMargin * 2;
|
||||
end;
|
||||
|
||||
// Update array rects
|
||||
with TVpContactGridOpener(FContactGrid) do begin
|
||||
cgContactArray[I].WholeRect := MoveRect(WholeRect, Anchor);
|
||||
cgContactArray[I].HeaderRect := MoveRect(HeadRect, Anchor);
|
||||
cgContactArray[I].AddressRect := MoveRect(AddrRect, Anchor);
|
||||
cgContactArray[I].CSZRect := MoveRect(CSZRect, Anchor);
|
||||
cgContactArray[I].CompanyRect := MoveRect(CompanyRect, Anchor);
|
||||
cgContactArray[I].EMailRect := MoveRect(EMailRect, Anchor);
|
||||
cgContactArray[I].Phone1Rect := MoveRect(Phone1Rect, Anchor);
|
||||
cgContactArray[I].Phone2Rect := MoveRect(Phone2Rect, Anchor);
|
||||
cgContactArray[I].Phone3Rect := MoveRect(Phone3Rect, Anchor);
|
||||
cgContactArray[I].Phone4Rect := MoveRect(Phone4Rect, Anchor);
|
||||
cgContactArray[I].Phone5Rect := MoveRect(Phone5Rect, Anchor);
|
||||
end;
|
||||
|
||||
// Draw the contact bitmap on the rendering canvas
|
||||
PaintContactBitmap(TmpBmp, contact, Anchor, WholeRect);
|
||||
|
||||
// Slide anchor down for the next record
|
||||
case Angle of
|
||||
ra0 : Anchor.Y := Anchor.Y + WholeRect.Bottom;
|
||||
ra90 : Anchor.X := Anchor.X + (WholeRect.Right - WholeRect.Left);
|
||||
ra180 : Anchor.Y := Anchor.Y - (WholeRect.Bottom - WholeRect.Top);
|
||||
ra270 : Anchor.X := Anchor.X + WholeRect.Right;
|
||||
end;
|
||||
|
||||
Inc(RecsInCol);
|
||||
// Slide anchor down for the next record
|
||||
case Angle of
|
||||
ra0 : Anchor.Y := Anchor.Y + WholeRect.Bottom;
|
||||
ra90 : Anchor.X := Anchor.X + WidthOf(WholeRect);
|
||||
ra180 : Anchor.Y := Anchor.Y - HeightOf(WholeRect);
|
||||
ra270 : Anchor.X := Anchor.X + WholeRect.Right;
|
||||
end;
|
||||
|
||||
if not DisplayOnly then
|
||||
|
Reference in New Issue
Block a user