[GB.REPORT]

* NEW: A New widget ReportPageBreak allow to break a page when you need
* NEW: Report.Print take now an optional argument Printer that allow
  to give an externally initialised printer. In tis case the dialog is not
  shown.
* BUG: Now ReportLabel rotation work fine and the angle is given in Rad
* BUG: You can now add an argument to the _New sub. Be carrefull the _New 
  event is called one time only at the report loading.
* BUG: The custom size work but there is some bugs with the printer.configure
  that setup the page size to A4 :-/



git-svn-id: svn://localhost/gambas/trunk@6089 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2014-01-19 21:44:48 +00:00
parent 35062bb200
commit 5dfef252d5
24 changed files with 346 additions and 123 deletions

View file

@ -1,7 +1,6 @@
[Component]
Key=gb.report
Version=3.3.0
Version=3.5.90
State=1
Authors=Fabien Bodard
Needs=Form,ImageIO

View file

@ -1,9 +1,2 @@
[Desktop Entry]
Icon=./.icon.png
[Dolphin]
Timestamp=2014,1,4,21,13,1
Version=3
[Settings]
HiddenFilesShown=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

View file

@ -290,22 +290,6 @@ Preview
m
Image
m
ReportBrush
(Value)s(X)s(Y)s
LinearGradient
m
ReportBrush
(Colors)Integer[];(Positions)Float[];
RadialGradient
m
ReportBrush
(Colors)Integer[];(Positions)Float[];
Color
m
ReportBrush
(iColor)i
Refresh
m
@ -321,7 +305,7 @@ Report
Print
m
[(hPrinter)Printer;]
#ReportBorder
C
@ -420,6 +404,10 @@ _Image
v
Image
Image
M
ReportBrush
(hImage)Image;
_Color
v
Integer[]
@ -452,10 +440,6 @@ ToString
m
s
ImageBrush
M
ReportBrush
(hImage)Image;
#ReportContainer
ReportFrame
@ -1033,6 +1017,13 @@ _Get
M
ReportPadding
(Value)s
#ReportPageBreak
ReportControl
C
_Properties
C
s
-*
#ReportPanel
ReportContainer
C

View file

@ -12,6 +12,7 @@ ReportImage
ReportLabel
ReportLine
ReportPadding
ReportPageBreak
ReportPanel
ReportSection
ReportSvgImage

View file

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.5.90
Title=Report designer
Startup=OutputReport2
Startup=Report9
Icon=printer1.png
Version=3.5.90
VersionFile=1

View file

@ -4,23 +4,33 @@ Create Static
Private hPrinter As New Printer As "Printer"
Private $hPrint As Report
Public Sub PrintReport(hReport As Report)
Public Sub PrintReport(hReport As Report, Optional MyPrinter As Printer)
Dim hSizeParse As TSizeParse
$hPrint = hReport.Clone()
$hPrint = hReport
'$hPrint = hReport.Clone()
If MyPrinter Then
hPrinter = MyPrinter
Else
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 = hSizeParse.ToCm() / 10
hPrinter.PaperWidth = hSizeParse.ToCm() * 10
hSizeParse = New TSizeParse($hPrint.Height)
hPrinter.PaperHeight = hSizeParse.ToCm() / 10
hPrinter.PaperHeight = hSizeParse.ToCm() * 10
Endif
If Not hPrinter.Configure() Then
If Not MyPrinter Then
If Not hPrinter.Configure() Then
hPrinter.Print
Endif
Else
hPrinter.Print
Endif
End
Public Sub Printer_Draw()

View file

@ -31,9 +31,9 @@ Public Sub _new()
$hReport.Resolution = Printer1.Resolution
If $hReport.Paper = Printer.Custom Then
hSizeInt = New TSizeParse($hReport.Width)
Printer1.PaperWidth = hSizeInt.ToCm() / 10
Printer1.PaperWidth = hSizeInt.ToCm() * 10
hSizeInt = New TSizeParse($hReport.Height)
Printer1.PaperHeight = hSizeInt.ToCm() / 10
Printer1.PaperHeight = hSizeInt.ToCm() * 10
Endif
'Debug Printer1.Orientation;; Printer1.PaperWidth;; Printer1.PaperHeight

View file

