mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 03:29:32 +01:00
* Allow use of custom elements registered in reporting engine (barcode en QRCode are standard)
git-svn-id: trunk@57686 -
This commit is contained in:
parent
3b9ac41419
commit
b4612a8bc7
@ -313,6 +313,7 @@ type
|
|||||||
procedure VAlignExecute(Sender: TObject);
|
procedure VAlignExecute(Sender: TObject);
|
||||||
procedure VResizeExecute(Sender: TObject);
|
procedure VResizeExecute(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
FCustomStartIndex : Integer;
|
||||||
FInitialFileName: String;
|
FInitialFileName: String;
|
||||||
FLoadModified : Boolean;
|
FLoadModified : Boolean;
|
||||||
FStopDesigning: Boolean;
|
FStopDesigning: Boolean;
|
||||||
@ -339,6 +340,8 @@ type
|
|||||||
procedure GetReportDataNames(Sender: TObject; List: TStrings);
|
procedure GetReportDataNames(Sender: TObject; List: TStrings);
|
||||||
procedure InitialiseData;
|
procedure InitialiseData;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
procedure AddCustomElementExecute(Sender: TObject);
|
||||||
|
procedure AddCustomElements;
|
||||||
procedure CheckLoadInitialFile;
|
procedure CheckLoadInitialFile;
|
||||||
function CreateDesignPopupMenu(aOWner: TComponent): TPopupMenu;
|
function CreateDesignPopupMenu(aOWner: TComponent): TPopupMenu;
|
||||||
function CreateNewPage: TFPReportCustomPage;
|
function CreateNewPage: TFPReportCustomPage;
|
||||||
@ -535,6 +538,8 @@ begin
|
|||||||
FreeAndNil(TSDesign); // Remove design-time added page
|
FreeAndNil(TSDesign); // Remove design-time added page
|
||||||
FReportDesignData:=TDesignReportDataManager.Create(Self);
|
FReportDesignData:=TDesignReportDataManager.Create(Self);
|
||||||
SetBandActionTags;
|
SetBandActionTags;
|
||||||
|
FCustomStartIndex:=Madd.Count;
|
||||||
|
AddCustomElements;
|
||||||
// DEMO
|
// DEMO
|
||||||
{$IFDEF USEDEMOREPORT}
|
{$IFDEF USEDEMOREPORT}
|
||||||
CreateDemoReport;
|
CreateDemoReport;
|
||||||
@ -558,6 +563,77 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Type
|
||||||
|
{ TAddElementAction }
|
||||||
|
|
||||||
|
TAddElementAction = Class(TAction)
|
||||||
|
private
|
||||||
|
FClass: TFPReportElementClass;
|
||||||
|
published
|
||||||
|
Property AClass : TFPReportElementClass Read FClass Write FClass;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPReportDesignerForm.AddCustomElements;
|
||||||
|
|
||||||
|
Function AllowClass(M : TFPReportClassMapping) : Boolean;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:= not M.ReportElementClass.InheritsFrom(TFPReportCustomBand)
|
||||||
|
and not M.ReportElementClass.InheritsFrom(TFPReportCustomPage);
|
||||||
|
if Result then
|
||||||
|
Result:=Not M.Standard;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Var
|
||||||
|
I : Integer;
|
||||||
|
M : TFPReportClassMapping;
|
||||||
|
MI : TMenuItem;
|
||||||
|
A : TAddElementAction;
|
||||||
|
Img : TPortableNetworkGraphic;
|
||||||
|
S : TMemoryStream;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for I:=0 to gElementFactory.MappingCount-1 do
|
||||||
|
begin
|
||||||
|
M:=gElementFactory.Mappings[i];
|
||||||
|
if AllowClass(M) then
|
||||||
|
begin
|
||||||
|
A:=TAddElementAction.Create(Self);
|
||||||
|
A.Caption:=M.MappingName;
|
||||||
|
A.AClass:=M.ReportElementClass;
|
||||||
|
A.OnUpdate:=@AAddElementUpdate;
|
||||||
|
A.OnExecute:=@AddCustomElementExecute;
|
||||||
|
A.Category:='Add';
|
||||||
|
A.ActionList:=ALReport;
|
||||||
|
if (Length(M.IconData)>0) then
|
||||||
|
begin
|
||||||
|
Img:=Nil;
|
||||||
|
S:=TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
S.WriteBuffer(M.IconData[0],Length(M.IConData));
|
||||||
|
S.Position:=0;
|
||||||
|
Img:=TPortableNetworkGraphic.Create;
|
||||||
|
Img.LoadFromStream(S);
|
||||||
|
A.ImageIndex:=ILReport.Add(Img,Nil);
|
||||||
|
Finally
|
||||||
|
S.Free;
|
||||||
|
Img.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
MI:=TMenuItem.Create(Self);
|
||||||
|
MI.Action:=A;
|
||||||
|
MAdd.Add(MI);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPReportDesignerForm.AddCustomElementExecute(Sender: TObject);
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (Sender is TAddElementAction) then
|
||||||
|
CurrentDesigner.AddElement((Sender as TAddElementAction).AClass);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPReportDesignerForm.FormCloseQuery(Sender: TObject;
|
procedure TFPReportDesignerForm.FormCloseQuery(Sender: TObject;
|
||||||
var CanClose: boolean);
|
var CanClose: boolean);
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -12,6 +12,8 @@ uses
|
|||||||
reportconns,
|
reportconns,
|
||||||
fpreport,
|
fpreport,
|
||||||
fpreportdb,
|
fpreportdb,
|
||||||
|
fpreportbarcode,
|
||||||
|
fpreportqrcode,
|
||||||
// Exports
|
// Exports
|
||||||
fpreportpdfexport,
|
fpreportpdfexport,
|
||||||
fpreporthtmlexport,
|
fpreporthtmlexport,
|
||||||
|
|||||||
@ -892,6 +892,7 @@ procedure TFPReportExportCanvas.RenderElement(ABand : TFPReportCustomBand; Eleme
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
C : TFPReportPoint;
|
C : TFPReportPoint;
|
||||||
|
LB,LE : TFPReportLayout;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF DEBUGRD}
|
{$IFDEF DEBUGRD}
|
||||||
@ -909,11 +910,13 @@ begin
|
|||||||
RenderCheckbox(ABand,TFPReportCustomCheckbox(Element))
|
RenderCheckbox(ABand,TFPReportCustomCheckbox(Element))
|
||||||
else if not (Element is TFPReportCustomBand) then
|
else if not (Element is TFPReportCustomBand) then
|
||||||
begin
|
begin
|
||||||
C.Left := ABand.RTLayout.Left + Element.RTLayout.Left;
|
LB:=GetLayout(ABand);
|
||||||
C.Top := ABand.RTLayout.Top + Element.RTLayout.Top ; // + Element.RTLayout.Height;
|
LE:=GetLayout(Element);
|
||||||
RenderFrame(ABand, Element.Frame, C, Element.RTLayout.Width, Element.RTLayout.Height);
|
C.Left := LB.Left + LE.Left;
|
||||||
C.Left:=aband.RTLayout.Left;
|
C.Top := LB.Top + LE.Top ; // + Element.RTLayout.Height;
|
||||||
C.Top:=aband.RTLayout.Top;
|
RenderFrame(ABand, Element.Frame, C, LE.Width, LE.Height);
|
||||||
|
C.Left:=LB.Left;
|
||||||
|
C.Top:=LB.Top;
|
||||||
RenderUnknownElement(C,Element,Self.VDPI);
|
RenderUnknownElement(C,Element,Self.VDPI);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user