View Issue Details

IDProjectCategoryView StatusLast Update
0022942LazarusLazReportpublic2012-09-22 23:24
ReporterLagunov AlekseyAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.1 (SVN)Product Build 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0022942: frPrintGrid improvement
DescriptionAdded the ability to word wrap in cells.
Added the ability to connect RxDBGrid.
TagsNo tags attached.
Fixed in Revision38798
LazTarget1.2
Widgetset
Attached Files
  • lr.diff (4,784 bytes)
    Index: source/lr_pgrid.pas
    ===================================================================
    --- source/lr_pgrid.pas	(revision 38771)
    +++ source/lr_pgrid.pas	(working copy)
    @@ -39,7 +39,7 @@
     
       TfrPrintGrid = class(TComponent)
       private
    -    FDBGrid               : TDBGrid;
    +    FDBGrid               : TCustomDBGrid;
         FOnGetValue: TDetailEvent;
         FOnSetUpColumn: TSetupColumnEvent;
         FReport               : TfrReport;
    @@ -57,7 +57,7 @@
     
         procedure OnEnterRect(Memo: TStringList; View: TfrView);
         procedure OnPrintColumn(ColNo: Integer; var Width: Integer);
    -    procedure SetDBGrid(const AValue: TDBGrid);
    +    procedure SetDBGrid(const AValue: TCustomDBGrid);
       protected
         { Protected declarations }
         procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    @@ -71,7 +71,7 @@
     
         procedure PreviewReport;
       published
    -    property DBGrid: TDBGrid read FDBGrid write SetDBGrid;
    +    property DBGrid: TCustomDBGrid read FDBGrid write SetDBGrid;
         property Orientation: TPrinterOrientation read FOrientation write FOrientation default poPortrait;
         property Font: TFont read FFont write FFont;
         property TitleFont : TFont read FTitleFont write FTitleFont;
    @@ -126,13 +126,13 @@
       i,j,ColumnWidth: Integer;
     begin
       SetLength(FColumnsInfo, 0);
    -  for i:=0 to DbGrid.Columns.Count-1 do begin
    +  for i:=0 to TDBGrid(DbGrid).Columns.Count-1 do begin
     
    -    PrintColumn := DbGrid.Columns[i].Visible;
    -    ColumnWidth := DbGrid.Columns[i].Width;
    +    PrintColumn := TDBGrid(DbGrid).Columns[i].Visible;
    +    ColumnWidth := TDBGrid(DbGrid).Columns[i].Width;
     
         if Assigned(FOnSetupColumn) then
    -      FOnSetupColumn(Self, TColumn(DbGrid.Columns[i]), PrintColumn, ColumnWidth);
    +      FOnSetupColumn(Self, TColumn(TDBGrid(DbGrid).Columns[i]), PrintColumn, ColumnWidth);
     
         if PrintColumn then begin
           j:=Length(FColumnsInfo);
    @@ -213,13 +213,13 @@
       end;
     end;
     
    -procedure TfrPrintGrid.SetDBGrid(const AValue: TDBGrid);
    +procedure TfrPrintGrid.SetDBGrid(const AValue: TCustomDBGrid);
     begin
       fDBGrid:=aValue;
       if (csDesigning in ComponentState) and Assigned(fDBGrid) then
       begin
         fFont.Assign(fDBGrid.Font);
    -    FTitleFont.Assign(fDBGrid.TitleFont);
    +    FTitleFont.Assign(TDBGrid(fDBGrid).TitleFont);
       end;
     end;
     
    @@ -231,8 +231,8 @@
       BM  : TBookMark;
       XPos,YPos: Integer;
     begin
    -  if (FDBGrid = nil) or (DBGrid.Datasource = nil) or
    -     (DBGrid.Datasource.Dataset = nil) then Exit;
    +  if (FDBGrid = nil) or (TDBGrid(DBGrid).Datasource = nil) or
    +     (TDBGrid(DBGrid).Datasource.Dataset = nil) then Exit;
     
       if (FTemplate<>'') and not FileExists(FTemplate) then
           raise Exception.CreateFmt('Template file %s does not exists',[FTemplate]);
    @@ -241,7 +241,7 @@
       if FTemplate<>'' then
         FReport.LoadFromFile(FTemplate);
     
    -  FDataSet := DBGrid.Datasource.Dataset;
    +  FDataSet := TDBGrid(DBGrid).Datasource.Dataset;
     
       FReport.OnEnterRect  :=@OnEnterRect;
       FReport.OnPrintColumn:=@OnPrintColumn;
    @@ -260,7 +260,7 @@
       FColumnDataSet.RangeEndCount := Length(FColumnsInfo);
     
       try
    -    FReportDataSet.DataSource := DBGrid.DataSource;
    +    FReportDataSet.DataSource := TDBGrid(DBGrid).DataSource;
         if FReport.Pages.Count=0 then
           FReport.Pages.add;
         Page := FReport.Pages[FReport.Pages.Count-1];
    @@ -304,6 +304,7 @@
         if self.fShowHdOnAllPage then
           b.Flags:=b.Flags+flBandRepeatHeader;
         b.SetBounds(XPos, YPos, 1000, 20);
    +    b.Flags:=b.Flags or flStretched;
         Page.Objects.Add(b);
     
         v := frCreateObject(gtMemo, '', Page);
    @@ -312,7 +313,7 @@
         TfrMemoView(v).FillColor := clSilver;
         TfrMemoView(v).Font.Assign(FTitleFont);
         TfrMemoView(v).Frames:=frAllFrames;
    -    TfrMemoView(v).Layout:=tlCenter;
    +    TfrMemoView(v).Layout:=tlTop;
         v.Memo.Add('[Header]');
         Page.Objects.Add(v);
     
    @@ -322,6 +323,7 @@
         b.BandType := btMasterData;
         b.Dataset := FReportDataSet.Name;
         b.SetBounds(0, YPos, 1000, 18);
    +    b.Flags:=b.Flags or flStretched;
         Page.Objects.Add(b);
     
         b := TfrBandView(frCreateObject(gtBand, '', Page));
    @@ -333,9 +335,10 @@
         v := frCreateObject(gtMemo, '', Page);
         v.SetBounds(XPos, YPos, 20, 18);
         v.Memo.Add('[Cell]');
    +    V.Flags:=V.Flags or flStretched;
         TfrMemoView(v).Font.Assign(FFont);
         TfrMemoView(v).Frames:=frAllFrames;
    -    TfrMemoView(v).Layout:=tlCenter;
    +    TfrMemoView(v).Layout:=tlTop;
         Page.Objects.Add(v);
     
         FDataSet.DisableControls;
    @@ -364,7 +367,7 @@
       if (i<0) or (i>Length(FColumnsInfo)-1) then
         exit;
     
    -  C := TColumn(DbGrid.Columns[FColumnsInfo[i].Column]);
    +  C := TColumn(TDBGrid(DbGrid).Columns[FColumnsInfo[i].Column]);
       if (C<>nil)and(Memo.Count>0) then
       begin
         if (Memo[0]='[Cell]') and (C.Field<>nil) then
    
    lr.diff (4,784 bytes)

