Just started to use BBCodeView as it seems very nice and useful indeed.
Nearly all worked out now, but don't quite understand how the placement of text works.
This is the string passed to the BBCodeView:
The height of the final text in the BBCodeView is determined by this function:
And this is the relevant code that handles it and shows the dialog:
To make the text placement OK I need the 2 lines that set the top and left of the BBCodeView scrollview.
Leaving those lines out will make the text too close to the left and to the top as shown in the attached 2 images.
Any suggestion how to improve on this and not need those 2 lines to place the scrollview?
RBS
Nearly all worked out now, but don't quite understand how the placement of text works.
This is the string passed to the BBCodeView:
B4X:
strPrompt = $"[TextSize=18]This allows you to run quickly through
a list of patients by clicking the
[TextSize=24][Vertical=3][FontAwesome=0xF0D8/][/Vertical][TextSize=18] and [TextSize=24][Vertical=3][FontAwesome=0xF0D7/][/Vertical][TextSize=18] buttons on various pages.
Start will start this option.
Stop will stop it.
"$
The height of the final text in the BBCodeView is determined by this function:
B4X:
Public Sub MeasureTextHeightBBCodeView(vParent As B4XView, strCodeText As String, iWidth As Int, arrPadding() As Int) As Int
Dim TextEngine As BCTextEngine
Dim iContentHeight As Int
vParent.LoadLayout("BBCodeView")
BBCodeView1.mBase.Width = iWidth
BBCodeView1.Padding.Left = arrPadding(0)
BBCodeView1.Padding.Top = arrPadding(1)
BBCodeView1.Padding.Right = arrPadding(2)
BBCodeView1.Padding.Bottom = arrPadding(3)
TextEngine.Initialize(vParent)
BBCodeView1.TextEngine = TextEngine
BBCodeView1.Text = strCodeText
If BBCodeView1.Paragraph.IsInitialized Then
iContentHeight = BBCodeView1.Paragraph.Height / TextEngine.mScale + BBCodeView1.Padding.Top + BBCodeView1.Padding.Bottom
End If
BBCodeView1.mBase.RemoveViewFromParent
Return iContentHeight
End Sub
And this is the relevant code that handles it and shows the dialog:
B4X:
If tDP.bPrompt Then
'this will be the same as tDP.iPromptHeight as determined by GetDialogParams
Log("BBCodeView content height: " & cMP.MeasureTextHeightBBCodeView(Parent, strPrompt, Parent.Width - 10dip, arrPromptPadding))
TextEngine.Initialize(Parent)
bbcvPrompt.TextEngine = TextEngine
bbcvPrompt.mBase.SetColorAndBorder(iPromptColour, 1dip, iBorderColour, 2dip)
bbcvPrompt.mBase.Height = tDP.iScrollViewHeight 'this is the visible height of the old plain prompt view
bbcvPrompt.mBase.Top = tDP.iPromptTop
bbcvPrompt.mBase.Width = tDP.iScrollViewWidth 'this is same as tDP.iPromptWidth
'these next 2 lines are needed to get the text placement in bbcvPrompt OK
bbcvPrompt.sv.Top = 4dip
bbcvPrompt.sv.Left = 4dip
'Private arrPromptPadding() As Int = Array As Int(4dip, 4dip, 4dip, 4dip)
bbcvPrompt.Padding.Left = arrPromptPadding(0)
bbcvPrompt.Padding.Top = arrPromptPadding(1)
bbcvPrompt.Padding.Right = arrPromptPadding(2)
bbcvPrompt.Padding.Bottom = arrPromptPadding(3)
'------------------------------------------------'
'This is the way to set the BBCodeView background'
'------------------------------------------------'
'bbcvPrompt.mBase.Color = iPromptColour >> set already in bbcvPrompt.mBase.SetColorAndBorder
bbcvPrompt.sv.Color = iPromptColour
bbcvPrompt.sv.ScrollViewInnerPanel.Color = iPromptColour
If tDP.bcsPrompt Then
bbcvPrompt.Text = csPrompt 'this won't happen
Else
bbcvPrompt.Text = strPrompt
End If
'get rid of the click sound as there will be nil clickable
'---------------------------------------------------------
Dim jo As JavaObject = bbcvPrompt.mBase
jo.RunMethod("setSoundEffectsEnabled", Array(False))
End If 'If tDP.bPrompt
To make the text placement OK I need the 2 lines that set the top and left of the BBCodeView scrollview.
Leaving those lines out will make the text too close to the left and to the top as shown in the attached 2 images.
Any suggestion how to improve on this and not need those 2 lines to place the scrollview?
RBS