An EditorGadget() can work with RTf texts, as RASHAD wrote you can use WordPad for creating a text file and include it into your code like this:
Code: Select all
#EmbeddedTextFileName$ = "<Your-RTF-File-to-use>"
Procedure.s GetRichText()
Protected rtftext$
; read rich text formatted text
rtftext$ = PeekS(?RtfDialogText, ?RtfDialogText_End - ?RtfDialogText, #PB_UTF8 | #PB_ByteLength) ; get text from embedded rtf file
; replace Program constants
; rtftext$ = ReplaceString(rtftext$, "$ProgramName$", #ProgramName$)
; rtftext$ = ReplaceString(rtftext$, "$ProgramAuthor$", #ProgramAuthor$)
ProcedureReturn rtftext$
EndProcedure
DataSection
RtfDialogText: ; start label
IncludeBinary(#EmbeddedTextFileName$)
RtfDialogText_End: ; end label
EndDataSection
; schnipp
; .. somewhere in your code
EditorGadget(#GADGET_edtDummy, 8, 8, 200, 120)
SetGadgetText(#GADGET_edtDummy, GetRichText())
; schnapp
If you want create the text directly in your code, you should know some basics about the rtf format like this.
Code: Select all
Procedure.s GetRichText()
Protected rtftext$
rtftext$ = "{\rtf1\ansi\deff0" +
"{\fonttbl; " +
"\f0 Segoe UI; " +
"\f1 Courier;" +
"}" +
"\viewkind0 " + ; \viewkindN .. 0:None, 1:Page Layout view, 2:Outline view, 3:Master Document view, 4:Normal view, 5:Online Layout view
"\viewzk2 " + ; \viewzkN .. zoom kind -> 0:None, 1:Full page, 2:Best fit
; color table cf1;cf2; ; reset by cf0
"{\colortbl;" +
"\red0\green0\blue0;" + ; <--> black
"\red255\green0\blue0;" + ; <--> red
"\red0\green0\blue139;" + ; <--> kind of blue (??)
"\red0\green0\blue128;" + ; <--> blue
"\red128\green128\blue128;" + ; <--> gray
"}" + ; end of color definition block
"" ; end of header
; start the content
rtftext$ + "\pard\cf3\fs40 <Here comes the text> \line\par " ; \pard:default paragraph \qc:Centered
rtftext$ + "\pard\cf0\fs18 " + ; new paragraph
"here comes another text" +
"\pard" + ;
; "{\i This} is a " + #CRLF$ + ;
; "formatted {\b text}." + #CRLF$ + ;
; "\par" + #CRLF$ + ;
; "\cf2\f1 And here we have a colored text in courier :) \par " + #CRLF$ +
; "\cf3\f0\fs24 and another colored text. \par " + #CRLF$ + ;
"}"
; end of rtf text
ProcedureReturn rtftext$
EndProcedure
Keep in mind, that the EditorGadget is looking for the starting "{\rtf1" and ending "}" characters. Without the correct syntax you will see nothing.
This is the reason why you cannot use the AddGadgetItem() procedure to add more text lines. You have to use something else, like this.
Code: Select all
Procedure AddOutputColoredText(Gadget, Text.s, Color) ; EditorGadget()
Protected hGad, format.CHARFORMAT2
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = #CFM_COLOR
format\crTextColor = Color
hGad = GadgetID(Gadget)
SendMessage_(hGad, #EM_SETSEL, -1, -1)
SendMessage_(hGad, #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
SendMessage_(hGad, #EM_REPLACESEL, 0, Text)
EndProcedure
Happy coding and stay healthy.