improved autosizing of TStringsPropertyEditorForm, implemented AnchorToCompanion Space

git-svn-id: trunk@7589 -
This commit is contained in:
mattias 2005-08-29 08:54:36 +00:00
parent 3c4dee55f9
commit 1ff461a21f
3 changed files with 41 additions and 53 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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