Next Previous Up Top Contents Index

7.3 A tour of layouts

7.3.4 Using horizontally and vertically macros

The macros horizontally and vertically are provided to position objects sequentially in a column layout or row layout. Using these macros, rather than creating layout objects explicitly, can lead to shorter and more readable code.

horizontally () make(<push-button>, label: "One");
                make(<push-button>, label: "Two");
                make(<push-button>, label: "Three") end;

Figure 7.26 Three buttons arranged in a horizontal layout

vertically () make(<push-button>, label: "One");
              make(<push-button>, label: "Two"); 
              make(<push-button>, label: "Three") end;

You can specify any init-keywords that you would specify for an instance of <row-layout> or <column-layout> using vertically and horizontally. To do this, just pass the init-keywords as arguments to the macro. The following code ensures that the row layout created by horizontally is the same width as the button with the really long label. In addition, the use of max-width: in the definitions of the two other buttons ensures that those buttons are sized so as to occupy the entire width of the row layout.

vertically (equalize-widths?: #t)
    horizontally ()
      make(<button>, label: "Red", max-width: $fill);
      make(<button>, label: "Ultraviolet", max-width: $fill);
    end;
    make(<button>, 
         label: "A button with a really really long label");
end


Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index