(in-package :snow-user)
(in-readtable snow:syntax)

(let ((clicks (make-var 0)) tf)
  (flet ((submit ()
	   (setf (widget-text tf) (str (widget-text tf) "#"))
	   (incf (var clicks))))
    (with-gui ()
      (frame (:size #C(640 280) :title "Hello Snow World" :on-close :exit)
        (panel (:layout "grow, wrap")
          (label :text "Hello World!" :font (font "Georgia" 12 :bold)
		 :foreground :blue) ;;labelfor="tf"
	  (text-field :id tf :text "Snow");;columns="20"
	  (button :text "Click Here" :on-action #'submit))
	(panel (:layout "dock south")
          (label :text "Clicks:" :font (font "Georgia" 36 :bold))
	  (label :font (font "Georgia" 36 :bold) :text $(c? (str (var clicks)))))
	(show self)))))

#||
The original example used the SwiXml idiom of coding a Java class to handle
the events; an instance of this class gets injected the components with an
ID into its JavaBean properties.
The Snow version does not rely on a Java class; instead it handles events in
Lisp and uses data binding to update the GUI. It is of course possible to
handle the events in Java, but Snow does not currently support automatic
injection of widgets into the properties of a Java object.
||#

#|| Original example:

<?xml version="1.0" encoding="UTF-8"?>
<frame size="640,280" title="Hello SWIXML World" defaultCloseOperation="JFrame.EXIT_ON_CLOSE">

  <panel constraints="BorderLayout.CENTER">
    <label labelfor="tf" font="Georgia-BOLD-12" foreground="blue" text="Hello World!"/>
    <textfield id="tf" columns="20" Text="Swixml"/>
    <button text="Click Here" action="submit"/>
  </panel>

  <panel constraints="BorderLayout.SOUTH">
    <label font="Georgia-BOLD-36" text="Clicks:"/>

    <label font="Georgia-BOLD-36" id="cnt"/>
  </panel>

</frame>

||#
