Recent

Author Topic: QuestionDlg behavior in Linux vs. Windows  (Read 1214 times)

MaxCuriosus

  • Full Member
  • ***
  • Posts: 111
QuestionDlg behavior in Linux vs. Windows
« on: July 04, 2020, 01:27:04 pm »
When compiling the code attached the order of the options (left-center-right) displayed by QuestionDlg is correct under Win8 but in reverse order under Deb9. Is this a matter of implementation or is it a bug?

Laz1.8.0 / FPC3.0.4 / Win8_64

Laz2.0.6 / FPC3.0.4 / Deb9_64

zeljko

  • Hero Member
  • *****
  • Posts: 1149
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #1 on: July 04, 2020, 02:04:54 pm »
No, it's not bug. It's about gtk widgetset - buttons in dialogs are in reverse order and it's normal behaviour of gtk.

howardpc

  • Hero Member
  • *****
  • Posts: 3553
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #2 on: July 04, 2020, 02:10:01 pm »
Different widgetsets espouse different conventions for layouts, affecting standard buttons, order of icons in the title bar and so on. Mac systems differ again from what you show.

If you want complete consistency of your app across all platforms in where every control gets positioned, you will have to go the non-native route and draw everything yourself (or use a library that does that), and avoid all system dialogs. The LCL, from the outset, has used native widgets for its basic controls.

jcdammeyer

  • Jr. Member
  • **
  • Posts: 72
  • Embedded System Developer
    • Automation Artisans Inc.
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #3 on: August 02, 2020, 04:15:15 am »
I've noticed a few differences between the exact same code compiled for WIN and Linux with either the Beagle or the Pi.
Fonts appear to be a big issue as shown by the spacing between lines on the TComboBox or the TListBox.

The TCombo box under windows also has a different behaviour from the two Linux systems.  Select the first item in the TComboBox and although it shows up it doesn't generate an OnChange event in Linux but does in Windows.

For example the Open/Close buttons are hidden until a selection is made in the TComboBox.  However, only if you select an entry from the second to last in the list.  So to get the buttons to show up in Linux you have to select the second available port in the list.  The buttons will then be set to visible in the OnChange Event handler.  Now you select the TComboBox again and select the first entry. 

At this point a user can select the open button to access the CANUSB device connected and dump messages while listening on the bus.

Text spacing is also an issue.  All three attached screens are identical source code within the Lazarus concept of write once, compile many times.    Some of the defaults like standard fonts and font size etc are different between Linux and Windows.  The Beagle and the Pi appear to behave the but differently from the WIN systems.  (Compiler is the same version on all three systems).

I will probably have to add something like this:
Code: Pascal  [Select][+][-]
  1. {$IFDEF LINUX}
  2.   //  definitions unique to Linux.
  3. {$ELSE}
  4.   // definitions unique to Windows.
  5. {$ENDIF}
  6.  

I don't know if there is a work-around with respect to the fonts.  There are a few other issues but overall I'm impressed with how similar the systems are.  The Main Form Caption shows on which system the porgram was run

jamie

  • Hero Member
  • *****
  • Posts: 3664
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #4 on: August 02, 2020, 03:15:39 pm »
In my opinion and really it's only my opinion the concept of Widget interfaces in the manner as they are constructed are over complicated and there for very hard to fix for the average user.

 The concept of Interface and Implementation has been around in the pascal language since the beginning and I don't understand why all libs and supporting files did not use that method instead ?

 All calls to make things cross platform could be in the interface section and all supporting code which would be different from platform to platform be in the implementation section and of course any units that are specific to that platform be in the uses section within the implementation section too.

 And for example any functions that exist on one target can be emulated on the other etc.

 so with this structure in mind, one could simply open a unit file from that install which would be in the common library files folder and fix it for their target.

 doing cross platform compiling would only mean a separate library path for the files.

 Just my opinion but it would make life easier for the average coder.

The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2266
  • Compiler Developer
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #5 on: August 02, 2020, 04:00:47 pm »
In my opinion and really it's only my opinion the concept of Widget interfaces in the manner as they are constructed are over complicated and there for very hard to fix for the average user.

 The concept of Interface and Implementation has been around in the pascal language since the beginning and I don't understand why all libs and supporting files did not use that method instead ?

 All calls to make things cross platform could be in the interface section and all supporting code which would be different from platform to platform be in the implementation section and of course any units that are specific to that platform be in the uses section within the implementation section too.

You forget functionality that is shared between the implementations. In your approach that would either need to be duplicated or the files would be riddled with includes to avoid code duplication. The LCL instead provides an abstraction layer for the widget set.

jcdammeyer

  • Jr. Member
  • **
  • Posts: 72
  • Embedded System Developer
    • Automation Artisans Inc.
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #6 on: August 02, 2020, 06:29:05 pm »
The LCL instead provides an abstraction layer for the widget set.

Are you also referring to my issue with fonts between platforms?  As my previous screen grabs show the Windows implementation does use the Courier New font and this screen grab shows how I set it up.

The Beagle for example doesn't have a 'Courier New' so it selects the next best thing which is 'sans' and 10 point. 

