
Of course. We should always be able to query the actual size. How about size is not an attribute? Size could be a ro variable. The attribute is the SizePolicy.
Sounds good.
SizePolicyType =
We'll have to think about the actual constructors a bit more, I think.
I'm used to using HBox's and VBox's. Is a grid as simple as I think it is? If it is . . . HBox, VBox, and GridBox seem to be a good addition.
Grids are reasonably simple to use; they become really great when used in conjunction with a graphical GUI editor. They are slightly more general than HBoxes and VBoxes (although those cases that you can't model with H/VBoxes are rare in practice). For a GridBox, you would specify *) the number of rows and columns *) attributes for rows and columns (attributes include "Resizable" and "NonResizable"; some grid layout managers provide a "weight" attribute for resizable rows/columns). For each widget you place in the grid box, you'd specify *) row and column number *) row and column span (a widget may take up more than one cell) *) other attributes, like alignment (if a column is resized but the widget in it has a fixed size narrower than the column), padding etc. So we could have several different types of containers: HBoxes, VBoxes for simple dynamic layout GridBoxes for complex dynamic layout FixedPlacementBox for crazy people, for strange situations and for implementing dynamic layout schemes on top of it. How would we specify container-specific attributes? Row/Column number, row/column span etc. are not attributes of the widget, and they are attributes of a widget inside a GridBox container. What about having:
class Container c where addChild :: Widget w => c -> w -> [Prop (c,w)] -> IO () removeChild :: Widget w => c -> w -> IO ()
So that I could write something like:
myGrid <- mkGridBox [columns =: [Resizable, NonResizable], rows =: [NonResizable, NonResizable]] myLabel <- mkLabel [title =: "foo"] myEntry <- mkEditableTextField [] myButton <- mkButton [title =: "bar"]
addChild myGrid myLabel [row =: 1, column =: 1, columnspan =: 2, halign =: Center] addChild myGrid myEntry [row =: 2, column =: 1] addChild myGrid myButton [row =: 2, column =: 2]
... and later I could use things like:
set (myGrid, myLabel) [columnspan =: 1]
Of course, HBoxes, VBoxes, fixed placement, and everything else people might come up with, would fit in the same framework. What do you think? Cheers, Wolfgang