Recent

Author Topic: Cross Platform Form/GUI Maintenance  (Read 8385 times)

sfeinst

  • Sr. Member
  • ****
  • Posts: 258
Cross Platform Form/GUI Maintenance
« on: February 25, 2010, 09:15:30 pm »
I have begun writing an app using Lazarus.  I've noticed that as I move between environments (in my case Windows and Linux), forms do not look so good.  If I create on Windows, the fonts are too large on Linux.  If I create on Linux, fonts are too small on Windows.  In both cases, some items do not line up when I switch.

I was wondering how other developers handle this.  What I began to do is put in a $IFDEF WINDOWS and a $IFDEF LINUX and then I set the fonts at startup.  But that does not always fix the problem (making a button large enough for Windows font may be too small or too large for the Linux font).  But it worked on the app so far.

Do you set the fonts and sizes in code?
Do you code fully in one environment and only build in the other so you realign and modify fonts prior to compiling?
Do you keep two copies of the lfm file?
Something else?

Thanks

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cross Platform Form/GUI Maintenance
« Reply #1 on: February 26, 2010, 10:22:25 am »
Read LCL AutoSizing, this will solve the size, position, and alignment problem. Don't know about fonts since I never set other than the default value.

sfeinst

  • Sr. Member
  • ****
  • Posts: 258
Re: Cross Platform Form/GUI Maintenance
« Reply #2 on: February 26, 2010, 03:00:49 pm »
Read LCL AutoSizing, this will solve the size, position, and alignment problem. Don't know about fonts since I never set other than the default value.

Thanks for the link.  It gives some useful info.  I think some of my alignment issues are font related.  As an example, I have a TLabeledEdit within a Group Box.  On Windows, it all fits, in Linux (because it tends to use a larger font - especially since it has to guess which Linux font to use to replace the Windows one), the label gets pushed outside of the group box.

I have changed the fonts on most items, I may try and reset them to the default to see what happens.

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Cross Platform Form/GUI Maintenance
« Reply #3 on: February 26, 2010, 03:20:01 pm »
This says something about fonts: http://wiki.lazarus.freepascal.org/Lazarus_For_Delphi_Users#TControl.Font.2FTControl.ParentFont

Anyway, my advice to you is just to always set AutoSize to true and use anchoring, I find it very helpful.

Also read this two articles:
http://wiki.lazarus.freepascal.org/Autosize_/_Layout
http://wiki.lazarus.freepascal.org/Anchor_Sides
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cross Platform Form/GUI Maintenance
« Reply #4 on: March 01, 2010, 07:33:00 am »
Quote
the label gets pushed outside of the group box
As Zoran points, this issue is related to autosizing and anchor sides. Set autosize to true so that the size is big enough for the font to appear as a whole, and set the (relevant) label anchors to the owner control (in your case, the group box).

sfeinst

  • Sr. Member
  • ****
  • Posts: 258
Re: Cross Platform Form/GUI Maintenance
« Reply #5 on: March 02, 2010, 03:44:06 pm »
Thanks for all of the information.  The sizing is improving.  Button widths tend to be inconsistent (I like all buttons to be the same width, but auto-sizing prevents that), but if I keep the text to be about the same size, then I can keep the buttons to be close to the same width.

 

TinyPortal © 2005-2018