[GB.REPORT]

* NEW: ReportSvgImage have the same properties than 
  ReportImage (StretchMode, Alignment)


git-svn-id: svn://localhost/gambas/trunk@4318 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2011-12-22 19:44:49 +00:00
parent 021de427c5
commit 805e8c3ad9
9 changed files with 179 additions and 71 deletions

View file

@ -486,7 +486,11 @@ _RealSpacing
v
i
:Data
:BeforeArrange
:
:AfterArrange
:
@ -772,10 +776,6 @@ _PaintBefore
m
(Page)i(X)f(Y)f(hControl)TControl;(VirtualId)i
RoundRect
m
(X)i(Y)i(w)i(h)i(Radius_X)Float[];(radius_y)Float[];
_PaintFrame
m
@ -1043,18 +1043,30 @@ C
_Properties
C
s
*,Stretch,Image{SvgImage}
*,StretchMode{ReportImage.None;Proportional;Fill},Alignment{Align.*},Image{SvgImage}
_Similar
C
s
ReportTextLabel
Data
v
SvgImage
Image
p
SvgImage
Stretch
StretchMode
p
b
i
Alignment
p
i
:Data
:
_GetSizeHints
m

View file

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.6
Title=Report designer
Startup=myReport1
Startup=myReport2
Icon=printer1.png
Version=2.99.6
VersionProgram=gbx3 -V

View file

@ -68,9 +68,14 @@ Static Public Function _get(sValue As String) As ReportBorder
FillObject(hReportBorder.bottom, aScan[1])
Case "top"
FillObject(hReportBorder.Top, aScan[1])
Case "roundcorners"
GetCorners(hReportBorder, aScan[1])
Case "topleftcorner"
hReportBorder.RoundCorner.TopLeft = aScan[1]
Case "toprightcorner"
hReportBorder.RoundCorner.TopRight = aScan[1]
Case "bottomleftcorner"
hReportBorder.RoundCorner.BottomLeft = aScan[1]
Case "bottomrightcorner"
hReportBorder.RoundCorner.BottomRight = aScan[1]
End Select
@ -97,28 +102,6 @@ Static Private Sub FillObject(hObj As Object, sValue As String)
End
Static Private Sub GetCorners(hReportBorder As ReportBorder, sValue As String)
Dim aPair As String[]
Dim i As Integer
aPair = Split(sValue, " ")
For i = 0 To aPair.Max
Select Case i
Case 0
hReportBorder.RoundCorner.TopLeft = aPair[0]
Case 1
hReportBorder.RoundCorner.TopRight = aPair[1]
Case 2
hReportBorder.RoundCorner.BottomRight = aPair[2]
Case 3
hReportBorder.RoundCorner.BottomLeft = aPair[3]
End Select
Next
End
Public Function ToString() As String
Dim aValue As New String[]

View file

