[Lazarus] RE : RE : Right-aligned word wrap label doesn't seem to work

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Nov 27 14:26:07 CET 2011


On Sun, 27 Nov 2011 13:52:27 +0100
"Ludo Brands" <ludo.brands at free.fr> wrote:

> > The LCL extends the Width if possible.
> > A fixed Width can be set with Constraints.Min/MaxWidth or 
> > using Anchors. The label will extend the Height if WordWrap 
> > is true and the Width is fixed.
> > 
> 
> Mmm... Seems there are some problems with the windows implementation. On
> windows set maxwidth:=45 autosize:=true wordwrap:=true and enter in caption
> 'line1 line2 line3 line4 line5 line666666666666666666666'. Until line6 all
> is ok but as you enter more 6'es the hight is shrinking and lines drop.

It works under gtk2. So, yes, the bug is in the LCL win32 interface.
I hope you have disabled OptimalFill.

Under carbon line666666 is not broken into several lines, it is clipped.
Both gtk2 and carbon make sense.

> Do the same with Alignment:=taRightJustify and you'll notice that when
> typing line2, the 2nd line disappears (Reiniers problem) but as soon you
> enter another character the 2nd line appears again. When finished typing
> line3, the line interspacing suddenly doubles. Probably the line
> interspacing is the reason why line 2 disappeared. Possibly your default
> font is different than mine and the "behavior" is triggered at other
> moments.

This works too under gtk2.

Under carbon there is one word too much on each line.
 
> > That means the LCL does not need any special rule for TLabel.
> > 
> > This has also the advantage that a LCL wordwrapped TLabel can 
> > resize in both directions.
> > 
> 
> Top or bottom anchor centered to sibling you mean?

I'm not sure what case you mean.
I mean, if something depends on the width of the label, for instance
the parent or another sibling, and you set MaxWidth and WordWrap, then
changing the caption allows the LCL to shrink the Label Width,
resizing its Parent or moving the sibling.
For example a TLabel Align=alLeft, a TMemo Align=alClient. Set Label
MaxWidth=100, AutoSize=true, WordWrap=true.
Now set Label caption. It can be less than 100, giving the memo
automatically more space.

 
> > So, the LCL is more consistent and more powerful. So I would 
> > prefer to break Delphi compatibility here.
> > 
> 
> Somewhat more work is needed for the frequently used right aligned, fixed
> right side, left anchored labels. You need to right anchor the label to a
> left anchored sibling.  

Or set Constraints.MaxWidth or set Align=alTop or ...


Mattias




More information about the Lazarus mailing list