Commit 2a449310 authored by Benoît Minisini's avatar Benoît Minisini
Browse files

Report.Print() now works correctly whatever the toolkit or the printer.

[GB.REPORT2]
* BUG: Report.Print() now works correctly whatever the toolkit or the printer.
* BUG: Checking or unchecking the grayscale checkbox now correctly refreshes the preview.
parent b7f1e745
Pipeline #186348577 passed with stage
in 19 minutes and 27 seconds
[Component]
Key=gb.report2
Version=3.14.90
Version=3.15.90
Needs=Form
Requires=gb.form,gb.eval
......@@ -2,7 +2,7 @@
Title=ReportsEvolution
Startup=Report13
Icon=.hidden/control/reportview.png
Version=3.14.90
Version=3.15.90
VersionFile=1
Component=gb.image
Component=gb.gui
......
......@@ -143,7 +143,6 @@ Public Sub Layout(Optional iPage As Integer = -1)
$bOpened = True
Endif
If Not _LayoutIsDirty Then Return
If _bInExec Then Return
If iPage > -1 Then
......@@ -156,11 +155,11 @@ Public Sub Layout(Optional iPage As Integer = -1)
$iPageCount = 0
Me._Reset
Endif
'Set execution Flag to true
_bInExec = True
CBaseSection = $aSections[0].Ctrl
For i = $iCurSection To $aSections.Max
Tsection = $aSections[i]
CSection = TSection.Ctrl
......
' Gambas class file
Create Static
Private hPrinter As New Printer As "Printer"
Private $hPrint As Report
Private $hPrinter As New Printer As "Printer"
Private $hReport As Report
Static Public Sub InitPrinterFromReport(hPrinter As Printer, hReport As Report)
hPrinter.FullPage = True
hPrinter.Orientation = hReport.Orientation
If hReport.Paper = Printer.Custom Then
'pnlCustom.Enabled = True
hPrinter.PaperWidth = Report.UnitTo(TSizeParse[hReport.Width].ToInch(), "in", "mm")
hPrinter.PaperHeight = Report.UnitTo(TSizeParse[hReport.Height].ToInch(), "in", "mm")
Else
hPrinter.Paper = hReport.Paper
Endif
End
Public Sub PrintReport(hReport As Report, Optional MyPrinter As Printer)
Dim hSizeParse As TSizeParse
$hPrint = hReport
Dim hImage As Image
$hReport = hReport
$hReport.Scale = 1
'$hPrint = hReport.Clone()
If MyPrinter Then
hPrinter = MyPrinter
$hPrinter = MyPrinter
Else
hPrinter = New Printer
$hPrinter = New Printer
Endif
Object.Attach(hPrinter, Me, "Printer")
hPrinter.Paper = $hPrint.Paper
hPrinter.Orientation = $hPrint.Orientation
If $hPrint.Paper = Printer.Custom Then
hSizeParse = New TSizeParse($hPrint.Width)
hPrinter.PaperWidth = Report.UnitTo(hSizeParse.ToInch(), "in", "mm") ' * 10
hSizeParse = New TSizeParse($hPrint.Height)
hPrinter.PaperHeight = Report.UnitTo(hSizeParse.ToInch(), "in", "mm") ' * 10
Endif
Object.Attach($hPrinter, Me, "Printer")
InitPrinterFromReport($hPrinter, $hReport)
If Not MyPrinter Then
If Not hPrinter.Configure() Then
hPrinter.Print
Endif
Else
hPrinter.Print
If $hPrinter.Configure() Then Return
Endif
' The report layout only works on Image, i.e. when DPI = 72
hImage = New Image(1, 1)
Paint.Begin(hImage)
$hReport.Layout()
Paint.End
$hPrinter.Print
End
Public Sub Printer_Draw()
$hPrint.Paint(hPrinter.Page)
Paint.FontScale = 25.4 / 72 * Paint.W / $hPrinter.PaperWidth * 72 / 96 * 96 / $hPrinter.Resolution
$hReport.Paint($hPrinter.Page)
End
Public Sub Printer_Begin()
'Debug Object.Type($hReport)
$hPrint.Layout
hPrinter.Count = $hPrint.PageCount
$hPrinter.Count = $hReport.PageCount
End
Public Sub Printer_End()
$hPrint = Null
$hReport = Null
End
......@@ -69,14 +69,11 @@ End
Private Sub GetValuesFromReport()
cmbPaper.Index = View.Report.Paper
$hPrinter.Orientation = View.Report.Orientation
CPrint.InitPrinterFromReport($hPrinter, View.Report)
If View.Report.Paper = Printer.Custom Then
pnlCustom.Enabled = True
$hPrinter.PaperWidth = TSizeParse[View.Report.Width].ToInch() * 10
$hPrinter.PaperHeight = TSizeParse[View.Report.Height].ToInch() * 10
Else
$hPrinter.Paper = View.Report.Paper
Endif
cmbOrientation.Index = $hPrinter.Orientation
......@@ -150,6 +147,7 @@ Public Sub tgbGrayScale_Click()
'Last.Background = IIf(Last.Value, Color.Gray, Color.Default)
$hPrinter.GrayScale = Last.Value
View._GrayScale = Last.Value
View.Refresh()
End
......@@ -361,6 +359,8 @@ End
Public Sub Printer_Draw()
'Debug Paint.W;; $hPrinter.PaperWidth;; $hPrinter.Resolution;; Paint.FontScale
If View.RangePages.Count = 0 Then
View.Report.Paint($hPrinter.Page)
Else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment