From 1ff461a21f9cd32828fe106002172d18f3d1feca Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 29 Aug 2005 08:54:36 +0000 Subject: [PATCH] improved autosizing of TStringsPropertyEditorForm, implemented AnchorToCompanion Space git-svn-id: trunk@7589 - --- components/rtticontrols/rttictrls.pas | 13 ++--- ideintf/propedits.pp | 80 ++++++++++++--------------- lcl/include/control.inc | 1 + 3 files changed, 41 insertions(+), 53 deletions(-) diff --git a/components/rtticontrols/rttictrls.pas b/components/rtticontrols/rttictrls.pas index aa9ea8d680..db91275790 100644 --- a/components/rtticontrols/rttictrls.pas +++ b/components/rtticontrols/rttictrls.pas @@ -253,7 +253,7 @@ Type FCollectedValues: TAliasStrings; procedure AddValue(const s: string); virtual; public - procedure AddButtons(var x, y, BtnWidth: integer); override; + procedure AddButtons; override; end; @@ -2074,18 +2074,17 @@ begin FCollectedValues.Values[s]:=s; end; -procedure TAliasStringsPropEditorDlg.AddButtons(var x, y, BtnWidth: integer); +procedure TAliasStringsPropEditorDlg.AddButtons; begin - inherited AddButtons(x, y, BtnWidth); + inherited AddButtons; GetDefaultValuesButton := TButton.Create(Self); with GetDefaultValuesButton do Begin - Parent := Self; - dec(x,BtnWidth+8); - SetBounds(x,y,BtnWidth,Height); - Anchors:= [akRight, akBottom]; + Parent:=Self; Caption:='Get Defaults'; OnClick:=@GetDefaultValuesButtonClick; + AutoSize:=true; + AnchorToCompanion(akRight,5,SortButton); end; end; diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index b9752d5394..fda9a6a2a5 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -1367,11 +1367,11 @@ type Memo: TMemo; OKButton, CancelButton: TBitBtn; SortButton: TButton; - Bevel: TBevel; + Panel: TPanel; StatusLabel: TLabel; Editor: TPropertyEditor; constructor Create(TheOwner: TComponent); override; - procedure AddButtons(var x, y, BtnWidth: integer); virtual; + procedure AddButtons; virtual; end; //============================================================================== @@ -4551,12 +4551,6 @@ end; { TStringsPropEditorDlg } constructor TStringsPropEditorDlg.Create(TheOwner : TComponent); -var - x: Integer; - y: Integer; - MaxX: LongInt; - MaxY: LongInt; - w: Integer; begin inherited Create(TheOwner); Position := poScreenCenter; @@ -4564,72 +4558,66 @@ begin Height := 250; Caption := oisStringsEditorDialog; - Bevel:= TBevel.Create(Self); - x:=4; - y:=4; - MaxX:=Self.ClientWidth; - MaxY:=Self.ClientHeight; - with Bevel do begin - Parent:= Self; - Shape:= bsFrame; - SetBounds(x, y, MaxX-2*x, MaxY-y-34); - Anchors:= [akLeft, akTop, akRight, akBottom]; + Panel := TPanel.Create(Self); + with Panel do begin + Parent:=Self; + BorderSpacing.Around:=4; + BevelInner:=bvLowered; + Align:=alTop; end; StatusLabel:= TLabel.Create(Self); - x:=8; - y:=8; with StatusLabel do begin - Parent:= Self; - SetBounds(x,y,MaxX-2*x, Height); - Anchors:= [akLeft, akTop, akRight]; + Parent:=Panel; + Left:=7; + Top:=5; Caption:= ois0Lines0Chars; end; Memo := TMemo.Create(self); - y:=StatusLabel.Top+StatusLabel.Height; with Memo do begin - Parent:= Self; - SetBounds(x,y,MaxX-2*x,MaxY-y-38); - Anchors:= [akLeft, akTop, akRight, akBottom]; + Parent:= Panel; + Align:=alBottom; + AnchorToNeighbour(akTop,2,StatusLabel); Memo.OnChange:= @MemoChanged; end; - x:=MaxX; - y:=MaxY-30; - w:=80; - AddButtons(x,y,w); + AddButtons; + + Panel.AnchorToNeighbour(akBottom,4,OKButton); + + CancelControl:=CancelButton; + DefaultControl:=OKButton; end; -procedure TStringsPropEditorDlg.AddButtons(var x, y, BtnWidth: integer); +procedure TStringsPropEditorDlg.AddButtons; begin OKButton := TBitBtn.Create(Self); with OKButton do Begin - Parent := Self; - Kind:= bkOK; - dec(x,BtnWidth+8); - SetBounds(x,y,BtnWidth,Height); - Anchors:= [akRight, akBottom]; + Parent:=Self; + Kind:=bkOK; + AutoSize:=true; + Anchors:=[akRight,akBottom]; + AnchorParallel(akRight,4,Parent); + AnchorParallel(akBottom,4,Parent); end; CancelButton := TBitBtn.Create(Self); with CancelButton do Begin - Parent := Self; - Kind:= bkCancel; - dec(x,BtnWidth+8); - SetBounds(x,y,BtnWidth,Height); - Anchors:= [akRight, akBottom]; + Parent:=Self; + Kind:=bkCancel; + AutoSize:=true; + AnchorToCompanion(akRight,5,OKButton); end; if Assigned(ShowSortSelectionDialogFunc) then begin SortButton := TButton.Create(Self); with SortButton do Begin - Parent := Self; - dec(x,BtnWidth+8); - SetBounds(x,y,BtnWidth,Height); - Anchors:= [akRight, akBottom]; + Parent:=Self; Caption:=oisSort; OnClick:=@SortButtonClick; + AutoSize:=true; + AnchorToCompanion(akRight,5,CancelButton); end; end; end; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 98fec5f244..c5ce005b59 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -3357,6 +3357,7 @@ procedure TControl.AnchorToCompanion(Side: TAnchorKind; Space: integer; AnchorToNeighbour(ResizeSide,0,Sibling); AnchorParallel(FixedSide1,0,Sibling); AnchorParallel(FixedSide2,0,Sibling); + BorderSpacing.SetSpace(ResizeSide,Space); end; var