Hi RASHAD,
I've been following your thread with much interest

and always testing the codes on Linux
('cos from here I surf. else I'm on Win).
I find the latest code works best now. Still one thing never worked - there's no wrap. Today I searched, found a way
Inf0Byt3 wrote:As you probably know the text gadget doesn't wrap the text by itself, like on Windows.
Here's a snippet for enabling it
and implemented it:
Code: Select all
Global Text$,FSize,x,y,GW,GH,FColor,BColor,count
Global Dim A$(0)
Procedure TextGadgetEx(Gadget,x,y,GW,GH,FColor,BColor)
StartDrawing(WindowOutput(0))
DrawingFont(FontID(0))
For i = 1 To count
A$(i) = StringField(Text$,i, " ")
Next
; Debug count
; Debug i
k = 1
NLines = 1
While k <> count
TW = TW + TextWidth(A$(k))
If TW < GW
k = k + 1
Else
TW = 0
NLines = NLines + 1
EndIf
If (TW = (GW - 1) And FSize&1=1) Or (TW = (GW - 2) And FSize&1=0)
NLines = NLines + 1
EndIf
Wend
; Debug NLines
TH = TextHeight("W")
StopDrawing()
LH = NLines * TH
; Debug GW
; Debug LH
mLH = (GH - LH)/2
UseGadgetList(0)
result = ContainerGadget(#PB_Any, x, y,GW,GH,#PB_Container_Single)
SetGadgetColor(result,#PB_Gadget_BackColor, $006666)
TextGadget(Gadget,0,mLH-2,GW,LH,Text$,#PB_Text_Center)
SetGadgetColor(Gadget,#PB_Gadget_BackColor,BColor)
SetGadgetColor(Gadget,#PB_Gadget_FrontColor,FColor)
SetGadgetFont(Gadget,FontID(0))
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
gtk_label_set_line_wrap_(GadgetID(Gadget),1)
gtk_widget_set_size_request_(GadgetID(Gadget), GW, LH)
gtk_label_set_justify_(GadgetID(Gadget), #GTK_JUSTIFY_CENTER)
CompilerEndSelect
CloseGadgetList()
EndProcedure
FSize = 18
LoadFont(0,"Georgia",FSize)
Text$ = "Test Vertical and Horizontal Centered Text in Multiline TextGadget For MyTrial and more"
count = CountString(Text$," ") + 2
ReDim A$(count)
OpenWindow(0,0,0,300,200,"Edit Control VCenter",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadgetEx(0,10,10,280,180,$0002FF,$00ccff)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
It might not be the best or proper solution, but within limits of fontsizes and textamount it works fine. Maybe one of our Linux-pros might have a look over it.
(btw: I changed the colors to verify if and where they are supplied)
Two more hints:
- the font Georgia is available on both plattforms
- starting from fontsize 40 you get broken results
regards ~ Vera