* Allow aligning to top/bottom left/right of band

git-svn-id: trunk@57477 -
This commit is contained in:
michael 2018-03-09 07:53:48 +00:00
parent 8c4f984d95
commit cf76a5378c
4 changed files with 52 additions and 32 deletions

View File

@ -29,8 +29,8 @@ Const
Type
TSelectionSort = (ssNone,ssHorz,ssvert);
THAlignAction = (haNone,haLeft,haCenter,haRight,haSpace,haCentB);
TVAlignAction = (vaNone,vaTop,vaCenter,vaBottom,vaSpace,vaCentB);
THAlignAction = (haNone,haLeft,haCenter,haRight,haSpace,haCentB,haLeftB,haRightB);
TVAlignAction = (vaNone,vaTop,vaCenter,vaBottom,vaSpace,vaCentB,vaTopB,vaBottomB);
TSizeAdjust = (saNone,saLargest,saSmallest,saValue,saParent);
TFrameAction = (faNone,faAll,faTop,faBottom,faLeft,faRight);
TResizeHandlePosition = (rhNone,rhTopLeft,rhTop,rhTopRight,rhLeft,rhRight,rhBottomLeft, rhBottom,rhBottomRight);
@ -1435,42 +1435,50 @@ Var
Procedure AlignControl (El : TFPReportElement; Hor : THAlignAction; Ver : TValignAction; IsBorder : Boolean);
Var
NewRect : TFPReportRect;
BHCenter,BVCenter : TFPReportUnits;
ElRect : TFPReportRect;
BW,BH,BHCenter,BVCenter : TFPReportUnits;
HOffset,VOffset : TFPReportUnits;
begin
BW:=0;
BH:=0;
BHCenter:=0;
BVCenter:=0;
El.Layout.GetBoundsRect(NewRect);
El.Layout.GetBoundsRect(ElRect);
if Assigned(EL.Parent) then
With EL.Parent.Layout Do
begin
BHCenter:=Width / 2;
BVCenter:=Height / 2;
BW:=Width;
BH:=Height;
BHCenter:=BW / 2;
BVCenter:=BH / 2;
end;
HOffset:=0;
VOffset:=0;
Case hor of
haleft : HOffset:=OutLineRect.Left-NewRect.Left;
haRight : HOffset:=OutLineRect.Right-NewRect.Right;
haCenter : HOffset:=HCenter-(Newrect.Right+NewRect.Left) / 2;
haCentB : HOffset:=BHCenter-(NewRect.Right+NewRect.Left) / 2;
haleft : HOffset:=OutLineRect.Left-ElRect.Left;
haRight : HOffset:=OutLineRect.Right-ElRect.Right;
haCenter : HOffset:=HCenter-(ElRect.Right+ElRect.Left) / 2;
haCentB : HOffset:=BHCenter-(ElRect.Right+ElRect.Left) / 2;
haLeftB : HOffset:=-ElRect.Left;
haRightB : HOffset:=BW-EL.Layout.Width-ElRect.Left;
haSpace : If Not IsBorder Then
HOffset:=HSCenter-(Newrect.Right+NewRect.Left) / 2;
HOffset:=HSCenter-(ElRect.Right+ElRect.Left) / 2;
end;
Case Ver of
vaTop : VOffset:=OutLineRect.Top-NewRect.Top;
vaBottom : VOffset:=OutLineRect.Bottom-NewRect.Bottom;
vaCenter : VOffset:=VCenter-(Newrect.Bottom+NewRect.Top) / 2;
vaCentB : VOffSet:=BVCenter-(NewRect.Bottom+NewRect.Top) / 2;
vaTop : VOffset:=OutLineRect.Top-ElRect.Top;
vaBottom : VOffset:=OutLineRect.Bottom-ElRect.Bottom;
vaCenter : VOffset:=VCenter-(ElRect.Bottom+ElRect.Top) / 2;
vaCentB : VOffSet:=BVCenter-(ElRect.Bottom+ElRect.Top) / 2;
vatopB : VOffset:=-ElRect.Top;
vaBottomB : VOffset:=BH-EL.Layout.Height-ElRect.Top;
vaSpace : If Not IsBorder Then
VOffset:=VSCenter-(Newrect.Bottom+NewRect.Top) / 2;
VOffset:=VSCenter-(ElRect.Bottom+ElRect.Top) / 2;
end;
// Go back Relative to the band..
NewRect.OffsetRect(HOffset,VOffset);
EL.Layout.Left:=NewRect.Left;
EL.Layout.Top:=NewRect.Top;
ElRect.OffsetRect(HOffset,VOffset);
EL.Layout.Left:=ElRect.Left;
EL.Layout.Top:=ElRect.Top;
end;
@ -1548,6 +1556,7 @@ begin
end;
end;
end;
SelectRectInvalid;
ReportChanged;
end;

