Layout with Properties

Layout with Properties

Thus far we have always used our layout without properties or parameters and so we have used the short syntax.

ACORN 1.0 IWML 1.0
Page[]
  SimpleStack[]
    Text One
    Text Two
    Text Three
  ]
]

Layouts can have properties and parameters as well. They can also be named. To name a layout when the short syntax is used:

ACORN 1.0 IWML 1.0
Page[]
  SimpleStack[]:MyStack
    Text One
    Text Two
    Text Three
  ]
]

Stack

SimpleStack does not accept a parameter and has minimal properties. Let’s change SimpleStack to Stack:

ACORN 1.0 IWML 1.0
Page[]
   Stack[]:MyStack
    Text One
    Text Two
    Text Three
  ]
]

Layout Properties

Stack is a more capable layout than SimpleStack, but it also emits more HTML. The most commonly used property of Stack is .Orientation. Orientation can be set as a property:

ACORN 1.0 IWML 1.0
Page[]
  Stack
    Orientation: Horizontal
    Cells[]
      Edit Hello World
      gap;
      Button OK
    ]
  ]
]

To allow properties on the layout, we had to modify the Stack declaration. We removed the [], and added a Cells[] block to contain the child controls. When a container control ends with [], it tells IWML to use the default array of the control.
For layouts, this is Cells[].

Layout with Parameters

Many layout controls support the use of parameters also. For Stack, the parameter corresponds to the .Orientation property. Thus we can rewrite the above IWML as:

If we need to set other properties not supported by the parameter, then we must revert back to the full syntax.