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/16 23:52:56 UTC

svn commit: r815979 - in /incubator/pivot/trunk: tutorials/src/org/apache/pivot/tutorials/menus/ tutorials/src/org/apache/pivot/tutorials/tableviews/ wtk/src/org/apache/pivot/wtk/skin/terra/ wtk/test/org/apache/pivot/wtk/test/

Author: gbrown
Date: Wed Sep 16 21:52:56 2009
New Revision: 815979

URL: http://svn.apache.org/viewvc?rev=815979&view=rev
Log:
Finish MenuButton tutorial (code); stub out TableView tutorial; minor tweak to focus handling in TerraTextInputSkin.

Added:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/TableViews.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/table_views.wtkx
Modified:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.wtkx
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowFocusTest.java

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java?rev=815979&r1=815978&r2=815979&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/MenuButtons.java Wed Sep 16 21:52:56 2009
@@ -44,6 +44,9 @@
 
     private Drawing drawing = null;
 
+    public static final int MAX_X = 480;
+    public static final int MAX_Y = 360;
+
     public MenuButtons() {
         Action.getNamedActions().put("newCircle", new Action() {
             @Override
@@ -97,12 +100,12 @@
 
         drawing = new Drawing();
 
-        Rectangle border = new Rectangle();
-        border.setSize(480, 360);
-        border.setFill((Paint)null);
-        border.setStrokeThickness(1);
+        Rectangle borderRectangle = new Rectangle();
+        borderRectangle.setSize(MAX_X, MAX_Y);
+        borderRectangle.setStroke((Paint)null);
+        borderRectangle.setFill("#eeeeee");
 
-        drawing.getCanvas().add(border);
+        drawing.getCanvas().add(borderRectangle);
 
         imageView.setImage(drawing);
 
@@ -134,8 +137,8 @@
     public Point getRandomLocation(Shape shape) {
         Bounds bounds = shape.getBounds();
 
-        int x = (int)(Math.random() * (double)(drawing.getWidth() - bounds.width));
-        int y = (int)(Math.random() * (double)(drawing.getHeight() - bounds.height));
+        int x = (int)(Math.random() * (double)(MAX_X - bounds.width));
+        int y = (int)(Math.random() * (double)(MAX_Y - bounds.height));
 
         return new Point(x, y);
     }

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menus/menu_buttons.wtkx?rev=815979&r1=815978&r2=815979&view=diff
==============================================================================
Binary files - no diff available.

Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/TableViews.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/TableViews.java?rev=815979&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/TableViews.java (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/TableViews.java Wed Sep 16 21:52:56 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.pivot.tutorials.tableviews;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class TableViews implements Application {
+    private Window window = null;
+
+    @Override
+    public void startup(Display display, Map<String, String> properties) throws Exception {
+        WTKXSerializer wtkxSerializer = new WTKXSerializer();
+        window = (Window)wtkxSerializer.readObject(this, "table_views.wtkx");
+
+        window.open(display);
+    }
+
+    @Override
+    public boolean shutdown(boolean optional) {
+        if (window != null) {
+            window.close();
+        }
+
+        return false;
+    }
+
+    @Override
+    public void suspend() {
+    }
+
+    @Override
+    public void resume() {
+    }
+}

Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/table_views.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/table_views.wtkx?rev=815979&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/table_views.wtkx (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/table_views.wtkx Wed Sep 16 21:52:56 2009
@@ -0,0 +1,24 @@
+<?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="Table Views" maximized="true"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns="org.apache.pivot.wtk">
+    <content>
+    </content>
+</Window>

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=815979&r1=815978&r2=815979&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Wed Sep 16 21:52:56 2009
@@ -1258,8 +1258,8 @@
         if (component.isFocused()) {
             // If focus was permanently transferred within this window,
             // select all
-            if (obverseComponent != null
-                && obverseComponent.getWindow() == window) {
+            if (obverseComponent == null
+                || obverseComponent.getWindow() == window) {
                 if (Mouse.getCapturer() != component) {
                     textInput.selectAll();
                 }
@@ -1269,8 +1269,8 @@
         } else {
             // If focus was permanently transferred within this window,
             // clear the selection
-            if (obverseComponent != null
-                && obverseComponent.getWindow() == window) {
+            if (obverseComponent == null
+                || obverseComponent.getWindow() == window) {
                 textInput.clearSelection();
             }
 

Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowFocusTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowFocusTest.java?rev=815979&r1=815978&r2=815979&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowFocusTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/WindowFocusTest.java Wed Sep 16 21:52:56 2009
@@ -32,7 +32,9 @@
     @Override
     public void startup(Display display, Map<String, String> properties) throws Exception {
         BoxPane boxPane1 = new BoxPane(Orientation.VERTICAL);
-        boxPane1.add(new TextInput());
+        TextInput textInput1 = new TextInput();
+        textInput1.setText("ABCD");
+        boxPane1.add(textInput1);
         boxPane1.add(new TextInput());
         boxPane1.add(new TextInput());
         frame1 = new Frame(boxPane1);
@@ -40,7 +42,9 @@
         frame1.open(display);
 
         BoxPane boxPane2 = new BoxPane(Orientation.VERTICAL);
-        boxPane2.add(new TextInput());
+        TextInput textInput2 = new TextInput();
+        textInput2.setText("1234");
+        boxPane2.add(textInput2);
         boxPane2.add(new TextInput());
         boxPane2.add(new TextInput());
         frame2 = new Frame(boxPane2);