* Add menu item to adjust band height to content (Bug ID #33362)

git-svn-id: trunk@57481 -
This commit is contained in:
michael 2018-03-09 08:34:23 +00:00
parent 2f07f2fb0e
commit 6aad5cc192
3 changed files with 57 additions and 0 deletions

View File

@ -117,6 +117,8 @@ Type
procedure ResizeSelection(aHeight: TSizeAdjust; HSize: TFPReportUnits; aWidth: TSizeAdjust; WSize: TFPReportUnits);virtual;
Procedure ResizeSelection(Delta : TPoint; ADPI : integer; ApplyToPos : TResizeHandlePosition);virtual;
Procedure FrameSelection(aFrameAction : TFrameActions; doClearFirst : Boolean);
Procedure AdjustSelectedBandToContent(B : TFPReportCustomBand);
Procedure AdjustSelectedBandsToContent;
Procedure ResetModified;
Procedure SelectElement(E : TFPReportElement);
// Will call selectionchanged, except when result=odrPage
@ -636,6 +638,38 @@ begin
ReportChanged;
end;
procedure TReportObjectList.AdjustSelectedBandToContent(B: TFPReportCustomBand);
Var
I : Integer;
H,P : TFPReportUnits;
begin
if B.ChildCount=0 then
exit;
H:=B.Child[0].Layout.Height+B.Child[0].Layout.Top;
For I:=1 to B.ChildCount-1 do
begin
P:=B.Child[i].Layout.Height+B.Child[i].Layout.Top;
If P>H then
H:=P;
end;
B.Layout.Height:=H;
SelectRectInvalid;
ReportChanged;
end;
procedure TReportObjectList.AdjustSelectedBandsToContent;
Var
I : integer;
begin
For I:=0 to Count-1 do
If Objects[i].Selected and Objects[i].IsBand then
AdjustSelectedBandToContent(Objects[i].AsBand);
end;
procedure TReportObjectList.ResetModified;
begin
FModified:=False;

View File

@ -507,6 +507,9 @@ object FPReportDesignerForm: TFPReportDesignerForm
object MIResizeVSmallest: TMenuItem
Action = AResizeVSmallest
end
object MenuItem3: TMenuItem
Action = AResizeBandToFit
end
end
object MFrames: TMenuItem
Caption = 'Frames'
@ -907,6 +910,11 @@ object FPReportDesignerForm: TFPReportDesignerForm
OnExecute = AFileSaveAsExecute
OnUpdate = AFileSaveAsUpdate
end
object AResizeBandToFit: TAction
Caption = 'Adjust Band height to content'
OnExecute = AResizeBandToFitExecute
OnUpdate = AResizeBandToFitUpdate
end
end
object SDReport: TSaveDialog
DefaultExt = '.json'

View File

@ -74,6 +74,7 @@ type
AAlignVCenter: TAction;
AAlignBottom: TAction;
AAlign: TAction;
AResizeBandToFit: TAction;
AFileSaveAs: TAction;
ARecent: TAction;
AReportData: TAction;
@ -100,6 +101,7 @@ type
ILReport: TImageList;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MISaveAs: TMenuItem;
MIPreview: TMenuItem;
MIframeBottom: TMenuItem;
@ -248,6 +250,8 @@ type
procedure AReportPropertiesUpdate(Sender: TObject);
procedure AReportVariablesExecute(Sender: TObject);
procedure AReportVariablesUpdate(Sender: TObject);
procedure AResizeBandToFitExecute(Sender: TObject);
procedure AResizeBandToFitUpdate(Sender: TObject);
procedure AResizeExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormDestroy(Sender: TObject);
@ -1208,6 +1212,17 @@ begin
(Sender as Taction).Enabled:=Assigned(Report) and (rdoManageVariables in DesignOptions);
end;
procedure TFPReportDesignerForm.AResizeBandToFitExecute(Sender: TObject);
begin
If Assigned(CurrentDesigner) then
CurrentDesigner.Objects.AdjustSelectedBandsToContent;
end;
procedure TFPReportDesignerForm.AResizeBandToFitUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentDesigner) and (CurrentDesigner.Objects.HaveSelection);
end;
procedure TFPReportDesignerForm.AResizeExecute(Sender: TObject);
Var