Is it possible to bring in a 'Courier New' fixed pitch font into the Linux systems like a Pi or Beaglebone?   Or better still is it possible to include as part of the Lazarus project file, the fonts used?  We drag along the ICON.  Although I haven't tried it with Lazarus we can embed a BMP without including it as a file can't we?

Is this perhaps a configuration feature I haven't found yet?

John



Thaddy

  • Hero Member
  • *****
  • Posts: 10524
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #7 on: August 02, 2020, 06:36:53 pm »
You can simply copy the TTF font to the linux font directory, but be aware there may be copyright issues for commercial applications.
It is always better to choose a font type without those issues.

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #8 on: August 02, 2020, 06:47:48 pm »
Hi!

After  copying your font files to the linux font directory
don't forget to update the font cache:

Code: Bash  [Select][+][-]
  1. fc-cache -f -v

Winni

jcdammeyer

  • Jr. Member
  • **
  • Posts: 72
  • Embedded System Developer
    • Automation Artisans Inc.
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #9 on: August 02, 2020, 07:43:47 pm »
I'm not sure the Courier New is covered under any copyright.   Or perhaps it should be just Courier? The windows ones are here. 
%windir%\fonts
Drag from there into my BBB Downloads folder.  Then with puTTy sign in and create a courier folder in
debian@ebb:/usr/share/fonts/truetype/courier$

Code: Bash  [Select][+][-]
  1. debian@ebb:/usr/share/fonts/truetype/courier$ sudo fc-cache -f -v
  2. /usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs
  3. /usr/share/fonts/X11: caching, new cache contents: 0 fonts, 3 dirs
  4. /usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
  5. /usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
  6. /usr/share/fonts/X11/misc: caching, new cache contents: 59 fonts, 0 dirs
  7. /usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
  8. /usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
  9. /usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs
  10. /usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs
  11. /usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs
  12. /usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs
  13. /usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs
  14. /usr/share/fonts/opentype: caching, new cache contents: 0 fonts, 1 dirs
  15. /usr/share/fonts/opentype/noto:
  16.  

Interesting side effect from this.  I then restart Lazarus and now select Courier as the font.  Compile and sure enough I now have courier as the text in the terminal window.   
Now close Lazarus and restart and the editor is now using Courier too.  I never told it to do that.  Not even sure how I'd tell it to start using courier.
Where is that done?
If I now move the courier fonts back to the debian user Downloads folder and rerun fc-cache.  And then restart Lazarus the editor fonts are back to what they were before.

I'll try it later this afternoon with the Pi3 and see if I get similar behaviour.  I realize that the target platform will create the look and feel of that platform for Lazarus.  That only makes sense.  But if I install Courier fonts for a list box why should it now change the look and feel?  Other than perhaps standard Lazarus expects Courier New for the editor and since it can't find it on the Beagle or Pi chooses the closest.  On the windows version it's Courier.

Implication is that we really need to have Courier of some sort installed when Lazarus is installed?

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #10 on: August 02, 2020, 07:59:12 pm »
Hi!

A good substitute for ,Windows fonts is the free Liberation Font.
It comes with a lot of Linux Distros.

Use Liberation sans as substitute for Arial.
Use Libration serif as substitute for Times New Roman and
Liberation mono for Courier.

Liberation can be downloaded here:

https://github.com/liberationfonts


Winni

Zoran

  • Hero Member
  • *****
  • Posts: 1592
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #11 on: August 02, 2020, 09:05:05 pm »
Yes, Liberation family is a good choice.

But is it possible to pack a font as a resource and use it in application without installing it on user's system?

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #12 on: August 02, 2020, 09:13:37 pm »
Yes, Liberation family is a good choice.

But is it possible to pack a font as a resource and use it in application without installing it on user's system?

Hi!

AFAIK this is not possible. I spend a lot of time for finding a solution but I missed.

Winni

Zoran

  • Hero Member
  • *****
  • Posts: 1592
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #13 on: August 02, 2020, 09:44:42 pm »
Yes, Liberation family is a good choice.

But is it possible to pack a font as a resource and use it in application without installing it on user's system?

Hi!

AFAIK this is not possible. I spend a lot of time for finding a solution but I missed.

Winni

Seems strange that you just can't do that, so I thought it had to be simple, although I couldn't find the way. :(
Thank you.

jcdammeyer

  • Jr. Member
  • **
  • Posts: 72
  • Embedded System Developer
    • Automation Artisans Inc.
Re: QuestionDlg behavior in Linux vs. Windows
« Reply #14 on: August 02, 2020, 10:07:39 pm »
AFAIK this is not possible. I spend a lot of time for finding a solution but I missed.
Winni

Too bad.  If you go back a few messages to the 3 screenshots I'd like to address a different issue.  I tried character font and height.  In neither case on the Beagle or Pi was I able to reduce the space between lines like it's shown on the Windows screen capture. 

What I want is what I see on the Windows version.  Is there some other parameter that is hidden that fixes the overall height of the white space above/below the font?  Changing the Height value from say -12 to -10 just makes the characters smaller.  The white space remains the same.

It does appear to be OS dependent since it's happening on both the Beagle and the Pi but not the PC.  Haven't got the space to set up the Linux PC to try it there.

 

TinyPortal © 2005-2018