Recent

Author Topic: [solved] How to override the caption getter & setter  (Read 1002 times)

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1289
[solved] How to override the caption getter & setter
« on: November 27, 2023, 08:15:14 am »
Hi everyone, I’m making a customized flowpanel like this
Tmyflowpanel = class(tflowpanel)

How do I override the getcaption and setcaption methods for caption property

it seems that it is declared in control like this
property Caption: TCaption read GetText write SetText stored IsCaptionStored;


It also seems to use methods called Function realgettext and Procedure realsettext. I’m not sure why there are so many different names
« Last Edit: November 29, 2023, 02:04:02 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Bart

  • Hero Member
  • *****
  • Posts: 5497
    • Bart en Mariska's Webstek
Re: How to override the caption getter & setter
« Reply #1 on: November 27, 2023, 10:47:44 am »
You should override RealGetText and RealSetText.

Bart

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1289
Re: How to override the caption getter & setter
« Reply #2 on: November 27, 2023, 02:11:34 pm »
Thanks for the  clarification.
Another thing that I don't understand is I'm trying to have space between the controls in the flowpanel using childsizing and none of the things seem to have any effect. so far I've tried

Code: Pascal  [Select][+][-]
  1.   ChildSizing.TopBottomSpacing := 5;
  2.   ChildSizing.VerticalSpacing := 5;
  3.   ChildSizing.HorizontalSpacing := 5;
  4.   ChildSizing.LeftRightSpacing := 10;
the controls are still touching despite of this.
What am I doing wrong ? do I have to put border spacing on every control instead? why doesn't child sizing work ?

Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

wp

  • Hero Member
  • *****
  • Posts: 12525
Re: How to override the caption getter & setter
« Reply #3 on: November 27, 2023, 03:38:48 pm »
The word "ChildSizing" is not used anywhere in customflowpanel.inc, therefore I guess that TFlowPanel uses its own layout procedure and ChildSizing is not effective.

It works to set the BorderSpacing of the child controls, and you can simplify this by calling
Code: Pascal  [Select][+][-]
  1. procedure FlowPanelMargins(APanel: TFlowPanel; Margin: Integer);
  2. var
  3.   i: Integer;
  4. begin
  5.   for i := 0 to APanel.ControlCount-1 do
  6.     APanel.Controls[i].BorderSpacing.Around := Margin;
  7. end;

But note that there is a difference here also: while normally the Around spaces are allowed to overlap, they do not overlap here and must be added, in other words: when you set Margin to 5 the distance between controls will be 10, but the outer margin will be 5. To have the left-most, right-most, top-most and bottom-most margins at the same visual value you should additionally set the FlowPanel's BorderWidth to 5.

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1289
Re: How to override the caption getter & setter
« Reply #4 on: November 28, 2023, 02:53:57 pm »
I’ve also noticed that in addition to border width.around there is also aroundleft /right/top/bottom. What is the purpose of those?
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

 

TinyPortal © 2005-2018