/[snow]/trunk/docs/widget-reference.html
ViewVC logotype

Contents of /trunk/docs/widget-reference.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 79 - (hide annotations)
Thu Apr 29 18:59:28 2010 UTC (3 years, 11 months ago) by astalla
File MIME type: text/html
File size: 7079 byte(s)
Updated widget reference documentation.
1 astalla 2 <html>
2     <head>
3     <title>Snow Widget Reference</title>
4     <link rel="stylesheet" type="text/css" href="style.css">
5     </head>
6     <body>
7     <h1>Snow Widget Reference</h1>
8     <h3>Common properties</h3>
9     These properties are available on every widget, unless stated otherwise.
10 astalla 79 <hr />
11     <h2><code>id</code></h2>
12     <strong>Type:</strong> symbol<br />
13     <strong>Description:</strong> This pseudo-property has several uses:
14     <ul>
15     <li>if a lexical variable with the same name as the id exists, it will be assigned the widget.</li>
16     <li>if the widget is a container, a lexical variable with the same name as the id will be bound to the widget around the body of the container.</li>
17     </li>
18     <li>if a Java backing bean is used (as the value of *backing-bean*), and it has a property with the same name as the id, it will be injected the widget through the setter method of that property. The name of the id symbol will be translated from lisp-hyphenated-convention to javaCamelCasedConvention.</li>
19     </ul>
20     <strong>Examples:</strong>
21     <pre class="paste-area">
22     (frame (:id foo) foo)
23     ==> #&lt;javax.swing.JFrame ...frame.toString()... {identityHashCode}&gt;
24    
25     (let (bar)
26     (label :id bar)
27     bar)
28     ==> #&lt;javax.swing.JLabel ...label.toString()... {identityHashCode}&gt;</pre>
29     <hr />
30     <h2><code>layout-manager</code></h2>
31     <strong>Type:</strong> a member of the following set of values:
32 astalla 2 <ul>
33     <li>one of :default, :mig, :border, :box, :flow</li>
34     <li>a list whose car is one of the above and whose cdr are additional arguments</li>
35     <li>a native Java layout manager.</li>
36     </ul>
37 astalla 79 <strong>Description:</strong> 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.<br />
38     <strong>Examples:</strong>
39     <pre class="paste-area">
40 astalla 2 (panel (:layout-manager '(:box :y))
41     (label :text &quot;First Line&quot;)
42 astalla 79 (label :text &quot;Second Line&quot;))</pre>
43     <hr />
44     <h2><code>layout</code></h2>
45     <strong>Type:</strong> string<br />
46     <strong>Description:</strong> 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.<br />
47     <strong>Examples:</strong>
48     <pre class="paste-area">
49 astalla 2 (panel ()
50 astalla 79 (label :layout &quot;grow, wrap&quot; :text "hello")
51     (label :text &quot;world&quot;))</pre>
52     <hr />
53     <h2><code>enabled-p</code></h2>
54     <strong>Type:</strong> boolean<br />
55     <strong>Description:</strong> Controls whether the widget is enabled (able to receive user input).
56     <hr />
57     <h2><code>size</code></h2>
58     <strong>Type:</strong> complex<br />
59     <strong>Description:</strong> 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.<br />
60     <strong>Example:</strong>
61     <pre class="paste-area">(frame (:size #C(800 600)))</pre>
62     <hr />
63     <h2><code>label</code></h2>
64     <strong>Type:</strong> a label widget.<br />
65     <strong>Description:</strong> Connects a label to this widget. Typically, clicking on the label will bring focus on the widget.<br />
66     <strong>Examples:</strong>
67     <pre class="paste-area">
68     (let (lbl)
69     (label :id lbl :text "User Name: ")
70     (text-field :label lbl))</pre>
71     Or, shorter, using an inline label:
72     <pre class="paste-area">
73     (text-field :label (label :text "User Name: "))</pre>
74     <hr />
75 astalla 2 <h3>Widgets</h3>
76 astalla 79 Here's a summary of the widgets (GUI components) currently available in Snow. The &quot;C&quot; column indicates whether the widget is a container. You can follow the hyperlink on a widget's name to read about its properties.<br /><br />
77 astalla 2 <table border="1">
78     <tr>
79 astalla 79 <th>Name</th>
80     <th>Description</th>
81     <th>C</th>
82     <th>Examples</th>
83     <th>Notes</th>
84 astalla 2 </tr>
85     <tr>
86     <td style="text-align: center;"><strong><a href="#button_props"><code>button</code></a></strong></td>
87     <td>A button with text on it.</td>
88     <td><br /></td>
89     <td><pre class="paste-area">
90     (button :text "Ok!")</pre></td>
91     <td><br /></td>
92     </tr>
93     <tr>
94     <td style="text-align: center;"><strong><code>check-box</code></strong></td>
95     <td>A checkbox with optional text.</td>
96     <td><br /></td>
97     <td><pre class="paste-area">
98     (check-box :text "Enabled")</pre></td>
99     <td><br /></td>
100     </tr>
101     <tr>
102     <td style="text-align: center;"><strong><code>frame</code></strong></td>
103     <td>A top-level window.</td>
104     <td style="text-align: center;">Y</td>
105     <td><pre class="paste-area">
106     (frame (:title "A frame" :on-close :exit)
107     (label :text "push")
108     (button :text "this!"))</pre></td>
109     <td><br /></td>
110     </tr>
111     <tr>
112     <td style="text-align: center;"><strong><code>label</code></strong></td>
113     <td>Read-only text.</td>
114     <td><br /></td>
115     <td><pre class="paste-area">
116     (label :text "Hello")</pre></td>
117     <td><br /></td>
118     </tr>
119     <tr>
120     <td style="text-align: center;"><strong><code>list-widget</code></strong></td>
121     <td>Displays a list of strings.</td>
122     <td><br /></td>
123     <td><pre class="paste-area">
124     (list-widget :model (make-cons-list-model '("foo" "bar" "baz")))</pre></td>
125     <td>Not named list to avoid clashing with the commonly used function by the same name in the COMMON-LISP package.</td>
126     </tr>
127     <tr>
128     <td style="text-align: center;"><strong><code>panel</code></strong></td>
129     <td>A generic container for other components.</td>
130     <td style="text-align: center;">Y</td>
131     <td><pre class="paste-area">
132     (panel ()
133     (label :text "push")
134     (button :text "this!"))</pre></td>
135     <td><br /></td>
136     </tr>
137     <tr>
138     <td style="text-align: center;"><strong><code>scroll</code></strong></td>
139     <td>A container for a single child, providing scrollbar support.</td>
140     <td style="text-align: center;">Y</td>
141     <td><pre class="paste-area">
142     (scroll ()
143     (text-area :text "very, very, ..., long text"))</pre></td>
144     <td><br /></td>
145     </tr>
146     <tr>
147     <td style="text-align: center;"><strong><code>text-area</code></strong></td>
148     <td>Allows the user to enter multiple lines of text.</td>
149     <td><br /></td>
150     <td><pre class="paste-area">
151     (text-area :text "type something here")</pre></td>
152     <td><br /></td>
153     </tr>
154     <tr>
155     <td style="text-align: center;"><strong><code>text-field</code></strong></td>
156     <td>Allows the user to enter a single line of text.</td>
157     <td><br /></td>
158     <td><pre class="paste-area">
159     (text-field :text "type something here")</pre></td>
160     <td><br /></td>
161     </tr>
162     <tr>
163     <td style="text-align: center;"><strong><code>tree</code></strong></td>
164     <td>Displays hierarchical data in the form of a tree with expandable/collapsible nodes.</td>
165     <td><br /></td>
166     <td><pre class="paste-area">
167     (tree :model (make-cons-tree-model '("foo" ("bar" "baz"))))</pre></td>
168     <td><br /></td>
169     </tr>
170     </table>
171     <h3>Widget-specific properties</h3>
172     <a name="button_props" /><h4>button</h4>
173     <p>
174     <dd><code>:text</code></dd>
175     <dt>Sets the text displayed on the button</dt>
176     <dd><code>:on-action</code></dd>
177     <dt>Sets a callback to be invoked when the button is activated (e.g. by a mouse click or using the keyboard)</dt>
178     </p>
179     </body>
180     </html>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5