From 4506e97271945ce24104d8752e2ceaf60edddaac Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 23 Aug 2006 17:58:03 +0000 Subject: [PATCH] codetools: added static keyword for methods git-svn-id: trunk@9742 - --- components/codetools/keywordfunclists.pas | 1 + lcl/controls.pp | 1 + lcl/include/control.inc | 22 ++++ lcl/ldockctrl.pas | 144 ++++++++++++++++++---- lcl/ldocktree.pas | 9 +- 5 files changed, 148 insertions(+), 29 deletions(-) diff --git a/components/codetools/keywordfunclists.pas b/components/codetools/keywordfunclists.pas index 9232715909..5c309ac889 100644 --- a/components/codetools/keywordfunclists.pas +++ b/components/codetools/keywordfunclists.pas @@ -659,6 +659,7 @@ begin Add('REINTRODUCE' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('STDCALL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('VIRTUAL' ,{$ifdef FPC}@{$endif}AllwaysTrue); + Add('STATIC' ,{$ifdef FPC}@{$endif}AllwaysTrue); end; IsKeyWordProcedureSpecifier:=TKeyWordFunctionList.Create; diff --git a/lcl/controls.pp b/lcl/controls.pp index 770b5d4e09..6f2fca74de 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -1124,6 +1124,7 @@ type Sibling: TControl; FreeCompositeSide: boolean = true); procedure AnchorSame(Side: TAnchorKind; Sibling: TControl); + procedure AnchorClient(Space: Integer); function AnchoredControlCount: integer; property AnchoredControls[Index: integer]: TControl read GetAnchoredControls; procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); virtual; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index b8baa69c57..39dc972e2f 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -3699,6 +3699,28 @@ begin AnchorSide[Side].Assign(Sibling.AnchorSide[Side]); end; +procedure TControl.AnchorClient(Space: Integer); +var + a: TAnchorKind; +begin + Parent.DisableAlign; + try + BorderSpacing.Left:=Space; + BorderSpacing.Top:=Space; + BorderSpacing.Right:=Space; + BorderSpacing.Bottom:=Space; + AnchorSide[akLeft].Side:=asrLeft; + AnchorSide[akTop].Side:=asrTop; + AnchorSide[akRight].Side:=asrRight; + AnchorSide[akBottom].Side:=asrBottom; + for a:=Low(TAnchorKind) to High(TAnchorKind) do + AnchorSide[a].Control:=Parent; + Anchors:=[akLeft,akTop,akRight,akBottom]; + finally + Parent.EnableAlign; + end; +end; + function TControl.AnchoredControlCount: integer; begin if fAnchoredControls=nil then diff --git a/lcl/ldockctrl.pas b/lcl/ldockctrl.pas index b1ec28f2ca..69dedd1231 100644 --- a/lcl/ldockctrl.pas +++ b/lcl/ldockctrl.pas @@ -25,8 +25,9 @@ This unit contains visual components for docking and streaming. ToDo: - - restoring layout, when a docked control becomes visible - - restoring minimzed, maximized + - restoring layout: pages + - restoring layout: move form after inserting a control + - restoring layout: spiral splitter - save TLazDockConfigNode to stream - load TLazDockConfigNode from stream } @@ -43,7 +44,7 @@ uses type TNonDockConfigNames = ( - ndcnControlName, // '-Name ' + AControl.Name + ndcnControlName, // '-Control ' + AControl.Name ndcnChildIndex, // '-ID ' + IntToStr(AControl index in Parent) +' '+ AControl.ClassName ndcnParent // '-Parent' : AControl.Parent ); @@ -228,6 +229,7 @@ type procedure ControlVisibleChanged(Sender: TObject); function CreateFormAndDockWithSplitter(Layout: TLazDockConfigNode; Side: TAnchorKind): boolean; + function DockAsPage(Layout: TLazDockConfigNode): boolean; procedure FixControlBounds(Layout: TLazDockConfigNode; AddedControl: TControl); procedure ShrinkNeighbourhood(Layout: TLazDockConfigNode; @@ -715,10 +717,113 @@ begin Result:=true; end; +function TCustomLazControlDocker.DockAsPage(Layout: TLazDockConfigNode + ): boolean; +var + SelfNode: TLazDockConfigNode; + PageNode: TLazDockConfigNode; + PageNodeIndex: LongInt; + PagesNode: TLazDockConfigNode; + NeighbourNode: TLazDockConfigNode; + NeighbourControl: TControl; + TopForm: TLazDockForm; + Pages: TLazDockPages; + NeighbourPage: TLazDockPage; + NeighbourControlPageIndex: LongInt; + Page: TLazDockPage; + PageIndex: LongInt; +begin + Result:=false; + DebugLn(['TCustomLazControlDocker.DockAsPage DockerName="',DockerName,'"']); + SelfNode:=Layout.FindByName(DockerName,true); + if SelfNode=nil then begin + DebugLn(['TCustomLazControlDocker.DockAsPage SelfNode not found DockerName="',DockerName,'"']); + exit; + end; + PageNode:=SelfNode.Parent; + if PageNode=nil then begin + DebugLn(['TCustomLazControlDocker.DockAsPage SelfNode.Parent=nil DockerName="',DockerName,'"']); + exit; + end; + if PageNode.TheType<>ldcntPage then begin + DebugLn(['TCustomLazControlDocker.DockAsPage PageNode.TheType<>ldcntPage DockerName="',DockerName,'"']); + exit; + end; + if PageNode.ChildCount<>1 then begin + DebugLn(['TCustomLazControlDocker.DockAsPage SelfNode.Parent.TheType<>ldcntPage DockerName="',DockerName,'"']); + exit; + end; + + PagesNode:=PageNode.Parent; + PageNodeIndex:=PagesNode.IndexOf(PageNode.Name); + if PageNodeIndex>0 then + NeighbourNode:=PagesNode.Childs[PageNodeIndex-1].Childs[0] + else + NeighbourNode:=PagesNode.Childs[PageNodeIndex+1].Childs[0]; + NeighbourControl:=Manager.FindControlByDockerName(NeighbourNode.Name); + if NeighbourControl=nil then begin + DebugLn(['TCustomLazControlDocker.CreateFormAndDockWithSplitter NeighbourControl not found "',NeighbourNode.Name,'"']); + exit; + end; + + if NeighbourControl.Parent=nil then begin + // NeighbourControl is a single top level control + // => create a TLazDockForm with a TLazDockPages and two TLazDockPage + TopForm:=TLazDockForm.Create(nil); + // TODO: resize TopForm + Pages:=TLazDockPages.Create(nil); + Pages.DisableAlign; + try + Pages.Parent:=TopForm; + Pages.AnchorClient(0); + if PageNodeIndex>0 then begin + Pages.Pages.Add(NeighbourControl.Caption); + Pages.Pages.Add(Control.Caption); + NeighbourPage:=Pages.Page[0]; + Page:=Pages.Page[1]; + end else begin + Pages.Pages.Add(Control.Caption); + Pages.Pages.Add(NeighbourControl.Caption); + Page:=Pages.Page[0]; + NeighbourPage:=Pages.Page[1]; + end; + NeighbourControl.Parent:=NeighbourPage; + NeighbourControl.AnchorClient(0); + Control.Parent:=Page; + Control.AnchorClient(0); + finally + Pages.EnableAlign; + end; + end else if NeighbourControl.Parent is TLazDockPage then begin + // NeighbourControl is on a page + // => insert a new page + NeighbourPage:=TLazDockPage(NeighbourControl.Parent); + NeighbourControlPageIndex:=NeighbourPage.PageIndex; + if PageNodeIndex>0 then begin + // insert left + PageIndex:=NeighbourControlPageIndex; + end else begin + // insert right + PageIndex:=NeighbourControlPageIndex+1; + end; + Pages.Pages.Insert(PageIndex,Control.Caption); + Page:=Pages.Page[PageIndex]; + Control.Parent:=Page; + Control.AnchorClient(0); + // TODO resize parents + end else begin + // NeighbourControl is a child control, but the parent is not yet a page + // => collect all neighbour controls for a page + + // TODO + end; + + Result:=true; +end; + procedure TCustomLazControlDocker.FixControlBounds(Layout: TLazDockConfigNode; AddedControl: TControl); -{ Fix bounds after inserting AddedControl -} +{ Fix bounds after inserting AddedControl } type TControlInfo = record Control: TControl; @@ -1195,9 +1300,7 @@ begin end; procedure TCustomLazControlDocker.RestoreLayout; - { TODO - - Goals of this algorithm: +{ Goals of this algorithm: - If a form is hidden and immediately shown again, the layout should be restored 1:1. That's why a TCustomLazControlDocker stores the complete layout on every @@ -1408,6 +1511,7 @@ var SplitterCount: Integer; SideNode: TLazDockConfigNode; begin + Result:=false; SplitterCount:=0; for a:=Low(TAnchorKind) to High(TAnchorKind) do begin SideNode:=FindNode(SelfNode.Sides[a]); @@ -1422,7 +1526,14 @@ var exit(true); end; end; + end; + + function PageDocking: boolean; + begin Result:=false; + if (SelfNode.TheType<>ldcntPage) then exit; + if (SelfNode.Parent.ChildCount<>1) then exit; + Result:=DockAsPage(Layout); end; var @@ -1439,21 +1550,8 @@ begin if SelfNode.Parent<>nil then begin // this control was docked - case SelfNode.Parent.TheType of - ldcntPage: - begin - // this control was docked as child of a page - DebugLn(['TCustomLazControlDocker.RestoreLayout TODO restore page']); - end; - ldcntControl,ldcntForm: - begin - // this control was docked on a form as child - DebugLn(['TCustomLazControlDocker.RestoreLayout restore splitter']); - if SplitterDocking then exit; - end; - else - exit; - end; + if SplitterDocking then exit; + if PageDocking then exit; end; // default: do not dock, just move diff --git a/lcl/ldocktree.pas b/lcl/ldocktree.pas index 0c8b891c8a..9c58b6c7fc 100644 --- a/lcl/ldocktree.pas +++ b/lcl/ldocktree.pas @@ -1074,8 +1074,7 @@ begin DropCtl.Parent:=NewParent; // init anchors of DropCtl DropCtl.Align:=alNone; - for a:=Low(TAnchorKind) to High(TAnchorKind) do - DropCtl.AnchorParallel(a,0,DropCtl.Parent); + DropCtl.AnchorClient(0); DropCtl.Anchors:=[akLeft,akTop,akRight,akBottom]; NewParent.Visible:=true; //DebugLn('TAnchoredDockManager.DockControl DropCtl=',DbgSName(DropCtl),' NewParent.BoundsRect=',dbgs(NewParent.BoundsRect)); @@ -1207,8 +1206,7 @@ begin DropCtlPage.DisableAlign; try DropCtl.Parent:=DropCtlPage; - for a:=Low(TAnchorKind) to High(TAnchorKind) do - DropCtl.AnchorParallel(a,0,DropCtl.Parent); + DropCtl.AnchorClient(0); finally DropCtlPage.EnableAlign; end; @@ -1224,8 +1222,7 @@ begin Control.Parent:=NewPage; if Control is TCustomForm then TCustomForm(Control).WindowState:=wsNormal; - for a:=Low(TAnchorKind) to High(TAnchorKind) do - Control.AnchorParallel(a,0,Control.Parent); + Control.AnchorClient(0); finally NewPage.EnableAlign; end;