Recent

Author Topic: TLabeledEdit persistence  (Read 1297 times)

nanobit

  • New member
  • *
  • Posts: 10
TLabeledEdit persistence
« on: October 18, 2018, 12:37:06 pm »
has Lazarus a way to unpublish (or default value) certain subcomponent properties so that they don't appear in the lfm file? Specifically I mean properties of TLabeledEdit.editLabel: AnchorSideXXX, Left, Top, because they are set automatically, not by the user.

Blaazen

  • Hero Member
  • *****
  • Posts: 2676
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabeledEdit persistence
« Reply #1 on: October 18, 2018, 01:07:28 pm »
Looking to ExtCtrls to TLabeledEdit source, solution can be to add four "unpublishing" lines:
Code: Pascal  [Select]
  1.   TBoundLabel = class(TCustomLabel)
  2.   public
  3.     constructor Create(TheOwner: TComponent); override;
  4.     property FocusControl;
  5.   published    
  6.     property AnchorSideLeft: TAnchorSide stored False;
  7.     property AnchorSideTop: TAnchorSide stored False;
  8.     property AnchorSideRight: TAnchorSide stored False;
  9.     property AnchorSideBottom: TAnchorSide stored False;
  10.     ...
  11.  
because anchoring is done in method TCustomLabeledEdit.DoPositionLabel and related properties are LabelPosition and LabelSpacing.
This change will need test whether the TLabeledEdit looks correctly when it is loaded from *.lfm.
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wp

  • Hero Member
  • *****
  • Posts: 5129
Re: TLabeledEdit persistence
« Reply #2 on: October 18, 2018, 02:28:11 pm »
Where are they published? TControl has AnchorSideXXX only as public properties, and as far as I can see there is no ancestor of TLabeledEdit which publishes them. So, I wonder why they are in the lfm at all?
« Last Edit: October 18, 2018, 02:30:46 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Blaazen

  • Hero Member
  • *****
  • Posts: 2676
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabeledEdit persistence
« Reply #3 on: October 18, 2018, 03:00:34 pm »
@ wp

No, TControl has them published. See unit Controls, line 1751 (trunk).
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wp

  • Hero Member
  • *****
  • Posts: 5129
Re: TLabeledEdit persistence
« Reply #4 on: October 18, 2018, 03:12:46 pm »
Ah, I stopped looking too early (at AnchorSide[xxx] which is public).

But then: why does not every other control have them? I do see that in components/ideintf/propedits TControl has the property editor THiddenPropertyEditor which "unpublishes" them for all controls. But again then: why is it there for TLabeledEdit which inherits from TControl, of course? And why do the makers of the LCL first publish a property for all TControls and unpublished it again? Looks very strange to me (at least beyond my horizon).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

nanobit

  • New member
  • *
  • Posts: 10
Re: TLabeledEdit persistence
« Reply #5 on: October 18, 2018, 03:28:37 pm »
Thank you! I've tested these without problems:
    property AnchorSideLeft stored False;
    property AnchorSideTop stored False;
    property AnchorSideRight stored False;
    property AnchorSideBottom stored False; 
    property Left stored False;
    property ParentColor default False;   
    property Top stored False;

Blaazen

  • Hero Member
  • *****
  • Posts: 2676
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabeledEdit persistence
« Reply #6 on: October 18, 2018, 04:51:57 pm »
Why "ParentColor default False"? It's for your purposes only or you want to fill issue on bugtracker?
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

nanobit

  • New member
  • *
  • Posts: 10
Re: TLabeledEdit persistence
« Reply #7 on: October 18, 2018, 09:44:52 pm »
I think one could use ParentColor-default False only in own projects, because ParentColor-default True is an old convention which cannot be reversed without more changes.

I will report the other six properties in the bugtracker.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: TLabeledEdit persistence
« Reply #8 on: October 19, 2018, 10:14:08 am »
I do see that in components/ideintf/propedits TControl has the property editor THiddenPropertyEditor which "unpublishes" them for all controls.
AFAIK THiddenPropertyEditor does not "unpublish" them. It merely hides them in the OI. Which is ok, because the anchor-editor should be used for them.

But they are still published for all other purposes (e.g. streaming)


wp

  • Hero Member
  • *****
  • Posts: 5129
Re: TLabeledEdit persistence
« Reply #9 on: October 19, 2018, 10:31:22 am »
Thanks for clarification. But I still don't understand: TControl publishes AnchorSideXXX properties, THiddenPropertyEditor removes them from the Object Inspector - ok. But I'd still expect them to be in the lfm file. But they are not (except for TBoundLabel of TLabeledEdit), and their declaration does not contain any "default" value or "stored" condition.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4949
    • wiki
Re: TLabeledEdit persistence
« Reply #10 on: October 19, 2018, 10:39:35 am »
If I edit them, then they are in the lfm.

Code: Pascal  [Select]
  1. object Form1: TForm1
  2.   AnchorSideTop.Side = asrCenter
  3. ...
  4.   LCLVersion = '2.1.0.0'
  5.   object Label1: TLabel
  6.     AnchorSideTop.Control = Owner
  7.     AnchorSideTop.Side = asrCenter
  8. ...
  9.  

TLabeledEdit changeds there values for TBoundLabes, so they are stored.

wp

  • Hero Member
  • *****
  • Posts: 5129
Re: TLabeledEdit persistence
« Reply #11 on: October 19, 2018, 11:56:38 am »
If I edit them, then they are in the lfm.
Sorry for these silly questions, but I must be missing something: Because TLabel and any other controls don't declare the AnchorSideXXX properties neither with a default value and nor with a "stored" directive the properties should be in the lfm even when they are not changed.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Blaazen

  • Hero Member
  • *****
  • Posts: 2676
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabeledEdit persistence
« Reply #12 on: October 19, 2018, 02:33:05 pm »
Because TAnchorSide is TPersistent with two published properties, which one has default value and the second is TControl (nil by default), so they are not stored to *.lfm.

EDIT: The same reason why there is not Font even if you set ParentFont := False;
« Last Edit: October 19, 2018, 02:38:00 pm by Blaazen »
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wp

  • Hero Member
  • *****
  • Posts: 5129
Re: TLabeledEdit persistence
« Reply #13 on: October 19, 2018, 02:56:02 pm »
Got it, thank you. I should have looked at TAnchorSide in more detail.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10