From 4bfd712116a0351d1b295552d9b3966e7c5751e0 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 28 Feb 2018 14:30:21 +0000 Subject: [PATCH] * Correct font names/sizes/colors, editable (Bug ID #33261) git-svn-id: trunk@57419 - --- components/fpreport/design/regfpdesigner.pp | 78 ++++++++++++++++++++- components/fpreport/fpreportlclexport.pas | 13 +++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/components/fpreport/design/regfpdesigner.pp b/components/fpreport/design/regfpdesigner.pp index a1c635ffce..986eebdc53 100644 --- a/components/fpreport/design/regfpdesigner.pp +++ b/components/fpreport/design/regfpdesigner.pp @@ -19,10 +19,25 @@ unit regfpdesigner; interface uses - Classes, SysUtils, fpreport, ideintf, propedits, ObjInspStrConsts, frmfpreportmemoedit; + fpttf, GraphPropEdits, Classes, SysUtils, dialogs, fpreport, ideintf, propedits, ObjInspStrConsts, frmfpreportmemoedit; Type + { TReportFontPropertyEditor } + + TReportFontPropertyEditor = class(TClassPropertyEditor) + public + procedure Edit; override; + function GetAttributes: TPropertyAttributes; override; + end; + + { TReportFontNamePropertyEditor } + + TReportFontNamePropertyEditor = class(TFontNamePropertyEditor) + public + procedure SetValue(const NewValue: ansistring); override; + end; + { TPaperNamePropertyEditor } TPaperNamePropertyEditor = class(TStringPropertyEditor) @@ -104,6 +119,8 @@ Procedure RegisterFPReportPropEditors; implementation +uses fpreportlclexport; + Procedure RegisterFPReportPropEditors; begin @@ -114,9 +131,65 @@ begin RegisterPropertyEditor(TypeInfo(TFPReportCustomDataBand), TFPReportCustomBand, 'MasterBand', TDataBandPropertyEditor); RegisterPropertyEditor(TypeInfo(TFPReportCustomGroupHeaderBand),TFPReportCustomGroupHeaderBand, 'ParentGroupHeader', TGroupHeaderBandPropertyEditor); RegisterPropertyEditor(TypeInfo(TFPReportCustomGroupFooterBand),TFPReportCustomGroupHeaderBand, 'GroupFooter', TGroupFooterBandPropertyEditor); - RegisterPropertyEditor(TypeInfo(String),TFPReportPageSize,'PaperName',TPaperNamePropertyEditor); + RegisterPropertyEditor(ClassTypeInfo(TFPReportFont), nil,'',TReportFontPropertyEditor); + RegisterPropertyEditor(TypeInfo(String),TFPReportFont,'Name',TReportFontNamePropertyEditor); end; +{ TReportFontPropertyEditor } +Function FontNameToPostScriptName(N : String) : String; + +Var + F : TFPFontCacheItem; + +begin + if (N='default') then + N:=ReportDefaultFont; + F:=gTTFontCache.Find(N,False,False); + if Assigned(F) then + N:=F.PostScriptName; + Result:=N; +end; + +{ TReportFontNamePropertyEditor } + + +procedure TReportFontNamePropertyEditor.SetValue(const NewValue: ansistring); +begin + inherited SetValue(FontNameToPostScriptName(NewValue)); +end; + +procedure TReportFontPropertyEditor.Edit; + +var + FontDialog: TFontDialog; + R : TFPReportFont; + +begin + FontDialog := TFontDialog.Create(nil); + try + R:=TFPReportFont(GetObjectValue(TFPReportFont)); + FontDialog.Font.Name := R.Name; + FontDialog.Font.Size:=R.Size; + FontDialog.Font.Color:=TFPReportExportCanvas.RGBtoBGR(R.Color); + FontDialog.Options := FontDialog.Options + [fdShowHelp, fdForceFontExist]; + if FontDialog.Execute then + begin + FontDialog.Font.Name := FontNameToPostScriptName(R.Name); + FontDialog.Font.Size:=R.Size; + FontDialog.Font.Color:=TFPReportExportCanvas.RGBtoBGR(R.Color); + end; + finally + FontDialog.Free; + end; +end; + +function TReportFontPropertyEditor.GetAttributes: TPropertyAttributes; +begin + Result := [paMultiSelect, paSubProperties, paDialog, paReadOnly]; +end; + + + { TPaperNamePropertyEditor } procedure TPaperNamePropertyEditor.GetValues(Proc: TGetStrProc); @@ -134,6 +207,7 @@ begin Result:=[paValueList, paPickList, paAutoUpdate, paSortList]; end; + { TGroupFooterBandPropertyEditor } function TGroupFooterBandPropertyEditor.BandTypes: TFPReportBandTypes; diff --git a/components/fpreport/fpreportlclexport.pas b/components/fpreport/fpreportlclexport.pas index 403be56c7f..e4653bb61c 100644 --- a/components/fpreport/fpreportlclexport.pas +++ b/components/fpreport/fpreportlclexport.pas @@ -149,6 +149,7 @@ type Function GetElementRect(BandLayout,ElementLayout : TFPReportLayout) : TRect; Function GetElementRect(ABand : TFPReportCustomBand; AElement : TFPReportElement) : TRect; Class function RGBtoBGR(const AColor: UInt32): TColor; + Class function BGRToRGB(const AColor: TColor): TFPReportColor; // Properties property HDPI: integer read FHDPI write FHDPI; property VDPI: integer read FVDPI write FVDPI; @@ -211,6 +212,16 @@ begin Result:=RGBToColor(R,G,B); end; +class function TFPReportExportCanvas.BGRToRGB(const AColor: TColor): TFPReportColor; + +var + R,G,B : Byte; + +begin + RedGreenBlue(ColorToRGB(AColor),R,G,B); + Result:=RGBToReportColor(R,G,B); +end; + { THyperLinkList } function THyperLinkList.GetL(AIndex : Integer): THyperLinkItem; @@ -433,7 +444,7 @@ procedure TFPReportExportCanvas.RenderFrame(const ABand: TFPReportCustomBand; co const APos: TFPReportPoint; const AWidth, AHeight: TFPReportUnits); begin - RenderFrame(AFrame,CoordToRect(APos,AWidth,AHeight),ABand.Frame.BackgroundColor); + RenderFrame(AFrame,CoordToRect(APos,AWidth,AHeight), RGBtoBGR(ABand.Frame.BackgroundColor)); end; Type