RxFPC:continue work on RxDBGrid PDF export

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5079 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-08-10 14:03:15 +00:00
parent 1276eb57b8
commit 667cae6df5
2 changed files with 56 additions and 8 deletions

View File

@ -18,6 +18,7 @@ type
TRxCustomDateRangeEdit = class(TCustomControl)
private
FFlat: Boolean;
FLockCount:integer;
FOnEditChange: TNotifyEvent;
FOnEditClick: TNotifyEvent;
FOnEditEnter: TNotifyEvent;
@ -50,6 +51,8 @@ type
procedure InternalOnEditClick(Sender: TObject);
procedure InternalOnEditEnter(Sender: TObject);
procedure InternalOnEditExit(Sender: TObject);
procedure Lock;
procedure UnLock;
protected
class function GetControlClassDefaultSize: TSize; override;
procedure FillMonthNames;
@ -158,6 +161,7 @@ begin
end
else
FEditMonth.ItemIndex := 0;
InternalOnEditChange(Self);
end;
procedure TRxCustomDateRangeEdit.DoIncYear(Sender: TObject);
@ -206,6 +210,7 @@ begin
end
else
FEditMonth.ItemIndex := 0;
InternalOnEditChange(Self);
end;
procedure TRxCustomDateRangeEdit.DoDecYear(Sender: TObject);
@ -316,6 +321,7 @@ end;
procedure TRxCustomDateRangeEdit.InternalOnEditChange(Sender: TObject);
begin
if FLockCount = 0 then
EditChange;
end;
@ -334,6 +340,19 @@ begin
EditExit;
end;
procedure TRxCustomDateRangeEdit.Lock;
begin
Inc(FLockCount);
end;
procedure TRxCustomDateRangeEdit.UnLock;
begin
if FLockCount > 0 then
Dec(FLockCount)
else
InternalOnEditChange(Self);
end;
class function TRxCustomDateRangeEdit.GetControlClassDefaultSize: TSize;
begin
Result.CX := 80 + 70 + 23 * 4;
@ -410,6 +429,7 @@ end;
constructor TRxCustomDateRangeEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLockCount:=0;
FOptions:=[reoMonth];
FEditYear:=TSpinEdit.Create(Self);

View File

@ -159,19 +159,36 @@ procedure TRxDBGridExportPDF.DoExportTitle;
var
P: TPDFPage;
Pt: TPDFCoord;
i: Integer;
i, X: Integer;
C: TRxColumn;
S: String;
begin
X:=20;
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
P:=TPDFPage(FWorkPages[0]);
C:=FRxDBGrid.Columns[i];
Pt.X := 20 + i * 40;
Pt.X := X;
Pt.Y := FPosY;
P.SetColor(C.Color);
P.DrawRect(Pt.X, Pt.Y, 40, FRxDBGrid.DefaultRowHeight, 1, true, true);
P.DrawRect(Pt.X, Pt.Y, C.Width, FRxDBGrid.DefaultRowHeight, 1, false, true);
P.SetFont(FHeaderFont, 10);
//P.SetColor(clBlue, false);
P.WriteText(Pt.X+2, Pt.Y-10, C.Title.Caption);
Inc(X, C.Width);
end;
Inc(FPosY, FRxDBGrid.DefaultRowHeight)
Inc(FPosY, FRxDBGrid.DefaultRowHeight);
{
S:='Russian: Привет мир!';
P.SetFont(FBodyFont, 11);
P.WriteText(40, 160, S);}
end;
procedure TRxDBGridExportPDF.DoExportBody;
@ -181,11 +198,22 @@ end;
procedure TRxDBGridExportPDF.DoSetupFonts;
begin
FHeaderFont := FPDFDocument.AddFont('Helvetica');
//FPDFDocument.FontDirectory := '/usr/share/fonts/liberation';
FPDFDocument.FontDirectory := '/usr/share/fonts/liberation';
FHeaderFont := FPDFDocument.AddFont('LiberationSans-Regular.ttf', 'LiberationSans', clGreen);
FPDFDocument.FontDirectory := 'fonts';
FBodyFont := FPDFDocument.AddFont('FreeSans.ttf', 'FreeSans', clGreen); // TODO: this color value means nothing - not used at all
// FHeaderFont := FPDFDocument.AddFont('Helvetica');
// FBodyFont := D.AddFont('Helvetica');
// FFooterFont := D.AddFont('Helvetica');
FBodyFont := FHeaderFont;
// FBodyFont := FHeaderFont;
FFooterFont := FHeaderFont;
{FtTitle := D.AddFont('Helvetica', clRed);
FtText1 := D.AddFont('FreeSans.ttf', 'FreeSans', clGreen); // TODO: this color value means nothing - not used at all
FtText2 := D.AddFont('Times-BoldItalic', clBlack);}
end;
procedure TRxDBGridExportPDF.DoExportFooter;
@ -248,7 +276,7 @@ begin
FWorkPages.Add(P);
end;
FPosY:=20;
FPosY:=40;
if repExportTitle in FOptions then
DoExportTitle;