@ -38,7 +38,8 @@ Property Read _RelativeSpacing As Boolean
Public _RealSpacing As Integer
Static Private $iLevel As Integer
Event Data
Event BeforeArrange
Event AfterArrange
Public Function _Add(cControl As ReportControl) 'As TControl
@ -455,6 +456,8 @@ Public Sub _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float, Con
'If Me.Tag = "*" Then Stop
'Print "Geometry " & Object.Type(Me)
Raise BeforeArrange
Select Case _Arrangement
Case Arrange.Vertical
SetVChildGeometry(X, Y, W, H, ContPage, bInFixed)
@ -468,6 +471,8 @@ Public Sub _SetChildGeometry(X As Float, Y As Float, W As Float, H As Float, Con
SetNChildGeometry(X, Y, W, H, ContPage, bInFixed)
End Select
Raise AfterArrange
End
Private Sub SetCChildGeometry(X As Float, Y As Float, W As Float, H As Float, ContPage As Integer, bInFixed As Boolean)

View file

@ -217,7 +217,7 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As
End
Public Sub RoundRect(x As Integer, y As Integer, w As Integer, h As Integer, Radius_X As Float[], radius_y As Float[])
Private Sub RoundRect(x As Integer, y As Integer, w As Integer, h As Integer, Radius_X As Float[], radius_y As Float[])
Dim ARC_TO_BEZIER As Float = 0.55228475
Dim c1, c2 As Float

View file

@ -3,14 +3,17 @@
Export
Inherits ReportFrame
Private $hSvgImage As SvgImage
Private $bStretch As Boolean
Private $hPic As SvgImage
Private $iStretchMode As Integer
Private $iAlignment As Integer = Align.Normal
'Private $sPath As String
Public Const _Properties As String = "*,Stretch,Image{SvgImage}"
Public Const _Properties As String = "*,StretchMode{ReportImage.None;Proportional;Fill},Alignment{Align.*},Image{SvgImage}"
Public Const _Similar As String = "ReportTextLabel"
Public Data As SvgImage
Property Image As SvgImage
Property Stretch As Boolean
Property StretchMode As Integer
Property Alignment As Integer
Event Data
Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As Float, TotalHeight As Float) As TSizeHint
@ -18,66 +21,165 @@ Public Sub _GetSizeHints(AvailableW As Float, AvailableH As Float, TotalWidth As
Dim h As Float = IIf(Me._Height > AvailableH, AvailableH, Me._Height)
Dim w As Float = IIf(Me._Width > AvailableW, AvailableW, Me._Width)
Dim Scale As Float
Dim hPic As SvgImage
hMyHints = Super._GetSizeHints(AvailableW, AvailableH, TotalWidth, TotalWidth)
If Me.Autoresize Then
If h < w Then
Scale = $hSvgImage.Width / $hSvgImage.Height
hMyHints.Width = (hMyHints.Height * Scale)
hMyHints.Height = hMyHints.Height
If $hpic Then
hpic = $hpic
Else
Scale = $hSvgImage.Height / $hSvgImage.Width
hMyHints.Height = (hMyHints.Width * Scale)
hMyHints.Width = hMyHints.Width
Raise Data()
hpic = Data
Endif
If hpic Then
hMyHints.Width = Max(hMyHints.Width, Me.Padding._Left + Units.UnitToCm(hpic.Width, "px") + Me.Padding._Right)
hMyHints.Height = Max(hMyHints.Width, Me.Padding._Top + Units.UnitToCm(hpic.Height, "px") + Me.Padding._Bottom)
Endif
Endif
Return hMyHints
End
Public Sub _Paint(Page As Integer, X As Float, Y As Float, hControl As TControl, VirtualId As Integer)
Dim iX, iY, iW, iH As Integer
Dim ix, iy As Float
'Dim hBrush As PaintBrush
Dim hPic As SvgImage
Dim fScale As Integer
Dim w, h As Float
Dim fTemp As Float
iX = (x + hControl.RealLeft + MTools.UnitsToPixels(Me.Padding._Left + Me.Border._Left))
iY = (y + hControl.RealTop + MTools.UnitsToPixels(Me.Padding._Top + Me.Border._Top))
iW = (hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Left + Me.Padding._Right + Me.Border._Left + Me.Border._Right))
ix = x + hControl.RealLeft '+ MTools.UnitsToPixels(Me.Padding._Left)
iy = y + hControl.RealTop '+ MTools.UnitsToPixels(Me.Padding._Top)
iH = (hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Top + Me.Padding._Bottom + Me.Border._Top + Me.Border._Bottom))
If Not $hpic Then
Raise Data()
hpic = Data
If Not hPic Then Return
Else
hPic = $hpic
Endif
Paint.MoveTo(ix, iY)
$hSvgImage.Width = iW
$hSvgImage.Height = iH
$hSvgImage.Paint
'Draw.Drawing($hDrw, (x + hControl.RealLeft + Me.Padding) * MRTools.ReportZoom,
'(y + hControl.RealTop + Me.Padding) * MRTools.ReportZoom,
'hControl.RealWidth * MRTools.ReportZoom, '
'hControl.RealHeight * MRTools.ReportZoom)
'$hPic = $hPic.Stretch(hControl.RealWidth, hControl.RealHeight)
'hBrush = Paint.Image(hpic)
If Me.StretchMode = ReportImage.Fill Then
iX += MTools.UnitsToPixels(Me.Padding._Left + Me.Border._Left)
iY += MTools.UnitsToPixels(Me.Padding._Top + Me.Border._Top)
w = (hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Left + Me.Padding._Right + Me.Border._Left + Me.Border._Right))
h = (hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Top + Me.Padding._Bottom + Me.Border._Top + Me.Border._Bottom))
' hBrush.Translate(ix, iy - 1)
'hBrush.Scale(w / hPic.Width, h / hPic.Height)
'Paint.Brush = hBrush
hpic.Width = w
hpic.Height = h
Paint.MoveTo(ix, iy)
hpic.Paint
'Paint.Rectangle(ix, iy, w, h)
Else
If Me.StretchMode = ReportImage.Proportional Then
'on détermine la partie prédominante
If hPic.Width >= hPic.Height
'C'est la largeur
'on détermine une hauteur en fonction de la largeur connue
w = hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Width)
h = hPic.Height / hPic.Width * w
'si h> a la place disponible alors on adapte en fonction de h en faite
If h > (hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Height)) Then
h = (hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Height))
w = hPic.Width / hPic.Height * h
Endif
Else
'C'est la hauteur
h = (hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Height))
w = hPic.Width / hPic.Height * h
'si w> la place disponible alors on adapte en fonction de w en faite
If w > (hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Width)) Then
w = hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Width)
h = hPic.Height / hPic.Width * w
Endif
Endif
Else
w = hPic.Width
h = hPic.Height
Endif
Select Case $iAlignment
Case Align.Normal, Align.TopLeft, Align.Left, Align.BottomLeft
'Gauche
ix += MTools.UnitsToPixels(Me.Padding._Left)
Case Align.Bottom, Align.Center, Align.Top
'centrée
ix += (hControl.RealWidth - w) / 2
Case Align.TopRight, Align.Right, Align.BottomRight
'Droite
ix += hControl.RealWidth - MTools.UnitsToPixels(Me.Padding._Right) - w
End Select
Select Case $iAlignment
Case Align.TopLeft, Align.Top, Align.TopRight
'Haut
iy += MTools.UnitsToPixels(Me.Padding._Top)
Case Align.Left, Align.Center, Align.Right
'Milieu
iy += (hControl.RealHeight - h) / 2
Case Align.BottomLeft, Align.Bottom, Align.BottomRight
iY += hControl.RealHeight - MTools.UnitsToPixels(Me.Padding._Bottom) - h
End Select
'hBrush.Translate(ix, iy - 1)
hpic.Width = W
hPic.Height = H
Paint.MoveTo(iX, iY)
hpic.Paint
'hBrush.Scale(w / hPic.Width, h / hPic.Height)
'Paint.Brush = hBrush
'Paint.Rectangle(ix, iy, w, h - 1)
Endif
End
Private Function Image_Read() As SvgImage
Return $hSvgImage
Return $hPic
End
Private Sub Image_Write(Value As SvgImage)
$hSvgImage = Value
$hPic = Value
End
Private Function Stretch_Read() As Boolean
Private Function StretchMode_Read() As Integer
Return $bStretch
Return $iStretchMode
End
Private Sub Stretch_Write(Value As Boolean)
Private Sub StretchMode_Write(Value As Integer)
$bStretch = Value
$iStretchMode = Value
End
Private Function Alignment_Read() As Integer
Return $iAlignment
End
Private Sub Alignment_Write(Value As Integer)
$iAlignment = Value
End

