The following additional libraries are needed: RichString, Reflection, StringUtils, Clipboard (optional). With RtfLabel text can be formatted and displayed scrollable.
Generally
Events
Members - overview
Members - discription
See also:
Text formatting / Hyperlinks / Anchors
Paragraph formatting
Paragraph formatting:
Text indent left / right, first line indent, bullet character, centering, text size, colored background, images centered or with body text.
Select text by user:
If the function is provided (RtfLabel1.MarkFunction = True) the user can select text (automatically by word) and copy.
To extend the selection over the visible area, the marking on the top or bottom line must be held - the text is then scrolled automatically.
RtfLabel is an "Activity Object", it cannot be declared under Sub Process_Globals. All formatting characters are enclosed in braces {...} - otherwise may not occur in the text! RtfLabel has a function for checking the text on formatting errors. Faulty paragraphs are indicated in the label itself with appropriate references (intended for the development time):
RtfLabel1.Text = "This {i}is{i} a {b}text{b} with {h/MyLink}hyperlink{h}! " | RtfLabel1.Text = "The text {i}is{i} a {b}text with errors in formatting! " | |
Text display without error checking: RtfLabel1.TextShow(False) |
Text display with error checking: RtfLabel1.TextShow(True) |
|
![]() |
![]() |
|
(to top)
LinkClick(LinkEventText As String)
Is dispatched when the user activates a hyperlink - the invisible event text is passed.
Sub RtfLabel1_LinkClick(LinkEventText As String) Log("LinkClick: " & LinkEventText) End Sub |
PageUpDownAvailable(PageUp As Boolean, PageDown As Boolean)
Is dispatched when the availability of features PageUp and PageDown has changed.
Sub RtfLabel1_PageUpDownAvailable(PageUp As Boolean, PageDown As Boolean) 'e.g. two buttons to control functions for the PageUp and PageDown: ButtonUp.Enabled = PageUp ButtonDown.Enabled = PageDown End Sub |
The following two events can for example be used to control a ToggleButton "Mark Button", with which the user can mark function on and off:
Sub ButtonMark_CheckedChange(Checked As Boolean) If Checked = True Then If RtfLabel1.AvailableMarkOn = True Then RtfLabel1.MarkOn Else ButtonMark.Checked = False End If Else RtfLabel1.MarkOff End If End Sub |
MarkOff()
Is dispatched when the marker function is off.
Sub RtfLabel1_MarkOff() If ButtonMark.Checked = True Then ButtonMark.Checked = False End Sub |
MarkOnAvailable(MarkOn As Boolean)
Is dispatched when the availability of the function has changed.
Sub RtfLabel1_MarkOnAvailable(MarkOn As Boolean) ButtonMark.Enabled = MarkOn End Sub |
MarkComplete(MarkText As String)
Is dispatched when the user has selected text. MarkText = text without formatting characters.
Sub RtfLabel1_MarkComplete(MarkText As String) 'e.g. automatically copy: (Clipboard library needed!) Clipboard.setText(MarkText) 'e.g. show note: ToastMessageShow("Text was copied!", False) End Sub |
(to top)
After changing the properties marked with (*), "TextShow" must be called again at the end (if text is already displayed)!
Initialization / Position / Size:
Initialize(CallbackModule As Object, EventName As String, Parent As Object, Left As Int, Top As Int, Width As Int, Height As Int) As Boolean
IsInitialized As Boolean
SetLayout(Left As Int, Top As Int, Width As Int, Height As Int) As Boolean (*)
Left As Int
Top As Int
Width As Int (*)
Height As Int
TextHeight As Int [read only]
BringToFront As Boolean
SendToBack As Boolean
RemoveView As Boolean
Appearance:
Color As Int [write only]
BackGround As Object
SetBackgroundImage(Bitmap As Bitmap) As Boolean
TextBorder As Int [write only] (*)
Visible As Boolean
Scrolling:
AvailablePageDown As Boolean [read only]
AvailablePageUp As Boolean [read only]
GoToAnchor(Anchor As String) As Boolean
GoToFirstRow As Boolean
GoToLastRow As Boolean
PageDown As Boolean
PageUp As Boolean
TextPositionTop As Object
Text display:
Text As String [write only]
TextShow(CheckBefore As Boolean) As Boolean
TextClear As Boolean
Text formatting: (*)
SetTextColors(ColorId As Int, Color As Int) As Boolean
TextColor As Int [write only]
TextSize As Float [write only]
TextSizeSmall As Float [write only]
Typeface As Typeface [write only]
Paragraph formatting: (*)
IndentWidth As String [write only]
SetFrameColors(ColorId As Int, Color As Int) As Boolean
Images: (*)
SetImages(Name As String, Image As Bitmap) As Boolean
ClearImages As Boolean
ImagesBorder As Int [write only]
Marking function:
MarkFunction As Boolean [write only] (*)
AvailableMarkOn As Boolean [read only]
MarkOn As Boolean
MarkOff As Boolean
MarkColor As Int [write only] (*)
Hyperlinks: (*)
LinkFormat As Int [write only]
LinkPressedColor As Int [write only]
LinkPressedCornerRadius As Int [write only]
LinkTextColor As Int [write only]
Others:
Enabled As Boolean
Tag As Object
(to top)
Initialization / Position / Size:
Initialize(CallbackModule As Object, EventName As String, Parent As Object, Left As Int, Top As Int, Width As Int, Height As Int) As Boolean
Initializes the label and adds it to the activity.
EventName: name for the event subs - for example "RtfLabel1": RtfLabel1_LinkClick(LinkEvenText As String) | |
Parent: Activity or Panel | |
Left, Top, Width, Height: position and size | |
Example - parent is activity: | |
RtfLabel1.Initialize(Me, "RtfLabel1", Activity, 0, 0, 100%x, 80%y) | |
Example - parent is a panel: | |
RtfLabel1.Initialize(Me, "RtfLabel1", Panel1, 0, 0, 100%x, 100%y) |
IsInitialized As Boolean
(as with the standard label)
SetLayout(Left As Int, Top As Int, Width As Int, Height As Int) As Boolean
Sets the position and size of the label anew (like the standard label).
RtfLabel1.SetLayout(0, 0, 100%x, 50%y) |
Left As Int
Gets or sets the view's left position (like the standard label).
Top As Int
Gets or sets the view's top position (like the standard label).
Width As Int
Gets or sets the view's width (like the standard label).
Height As Int
Gets or sets the view's height (like the standard label).
TextHeight As Int [read only]
Gets the total height of the text back - it may for example be used to realize an auto size function:
RtfLabel1.SetLayout(0, 0, 50%x, 10dip) ' RtfLabel e.g. half the width of the display RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " RtfLabel1.TextShow(False) RtfLabel1.Height = RtfLabel1.TextHeight 'The label is now as high as the (possibly multi-line) text. |
BringToFront As Boolean
Changes the Z order of this view and brings it to the front. (like the standard label).
SendToBack As Boolean
Changes the Z order of this view and sends it to the back. (like the standard label).
RemoveView As Boolean
Removes this view from its parent - activity or panel (like the standard label).
Appearance:
Color As Int [write only]
Sets the background color (like the standard label).
BackGround As Object
Gets or sets the background drawable (like the standard label).
SetBackgroundImage(Bitmap As Bitmap) As Boolean
Sets the background image for the label (like the standard label).
TextBorder As Int [write only]
Sets the left and right edges between label and text display (Value 0 bis 12dip - default 2dip).
RtfLabel1.TextBorder = 0 'no border: | |
![]() |
|
RtfLabel1.TextBorder = 10dip 'border left 10dip / border right 10dip:: | |
![]() |
Visible As Boolean
Gets or sets the visibility of the label (like the standard label).
Scrolling:
AvailablePageDown As Boolean [read only]
Gets the availability of the function "PageDown" back.
AvailablePageUp As Boolean [read only]
Gets the availability of the function "PageUp" back.
If RtfLabel is set in the sub Activity_Create, then the events PageUpDownAvailable and MarkOnAvailable cannot be received - but instead these additional properties (see use in example, in the sub Activity_Create).
GoToAnchor(Anchor As String) As Boolean
Brings the text with the anchor in the visible range.
RtfLabel1.Text = "... {a/paragraph3}§3 - Here follows the text of paragraph 3 ... | |
RtfLabel1.GoToAnchor("paragraph3") |
GoToFirstRow As Boolean
Scrolls the text to the top.
GoToLastRow As Boolean
Scrolls the text to the bottom.
PageDown As Boolean
Scrolls the text down one page (page = the label height minus dimmed border top / bottom).
PageUp As Boolean
Scrolls the text up one page.
TextPositionTop As Object
Gets the data above the text position of the first character of the first fully visible line or brings back the line with the position of text in the visible range (see in the example, the variable "Restore").
Dim Pos As Object Pos = RtfLabel1.TextPositionTop 'save position |
|
'after redisplaying the text, for example due to changes in the properties or orientation: | |
RtfLabel1.TextPositionTop = Pos 'brings the passage back into the visible area |
Text display:
Text As String [write only]
Sets the text (with formatting characters) to be displayed in the label.
RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " |
TextShow(CheckBefore As Boolean) As Boolean
Displays the text in the label. If CheckBefore = True, then the text will be checked on formatting errors, before displayed (see example above).
RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " | |
RtfLabel1.TextShow(False) | |
![]() |
|
If the properties are changed after "TextShow", the function must be called again: (see note above) | |
RtfLabel1.Color = Colors.Black 'The background color can be changed without redisplaying ... | |
RtfLabel1.TextColor = Colors.Yellow '... the font color does not! | |
RtfLabel1.TextShow(False) | |
![]() |
TextClear As Boolean
Clears the text screen and the text. The settings remain intact - also the data for SetTextColors, SetFrameColors and SetImages.
Text formatting:
SetTextColors(ColorId As Int, Color As Int) As Boolean
Sets the font color for the text formatting with {tc0} to {tc9} and the paragraph formatting with ptc{...}. Up to 10 colors (ColorId 0 to 9) can be defined. In the formatting characters in the text only the color-index is specified:
RtfLabel1.TextColor = Colors.Black 'Default font size | |
RtfLabel1.SetTextColors(0, Colors.Red) 'Color for ColorId 0 | |
RtfLabel1.SetTextColors(1, Colors.Blue) 'Color for ColorId 1 | |
'... | |
RtfLabel1.Text = "This {tc0}word{tc0} is red, this {tc1}{b}blue{b}{tc1}, the rest is black. " | |
![]() |
TextColor As Int [write only]
Sets the default text color for the display text (like the standard label).
TextSize As Float [write only]
Sets the default font size for the display text - value >= 8 (like the standard label).
TextSizeSmall As Float [write only]
Sets the relative font size for smaller displayed text - for formatting text with {s}. The factor (value 0.5 to 0.9) refers to the default font size or font size of the paragraph:
RtfLabel1.TextSize = 20 'Default font size | |
RtfLabel1.TextSizeSmall = 0.8 'Factor for small font | |
RtfLabel1.Text = "This {s}word{s} is smaller than the rest. " 'Font size: 20 * 0.8 = 16 |
|
![]() |
|
If the font size is specified for the paragraph, the factor refers to this size: ({pts = ParagraphTextSize) | |
RtfLabel1.Text = "{pts/1.5}This {s}word{s} is smaller than the rest. " 'Font size: 20 * 1.5 * 0.8 = 24 |
|
![]() |
Typeface As Typeface [write only]
Sets the font for the display text (like the standard label).
Dim MyFont As Typeface | |
MyFont = Typeface.LoadFromAssets("times.ttf") | |
RtfLabel1.Typeface = MyFont |
Paragraph formatting:
IndentWidth As String [write only]
Sets the string that is used to calculate the indent width per level, for the paragraph formatting.
RtfLabel1.IndentWidth = "XXX" |
SetFrameColors(ColorId As Int, Color As Int) As Boolean
Sets the background color for the paragraph formatting with frames. Up to 10 colors (ColorId 0 to 9) can be defined. In the formatting characters in the text only the color-index is specified:
RtfLabel1.SetFrameColors(0, Colors.Yellow) 'Color for ColorId 0 | |
RtfLabel1.SetFrameColors(1, Colors.LightGray) 'Color for ColorId 1 | |
'... | |
RtfLabel1.Text = "{pf/Indent:1/RIndent:1/ColorId:1/Border:0.5}{pi/2/0}{pri/2}This is a text with frame, as a design element. " | |
![]() |
Images:
SetImages(Name As String, Image As Bitmap) As Boolean
Transfers the images to the label, to display in the text (repeatedly if necessary). "Name" must be a unique designation (not case sensitive, no points, no spaces). When formatting with {pimage...} the image can be directly specified as the file name, or it is used from the preloaded images:
RtfLabel1.SetImages("ArrowL", LoadBitmap(File.DirAssets,"ArrowLeft.bmp")) | |
RtfLabel1.SetImages("ArrowR", LoadBitmap(File.DirAssets,"ArrowRight.bmp")) | |
RtfLabel1.Text = "{pc}{pimage/ArrowL/22/22}{pimage/ArrowR/22/22}" '{pc} is the paragraph centering | |
![]() |
|
or: | |
RtfLabel1.Text = "{pc}{pimage/ArrowLeft.bmp/22/22}{pimage/ArrowRight.bmp/22/22}" | |
![]() |
ClearImages As Boolean
Deletes all with "SetImages" assigned images.
ImagesBorder As Int [write only]
Sets the right and bottom edges between image and continuous text or the distance between two images (see, for paragraph formatting). The setting applies to all images in the text.
RtfLabel1.ImagesBorder = 6dip | |
RtfLabel1.Text = "{pimage/ArrowL/22/22}{pimage/ArrowR/22/22}Here follows the text to the image ..." | |
![]() |
Marking function:
MarkFunction As Boolean [write only]
Determines whether the functionality is provided for marking text in the label (MarkFunction = False, accelerates the text display).
AvailableMarkOn As Boolean [read only]
Gets the availability of the function "MarkOn" back.
MarkOn As Boolean
Turns the select mode on - the user can select text. This function is only available when MarkFunction = True.
MarkOff As Boolean
Turns the select mode off. This function is only available when MarkFunction = True.
MarkColor As Int [write only]
Sets the color with which the selected text is highlighted.
Hyperlinks:
LinkFormat As Int [write only]
Sets the formatting applied to all hyperlinks: 1 = underlined | 2 = colored | 3 = underlined and colored.
RtfLabel1.LinkFormat = 1 RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " |
|
![]() |
|
RtfLabel1.LinkTextColor = Colors.Blue RtfLabel1.LinkFormat = 2 |
|
![]() |
|
RtfLabel1.LinkTextColor = Colors.Blue RtfLabel1.LinkFormat = 3 |
|
![]() |
LinkPressedColor As Int [write only]
Sets the color of the hyperlinks for the pressed state.
RtfLabel1.LinkPressedColor = Colors.Cyan RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " |
|
![]() |
LinkPressedCornerRadius As Int [write only]
Sets the radius for LinkPressedColor with rounded corners (0 = none).
RtfLabel1.LinkPressedColor = Colors.Cyan RtfLabel1.LinkPressedCornerRadius = 5 RtfLabel1.Text = "This {b}is{b} a text with {h/MyLink1}hyperlink{h}. " |
|
![]() |
LinkTextColor As Int [write only]
Sets the text color for the links (with LinkFormat = 2 or 3).
Others:
Enabled As Boolean
Locks the label for user actions (e.g. scrolling text, select text) or released it.
Tag As Object
Gets or sets the Tag value. This is a place holder which can be used to store additional data (like the standard label).
(to top)