I adapt the window/gadget sizes between different OS (Linux, MacOS, Windows) to their respective font sizes.
The way I do that is to measure the width and height of the GUI font like this:
Code: Select all
StartDrawing(CanvasOutput(CanvasGadget(#PB_Any, 0, 0, 0, 0)))
FontWidth = TextWidth("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+[]\{}|;:,./<>?'")
FontHeight = TextHeight("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+[]\{}|;:,./<>?'")
StopDrawing()
On Linux (ManjaroBox) the reported width is 897, the height is 19.
On MacOS (Mavericks) the reported width is 578, the height is 15.
On Windows 7 the reported width is 677, the height is 16.
Depending on the original OS (font size) a resize factor is calculated.
(WidthFactor = TextWidth / TextWidthOfOriginalOsWhereTheGuiWasDesigned)
The positions of the gadgets and the width/height of the windows/gadgets are multiplied by the factor.
(all gadgets are treated the same)
It works fabulous between Linux and Windows, but on MacOS it's really bad because the width/height of the gadgets do not match the width/height that is set.
On MacOS:
The gadgets are not wide enough to fit the text.
Anyhow, to get it somewhat OK on MacOS I have to multiply the calculated factor by 1.5 which seems odd.
However, the ComboBoxGadget height is smaller than the set height and the StringGadget height is too big (bigger than buttons with the same set height). The panel has also some issues and I assume other gadgets as well. Didn't look at all gadgets...
IMHO the gadgets that look the most homogenuous along the board are the ones on Linux drawn by GTK3 (which is a real surprise for me), even though the original OS - where the GUI was designed - was Windows 7.
(Windows 7 looks OK as well)
Why are the gadgets on MacOS so crooked?
Is my solution OK?
Or is there is a better way to fix it?
Interestingly when the built-in XML gui commands of PureBasic are used to draw gadgets, the gadgets seem to fit the font nicely; what library is used there?
Maybe the best way to fix differences between OS font sizes is to use the built-in XML gui commands of PureBasic, but drawing busy user interfaces is very cumbersome and error prone.