Recent

Author Topic: [SOLVED] TLabeledEdit.EditLabel.Layout not working  (Read 2579 times)

jipété

  • Full Member
  • ***
  • Posts: 113
[SOLVED] TLabeledEdit.EditLabel.Layout not working
« on: December 05, 2023, 10:30:34 am »
Hello,

On the image below one can see 3 TLabeledEdit with 0 code, just setup in the Object's Inspector with Alignment : taLeftJustify, taCenter, taRightJustify and everything's well working.
OK.

But trying with EditLabel.Layout and using tlBottom (led1) or tlCenter (led2) or tlTop (led3), I cannot see the EditLabel moving up and down...

Same behaviour in Linux Debian Bullseye 11.8 and Windows Seven64 bits, with FPC 3.2.2, Lazarus 2.2.6 and Gtk 2.8.

What can I do ?

Regards,
« Last Edit: December 05, 2023, 01:10:21 pm by jipété »

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #1 on: December 05, 2023, 10:56:46 am »
I just tested it with my Lazarus 2.2.6 GTK2 on Ubuntu Mate 23.10, same result. Changing the Layout had no effect. I think it is a bug.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #2 on: December 05, 2023, 11:10:25 am »
I would not call it a bug, but the price to be paid for the laziness to position an edit and a label in a single operation. And vertical centering a label at the left or right of the edit is the most natural way to do it. This way it is hard-coded in the TCustomLabeledEdit, and showing the Layout property in the object inspector is just because it is published by TLabel, but it has no effect any more due to anchoring.
Code: Pascal  [Select][+][-]
  1. procedure TCustomLabeledEdit.DoPositionLabel;
  2. begin
  3.   ...
  4.   case FLabelPosition of
  5.     ...
  6.     lpLeft :
  7.       begin
  8.         FEditLabel.AnchorToCompanion(akRight,FLabelSpacing,Self);
  9.         FEditLabel.AnchorVerticalCenterTo(Self);
  10.       end;
  11.     lpRight:
  12.       begin
  13.         FEditLabel.AnchorToCompanion(akLeft,FLabelSpacing,Self);
  14.         FEditLabel.AnchorVerticalCenterTo(Self);
  15.       end;
  16.   end;
  17.   ...
  18. end;
If you want full control over positions you still can use separate TLabel and TEdit controls.

jipété

  • Full Member
  • ***
  • Posts: 113
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #3 on: December 05, 2023, 11:31:22 am »
Well, thanks for your answers.

If you want full control over positions you still can use separate TLabel and TEdit controls.
it is not what I want.
What I want ("What God wants" sings Roger Waters, lol) is... read that, found in the Objects' Inspector little help :
Quote
Layout is a TTextLayout property with the vertical alignment used for the text displayed in the control. The default value for the property is tlTop. Changing the value in Layout causes the Invalidate method to be called to redraw the control.

Use the Alignment property to control the horizontal alignment for the text in the control.
Both sentences come together as if they were God's speech but the first is wrong, and both are displayed without writing one word 'bout the problem.

So please update that help and we will no more spend (loose ?) time trying to work with something broken.
EDIT : or better, modify a little bit the component and hide that option and the related help. /EDIT
« Last Edit: December 05, 2023, 11:38:51 am by jipété »

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #4 on: December 05, 2023, 12:33:27 pm »
Since it would be more work to document the removal of the Layout property of the EditLabel (since removing a published property is a code-breaking change) than to fix the issue, I decided to remove the vertical anchoring of the label to the edit's center and to change the default of EditLabel.Layout to tlCenter so that there is no change to the current visual situation. Now EditLabel.Layout is working.

And while doing this I noticed that there is no Alignment property for the label to allow horizontal adjustment when the label is above or below the edit. This was also an easy change. (TLabeledEdit.EditLabel.Alignment is independent of TLabeledEdit.Alignment)

Please test with Laz/main, it should work. See the attached screenshot.

But still: TLabeledEdit is a component that I would not use. Look what happens when the label is above/below the edit and is longer than the edit's width. Or when the label is at the left/right and consists of multiple lines. Or when you use the Anchor Editor to anchor the top of a LabeledEdit (with top label) to the top of its parent...
« Last Edit: December 05, 2023, 12:35:02 pm by wp »

jipété

  • Full Member
  • ***
  • Posts: 113
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #5 on: December 05, 2023, 01:07:05 pm »
Hi,

