You are not logged in.
I propose moving the setting of fInHeaderOrFooter in mORMotReport from DoHeaderFooterInternal() to DoHeader and DoFooter;
The reason for this is so that we can be in that mode while the event handlers StartPageHeader, EndPageHeader, StartPageFooter, EndPageFooter can be called when in Header/Footer mode.
This enables unlimited flexibility with customer headers and footers with DrawTextAt etc. Examples of this use would be in the generation of customer account statements or invoices.
Once again thanks for a great product.
Suggested code below of DoHeaderFooterInternal and DoHeader and DoFooter.
procedure TGDIPages.DoHeader;
begin
fHeaderDone := true;
if (fHeaderLines.Count = 0) then exit;
SaveLayout;
fInHeaderOrFooter := true;
try
if Assigned(fStartPageHeader) then
fStartPageHeader(Self);
Font.Color := clBlack;
DoHeaderFooterInternal(fHeaderLines);
if Assigned(fEndPageHeader) then
fEndPageHeader(Self);
GetLineHeight;
inc(fCurrentYPos,fLineHeight shr 2); // add a small header gap
fHeaderHeight := fCurrentYPos-fPageMarginsPx.Top;
finally
fInHeaderOrFooter := false;
RestoreSavedLayout;
end;
end;
procedure TGDIPages.DoFooter;
begin
if (fFooterLines.Count = 0) then exit;
SaveLayout;
fInHeaderOrFooter := true;
try
fCurrentYPos :=
fPhysicalSizePx.y - fPageMarginsPx.bottom - fFooterHeight + fFooterGap;
if Assigned(fStartPageFooter) then
fStartPageFooter(Self);
DoHeaderFooterInternal(fFooterLines);
if Assigned(fEndPageFooter) then
fEndPageFooter(Self);
finally
fInHeaderOrFooter := false;
RestoreSavedLayout;
end;
end;
procedure TGDIPages.DoHeaderFooterInternal(Lines: TObjectList);
var i: integer;
begin
SaveLayout;
try
for i := 0 to Lines.Count -1 do
with THeaderFooter(Lines[i]) do
begin
SavedState := State;
PrintFormattedLine(Text, State.Flags);
end;
finally
RestoreSavedLayout;
end;
end;
Regards,
Kevin.
Offline
Has been included as http://synopse.info/fossil/info/d8309b90c6
Thanks for the input!
Offline