Activities

2012-09-21 19:13

 

lr.diff (4,784 bytes)
Index: source/lr_pgrid.pas
===================================================================
--- source/lr_pgrid.pas	(revision 38771)
+++ source/lr_pgrid.pas	(working copy)
@@ -39,7 +39,7 @@
 
   TfrPrintGrid = class(TComponent)
   private
-    FDBGrid               : TDBGrid;
+    FDBGrid               : TCustomDBGrid;
     FOnGetValue: TDetailEvent;
     FOnSetUpColumn: TSetupColumnEvent;
     FReport               : TfrReport;
@@ -57,7 +57,7 @@
 
     procedure OnEnterRect(Memo: TStringList; View: TfrView);
     procedure OnPrintColumn(ColNo: Integer; var Width: Integer);
-    procedure SetDBGrid(const AValue: TDBGrid);
+    procedure SetDBGrid(const AValue: TCustomDBGrid);
   protected
     { Protected declarations }
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
@@ -71,7 +71,7 @@
 
     procedure PreviewReport;
   published
-    property DBGrid: TDBGrid read FDBGrid write SetDBGrid;
+    property DBGrid: TCustomDBGrid read FDBGrid write SetDBGrid;
     property Orientation: TPrinterOrientation read FOrientation write FOrientation default poPortrait;
     property Font: TFont read FFont write FFont;
     property TitleFont : TFont read FTitleFont write FTitleFont;
@@ -126,13 +126,13 @@
   i,j,ColumnWidth: Integer;
 begin
   SetLength(FColumnsInfo, 0);
-  for i:=0 to DbGrid.Columns.Count-1 do begin
+  for i:=0 to TDBGrid(DbGrid).Columns.Count-1 do begin
 
-    PrintColumn := DbGrid.Columns[i].Visible;
-    ColumnWidth := DbGrid.Columns[i].Width;
+    PrintColumn := TDBGrid(DbGrid).Columns[i].Visible;
+    ColumnWidth := TDBGrid(DbGrid).Columns[i].Width;
 
     if Assigned(FOnSetupColumn) then
-      FOnSetupColumn(Self, TColumn(DbGrid.Columns[i]), PrintColumn, ColumnWidth);
+      FOnSetupColumn(Self, TColumn(TDBGrid(DbGrid).Columns[i]), PrintColumn, ColumnWidth);
 
     if PrintColumn then begin
       j:=Length(FColumnsInfo);
@@ -213,13 +213,13 @@
   end;
 end;
 
-procedure TfrPrintGrid.SetDBGrid(const AValue: TDBGrid);
+procedure TfrPrintGrid.SetDBGrid(const AValue: TCustomDBGrid);
 begin
   fDBGrid:=aValue;
   if (csDesigning in ComponentState) and Assigned(fDBGrid) then
   begin
     fFont.Assign(fDBGrid.Font);