Please test with Laz/main, it should work.
Dunno how to do that, so I'll wait for the official laz 3.0.

TLabeledEdit is a component that I would not use.
Very usable for little things, for example, the attached sample_labelededit.png

Thanks a lot for this fast help,
and Happy Xmas !
« Last Edit: December 05, 2023, 01:09:45 pm by jipété »

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #6 on: December 05, 2023, 01:39:17 pm »
Please test with Laz/main, it should work.
Dunno how to do that, so I'll wait for the official laz 3.0.
No, sorry, this is a new feature and will not be in there. The next new-feature release will be 4.0 which - taking the time between previous releases - very probably will not be before 2025...

If you don't want to wait so long you will have to patch three files from your current release. Please make a backup copy of the files to be changed since I cannot guarantee that the patched IDE will compile.
  • Load file "customlabelededit.inc" from folder lcl/include of your Lazarus installation. Find procedure TCustomLabeledEdit.DoPositionLabel. In the block "case FLabelPosition", remove the two "FLabelEdit.AnchorVerticalCenterTo(...)" lines; they are in the lpLeft and lpRight cases (these are the lines highlighted in the earlier post).
  • Load file "boundlabel.inc" from the same folder. It contains only a single procedure, "constructor TBoundlabel.Create(...)". Add two lines: "Alignment := taLeftJustify" and "Layout := tlCenter".
  • Finally load file "extctrls.pp" in folder lcl. Find the declaration of TBoundLabel (about line 970). In the "published" section of the declaration add "property Alignment", and change the line "property Layout" to be "property Layout default tlCenter;"
  • Now rebuild the IDE: go to "Tools" > "Configure Build Lazarus", in the "Clean up" box check "Clean all" and "Switch after building to automatically". Then click "Build" and wait until the IDE restarts.
  • Don't forget that you'll have to repeat these steps whenever you install a new Lazarus version.
« Last Edit: December 05, 2023, 01:43:01 pm by wp »

jipété

  • Full Member
  • ***
  • Posts: 113
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #7 on: December 05, 2023, 05:41:46 pm »
Hi,

Quote
remove the two "FLabelEdit.AnchorVerticalCenterTo(...)" lines
do you mean
Quote
remove the two "FEditLabel.AnchorVerticalCenterTo(...)" lines
?
I assumed "yes".

Then, after all changes done, rebuild of IDE :

Code: Pascal  [Select][+][-]
  1. Nettoyer les codes sources de Lazarus: Code de sortie 2, Erreurs : 1
  2. make[2]: *** interfaces/carbon: No such file or directory.  Stop.
  3. make[1]: *** [Makefile:5176: cleanall] Error 2
  4. Error: make: *** [Makefile:3865: cleanlaz] Error 2
  5.  
re-Rebuild with original parameters --> "one or more packages are missing. See Packaging Graph for help" and there is nothing written in red on this graph...

I remember a problem with RichMemo (no way to install it using Online Package Manager) and now, I cannot rebuild my ide ; everytime I rebuild, I get
Quote
printer4lazarus.pas(11,29) Fatal: Impossible de trouver WinUtilPrn utilisé par Printer4Lazarus. Vérifier le chemin de recherche du paquet Printer4Lazarus ; essayer une reconstruction propre ; vérifier la clause uses de la section implementation..
I don't understand why the package Printer4Lazarus wants WinUtilPrn when I'm running Linux, and I cannot remove that package nor the Printer4Lazarus package

This stuff drives me nuts  :'(.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #8 on: December 05, 2023, 06:15:52 pm »
"interfaces/carbon"? I thought you are on Linux Debian and on Windows 7?

An which system do you get the compilation error?

Tell me your exact Lazarus and FPC version so that I can try my instructions myself on a similar system.

Can you still start the IDE? (*) Restore the backup of the changed files that you hopefully had created. Then try to rebuild the IDE again. If you cannot, you seem to have a general configuration issue independent of the changes that I proposed.

In this case, at first find out the configuration folder with your user settings: Go to "View" > "IDE Internals" > "About IDE", note the directory listed in the line "Primary config directory". Close the IDE. Rename this directory so that the IDE can use default settings. Restart the IDE, there may be an error message about configuration error (because your current IDE does not match the default settings), ignore, and try to rebuild the IDE again ("Tools" > "Configure Build Lazarus" etc, like in the previous commit).

