You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/08/06 18:24:46 UTC

svn commit: r801703 - in /incubator/pivot/trunk/tutorials: src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx www/bounded_range_components.template.html www/spinners.template.html

Author: gbrown
Date: Thu Aug  6 16:24:46 2009
New Revision: 801703

URL: http://svn.apache.org/viewvc?rev=801703&view=rev
Log:
Add Spinner tutorial.

Added:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx
Modified:
    incubator/pivot/trunk/tutorials/www/bounded_range_components.template.html
    incubator/pivot/trunk/tutorials/www/spinners.template.html

Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx?rev=801703&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/boundedrange/spinners.wtkx Thu Aug  6 16:24:46 2009
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Window title="Spinners" maximized="true"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns:content="org.apache.pivot.wtk.content"
+    xmlns="org.apache.pivot.wtk">
+    <content>
+        <Border>
+            <content>
+                <BoxPane styles="{verticalAlignment:'center'}">
+                    <Spinner spinnerData="['One', 'Two', 'Three', 'Four', 'Five']"
+                        circular="true" preferredWidth="80" selectedIndex="0"/>
+                    <Spinner preferredWidth="40" selectedIndex="0">
+                        <spinnerData>
+                            <content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/>
+                        </spinnerData>
+                    </Spinner>
+                </BoxPane>
+            </content>
+        </Border>
+    </content>
+</Window>

Modified: incubator/pivot/trunk/tutorials/www/bounded_range_components.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/bounded_range_components.template.html?rev=801703&r1=801702&r2=801703&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/bounded_range_components.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/bounded_range_components.template.html Thu Aug  6 16:24:46 2009
@@ -28,9 +28,9 @@
 <ul>
 <li><p><a href="scroll_bars.html"><b>ScrollBar</b></a> - Allows a user to select one of a range of values using up/down buttons or a draggable "thumb" that also represents an extent value. Most often used to facilitate scrolling in a scroll pane but can be used in other contexts.</p></li>
 
-<li><p><a href="spinners.html"><b>Spinner</b></a> - An "up/down" control allowing a user to cycle through a range of pre-defined values.</p></li>
+<li><p><a href="sliders.html"><b>Slider</b></a> - Allows a user to select one of a range of values by dragging the mouse.</p></li>
 
-<li><p><a href="scroll_bars.html"><b>Slider</b></a> - Allows a user to select one of a range of values by dragging the mouse.</p></li>
+<li><p><a href="spinners.html"><b>Spinner</b></a> - An "up/down" control allowing a user to cycle through a range of pre-defined values.</p></li>
 </ul>
 
 <p>Next: <a href="scroll_bars.html">Scroll Bars</a></p>

Modified: incubator/pivot/trunk/tutorials/www/spinners.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/spinners.template.html?rev=801703&r1=801702&r2=801703&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/spinners.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/spinners.template.html Thu Aug  6 16:24:46 2009
@@ -34,7 +34,89 @@
 <body>
 <h1>Spinners</h1>
 
-<p>This section is not yet complete.</p>
+<p><tt>Spinner</tt> is a component that provides a means of cycling through a list of items. The items are defined by the spinner's model data, specified via the "spinnerData" property. Spinners behave similarly to a single-select <tt>ListView</tt> or a <tt>ListButton</tt>, allowing a user to select one of the items in the list. However, unlike list views and list buttons, spinners only present a single item at a time.</p>
+
+<p>Note that spinners may be "circular". When a spinner's "circular" property is set to <tt>true</tt>, the spinner's selection will wrap when it reaches the first or last item in the list. In the following example, the first spinner is circular, and the second is not:</p>
+
+<script>
+var attributes = {code:"org.apache.pivot.wtk.BrowserApplicationContext$HostApplet",
+    archive:"lib/@project_name@-core-@version@.jar,lib/@project_name@-wtk-@version@.jar,lib/@project_name@-wtk-@version@.terra.jar,lib/@project_name@-tutorials-@version@.jar",
+    width:160,
+    height:30
+};
+var parameters = {application_class_name:"org.apache.pivot.tutorials.boundedrange.Spinners",
+    codebase_lookup:false
+};
+deployJava.writeAppletTag(attributes, parameters);
+</script>
+
+<p>Because spinner data is specified using an instance of the <tt>List</tt> interface, spinners are quite flexible. The second spinner in the above example uses an instance of <tt>NumericSpinnerData</tt> as its model. This class is a lightweight means of representing a list of numeric value options: it doesn't actually store the values as a list in memory - it simply calculates the appropriate value for a given index using its lower and upper bounds and increment value.</p>
+
+<p>The WTKX for this example is shown below:</p>
+
+<pre class="brush:xml">
+&lt;Window title="Spinners" maximized="true"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns:content="org.apache.pivot.wtk.content"
+    xmlns="org.apache.pivot.wtk"&gt;
+    &lt;content&gt;
+        &lt;Border&gt;
+            &lt;content&gt;
+                &lt;BoxPane styles="{verticalAlignment:'center'}"&gt;
+                    &lt;Spinner spinnerData="['One', 'Two', 'Three', 'Four', 'Five']"
+                        circular="true" preferredWidth="80" selectedIndex="0"/&gt;
+                    &lt;Spinner preferredWidth="40" selectedIndex="0"&gt;
+                        &lt;spinnerData&gt;
+                            &lt;content:NumericSpinnerData lowerBound="0" upperBound="9" increment="1"/&gt;
+                        &lt;/spinnerData&gt;
+                    &lt;/Spinner&gt;
+                &lt;/BoxPane&gt;
+            &lt;/content&gt;
+        &lt;/Border&gt;
+    &lt;/content&gt;
+&lt;/Window&gt;
+</pre>
+
+<p>The Java source is as follows:</p>
+
+<pre class="brush:java">
+package org.apache.pivot.tutorials.boundedrange;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class Spinners implements Application {
+    private Window window = null;
+
+    public void startup(Display display, Map&lt;String, String&gt; properties) throws Exception {
+        WTKXSerializer wtkxSerializer = new WTKXSerializer();
+        window = (Window)wtkxSerializer.readObject(this, "spinners.wtkx");
+        window.open(display);
+    }
+
+    public boolean shutdown(boolean optional) {
+        if (window != null) {
+            window.close();
+        }
+
+        return false;
+    }
+
+    public void suspend() {
+    }
+
+    public void resume() {
+    }
+
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(Spinners.class, args);
+    }
+}
+</pre>
 
 <p>Next: <a href="sliders.html">Sliders</a></p>
 </body>