Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-11

Right-aligned word wrap label doesn't seem to work

9 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ludo Brands
to Reinier Olislagers
It flows correctly when I set alignment to taCenter What am I doing wrong?

Nothing. Seems to be a bug on windows. GTK2 is working.

Checking this in lazarus I stumbled on another compatibility issue with TLabel. Delphi states "When WordWrap is True, the width of the label is fixed. If AutoSize is also True, changes to the text cause the label to change in height. ". Lazarus increases the width... SVN 33665

Ludo

Reply by email

Mattias Gaertner
to Ludo Brands
Show quoted text 10 lines
> It flows correctly when I set alignment to taCenter > What am I doing wrong? > Nothing. Seems to be a bug on windows. GTK2 is working. Checking this in lazarus I stumbled on another compatibility issue with TLabel. Delphi states "When WordWrap is True, the width of the label is fixed. If AutoSize is also True, changes to the text cause the label to change in height. ". Lazarus increases the width... SVN 33665

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.

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.

So, the LCL is more consistent and more powerful. So I would prefer to break Delphi compatibility here.

Mattias

Reply by email

Ludo Brands
to Mattias Gaertner
Show quoted text 5 lines
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. 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.

Show quoted text 5 lines
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?

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.

Ludo

Reply by email

Mattias Gaertner
to Ludo Brands
Show quoted text 10 lines
> 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.

Show quoted text 7 lines
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.

Show quoted text 7 lines
> 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.

Show quoted text 7 lines
> 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

Reply by email

Ludo Brands
to Mattias Gaertner
Show quoted text 6 lines
> 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.

:) yes.

I'll create an issue. Or better 2. Not sure the shrinking height is related to the interlign change in RightJustify.

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

Yes. But unfortunately different.

Show quoted text 15 lines
> > 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.

Got it.

Show quoted text 6 lines
> 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 ...

Constraints.MaxWidth doesn't keep your right margin in the same place for left anchored labels.

Ludo

Reply by email

Mattias Gaertner
to Ludo Brands
Show quoted text 10 lines
[...] > > 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 ... Constraints.MaxWidth doesn't keep your right margin in the same place for left anchored labels.

If you want that set MinWidth.

Mattias

Reply by email

Luiz Americo Pereira Camara
to Mattias Gaertner: On Sun, 27 Nov 2011 12:00:13 +0100 The LCL extends the Width if possible. A fixed Width…
Mattias Gaertner wrote 12 lines
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. 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. So, the LCL is more consistent and more powerful. So I would prefer to break Delphi compatibility here.

If i understand correctly http://bugs.freepascal.org/view.php?id=18505 can be resolved as wont fix right?

Luiz

Reply by email

Reinier Olislagers
to Luiz Americo Pereira Camara
Luiz Americo Pereira Camara wrote 8 lines
On 27/11/2011 09:27, Mattias Gaertner wrote: > So, the LCL is more consistent and more powerful. So I would prefer to > break Delphi compatibility here. If i understand correctly http://bugs.freepascal.org/view.php?id=18505 can be resolved as wont fix right? Luiz

Thanks all for looking into this & filing the bugs.

I've manually extended the width for now so it fits on one line :)

Regards,
Reinier

Reply by email