2016-06-23 11:53:21 +00:00
|
|
|
unit VpContactGridPainter;
|
|
|
|
|
2016-06-25 23:46:00 +00:00
|
|
|
{$I vp.inc}
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
LCLType, LCLIntf,
|
|
|
|
Types, Classes, Graphics,
|
|
|
|
VpConst, VPBase, VpData, VpBasePainter, VpContactGrid;
|
|
|
|
|
|
|
|
type
|
|
|
|
TVpContactGridPainter = class(TVpBasePainter)
|
|
|
|
private
|
|
|
|
FContactGrid: TVpContactGrid;
|
|
|
|
// local variables of the original TVpContactGrid method
|
|
|
|
PhoneLblWidth: Integer;
|
|
|
|
StartContact: Integer;
|
|
|
|
RealColumnWidth: Integer;
|
|
|
|
RealColor: TColor;
|
|
|
|
SizingBarColor: TColor;
|
|
|
|
BevelDarkShadow: TColor;
|
|
|
|
BevelShadow: TColor;
|
|
|
|
BevelHighlight: TColor;
|
|
|
|
BevelFace: TColor;
|
|
|
|
RealBarColor: TColor;
|
|
|
|
RealContactHeadAttrColor: TColor;
|
|
|
|
|
|
|
|
protected
|
|
|
|
procedure Clear;
|
|
|
|
procedure DrawBorders;
|
2016-06-23 22:50:04 +00:00
|
|
|
procedure DrawContactLine(ABitmap: TBitmap; AText, ALabel: String;
|
2016-06-23 16:13:17 +00:00
|
|
|
var AWholeRect, ATextRect: TRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
procedure DrawContacts;
|
|
|
|
procedure DrawVerticalBars;
|
2016-07-15 11:52:21 +00:00
|
|
|
procedure FixFontHeights;
|
2016-06-23 11:53:21 +00:00
|
|
|
procedure InitColors;
|
|
|
|
|
|
|
|
public
|
|
|
|
constructor Create(AContactGrid: TVpContactGrid; ARenderCanvas: TCanvas);
|
|
|
|
procedure RenderToCanvas(ARenderIn: TRect; AAngle: TVpRotationAngle;
|
|
|
|
AScale: Extended; ARenderDate: TDateTime; AStartLine, AStopLine: Integer;
|
|
|
|
AUseGran: TVpGranularity; ADisplayOnly: Boolean); override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
VpCanvasUtils, VpMisc, VpSR;
|
|
|
|
|
|
|
|
type
|
|
|
|
TVpContactGridOpener = class(TVpContactGrid);
|
|
|
|
|
|
|
|
constructor TVpContactGridPainter.Create(AContactGrid: TVpContactGrid;
|
|
|
|
ARenderCanvas: TCanvas);
|
|
|
|
begin
|
|
|
|
inherited Create(ARenderCanvas);
|
|
|
|
FContactGrid := AContactGrid;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpContactGridPainter.Clear;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
begin
|
|
|
|
{ clear Client Area }
|
|
|
|
RenderCanvas.Brush.Color := RealColor;
|
|
|
|
RenderCanvas.FillRect(RenderIn);
|
|
|
|
|
|
|
|
{ clear the vertical bar array }
|
|
|
|
for I := 0 to pred(MaxColumns) do begin
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
|
|
|
if cgBarArray[I].Index = -1 then
|
|
|
|
Break;
|
|
|
|
cgBarArray[I].Rec := Rect(-1, -1, -1, -1);
|
|
|
|
cgBarArray[I].Index := -1;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ initialize the contact array at runtime }
|
|
|
|
if not (csDesigning in FContactGrid.ComponentState) and (FContactGrid.DataStore <> nil)
|
|
|
|
and (FContactGrid.DataStore.Resource <> nil)
|
|
|
|
then
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
|
|
|
SetLength(cgContactArray, DataStore.Resource.Contacts.Count);
|
|
|
|
for I := 0 to pred(Length(cgContactArray)) do
|
|
|
|
with cgContactArray[I] do begin
|
|
|
|
Index := -1;
|
|
|
|
Contact := nil;
|
|
|
|
WholeRect := Rect(-1, -1, -1, -1);
|
|
|
|
HeaderRect := Rect(-1, -1, -1, -1);
|
|
|
|
AddressRect := Rect(-1, -1, -1, -1);
|
|
|
|
CSZRect := Rect(-1, -1, -1, -1);
|
|
|
|
Phone1Rect := Rect(-1, -1, -1, -1);
|
|
|
|
Phone2Rect := Rect(-1, -1, -1, -1);
|
|
|
|
Phone3Rect := Rect(-1, -1, -1, -1);
|
|
|
|
Phone4Rect := Rect(-1, -1, -1, -1);
|
|
|
|
Phone5Rect := Rect(-1, -1, -1, -1);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpContactGridPainter.DrawBorders;
|
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
begin
|
|
|
|
R := RenderIn;
|
|
|
|
dec(R.Right, 1);
|
|
|
|
dec(R.Bottom, 1);
|
|
|
|
case FContactGrid.DrawingStyle of
|
|
|
|
dsFlat:
|
2016-07-02 08:56:40 +00:00
|
|
|
begin { Draw a simple border rectangle }
|
|
|
|
DrawBevelRect(RenderCanvas, R, BevelShadow, BevelShadow);
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
ds3d:
|
2016-07-02 08:56:40 +00:00
|
|
|
begin { Draw a 3d bevel }
|
2016-06-23 11:53:21 +00:00
|
|
|
DrawBevelRect(RenderCanvas, R, BevelShadow, BevelHighlight);
|
|
|
|
InflateRect(R, -1, -1);
|
2016-07-03 08:39:53 +00:00
|
|
|
DrawBevelRect(RenderCanvas, R, BevelDarkShadow, BevelFace);
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-23 22:50:04 +00:00
|
|
|
procedure TVpContactGridPainter.DrawContactLine(ABitmap: TBitmap;
|
|
|
|
AText, ALabel: String; var AWholeRect, ATextRect: TRect);
|
2016-06-23 16:13:17 +00:00
|
|
|
var
|
|
|
|
txtheight: Integer;
|
|
|
|
txtColWidth: Integer;
|
|
|
|
begin
|
2016-06-23 22:50:04 +00:00
|
|
|
if AText = '' then begin
|
|
|
|
ATextRect := Rect(0, 0, 0, 0);
|
2016-06-23 16:13:17 +00:00
|
|
|
exit;
|
2016-06-23 22:50:04 +00:00
|
|
|
end;
|
2016-06-23 16:13:17 +00:00
|
|
|
|
|
|
|
txtHeight := ABitmap.Canvas.TextHeight(VpProductName);
|
|
|
|
|
|
|
|
case Angle of
|
|
|
|
ra0:
|
|
|
|
begin
|
|
|
|
ATextRect.Left := TextMargin;
|
|
|
|
ATextRect.Top := AWholeRect.Bottom + TextMargin div 2;
|
|
|
|
ATextRect.Right := ABitmap.Width;
|
|
|
|
ATextRect.Bottom := ATextRect.Top + txtHeight + TextMargin div 2;
|
|
|
|
AWholeRect.Bottom := ATextRect.Bottom;
|
|
|
|
txtColWidth := ABitmap.Width;
|
|
|
|
end;
|
|
|
|
ra90:
|
|
|
|
begin
|
|
|
|
ATextRect.Left := AWholeRect.Left - txtHeight + TextMargin div 2;
|
|
|
|
ATextRect.Top := TextMargin;
|
|
|
|
ATextRect.Right := AWholeRect.Left - TextMargin div 2;
|
|
|
|
ATextRect.Bottom := AWholeRect.Bottom + TextMargin div 2;
|
|
|
|
AWholeRect.Left := ATextRect.Left;
|
|
|
|
txtColWidth := ABitmap.Height;
|
|
|
|
end;
|
|
|
|
ra180:
|
|
|
|
begin
|
|
|
|
ATextRect.Left := AWholeRect.Right - TextMargin * 2; // Shouldn't this be "div 2" ?
|
|
|
|
ATextRect.Top := AWholeRect.Top - txtHeight - TextMargin;
|
|
|
|
ATextRect.Right := AWholeRect.Left + TextMargin;
|
|
|
|
ATextRect.Bottom := AWholeRect.Top - TextMargin div 2;
|
|
|
|
AWholeRect.Top := ATextRect.Top;
|
|
|
|
txtColWidth := ABitmap.Width;
|
|
|
|
end;
|
|
|
|
ra270:
|
|
|
|
begin
|
|
|
|
ATextRect.Left := AWholeRect.Right;
|
|
|
|
ATextRect.Top := AWholeRect.Bottom - TextMargin;
|
|
|
|
ATextRect.Right := AWholeRect.Right + txtHeight + TextMargin div 2;
|
|
|
|
ATextRect.Bottom := AWholeRect.Top + TextMargin div 2;
|
|
|
|
AWholeRect.Right := ATextRect.Right;
|
|
|
|
txtColWidth := ABitmap.Height;
|
|
|
|
end;
|
|
|
|
end; // case Angle...
|
|
|
|
|
|
|
|
AText := GetDisplayString(ABitmap.Canvas, AText, 2, txtColWidth - TextMargin * 2);
|
|
|
|
|
|
|
|
if ALabel <> '' then begin
|
|
|
|
TPSTextOutAtPoint(
|
|
|
|
ABitmap.Canvas,
|
|
|
|
Angle,
|
|
|
|
Rect(0, 0, ABitmap.Width, ABitmap.Height),
|
|
|
|
ATextRect.Left + TextMargin,
|
|
|
|
ATextRect.Top + TextMargin div 2,
|
|
|
|
ALabel
|
|
|
|
);
|
|
|
|
|
|
|
|
with ATextRect do
|
|
|
|
case Angle of
|
|
|
|
ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + TextMargin div 2);
|
|
|
|
ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + TextMargin);
|
|
|
|
ra180 : TopLeft := Point(Left - PhoneLblWidth, top + TextMargin div 2);
|
|
|
|
ra270 : TopLeft := Point(Left + TextMargin div 2, Top - PhoneLblWidth);
|
|
|
|
end;
|
|
|
|
TPSTextOutAtPoint(
|
|
|
|
ABitmap.Canvas,
|
|
|
|
Angle,
|
|
|
|
Rect(0, 0, ABitmap.Width, ABitmap.Height),
|
|
|
|
ATextRect.Left,
|
|
|
|
ATextRect.Top,
|
|
|
|
AText
|
|
|
|
);
|
|
|
|
end else
|
|
|
|
TPSTextOutAtPoint(
|
|
|
|
ABitmap.Canvas,
|
|
|
|
Angle,
|
|
|
|
Rect(0, 0, ABitmap.Width, ABitmap.Height),
|
|
|
|
ATextRect.Left + TextMargin,
|
|
|
|
ATextRect.Top + TextMargin div 2,
|
|
|
|
AText
|
|
|
|
);
|
|
|
|
end;
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
procedure TVpContactGridPainter.DrawContacts;
|
|
|
|
var
|
|
|
|
Anchor: TPoint;
|
|
|
|
I, J: Integer;
|
|
|
|
Str: string;
|
|
|
|
TmpBmp: TBitmap;
|
|
|
|
TmpCon: TVpContact;
|
|
|
|
Col, RecsInCol: Integer;
|
2016-07-15 23:25:07 +00:00
|
|
|
HeadRect: TRect;
|
|
|
|
WholeRect: TRect;
|
2016-06-23 11:53:21 +00:00
|
|
|
TmpBmpRect: TRect;
|
|
|
|
TextColWidth: Integer;
|
|
|
|
TextXOffset: Integer;
|
|
|
|
TextYOffset: Integer;
|
|
|
|
oldCol1RecCount: Integer;
|
2016-07-15 23:25:07 +00:00
|
|
|
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);
|
2018-06-09 13:23:44 +00:00
|
|
|
R: TRect;
|
2018-06-10 16:42:16 +00:00
|
|
|
contactCount: Integer;
|
|
|
|
baseTextHeight: Integer;
|
|
|
|
maxTextWidth: Integer;
|
2016-06-23 11:53:21 +00:00
|
|
|
begin
|
|
|
|
{ if the component is sufficiently small then no sense in painting it }
|
|
|
|
if (FContactGrid.Height < 20) then exit;
|
|
|
|
|
|
|
|
{ don't paint contacts at designtime or if the data connection is invalid }
|
|
|
|
if (csDesigning in FContactGrid.ComponentState) or
|
|
|
|
(FContactGrid.DataStore = nil) or
|
|
|
|
(FContactGrid.DataStore.Resource = nil)
|
|
|
|
then
|
|
|
|
Exit;
|
|
|
|
|
2018-06-12 09:22:39 +00:00
|
|
|
{ Some initializations }
|
|
|
|
contactCount := FContactGrid.DataStore.Resource.Contacts.Count;
|
|
|
|
oldCol1RecCount := TVpContactGridOpener(FContactGrid).cgCol1RecCount;
|
|
|
|
TVpContactGridOpener(FContactGrid).FVisibleContacts := 0;
|
|
|
|
TVpContactGridOpener(FContactGrid).cgCol1RecCount := 0;
|
|
|
|
TextXOffset := 0;
|
|
|
|
TextYOffset := 0;
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
{ create a temporary bitmap for painting the items }
|
|
|
|
TmpBmp := TBitmap.Create;
|
|
|
|
try
|
|
|
|
if (Angle = ra0) or (Angle = ra180) then begin
|
2018-06-09 13:23:44 +00:00
|
|
|
TmpBmp.Width := RealColumnWidth - TextMargin * 4 + 4; // wp:+4
|
2016-06-23 11:53:21 +00:00
|
|
|
TmpBmp.Height := RealHeight - TextMargin * 2;
|
|
|
|
TextColWidth := TmpBmp.Width;
|
|
|
|
end else begin
|
2018-06-09 13:23:44 +00:00
|
|
|
TmpBmp.Height := RealColumnWidth - TextMargin * 4 + 4; // wp: +4
|
2016-06-23 11:53:21 +00:00
|
|
|
TmpBmp.Width := RealHeight - TextMargin * 2;
|
|
|
|
TextColWidth := TmpBmp.Height;
|
|
|
|
end;
|
|
|
|
TmpBmpRect := Rect(0, 0, TmpBmp.Width, TmpBmp.Height);
|
|
|
|
TmpBmp.Canvas.Font.Assign(FContactGrid.Font);
|
2017-05-22 08:11:27 +00:00
|
|
|
{$IF VP_LCL_SCALING = 0}
|
2016-08-08 18:29:24 +00:00
|
|
|
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
2017-05-22 08:11:27 +00:00
|
|
|
{$ENDIF}
|
2018-06-10 16:42:16 +00:00
|
|
|
baseTextHeight := TmpBmp.Canvas.TextHeight(VpProductName);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
|
|
|
{ Calculate Phone Lbl Width }
|
|
|
|
PhoneLblWidth := TmpBmp.Canvas.TextWidth(RSEmail);
|
|
|
|
for I := 0 to 7 do begin
|
|
|
|
Str := PhoneLabel(TVpPhoneType(I)) + ': ';
|
|
|
|
J := TmpBmp.Canvas.TextWidth(Str);
|
|
|
|
if J > PhoneLblWidth then
|
|
|
|
PhoneLblWidth := J;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Col := 1;
|
2016-06-23 22:50:04 +00:00
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
{ clear the bitmap }
|
|
|
|
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
|
|
|
|
|
|
|
{ sort the records }
|
2018-06-09 22:57:50 +00:00
|
|
|
FContactGrid.DataStore.Resource.Contacts.Sort; // wp: why sort here?
|
2016-06-23 11:53:21 +00:00
|
|
|
|
|
|
|
{ Set the anchor starting point }
|
|
|
|
case Angle of
|
|
|
|
ra0:
|
|
|
|
Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2);
|
|
|
|
ra90:
|
|
|
|
Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2);
|
|
|
|
ra180:
|
|
|
|
Anchor := Point(
|
|
|
|
RenderIn.Right - RenderIn.Left - TmpBmp.Width - 2 - TextMargin * 2,
|
|
|
|
TmpBmp.Height - 2 - TextMargin * 2
|
|
|
|
);
|
|
|
|
ra270:
|
|
|
|
Anchor := Point(
|
|
|
|
2 + TextMargin * 2,
|
|
|
|
RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - 2 - TextMargin * 2
|
|
|
|
);
|
|
|
|
end;
|
|
|
|
RecsInCol := 0;
|
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
for I := StartContact to pred(contactCount) do begin
|
2016-06-23 11:53:21 +00:00
|
|
|
TmpCon := FContactGrid.DataStore.Resource.Contacts.GetContact(I);
|
|
|
|
if (TmpCon <> nil) then begin
|
2018-06-10 16:42:16 +00:00
|
|
|
TVpContactGridOpener(FContactGrid).cgContactArray[I].Contact := TmpCon;
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
{ Clear bmp canvas }
|
|
|
|
TmpBmp.Canvas.Brush.Color := RealColor;
|
|
|
|
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
|
|
|
|
|
|
|
{ start building the WholeRect and build the HeaderRect}
|
|
|
|
TmpBmp.Canvas.Pen.Color := BevelDarkShadow;
|
|
|
|
TmpBmp.Canvas.Brush.Style := bsSolid;
|
|
|
|
TmpBmp.Canvas.Font.Assign(FContactGrid.ContactHeadAttributes.Font);
|
2017-05-22 08:11:27 +00:00
|
|
|
{$IF VP_LCL_SCALING = 0}
|
2016-08-08 18:29:24 +00:00
|
|
|
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
2017-05-22 08:11:27 +00:00
|
|
|
{$ENDIF}
|
2018-06-09 13:23:44 +00:00
|
|
|
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then
|
|
|
|
TmpBmp.Canvas.Font.Style := [fsBold];
|
2016-06-23 11:53:21 +00:00
|
|
|
case Angle of
|
|
|
|
ra0:
|
|
|
|
begin
|
|
|
|
WholeRect.TopLeft := Point(0, 0);
|
2018-06-09 13:23:44 +00:00
|
|
|
// HeadRect.TopLeft := Point(TextMargin, TextMargin div 2);
|
|
|
|
// HeadRect.TopLeft := Point(TextMargin, 0);
|
|
|
|
HeadRect.TopLeft := Point(0, 0);
|
2016-06-23 11:53:21 +00:00
|
|
|
HeadRect.BottomRight := Point(
|
|
|
|
TmpBmp.Width,
|
2018-06-10 16:42:16 +00:00
|
|
|
HeadRect.Top + baseTextHeight + TextMargin div 2
|
2016-06-23 11:53:21 +00:00
|
|
|
);
|
|
|
|
WholeRect.BottomRight := HeadRect.BottomRight;
|
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
ra90: // TO DO: CHECK CORRECT USAGE OF TextMargin HERE !!!!!!!!!
|
2016-06-23 11:53:21 +00:00
|
|
|
begin
|
|
|
|
HeadRect.TopLeft := Point(
|
2018-06-10 16:42:16 +00:00
|
|
|
TmpBmpRect.Right - TextMargin - baseTextHeight + TextMargin div 2,
|
2016-06-23 11:53:21 +00:00
|
|
|
0
|
|
|
|
);
|
|
|
|
HeadRect.BottomRight := Point(TmpBmpRect.Right, TmpBmp.Height);
|
|
|
|
WholeRect.TopLeft := HeadRect.TopLeft;
|
|
|
|
WholeRect.BottomRight := HeadRect.BottomRight;
|
|
|
|
end;
|
|
|
|
ra180:
|
|
|
|
begin
|
|
|
|
WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height);
|
|
|
|
HeadRect.TopLeft := Point(
|
|
|
|
TextMargin,
|
2018-06-10 16:42:16 +00:00
|
|
|
TmpBmpRect.Bottom - baseTextHeight - TextMargin
|
2016-06-23 11:53:21 +00:00
|
|
|
);
|
|
|
|
HeadRect.BottomRight := Point(
|
|
|
|
TmpBmp.Width,
|
|
|
|
TmpBmp.Height - TextMargin div 2
|
|
|
|
);
|
|
|
|
WholeRect.TopLeft := HeadRect.TopLeft;
|
|
|
|
end;
|
|
|
|
ra270:
|
|
|
|
begin
|
|
|
|
WholeRect.TopLeft := Point(0, 0);
|
|
|
|
HeadRect.TopLeft := Point(0, TextMargin);
|
|
|
|
HeadRect.BottomRight := Point(
|
2018-06-10 16:42:16 +00:00
|
|
|
TextMargin + baseTextHeight + TextMargin div 2,
|
2016-06-23 11:53:21 +00:00
|
|
|
TmpBmp.Height
|
|
|
|
);
|
|
|
|
WholeRect.BottomRight := HeadRect.BottomRight;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ paint the header cell's background }
|
|
|
|
TmpBmp.Canvas.Brush.Color := RealContactHeadAttrColor;
|
|
|
|
TmpBmp.Canvas.FillRect(HeadRect);
|
|
|
|
|
|
|
|
{ paint the header cell's border }
|
|
|
|
if FContactGrid.ContactHeadAttributes.Bordered and (FContactGrid.DrawingStyle <> dsNoBorder)
|
|
|
|
then begin
|
|
|
|
TmpBmp.Canvas.Pen.Style := psSolid;
|
|
|
|
TmpBmp.Canvas.Rectangle(HeadRect);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ paint the header cell's text }
|
|
|
|
case Angle of
|
|
|
|
ra90:
|
|
|
|
begin
|
|
|
|
TextXOffset := WidthOf(HeadRect) - TextMargin div 2;
|
|
|
|
TextYOffset := TextMargin div 3;
|
|
|
|
end;
|
|
|
|
ra180:
|
|
|
|
begin
|
|
|
|
TextXOffset := WidthOf(HeadRect) - TextMargin;
|
|
|
|
TextYOffset := HeightOf(HeadRect) - TextMargin div 3;
|
|
|
|
end;
|
|
|
|
ra270:
|
|
|
|
begin
|
|
|
|
TextXOffset := TextMargin div 2;
|
|
|
|
TextYOffset := HeightOf(HeadRect) - TextMargin div 3;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
{ assemble the header string }
|
2018-06-10 16:42:16 +00:00
|
|
|
if (Angle in [ra0, ra180]) then
|
|
|
|
maxTextWidth := WidthOf(HeadRect)
|
|
|
|
else
|
|
|
|
maxTextWidth := HeightOf(HeadRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
Str := AssembleName(TmpCon);
|
2018-06-10 16:42:16 +00:00
|
|
|
Str := GetDisplayString(TmpBmp.Canvas, Str, 2, maxTextWidth - TextMargin);
|
|
|
|
|
|
|
|
TPSTextOutAtPoint(
|
|
|
|
TmpBmp.Canvas,
|
|
|
|
Angle,
|
|
|
|
TmpBmpRect,
|
|
|
|
HeadRect.Left + TextMargin div 2 + TextXOffset,
|
|
|
|
HeadRect.Top + TextMargin div 3 + TextYOffset,
|
|
|
|
Str
|
|
|
|
);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ restore font and colors }
|
|
|
|
TmpBmp.Canvas.Font.Assign(FContactGrid.Font);
|
|
|
|
{$IF VP_LCL_SCALING = 0}
|
|
|
|
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
|
|
|
{$ENDIF}
|
|
|
|
TmpBmp.Canvas.Brush.Color := RealColor;
|
|
|
|
TmpBmp.Canvas.Pen.Color := BevelDarkShadow;
|
|
|
|
TmpBmp.Canvas.Pen.Style := psSolid;
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Company }
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Company, '', WholeRect, CompanyRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do address... }
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Address1, '', WholeRect, AddrRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do City, State, Zip }
|
|
|
|
Str := AssembleCSZ(TmpCon, 1, FContactGrid.GetCityStateZipFormat);
|
|
|
|
DrawContactLine(TmpBmp, Str, '', WholeRect, CSZRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Phone1 }
|
|
|
|
Str := PhoneLabel(TVpPhoneType(TmpCon.PhoneType1)) + ': ';
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Phone1, Str, WholeRect, Phone1Rect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Phone2 }
|
|
|
|
Str := PhoneLabel(TVpPhoneType(TmpCon.PhoneType2)) + ': ';
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Phone2, Str, WholeRect, Phone2Rect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Phone3 }
|
|
|
|
Str := PhoneLabel(TVpPhoneType(TmpCon.PhoneType3)) + ': ';
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Phone3, Str, WholeRect, Phone3Rect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Phone4 }
|
|
|
|
Str := PhoneLabel(TVpPhoneType(TmpCon.PhoneType4)) + ': ';
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Phone4, Str, WholeRect, Phone4Rect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do Phone5 }
|
|
|
|
Str := PhoneLabel(TVpPhoneType(TmpCon.PhoneType5)) + ': ';
|
|
|
|
DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ do EMail }
|
|
|
|
Str := TVpContactGridOpener(FContactGrid).GetDisplayEMailValue(TmpCon);
|
|
|
|
DrawContactLine(TmpBmp, Str, RSEmail + ': ', WholeRect, EMailRect);
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ 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
|
2016-06-23 11:53:21 +00:00
|
|
|
case Angle of
|
2018-06-10 16:42:16 +00:00
|
|
|
ra0:
|
|
|
|
if (RenderIn.Top + Anchor.y + WholeRect.Bottom >= RenderIn.Bottom - TextMargin * 3) then
|
|
|
|
begin
|
2016-06-23 11:53:21 +00:00
|
|
|
Anchor := Point(
|
|
|
|
Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3,
|
|
|
|
2 + TextMargin * 2
|
|
|
|
);
|
|
|
|
if Col = 1 then
|
|
|
|
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
|
|
|
Inc(Col);
|
|
|
|
RecsInCol := 0;
|
|
|
|
if DisplayOnly and (Anchor.X + TextColWidth >= RenderIn.Right) then
|
|
|
|
Exit;
|
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
ra90 :
|
|
|
|
if (Anchor.x + RenderIn.Left + WholeRect.Right - WholeRect.Left > RenderIn.Right - TextMargin * 3) then
|
|
|
|
begin
|
2016-06-23 11:53:21 +00:00
|
|
|
Anchor.x := 2 + TextMargin * 2;
|
|
|
|
Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3;
|
|
|
|
if Col = 1 then
|
|
|
|
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
|
|
|
Inc(Col);
|
|
|
|
RecsInCol := 0;
|
|
|
|
if DisplayOnly and (Anchor.y + TextColWidth >= RenderIn.Bottom) then
|
|
|
|
Exit;
|
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
ra180 :
|
|
|
|
if (Anchor.y + RenderIn.Top - WholeRect.Bottom - WholeRect.Top <= RenderIn.Top + TextMargin * 3) then
|
2016-06-23 11:53:21 +00:00
|
|
|
begin
|
|
|
|
Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3);
|
|
|
|
Anchor.y := TmpBmp.Height - 2 - TextMargin * 2;
|
|
|
|
if Col = 1 then
|
|
|
|
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
|
|
|
Inc(Col);
|
|
|
|
RecsInCol := 0;
|
|
|
|
if DisplayOnly and (Anchor.x + TextColWidth < RenderIn.Left) then
|
|
|
|
Exit;
|
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
ra270 :
|
|
|
|
if (Anchor.x + RenderIn.Left + (WholeRect.Right - WholeRect.Left) >= RenderIn.Right - TextMargin * 3) then
|
2016-06-23 11:53:21 +00:00
|
|
|
begin
|
|
|
|
Anchor.x := 2 + TextMargin * 2;
|
|
|
|
Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3);
|
|
|
|
if Col = 1 then
|
|
|
|
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
|
|
|
|
Inc(Col);
|
|
|
|
RecsInCol := 0;
|
|
|
|
if DisplayOnly and (Anchor.y + TextColWidth <= RenderIn.Top) then
|
|
|
|
Exit;
|
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
end;
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ add a little spacing between records }
|
|
|
|
case Angle of
|
|
|
|
ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin * 2;
|
|
|
|
ra90 : WholeRect.Left := WholeRect.Left - TextMargin * 2;
|
|
|
|
ra180 : WholeRect.Top := WholeRect.Top - TextMargin * 2;
|
|
|
|
ra270 : WholeRect.Right := WholeRect.Right + TextMargin * 2;
|
|
|
|
end;
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ 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;
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ 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);
|
|
|
|
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);
|
|
|
|
ra180 : R := Rect(Anchor.X + WholeRect.Left + RenderIn.Left,
|
|
|
|
Anchor.Y - (WholeRect.Bottom - WholeRect.Top) + RenderIn.Top,
|
|
|
|
Anchor.X + TmpBmp.Width + RenderIn.Left,
|
|
|
|
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));
|
|
|
|
end;
|
|
|
|
RenderCanvas.CopyRect(R, TmpBmp.Canvas, WholeRect);
|
|
|
|
|
|
|
|
{ draw focusrect around selected record }
|
|
|
|
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then begin
|
|
|
|
with TVpContactGridOpener(FContactGrid).cgContactArray[I] do begin
|
|
|
|
R := WholeRect;
|
|
|
|
InflateRect(R, 3, 0);
|
|
|
|
OffsetRect(R, 0, -3);
|
|
|
|
RenderCanvas.DrawFocusRect(R);
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
end;
|
2016-06-23 11:53:21 +00:00
|
|
|
|
2018-06-10 16:42:16 +00:00
|
|
|
{ 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;
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
2018-06-10 16:42:16 +00:00
|
|
|
|
|
|
|
Inc(RecsInCol);
|
|
|
|
end; // for I := StartCont to ...
|
2016-06-23 11:53:21 +00:00
|
|
|
|
|
|
|
if not DisplayOnly then
|
|
|
|
case Angle of
|
|
|
|
ra0 :
|
|
|
|
with TVpContactGridOpener(FContactGrid) do
|
|
|
|
if (Anchor.X > RenderIn.Right) and (I < DataStore.Resource.Contacts.Count)
|
|
|
|
then begin
|
|
|
|
{ we have filled in the visible area }
|
2018-06-10 16:42:16 +00:00
|
|
|
FContactsAfter := contactCount - I;
|
|
|
|
FVisibleContacts := contactCount - StartContact - FContactsAfter;
|
2016-06-23 11:53:21 +00:00
|
|
|
Break;
|
|
|
|
end else begin
|
|
|
|
FContactsAfter := 0;
|
2018-06-10 16:42:16 +00:00
|
|
|
FVisibleContacts := contactCount - StartContact;
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
ra90 :
|
|
|
|
with TVpContactGridOpener(FContactGrid) do
|
2018-06-10 16:42:16 +00:00
|
|
|
if (Anchor.Y > RenderIn.Bottom) and (I < contactCount)
|
2016-06-23 11:53:21 +00:00
|
|
|
then begin
|
|
|
|
{ we have filled in the visible area }
|
2018-06-10 16:42:16 +00:00
|
|
|
FContactsAfter := contactCount - I;
|
|
|
|
FVisibleContacts := contactCount - StartContact - FContactsAfter;
|
2016-06-23 11:53:21 +00:00
|
|
|
Break;
|
|
|
|
end else begin
|
|
|
|
FContactsAfter := 0;
|
2018-06-10 16:42:16 +00:00
|
|
|
FVisibleContacts := contactCount - StartContact;
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
ra180 :
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
2018-06-10 16:42:16 +00:00
|
|
|
if (Anchor.X < RenderIn.Left) and (I < contactCount)
|
2016-06-23 11:53:21 +00:00
|
|
|
then begin
|
|
|
|
{ we have filled in the visible area }
|
2018-06-10 16:42:16 +00:00
|
|
|
FContactsAfter := contactCount - I;
|
|
|
|
FVisibleContacts := contactCount - StartContact - FContactsAfter;
|
2016-06-23 11:53:21 +00:00
|
|
|
Break;
|
|
|
|
end else
|
|
|
|
FContactsAfter := 0;
|
2018-06-10 16:42:16 +00:00
|
|
|
FVisibleContacts := contactCount - StartContact;
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
ra270 :
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
2018-06-10 16:42:16 +00:00
|
|
|
if (Anchor.Y < RenderIn.Top) and (I < contactCount)
|
2016-06-23 11:53:21 +00:00
|
|
|
then begin
|
|
|
|
{ we have filled in the visible area }
|
2018-06-10 16:42:16 +00:00
|
|
|
FContactsAfter := contactCount - I;
|
|
|
|
FVisibleContacts := contactCount - StartContact - FContactsAfter;
|
2016-06-23 11:53:21 +00:00
|
|
|
Break;
|
|
|
|
end else
|
|
|
|
FContactsAfter := 0;
|
2018-06-10 16:42:16 +00:00
|
|
|
FVisibleContacts := contactCount - StartContact;
|
2016-06-23 11:53:21 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
TmpBmp.Free;
|
|
|
|
end;
|
|
|
|
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
|
|
|
if FContactsAfter = 0 then
|
|
|
|
FLastPrintLine := -2
|
|
|
|
else
|
|
|
|
FLastPrintLine := FContactsAfter;
|
|
|
|
|
|
|
|
if (oldCol1RecCount > 0) and (cgCol1RecCount = 0) then
|
|
|
|
cgCol1RecCount := oldCol1RecCount;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpContactGridPainter.DrawVerticalBars;
|
|
|
|
var
|
|
|
|
BarPos, BarCount, I: Integer;
|
|
|
|
begin
|
|
|
|
{ if the component is sufficiently small then no sense in painting it }
|
|
|
|
if (FContactGrid.Height < 20) then exit;
|
|
|
|
|
|
|
|
{ draw vertical bars }
|
|
|
|
RenderCanvas.Pen.Color := RealBarColor;
|
|
|
|
RenderCanvas.Pen.Style := psSolid;
|
|
|
|
BarPos := RealLeft + 2 + RealColumnWidth + ExtraBarWidth;
|
|
|
|
BarCount := 0;
|
|
|
|
while (BarPos < RealRight) and (BarCount < Pred(MaxColumns)) do begin
|
|
|
|
TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Rec := Rect(
|
|
|
|
BarPos - ExtraBarWidth,
|
|
|
|
RealTop,
|
2018-06-09 09:59:39 +00:00
|
|
|
BarPos + ExtraBarWidth + FContactGrid.BarWidth,
|
2016-06-23 11:53:21 +00:00
|
|
|
RealBottom
|
|
|
|
);
|
2018-06-09 13:23:44 +00:00
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount;
|
|
|
|
for I := 1 to FContactGrid.BarWidth do begin
|
2016-09-23 13:29:12 +00:00
|
|
|
TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2);
|
|
|
|
TPSLineTo(RenderCanvas, Angle, RenderIn, BarPos, RealBottom - TextMargin * 2);
|
2016-06-23 11:53:21 +00:00
|
|
|
Inc(BarPos);
|
|
|
|
end;
|
|
|
|
Inc(BarPos, RealColumnWidth);
|
|
|
|
Inc(BarCount);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ if the columns are being resized, then draw the temporary resizing bars }
|
|
|
|
if TVpContactGridOpener(FContactGrid).cgGridState = gsColSizing then begin
|
|
|
|
{ clear sizing bar array }
|
|
|
|
for I := 0 to pred(MaxColumns) do
|
|
|
|
with TVpContactGridOpener(FContactGrid) do begin
|
|
|
|
if cgResizeBarArray[I].Index = -1 then
|
|
|
|
Break;
|
|
|
|
cgResizeBarArray[I].Rec := Rect(-1, -1, -1, -1);
|
|
|
|
cgResizeBarArray[I].Index := -1;
|
|
|
|
end;
|
|
|
|
{ draw sizing bars }
|
|
|
|
RenderCanvas.Pen.Color := SizingBarColor;
|
|
|
|
RenderCanvas.Pen.Style := psDash;
|
|
|
|
BarPos := RealLeft + 2 + TVpContactGridOpener(FContactGrid).cgNewColWidth + ExtraBarWidth;
|
|
|
|
BarCount := 0;
|
|
|
|
while (BarPos < FContactGrid.Width) and (BarCount < pred(MaxColumns)) do begin
|
|
|
|
TVpContactGridOpener(FContactGrid).cgResizeBarArray[BarCount].Index := BarCount;
|
|
|
|
TVpContactGridOpener(FContactGrid).cgResizeBarArray[BarCount].Rec := Rect(
|
|
|
|
BarPos - ExtraBarWidth,
|
|
|
|
RealTop,
|
|
|
|
BarPos - ExtraBarWidth + FContactGrid.BarWidth,
|
|
|
|
RealBottom
|
|
|
|
);
|
|
|
|
for I := 1 to FContactGrid.BarWidth do begin
|
2017-05-22 08:11:27 +00:00
|
|
|
TPSMoveTo(
|
|
|
|
RenderCanvas, Angle, RenderIn,
|
|
|
|
RealLeft + BarPos,
|
|
|
|
RealTop + 2 + TextMargin * 2
|
|
|
|
);
|
|
|
|
TPSLineTo(
|
|
|
|
RenderCanvas, Angle, RenderIn,
|
|
|
|
RealLeft + BarPos,
|
|
|
|
RealBottom - TextMargin * 2
|
|
|
|
);
|
2016-06-23 11:53:21 +00:00
|
|
|
Inc(BarPos);
|
|
|
|
end;
|
|
|
|
Inc(BarPos, TVpContactGridOpener(FContactGrid).cgNewColWidth);
|
|
|
|
Inc(BarCount);
|
|
|
|
end;
|
|
|
|
RenderCanvas.Pen.Style := psSolid;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-07-15 11:52:21 +00:00
|
|
|
procedure TVpContactGridPainter.FixFontHeights;
|
|
|
|
begin
|
2017-05-22 08:11:27 +00:00
|
|
|
{$IF VP_LCL_SCALING = 0}
|
2016-07-15 11:52:21 +00:00
|
|
|
with FContactGrid do begin
|
|
|
|
ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font);
|
|
|
|
Font.Height := GetRealFontHeight(Font);
|
|
|
|
end;
|
2017-05-22 08:11:27 +00:00
|
|
|
{$ENDIF}
|
2016-07-15 11:52:21 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
procedure TVpContactGridPainter.InitColors;
|
|
|
|
begin
|
|
|
|
if DisplayOnly then begin
|
|
|
|
RealColor := clWhite;
|
|
|
|
SizingBarColor := clBlack;
|
|
|
|
BevelDarkShadow := clBlack;
|
|
|
|
BevelShadow := clBlack;
|
|
|
|
BevelHighlight := clBlack;
|
|
|
|
BevelFace := clBlack;
|
|
|
|
RealBarColor := clBlack;
|
|
|
|
RealContactHeadAttrColor := clSilver;
|
|
|
|
end else begin
|
|
|
|
RealColor := FContactGrid.Color;
|
|
|
|
SizingBarColor := clBlack;
|
|
|
|
BevelDarkShadow := cl3dDkShadow;
|
|
|
|
BevelShadow := clBtnShadow;
|
|
|
|
BevelHighlight := clBtnHighlight;
|
|
|
|
BevelFace := clBtnFace;
|
|
|
|
RealBarColor := FContactGrid.BarColor;
|
|
|
|
RealContactHeadAttrColor := FContactGrid.ContactHeadAttributes.Color;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpContactGridPainter.RenderToCanvas(ARenderIn: TRect;
|
|
|
|
AAngle: TVpRotationAngle; AScale: Extended; ARenderDate: TDateTime;
|
|
|
|
AStartLine, AStopLine: Integer; AUseGran: TVpGranularity; ADisplayOnly: Boolean);
|
|
|
|
var
|
|
|
|
nc: Integer;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
InitColors;
|
|
|
|
SavePenBrush;
|
|
|
|
InitPenBrush;
|
2016-07-15 11:52:21 +00:00
|
|
|
if ADisplayOnly then FixFontHeights;
|
2016-07-02 22:46:05 +00:00
|
|
|
|
2016-06-23 11:53:21 +00:00
|
|
|
Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom);
|
|
|
|
try
|
|
|
|
SelectClipRgn(RenderCanvas.Handle, Rgn);
|
|
|
|
|
|
|
|
if StartLine = -1 then
|
|
|
|
StartContact := TVpContactGridOpener(FContactGrid).FContactsBefore
|
|
|
|
else
|
|
|
|
StartContact := StartLine;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
{ draw the contacts }
|
|
|
|
if StartLine <> -2 then
|
|
|
|
DrawContacts;
|
|
|
|
|
|
|
|
{ draw the vertical bars }
|
|
|
|
DrawVerticalBars;
|
|
|
|
|
|
|
|
{ draw the borders }
|
|
|
|
DrawBorders;
|
|
|
|
|
|
|
|
TVpContactGridOpener(FContactGrid).SetHScrollPos;
|
|
|
|
|
|
|
|
finally
|
|
|
|
SelectClipRgn(RenderCanvas.Handle, 0);
|
|
|
|
DeleteObject(Rgn);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ reinstate canvas settings }
|
|
|
|
RestorePenBrush;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|