FormatTextAreaText

BlitzMax Forums/BlitzMax Beginners Area/FormatTextAreaText

Hi all

After trying many time by changing value I can't get my text changing color

FormatTextAreaText(textarea:TGadget,r,g,b,flags,pos=0,length=-1,units=1 )

what the flag for ? for what I see it change mode like Italic, bolt... I can't figure what the units is for?
anyone can help out?

thanks

See if this works for you:
'TextAreaText - Formating test

Local win:TGadget=CreateWindow("TextArea Test",40,60,440,280,0,1)
Local ta:TGadget=CreateTextArea(16,16,376,188,win,0)
SetGadgetText ta,"testing textarea text formating"
SetTextAreaFont ta,LoadGuiFont("tahoma",16)
SetTextAreaColor ta,255,255,255,1
SetTextAreaColor ta,0,0,0,0

Const NORMAL=0,BOLD=1,ITALICS=2

'LockTextArea ta
FormatTextAreaText ta,$77,$00,$00,BOLD,8,8
FormatTextAreaText ta,$44,$ff,$ff,ITALICS,17,4
FormatTextAreaText ta,$ff,$aa,$37,ITALICS+BOLD,22,9
'UnlockTextArea ta 


Repeat
	Select WaitEvent()
		'Case EVENT_GADGETACTION
		Case EVENT_WINDOWCLOSE
		Exit
	End Select
Forever


Another example to play with:
' FormatTextAreaText - example

Local win:TGadget=CreateWindow("FormatTextAreaText - example",80,90,378,320,0,WINDOW_TITLEBAR)
Local ta:TGadget=CreateTextArea(8,8,352,216,win,TEXTAREA_WORDWRAP)
Local btnNORMAL:TGadget=CreateButton("Normal",8,232,64,24,win,1)
Local btnBOLD:TGadget=CreateButton("Bold",80,232,64,24,win,1)
Local btnITALIC:TGadget=CreateButton("Italic",152,232,64,24,win,1)
Local btnBOLDITALIC:TGadget=CreateButton("Bold + Italic",224,232,136,24,win,1)
Local btnCOLOR:TGadget=CreateButton("Color",8,264,208,24,win,1)
Local btnRESET:TGadget=CreateButton("Restore text",224,264,136,24,win,1)

SetTextAreaFont ta,LoadGuiFont("tahoma",12)
SetGadgetText ta,"Select parts of this text and click buttons below"
SetTextAreaColor ta,255,255,255,1
SetTextAreaColor ta,0,0,0,0

Const NORMAL=0,BOLD=1,ITALICS=2

' =======

Repeat
	Select WaitEvent()
	Case EVENT_GADGETACTION
	Local taPOS=TextAreaCursor(ta)
	Local taLEN=TextAreaSelLen(ta)
	Select EventSource()
		Case btnNORMAL
		FormatTextAreaText ta,0,0,0,NORMAL,taPOS,taLEN
		Case btnBOLD
		FormatTextAreaText ta,0,0,0,BOLD,taPOS,taLEN
		Case btnITALIC
		FormatTextAreaText ta,0,0,0,ITALICS,taPOS,taLEN
		Case btnBOLDITALIC
		FormatTextAreaText ta,0,0,0,BOLD+ITALICS,taPOS,taLEN
		Case btnCOLOR
		rgb=RequestColor(0,0,0)
		r=RequestedRed() ; g=RequestedGreen() ; b=RequestedBlue()
		FormatTextAreaText ta,r,g,b,NORMAL,taPOS,taLEN
		Case btnRESET
		FormatTextAreaText ta,0,0,0,NORMAL
		SelectTextAreaText ta,0,0
	End Select
	Case EVENT_WINDOWCLOSE
	Exit
	End Select
Forever

End