SetTextAreaTabs() Units

BlitzMax Forums/MaxGUI Module/SetTextAreaTabs() Units

SebHoll(Posted 2010) [#1]
Hi Guys,

I noticed that my tab stops were slightly different on Windows since I started using my new monitor, and so I went to investigate and very quickly got stuck as it isn't defined anywhere what the unit "tabs" actually is.

I was always under the impression that 1 tab unit was equal to the average character width, and so setting a tab unit of say 4 or 6 with a monospaced font would give the same spacing as typing 4 or 6 spaces.

This is certainly the way the FLTK text area works and was how I thought the Windows driver worked, until I revisited the code and noticed that it is doing a conversion along the lines of inches to pixels to points or something.

So my first question is, is there an agreed unit for tab spacing and if so, what is it?

And my second question, which unit should MaxGUI be using? I live the average character thing because it would scale with font sizes, but also because it's easy to implement :P.

Cheers!


Mark Tiffany(Posted 2010) [#2]
This has always bugged me. Tabs are based on a *graphical* size (according to skid), not characters.

See old bug report, moved out of the bug report forum ages back.

http://www.blitzbasic.com/Community/posts.php?topic=67295

I understand the argument, but would at least like a "SetMyOwnTextAreaTabPixelSize" command if they are deemed to be graphical to ensure consistency. Note that this might be something that would support not just regular tabs every 4 chars, but e.g. a tab at pixel 32,40,78,80,100 if you wanted. (yes, those are random numbers).


skidracer(Posted 2010) [#3]
Twips are indeed a bit fiddly. SetTextAreaTabs bevavior is possibly easier to justify (/pun) if you consider requirements of basic WYSIWIG, where unlike code editors with single fixed size font, tab stops live on a ruler on a physical page and are completely independent of the fonts in use.

BlitzPlus compatibility means perhaps there is too much of a compromise of the two as a BlitzTwip from memory was chosen to match a 9 point fixed font and the intention was to modify MaxIDE to scale tabs to match font size.

I would be happy to see a new SetTextAreaTabStops that matched the Cocoa method of configuration which from memory was the most flexible.


Mark Tiffany(Posted 2010) [#4]
Agreed - although in order scale the tabs with the font size, you would also need a means of retrieving the width of a font - GetFontWidth in addition to GetFontHeight. Of course would need to define some appropriate behaviour for non-fixed width fonts: an exception (ouch), a -1 result (doesn't help us scale the tabstops), or the average or largest font width of all 26xupper/lower chars???

(although just being able to set the graphical size of the tabs - and making it obvious in the IDE you are setting a graphical would be a start)