@ -0,0 +1,35 @@
' Gambas class file
Public Sub Form_Open()
Dim hprinter As New Printer
Dim sPrinter As String
For Each sPrinter In Printer.List
ListView1.Add(sPrinter, sPrinter, IIf(sPrinter = Printer.Default, Picture["icon:/16/ok"], Picture["icon:/16/printer"]))
If sPrinter = Printer.Default Then ListView1[sPrinter].RichText = "<b>" & sPrinter & "</b>"
Next
' hprinter.ReverseOrder
' hprinter.FullPage
' hprinter.GrayScale
' hprinter.CollateCopies
' hprinter.FirstPage
' hprinter.LastPage
' hprinter.NumCopies
' hprinter.Orientation
' hprinter.Page
' hprinter.OutputFile
' hprinter.Paper
' hprinter.PaperHeight
' hprinter.PaperWidth
' hprinter.ReverseOrder
End
Public Sub Panel6_Show()
Me.Refresh
End

View file

@ -0,0 +1,132 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,81,67)
Text = ("Printer Config")
Resizable = False
Arrangement = Arrange.Horizontal
AutoResize = True
Spacing = True
Margin = True
{ Panel3 VBox
MoveScaled(3,4,53,60)
Expand = True
AutoResize = True
Spacing = True
Padding = 20
{ ListView1 ListView
MoveScaled(0,0,52,20)
}
{ Panel6 Expander
MoveScaled(1,21,51,37)
Text = ("More...")
Hidden = True
{ Panel7 VBox
MoveScaled(1,2,44,32)
Spacing = True
Padding = 20
{ HBox3 HBox
MoveScaled(1,2,50,4)
{ Label8 Label
MoveScaled(1,1,18,3)
Text = ("Range")
}
{ Panel10 Panel
MoveScaled(15,1,12,3)
Expand = True
}
{ TextBox1 TextBox
MoveScaled(19,0,22,4)
}
}
{ HBox1 HBox
MoveScaled(2,8,50,4)
{ Label1 Label
MoveScaled(1,1,18,3)
Text = ("RectoVerso")
}
{ Panel5 Panel
MoveScaled(15,1,12,3)
Expand = True
}
{ ComboBox1 ComboBox
MoveScaled(20,1,18,3)
ReadOnly = True
List = [("None"), ("Long side"), ("Short side")]
}
}
{ HBox2 HBox
MoveScaled(2,13,50,4)
{ Label3 Label
MoveScaled(1,1,18,3)
Text = ("Paper")
}
{ Panel8 Panel
MoveScaled(15,1,12,3)
Expand = True
}
{ cmbPaper ComboBox
MoveScaled(20,1,18,3)
ReadOnly = True
List = [("None"), ("Long side"), ("Short side")]
}
}
{ Panel9 Panel
MoveScaled(2,19,40,11)
Border = Border.Etched
{ Label4 Label
MoveScaled(1,1,13,3)
Text = ("Width")
}
{ Label5 Label
MoveScaled(23,1,13,3)
Text = ("Height")
}
{ SpinBox2 SpinBox
MoveScaled(1,4,13,4)
}
{ SpinBox3 SpinBox
MoveScaled(23,4,13,4)
}
{ Label6 Label
MoveScaled(14,4,4,4)
Text = ("mm")
}
{ Label7 Label
MoveScaled(36,4,4,4)
Text = ("mm")
}
}
}
}
}
{ Separator1 Separator
MoveScaled(58,4,1,16)
}
{ Panel1 VBox
MoveScaled(61,6,17,45)
{ Button1 Button
MoveScaled(0,0,16,16)
Picture = Picture["icon:/64/printer"]
}
{ Panel4 Panel
MoveScaled(1,16,14,5)
}
{ Label2 Label
MoveScaled(1,21,10,2)
Text = ("Copies :")
}
{ SpinBox1 SpinBox
MoveScaled(0,23,16,4)
}
{ Panel2 Panel
MoveScaled(2,30,12,6)
Expand = True
}
{ Button2 Button
MoveScaled(2,38,15,5)
Text = Shortcut(("Cancel"), "C")
Picture = Picture["icon:/22/cancel"]
}
}
}

View file

