* Correct font names/sizes/colors, editable (Bug ID #33261)

git-svn-id: trunk@57419 -
This commit is contained in:
michael 2018-02-28 14:30:21 +00:00
parent 9922476f6a
commit 4bfd712116
2 changed files with 88 additions and 3 deletions

View File

@ -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;

View File

@ -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