From 6deb924b134ac9f3d1bcce84cfafbb1cfd28471e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 8 Jun 2009 19:18:36 +0000 Subject: [PATCH] Fix issue #1159: Defaults editor in table editor partly hidden in bottom columns. Moves the defaults editor various calculated pixels to left and top so it fits into the client area. --- source/grideditlinks.pas | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index 67af26c7..fa93deef 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -1045,8 +1045,7 @@ begin FPanel := TPanel.Create(Tree); FPanel.Parent := FTree; - FPanel.Left := TextBounds.Left; - FPanel.Top := TextBounds.Top; + SetBounds(TextBounds); FPanel.Width := 200; FPanel.ParentBackground := False; // usefull but looks ugly: @@ -1145,9 +1144,27 @@ end; procedure TColumnDefaultEditorLink.SetBounds(R: TRect); stdcall; +var + TreeBottom, TreeRight, + PanelTop, PanelLeft: Integer; + TreeRect: TRect; begin - FPanel.Top := R.Top; - FPanel.Left := R.Left; + TreeRect := FTree.BoundsRect; + + PanelTop := R.Top; + TreeBottom := TreeRect.Bottom - TreeRect.Top - + (FTree as TVirtualStringtree).Header.Height - 20; // Column header and scrollbar + if R.Top + FPanel.Height > TreeBottom then + PanelTop := Max(0, TreeBottom - FPanel.Height); + + PanelLeft := R.Left; + TreeRight := TreeRect.Right - TreeRect.Left - 20; + mainform.LogSQL(inttostr(treeright)); + if R.Left + FPanel.Width > TreeRight then + PanelLeft := Max(0, TreeRight - FPanel.Width); + + FPanel.Top := PanelTop; + FPanel.Left := PanelLeft; end;