@ -33,7 +33,10 @@ Private $iCurSection As Integer
Private $iCurPage As Integer = -1
Private $iPaper As Integer = 2
Private $iOrientation As Integer
' Private $hPrinter As New Printer As "Printer"
' Property Read Printer As Printer
Property Resolution As Integer
Property Scale As Float
Property Read PageCount As Integer
@ -317,55 +320,55 @@ Public Function Preview()
End
Public Function Image(Value As String, X As String, Y As String) As ReportBrush
' Public Function Image(Value As String, X As String, Y As String) As ReportBrush
'
' Dim hBrush As New ReportBrush
'
' hBrush._Type = 1
' hBrush._X = New TSizeParse(X)
' hBrush._Y = New TSizeParse(Y)
' hBrush._Image = Image.Load(Value)
' Return hBrush
'
' End
'
' Public Function LinearGradient(Colors As Integer[], Positions As Float[]) As ReportBrush
'
' Dim hBrush As New ReportBrush
'
' hBrush._Type = 2
' 'hBrush.X = MRTools.ScanValue(X)
' 'hBrush.Y = MRTools.ScanValue(Y)
'
' hBrush._Color = Colors
' hBrush._Pos = Positions
' Return hBrush
'
' End
Dim hBrush As New ReportBrush
' Public Function RadialGradient(Colors As Integer[], Positions As Float[]) As ReportBrush
'
' Dim hBrush As New ReportBrush
'
' hBrush._Type = 3
' 'hBrush.X = MRTools.ScanValue(X)
' 'hBrush.Y = MRTools.ScanValue(Y)
'
' hBrush._Color = Colors
' hBrush._Pos = Positions
' Return hBrush
'
' End
hBrush._Type = 1
hBrush._X = New TSizeParse(X)
hBrush._Y = New TSizeParse(Y)
hBrush._Image = Image.Load(Value)
Return hBrush
End
Public Function LinearGradient(Colors As Integer[], Positions As Float[]) As ReportBrush
Dim hBrush As New ReportBrush
hBrush._Type = 2
'hBrush.X = MRTools.ScanValue(X)
'hBrush.Y = MRTools.ScanValue(Y)
hBrush._Color = Colors
hBrush._Pos = Positions
Return hBrush
End
Public Function RadialGradient(Colors As Integer[], Positions As Float[]) As ReportBrush
Dim hBrush As New ReportBrush
hBrush._Type = 3
'hBrush.X = MRTools.ScanValue(X)
'hBrush.Y = MRTools.ScanValue(Y)
hBrush._Color = Colors
hBrush._Pos = Positions
Return hBrush
End
Public Sub {Color}(iColor As Integer) As ReportBrush
Dim hBrush As New ReportBrush
hBrush._Type = 0
hBrush._iValue = iColor
Return hBrush
End
' Public Sub {Color}(iColor As Integer) As ReportBrush
'
' Dim hBrush As New ReportBrush
'
' hBrush._Type = 0
' hBrush._iValue = iColor
' Return hBrush
'
' End
Public Sub Refresh()
@ -686,9 +689,12 @@ Private Sub Orientation_Write(Value As Integer)
End
Public Sub Print()
Public Sub Print(Optional hPrinter As Printer)
If hPrinter Then
CPrint.PrintReport(Me, hPrinter)
Else
CPrint.PrintReport(Me)
Endif
End
@ -746,3 +752,16 @@ Public Sub _Reset()
$iPageCount = 0
End
' Private Function Printer_Read() As Printer
'
' Return $hPrinter
'
' End
' Public Sub Print2()
'
' _Reset
'
' End

View file

