Snow Widget Reference

Common properties

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

id

Type: symbol
Description: This pseudo-property has several uses: Examples:
(frame (:id foo) foo)
==> #<javax.swing.JFrame ...frame.toString()... {identityHashCode}>

(let (bar)
  (label :id bar)
  bar)
==> #<javax.swing.JLabel ...label.toString()... {identityHashCode}>

layout-manager

Type: a member of the following set of values: Description: Sets the policy for laying out the component's children. For containers only. If not specified, defaults to :default - which is the same as :mig, i.e., MiGLayout is used.
Examples:
(panel (:layout-manager '(:box :y))
  (label :text "First Line")
  (label :text "Second Line"))

layout

Type: string
Description: 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.
Examples:
(panel ()
  (label :layout "grow, wrap" :text "hello")
  (label :text "world"))

enabled-p

Type: boolean
Description: Controls whether the widget is enabled (able to receive user input).

size

Type: complex
Description: Sets the size of the widget. The size is represented as a complex number whose real part is the Width and imaginary part is the Height.
Example:
(frame (:size #C(800 600)))

label

Type: a label widget.
Description: Connects a label to this widget. Typically, clicking on the label will bring focus on the widget.
Examples:
(let (lbl)
  (label :id lbl :text "User Name: ")
  (text-field :label lbl))
Or, shorter, using an inline label:
(text-field :label (label :text "User Name: "))

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 Examples Notes
button A button with text on it.
(button :text "Ok!")

check-box A checkbox with optional text.
(check-box :text "Enabled")

frame A top-level window. Y
(frame (:title "A frame" :on-close :exit)
  (label :text "push")
  (button :text "this!"))

label Read-only text.
(label :text "Hello")

list-widget Displays a list of strings.
(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
(panel ()
  (label :text "push")
  (button :text "this!"))

scroll A container for a single child, providing scrollbar support. Y
(scroll ()
  (text-area :text "very, very, ..., long text"))

text-area Allows the user to enter multiple lines of text.
(text-area :text "type something here")

text-field Allows the user to enter a single line of text.
(text-field :text "type something here")

tree Displays hierarchical data in the form of a tree with expandable/collapsible nodes.
(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)