Just one column, uses startdrawing which might be awful in many peoples eyes... but it does its job.
Code: Select all
;Listicongadget multiline works so-so, especially if you decide to go cross platform
;This is a simple workaround.
;Use it any way you want to
;Jesper Brännmark, 2011
mytext.s="This is a line that is longer than the actual listicongadget and will therefor be cut off on several lines"
Procedure AddGadgetItem_wrap(gadget.l,text.s)
width=300-30
StartDrawing(ImageOutput(0))
DrawingFont(FontID(0))
If TextWidth(text)<=width
AddGadgetItem(gadget.l,-1,TEXT.S);
Else
limit=0 : Repeat : limit+1 : Until TextWidth(Left(text,limit))>width : cut=limit
Repeat : cut-1 : Until Mid(text,cut,1)=" " Or Mid(text,cut,1)="-" Or cut=0
If cut=0 : cut=limit-1 : EndIf
AddGadgetItem(gadget.l,-1,Left(text,cut))
StopDrawing()
AddGadgetItem_wrap(gadget.l,Right(text,Len(text)-cut))
EndIf
StopDrawing()
EndProcedure
;
OpenWindow(0,0,0,400,400,"Listicongadget textwrap")
CreateImage(0,400,400)
LoadFont(0,"Arial",12)
ListIconGadget(0,0,0,400,400,"Question",300)
SetGadgetFont(0,FontID(0))
AddGadgetItem(0,-1,mytext) ;-gets cut off
AddGadgetItem(0,-1,"") ;empty line
AddGadgetItem_wrap(0,mytext) ;-splits into several lines
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow