[Lazarus] TPanel bevel and client size

cobines cobines at gmail.com
Fri Feb 12 11:42:21 CET 2010


2010/2/12 Mattias Gärtner <nc-gaertnma at netcologne.de>:
> Zitat von cobines <cobines at gmail.com>:
>
>> 2010/2/12 Mattias Gärtner <nc-gaertnma at netcologne.de>:
>>>
>>> Zitat von cobines <cobines at gmail.com>:
>>>
>>>> 2010/2/12 Paul Ishenin <ip at kmiac.ru>:
>>>>>
>>>>> Bevels reduce ClientRect by BevelSize value.
>>>>
>>>> I thought so that they're supposed to do that, but if I put a TPanel
>>>> on a form with a outer bevel set to Lowered , the panel's ClientHeight
>>>> = Height.
>>>
>>> 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.

OK, I misunderstood what ClientWidth/Height represent.

>> For example if I want to check how much space is in the Panel for a
>> control, I do:
>>
>> SpaceAvailable := Panel.ClientHeight;
>> if SpaceAvailable >= 100 then
>>  ShowMyControl_of_size_100_or_more (because I'm sure it will fit)
>> else
>>  HideMyControl... (don't want to show it partially)
>>
>> (The Panel size is controlled by the user.)
>>
>> However, if TPanel contains bevels then the space available for the
>> child control is ClientHeight - BevelSize * 2. I have to take it into
>> account when calculating space. Otherwise, either my control will not
>> be fully shown, or it will be drawn over the bevels. Is there some
>> other property I can check that will include all borders, bevels,
>> etc.?
>
> r:=ClientRect;
> AdjustClientRect(r);
> SpaceAvailable:=r.Right-r.Left;

Thanks, this might help.

> 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.

Yes this works. A child control with Align=alClient does not overwrite bevels.

>>>>> BevelSize is used to calculate the ClientRect in
>>>>> TCustomPanel.AdjustClientRect.
>>>>
>>>> Yes, that function recalculates the rectangle correctly, but it seems
>>>> it's somehow not propagated to the auto size algorithm or to the
>>>> stored client rectangle.
>>>
>>> The autosize algorithm uses AdjustClientRect.
>>
>> It still puts child controls over the bevels. I don't know, maybe I'm
>> confusing it with aligning child controls. It is supposed to either
>> make the child control smaller so that it doesn't overwrite the
>> bevels, or make the TPanel bigger so that the child control fits in
>> whole and there's still space left for the bevels.
>
> It works here on a simple example. Child controls are not on the bevels but
> within the bevels with autosize=true on gtk2.

This is what doesn't work for me.

Take a look at attached example.

Panel1 has a bevel and is autosized. It includes a panel with no
borders. For me both are invisible, but Panel1 bevels should be
visible.

Panel3 has a bevel and is not autosized. It includes a panel with no
borders that has Align=alClient. Bevels of Panel3 are visible.

Same thing on QT.

--
cobines
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel_bevel.tar.bz2
Type: application/x-bzip2
Size: 1816 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100212/13cdd190/attachment-0004.bin>


More information about the Lazarus mailing list