* Allow resize of elements relative to parent

git-svn-id: trunk@57471 -
This commit is contained in:
michael 2018-03-08 17:31:08 +00:00
parent f2b05a03f8
commit 25b06d4f2e
4 changed files with 57 additions and 13 deletions

View File

@ -31,7 +31,7 @@ Type
TSelectionSort = (ssNone,ssHorz,ssvert);
THAlignAction = (haNone,haLeft,haCenter,haRight,haSpace,haCentB);
TVAlignAction = (vaNone,vaTop,vaCenter,vaBottom,vaSpace,vaCentB);
TSizeAdjust = (saNone,saLargest,saSmallest,saValue);
TSizeAdjust = (saNone,saLargest,saSmallest,saValue,saParent);
TFrameAction = (faNone,faAll,faTop,faBottom,faLeft,faRight);
TResizeHandlePosition = (rhNone,rhTopLeft,rhTop,rhTopRight,rhLeft,rhRight,rhBottomLeft, rhBottom,rhBottomRight);
TResizeHandlePositions = set of TResizeHandlePosition;
@ -515,6 +515,24 @@ begin
For I:=0 to Length(Arr)-1 do
With Arr[i].Element.Layout do
begin
// For saParent, we determine the actual height/width here
// The parent can be different..
if AHeight=saParent then
begin
Top:=0.0;
if Assigned(Arr[i].Element.Parent) then
HSize:=Arr[i].Element.Parent.Layout.Height
else
HSize:=Arr[i].Element.Layout.Height
end;
if AWidth=saParent then
begin
Left:=0.0;
if Assigned(Arr[i].Element.Parent) then
WSize:=Arr[i].Element.Parent.Layout.Width
else
WSize:=Arr[i].Element.Layout.Width
end;
If (aHeight<>saNone) then
Height:=HSize;
If aWidth<>saNone then

View File

@ -1,17 +1,17 @@
object ResizeElementsForm: TResizeElementsForm
Left = 728
Height = 280
Height = 328
Top = 319
Width = 455
Caption = 'Resize selected elements'
ClientHeight = 280
ClientHeight = 328
ClientWidth = 455
Position = poOwnerFormCenter
LCLVersion = '1.9.0.0'
object BPResize: TButtonPanel
Left = 6
Height = 42
Top = 232
Top = 280
Width = 443
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -26,11 +26,11 @@ object ResizeElementsForm: TResizeElementsForm
end
object GBHorizontal: TGroupBox
Left = 8
Height = 219
Height = 256
Top = 8
Width = 184
Caption = 'Horizontal'
ClientHeight = 201
ClientHeight = 238
ClientWidth = 182
TabOrder = 1
object RBHNone: TRadioButton
@ -39,10 +39,8 @@ object ResizeElementsForm: TResizeElementsForm
Top = 12
Width = 54
Caption = 'None'
Checked = True
OnClick = RBHFixedClick
TabOrder = 0
TabStop = True
end
object RBHSmallest: TRadioButton
Left = 18
@ -82,14 +80,25 @@ object ResizeElementsForm: TResizeElementsForm
TabOrder = 4
Value = 1
end
object RBHParentSize: TRadioButton
Left = 18
Height = 22
Top = 208
Width = 86
Caption = 'Parent size'
Checked = True
OnClick = RBHFixedClick
TabOrder = 5
TabStop = True
end
end
object GBVertical: TGroupBox
Left = 208
Height = 219
Height = 248
Top = 8
Width = 176
Caption = 'Vertical'
ClientHeight = 201
ClientHeight = 230
ClientWidth = 174
TabOrder = 2
object RBVNone: TRadioButton
@ -98,10 +107,8 @@ object ResizeElementsForm: TResizeElementsForm
Top = 12
Width = 54
Caption = 'None'
Checked = True
OnClick = RBVNoneClick
TabOrder = 0
TabStop = True
end
object RBVSmallest: TRadioButton
Left = 18
@ -141,5 +148,16 @@ object ResizeElementsForm: TResizeElementsForm
TabOrder = 4
Value = 1
end
object RBVParentSize: TRadioButton
Left = 18
Height = 22
Top = 208
Width = 86
Caption = 'Parent size'
Checked = True
OnClick = RBHFixedClick
TabOrder = 5
TabStop = True
end
end
end

View File

@ -33,8 +33,10 @@ type
FSEVertical: TFloatSpinEdit;
GBHorizontal: TGroupBox;
GBVertical: TGroupBox;
RBHParentSize: TRadioButton;
RBHNone: TRadioButton;
RBHFixed: TRadioButton;
RBVParentSize: TRadioButton;
RBVNone: TRadioButton;
RBVFixed: TRadioButton;
RBVLargest: TRadioButton;
@ -84,6 +86,8 @@ begin
Result:=saLargest
else if RBHFixed.Checked then
Result:=saValue
else if RBHParentSize.Checked then
Result:=saParent
else
Result:=saNone;
end;
@ -101,6 +105,8 @@ begin
Result:=saLargest
else if RBVFixed.Checked then
Result:=saValue
else if RBVParentSize.Checked then
Result:=saParent
else
Result:=saNone;
end;
@ -116,6 +122,7 @@ begin
saLargest : RBHLargest.Checked:=True;
saSmallest : RBHSmallest.Checked:=True;
saValue : RBHFixed.Checked:=True;
saParent : RBHParentSize.Checked:=True;
else
RBHNone.Checked:=True;
end;
@ -132,6 +139,7 @@ begin
saLargest : RBVLargest.Checked:=True;
saSmallest : RBVSmallest.Checked:=True;
saValue : RBVFixed.Checked:=True;
saParent : RBVParentSize.Checked:=True;
else
RBVNone.Checked:=True;
end;

View File

@ -1255,7 +1255,7 @@ end;
procedure TFPReportDesignerForm.AResizeUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner) and CurrentDesigner.Objects.IsMultiSelect;
(Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner);
end;
procedure TFPReportDesignerForm.HResizeAllow(Sender: TObject);