mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 12:39:15 +02:00
LazReport, check that printgrid template bands don't overlap with created ones
git-svn-id: trunk@17798 -
This commit is contained in:
parent
3b2850d477
commit
e415847d82
@ -64,6 +64,7 @@ type
|
|||||||
procedure SetupColumns;
|
procedure SetupColumns;
|
||||||
function FindBand(APage: TFrPage; AType: TfrBandType): TFrBandView;
|
function FindBand(APage: TFrPage; AType: TfrBandType): TFrBandView;
|
||||||
procedure ReplaceTemplate(APage:TFrPage; ABand: TFrBandView; ATemplate,AReplace:String);
|
procedure ReplaceTemplate(APage:TFrPage; ABand: TFrBandView; ATemplate,AReplace:String);
|
||||||
|
procedure FindFreeSpace(APage: TfrPage; out XPos,YPos:Integer);
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -174,6 +175,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrPrintGrid.FindFreeSpace(APage: TfrPage; out XPos, YPos: Integer);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
Ydone,Xdone: boolean;
|
||||||
|
begin
|
||||||
|
|
||||||
|
YPos := 0;
|
||||||
|
XPos := 20;
|
||||||
|
|
||||||
|
YDone:= false;
|
||||||
|
XDone:= false;
|
||||||
|
|
||||||
|
for i:=0 to APage.Objects.Count-1 do begin
|
||||||
|
if not (TObject(APage.Objects[i]) is TFrBandView) then
|
||||||
|
continue;
|
||||||
|
|
||||||
|
with TfrBandView(APage.Objects[i]) do begin
|
||||||
|
if BandType in [btCrossHeader, btCrossData, btCrossFooter] then begin
|
||||||
|
if not XDone then begin
|
||||||
|
if x - XPos > 20 then
|
||||||
|
XDone := true
|
||||||
|
else
|
||||||
|
XPos := x + dx + 1;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
if not YDone then begin
|
||||||
|
if y - YPos > 40 then
|
||||||
|
YDone := true
|
||||||
|
else
|
||||||
|
YPos := x + dy + 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrPrintGrid.SetDBGrid(const AValue: TDBGrid);
|
procedure TfrPrintGrid.SetDBGrid(const AValue: TDBGrid);
|
||||||
begin
|
begin
|
||||||
fDBGrid:=aValue;
|
fDBGrid:=aValue;
|
||||||
@ -190,7 +228,7 @@ var
|
|||||||
b,h: TfrBandView;
|
b,h: TfrBandView;
|
||||||
Page: TfrPage;
|
Page: TfrPage;
|
||||||
BM : TBookMark;
|
BM : TBookMark;
|
||||||
yPos: Integer;
|
XPos,YPos: Integer;
|
||||||
begin
|
begin
|
||||||
if (FDBGrid = nil) or (DBGrid.Datasource = nil) or
|
if (FDBGrid = nil) or (DBGrid.Datasource = nil) or
|
||||||
(DBGrid.Datasource.Dataset = nil) then Exit;
|
(DBGrid.Datasource.Dataset = nil) then Exit;
|
||||||
@ -228,19 +266,16 @@ begin
|
|||||||
with Page do
|
with Page do
|
||||||
ChangePaper(pgSize, Width, Height, FOrientation);
|
ChangePaper(pgSize, Width, Height, FOrientation);
|
||||||
|
|
||||||
YPos := -1;
|
|
||||||
b := FindBand(Page, btReportTitle);
|
b := FindBand(Page, btReportTitle);
|
||||||
if b<>nil then begin
|
if b<>nil then begin
|
||||||
if FShowCaption then
|
if FShowCaption then
|
||||||
ReplaceTemplate(Page, b, '<title>', FCaption);
|
ReplaceTemplate(Page, b, '<title>', FCaption);
|
||||||
YPos := b.y + b.dy + 10;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
h := FindBand(Page, btPageHeader);
|
h := FindBand(Page, btPageHeader);
|
||||||
if h<>nil then begin
|
if h<>nil then begin
|
||||||
if FShowCaption then
|
if FShowCaption then
|
||||||
ReplaceTemplate(Page, h, '<title>', FCaption);
|
ReplaceTemplate(Page, h, '<title>', FCaption);
|
||||||
YPos := h.y + h.dy + 10;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FShowCaption and (b=nil) and (h=nil) then begin
|
if FShowCaption and (b=nil) and (h=nil) then begin
|
||||||
@ -254,21 +289,22 @@ begin
|
|||||||
TfrMemoView(v).Font.Assign(FTitleFont);
|
TfrMemoView(v).Font.Assign(FTitleFont);
|
||||||
v.Memo.Add(FCaption);
|
v.Memo.Add(FCaption);
|
||||||
Page.Objects.Add(v);
|
Page.Objects.Add(v);
|
||||||
YPos := b.y + b.dy + 10;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if YPos<0 then
|
// if we have a template we need to be sure that bands on template
|
||||||
YPos := 60;
|
// do not overlap with bands we are about to add, we need exactly
|
||||||
|
// 40 pixels of free height space and 20 pixels width for cross band
|
||||||
|
FindFreeSpace(Page, XPos, YPos);
|
||||||
|
|
||||||
b := TfrBandView(frCreateObject(gtBand, ''));
|
b := TfrBandView(frCreateObject(gtBand, ''));
|
||||||
b.BandType := btMasterHeader;
|
b.BandType := btMasterHeader;
|
||||||
if self.fShowHdOnAllPage then
|
if self.fShowHdOnAllPage then
|
||||||
b.Flags:=b.Flags+flBandRepeatHeader;
|
b.Flags:=b.Flags+flBandRepeatHeader;
|
||||||
b.SetBounds(20, YPos, 1000, 20);
|
b.SetBounds(XPos, YPos, 1000, 20);
|
||||||
Page.Objects.Add(b);
|
Page.Objects.Add(b);
|
||||||
|
|
||||||
v := frCreateObject(gtMemo, '');
|
v := frCreateObject(gtMemo, '');
|
||||||
v.SetBounds(20, YPos, 20, 20);
|
v.SetBounds(XPos, YPos, 20, 20);
|
||||||
TfrMemoView(v).Alignment:=taCenter;
|
TfrMemoView(v).Alignment:=taCenter;
|
||||||
TfrMemoView(v).FillColor := clSilver;
|
TfrMemoView(v).FillColor := clSilver;
|
||||||
TfrMemoView(v).Font.Assign(FTitleFont);
|
TfrMemoView(v).Font.Assign(FTitleFont);
|
||||||
@ -277,7 +313,7 @@ begin
|
|||||||
v.Memo.Add('[Header]');
|
v.Memo.Add('[Header]');
|
||||||
Page.Objects.Add(v);
|
Page.Objects.Add(v);
|
||||||
|
|
||||||
YPos := YPos + 40;
|
YPos := YPos + 22;
|
||||||
|
|
||||||
b := TfrBandView(frCreateObject(gtBand, ''));
|
b := TfrBandView(frCreateObject(gtBand, ''));
|
||||||
b.BandType := btMasterData;
|
b.BandType := btMasterData;
|
||||||
@ -288,11 +324,11 @@ begin
|
|||||||
b := TfrBandView(frCreateObject(gtBand, ''));
|
b := TfrBandView(frCreateObject(gtBand, ''));
|
||||||
b.BandType := btCrossData;
|
b.BandType := btCrossData;
|
||||||
b.Dataset := FColumnDataSet.Name;
|
b.Dataset := FColumnDataSet.Name;
|
||||||
b.SetBounds(20, 0, 20, 1000);
|
b.SetBounds(XPos, 0, 20, 1000);
|
||||||
Page.Objects.Add(b);
|
Page.Objects.Add(b);
|
||||||
|
|
||||||
v := frCreateObject(gtMemo, '');
|
v := frCreateObject(gtMemo, '');
|
||||||
v.SetBounds(20, YPos, 20, 18);
|
v.SetBounds(XPos, YPos, 20, 18);
|
||||||
v.Memo.Add('[Cell]');
|
v.Memo.Add('[Cell]');
|
||||||
TfrMemoView(v).Font.Assign(FFont);
|
TfrMemoView(v).Font.Assign(FFont);
|
||||||
TfrMemoView(v).Frames:=frAllFrames;
|
TfrMemoView(v).Frames:=frAllFrames;
|
||||||
|
Loading…
Reference in New Issue
Block a user