# Snow Widget Reference

### Common properties

These properties are available on every widget, unless stated otherwise.

Name | Type | Description | Examples | Notes
--- | --- | --- | --- | ---
`id` | symbol | Binds a lexical variable to the current widget locally to the widget body. |
    (frame (:id foo)
      (print foo))
| For containers only.
`layout-manager` | one of :default, :mig, :border, :box, :flow a list whose car is one of the above and whose cdr are additional arguments a native Java layout manager. | Sets the policy for laying out the component's children. |
    (panel (:layout-manager '(:box :y))
      (label :text "First Line")
      (label :text "Second Line"))
| For containers only.
`layout` | string | Constraints used to control how the component is to be laid out in its container. The possible values and their meaning depend on the layout manager of the container. |
    (panel ()
      (label :layout "grow, wrap"
             :text "hello")
      (label :text "world"))
`enabled-p` | boolean | Controls whether the widget is enabled (able to receive user input). |  |
`size` | complex | Sets the size of the widget. |
    (frame (:size #C(800 600)))
| The size is represented as a complex number whose real part is the Width and imaginary part is the Height.

### Widgets

Here's a summary of the widgets (GUI components) currently available in Snow. The "C" column indicates whether the widget is a container. You can follow the hyperlink on a widget's name to read about its properties.

Name | Description | C | Backend | Examples | Notes
--- | --- | --- | --- | --- | ---
Swing
`button` | A button with text on it. |  | Y |
    (button :text "Ok!")
`check-box` | A checkbox with optional text. |  | Y |
    (check-box :text "Enabled")
`frame` | A top-level window. | Y | Y |
    (frame (:title "A frame" :on-close :exit)
      (label :text "push")
      (button :text "this!"))
`label` | Read-only text. |  | Y |
    (label :text "Hello")
`list-widget` | Displays a list of strings. |  | Y |
    (list-widget :model (make-cons-list-model '("foo" "bar" "baz")))
| Not named list to avoid clashing with the commonly used function by the same name in the COMMON-LISP package.
`panel` | A generic container for other components. | Y | Y |
    (panel ()
      (label :text "push")
      (button :text "this!"))
`scroll` | A container for a single child, providing scrollbar support. | Y | Y |
    (scroll ()
      (text-area :text "very, very, ..., long text"))
`text-area` | Allows the user to enter multiple lines of text. |  | Y |
    (text-area :text "type something here")
`text-field` | Allows the user to enter a single line of text. |  | Y |
    (text-field :text "type something here")
`tree` | Displays hierarchical data in the form of a tree with expandable/collapsible nodes. |  | Y |
    (tree :model (make-cons-tree-model '("foo" ("bar" "baz"))))

### Widget-specific properties

#### button

  `:text`
Sets the text displayed on the button
  `:on-action`
Sets a callback to be invoked when the button is activated (e.g. by a mouse click or using the keyboard)