TextWidth for MaxGUI

BlitzMax Forums/MaxGUI Module/TextWidth for MaxGUI

Rozek(Posted 2010) [#1]
Hello!

Is there an equivalent for the (Max2D) function TextWidth (and TextHeight) under MaxGUI?

Max2D uses TImageFonts, while MaxGUI uses TGUIFonts - as far as I know, these are not interchangeable (athough I do not know why we need different fonts for Max2D and MaxGUI)

Thanks in advance for any help!


degac(Posted 2010) [#2]
Hi,

at the moment there is not an equivalent function to TextWidth. The fonts are 'different' because they're handled one from Max2d graphic drivers, the other by the OS.
As - usualy - a GUI should be 'standard' to integrate with the OS environment (ie: other applications) there are not so many commands to 'change the skin' of a gadget. Therefore the lack of a TextWidth command.


Rozek(Posted 2010) [#3]
Hello!

I seem to have overlooked your answer until know - sorry for this!

Not having an equivalent is a real pity, because it makes GUIs with adaptive layout (like Java's AWT/Swing) much more difficult to implement - on the other side, a cross-platform runtime environment really needs adaptive layouting as fonts usually differ from platform to platform.

Meanwhile, I have implemented my own (skinned) mini-GUI on top of BlitzMAX canvases - and it seems to work fairly well...


ima747(Posted 2010) [#4]
I'd like to bump this feature request. Pretty much every time I need to make a label gadget it takes me an hour to get it right as I have to guess a size, test and correct until I get it right, then re-test on windows, and if I was targeting linux too I would have to test again... and that's with a manually set font (to override the system font, because who knows what people have their defaults set to for just size let alone the actual font...). And I have to start all over again if I need to re-word the label...

Being able to say "make my label as wide as it needs to be to fit this text please" would save a LOT of time... I had to resort to making a canvas just for a 2 line text label, and re-coded my own drop down menu in the canvas because it was easier than trying to get the sizes and positions right...

Another example. I want a line of text with one word in the middle a different color. The way I would like to do that is
Label 1, start of sentence, auto width
label 2, colored word, position at the end of label 1 and auto width, set color
label 3, end of sentence, position at the end of label 2, auto width
right now, I do exactly that but in a canvas with draw text because figuring out the sizes is impossible cross platform, multifont, and with dynamic content (sort of assumed if something is colored it's dynamic...)

so yea. GuiTextWidth() please... maybe GuiTextWidth(TGuiFont) and if it's null it uses default same as gadget fonts...
la


Rozek(Posted 2010) [#5]
add me to the list of users who would like to see that feature!


Paul "Taiphoz"(Posted 2011) [#6]
and me


jsp(Posted 2011) [#7]
Is skn3's solution may working for you:
http://www.blitzmax.com/Community/posts.php?topic=96230


Paul "Taiphoz"(Posted 2011) [#8]
I ended up just bashing in a quick fix as its something that I will probably never look at again unless the community changes how some of the code works with the IDE.

thanks for the link tho when or IF I ever try making some GUI stuff I will deff have another look at that code.