Public Sub MeasureTextHeightBBCodeView(vParent As B4XView, _
strCodeText As String, _
iWidth As Int, _
fTextSize2 As Float, _
arrPadding() As Int) As Int
'Note fTextSize is not used in this Sub
Dim iMaxDialogHeight As Int = vParent.Height - 144dip
Dim TextEngine As BCTextEngine
Dim iContentHeight As Int
Dim rectPadding As B4XRect
Log(strCodeText)
'-----------------------------------------------------------------------------------------
'note that is the same layout that will be used to show the actual final text
'it will be removed first after getting the content height and will then be reloaded later
'-----------------------------------------------------------------------------------------
vParent.LoadLayout("Dialog_bcte")
'bbcvPrompt is private module level variable (in B4XMainPage)
bbcvPrompt.mBase.Width = iWidth
TextEngine.Initialize(vParent)
bbcvPrompt.TextEngine = TextEngine
rectPadding.Initialize(arrPadding(0), arrPadding(1), arrPadding(2), arrPadding(3))
bbcvPrompt.Padding = rectPadding
bbcvPrompt.LazyLoading = True 'but already set so in the designer
bbcvPrompt.Text = strCodeText
If bbcvPrompt.Paragraph.IsInitialized Then
iContentHeight = bbcvPrompt.Paragraph.Height / TextEngine.mScale + bbcvPrompt.Padding.Top + bbcvPrompt.Padding.Bottom' + iDoubleLineBreaks * fTextSize
End If
Log("MeasureTextHeightBBCodeView, bbcvPrompt.Paragraph.Height: " & bbcvPrompt.Paragraph.Height)
Log("MeasureTextHeightBBCodeView, TextEngine.mScale: " & TextEngine.mScale)
Log("MeasureTextHeightBBCodeView, bbcvPrompt.Padding.Top: " & bbcvPrompt.Padding.Top)
Log("MeasureTextHeightBBCodeView, bbcvPrompt.Padding.Bottom: " & bbcvPrompt.Padding.Bottom)
Log("MeasureTextHeightBBCodeView, iContentHeight: " & iContentHeight)
bbcvPrompt.Paragraph.TextLines.Clear '?clear memory
'all these are on the layout dialog_bcte and will need removing
imgIcon.RemoveViewFromParent
bbcvPrompt.mBase.RemoveViewFromParent
lblTitle.RemoveViewFromParent
edtInput.RemoveViewFromParent
Private bbcvPrompt As BBCodeView '?clear memory, not sure what difference there is to declare here with Dim or Private
'Log("MeasureTextHeightBBCodeView, iContentHeight: " & iContentHeight)
If iContentHeight > iMaxDialogHeight Then
iContentHeight = iMaxDialogHeight
End If
Return iContentHeight
End Sub