[Lazarus] TPanel bevel and client size

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Feb 13 11:23:10 CET 2010


On Sat, 13 Feb 2010 05:39:32 +0100
Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:

> Mattias Gärtner schrieb:
> 
> >>> Bevel reduces the AdjustClientRect, which is ClientRect minus the 
> >>> Bevels.
> >>> ClientWidth is the client area width from the widgetset. The bevels are
> >>> custom drawn by TPanel and therefore not in the ClientWidth of TPanel.
> >>>
> >>
> >> Ok, that clears up why ClientWidth=Width. But why the bevels are
> >> included in ClientRect? I think child controls are not supposed to
> >> occupy the bevels' space. Can the ClientWidth, ClientHeight from the
> >> widgetset be adjusted to include bevels?
> > 
> > The widgetset values should only include the widgetset things.
> > 
> > Maybe you want new properties AdjustedClientWidth, AdjustedClientHeight. 
> > Changing ClientWidth/ClientHeight would be a big change and some third 
> > party controls rely on that.
> > Note: The LCL ClientWidth/Height are not compatible to the VCL, so 
> > Delphi compatibility is irrelevant here.
> 
> I came across the various client sizes in my attempt to better document 
> the LCL. IMO we have the following related areas:
> 
> - raw client area (0,0,Width,Height)
> - usable client area (excluding bevels...)
> - logical client area (in scrolling containers)
> - visible client area (visible part of logical area)
> - BaseBounds (undocumented???)
> 
> IMO beveled controls should report the usable client area to the outer 
> world, by adjusting ClientRect etc. accordingly. Internally they use the 
> inherited methods/properties, to get the full client area for painting 
> bevels etc.
> 
> What about drop down controls (combo boxes)?
> 
> 
> > r:=ClientRect;
> > AdjustClientRect(r);
> This IMO should be what [Get]ClientRect returns.

I agree, but that would be Delphi incompatible.

 
> > SpaceAvailable:=r.Right-r.Left;
> This should be what [Get]ClientWidth returns.

dito


> > Did you know, that you can anchor controls:
> > MyControl.AnchorParallel(akLeft,0,MyControl.Parent);
> > MyControl.AnchorParallel(akRight,0,MyControl.Parent);
> > 
> > This will expand MyControl to the full client area width, excluding the 
> > bevels.
> 
> ???

In other words:
If you want to position a child control to fill the complete width of
its parent, use the above. (or use Align=alTop,alBottom,alClient).
This will exclude the bevels.

 
> BTW, the determination of a control on a given screen coordinate also 
> could be more straight forward. In the related code I found the 
> beforementioned different areas, but the handling looks quite crappy to 
> me. Did you ever test this with nested scrolling controls?

When Panel.AutoSize=true, then the LCL will expand the Panel, so that no
scrolling is needed.
About nesting: The current algorithm is better than the VCL algorithm,
but still not perfect. The new algorithm supports infinite
nesting, but requires some improvements in the widgetsets before it
will be enabled.

 
> I also have to test the docking manager code, with beveled or scrolling 
> dock sites. IMO no changes should be required, the specialized (beveled, 
> scrolling) controls should encapsulate and hide their special treatment 
> of client coordinates from *every* user code.


Mattias




More information about the Lazarus mailing list