-    FTitleFont.Assign(fDBGrid.TitleFont);
+    FTitleFont.Assign(TDBGrid(fDBGrid).TitleFont);
   end;
 end;
 
@@ -231,8 +231,8 @@
   BM  : TBookMark;
   XPos,YPos: Integer;
 begin
-  if (FDBGrid = nil) or (DBGrid.Datasource = nil) or
-     (DBGrid.Datasource.Dataset = nil) then Exit;
+  if (FDBGrid = nil) or (TDBGrid(DBGrid).Datasource = nil) or
+     (TDBGrid(DBGrid).Datasource.Dataset = nil) then Exit;
 
   if (FTemplate<>'') and not FileExists(FTemplate) then
       raise Exception.CreateFmt('Template file %s does not exists',[FTemplate]);
@@ -241,7 +241,7 @@
   if FTemplate<>'' then
     FReport.LoadFromFile(FTemplate);
 
-  FDataSet := DBGrid.Datasource.Dataset;
+  FDataSet := TDBGrid(DBGrid).Datasource.Dataset;
 
   FReport.OnEnterRect  :=@OnEnterRect;
   FReport.OnPrintColumn:=@OnPrintColumn;
@@ -260,7 +260,7 @@
   FColumnDataSet.RangeEndCount := Length(FColumnsInfo);
 
   try
-    FReportDataSet.DataSource := DBGrid.DataSource;
+    FReportDataSet.DataSource := TDBGrid(DBGrid).DataSource;
     if FReport.Pages.Count=0 then
       FReport.Pages.add;
     Page := FReport.Pages[FReport.Pages.Count-1];
@@ -304,6 +304,7 @@
     if self.fShowHdOnAllPage then
       b.Flags:=b.Flags+flBandRepeatHeader;
     b.SetBounds(XPos, YPos, 1000, 20);
+    b.Flags:=b.Flags or flStretched;
     Page.Objects.Add(b);
 
     v := frCreateObject(gtMemo, '', Page);
@@ -312,7 +313,7 @@
     TfrMemoView(v).FillColor := clSilver;
     TfrMemoView(v).Font.Assign(FTitleFont);
     TfrMemoView(v).Frames:=frAllFrames;
-    TfrMemoView(v).Layout:=tlCenter;
+    TfrMemoView(v).Layout:=tlTop;
     v.Memo.Add('[Header]');
     Page.Objects.Add(v);
 
@@ -322,6 +323,7 @@
     b.BandType := btMasterData;
     b.Dataset := FReportDataSet.Name;
     b.SetBounds(0, YPos, 1000, 18);
+    b.Flags:=b.Flags or flStretched;
     Page.Objects.Add(b);
 
     b := TfrBandView(frCreateObject(gtBand, '', Page));
@@ -333,9 +335,10 @@
     v := frCreateObject(gtMemo, '', Page);
     v.SetBounds(XPos, YPos, 20, 18);
     v.Memo.Add('[Cell]');
+    V.Flags:=V.Flags or flStretched;
     TfrMemoView(v).Font.Assign(FFont);
     TfrMemoView(v).Frames:=frAllFrames;
-    TfrMemoView(v).Layout:=tlCenter;
+    TfrMemoView(v).Layout:=tlTop;
     Page.Objects.Add(v);
 
     FDataSet.DisableControls;
@@ -364,7 +367,7 @@
   if (i<0) or (i>Length(FColumnsInfo)-1) then
     exit;
 
-  C := TColumn(DbGrid.Columns[FColumnsInfo[i].Column]);
+  C := TColumn(TDBGrid(DbGrid).Columns[FColumnsInfo[i].Column]);
   if (C<>nil)and(Memo.Count>0) then
   begin
     if (Memo[0]='[Cell]') and (C.Field<>nil) then
lr.diff (4,784 bytes)

Jesus Reyes

2012-09-22 19:34

developer   ~0062571

Applied, thank you.

Issue History

Date Modified Username Field Change
2012-09-21 19:13 Lagunov Aleksey New Issue
2012-09-21 19:13 Lagunov Aleksey File Added: lr.diff
2012-09-21 21:48 Jesus Reyes Status new => assigned
2012-09-21 21:48 Jesus Reyes Assigned To => Jesus Reyes
2012-09-22 19:34 Jesus Reyes Fixed in Revision => 38798
2012-09-22 19:34 Jesus Reyes LazTarget => 1.2
2012-09-22 19:34 Jesus Reyes Status assigned => resolved
2012-09-22 19:34 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-09-22 19:34 Jesus Reyes Resolution open => fixed
2012-09-22 19:34 Jesus Reyes Note Added: 0062571
2012-09-22 19:34 Jesus Reyes Target Version => 1.2.0
2012-09-22 23:24 Lagunov Aleksey Status resolved => closed