If the IDE can be built, restore your personal settings and install your packages again step by step. Decide whether you really need all packages - a slim system is easier to maintain.

(*) If you cannot start the IDE there should be a backup version of the IDE before the failed new installation. In Windows it is called lazarus.old.exe, in Linux probably similarly. Delete the lazarus.exe and rename the lazarus.old.exe to lazarus.exe (on Linux accordingly), and you should have the old IDE again.

jipété

  • Full Member
  • ***
  • Posts: 113
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #9 on: December 05, 2023, 06:57:02 pm »
Hi,

I'm using Linux and Windows7 is one of my virtual machines.

Compil error with Linux.

Laz 2.2.6, FPC 3.2.2

Quote
Then try to rebuild the IDE again. If you cannot, you seem to have a general configuration issue independent of the changes that I proposed.
Absolutely right.

Quote
in this case, at first find out the configuration folder with your user settings: Go to "View" > "IDE Internals" > "About IDE", note the directory listed in the line "Primary config directory". Close the IDE. Rename this directory so that the IDE can use default settings. Restart the IDE, there may be an error message about configuration error (because your current IDE does not match the default settings), ignore, and try to rebuild the IDE again ("Tools" > "Configure Build Lazarus" etc, like in the previous commit).
So I closed the ide, changed the name of the folder, restarted the ide and got an error message :
Package "Printer4Lazarus" is installed but no valid package file .lpk found.
Fake package created.
[ OK ]
then a new ide appears, I try to rebuild it and same "interfaces/carbon" error is displayed...

Revert to good old ide and now it cannot be rebuild due to others broken dependancies, looking in files not used for years...

And last but not least, now, I have lost the green panel hosting the 3 labelededits and tje 3 labelededits, but if I compile that project, there is no errors......

Well, I'm tired, it's time to play with backups.

dsiders

  • Hero Member
  • *****
  • Posts: 1084
Re: TLabeledEdit.EditLabel.Layout not working
« Reply #10 on: December 05, 2023, 10:03:40 pm »
Well, thanks for your answers.

If you want full control over positions you still can use separate TLabel and TEdit controls.
it is not what I want.
What I want ("What God wants" sings Roger Waters, lol) is... read that, found in the Objects' Inspector little help :
Quote
Layout is a TTextLayout property with the vertical alignment used for the text displayed in the control. The default value for the property is tlTop. Changing the value in Layout causes the Invalidate method to be called to redraw the control.

Use the Alignment property to control the horizontal alignment for the text in the control.
Both sentences come together as if they were God's speech but the first is wrong, and both are displayed without writing one word 'bout the problem.

So please update that help and we will no more spend (loose ?) time trying to work with something broken.
EDIT : or better, modify a little bit the component and hide that option and the related help. /EDIT

Documentation can always be improved. Based on the changes submitted by Werner, topics will be updated... but they will not appear in fixes_3_0 either.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #11 on: December 06, 2023, 12:37:48 am »
Hi,

I'm using Linux and Windows7 is one of my virtual machines.

Compil error with Linux.

Laz 2.2.6, FPC 3.2.2

Quote
Then try to rebuild the IDE again. If you cannot, you seem to have a general configuration issue independent of the changes that I proposed.
Absolutely right.

Quote
in this case, at first find out the configuration folder with your user settings: Go to "View" > "IDE Internals" > "About IDE", note the directory listed in the line "Primary config directory". Close the IDE. Rename this directory so that the IDE can use default settings. Restart the IDE, there may be an error message about configuration error (because your current IDE does not match the default settings), ignore, and try to rebuild the IDE again ("Tools" > "Configure Build Lazarus" etc, like in the previous commit).
So I closed the ide, changed the name of the folder, restarted the ide and got an error message :
Package "Printer4Lazarus" is installed but no valid package file .lpk found.
Fake package created.
[ OK ]
then a new ide appears, I try to rebuild it and same "interfaces/carbon" error is displayed...

Revert to good old ide and now it cannot be rebuild due to others broken dependancies, looking in files not used for years...

And last but not least, now, I have lost the green panel hosting the 3 labelededits and tje 3 labelededits, but if I compile that project, there is no errors......

Well, I'm tired, it's time to play with backups.
I have Laz 3.0RC1 in a VM with Debian 12. Downloaded V2.2.6 from the Lazarus site (https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%202.2.6/lazarus-project_2.2.6-0_amd64.deb/download) and installed it over the v3RC1 to have a similar system like you.

