[GB.REPORT]

* NEW: ReportVPanel widget and arrange.Column arrange controls in columns
* BUG: Layout now correctly reset dataindex



git-svn-id: svn://localhost/gambas/trunk@4282 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2011-12-17 20:25:27 +00:00
parent 7fc02a9d07
commit 63e7d518bc
10 changed files with 243 additions and 47 deletions

View file

@ -64,6 +64,10 @@ Vertical
C
i
2
Column
C
i
4
Fill
C
i
@ -733,29 +737,6 @@ _GetActualBrush
m
PaintBrush
(X1)i(Y1)i(X2)i(Y2)i
#ReportDrawingArea
ReportFrame
C
:Draw
:
_Properties
C
s
*
_Similar
C
s
ReportImage
_DefaultEvent
C
s
Draw
_Paint
m
(Page)i(X)f(Y)f(hControl)TControl;(VirtualId)i
#ReportFrame
ReportControl
@ -1016,7 +997,7 @@ C
_Properties
C
s
*,Arrangement{Arrange.None;Vertical;Horizontal;Fill}=Vertical
*,Arrangement{Arrange.None;Vertical;Horizontal;Column;Fill}=Vertical
_Similar
C
s
@ -1125,6 +1106,25 @@ _Free
m
#ReportVPanel
ReportContainer
C
_Properties
C
s
*
_Similar
C
s
ReportVBox
_new
m
_Free
m
#_ReportBorderSide
C

View file

@ -7,7 +7,6 @@ ReportBorder
ReportBrush
ReportContainer
ReportControl
ReportDrawingArea
ReportFrame
ReportHBox
ReportImage
@ -19,4 +18,5 @@ ReportSection
ReportSvgImage
ReportTextLabel
ReportVBox
ReportVPanel
_ReportBorderSide

View file

@ -5,4 +5,5 @@ Export Optional
Public Const {None} As Integer = 0
Public Const {Horizontal} As Integer = 1
Public Const {Vertical} As Integer = 2
Public Const {Column} As Integer = 4
Public Const {Fill} As Integer = 5

View file

