* * *

Author Topic: Autosize mechanism  (Read 2545 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 7115
Re: Autosize mechanism
« Reply #15 on: July 07, 2018, 12:08:44 pm »
People will be amazed how many things break after changing private to strict private. The latter has always been the intention of the language, the former was and still is open to miss-use.
Change private to strict private and the code does what you actually mean. (strict private is a kind of misnomer, should not have been necessary)
« Last Edit: July 07, 2018, 12:31:18 pm by Thaddy »
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.

taazz

  • Hero Member
  • *****
  • Posts: 5344
Re: Autosize mechanism
« Reply #16 on: July 07, 2018, 12:33:01 pm »
People will be amazed how many things break after changing private to strict private. The latter has always been the intention of the language, the former was and still is open to miss-use.
Change private to strict private and the code does what you actually mean. (strict private is a kind of misnomer, should not have been necessary)
well I know that my code breaks, already tried it, so can't be very critical about other peoples code, but this method is the perfect example of what not to do.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3524
  • I like bugs.
Re: Autosize mechanism
« Reply #17 on: July 08, 2018, 12:22:29 am »
as for the existing interface comment you haven't answer my original question, I want to change the size of a control and not inform anyone about that change how it is done? I do not want the parent to be updated I do not want the layout to be recalculated or changed in any way. I just want to change the control's size. Go show me how.
TControl has DisableAutoSizing / EnableAutoSizing. You can play with them.
If your control's parent is not autosized, AFAIK it will not be updated whatever your control does.
Otherwise I don't know. I am not a component design expert. The LCL layout system is also not done by me.
I wonder why you so desperately try to find problems in this system. It feels unreasonable.

About accessing private variables of other classes: It is a useful feature between tightly coupled classes which must be placed in the same unit anyway.
Yes, maybe the current "strict private" should be called "private" and the current "private" should be called "unit private" or similar.
Until it gets changed it is OK to access "private" variables of tightly coupled classes.
TControl and TWinControl are tightly coupled because of their parent / child relation among other things.
« Last Edit: July 08, 2018, 12:24:21 am by JuhaManninen »

taazz

  • Hero Member
  • *****
  • Posts: 5344
Re: Autosize mechanism
« Reply #18 on: July 08, 2018, 12:35:08 am »
as for the existing interface comment you haven't answer my original question, I want to change the size of a control and not inform anyone about that change how it is done? I do not want the parent to be updated I do not want the layout to be recalculated or changed in any way. I just want to change the control's size. Go show me how.
TControl has DisableAutoSizing / EnableAutoSizing. You can play with them.
If your control's parent is not autosized, AFAIK it will not be updated whatever your control does.
Otherwise I don't know. I am not a component design expert. The LCL layout system is also not done by me.
I wonder why you so desperately try to find problems in this system. It feels unreasonable.
And here I thought we had a good discussion of good and bad design and all that, so your or only goal was to "simply dispel the negativity I cast on the library" sorry I wasted your time. It will not happen again.
About accessing private variables of other classes: It is a useful feature between tightly coupled classes which must be placed in the same unit anyway.
Yes, maybe the current "strict private" should be called "private" and the current "private" should be called "unit private" or similar.
Until it gets changed it is OK to access "private" variables of tightly coupled classes.
TControl and TWinControl are tightly coupled because of their parent / child relation among other things.
I never said that tight coupling is not a valid choice (a bad choice but valid) I only said that you do not mess with other objects internals aka direct access to their private fields.

As always have fun and sorry for wasting your time.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

kupferstecher

  • Full Member
  • ***
  • Posts: 218
Re: Autosize mechanism
« Reply #19 on: July 08, 2018, 10:50:32 am »
Is there some documentation when resizing and repaint of controls are triggered? I'd like to understand it, also the discussion you have. But still I don't really grap it.

In a programm that I made with some custom controls I added a WriteLn in the paint procedure. The paint procedure appearently was repeatedly called several times at the moment of creation and on normal programm execution often twice. I guessed it had to do with Resize events, as normally I would expect the paint procedure always to be called just once for each change. I don't have example code here now, I encountered that a longer time before. That certain case also is not important for me, I just would like to understand better in what circumstances a resize is fired.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3524
  • I like bugs.
Re: Autosize mechanism
« Reply #20 on: July 08, 2018, 12:48:40 pm »
Is there some documentation when resizing and repaint of controls are triggered? I'd like to understand it, also the discussion you have. But still I don't really grap it.
http://wiki.freepascal.org/Autosize_/_Layout

kupferstecher

  • Full Member
  • ***
  • Posts: 218
Re: Autosize mechanism
« Reply #21 on: July 08, 2018, 09:03:35 pm »
Ok, thank You!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus