What's the secret to make a custom FWT component (ie: Canvas) fill 100% of the parent width ... somehow this is giving me trouble.
I'm guessing I have to override prefSize() ... but don't know what to return for 1005 width.
tcolarTue 27 Apr 2010
Or maybe let m,e explain my actual issue
If I do:
Window
{
size = Size(800,600)
EdgePane
{
left = Label{text = "Hello"}
right = Label{text = "Bye Bye"}
},
}.open
I get what I expect ("Hello" on far left "Bye Bye" on far right)
Now If i use an "expandable" grid
Window
{
size = Size(800,600)
GridPane
{
numCols = 1
expandCol = 0
EdgePane
{
left = Label{text = "Hello"}
right = Label{text = "Bye Bye"}
},
// maybe some other items
},
}.open
They get bunched next to each other on the left. I though expandCol would make the grid 100% width .. i guess not.
What to do to get the expected result ?
KevinKelleyTue 27 Apr 2010
I though expandCol would make the grid 100%
No, it's weird; expandCol means, which column to expand to take excess space.
If you've got numCols set to 1, then set expandCol to 0 and it should then grow. (the examples/fwt/demo.fan demo is handy to tinker around with).
You also want halignCells to fill; expandCol makes the cell grow but leaves the item in it (the EdgePane) at default size; halignCells=fill makes the cell content grow to fit the cell.
tcolarWed 28 Apr 2010
Doh! Thanks, can't believe I missed that for a while.
tcolar Tue 27 Apr 2010
What's the secret to make a custom FWT component (ie: Canvas) fill 100% of the parent width ... somehow this is giving me trouble.
I'm guessing I have to override prefSize() ... but don't know what to return for 1005 width.
tcolar Tue 27 Apr 2010
Or maybe let m,e explain my actual issue
If I do:
Window { size = Size(800,600) EdgePane { left = Label{text = "Hello"} right = Label{text = "Bye Bye"} }, }.openI get what I expect ("Hello" on far left "Bye Bye" on far right)
Now If i use an "expandable" grid
Window { size = Size(800,600) GridPane { numCols = 1 expandCol = 0 EdgePane { left = Label{text = "Hello"} right = Label{text = "Bye Bye"} }, // maybe some other items }, }.openThey get bunched next to each other on the left. I though
expandColwould make the grid 100% width .. i guess not.What to do to get the expected result ?
KevinKelley Tue 27 Apr 2010
No, it's weird; expandCol means, which column to expand to take excess space.
If you've got numCols set to 1, then set expandCol to 0 and it should then grow. (the
examples/fwt/demo.fandemo is handy to tinker around with).You also want
halignCellstofill; expandCol makes the cell grow but leaves the item in it (the EdgePane) at default size; halignCells=fill makes the cell content grow to fit the cell.tcolar Wed 28 Apr 2010
Doh! Thanks, can't believe I missed that for a while.
SlimerDude Sat 4 May 2013
Argh!
content = GridPane { ... halignCells = Halign.fill ... }Thank you!
I've been meddling with layouts for days trying to figure that one out!