@ -275,10 +275,10 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As
Case Arrange.Vertical
Return GetVSizeInt(AvailableW, AvailableH, TotalWidth, TotalHeight)
Case Arrange.Horizontal
Return GetHSizeInt(AvailableW, AvailableH, TotalWidth, TotalHeight)
Case Arrange.Column
Return GetCSizeInt(AvailableW, AvailableH, TotalWidth, TotalHeight)
Case Arrange.Fill, Arrange.None
Return Super._GetSizeHints(AvailableW, AvailableH, TotalWidth, TotalHeight)
'hMyHints.Height = AvailableH
@ -388,6 +388,27 @@ Private Function GetVSizeInt(AvailableW As Float, AvailableH As Float, TotalWidt
End
Private Function GetCSizeInt(AvailableW As Float, AvailableH As Float, TotalWidth As Float, TotalHeight As Float) As TSizeHint
Dim hSizeInt As New TSizeHint
Dim htmpInts As TSizeHint
Dim hChild As ReportControl ''Enfants
Dim fHeight, fSpacing, fWidth As Float
Dim i, j As Integer
Dim bExitLoop As Boolean
'D'abord utiliser la méthode du controle pour définir la taille
hSizeInt = Super._GetSizeHints(AvailableW, AvailableH, TotalWidth, TotalHeight)
'On ne peut pas dépasser la taille disponible (report sur prochaine page)
hSizeInt.Height = Min(hSizeInt.Height, AvailableH)
Me._SizeInt = hSizeInt
Return hSizeInt
End
Public Function _GetData(sKey As String) As Variant
If $bDataIsResult Then
@ -438,6 +459,7 @@ Public Sub _Reset()
Dim hChild As ReportControl
Me._CurItem = 0
Me._DataIndex = 0
Me._PageChildren.Clear
For Each hChild In Me.Children
@ -457,6 +479,8 @@ Public Sub _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float, Con
SetVChildGeometry(X, Y, W, H, ContPage, bInFixed)
Case Arrange.Horizontal
SetHChildGeometry(X, Y, W, H, ContPage, bInFixed)
Case Arrange.Column
SetCChildGeometry(X, Y, W, H, ContPage, bInFixed)
Case Arrange.Fill
SetFChildGeometry(X, Y, W, H, ContPage, bInFixed)
Case Arrange.None
@ -465,6 +489,142 @@ Public Sub _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float, Con
End
Private Sub SetCChildGeometry(X As Float, Y As Float, W As Float, H As Float, ContPage As Integer, bInFixed As Boolean)
Dim aPageItems As New TControl[] ''Éléments contenu par cette page
Dim aPageColumns As New TControl[][]
Dim aPageColumn As New TControl[]
Dim aColX As New Float[]
Dim hChildHints As TSizeHint ''Besoins en hauteur/largeur de l'enfant
Dim hChild As ReportControl ''Un enfant reportcontrol
Dim oChild As Object
Dim TH, fHeight, fSpc As Float
Dim fExp As Float
Dim iNExp As Integer
Dim O As Object
Dim i, j, k As Integer
Dim hTItem As TControl
'Dim bPass As Boolean
Dim fX, fY, fTmpY As Float
Dim bExitLoop As Boolean
Dim AllowNextCol As Boolean
Dim fNextColStartPos, fCurColX As Float
'Initialisation des variables
fSpc = IIf(Me._RelativeSpacing, H * Me._Spacing / 100, Me._Spacing) 'ME._Spacing
'On retire les marges a la hauteur et les bordures
H = H - Me.Padding._Top - Me.Padding._Bottom - Me.Border._Top - Me.Border._Bottom
'on retire a la largeur les paddings (et les bordure ?)
W = W - Me.Padding._Left - Me.Padding._Right - Me.Border._Left - Me.Border._Right
'On positionne le curseur de position au coin a gauche
X = Me.Padding._Left + Me.Border._Left
Y = Me.Padding._Top + Me.Border._Top
'On initialise la hauteur total avec la hauteur disponible
TH = H
fCurColX = X
'On va retirer a la hauteur totale les éléments fixes
For i = Me._CurItem To Me.Children.Max
hChild = Me.Children[i]
For j = hchild._DataIndex To hchild._Count - 1
hChildHints = hChild._GetSizeHints(W, TH, W, H)
hTItem = New TControl
hTItem.Ctrl = hChild
hTItem.SizeHint = hChildHints
' Je cherche l'élément le plus large pour définir la position de la colonne suivante
If fNextColStartPos < fCurColX + hChildHints.Width Then fNextColStartPos = fCurColX + hChildHints.Width
'Si un des éléments de colonne dépasse la largeur et qu'il n'est pas dans la première colonne
'alors on annule toute la colonne
If fNextColStartPos > X + W Then
hchild._DataIndex = k
bExitLoop = True
'Print "trop large", fNextColStartPos, X + W
Break
Endif
'si on arrive en bas du container alor on change de colonne
If TH - hChildHints.Height < 0 Then
'Print TH - hChildHints.Height
aPageColumns.Add(aPageColumn)
aColX.Add(fCurColX)
aPageColumn = New TControl[]
fCurColX = fNextColStartPos + fspc
k = j
TH = H
Endif
TH = TH - hChildHints.Height - fspc
hTItem.Index = j
aPageColumn.Add(hTItem)
'On l'ajoute a la page
Next
'Print j & "/" & hchild._Count
'Print Me._CurItem & "/" & Me.Children.Max
If bExitLoop Then Break
Inc Me._CurItem
Next
If Not bExitLoop Then
aColX.Add(fCurColX)
aPageColumns.Add(aPageColumn)
Endif
'On va mettre en page a présent
'On définit la taille des éléments étendus
If iNexp Then
fExp = (TH + fExp) / iNexp
Endif
i = 0
For Each aPageColumn In aPageColumns
fTmpY = Y
For Each hTItem In aPageColumn
oChild = hTItem.Ctrl
'Si l'élément est étendu on lui applique la taille répartie
If oChild.Expand And Not oChild.Ignore Then
'If Me.Tag = "*" Then Stop
fHeight = fExp
Else
'sinon il maintien sa taille
fHeight = hTItem.SizeHint.Height
Endif
'Print Object.Type(hChild) & " " & fHeight
If Not oChild.Ignore Then
hTItem._SetGeometry(aColX[i], fTmpY, hTItem.SizeHint.Width, fHeight)
oChild._SetChildGeometry(aColX[i], fTmpY, hTItem.SizeHint.Width, fHeight, ContPage, bInFixed Or Me.Fixed)
fTmpY += fHeight + fspc
Else
fX = X + IIf(oChild._RelativeLeft, W * oChild._Left / 100, oChild._Left)
fY = Y + IIf(oChild._RelativeTop, H * oChild._Top / 100, oChild._Top)
hTItem._SetGeometry(fX, fY, hTItem.SizeHint.Width, fHeight)
oChild._SetChildGeometry(fX, fY, hTItem.SizeHint.Width, fHeight, ContPage, bInFixed Or Me.Fixed)
Endif
If oChild Is ReportContainer Then
If oChild._CurItem <= oChild.Children.max Then
'Print "il reste des éléments dans " & oChild.Tag & " a la page " & ContPage
'Print ochild.Children.max - ochild._CurItem
j = Me.Children.Find(oChild)
Me._CurItem = Min(Me._CurItem, j)
Endif
Endif
Next
Inc i
aPageItems.Insert(aPageColumn)
Next
'Fin du processus
'On ajoute cette page au dossier du conteneur
Me._PageChildren[ContPage] = aPageItems
End
Private Sub SetVChildGeometry(X As Float, Y As Float, W As Float, H As Float, ContPage As Integer, bInFixed As Boolean)
Dim aPageItems As New TControl[] ''Éléments contenu par cette page
@ -481,11 +641,6 @@ Private Sub SetVChildGeometry(X As Float, Y As Float, W As Float, H As Float, Co
Dim fX, fY, fTmpY As Float
Dim bExitLoop As Boolean
' If Me.Tag = "*" Then
' Print H
' Stop
' Endif
'If Me.tag = "Contenu1" Then Print "H= " & H
'Initialisation des variables
fSpc = IIf(Me._RelativeSpacing, H * Me._Spacing / 100, Me._Spacing) 'ME._Spacing
'On retire les marges a la hauteur et les bordures
@ -499,14 +654,13 @@ Private Sub SetVChildGeometry(X As Float, Y As Float, W As Float, H As Float, Co
'On initialise la hauteur total avec la hauteur disponible
TH = H
'If Me.Tag = "Contenu1" Then Print TH
'On va retirer a la hauteur totale les éléments fixes
'If Me.Tag = "ListeElements" Then Stop
For i = 0 To Me.Children.Max
hChild = Me.Children[i]
If hChild.Fixed Then
hChildHints = hChild._GetSizeHints(W, TH, W, H)
'Print "Ajout de :" & Object.Type(hChild)
'si l'index courant est inférieur a l'objet en cour du conteneur alors
'on l'ajoute a la page et on incrémente la place des objet étendu si il est étendu

View file

@ -1,6 +1,6 @@
' Gambas class file
Export
'Export
Inherits ReportFrame
Event Draw

View file

@ -2,7 +2,7 @@
Export
Inherits ReportContainer
Public Const _Properties As String = "*,Arrangement{Arrange.None;Vertical;Horizontal;Fill}=Vertical"
Public Const _Properties As String = "*,Arrangement{Arrange.None;Vertical;Horizontal;Column;Fill}=Vertical"
Public Const _Similar As String = "ReportVBox"
Property Arrangement As Integer

View file

@ -0,0 +1,18 @@
' Gambas class file
Export
Inherits ReportContainer
Public Const _Properties As String = "*"
Public Const _Similar As String = "ReportVBox"
Public Sub _new()
Super._Arrangement = Arrange.Column
End
Public Sub _Free()
Super._Free
End

View file

@ -1,7 +1,16 @@
' Gambas class file
Public Sub _new()
'Report.Debug = True
Report.Debug = True
ReportHBox1.DataCount = 52
ReportHBox1.Border.RoundCorner.TopRight = "5mm/5mm"
'ReportHBox1.Border.RoundCorner.BottomRight = "5mm/5mm"
End
Public Sub ReportLabel1_Data()
Last.data = "Salut Benoit " & Last.DataIndex
End

View file

@ -4,15 +4,29 @@
#MoveScaled(0,0,64,64)
Index = 0
Text = ("")
{ ReportLabel1 ReportLabel
#MoveScaled(4,9,62,4)
Width = "8cm"
Font = Font["+5"]
Padding = ReportPadding["Top:7mm;Bottom:7mm;Left:7mm;Right:7mm"]
AutoResize = True
Text = ("Salut Benoit")
Alignment = Align.Center
Rotate = 25
{ ReportPanel1 ReportVPanel
#MoveScaled(3,6,64,49)
Padding = ReportPadding["Top:4mm;Bottom:4mm;Left:4mm;Right:4mm"]
Expand = True
Spacing = "7mm"
{ ReportHBox1 ReportHBox
#MoveScaled(0,0,64,8)
Width = "2cm"
Height = "2cm"
AutoResize = True
Border = ReportBorder["Top:1mm #000000;Bottom:1mm #000000;Left:1mm #000000;Right:1mm #000000"]
Background = ReportBrush["LinearGradient(0,0,1,1,[#3F1D00,#FF7F00],[0,1])"]
{ ReportLabel1 ReportLabel
#MoveScaled(1,2,62,4)
Brush = ReportBrush["#FFFF00"]
Font = Font["+5"]
Padding = ReportPadding["Top:3mm;Bottom:3mm;Left:3mm;Right:3mm"]
Expand = True
AutoResize = True
Alignment = Align.Center
Rotate = 45
}
}
}
Index = 0
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B