You've already forked lazarus-ccr
tvplanit: Improved positioning of VpContactGrid inplace editor.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6483 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -426,6 +426,7 @@ object MainForm: TMainForm
|
||||
Width = 794
|
||||
ControlLink = VpControlLink1
|
||||
Color = clWindow
|
||||
ParentFont = False
|
||||
Align = alClient
|
||||
TabStop = True
|
||||
TabOrder = 1
|
||||
|
@ -168,7 +168,7 @@ type
|
||||
procedure SetColor(Value: TColor); reintroduce;
|
||||
procedure SetHScrollPos;
|
||||
procedure SetPrintNumColumns(const v: Integer);
|
||||
procedure SetSortBy (const v : TVpContactSort);
|
||||
procedure SetSortBy(const Value: TVpContactSort);
|
||||
procedure SetDataStore(const Value: TVpCustomDataStore); override;
|
||||
|
||||
{ internal methods }
|
||||
@ -353,7 +353,7 @@ begin
|
||||
inherited Create(AOwner);
|
||||
field := '';
|
||||
TabStop := False;
|
||||
BorderStyle := bsNone;
|
||||
//BorderStyle := bsNone;
|
||||
{$IFDEF VERSION4}
|
||||
// DoubleBuffered := False;
|
||||
{$ENDIF}
|
||||
@ -363,27 +363,17 @@ begin
|
||||
end;
|
||||
|
||||
procedure TVpCGInPlaceEdit.Move(const Loc: TRect; Redraw: Boolean);
|
||||
var
|
||||
Margin: Integer;
|
||||
const
|
||||
dy = 2;
|
||||
begin
|
||||
CreateHandle;
|
||||
Redraw := Redraw or not IsWindowVisible(Handle);
|
||||
Invalidate;
|
||||
with Loc do begin
|
||||
Margin := 0;
|
||||
if (Field = 'Address') or (Field = 'Company') or (Field ='CSZ') then
|
||||
Margin := TextMargin * 2;
|
||||
{$IFDEF LCL}
|
||||
SetBounds(
|
||||
Left + Margin,
|
||||
Top + TextMargin div 2,
|
||||
Right - Left - TextMargin * 2,
|
||||
Bottom - Top
|
||||
);
|
||||
SetBounds(Left, Top-dy, Right-Left, Bottom - Top);
|
||||
{$ELSE}
|
||||
SetWindowPos(Handle, HWND_TOP, Left + Margin,
|
||||
Top + (TextMargin div 2), Right - Left - TextMargin * 2, Bottom - Top,
|
||||
SWP_NOREDRAW);
|
||||
SetWindowPos(Handle, HWND_TOP, Left, Top-dy, Right-Left, Bottom-Top, SWP_NOREDRAW);
|
||||
{$ENDIF}
|
||||
end;
|
||||
if Redraw then Invalidate;
|
||||
@ -889,7 +879,7 @@ procedure TVpContactGrid.SetContactIndex(Value: Integer);
|
||||
begin
|
||||
FContactIndex := Value;
|
||||
if (DataStore <> nil) and (DataStore.Resource <> nil) then
|
||||
FActiveContact := DataStore.Resource.Contacts.GetContact(Value)
|
||||
FActiveContact := DataStore.Resource.Contacts.GetContact(FContactIndex)
|
||||
else
|
||||
FContactIndex := -1;
|
||||
end;
|
||||
@ -1311,24 +1301,30 @@ begin
|
||||
if field = 'Address' then begin
|
||||
cgInPlaceEditor.Field := 'Address1';
|
||||
cgInPlaceEditor.Move(AddressRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(AddressRect.Left + TextMargin - 1,
|
||||
AddressRect.Top, AddressRect.Right + 3, AddressRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.Address1;
|
||||
end;
|
||||
{ edit company }
|
||||
if field = 'Company' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(CompanyRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(CompanyRect.Left + TextMargin - 1,
|
||||
CompanyRect.Top, CompanyRect.Right + 3, CompanyRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.Company;
|
||||
end;
|
||||
{ edit CSZ }
|
||||
if field = 'CSZ' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(CSZRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(CSZRect.Left + TextMargin - 1,
|
||||
CSZRect.Top, CSZRect.Right + 3, CSZRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.City1 + ', ' + FActiveContact.State1
|
||||
+ ' ' + FActiveContact.Zip1;
|
||||
end;
|
||||
@ -1336,48 +1332,56 @@ begin
|
||||
if field = 'EMail' then begin
|
||||
cgInPlaceEditor.Field := GetDisplayEMailField(FActiveContact); //'EMail1';
|
||||
cgInPlaceEditor.Move(EMailRect, true);
|
||||
Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
|
||||
EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
|
||||
cgInPlaceEditor.Text := FActiveContact.EMail1;
|
||||
{
|
||||
Canvas.DrawFocusRect(EMailRect);
|
||||
// Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
|
||||
// EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := GetDisplayEMail(FActiveContact); //FActiveContact.EMail1;
|
||||
end;
|
||||
{ edit Phone1 }
|
||||
if field = 'Phone1' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone1Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone1Rect.Left - TextMargin,
|
||||
Phone1Rect.Top, Phone1Rect.Right + 3, Phone1Rect.Bottom + 3));
|
||||
Phone1Rect.Top, Phone1Rect.Right + 3, Phone1Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone1;
|
||||
end;
|
||||
{ edit Phone2 }
|
||||
if field = 'Phone2' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone2Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone2Rect.Left - TextMargin,
|
||||
Phone2Rect.Top, Phone2Rect.Right + 3, Phone2Rect.Bottom + 3));
|
||||
Phone2Rect.Top, Phone2Rect.Right + 3, Phone2Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone2;
|
||||
end;
|
||||
{ edit Phone3 }
|
||||
if field = 'Phone3' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone3Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone3Rect.Left - TextMargin,
|
||||
Phone3Rect.Top, Phone3Rect.Right + 3, Phone3Rect.Bottom + 3));
|
||||
Phone3Rect.Top, Phone3Rect.Right + 3, Phone3Rect.Bottom + 3)); }
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone3;
|
||||
end;
|
||||
{ edit Phone4 }
|
||||
if field = 'Phone4' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone4Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone4Rect.Left - TextMargin ,
|
||||
Phone4Rect.Top, Phone4Rect.Right + 3, Phone4Rect.Bottom + 3));
|
||||
Phone4Rect.Top, Phone4Rect.Right + 3, Phone4Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone4;
|
||||
end;
|
||||
{ edit Phone5 }
|
||||
if field = 'Phone5' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone5Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone5Rect.Left - TextMargin,
|
||||
Phone5Rect.Top, Phone5Rect.Right + 3, Phone5Rect.Bottom + 3));
|
||||
Phone5Rect.Top, Phone5Rect.Right + 3, Phone5Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone5;
|
||||
end;
|
||||
end;
|
||||
@ -1614,11 +1618,17 @@ begin
|
||||
if ContactIndex < Pred(DataStore.Resource.Contacts.Count) then
|
||||
ContactIndex := ContactIndex + 1;
|
||||
VK_HOME :
|
||||
ContactIndex := 0;
|
||||
{
|
||||
if ContactIndex > 0 then
|
||||
ContactIndex := ContactIndex - 1;
|
||||
}
|
||||
VK_END :
|
||||
ContactIndex := Pred(Datastore.Resource.Contacts.Count);
|
||||
{
|
||||
if ContactIndex < Pred(DataStore.Resource.Contacts.Count) then
|
||||
ContactIndex := ContactIndex + 1;
|
||||
}
|
||||
VK_RIGHT :
|
||||
if ContactIndex + cgCol1RecCount <= Pred(DataStore.Resource.Contacts.Count) then
|
||||
ContactIndex := ContactIndex + cgCol1RecCount
|
||||
@ -1639,16 +1649,14 @@ begin
|
||||
Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True));
|
||||
{$ENDIF}
|
||||
VK_F10 :
|
||||
if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin
|
||||
if (ssShift in Shift) and not Assigned(PopupMenu) then begin
|
||||
PopupPoint := GetClientOrigin;
|
||||
FDefaultPopup.Popup (PopupPoint.x + 10,
|
||||
PopupPoint.y + 10);
|
||||
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
||||
end;
|
||||
VK_APPS :
|
||||
if not Assigned(PopupMenu) then begin
|
||||
PopupPoint := GetClientOrigin;
|
||||
FDefaultPopup.Popup (PopupPoint.x + 10,
|
||||
PopupPoint.y + 10);
|
||||
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
||||
end;
|
||||
end;
|
||||
Invalidate;
|
||||
@ -1774,10 +1782,10 @@ begin
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpContactGrid.SetSortBy (const v : TVpContactSort);
|
||||
procedure TVpContactGrid.SetSortBy(const Value: TVpContactSort);
|
||||
begin
|
||||
if v <> FSortBy then begin
|
||||
FSortBy := v;
|
||||
if Value <> FSortBy then begin
|
||||
FSortBy := Value;
|
||||
if not Assigned(DataStore) then
|
||||
Exit;
|
||||
if not Assigned(DataStore.Resource) then
|
||||
@ -1812,7 +1820,7 @@ begin
|
||||
if PointInRect(Pnt, cgContactArray[I].WholeRect) then begin
|
||||
{ Set ActiveContact to the selected one }
|
||||
FContactIndex := I;
|
||||
FActiveContact := TVpCOntact(cgContactArray[I].Contact);
|
||||
FActiveContact := TVpContact(cgContactArray[I].Contact);
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
@ -531,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;
|
||||
@ -539,6 +539,19 @@ begin
|
||||
|
||||
{ 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);
|
||||
(*
|
||||
|
||||
cgContactArray[I].WholeRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + WholeRect.Top);
|
||||
cgContactArray[I].WholeRect.BottomRight := Point(
|
||||
@ -593,6 +606,7 @@ begin
|
||||
Anchor.X + Phone5Rect.Left, Anchor.Y + Phone5Rect.Top);
|
||||
cgContactArray[I].Phone5Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone5Rect.Bottom);
|
||||
*)
|
||||
end;
|
||||
|
||||
{ move the drawn record from the bitmap to the component canvas }
|
||||
|
@ -103,6 +103,9 @@ function RightOf(AControl: TControl): Integer;
|
||||
function BottomOf(AControl: TControl): Integer;
|
||||
{- returns the bottom edge of a control }
|
||||
|
||||
function MoveRect(const ARect: TRect; const ADelta: TPoint): TRect;
|
||||
{ - moves ARect by dx in ADelta.x and dy in ADelta.y direction }
|
||||
|
||||
function GetDisplayString(Canvas : TCanvas; const S : string;
|
||||
MinChars, MaxWidth : Integer) : string;
|
||||
{ given a string, a minimum number of chars to display, and a max width,
|
||||
@ -858,6 +861,13 @@ begin
|
||||
Result := AControl.Top + AControl.Height;
|
||||
end;
|
||||
|
||||
{ Moves a rectangle ARect by ADelta.x in x, and by ADelta.y in y direction }
|
||||
function MoveRect(const ARect: TRect; const ADelta: TPoint): TRect;
|
||||
begin
|
||||
Result := ARect;
|
||||
OffsetRect(Result, ADelta.x, ADelta.y);
|
||||
end;
|
||||
|
||||
{ Replaces embedded C-style line endings (\n) by FPC line endings (#13#10, #13,
|
||||
#10, depending on system) }
|
||||
function DecodeLineEndings(const AText: String): String;
|
||||
|
Reference in New Issue
Block a user