From astalla at common-lisp.net Sun Jan 3 23:35:45 2010 From: astalla at common-lisp.net (Alessio Stalla) Date: Sun, 03 Jan 2010 18:35:45 -0500 Subject: [snow-cvs] r41 - in trunk/examples: . swixml Message-ID: Author: astalla Date: Sun Jan 3 18:35:44 2010 New Revision: 41 Log: Added the examples directory with the helloworld SwiXml example. Added: trunk/examples/ trunk/examples/swixml/ trunk/examples/swixml/README.txt trunk/examples/swixml/helloworld.lisp Added: trunk/examples/swixml/README.txt ============================================================================== --- (empty file) +++ trunk/examples/swixml/README.txt Sun Jan 3 18:35:44 2010 @@ -0,0 +1,4 @@ +The examples in this directory are the Snow version of the SwiXml examples +located at . When SwiXml supports +some feature that Snow does not, the SwiXml code is kept in a comment near +its translation into Snow. Added: trunk/examples/swixml/helloworld.lisp ============================================================================== --- (empty file) +++ trunk/examples/swixml/helloworld.lisp Sun Jan 3 18:35:44 2010 @@ -0,0 +1,49 @@ +(in-package :snow-user) +(in-readtable snow:syntax) + +(let ((clicks (make-var 0)) tf) + (flet ((submit (event) + (declare (ignore event)) + (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" + (child (setf tf (text-field :text "Snow")));;columns="20" TODO :var tf + (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))))))))) + +#|| +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: + + + + + +