Started the new v2.2.6 as root (sudo startlazarus) and edited the three files as I described above (root is required because I don't have write permission in the lazarus installation directory as normal user). Tried to rebuild the IDE, there were some issues which I forgot, maybe in relation to the previous installation that I had used before. One of them was an empty component palette. Solved this by doing a "cd" to /usr/share/lazarus/2.2.6 and running "sudo make bigide" - ok. Then moved back to my home directory, called startlazarus (now without sudo) - there was the expected error message about missing packages. I opened "Tools" > "Install/uninstall packages" and removed those packages in the left list which did not have an icon (i.e. were not found), then built the IDE again. OK. After the next start the TLabeledEdit was changed as intended.

Unlike what I wrote above I had problems when doing a clean rebuild, there were lots of error messages, among them also "interfaces/carbon" thing. Unfortunately I do not know too much about Linux to attempt an explanation. However, doing a simple rebuild ("Tools" > "Build Lazarus with Profile..") was successful.

jipété

  • Full Member
  • ***
  • Posts: 113
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #12 on: December 06, 2023, 11:52:35 am »
Hello,

Thanks for your try, no time now, but tomorrow...

So, carefully followed your yesterday's instructions in a VirtualMachine with Debian 11 and Laz 3.0rc1 / FPC 3.2.2, and the TLabeledEdit is still broken !
I asked for tlTop, tlCenter and tlBottom, but after F9, the three labels are identical.

And by the way, I cannot use the grip of the StatusBar of the Source Editor window to reduce his size : it's not working... I can enlarge but cannot reduce, really not a good idea : sometimes, desktop of VM are not so big as the host screen.
And I cannot reduce the height of the Objects' Inspector...

Notice that I'm off, from now till tomorrow.
Thx,

jipété

  • Full Member
  • ***
  • Posts: 113
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #13 on: December 06, 2023, 12:00:58 pm »
... Solved this by doing a "cd" to /usr/share/lazarus/2.2.6 and running "sudo make bigide" - ok.
I've tried the same "make bigide" as root, but at the end of the job, I read :
Code: Pascal  [Select][+][-]
  1. (3104) Compiling ./win32/winutilprn.pas
  2. /usr/share/lazarus/2.2.6/components/printers/./win32/winutilprn.pas(27,2) Fatal: (2022) User defined: This unit is reserved to Win32/Win64
  3. Fatal: (1018) Compilation aborted
  4. make[2]: *** [Makefile:3724 : printer4lazarus.ppu] Erreur 1
  5. make[2] : on quitte le répertoire « /usr/share/lazarus/2.2.6/components/printers »
  6. make[1]: *** [Makefile:1827 : bigide] Erreur 2
  7. make[1] : on quitte le répertoire « /usr/share/lazarus/2.2.6/components »
  8. make: *** [Makefile:3817 : bigidecomponents] Erreur 2

I'm lost...
I really don't understand why the tool needs a Win32 file when I'm Linux native...

Maybe a broken or wrong config file, but which one ???

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: [SOLVED] TLabeledEdit.EditLabel.Layout not working
« Reply #14 on: December 06, 2023, 12:27:05 pm »
I asked for tlTop, tlCenter and tlBottom, but after F9, the three labels are identical.
You still have the old TLabeledEdit - I can see this in your ObjectInspector screenshot which does not display the new Alignment property immededately below the gray "EditLabel". Probably you compiled the IDE as root, and this will write the binary to /usr/share/lazarus. But normally you are not root, and in order to be able to compile the IDE here too the compilation goes into your home directory. And the startlazarus program allows to select between the two versions.

So, simply rebuild the IDE again as normal user (after having made the source changes as root), and if startlazarus asks you to select the version pick the custom version.

Code: Pascal  [Select][+][-]
  1. (3104) Compiling ./win32/winutilprn.pas
  2. /usr/share/lazarus/2.2.6/components/printers/./win32/winutilprn.pas(27,2) Fatal: (2022) User defined: This unit is reserved to Win32/Win64
  3. make[2]: *** [Makefile:3724 : printer4lazarus.ppu] Erreur 1
  4.  
I really don't understand why the tool needs a Win32 file when I'm Linux native...
I have no idea...

 

TinyPortal © 2005-2018