Hi
Determine the longest line first
Use the proper font and font size to both the dummy TextGadget() and the EditorGadget()
Code: Select all
Global reqwidth
Procedure GetWIDTH(Text$)
dummy = TextGadget(#PB_Any,0,0,2000,24,text$)
SetGadgetFont(dummy,FontID(0))
reqwidth = GadgetWidth(dummy,#PB_Gadget_RequiredSize)+4
FreeGadget(dummy)
ProcedureReturn reqwidth
EndProcedure
LoadFont(0,"Tahoma",20)
Text$ = "yui ioiooooo ioooyyyoy oio o yoyo oyoyoioi oyioi"
If OpenWindow(0, 0, 0, 600, 300, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
GetWIDTH(Text$)
EditorGadget(1, 10, 10, reqwidth,130)
SetGadgetFont(1,FontID(0))
AddGadgetItem(1,0, Text$)
Repeat
Select WaitWindowEvent(10)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
EndSelect
Until Quit = 1
EndIf