[Lazarus] Autosize behaviour

Michael Van Canneyt michael at freepascal.org
Tue Apr 6 11:33:50 CEST 2010



On Tue, 6 Apr 2010, Mattias Gaertner wrote:

> On Tue, 6 Apr 2010 10:48:58 +0200 (CEST)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
>>
>>
>> On Tue, 6 Apr 2010, Hans-Peter Diettrich wrote:
>>
>>> Michael Van Canneyt schrieb:
>>>
>>>>>> I have been thinking about layout managers. I think that this should be
>>>>>> an add-on
>>>>>> to the currently existing layouting (to preserve delphi compatibility): I
>>>>>> imagine a component that one drops on a form. One sets the 'target'
>>>>>> control (control whose children should be managed) and some properties.
>>>>>
>>>>> I imagine a Layout property for TWinControls, or an intermediate layer,
>>>>> that is initialized to the Delphi compatible manager. That property then
>>>>> can be assigned any other layout manager.
>>>>
>>>> That is the same as what I am saying, only the arrow points in the opposite
>>>> direction.  I want to avoid this extra TWinControl property.
>>>
>>> I wonder how you want LCL code to use a dropped layout component. When no
>>> predefined property exists, every TWinControl had to be searched for an
>>> according component, whenever a layout method or property shall be accessed.
>>
>> I would use a mechanism similar to the datalink. As soon as you tell the
>> layout manager to manage a certain control, a hook is installed in the
>> control.
>
> And where is the hook stored?

In TWinControl, protected or even private.

>>> With a dedicated LayoutManager property, all anchor-docking related stuff
>>> could be moved from TWinControl into the AnchoredLayoutManager, and
>>> DockManager could be replaced (or merged with) the LayoutManager. In further
>>> steps the DockClient list could be removed, the Controls list can be used
>>> instead. Delphi compatibility can be maintained by delegation to the still
>>> existing elements.
>>
>> The reason I don't want to introduce the layoutmanager property is that it
>> simply does not make sense for all TWinControls. a TEdit does not need a
>> layoutmanager, only the parent of the TEdit needs one.
>
> Then don't publish it for TEdit.

I understand this, I thought of this also. 
But I think it is more clean if the hook is hidden completely; This
way one cannot 'forget' to publish it or publish it when it is not
needed.

Finally, it doesn't really matter. To my taste, my solution is cleaner.

Opinions may vary on what 'clean' is, of course :-)

Michael.




More information about the Lazarus mailing list