TFLine
Source: source/classes/fline.prg
Standalone class
TFLine (Formatted Line) is a utility class for composing a formatted line from multiple
styled text fragments. Each fragment can have its own font, color, and alignment. TFLine
is used in conjunction with TSay:oLine to render rich text labels and with TReport's
formatted line output. The class maintains an array of text, font, and color triplets that
are drawn as a single line with word wrap controlled by lCrLf.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
oUp | Object | Linked upstream object (used in line chains) |
oDown | Object | Linked downstream object |
nalign | Numeric | Line alignment value (0 = default) |
aText | Array | Array of text strings for each fragment |
aFonts | Array | Array of font objects or indexes for each fragment |
aColors | Array | Array of color values for each fragment |
lCrLf | Logical | Insert carriage return/line feed after this line |
Methods
| Method | Description |
|---|---|
New( nalign, aText, aFonts, aColors, lCrLf ) | Create a formatted line with the given fragments. Defaults: {}, {}, {}, 0, .F. |
End() | Release linked objects (sets oUp and oDown to NIL) |
Example: Styled Text Fragments
#include "FiveWin.ch"
function FormattedLabel()
local oSay, oLine
DEFINE FONT oFont1 NAME "Arial" SIZE 0, -24
DEFINE FONT oFont2 NAME "Arial" SIZE 0, -18 BOLD
oLine := TFLine():New( 0, ;
{ "Welcome ", "FiveWin ", "User" }, ;
{ oFont1, oFont2, oFont1 }, ;
{ CLR_BLUE, CLR_RED, CLR_BLACK } )
// Use oLine with TSay for display
@ 10, 10 SAY oSay PROMPT "" OF oWnd SIZE 300, 50
oSay:oLine := oLine
oSay:lTransparent := .T.
return nil
Notes
- TFLine is primarily used internally by TSay and TReport to support multi-style text rendering on a single line.
- Each array element in
aText,aFonts, andaColorscorresponds to one styled fragment. The fragments are concatenated horizontally. - Set
lCrLf := .T.to force a line break after this formatted line. - The
oUpandoDownpointers enable chaining multiple TFLine objects together.