GLBasic forum

Main forum => GLBasic - en => Topic started by: Richard Rae on 2007-Apr-20

Title: text
Post by: Richard Rae on 2007-Apr-20
Is there any way to centre justify printed text or any other justification(left,right)
Title: text
Post by: Schranz0r on 2007-Apr-20
I make a small function for you, one moment pls ;)
Title: text
Post by: Schranz0r on 2007-Apr-20
So i got it  :D

CENTER TEXT:

Code (glbasic) Select
// SX = String X (Center);    SY = StringY (Center)

FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION
TEXT RIGHT:
Code (glbasic) Select
FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
Text to the left are the normal Print ;)

For Example:

Code (glbasic) Select
GLOBAL WinX = 800
GLOBAL WinY = 600

SETSCREEN WinX,WinY,0




WHILE TRUE

PRINT "Whats up there",0,WinY/2+10
Print_R("Test at the right side of life..... XD",WinX,WinY/2,0) // Set the Text to the right
Print_C("Hello World",WinX/2,WinY/2+10,0) // Center Text

SHOWSCREEN
WEND
END




FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION



FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
Title: text
Post by: Richard Rae on 2007-Apr-20
Works great.Thank you.
Title: text
Post by: Schranz0r on 2007-Apr-20
no problem ;)