Public Sub setText(value As Object)
mLbl.Text = value
Dim multipleLines As Boolean = mLbl.Text.Contains(CRLF)
Dim size As Float
For size = 2 To 80
If CheckSize(size, multipleLines, value) Then Exit
Next
size = size - 0.5
If CheckSize(size, multipleLines, value) Then size = size - 0.5
mLbl.TextSize = size
End Sub
'returns true if the size is too large
Private Sub CheckSize(size As Float, MultipleLines As Boolean, Text As Object) As Boolean
mLbl.TextSize = size
If MultipleLines Then
Return su.MeasureMultilineTextHeight(mLbl, Text) > mLbl.Height
Else
Return cvs.MeasureStringWidth(mLbl.Text, mLbl.Typeface, size) > mLbl.Width Or _
su.MeasureMultilineTextHeight(mLbl, Text) > mLbl.Height
End If
End Sub