Need for a grid morph
Last updated at 10:16 am UTC on 9 November 2017
Page needs to be updated. What is available in Squeak 5.1 / 6.0a?
Pages with possibly relevant information
Question Ramiro Diaz Trepa January 26, 2004:
Regarding the laying out of Morphs, I've seen that in the TableLayout it is not possible to "fix" a specific number of rows and columns. When you resize the main container window, components scroll up or down like if they were words on a word processor. Besides that, I also could not find a way to tell the layout manager that a specific component might occupy, for instance 3 cells horizontally and 1 vertically. I am sure that these things are resolved in some way in Squeak, if anybody could point me a complex window layout example to learn from it would be great.
Answer Ned Konz [To "fix" a specific number of rows and columns] add more interior morphs. For a forced 2 column display, you can do this:
MyMorph (table, left-to-right, no wrap)
column1 (table, top-to-bottom, no wrap)
column2 (table, top-to-bottom, no wrap)
Andreas made a very nice Active Essay about the layouts. It's on SqueakMap. [See also DecentReviewerNotePad.]
Ramiro Diaz Trepat: Thank you very much for your prompt response Ned. I did think of the layout solution you told me, but as a work around to the problem, because doing it that way I believe you cannot control for instance "row alignment" since the height of the rows is independent between columns. That is if I have labels on the left column and text entry fields on the right column, and I want the labels to be vertically centered with their corresponding entry field on the right side of the row. This would be harder to achieve if the components were of variable heights. If this is so, I think that there is a real need for another TableLayout with the usual characteristics, like the ones in Java or C++ (may be I could develop it :)
Ned Konz: So you could do this:
MyMorph (TableLayout, topToBottom)
row1 (ProportionalLayout or no layout)
row2 (ProportionalLayout or no layout)
Or you could use leftToRight TableLayouts. Just experiment with the 'layout' menu.
Ramiro Diaz Trepat: This produces the same problem but the other way. If you decide to make rows you cannot align columns, if you decide to make columns you cannot align rows. I have come to the conclusion that something like Java's GridBagLayout is really needed in Squeak. I hope I can find the time to code one myself and send it to the list.
- Open up the Objects tool and from the "presentation" category get a Column or a Row.
- Open up a Viewer on that row or column, and choose the "layout" category.
- Now twiddle with the values of the layout parameters in the Viewer; you'll be able to see the results immediately on the morph. Twiddling further parameters in the "color & border" and "basic" categories may also be useful in such explorations.