From b6d3061790508cd6c72392be5c9d86740a558097 Mon Sep 17 00:00:00 2001 From: Fabien Bodard Date: Mon, 29 Mar 2010 12:21:26 +0000 Subject: [PATCH] [GB.REPORT] * NEW: Complete change of the way that label get datas Now you just give to the container to repeat a collection[] or a result and to the label a key and all will simply be done. The Container_data and Label_data events are removed, the label.index property and the container.repeat property are removed too git-svn-id: svn://localhost/gambas/trunk@2842 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- comp/src/gb.report/.info | 36 +-- comp/src/gb.report/.project | 1 + comp/src/gb.report/.src/Report.class | 2 +- comp/src/gb.report/.src/ReportContainer.class | 295 +++++++----------- comp/src/gb.report/.src/ReportLabel.class | 63 ++-- comp/src/gb.report/.src/Tests/Report1.class | 35 ++- comp/src/gb.report/.src/Tests/Report1.report | 77 ++--- comp/src/gb.report/.src/Tests/Report2.class | 21 +- comp/src/gb.report/.src/Tests/Report2.report | 96 +++++- 9 files changed, 320 insertions(+), 306 deletions(-) diff --git a/comp/src/gb.report/.info b/comp/src/gb.report/.info index 75a4ba7bf..1f0b06ce4 100644 --- a/comp/src/gb.report/.info +++ b/comp/src/gb.report/.info @@ -198,7 +198,7 @@ Container _Properties C s -*,Spacing{ReportCoord},Repeat=False +*,Spacing{ReportCoord} _DefaultEvent C s @@ -215,9 +215,9 @@ Spacing p s -Repeat +Data p -b +o _Spacing r @@ -259,10 +259,6 @@ _GenerateClones m -_GetData -m -b -(iIndex)i _SetChildGeometry m f @@ -271,6 +267,10 @@ _GetSizeHints m TSizeHint (AvailableW)f(AvailableH)f(TotalWidth)f(TotalHeight)f +_GetData +m +v +(sKey)s #ReportControl @@ -493,11 +493,7 @@ C _Properties C s -*,Text,Alignment{Align.*} -_DefaultEvent -C -s -Data +*,Text,Key,Format,Alignment{Align.*} Text p s @@ -510,17 +506,13 @@ IsSpecial p b -Index -r -i - -:Data -: - - -_New -m +Key +p +s +Format +p +s _GetSizeHints m diff --git a/comp/src/gb.report/.project b/comp/src/gb.report/.project index 424928b16..4b5bb02ab 100644 --- a/comp/src/gb.report/.project +++ b/comp/src/gb.report/.project @@ -8,6 +8,7 @@ VersionProgram=gbx3 -V Component=gb.image Component=gb.gui Component=gb.form +Component=gb.db Component=gb.report Description="Report engine for gambas" Authors="Fabien Bodard" diff --git a/comp/src/gb.report/.src/Report.class b/comp/src/gb.report/.src/Report.class index bd6b1f046..b17450ee0 100644 --- a/comp/src/gb.report/.src/Report.class +++ b/comp/src/gb.report/.src/Report.class @@ -59,7 +59,7 @@ End Public Sub Layout() - + Print "layout" 'Set execution Flag to true _bInExec = True 'If $sOldDeviceName = Paint.Device.Name Then Return diff --git a/comp/src/gb.report/.src/ReportContainer.class b/comp/src/gb.report/.src/ReportContainer.class index ce0f74a86..9394eebf9 100644 --- a/comp/src/gb.report/.src/ReportContainer.class +++ b/comp/src/gb.report/.src/ReportContainer.class @@ -6,9 +6,9 @@ Inherits ReportFrame Public Const _IsContainer As Boolean = True Public Const _Group As String = "Container" -Public Const _Properties As String = "*,Spacing{ReportCoord},Repeat=False" +Public Const _Properties As String = "*,Spacing{ReportCoord}" Public Const _DefaultEvent As String = "Data" - +Private $bDataIsResult As Boolean Public _Arrangement As Integer @@ -21,12 +21,11 @@ Private $aChildCopy As TControl[] ' Private $iCount As Integer ' Private $bStopRepeat As Boolean Private $iIndex As Integer - +Private $hData As Object Property Read Children As TControl[] Property Read Index As Integer Property Spacing As String -Property {Repeat} As Boolean - +Property Data As Object Property Read _Spacing As Float Property Read _RelativeSpacing As Boolean @@ -90,8 +89,8 @@ Public Sub _ClipChildren(Page As Integer, X As Float, Y As Float, hControl As TC Dim hChild As TControl Dim vi As Integer - Dim hExt As PaintExtents - Dim fFrameWidth As Float + 'Dim hExt As PaintExtents + 'Dim fFrameWidth As Float Dim CX1, CX2, CY1, CY2 As Float Dim hCont As ReportContainer @@ -116,7 +115,7 @@ Public Sub _ClipChildren(Page As Integer, X As Float, Y As Float, hControl As TC 'reset the Painting flag hChild._SkipPainting = False 'Test the painting Position - 'fFrameWidth = hChild.Ctrl._FrameWidth + If Not Paint.Device Is Printer And If CX2 > CX1 And If CY2 > CY1 Then If (X + hChild.RealLeft) > CX2 Then hChild._SkipPainting = True @@ -152,35 +151,11 @@ Public Sub _ClipChildren(Page As Integer, X As Float, Y As Float, hControl As TC End -' -' Public Sub _PaintBefore(Page As Integer, X As Float, Y As Float, hControl As TControl, VirtualId As Integer) -' -' Dim hChild As TControl -' Dim vi As Integer -' Dim hExt As PaintExtents -' Dim fFrameWidth As Float -' -' Super._PaintBefore(Page, X, Y, hControl, VirtualId) -' -' X += hControl.RealLeft -' Y += hControl.RealTop -' -' For Each hChild In Me.Children -' If hChild._SkipPainting Then Continue -' -' vi = VirtualId -' If hControl.VirtualId > -1 Then vi = hControl.VirtualId -' -' hChild.Ctrl._PaintBefore(Page, X, Y, hChild, vi) -' -' Next -' -' End Public Sub _Paint(Page As Integer, X As Float, Y As Float, hControl As TControl, VirtualId As Integer) Dim hChild As TControl - Dim vi As Integer + 'Dim vi As Integer X += hControl.RealLeft Y += hControl.RealTop @@ -191,34 +166,16 @@ Public Sub _Paint(Page As Integer, X As Float, Y As Float, hControl As TControl, Inc MTools.DrawCount - vi = VirtualId - If hControl.VirtualId > -1 Then vi = hControl.VirtualId + 'vi = VirtualId + $iIndex = VirtualId + If hControl.VirtualId > -1 Then $iIndex = hControl.VirtualId - hChild.Ctrl._Paintframe(Page, X, Y, hChild, vi) + hChild.Ctrl._Paintframe(Page, X, Y, hChild, $iIndex) Next End -' Public Sub _PaintAfter(Page As Integer, X As Float, Y As Float, hControl As TControl, VirtualId As Integer) -' -' Dim hChild As TControl -' Dim vi As Integer -' -' Super._PaintAfter(Page, X, Y, hControl, VirtualId) -' -' X += hControl.RealLeft -' Y += hControl.RealTop -' -' For Each hChild In Me.Children -' If hChild._SkipPainting Then Continue -' 'Draw After -' hChild.Ctrl._PaintAfter(Page, X, Y, hChild, vi) -' Next -' -' End - - Private Function _Spacing_Read() As Float @@ -226,11 +183,6 @@ Private Function _Spacing_Read() As Float End -' ' PRIVATE FUNCTION _Padding_Read() AS Float -' ' -' ' RETURN $fPadding -' ' -' END Private Function _RelativeSpacing_Read() As Boolean @@ -252,20 +204,8 @@ Public Sub _SetUnifiedValues() hChild.Ctrl._SetUnifiedValues() Next - End -Private Function Repeat_Read() As Boolean - - Return $bRepeat - -End - -Private Sub Repeat_Write(Value As Boolean) - - $bRepeat = Value - -End Public Sub _GenerateClones() @@ -277,42 +217,49 @@ Public Sub _GenerateClones() Dim bRaiseRet As Boolean - - If IsNull($aChildCopy) Then - $aChildCopy = $aChild.Copy() - Else - $aChild = $aChildCopy.Copy() - Endif - - For Each hTc In $aChildCopy - If hTc.Ctrl Is ReportContainer Then - hCont = hTc.Ctrl - If hCont.Repeat Then - aNewChild = New TControl[] - i = 0 - Do - Inc i - hNewTControl = New TControl - hNewTControl.Ctrl = hTc.Ctrl - hNewTControl.VirtualId = i - aNewChild.Add(hNewTControl) - - bRaiseRet = hCont._GetData(i) - If bRaiseRet Then Break - Loop - $aChild = $aChild.Insert(aNewChild, $aChild.Find(hTc)) - $aChild.Remove($aChild.Find(hTc)) + If IsNull($aChildCopy) Then + $aChildCopy = $aChild.Copy() + Else + $aChild = $aChildCopy.Copy() + Endif + + + For Each hTc In $aChildCopy + If hTc.Ctrl Is ReportContainer Then + hCont = hTc.Ctrl + If hCont.Data Then + aNewChild = New TControl[] + 'i = 0 + For i = 0 To hCont.Data.Count - 1 + 'Inc i + hNewTControl = New TControl + hNewTControl.Ctrl = hTc.Ctrl + hNewTControl.VirtualId = i + aNewChild.Add(hNewTControl) + Next + $aChild = $aChild.Insert(aNewChild, $aChild.Find(hTc)) + $aChild.Remove($aChild.Find(hTc)) + + Endif + hCont._GenerateClones Endif - hCont._GenerateClones - Endif - Next + Next + ' Else + ' 'if no data array is set + ' For Each hTc In $aChild + ' If hTc.Ctrl Is ReportContainer Then + ' hcont = hTc.Ctrl + ' hCont._GenerateClones + ' Endif + ' Next + ' + ' Endif End - Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float, ContPage As Integer) As Float Dim hChildHints As TSizeHint Dim hChild As TControl @@ -334,32 +281,29 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float If _Arrangement = Arrange.Vertical Then - fSpc = IIf(Me._RelativeSpacing, H * Me._Spacing / 100, Me._Spacing) 'ME._Spacing fPdg = Me._Padding - - - + X = fPdg Y = fPdg W -= fPdg * 2 H -= fPdg * 2 tmpX = X - + 'Calcul des zone libres pour l'extention et 'repartition des controles par pages - + For Each hChild In Me.Children - + hChildHints = hChild.ctrl._GetSizeHints(W, H - fSExp, W, H) - + If hChild.Ctrl.Ignore Then aIgnored.Add(hchild) Continue Endif - + If hChild.ctrl.Expand Then Inc iNExp - + If fSExp + hChildHints.Height > H And Not Me Is Report Then fSExp -= fSpc aPageItems.SExp = H - fsExp @@ -368,18 +312,18 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float aPageItems = New CPageInfo fsExp = 0 iNExp = 0 - + Endif - + fSExp += hChildHints.Height - + hChild.RelPage = aPage.Count hChild.RealPage = ContPage + aPage.Count aPageItems.Children.Add(hChild) fSExp += fSpc Next - fSExp -= fSpc '* 2 ' * iNExp + fSExp -= fSpc fSExp = H - fSExp aPage.Add(aPageItems) aPageItems.SExp = fSExp @@ -395,19 +339,13 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float X = fPdg Y = fPdg - 'W -= fPdg * 2 - 'H -= fPdg * 2 + bFirst = True For Each hChild In aPage[i].Children If hchild.Ctrl.Ignore Then Continue hChildHints = hChild.ctrl._GetSizeHints(W, H - Y, W, H) - ' PRINT Object.Class(hChild) - ' PRINT W, H - Y - ' PRINT hChildHints.Width, hChildHints.Height - - - + If Not bFirst Then Y += fSpc Endif @@ -422,14 +360,6 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float iPage = iPage + hChild._SetGeometry(X, Y, W, fH) - ' If Left(hchild.ctrl.tag, 1) = "*" Then - ' - ' ' PRINT "SetGeometry(" & X & ", " & Y & ", " & W & ", " & fH & ")" - ' ' PRINT hChild.RealTop - ' ' PRINT "page sexp:" & aPage[i].sExp, aPage[i].Nexp - ' ' PRINT hChildHints.Height - ' ' PRINT H - ' End If Y += fH Next @@ -455,8 +385,6 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float fSpc = IIf(Me._RelativeSpacing, W * Me._Spacing / 100, Me._Spacing) 'ME._Spacing fPdg = Me._Padding - - 'SUPER._SetGeometry(X, Y, W, H) X = fPdg Y = fPdg @@ -482,7 +410,6 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float bFirst = True - For Each hChild In Me.Children If hChild.Ctrl.Ignore Then aIgnored.Add(hChild) @@ -523,8 +450,6 @@ Public Function _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float If _Arrangement = Arrange.Fill Then fPdg = Me._Padding - - 'SUPER._SetGeometry(X, Y, W, H) X = fPdg Y = fPdg @@ -550,9 +475,7 @@ End Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As Float, TotalHeight As Float) As TSizeHint - 'DIM aChildHints AS Integer[] Dim hChild As TControl - 'DIM iChildrenH AS Integer Dim fHeight As Float Dim hChildHints As TSizeHint Dim hMyHints As New TSizeHint @@ -568,15 +491,14 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As For Each hChild In Me.Children 'Obtention des volontées des enfants - 'PRINT "GetSizeHint : " & Object.Type(hchild.Ctrl) hChildHints = hChild.ctrl._GetSizeHints(AvailableW, AvailableH - hMyHints.Height, AvailableW, AvailableH) If Not hchild.Ctrl.Ignore Then hMyHints.Height += hChildHints.Height + fSpacing 'ME._Spacing If hMyHints.Width < hChildHints.Width Then hMyHints.Width = hChildHints.Width Next - hMyHints.Height -= fSpacing 'ME._Spacing + hMyHints.Height -= fSpacing hMyHints.Height += 2 * Me._Padding 'Je dit que moi je veux toute la largeur - fHeight = Me._Height 'MRTools.RealHeight(ME) + fHeight = Me._Height If hMyHints.Height < fHeight And Not Me.Autoresize Then hMyHints.Height = fHeight If Me._RelativeHeight Then hMyHints.Height = AvailableH * Me._Height / 100 @@ -584,11 +506,9 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As If Not Me.Autoresize Then If Me._RelativeWidth Then hMyHints.Width = AvailableW * Me._Width / 100 - hMyHints.Width = Me._Width 'MRTools.RealWidth(ME) + hMyHints.Width = Me._Width Endif - - 'hMyHints.Width += Me._BorderWidth - 'hMyHints.Height += Me._BorderWidth + Return hMyHints @@ -602,13 +522,13 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As fSpacing = IIf(Me._RelativeSpacing, TotalWidth * Me._Spacing / 100, Me._Spacing) For Each hChild In Me.Children - 'PRINT "GetSizeHint : " & Object.Type(hchild.Ctrl) + 'Obtention des volontées des enfants hChildHints = hChild.ctrl._GetSizeHints(AvailableW - hMyHints.Width, AvailableH, AvailableW, AvailableH) If Not hchild.Ctrl.Ignore Then hMyHints.Width += hChildHints.Width + fSpacing 'ME._Spacing If hMyHints.Height < hChildHints.Height Then hMyHints.Height = hChildHints.Height Next - hMyHints.Width -= fSpacing 'ME._Spacing + hMyHints.Width -= fSpacing hMyHints.Width += 2 * Me._Padding If Me._RelativeWidth Then hMyHints.Width = AvailableW * Me._Width / 100 'je veut ma hauteur ! @@ -617,8 +537,6 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As If Me._RelativeHeight Then hMyHints.Height = AvailableH * Me._Height / 100 Endif - 'hMyHints.Width += Me._BorderWidth - 'hMyHints.Height += Me._BorderWidth Return hMyHints Endif @@ -628,53 +546,30 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As '******************************* If _Arrangement = Arrange.Fill Then - 'For Each hChild In Me.Children - 'PRINT "GetSizeHint : " & Object.Type(hchild.Ctrl) - 'Obtention des volontées des enfants - 'hChildHints = hChild.ctrl._GetSizeHints(AvailableW - hMyHints.Width, AvailableH, AvailableW, AvailableH) - 'If Not hchild.Ctrl.Ignore Then hMyHints.Width += hChildHints.Width + fSpacing 'ME._Spacing - 'If hMyHints.Height < hChildHints.Height Then hMyHints.Height = hChildHints.Height hMyHints.Width = Me._Height hMyHints.Height = Me._Height - - 'Next - 'hMyHints.Width += Me._BorderWidth - 'hMyHints.Height += Me._BorderWidth + Return hMyHints Endif End -' Private Function GetChildPosition() As Integer -' -' If _Arrangement = Arrange.Horizontal Then -' -' -' -' Endif -' -' -' If _Arrangement = Arrange.Vertical Then -' -' -' Endif -' -' End -' Public Sub _StopRepeat() -' If Not Me.Repeat Then -' If Not (Me.id = $iReportId) Then Me.Parent._StopRepeat -' Return -' Endif -' $bStopRepeat = True -' -' End -Public Function _GetData(iIndex As Integer) As Boolean +Public Function _GetData(sKey As String) As Variant - Dim sRaiseRet As Boolean - $iIndex = iIndex - sRaiseRet = Raise Data - Return sRaiseRet + If $bDataIsResult Then + If $hData.Fields.Exist(sKey) Then + $hData.MoveTo($iIndex) + Return $hData[skey] + Endif + Else + If $hdata <> Null And If $hData[0].Exist(sKey) Then + Return $hdata[$iIndex][skey] + Endif + Endif + If Not Me.Parent Is Report Then Return Me.Parent._GetData(sKey) + + Return Null End Private Function Index_Read() As Integer @@ -682,3 +577,29 @@ Private Function Index_Read() As Integer Return $iIndex End + +Private Function Data_Read() As Object + + Return $hData + +End + +Private Sub Data_Write(Value As Object) + + If Not (Object.Type(Value) = "Collection[]") Then + If Object.Type(Value) = "Result" Then + $bDataIsResult = True + Else + Print Error.Text + $bDataIsResult = False + + Endif + If Not $bDataIsResult Then + Error.Raise(("You must give a Collecton[] object or a Result Object")) + Return + Endif + Endif + + $hData = Value + +End diff --git a/comp/src/gb.report/.src/ReportLabel.class b/comp/src/gb.report/.src/ReportLabel.class index 47ba0249d..c14cc0415 100644 --- a/comp/src/gb.report/.src/ReportLabel.class +++ b/comp/src/gb.report/.src/ReportLabel.class @@ -3,25 +3,20 @@ Export Inherits ReportFrame -Public Const _Properties As String = "*,Text,Alignment{Align.*}" -Public Const _DefaultEvent As String = "Data" +Public Const _Properties As String = "*,Text,Key,Format,Alignment{Align.*}" + Private $sText As String Private $iAlignment As Integer = Align.Normal Private $bIsSpecial As Boolean -Private $iIndex As Integer Private $bGetValueAuto As Boolean = True +Private $sKey As String +Private $sFormat As String Property Text As String Property Alignment As Integer Property IsSpecial As Boolean -Property Read Index As Integer +Property Key As String +Property {Format} As String -Event Data - -Public Sub _New() - - - -End Private Function Text_Read() As String @@ -31,9 +26,6 @@ End Private Sub Text_Write(Value As String) - If Not Me.Report._bInExec Then - $bGetValueAuto = False - Endif $sText = Value End @@ -58,11 +50,6 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As Dim hext As PaintExtents Dim bRaiseRes As Boolean Dim $sTempText As String - ' If Not $bGetValueAuto Then - ' bRaiseRes = Raise Data - ' $sTempText = AvailableW - ' 'Print bRaiseRes, Me.Text - ' Endif hMyHints.Height = Me._Height + (2 * Me._Padding) @@ -75,7 +62,7 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As hext = Paint.TextExtents($sText) - If $bGetValueAuto Then + If $sKey Then fTextWidth = AvailableW Else fTextWidth = MTools.PixelsToUnits(hext.Width) @@ -105,11 +92,13 @@ End Public Sub _Paint(Page As Integer, X As Float, Y As Float, hControl As TControl, VirtualId As Integer) - If $bGetValueAuto Then - $iIndex = VirtualId - Raise Data - + Dim sTempText As String + If $sKey Then + sTempText = Me.Parent._GetData($sKey) + Else + sTempText = $sText Endif + 'Draw.Foreground = Me.Foreground Paint.Brush = Paint.Color(Me.Border.Color) 'Set the Font if it is initialized @@ -119,9 +108,9 @@ Public Sub _Paint(Page As Integer, X As Float, Y As Float, hControl As TControl, 'Draw.Clip((x + hControl.RealLeft + MRTools.UnitsToPixels(Me.Padding)) * MRTools.ReportZoom, (y + hControl.RealTop + MRTools.UnitsToPixels(Me.Padding)) * MRTools.ReportZoom, hControl.RealWidth * MRTools.ReportZoom, hControl.RealHeight * MRTools.ReportZoom) 'Draw.Text($sText, (x + hControl.RealLeft + MRTools.UnitsToPixels(Me.Padding)) * MRTools.ReportZoom, (y + hControl.RealTop + MRTools.UnitsToPixels(Me.Padding)) * MRTools.ReportZoom, hControl.RealWidth * MRTools.ReportZoom, hControl.RealHeight * MRTools.ReportZoom, $iAlignment) - Paint.Text($sText, (x + hControl.RealLeft + MTools.UnitsToPixels(Me._Padding + Me._BorderWidth)), (y + hControl.RealTop + MTools.UnitsToPixels(Me._Padding)), hControl.RealWidth, hControl.RealHeight, $iAlignment) + Paint.Text(sTempText, (x + hControl.RealLeft + MTools.UnitsToPixels(Me._Padding + Me._BorderWidth)), (y + hControl.RealTop + MTools.UnitsToPixels(Me._Padding)), hControl.RealWidth, hControl.RealHeight, $iAlignment) Paint.Fill - If $bGetValueAuto Then $sText = Null + 'If $sKey Then $sText = Null 'Draw.Clip.Enabled = False End @@ -140,8 +129,26 @@ Private Sub IsSpecial_Write(Value As Boolean) End -Private Function Index_Read() As Integer +Private Function Key_Read() As String - Return $iIndex + Return $sKey + +End + +Private Sub Key_Write(Value As String) + + $sKey = Value + +End + +Private Function Format_Read() As String + + Return $sFormat + +End + +Private Sub Format_Write(Value As String) + + $sFormat = Value End diff --git a/comp/src/gb.report/.src/Tests/Report1.class b/comp/src/gb.report/.src/Tests/Report1.class index ee1383cb8..ee8f238e2 100644 --- a/comp/src/gb.report/.src/Tests/Report1.class +++ b/comp/src/gb.report/.src/Tests/Report1.class @@ -1,20 +1,29 @@ ' Gambas class file Private $i As Integer +Private cCol As New Collection[10] +Private cCol2 As New Collection[2] Public Sub _new() + Dim i As Integer + Dim c As Collection + + For i = 0 To 9 + c = New Collection + c["Index"] = i + c["Text"] = "Text " & i + + cCol[i] = c + Next + + For i = 0 To 1 + c = New Collection + c["FactIndex"] = "Facture " & i + + + cCol2[i] = c + Next + ReportHBox4.Data = cCol 'Report.debug = True + ReportVBox3.data = cCol2 End - - -Public Sub ReportLabel11_Data() - - Last.text = Last.index - -End - -Public Sub ReportHBox4_Data() - - If Last.index = 30 Then Stop Event - -End diff --git a/comp/src/gb.report/.src/Tests/Report1.report b/comp/src/gb.report/.src/Tests/Report1.report index 9bf66ed9e..8b7f3162c 100644 --- a/comp/src/gb.report/.src/Tests/Report1.report +++ b/comp/src/gb.report/.src/Tests/Report1.report @@ -45,13 +45,14 @@ } } { ReportVBox3 ReportVBox - #Move(6,246,714,282) + #Move(0,252,714,282) Expand = True { ReportLabel4 ReportLabel - #Move(6,0,684,42) + #Move(24,6,684,42) Height = "3 cm" Font = Font["+7"] Text = ("Facture") + Key = "FactIndex" Alignment = Align.Center } { ReportHBox3 ReportHBox @@ -93,42 +94,47 @@ Alignment = Align.Center } } - { ReportHBox4 ReportHBox - #Move(6,102,696,48) + { ReportVBox4 ReportVBox + #Move(12,114,696,42) AutoResize = True - Repeat = True - { ReportVBox4 ReportVBox - #Move(12,6,114,36) - Width = "3 cm" - Border = ReportBorder["0.5 mm,&H000000&,Left,Right"] - { ReportLabel11 ReportLabel - #Move(6,6,102,30) + { ReportHBox4 ReportHBox + #Move(0,0,696,36) + AutoResize = True + { ReportLabel10 ReportLabel + #Move(12,6,120,30) + Width = "3 cm" + Border = ReportBorder["0.5 mm,&H000000&,Left,Right"] + Text = ("ReportLabel10") + Key = "Index" + } + { ReportLabel11 ReportLabel + #Move(186,12,126,24) + Expand = True + Border = ReportBorder["0.5 mm,&H000000&,Right"] + Text = ("ReportLabel11") + Key = "Text" + } + { ReportLabel12 ReportLabel + #Move(336,12,120,24) + Width = "3 cm" + Border = ReportBorder["0.5 mm,&H000000&,Right"] + Text = ("ReportLabel12") + Key = "FactIndex" + } + { ReportLabel13 ReportLabel + #Move(468,6,120,30) + Width = "3 cm" + Border = ReportBorder["0.5 mm,&H000000&,Right"] + } + { ReportLabel14 ReportLabel + #Move(606,6,78,30) + Width = "3 cm" + Border = ReportBorder["0.5 mm,&H000000&,Right"] } - } - { ReportVBox5 ReportVBox - #Move(162,0,114,36) - Width = "3 cm" - Expand = True - Border = ReportBorder["0.5 mm,&H000000&,Right"] - } - { ReportVBox6 ReportVBox - #Move(312,6,114,36) - Width = "3 cm" - Border = ReportBorder["0.5 mm,&H000000&,Right"] - } - { ReportVBox7 ReportVBox - #Move(456,0,114,36) - Width = "3 cm" - Border = ReportBorder["0.5 mm,&H000000&,Right"] - } - { ReportVBox8 ReportVBox - #Move(570,0,114,36) - Width = "3 cm" - Border = ReportBorder["0.5 mm,&H000000&,Right"] } } { ReportHBox5 ReportHBox - #Move(-6,156,696,48) + #Move(6,204,696,48) Height = "1 cm" AutoResize = True { ReportVBox9 ReportVBox @@ -158,10 +164,5 @@ Border = ReportBorder["0.5 mm,&H000000&,Bottom,Right"] } } - { ReportLabel10 ReportLabel - #Move(84,240,420,24) - Border = ReportBorder["0.5 mm,&H000000&,Left,Right,Bottom"] - Text = ("ReportLabel10") - } } } diff --git a/comp/src/gb.report/.src/Tests/Report2.class b/comp/src/gb.report/.src/Tests/Report2.class index bc0dcfe07..0a43482d9 100644 --- a/comp/src/gb.report/.src/Tests/Report2.class +++ b/comp/src/gb.report/.src/Tests/Report2.class @@ -1,14 +1,13 @@ ' Gambas class file +Private hCon As New connection - -Public Sub ReportVBox1_Data() - - If Last.index = 5 Then Stop Event - -End - -Public Sub ReportLabel1_Data() - - Last.Text = Last.index - +Public Sub _new() + + Dim hresult As Result + 'Report.debug = True + hCon.Type = "mysql" + hCon.User = "root" + hCon.Name = "test" + hresult = db.Exec("SELECT * FROM test") + ReportHBox3.Data = hresult End diff --git a/comp/src/gb.report/.src/Tests/Report2.report b/comp/src/gb.report/.src/Tests/Report2.report index 104c45468..a3e5606db 100644 --- a/comp/src/gb.report/.src/Tests/Report2.report +++ b/comp/src/gb.report/.src/Tests/Report2.report @@ -2,13 +2,97 @@ { Report Report #Move(0,0,384,384) - { ReportVBox1 ReportVBox - #Move(18,18,354,42) + Padding = "2 cm" + { ReportLabel2 ReportLabel + #Move(54,6,264,36) Height = "5 cm" - Border = ReportBorder["1 mm,&H000000&,Left,Right,Bottom"] - Repeat = True - { ReportLabel1 ReportLabel - #Move(48,12,192,12) + Font = Font["+14"] + Text = ("Base de donnée de test") + Alignment = Align.Center + } + { ReportHBox1 ReportHBox + #Move(6,60,378,306) + AutoResize = True + { ReportVBox2 ReportVBox + #Move(6,54,18,60) + Expand = True + } + { ReportVBox1 ReportVBox + #Move(30,6,312,312) + AutoResize = True + Spacing = "1 mm" + { ReportHBox2 ReportHBox + #Move(12,96,264,36) + AutoResize = True + { ReportLabel3 ReportLabel + #Move(6,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.2 mm" + Border = ReportBorder["0.5 mm,&H000000&"] + Text = ("Name") + Alignment = Align.Center + } + { ReportLabel4 ReportLabel + #Move(84,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.2 mm" + Border = ReportBorder["0.5 mm,&H000000&,Right,Top,Bottom"] + Text = ("FirstName") + Alignment = Align.Center + } + { ReportLabel5 ReportLabel + #Move(174,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.2 mm" + Border = ReportBorder["0.5 mm,&H000000&,Right,Top,Bottom"] + Text = ("Birth") + Alignment = Align.Center + } + } + { ReportVBox4 ReportVBox + #Move(18,138,288,156) + AutoResize = True + Border = ReportBorder["0.5 mm,&H000000&,Top,Bottom"] + { ReportHBox3 ReportHBox + #Move(0,24,264,36) + AutoResize = True + { ReportLabel1 ReportLabel + #Move(12,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.1 mm" + Border = ReportBorder["0.5 mm,&H000000&,Right,Left"] + Text = ("ReportLabel1") + Key = "name" + } + { ReportLabel6 ReportLabel + #Move(99,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.1 mm" + Border = ReportBorder["0.5 mm,&H000000&,Right"] + Text = ("ReportLabel1") + Key = "firstname" + } + { ReportLabel7 ReportLabel + #Move(180,6,72,24) + Width = "5 cm" + Font = Font["12"] + Padding = "0.1 mm" + Border = ReportBorder["0.5 mm,&H000000&,Right"] + Text = ("ReportLabel1") + Key = "birth" + Alignment = Align.Right + } + } + } + } + { ReportVBox3 ReportVBox + #Move(348,60,24,66) + Expand = True } } }