@ -211,7 +211,7 @@ Static Public Function RadialGradient(X As Float, Y As Float, Radius As Float, X
Return hBrush
End
Static Public Function ImageBrush(hImage As Image) As ReportBrush
Static Public Function Image(hImage As Image) As ReportBrush
Dim hBrush As New ReportBrush
hBrush._Image = hImage

View file

@ -694,7 +694,8 @@ Private Sub SetVChildGeometry(X As Float, Y As Float, W As Float, H As Float, Co
bForceNewPage = False
hchild._DataIndex = j
If Not bForceNewPage Then bExitLoop = True
'If Not bForceNewPage Then
bExitLoop = True
Break
Endif
@ -741,10 +742,18 @@ Private Sub SetVChildGeometry(X As Float, Y As Float, W As Float, H As Float, Co
'On prévoie un sortie de boucle si l'enfant demande un affichage 1 par page
If hchild.ForceNewPage Then bForceNewPage = True
Loop
'Next '## fin de la boucle de répétition
'Si la sortie anticipé est demandée alors on sort de la boucle
If bExitLoop Then Break
If i < Me.Children.Max Then
If Me.Children[i + 1] Is ReportPageBreak Then
bForceNewPage = True
Inc Me._CurItem
Inc i
Endif
Endif
'Tout les objets on été répété alors on remet l'index à 0
'hchild._DataIndex = 0
'On incrémente le compteur des éléments traités
@ -1085,7 +1094,8 @@ Private Function _Index_Read() As Integer
End
Private Sub _Index_Write(Value As Integer)
'If Super._Index = Value Then Return
If Super._Index = Value And If Super._Index > 0 Then Return
$bIndexChange = True
Super._Index = Value

View file

@ -74,18 +74,19 @@ Public Sub _GetSizeHints((AvailableW) As Float, (AvailableH) As Float, (TotalWid
sText = $sText
Endif
If $fAngle = 0.0 Then
'hExt = Paint.TextExtents(sText)
hRect = Paint.TextSize(sText)
fTextWidth = Me.Padding._Left + Me.Border._Left + MTools.PixelsToUnitspaint(hRect.Width) + Me.Padding._Right + Me.Border._Right
fTextWidth = Me.Padding._Left + Me.Border._Left + MTools.PixelsToUnitsPaint(hRect.Width) + Me.Padding._Right + Me.Border._Right
fTextHeight = MTools.PixelsToUnitsPaint(hRect.Height) + Me.Padding._Top + Me.Padding._Bottom + Me.Border._Top + Me.Border._Bottom
'Debug Paint.Font.Height * Paint.ResolutionX / Desktop.Resolution
Else
Paint.Save
Paint.Rotate($fAngle)
Paint.Text(sText, 0, 0)
Paint.Rotate(Rad($fAngle))
fTextWidth = Me.Padding._Left + Me.Border._Left + MTools.PixelsToUnits(Paint.PathExtents.Width) + Me.Padding._Right + Me.Border._Right
fTextHeight = MTools.PixelsToUnits(Paint.PathExtents.Height) + Me.Padding._Top + Me.Padding._Bottom + Me.Border._Top + Me.Border._Bottom
hExt = Paint.PathExtents
fTextWidth = Me.Padding._Left + Me.Border._Left + MTools.PixelsToUnitsPaint(hExt.Width) + Me.Padding._Right + Me.Border._Right
fTextHeight = MTools.PixelsToUnitsPaint(hExt.Height) + Me.Padding._Top + Me.Padding._Bottom + Me.Border._Top + Me.Border._Bottom
Paint.Restore
Endif
hMyHints.Height = Max(hMyHints.Height, fTextHeight)
@ -145,7 +146,7 @@ Public Sub _Paint((Page) As Integer, (X) As Float, (Y) As Float, (hControl) As T
Paint.Text(sTempText, iX, iY, iW, iH, $iAlignment)
Else
Paint.Translate(iX + iW / 2, iY + iH / 2)
Paint.Rotate(Rad($fAngle))
Paint.Rotate($fAngle)
Paint.Translate(- (iX + iW / 2), - (iY + iH / 2))
Paint.Text(sTempText, iX, iY, iW, iH, Align.Center)

View file

@ -0,0 +1,6 @@
' Gambas class file
Export
Inherits ReportControl
Public Const _Properties As String = "-*"

View file

@ -22,32 +22,41 @@
Background = ReportBrush["#FFFF00"]
}
}
{ ReportLabel1 ReportLabel
#MoveScaled(2,9,59,8)
{ ReportPageBreak1 ReportPageBreak
#MoveScaled(5,10,60,5)
}
{ ReportLabel1 ReportImage
#MoveScaled(1,12,59,8)
Height = "7cm"
Border = ReportBorder["Bottom:2mm #000000"]
Background = ReportBrush["#00FF00"]
}
{ ReportLabel2 ReportLabel
#MoveScaled(2,14,59,8)
#MoveScaled(2,18,59,8)
Height = "2cm"
Border = ReportBorder["Bottom:2mm #000000"]
Background = ReportBrush["LinearGradient(1,0,0.28,0.35,[#00FF00,#FFFFFF],[0,1])"]
}
{ ReportLabel4 ReportLabel
{ ReportLabel4 ReportImage
#MoveScaled(3,23,59,8)
Height = "6cm"
Border = ReportBorder["Bottom:2mm #000000"]
Background = ReportBrush["#00FF00"]
}
{ ReportPageBreak2 ReportPageBreak
#MoveScaled(2,31,59,2)
}
{ ReportLabel5 ReportLabel
#MoveScaled(2,33,59,8)
Height = "2cm"
Border = ReportBorder["Bottom:2mm #000000"]
Background = ReportBrush["#00FF00"]
}
{ ReportPageBreak3 ReportPageBreak
#MoveScaled(2,42,58,3)
}
{ ReportLabel3 ReportLabel
#MoveScaled(2,42,59,8)
#MoveScaled(1,44,59,8)
Height = "2cm"
Border = ReportBorder["Bottom:2mm #000000"]
Background = ReportBrush["#00FF00"]

View file

@ -24,7 +24,10 @@ Public Sub ReportLabel1_Data(Index As Integer)
End
Public Sub ReportPanel1_BeforeData()
If hResult1.Max < ReportPanel1.DataIndex Then
Print "error" & ReportPanel1.DataIndex
Return
Endif
hResult1.MoveTo(ReportPanel1.dataindex)
Print "BeforeData = " & hResult1!firstname
hResult2 = db.Exec("Select * From test where firstname=&1 LIMIT 1,20", hResult1!firstname)

View file

@ -31,7 +31,7 @@
Tag = "Boite 1"
Spacing = "1cm"
{ ReportPanel1 ReportVBox
#MoveScaled(1,3,64,45)
#MoveScaled(7,3,64,45)
Width = "4cm"
Height = "5cm"
AutoResize = True

View file

@ -41,7 +41,7 @@
}
}
{ ReportVBox3 ReportVBox
#MoveScaled(37,2,34,16)
#MoveScaled(38,1,34,20)
Padding = ReportPadding["Top:4mm;Bottom:4mm;Left:4mm;Right:4mm"]
Expand = True
AutoResize = True

View file

@ -6,7 +6,7 @@
Padding = ReportPadding["Top:20mm;Bottom:10mm;Left:20mm;Right:20mm"]
Ignore = True
AutoResize = True
Paper = Printer.Letter
Orientation = Printer.Landscape
Index = 0
Text = ("")
{ ReportHBox1 ReportHBox

View file

@ -0,0 +1,8 @@
' Gambas class file
Public Sub _new()
'Report.Debug = True
Me.Width = "5cm"
Me.Height = "10cm"
End

View file

@ -0,0 +1,16 @@
# Gambas Form File 3.0
{ Report Report
#MoveScaled(0,0,64,64)
Index = 0
Text = ("")
{ ReportLabel1 ReportLabel
#MoveScaled(22,13,7,41)
Font = Font["Bold,+4"]
AutoResize = True
Border = ReportBorder["Top:1px #000000;Bottom:1px #000000;Left:1px #000000;Right:1px #000000"]
Text = ("Test")
Rotate = 1.57
}
Index = 0
}

View file

@ -1,19 +1,9 @@
' Gambas module file
' Public Sub Main()
Public Sub Main()
'
' 'Dim hReport As New Report11
' Dim hLabel As ReportLabel
' 'hReport.Padding = ReportPadding["2cm"]
' '
' ' hLabel = New ReportLabel(hReport)
' ' 'hLabel.Padding = ReportPadding["1mm"]
' '
' ' hLabel.Border.Width = "1mm"
' ' hLabel.Text = "coucou"
' ' hLabel.Autoresize = True
' '
' ' hReport.Preview
' hReport.Print
'
' End
Dim hreport As New Report9
Dim hprinter As New Printer
hprinter.OutputFile = User.Home &/ "sortie.pdf"
hreport.Print(hprinter)
End

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB