06-21-2006, 07:43 PM
06-21-2006, 07:51 PM
You can use GfxFont::getTextDimensions (YaglGfxFont_getTextDimensions in the wrapper):
Code:
Dim font As YaglGfxFont
Dim text As String
Dim x As UInteger, y As UInteger
...
text = "Hello, world"
YaglGfxFont_getTextDimensions(font, text, x, y)
06-21-2006, 08:43 PM
it doesn't seem to work the compiler yields the error
error 10: expected '=', found 'dispfont'
error 10: expected '=', found 'dispfont'
06-21-2006, 08:51 PM
Could you post your code?
06-21-2006, 09:00 PM
Code:
SUB makebutton (x1, y1, x2, y2, text$, idx)
z = buttonindex(idx)
If z = 0 Then leftcol = rgb(255, 255, 255): rightcol = rgb(200, 200, 200): fontcol = 0
If z = 1 Then leftcol = rgb(200, 200, 200): rightcol = rgb(255, 255, 255): fontcol = rgb(0, 0, 255)
YaglGfxDevice_SolidBox x1, y1, x2, y2, rgb(240, 240, 240), 1
YaglGfxDevice_Solidbox x1, y1, x2, y1 + 2, leftcol, 1
YaglGfxDevice_SolidBox x1, y1, x1 + 2, y2, leftcol, 1
YaglGfxDevice_SolidBox x2, y2, x2 - 2, y1, rightcol, 1
YaglGfxDevice_SolidBox x2, y2, x1, y2 - 2, rightcol, 1
YaglGfxFont_getTextDimensions dispfont, text$, strxlen, strylen
'YaglGfxFont_getTextDimensions
'strlen = len(text$) * 12
xlen = x2 - x1
ylen = y2 - y1
xdisp = (xlen - strxlen) \ 2
ydisp = (ylen - strylen) \ 2
YaglGfxDevice_Printat text$, x1 + xdisp, y1 + ydisp, fontcol, dispfont, 1
END SUB
06-21-2006, 09:57 PM
Its ok i figured out what's wrong. for some reason the function is YagGfxDevice, and is missing an l.
06-21-2006, 10:03 PM
Hmm, there's a typo in the latest released yaglwrapper.bi - change "YagGfxFont_getTextDimensions" to "YaglGfxFont_getTextDimensions" (add the "L").