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/09/26 18:57:35 UTC
svn commit: r819173 - in /incubator/pivot/trunk:
demos/src/org/apache/pivot/demos/scripting/
tutorials/src/org/apache/pivot/tutorials/windows/ tutorials/www/
wtk/src/org/apache/pivot/wtk/skin/terra/
Author: gbrown
Date: Sat Sep 26 16:57:34 2009
New Revision: 819173
URL: http://svn.apache.org/viewvc?rev=819173&view=rev
Log:
Update windows tutorial.
Added:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/dialog.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/palette.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/sheet.wtkx
Removed:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/application_form_add.png
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/desktop.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/pivot_logo.png
Modified:
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/scripting/scripting_demo.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx
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/demos/src/org/apache/pivot/demos/scripting/scripting_demo.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/scripting/scripting_demo.wtkx?rev=819173&r1=819172&r2=819173&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java?rev=819173&r1=819172&r2=819173&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/Windows.java Sat Sep 26 16:57:34 2009
@@ -18,136 +18,51 @@
import java.io.IOException;
-import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.Map;
-import org.apache.pivot.collections.Sequence;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Application;
-import org.apache.pivot.wtk.ApplicationContext;
-import org.apache.pivot.wtk.BoxPane;
-import org.apache.pivot.wtk.Button;
-import org.apache.pivot.wtk.ButtonPressListener;
-import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.Container;
-import org.apache.pivot.wtk.ContainerListener;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Frame;
-import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.Window;
-import org.apache.pivot.wtk.content.ButtonData;
import org.apache.pivot.wtkx.WTKXSerializer;
public class Windows implements Application {
- private Window desktop = null;
- private PushButton newFrameButton = null;
- private BoxPane windowButtonBoxPane = null;
-
- private int frameNumber = 1;
- private int frameX = 0;
- private int frameY = 0;
+ private Display display = null;
@Override
- public void startup(final Display display, Map<String, String> properties) throws Exception {
- WTKXSerializer wtkxSerializer = new WTKXSerializer();
- desktop = (Window)wtkxSerializer.readObject(this, "desktop.wtkx");
-
- display.getContainerListeners().add(new ContainerListener.Adapter() {
- @Override
- public void componentInserted(Container container, int index) {
- final Window window = (Window)container.get(index);
-
- if (window.getOwner() == desktop) {
- final PushButton windowButton = new PushButton();
- windowButton.getStyles().put("toolbar", true);
-
- ButtonData windowButtonData = new ButtonData(window.getIcon(), window.getTitle());
- windowButton.setButtonData(windowButtonData);
- windowButton.getUserData().put("window", window);
-
- windowButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- window.moveToFront();
- }
- });
-
- windowButtonBoxPane.add(windowButton);
-
- ApplicationContext.queueCallback(new Runnable() {
- @Override
- public void run() {
- windowButton.scrollAreaToVisible(0, 0, windowButton.getWidth(), windowButton.getHeight());
- }
- });
- }
- }
+ public void startup(Display display, Map<String, String> properties) throws Exception {
+ this.display = display;
- @Override
- public void componentsRemoved(Container container, int index, Sequence<Component> removed) {
- removed = new ArrayList<Component>(removed);
-
- for (int i = windowButtonBoxPane.getLength() - 1; i >= 0; i--) {
- PushButton windowButton = (PushButton)windowButtonBoxPane.get(i);
- Window window = (Window)windowButton.getUserData().get("window");
-
- for (int j = 0, n = removed.getLength(); j < n; j++) {
- if (window == removed.get(j)) {
- windowButtonBoxPane.remove(i, 1);
- removed.remove(j, 1);
- break;
- }
- }
-
- if (removed.getLength() == 0) {
- break;
- }
- }
- }
- });
+ int x = 0;
+ int y = 0;
- newFrameButton = (PushButton)wtkxSerializer.get("newFrameButton");
- newFrameButton.getButtonPressListeners().add(new ButtonPressListener() {
- @Override
- public void buttonPressed(Button button) {
- WTKXSerializer wtkxSerializer = new WTKXSerializer();
-
- 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 " + frameNumber);
- frameNumber++;
-
- frame.setLocation(frameX, frameY);
- frameX += 20;
- if (frameX > display.getWidth()) {
- frameX = 0;
- }
-
- frameY += 20;
- if (frameY > display.getHeight()) {
- frameY = 0;
- }
+ for (int i = 0; i < 3; i++) {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
- frame.open(desktop);
+ 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);
}
- });
- windowButtonBoxPane = (BoxPane)wtkxSerializer.get("windowButtonBoxPane");
+ frame.setTitle("Frame " + (i + 1));
+ frame.setLocation(x, y);
+ x += 20;
+ y += 20;
- desktop.open(display);
+ frame.open(display);
+ }
}
@Override
public boolean shutdown(boolean optional) {
- if (desktop != null) {
- desktop.close();
+ for (int i = display.getLength() - 1; i >= 0; i--) {
+ Window window = (Window)display.get(i);
+ window.close();
}
return false;
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/dialog.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/dialog.wtkx?rev=819173&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/dialog.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/dialog.wtkx Sat Sep 26 16:57:34 2009
@@ -0,0 +1,42 @@
+<?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.
+-->
+
+<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>
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx?rev=819173&r1=819172&r2=819173&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/frame.wtkx Sat Sep 26 16:57:34 2009
@@ -17,10 +17,16 @@
-->
<Frame icon="@application_form.png"
- preferredWidth="320" preferredHeight="240"
+ 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:include wtkx:id="palette" src="palette.wtkx"/>
+ </wtkx:define>
+
<content>
<BoxPane orientation="vertical">
<PushButton buttonData="Show Alert">
@@ -48,6 +54,45 @@
</wtkx:script>
</buttonPressListeners>
</PushButton>
+
+ <PushButton buttonData="Show Dialog">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ dialog.open(button.getWindow(), null);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Sheet">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ sheet.open(button.getWindow(), null);
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+
+ <PushButton buttonData="Show Palette">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ palette.open(button.getWindow());
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
</BoxPane>
</content>
</Frame>
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/palette.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/palette.wtkx?rev=819173&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/palette.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/palette.wtkx Sat Sep 26 16:57:34 2009
@@ -0,0 +1,32 @@
+<?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.
+-->
+
+<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>
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/sheet.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/sheet.wtkx?rev=819173&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/sheet.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/windows/sheet.wtkx Sat Sep 26 16:57:34 2009
@@ -0,0 +1,44 @@
+<?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.
+-->
+
+<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>
Modified: incubator/pivot/trunk/tutorials/www/windows.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/windows.template.html?rev=819173&r1=819172&r2=819173&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/windows.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/windows.template.html Sat Sep 26 16:57:34 2009
@@ -59,14 +59,5 @@
<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 simulates an "application launcher", such as the Microsoft Windows¨ task bar or the Mac OS X dock. It allows the user to create multiple top-level <tt>Frame</tt> instances, each of which can, in turn, open a selection of additional windows for which the frame will be the owner:</p>
-
-alert
-prompt
-modal dialog
-sheet
-palette
-tooltip
-
</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=819173&r1=819172&r2=819173&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 Sat Sep 26 16:57:34 2009
@@ -96,7 +96,7 @@
private Point dragOffset = null;
- private Insets padding = new Insets(4);
+ private Insets padding = new Insets(1);
private WindowListener ownerListener = new WindowListener.Adapter() {
@Override