View file

@ -16,7 +16,7 @@
#MoveScaled(5,18,49,11)
Font = Font["Bitstream Charter,Bold,+9"]
AutoResize = True
Border = ReportBorder["Top:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Bottom:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Left:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Right:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56])"]
Border = ReportBorder["Top:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Bottom:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Left:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);Right:1mm LinearGradient(0.14,0.13,0.97,0.97,[#00FF00,#FFFFFF,#FF0000],[0,1,0.56]);TopLeftCorner:10mm/10mm"]
Text = ("Report About")
Alignment = Align.Center
}

View file

@ -77,3 +77,9 @@ Public Sub entete_Data()
Last.data = cFactHead[Last.dataIndex][Last.tag]
End
Public Sub ReportVBox1_BeforeArrange()
Debug "Before Arrange"
End

View file

@ -21,23 +21,23 @@
}
{ ReportHBox1 ReportHBox
#MoveScaled(1,9,72,25)
Height = "2cm"
Height = "4cm"
Fixed = True
Expand = True
AutoResize = True
Border = ReportBorder["Bottom:1px #000000;Left:1px #000000;Right:1px #000000"]
{ ReportHBox5 ReportHBox
#MoveScaled(2,1,34,22)
Width = "5cm"
Height = "5cm"
Fixed = True
Padding = ReportPadding["Top:3mm;Bottom:3mm;Left:3mm;Right:3mm"]
Expand = True
AutoResize = True
{ ReportSvgImage1 ReportSvgImage
#MoveScaled(3,2,25,17)
Width = "50mm"
Height = "30mm"
StretchMode = ReportImage.Proportional
Alignment = Align.Center
Image = SvgImage.Load("img/logo.svg")
}
}