View File

@ -1,18 +1,18 @@
object AlignForm: TAlignForm
Left = 575
Height = 255
Height = 328
Top = 168
Width = 437
BorderStyle = bsDialog
Caption = 'Align selected elements'
ClientHeight = 255
ClientHeight = 328
ClientWidth = 437
Position = poOwnerFormCenter
LCLVersion = '1.9.0.0'
object BPAlign: TButtonPanel
Left = 6
Height = 42
Top = 207
Top = 280
Width = 425
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -27,7 +27,7 @@ object AlignForm: TAlignForm
end
object RGHorizontal: TRadioGroup
Left = 16
Height = 168
Height = 232
Top = 16
Width = 185
AutoFill = True
@ -39,7 +39,7 @@ object AlignForm: TAlignForm
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 150
ClientHeight = 214
ClientWidth = 183
Items.Strings = (
'No action'
@ -48,12 +48,14 @@ object AlignForm: TAlignForm
'Align right edges'
'Space equally'
'Center on parent band'
'Flush left on parent band'
'Flush right on parent band'
)
TabOrder = 1
end
object RGVertical: TRadioGroup
Left = 224
Height = 168
Height = 232
Top = 16
Width = 193
AutoFill = True
@ -65,7 +67,7 @@ object AlignForm: TAlignForm
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 150
ClientHeight = 214
ClientWidth = 191
Items.Strings = (
'No action'
@ -74,7 +76,10 @@ object AlignForm: TAlignForm
'Align bottom edges'
'Space equally'
'Center on parent band'
'Flush top on parent band'
'Flush bottom on parent band'
)
OnClick = RGVerticalClick
TabOrder = 2
end
end

View File

@ -30,6 +30,7 @@ type
BPAlign: TButtonPanel;
RGHorizontal: TRadioGroup;
RGVertical: TRadioGroup;
procedure RGVerticalClick(Sender: TObject);
protected
function GetH: THAlignAction; override;
function GetV: TVAlignAction; override;
@ -49,6 +50,11 @@ implementation
{ TAlignForm }
procedure TAlignForm.RGVerticalClick(Sender: TObject);
begin
end;
function TAlignForm.GetH: THAlignAction;
begin
if (RGHorizontal.ItemIndex=-1) then

View File

@ -612,7 +612,7 @@ begin
FOI.UpdateSelection
else
FOI.SelectControls(D.Objects);
if D.Objects.SelectionCount>0 then
if D.Objects.HaveSelection then
S:=D.Objects.GetSelectionRect.AsString
else
S:=SNoSelection;
@ -871,7 +871,7 @@ procedure TFPReportDesignerForm.AAlignUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(ReportAlignFormClass)
and Assigned(CurrentDesigner)
and CurrentDesigner.Objects.IsMultiSelect;
and CurrentDesigner.Objects.HaveSelection
end;
procedure TFPReportDesignerForm.ADeleteExecute(Sender: TObject);
@ -888,7 +888,7 @@ end;
procedure TFPReportDesignerForm.ADeleteUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and (CurrentDesigner.Objects.SelectionCount>0);
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and CurrentDesigner.Objects.HaveSelection;
end;
procedure TFPReportDesignerForm.AFileSaveAsExecute(Sender: TObject);
@ -925,7 +925,7 @@ end;
procedure TFPReportDesignerForm.AFrameUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and (CurrentDesigner.Objects.SelectionCount>0);
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and CurrentDesigner.Objects.HaveSelection;
end;
function TFPReportDesignerForm.GetModified: boolean;
@ -1255,7 +1255,7 @@ end;
procedure TFPReportDesignerForm.AResizeUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner);
(Sender as TAction).Enabled:=Assigned(ReportResizeFormClass) and Assigned(CurrentDesigner) and (CurrentDesigner.Objects.Haveselection) ;
end;
procedure TFPReportDesignerForm.HResizeAllow(Sender: TObject);