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/10/08 00:26:52 UTC
svn commit: r822945 - in /incubator/pivot/trunk: tutorials/www/
wtk/src/org/apache/pivot/wtk/skin/terra/
Author: gbrown
Date: Wed Oct 7 22:26:52 2009
New Revision: 822945
URL: http://svn.apache.org/viewvc?rev=822945&view=rev
Log:
Minor fix to TerraPaletteSkin; tutorial documentation updates.
Modified:
incubator/pivot/trunk/tutorials/www/calendars.template.html
incubator/pivot/trunk/tutorials/www/sample_application.template.html
incubator/pivot/trunk/tutorials/www/table_views.json.template.html
incubator/pivot/trunk/tutorials/www/text.template.html
incubator/pivot/trunk/tutorials/www/windows.template.html
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java
Modified: incubator/pivot/trunk/tutorials/www/calendars.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/calendars.template.html?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/calendars.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/calendars.template.html Wed Oct 7 22:26:52 2009
@@ -33,7 +33,141 @@
</head>
<body>
<h1>Calendars</h1>
-<p>This section is not yet complete.</p>
+
+<p>Pivot supports two types of calendar components: a standalone <tt>Calendar</tt> component that can be used anywhere within an application's user interface, and a <tt>CalendarButton</tt> component that, like a <a href="lists.html">list button</a>, displays a popup calendar when pressed.</p>
+
+<p>The following sample application demonstrates both types of components:</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:360,
+ height:480
+};
+var parameters = {application_class_name:"org.apache.pivot.tutorials.calendars.Calendars",
+ codebase_lookup:false,
+ java_arguments:"-Dsun.awt.noerasebackground=true -Dsun.awt.erasebackgroundonresize=true"
+};
+deployJava.writeAppletTag(attributes, parameters);
+</script>
+
+<p>The WTKX source is as follows:</p>
+
+<pre class="brush:xml">
+<Window title="Calendars" maximized="true"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <content>
+ <Border styles="{padding:8}">
+ <content>
+ <Form styles="{rightAlignLabels:true}">
+ <sections>
+ <Form.Section>
+ <Border Form.label="Calendar" styles="{padding:0, color:10}">
+ <content>
+ <Calendar wtkx:id="calendar"/>
+ </content>
+ </Border>
+ <CalendarButton wtkx:id="calendarButton" Form.label="Calendar button"/>
+ </Form.Section>
+ <Form.Section>
+ <Label wtkx:id="selectedDateLabel" Form.label="Selected date"/>
+ </Form.Section>
+ </sections>
+ </Form>
+ </content>
+ </Border>
+ </content>
+</Window>
+</pre>
+
+<p>The Java source is as follows. It simply registers event handlers that keep the selection state of the <tt>Calendar</tt> and <tt>CalendarButton</tt> in sync:</p>
+
+<pre class="brush:java">
+package org.apache.pivot.tutorials.calendars;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.util.CalendarDate;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Calendar;
+import org.apache.pivot.wtk.CalendarButton;
+import org.apache.pivot.wtk.CalendarButtonSelectionListener;
+import org.apache.pivot.wtk.CalendarSelectionListener;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Label;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class Calendars implements Application {
+ private Window window = null;
+ private Calendar calendar = null;
+ private CalendarButton calendarButton = null;
+ private Label selectedDateLabel = null;
+
+ private boolean updatingSelectedDate = false;
+
+ @Override
+ public void startup(Display display, Map<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ window = (Window)wtkxSerializer.readObject(this, "calendars.wtkx");
+ calendar = (Calendar)wtkxSerializer.get("calendar");
+ calendarButton = (CalendarButton)wtkxSerializer.get("calendarButton");
+ selectedDateLabel = (Label)wtkxSerializer.get("selectedDateLabel");
+
+ calendar.getCalendarSelectionListeners().add(new CalendarSelectionListener() {
+ @Override
+ public void selectedDateChanged(Calendar calendar, CalendarDate previousSelectedDate) {
+ updateSelectedDate(calendar.getSelectedDate());
+ }
+ });
+
+ calendarButton.getCalendarButtonSelectionListeners().add(new CalendarButtonSelectionListener() {
+ @Override
+ public void selectedDateChanged(CalendarButton calendarButton, CalendarDate previousSelectedDate) {
+ updateSelectedDate(calendarButton.getSelectedDate());
+ }
+ });
+
+ window.open(display);
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ if (window != null) {
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void suspend() {
+ }
+
+ @Override
+ public void resume() {
+ }
+
+ private void updateSelectedDate(CalendarDate selectedDate) {
+ if (!updatingSelectedDate) {
+ updatingSelectedDate = true;
+
+ calendar.setSelectedDate(selectedDate);
+ calendarButton.setSelectedDate(selectedDate);
+ selectedDateLabel.setText(selectedDate.toString());
+
+ updatingSelectedDate = false;
+ }
+ }
+
+ public static void main(String[] args) {
+ DesktopApplicationContext.main(Calendars.class, args);
+ }
+}
+</pre>
+
<p>Next: <a href="menus.html">Menus</a></p>
</body>
</html>
Modified: incubator/pivot/trunk/tutorials/www/sample_application.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/sample_application.template.html?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/sample_application.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/sample_application.template.html Wed Oct 7 22:26:52 2009
@@ -29,8 +29,8 @@
<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:720,
- height:480
+ width:800,
+ height:600
};
var parameters = {application_class_name:"org.apache.pivot.tutorials.KitchenSink",
codebase_lookup:false
Modified: incubator/pivot/trunk/tutorials/www/table_views.json.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/table_views.json.template.html?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/table_views.json.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/table_views.json.template.html Wed Oct 7 22:26:52 2009
@@ -118,6 +118,7 @@
</pre>
<p>In this case, the listener assigns an instance of <tt>TableViewRowComparator</tt> to the table data. This class is capable of sorting many types of table data given the sort dictionary of the <tt>TableView</tt> passed to its constructor.</p>
</li>
+</ul>
<p>The contents of "standings.json" are as follows. Medal counts are represented as actual numeric data rather than strings, allowing <tt>TableViewRowComparator</tt> to sort them properly:</p>
Modified: incubator/pivot/trunk/tutorials/www/text.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/text.template.html?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/text.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/text.template.html Wed Oct 7 22:26:52 2009
@@ -42,8 +42,7 @@
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:240,
- height:40,
- style:"border:solid 1px #999999"
+ height:40
};
var parameters = {application_class_name:"org.apache.pivot.tutorials.text.Text",
codebase_lookup:false,
Modified: incubator/pivot/trunk/tutorials/www/windows.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/windows.template.html?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/windows.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/windows.template.html Wed Oct 7 22:26:52 2009
@@ -42,7 +42,7 @@
<p><img src="windows/windows.png"></p>
<p class="caption">Window class hierarchy.</p>
-<p>The following is a description of the window types shown in the diagram:</p>
+<p>The following is a description of each window type:</p>
<ul>
<li><p><b>Window</b> - Base window class; it is not abstract and is the most basic means by which content may be placed on the screen. It simply provides an undecorated region in which other components may be placed.</p></li>
@@ -59,5 +59,271 @@
<p>Most of the tutorial examples up to this point have used a single, maximized, decorationless <tt>Window</tt> to host their example content, since this type of user interface is well-suited to browser-based deployment as employed by this tutorial. However, Pivot applications are not limited to this sort of interface. Just like a native windowing toolkit, a Pivot application can open as many windows on the display of as many different types as are required by the application.</p>
+<p>The following sample application demonstrates each of these window types. It creates three top-level frames, each of which contains buttons for launching several other window types:</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:800,
+ height:600
+};
+var parameters = {application_class_name:"org.apache.pivot.tutorials.windows.Windows",
+ codebase_lookup:false,
+ java_arguments:"-Dsun.awt.noerasebackground=true -Dsun.awt.erasebackgroundonresize=true"
+};
+deployJava.writeAppletTag(attributes, parameters);
+</script>
+
+<p>The content of each frame is defined in "frame.wtkx":</p>
+
+<pre class="brush:xml">
+<Frame wtkx:id="frame" icon="@application_form.png"
+ preferredWidth="480" preferredHeight="360"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk">
+ <wtkx:define>
+ <wtkx:include wtkx:id="dialog" src="dialog.wtkx"/>
+ <wtkx:include wtkx:id="sheet" src="sheet.wtkx"/>
+ </wtkx:define>
+
+ <wtkx:script>
+ var palette = null;
+ </wtkx:script>
+
+ <content>
+ <BoxPane orientation="vertical">
+ <PushButton buttonData="Show Alert">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ Alert.alert("This is an Alert.", frame);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Prompt">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ Prompt.prompt("This is a Prompt.", frame);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Dialog">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ dialog.open(frame, null);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Sheet">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ sheet.open(frame, null);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Palette">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ if (palette == null) {
+ palette = application.load("palette.wtkx");
+ palette.setLocation(frame.getX() + frame.getWidth() + 20, frame.getY() + 20);
+ }
+
+ palette.open(frame);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+ </BoxPane>
+ </content>
+</Frame>
+</pre>
+<p class="caption">frame.wtkx</p>
+
+<p>This file includes several additional WTKX files that define the dialog, sheet, and palette windows opened by the main frame:</p>
+
+<pre class="brush:xml">
+<Dialog wtkx:id="dialog" title="Dialog"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <content>
+ <TablePane preferredWidth="320" preferredHeight="210">
+ <columns>
+ <TablePane.Column width="1*"/>
+ </columns>
+ <rows>
+ <TablePane.Row height="1*">
+ <Label text="This is a dialog."
+ preferredWidth="320" preferredHeight="210"
+ styles="{horizontalAlignment:'center', verticalAlignment:'center'}"/>
+ </TablePane.Row>
+ <TablePane.Row height="-1">
+ <BoxPane styles="{horizontalAlignment:'right'}">
+ <PushButton buttonData="Close"
+ ButtonPressListener.buttonPressed="dialog.close()"/>
+ </BoxPane>
+ </TablePane.Row>
+ </rows>
+ </TablePane>
+ </content>
+</Dialog>
+</pre>
+<p class="caption">dialog.wtkx</p>
+
+<pre class="brush:xml">
+<Sheet wtkx:id="sheet" title="Sheet"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <content>
+ <BoxPane styles="{verticalAlignment:'bottom'}">
+ <TablePane>
+ <columns>
+ <TablePane.Column width="1*"/>
+ </columns>
+ <rows>
+ <TablePane.Row height="1*">
+ <Label text="This is a sheet."
+ preferredWidth="320" preferredHeight="210"
+ styles="{horizontalAlignment:'center', verticalAlignment:'center'}"/>
+ </TablePane.Row>
+ <TablePane.Row height="-1">
+ <BoxPane styles="{horizontalAlignment:'right'}">
+ <PushButton buttonData="Close"
+ ButtonPressListener.buttonPressed="sheet.close()"/>
+ </BoxPane>
+ </TablePane.Row>
+ </rows>
+ </TablePane>
+ </BoxPane>
+ </content>
+</Sheet>
+</pre>
+<p class="caption">sheet.wtkx</p>
+
+<pre class="brush:xml">
+<Palette title="Palette" preferredWidth="60" preferredHeight="120"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <content>
+ <FlowPane styles="{padding:1}">
+ <PushButton buttonData="1" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ <PushButton buttonData="2" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ <PushButton buttonData="3" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ <PushButton buttonData="4" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ <PushButton buttonData="5" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ <PushButton buttonData="6" styles="{toolbar:true, minimumAspectRatio:1, maximumAspectRatio:1}"/>
+ </FlowPane>
+ </content>
+</Palette>
+</pre>
+<p class="caption">palette.wtkx</p>
+
+<p>The application code simply instantiates three <tt>Frame</tt> objects and sets the component read from the WTKX as the frames' contents:</p>
+
+<pre class="brush:java">
+package org.apache.pivot.tutorials.windows;
+
+import java.io.IOException;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Frame;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class Windows implements Application {
+ private Display display = null;
+
+ @Override
+ public void startup(Display display, Map<String, String> properties) throws Exception {
+ this.display = display;
+
+ int x = 0;
+ int y = 0;
+
+ for (int i = 0; i < 3; i++) {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ wtkxSerializer.put("application", this);
+
+ Frame frame;
+ try {
+ frame = (Frame)wtkxSerializer.readObject(Windows.this, "frame.wtkx");
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ }
+
+ frame.setTitle("Frame " + (i + 1));
+ frame.setLocation(x, y);
+ x += 20;
+ y += 20;
+
+ frame.open(display);
+ }
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ for (int i = display.getLength() - 1; i >= 0; i--) {
+ Window window = (Window)display.get(i);
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void suspend() {
+ }
+
+ @Override
+ public void resume() {
+ }
+
+ public Window load(String fileName)
+ throws SerializationException, IOException {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ return (Window)wtkxSerializer.readObject(this, fileName);
+ }
+
+ public static void main(String[] args) {
+ DesktopApplicationContext.main(Windows.class, args);
+ }
+}
+</pre>
+
+<p>Next: <a href="clipboard.html">The Clipboard</a></p>
</body>
</html>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java?rev=822945&r1=822944&r2=822945&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java Wed Oct 7 22:26:52 2009
@@ -187,7 +187,7 @@
titleBoxPane.getStyles().put("padding", new Insets(0, 0, 0, 3));
Font titleFont = theme.getFont();
- titleFont = titleFont.deriveFont(Math.round(titleFont.getSize2D() * 0.8f), Font.BOLD);
+ titleFont = titleFont.deriveFont(Font.BOLD, Math.round(titleFont.getSize2D() * 0.8f));
titleLabel.getStyles().put("font", titleFont);
titleLabel.getStyles().put("color", titleBarColor);