mettli / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

TextBox::setText and TextBox::addRow resizes the control to contents #46

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce the problem:

textBox.setPosition(0, 0);
textBox.addRow("test message 1");

//set textBox dimensions !!!
textBox.setWidth(700);
textBox.setHeight(80);
window.add(&textBox);

//!!! any of these 2 calls resets textBox dimensions to content size
textBox.addRow("test mes 2");
textBox.setText("text");

Expected behavior:
TextBox dimensions shall persist after TextBox::addRow() or
TextBox::setText() calls.

Original issue reported on code.google.com by igagis@gmail.com on 1 May 2008 at 8:14

GoogleCodeExporter commented 9 years ago
guichan 0.8.0

Original comment by igagis@gmail.com on 1 May 2008 at 8:26

GoogleCodeExporter commented 9 years ago
I believe TextBox calls adjustSize automatically since it is meant to be used 
within
a ScrollArea, where the user only defines the size of the ScrollArea. This is
different from Label and TextField, which do not automatically adjust their 
size. The
documentation doesn't seem to mention this, however. TextBox also relies on
ScrollArea to draw a border around it.

I'm not sure about the best way to fix this. In Qt, the QTextEdit (like 
gcn::TextBox)
subclasses from QAbstractScrollArea (like gcn::ScrollArea), so you can't even 
use it
on its own. Though of course you can disable the scroll bars and the border.

Original comment by b.lindeijer on 5 May 2008 at 10:56

GoogleCodeExporter commented 9 years ago
Well, I think it would be the best solution to embed the Scrolling 
functionality to
TextBox class (as it is in QT). Because it is not obvious that I always must use
TextBox in conjunction with scroll area.

Possible solution: derive TextBox from ScrollArea and add the object of Current
TextBox class to this scroll area in the constructor of new TextBox class. 
Something
like that?

Original comment by igagis@gmail.com on 5 May 2008 at 11:08

GoogleCodeExporter commented 9 years ago
One problem I didn't realize before with deriving from gcn::ScrollArea is that 
it
then becomes rather impossible to use your own customized ScrollArea class. 
You'd
basically have to re-do the same customizations on top of gcn::TextBox.

So the solution I would suggest for now is to improve the documentation.

Original comment by b.lindeijer on 5 May 2008 at 12:29

GoogleCodeExporter commented 9 years ago
Yes, looks like modifying docs will be enough.

By the way, if TextBox is supposed to be used only in conjunction with 
ScrollArea,
maybe the default TextBox should have transparent background then? So, it would 
draw
only text inside it and ScrollArea will be responsible for drawing background.

Currently TextBox has white background color.

Original comment by igagis@gmail.com on 5 May 2008 at 1:02

GoogleCodeExporter commented 9 years ago
One solution to the problem is to make TextBox use a ScrollArea widget just like
DropDown does, that way you only need to pass a customized ScrollArea to TextBox
instead of subclassing TextBox.

Original comment by olof.nae...@gmail.com on 6 May 2008 at 1:19