[snow-cvs] r41 - in trunk/examples: . swixml
Alessio Stalla
astalla at common-lisp.net
Sun Jan 3 23:35:45 UTC 2010
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 <http://www.swixml.org/samples/index.html>. 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:
+
+<?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>
+
+||#
More information about the snow-cvs
mailing list