Sub Class_Globals
Private fx As JFX
Private xui As XUI
Private frm As Form
Private SplitPane1 As SplitPane
Private TextArea1 As TextArea
Private BBCodeView1 As BBCodeView
Private TextEngine As BCTextEngine
End Sub
Public Sub Initialize (Parent As Form,left As String,top As String,width As String,height As String,titel As String,text As String)
If frm.IsInitialized = False Then
frm.Initialize("frm", 800, 600)
frm.RootPane.LoadLayout("frmEditor")
SplitPane1.LoadLayout("Top")
SplitPane1.LoadLayout("Bottom")
End If
Dim ps As Screen = fx.PrimaryScreen
frm.WindowWidth = width
frm.WindowHeight = height
frm.WindowTop = ps.MinY + (ps.MaxY - frm.WindowHeight) / 2
frm.WindowLeft = ps.MinX + (ps.MaxX - frm.WindowWidth) / 2
frm.Title=titel
frm.SetFormStyle("DECORATED")
frm.Resizable = True
End Sub
Public Sub Show As String
'TextEngine.Initialize(frm.RootPane) ' to early here
frm.ShowAndWait
TextEngine.Initialize(frm.RootPane) ' to late here
Return TextArea1.Text
End Sub
Sub btnUpdate_Click
Try
AddViews(TextArea1.Text)
BBCodeView1.Text = TextArea1.Text
Catch
TextEngine.TagParser.ErrorString.Append(CRLF).Append(LastException.Message)
Log(LastException)
End Try
If TextEngine.TagParser.ErrorString.Length > 0 Then
xui.MsgboxAsync(TextEngine.TagParser.ErrorString, "Error")
End If
End Sub
Sub AddViews (s As String)
Dim m As Matcher = Regex.Matcher2("\[view=(\w+)", Regex.CASE_INSENSITIVE, s)
Do While m.Find
Dim key As String = m.Group(1)
If BBCodeView1.Views.ContainsKey(key) = False Then
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 100dip, 100dip)
p.Color = Rnd(0xff000000, -1)
BBCodeView1.Views.Put(key, p)
End If
Loop
End Sub