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:
wp_xxyyzz
2018-06-09 13:23:44 +00:00
parent ad07af3511
commit 2c923b154e
2 changed files with 60 additions and 9 deletions

View File

@ -183,6 +183,9 @@ type
procedure CreateParams(var Params: TCreateParams); override; procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override; procedure CreateWnd; override;
function GetContactIndexByCoord(Pnt: TPoint): Integer; 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 KeyDown(var Key: Word; Shift: TShiftState); override;
procedure MouseEnter; override; procedure MouseEnter; override;
procedure MouseLeave; override; procedure MouseLeave; override;
@ -1331,7 +1334,7 @@ begin
end; end;
{ edit email } { edit email }
if field = 'EMail' then begin if field = 'EMail' then begin
cgInPlaceEditor.Field := 'EMail1'; cgInPlaceEditor.Field := GetDisplayEMailField(FActiveContact); //'EMail1';
cgInPlaceEditor.Move(EMailRect, true); cgInPlaceEditor.Move(EMailRect, true);
Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin, Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3)); EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
@ -1409,7 +1412,8 @@ begin
{EMail} {EMail}
else if cgInPlaceEditor.field = 'EMail' then begin else if cgInPlaceEditor.field = 'EMail' then begin
if cgInPlaceEditor.Text <> FActiveContact.EMail1 then begin if cgInPlaceEditor.Text <> FActiveContact.EMail1 then begin
FActiveContact.EMail1 := cgInPlaceEditor.Text; SetDisplayEMail(FACtiveContact, cgInplaceEditor.Text);
// FActiveContact.EMail1 := cgInPlaceEditor.Text;
FActiveContact.Changed := true; FActiveContact.Changed := true;
end; end;
end end
@ -1819,6 +1823,39 @@ begin
Invalidate; Invalidate;
end; 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} {$IF VP_LCL_SCALING = 2}
procedure TVpContactGrid.ScaleFontsPPI(const AToPPI: Integer; procedure TVpContactGrid.ScaleFontsPPI(const AToPPI: Integer;
const AProportion: Double); const AProportion: Double);

View File

@ -236,6 +236,7 @@ var
Phone3Rect: 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); Phone4Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
Phone5Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0); Phone5Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
R: TRect;
begin begin
oldCol1RecCount := TVpContactGridOpener(FContactGrid).cgCol1RecCount; oldCol1RecCount := TVpContactGridOpener(FContactGrid).cgCol1RecCount;
TVpContactGridOpener(FContactGrid).FVisibleContacts := 0; TVpContactGridOpener(FContactGrid).FVisibleContacts := 0;
@ -257,11 +258,11 @@ begin
TmpBmp := TBitmap.Create; TmpBmp := TBitmap.Create;
try try
if (Angle = ra0) or (Angle = ra180) then begin 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; TmpBmp.Height := RealHeight - TextMargin * 2;
TextColWidth := TmpBmp.Width; TextColWidth := TmpBmp.Width;
end else begin end else begin
TmpBmp.Height := RealColumnWidth - TextMargin * 4; TmpBmp.Height := RealColumnWidth - TextMargin * 4 + 4; // wp: +4
TmpBmp.Width := RealHeight - TextMargin * 2; TmpBmp.Width := RealHeight - TextMargin * 2;
TextColWidth := TmpBmp.Height; TextColWidth := TmpBmp.Height;
end; end;
@ -323,18 +324,22 @@ begin
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI); TmpBmp.Canvas.Font.Size := ScaleY(TmpBmp.Canvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then
TmpBmp.Canvas.Font.Style := [fsBold];
case Angle of case Angle of
ra0: ra0:
begin begin
WholeRect.TopLeft := Point(0, 0); 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( HeadRect.BottomRight := Point(
TmpBmp.Width, TmpBmp.Width,
HeadRect.Top + TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2 HeadRect.Top + TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2
); );
WholeRect.BottomRight := HeadRect.BottomRight; WholeRect.BottomRight := HeadRect.BottomRight;
end; end;
ra90: ra90: // TO DO: CHECK THE USAGE OF TextMargin HERE !!!!!!!!!
begin begin
HeadRect.TopLeft := Point( HeadRect.TopLeft := Point(
TmpBmpRect.Right - TextMargin - TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2, TmpBmpRect.Right - TextMargin - TmpBmp.Canvas.TextHeight(VpProductName) + TextMargin div 2,
@ -458,7 +463,8 @@ begin
DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect); DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect);
{ do EMail } { 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 } { 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 } { column, then slide over to the top of the next column }
@ -525,7 +531,7 @@ begin
{ add a little spacing between records } { add a little spacing between records }
case Angle of case Angle of
ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin * 2; ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin; // * 2;
ra90 : WholeRect.Left := WholeRect.Left - TextMargin * 2; ra90 : WholeRect.Left := WholeRect.Left - TextMargin * 2;
ra180 : WholeRect.Top := WholeRect.Top - TextMargin * 2; ra180 : WholeRect.Top := WholeRect.Top - TextMargin * 2;
ra270 : WholeRect.Right := WholeRect.Right + TextMargin * 2; ra270 : WholeRect.Right := WholeRect.Right + TextMargin * 2;
@ -626,9 +632,16 @@ begin
{ draw focusrect around selected record } { draw focusrect around selected record }
if FContactGrid.Focused and (TmpCon = FContactGrid.ActiveContact) then begin 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, RenderCanvas.DrawFocusRect(Rect(WholeRect.Left, WholeRect.Top - 3,
WholeRect.Right + TextMargin, WholeRect.Bottom - 2)); WholeRect.Right + TextMargin, WholeRect.Bottom - 2));
}
end;
end; end;
{ slide anchor down for the next record } { slide anchor down for the next record }
@ -728,6 +741,7 @@ begin
BarPos + ExtraBarWidth + FContactGrid.BarWidth, BarPos + ExtraBarWidth + FContactGrid.BarWidth,
RealBottom RealBottom
); );
TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount; TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount;
for I := 1 to FContactGrid.BarWidth do begin for I := 1 to FContactGrid.BarWidth do begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2); TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2);