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/03 15:57:53 UTC
svn commit: r810945 - in /incubator/pivot/trunk:
core/src/org/apache/pivot/collections/
tutorials/src/org/apache/pivot/tutorials/menus/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/media/
Author: gbrown
Date: Thu Sep 3 13:57:53 2009
New Revision: 810945
URL: http://svn.apache.org/viewvc?rev=810945&view=rev
Log:
Various minor fixes; preliminary work on Menus tutorial.
Added:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx
Modified:
incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java?rev=810945&r1=810944&r2=810945&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java Thu Sep 3 13:57:53 2009
@@ -121,10 +121,8 @@
public HashMap(Map<K, V> map) {
this(Math.max((int)((float)map.getCount() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_CAPACITY));
- if (map != null) {
- for (K key : map) {
- put(key, map.get(key));
- }
+ for (K key : map) {
+ put(key, map.get(key));
}
}
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java?rev=810945&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/Menus.java Thu Sep 3 13:57:53 2009
@@ -0,0 +1,95 @@
+package org.apache.pivot.tutorials.menus;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Action;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.FileBrowserSheet;
+import org.apache.pivot.wtk.Panel;
+import org.apache.pivot.wtk.TabPane;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class Menus implements Application {
+ private Window window = null;
+ private TabPane tabPane = null;
+
+ public Menus() {
+ Action.getNamedActions().put("fileNew", new Action() {
+ @Override
+ public void perform() {
+ // TODO Read document.wtkx
+
+ Panel panel = new Panel();
+ tabPane.getTabs().add(panel);
+ TabPane.setLabel(panel, "Document " + tabPane.getTabs().getLength());
+ }
+ });
+
+ Action.getNamedActions().put("fileOpen", new Action() {
+ @Override
+ public void perform() {
+ FileBrowserSheet fileBrowserSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN);
+ fileBrowserSheet.open(window);
+ }
+ });
+
+ Action.getNamedActions().put("cut", new Action() {
+ @Override
+ public void perform() {
+ TextInput textInput = (TextInput)window.getFocusDescendant();
+ textInput.cut();
+ }
+ });
+
+ Action.getNamedActions().put("copy", new Action() {
+ @Override
+ public void perform() {
+ TextInput textInput = (TextInput)window.getFocusDescendant();
+ textInput.copy();
+ }
+ });
+
+ Action.getNamedActions().put("paste", new Action() {
+ @Override
+ public void perform() {
+ TextInput textInput = (TextInput)window.getFocusDescendant();
+ textInput.paste();
+ }
+ });
+ }
+
+ @Override
+ public void startup(Display display, Map<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ window = (Window)wtkxSerializer.readObject(this, "menus.wtkx");
+
+ tabPane = (TabPane)wtkxSerializer.get("tabPane");
+
+ window.open(display);
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ if (window != null) {
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void suspend() {
+ }
+
+ @Override
+ public void resume() {
+ }
+
+ public static void main(String[] args) {
+ DesktopApplicationContext.main(Menus.class, args);
+ }
+}
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx?rev=810945&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/document.wtkx Thu Sep 3 13:57:53 2009
@@ -0,0 +1,25 @@
+<?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.
+-->
+
+<BoxPane orientation="vertical" styles="{padding:4}"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk">
+ <TextInput text="abcd"/>
+ <TextInput text="1234"/>
+ <PushButton buttonData="Click Me"/>
+</BoxPane>
Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx?rev=810945&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menus.wtkx Thu Sep 3 13:57:53 2009
@@ -0,0 +1,93 @@
+<?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.
+-->
+
+<Frame title="Menus" maximized="true"
+ styles="{padding:{top:0, left:4, bottom:4, right:4}, showWindowControls:false}"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk">
+ <actionMappings>
+ <Window.ActionMapping action="cut" keyStroke="CTRL-X"/>
+ <Window.ActionMapping action="copy" keyStroke="CTRL-C"/>
+ <Window.ActionMapping action="paste" keyStroke="CTRL-V"/>
+ </actionMappings>
+
+ <menuBar>
+ <MenuBar>
+ <items>
+ <MenuBar.Item buttonData="File">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item action="fileNew">
+ <buttonData>
+ <content:ButtonData text="New"/>
+ </buttonData>
+ </Menu.Item>
+ <Menu.Item action="fileOpen">
+ <buttonData>
+ <content:ButtonData text="Open"/>
+ </buttonData>
+ </Menu.Item>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+
+ <MenuBar.Item buttonData="Edit">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item action="cut">
+ <buttonData>
+ <content:MenuItemData text="Cut"
+ keyboardShortcut="CTRL-X"/>
+ </buttonData>
+ </Menu.Item>
+ <Menu.Item action="copy">
+ <buttonData>
+ <content:MenuItemData text="Copy"
+ keyboardShortcut="CTRL-C"/>
+ </buttonData>
+ </Menu.Item>
+ <Menu.Item action="paste">
+ <buttonData>
+ <content:MenuItemData text="Paste"
+ keyboardShortcut="CTRL-V"/>
+ </buttonData>
+ </Menu.Item>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+ </items>
+ </MenuBar>
+ </menuBar>
+
+ <content>
+ <Border styles="{backgroundColor:null}">
+ <content>
+ <TabPane wtkx:id="tabPane"/>
+ </content>
+ </Border>
+ </content>
+</Frame>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java?rev=810945&r1=810944&r2=810945&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java Thu Sep 3 13:57:53 2009
@@ -677,7 +677,8 @@
boolean cancel = false;
for (Window ownedWindow : new ArrayList<Window>(this.ownedWindows)) {
ownedWindow.close();
- cancel |= !(ownedWindow.isClosing() || ownedWindow.isClosed());
+ cancel |= !(ownedWindow.isClosing()
+ || ownedWindow.isClosed());
}
// Close this window only if all owned windows are closing or closed
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java?rev=810945&r1=810944&r2=810945&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Drawing.java Thu Sep 3 13:57:53 2009
@@ -58,7 +58,7 @@
public void regionUpdated(Canvas canvas, int x, int y, int width, int height) {
Bounds bounds = new Bounds(0, 0, Drawing.this.width, Drawing.this.height);
bounds = bounds.intersect(new Bounds(x, y, width, height));
- imageListeners.regionUpdated(Drawing.this, x, y, width, height);
+ imageListeners.regionUpdated(Drawing.this, bounds.x, bounds.y, bounds.width, bounds.height);
}
};