gambas-source-code/comp/src/gb.report/ReportHBox.class
Benoît Minisini ba19f3c1dd * Copy https://gambas.svn.sourceforge.net/svnroot/gambas/2.0 to https://gambas.svn.sourceforge.net/svnroot/gambas/gambas
git-svn-id: svn://localhost/gambas/trunk@893 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2007-12-30 16:41:49 +00:00

121 lines
2.8 KiB
Text

' Gambas class file
EXPORT
INHERITS ReportContainer
PUBLIC SUB _GetSizeHints(AvailableW AS Float, AvailableH AS Float, TotalWidth AS Float, TotalHeight AS Float) AS TSizeHint
DIM hChild AS Object
DIM hMyHints AS NEW TSizeHint
DIM hChildHints AS TSizeHint
DIM fSpacing AS Float
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)
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 += 2 * ME._Padding
IF ME._RelativeWidth THEN hMyHints.Width = AvailableW * ME._Width / 100
'je veut ma hauteur !
IF NOT ME.Autoresize THEN
hMyHints.Height = ME._Height
IF ME._RelativeHeight THEN hMyHints.Height = AvailableH * ME._Height / 100
ENDIF
RETURN hMyHints
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 Object
DIM fChildrenH AS Float
DIM PagePos AS NEW Integer[]
DIM iPage AS Integer
DIM aPage AS NEW Object[]
DIM aChild AS NEW Object[]
DIM iNExp AS Integer
DIM fSExp AS Float
DIM fSpc AS Float
DIM fPdg AS Float
DIM bFirst AS Boolean
DIM fH AS Float
DIM fW AS Float
DIM nbPage AS Integer
'PRINT "Set HBox Geometry = ", x, y, w, h
'PRINT Subst("_SetGeometry(&1,&2,&3,&4)", X, Y, W, H)
'If there is no change then do nothing
'IF X = ME.RealLeft AND IF Y = ME.RealTop AND IF W = ME.RealWidth AND IF H = ME.RealHeight THEN RETURN
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
W -= fPdg * 2
H -= fPdg * 2
FOR EACH hChild IN ME.Children
hChildHints = hChild.ctrl._GetSizeHints(W - fSExp, H, W, H)
IF hChild.ctrl.Expand THEN
INC iNExp
ELSE
fSExp += hChildHints.Width
ENDIF
fSExp += fSpc
NEXT
fSExp -= fSpc
fSExp = W - fSExp
bFirst = TRUE
FOR EACH hChild IN ME.Children
hChildHints = hChild.ctrl._GetSizeHints(W - X, H, W, H)
IF NOT bFirst THEN
X += fSpc
ENDIF
bFirst = FALSE
IF hChild.ctrl.Expand THEN
fW = fSExp / iNExp
ELSE
fW = hChildHints.Width
ENDIF
nbPage = hChild._SetGeometry(X, Y, fW, h)
IF nbPage > iPage THEN iPage = nbPage
X += fW
NEXT
RETURN iPage
END
PUBLIC SUB _Free()
SUPER._Free
END