You've already forked lazarus-ccr
tvplanit: Improved rendering of VpContactGrid.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6481 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -183,6 +183,9 @@ type
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
procedure CreateWnd; override;
|
||||
function GetContactIndexByCoord(Pnt: TPoint): Integer;
|
||||
function GetDisplayEMail(AContact: TVpContact): String;
|
||||
function GetDisplayEMailField(AContact: TVpContact): String;
|
||||
procedure SetDisplayEMail(AContact: TVpContact; AEMail: String);
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure MouseEnter; override;
|
||||
procedure MouseLeave; override;
|
||||
@ -1331,7 +1334,7 @@ begin
|
||||
end;
|
||||
{ edit email }
|
||||
if field = 'EMail' then begin
|
||||
cgInPlaceEditor.Field := 'EMail1';
|
||||
cgInPlaceEditor.Field := GetDisplayEMailField(FActiveContact); //'EMail1';
|
||||
cgInPlaceEditor.Move(EMailRect, true);
|
||||
Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
|
||||
EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
|
||||
@ -1409,7 +1412,8 @@ begin
|
||||
{EMail}
|
||||
else if cgInPlaceEditor.field = 'EMail' then begin
|
||||
if cgInPlaceEditor.Text <> FActiveContact.EMail1 then begin
|
||||
FActiveContact.EMail1 := cgInPlaceEditor.Text;
|
||||
SetDisplayEMail(FACtiveContact, cgInplaceEditor.Text);
|
||||
// FActiveContact.EMail1 := cgInPlaceEditor.Text;
|
||||
FActiveContact.Changed := true;
|
||||
end;
|
||||
end
|
||||
@ -1819,6 +1823,39 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
function TVpContactGrid.GetDisplayEMail(AContact: TVpContact): String;
|
||||
begin
|
||||
if AContact = nil then
|
||||
Result := ''
|
||||
else begin
|
||||
Result := AContact.EMail1;
|
||||
if Result = '' then Result := AContact.EMail2;
|
||||
if Result = '' then Result := AContact.EMail3;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpContactGrid.GetDisplayEMailField(AContact: TVpContact): String;
|
||||
begin
|
||||
if (AContact.EMail1 <> '') then
|
||||
Result := 'EMail1'
|
||||
else if (AContact.EMail2 <> '') then
|
||||
Result := 'EMail2'
|
||||
else if (AContact.EMail3 <> '') then
|
||||
Result := 'EMail3'
|
||||
else
|
||||
Result := 'EMail1';
|
||||
end;
|
||||
|
||||
procedure TVpContactGrid.SetDisplayEMail(AContact: TVpContact; AEMail: String);
|
||||
begin
|
||||
if (AContact.EMail1 <> '') then
|
||||
AContact.EMail1 := AEMail
|
||||
else if (AContact.EMail2 <> '') then
|
||||
AContact.EMail2 := AEMail
|
||||
else if (AContact.EMail3 <> '') then
|
||||
AContact.EMail3 := AEMail;
|
||||
end;
|
||||
|
||||
{$IF VP_LCL_SCALING = 2}
|
||||
procedure TVpContactGrid.ScaleFontsPPI(const AToPPI: Integer;
|
||||
const AProportion: Double);
|
||||
|
@ -236,6 +236,7 @@ var
|
||||
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);
|
||||
R: TRect;
|
||||
begin
|
||||
oldCol1RecCount := TVpContactGridOpener(FContactGrid).cgCol1RecCount;
|
||||
TVpContactGridOpener(FContactGrid).FVisibleContacts := 0;
|
||||
@ -257,11 +258,11 @@ begin
|
||||
TmpBmp := TBitmap.Create;
|
||||
try
|
||||
if (Angle = ra0) or (Angle = ra180) then begin
|
||||
TmpBmp.Width := RealColumnWidth - TextMargin * 4;
|
||||
TmpBmp.Width := RealColumnWidth - TextMargin * 4 + 4; // wp:+4
|
||||
TmpBmp.Height := RealHeight - TextMargin * 2;
|
||||
TextColWidth := TmpBmp.Width;
|
||||
end else begin
|
||||
TmpBmp.Height := RealColumnWidth - TextMargin * 4;
|
||||
TmpBmp.Height := RealColumnWidth - TextMargin * 4 + 4; // wp: +4
|
||||
TmpBmp.Width := RealHeight - TextMargin * 2;
|
||||
TextColWidth := TmpBmp.Height;
|
||||
end;
|
||||
@ -323,18 +324,22 @@ begin
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then
|
||||
TmpBmp.Canvas.Font.Style := [fsBold];
|
||||
case Angle of
|
||||
ra0:
|
||||
begin
|
||||
WholeRect.TopLeft := Point(0, 0);
|
||||
HeadRect.TopLeft := Point(TextMargin, 0);
|
||||
// HeadRect.TopLeft := Point(TextMargin, TextMargin div 2);
|
||||
// HeadRect.TopLeft := Point(TextMargin, 0);
|
||||
HeadRect.TopLeft := Point(0, 0);
|
||||
HeadRect.BottomRight := Point(
|
||||
TmpBmp.Width,
|
||||
HeadRect.Top + TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2
|
||||
);
|
||||
WholeRect.BottomRight := HeadRect.BottomRight;
|
||||
end;
|
||||
ra90:
|
||||
ra90: // TO DO: CHECK THE USAGE OF TextMargin HERE !!!!!!!!!
|
||||
begin
|
||||
HeadRect.TopLeft := Point(
|
||||
TmpBmpRect.Right - TextMargin - TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2,
|
||||
@ -458,7 +463,8 @@ begin
|
||||
DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect);
|
||||
|
||||
{ do EMail }
|
||||
DrawContactLine(TmpBmp, TmpCon.EMail1, RSEmail + ': ', WholeRect, EMailRect);
|
||||
Str := TVpContactGridOpener(FContactGrid).GetDisplayEMail(TmpCon);
|
||||
DrawContactLine(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 }
|
||||
@ -525,7 +531,7 @@ begin
|
||||
|
||||
{ add a little spacing between records }
|
||||
case Angle of
|
||||
ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin * 2;
|
||||
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;
|
||||
@ -626,9 +632,16 @@ begin
|
||||
|
||||
{ draw focusrect around selected record }
|
||||
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then begin
|
||||
with TVpContactGridOpener(FContactGrid).cgContactArray[I] do
|
||||
with TVpContactGridOpener(FContactGrid).cgContactArray[I] do begin
|
||||
R := WholeRect;
|
||||
InflateRect(R, 3, 3);
|
||||
dec(R.Bottom, 2*3);
|
||||
RenderCanvas.DrawFocusRect(R);
|
||||
{
|
||||
RenderCanvas.DrawFocusRect(Rect(WholeRect.Left, WholeRect.Top - 3,
|
||||
WholeRect.Right + TextMargin, WholeRect.Bottom - 2));
|
||||
}
|
||||
end;
|
||||
end;
|
||||
|
||||
{ slide anchor down for the next record }
|
||||
@ -728,6 +741,7 @@ begin
|
||||
BarPos + ExtraBarWidth + FContactGrid.BarWidth,
|
||||
RealBottom
|
||||
);
|
||||
|
||||
TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount;
|
||||
for I := 1 to FContactGrid.BarWidth do begin
|
||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2);
|
||||
|
Reference in New Issue
Block a user