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/07 16:18:34 UTC

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

Author: gbrown
Date: Fri Aug  7 14:18:34 2009
New Revision: 802018

URL: http://svn.apache.org/viewvc?rev=802018&view=rev
Log:
Resolve issue PIVOT-188.

Added:
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/MenuBarTest.java
    incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx
Modified:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menu_bar.wtkx
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Frame.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuBarSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menu_bar.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menu_bar.wtkx?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menu_bar.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/menu_bar.wtkx Fri Aug  7 14:18:34 2009
@@ -16,7 +16,8 @@
 limitations under the License.
 -->
 
-<MenuBar xmlns:wtkx="http://pivot.apache.org/wtkx"
+<MenuBar styles="{backgroundColor:4}"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
     xmlns:content="org.apache.pivot.wtk.content"
     xmlns="org.apache.pivot.wtk">
     <items>

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Frame.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Frame.java?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Frame.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Frame.java Fri Aug  7 14:18:34 2009
@@ -86,12 +86,14 @@
             // Walk down previous focus descendant hierarchy and call cleanupMenuBar()
             Component previousFocusDescendant = getFocusDescendant();
 
-            if (previousFocusDescendant != null) {
+            if (previousFocusDescendant != null
+                && !(previousFocusDescendant instanceof MenuBar.Item)) {
                 LinkedList<Component> previousFocusDescendantPath = new LinkedList<Component>();
 
                 Component previousFocusAncestor = previousFocusDescendant;
                 while (!(previousFocusAncestor instanceof Display)) {
                     previousFocusDescendantPath.insert(previousFocusAncestor, 0);
+                    previousFocusAncestor = previousFocusAncestor.getParent();
                 }
 
                 for (Component component : previousFocusDescendantPath) {
@@ -104,12 +106,14 @@
             }
 
             // Walk down focus descendant hierarchy and call configureMenuBar()
-            if (focusDescendant != null) {
+            if (focusDescendant != null
+                && !(previousFocusDescendant instanceof MenuBar.Item)) {
                 LinkedList<Component> focusDescendantPath = new LinkedList<Component>();
 
                 Component focusAncestor = focusDescendant;
                 while (!(focusAncestor instanceof Display)) {
                     focusDescendantPath.insert(focusAncestor, 0);
+                    focusAncestor = focusAncestor.getParent();
                 }
 
                 for (Component component : focusDescendantPath) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java Fri Aug  7 14:18:34 2009
@@ -196,6 +196,8 @@
                 // Add the component to the row
                 row.add(component);
                 rowWidth += componentSize.width + horizontalSpacing;
+            } else {
+                component.setSize(0, 0);
             }
         }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java Fri Aug  7 14:18:34 2009
@@ -55,8 +55,6 @@
 
 /**
  * Frame skin.
- * <p>
- * TODO Add menu bar support.
  *
  * @author gbrown
  * @author tvolkert
@@ -119,8 +117,8 @@
      */
     protected class MinimizeImage extends ButtonImage {
         public void paint(Graphics2D graphics) {
-            Window window = (Window)getComponent();
-            graphics.setPaint(window.isActive() ? titleBarColor : inactiveTitleBarColor);
+            Frame frame = (Frame)getComponent();
+            graphics.setPaint(frame.isActive() ? titleBarColor : inactiveTitleBarColor);
             graphics.fillRect(0, 6, 8, 2);
         }
     }
@@ -132,11 +130,11 @@
      */
     protected class MaximizeImage extends ButtonImage {
         public void paint(Graphics2D graphics) {
-            Window window = (Window)getComponent();
-            graphics.setPaint(window.isActive() ? titleBarColor : inactiveTitleBarColor);
+            Frame frame = (Frame)getComponent();
+            graphics.setPaint(frame.isActive() ? titleBarColor : inactiveTitleBarColor);
             graphics.fillRect(0, 0, 8, 8);
 
-            graphics.setPaint(window.isActive() ? titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
+            graphics.setPaint(frame.isActive() ? titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
             graphics.fillRect(2, 2, 4, 4);
         }
     }
@@ -148,12 +146,12 @@
      */
     protected class RestoreImage extends ButtonImage {
         public void paint(Graphics2D graphics) {
-            Window window = (Window)getComponent();
-            graphics.setPaint(window.isActive() ?
+            Frame frame = (Frame)getComponent();
+            graphics.setPaint(frame.isActive() ?
                 titleBarColor : inactiveTitleBarColor);
             graphics.fillRect(1, 1, 6, 6);
 
-            graphics.setPaint(window.isActive() ?
+            graphics.setPaint(frame.isActive() ?
                 titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
             graphics.fillRect(3, 3, 2, 2);
         }
@@ -166,8 +164,8 @@
      */
     protected class CloseImage extends ButtonImage {
         public void paint(Graphics2D graphics) {
-            Window window = (Window)getComponent();
-            graphics.setPaint(window.isActive() ?
+            Frame frame = (Frame)getComponent();
+            graphics.setPaint(frame.isActive() ?
                 titleBarColor : inactiveTitleBarColor);
             graphics.setStroke(new BasicStroke(2));
 
@@ -304,13 +302,13 @@
     public void install(Component component) {
         super.install(component);
 
-        Window window = (Window)component;
+        Frame frame = (Frame)getComponent();
 
         // Attach the drop-shadow decorator
         dropShadowDecorator = new DropShadowDecorator();
-        window.getDecorators().add(dropShadowDecorator);
+        frame.getDecorators().add(dropShadowDecorator);
 
-        window.add(titleBarTablePane);
+        frame.add(titleBarTablePane);
 
         // Create the frame buttons
         minimizeButton = new FrameButton(minimizeImage);
@@ -323,14 +321,14 @@
 
         ButtonPressListener buttonPressListener = new ButtonPressListener() {
             public void buttonPressed(Button button) {
-                Window window = (Window)getComponent();
+                Frame frame = (Frame)getComponent();
 
                 if (button == minimizeButton) {
-                    window.setDisplayable(false);
+                    frame.setDisplayable(false);
                 } else if (button == maximizeButton) {
-                    window.setMaximized(!window.isMaximized());
+                    frame.setMaximized(!frame.isMaximized());
                 } else if (button == closeButton) {
-                    window.close();
+                    frame.close();
                 }
             }
         };
@@ -339,24 +337,24 @@
         maximizeButton.getButtonPressListeners().add(buttonPressListener);
         closeButton.getButtonPressListeners().add(buttonPressListener);
 
-        window.add(resizeHandle);
+        frame.add(resizeHandle);
 
-        iconChanged(window, null);
-        titleChanged(window, null);
-        activeChanged(window);
+        iconChanged(frame, null);
+        titleChanged(frame, null);
+        activeChanged(frame);
 
         updateMaximizedState();
     }
 
     @Override
     public void uninstall() {
-        Window window = (Window)getComponent();
+        Frame frame = (Frame)getComponent();
 
         // Detach the drop shadow decorator
-        window.getDecorators().remove(dropShadowDecorator);
+        frame.getDecorators().remove(dropShadowDecorator);
         dropShadowDecorator = null;
 
-        window.remove(titleBarTablePane);
+        frame.remove(titleBarTablePane);
 
         buttonBoxPane.remove(minimizeButton);
         buttonBoxPane.remove(maximizeButton);
@@ -372,21 +370,26 @@
     public int getPreferredWidth(int height) {
         int preferredWidth = 0;
 
-        Window window = (Window)getComponent();
-        Component content = window.getContent();
-
         Dimensions preferredTitleBarSize = titleBarTablePane.getPreferredSize();
         preferredWidth = preferredTitleBarSize.width;
 
+        Frame frame = (Frame)getComponent();
+
+        MenuBar menuBar = frame.getMenuBar();
+        if (menuBar != null
+            && menuBar.isDisplayable()) {
+            preferredWidth = Math.max(preferredWidth, menuBar.getPreferredWidth());
+        }
+
+        Component content = frame.getContent();
         if (content != null
             && content.isDisplayable()) {
             if (height != -1) {
-                height = Math.max(height - preferredTitleBarSize.height - 4 -
+                height = Math.max(height - preferredTitleBarSize.height - 5 -
                     padding.top - padding.bottom, 0);
             }
 
-            preferredWidth = Math.max(preferredWidth,
-                content.getPreferredWidth(height));
+            preferredWidth = Math.max(preferredWidth, content.getPreferredWidth(height));
         }
 
         preferredWidth += (padding.left + padding.right) + 2;
@@ -397,15 +400,21 @@
     public int getPreferredHeight(int width) {
         int preferredHeight = 0;
 
-        Window window = (Window)getComponent();
-        Component content = window.getContent();
-
         if (width != -1) {
             width = Math.max(width - 2, 0);
         }
 
         preferredHeight = titleBarTablePane.getPreferredHeight(width);
 
+        Frame frame = (Frame)getComponent();
+
+        MenuBar menuBar = frame.getMenuBar();
+        if (menuBar != null
+            && menuBar.isDisplayable()) {
+            preferredHeight += menuBar.getPreferredHeight();
+        }
+
+        Component content = frame.getContent();
         if (content != null
             && content.isDisplayable()) {
             if (width != -1) {
@@ -415,7 +424,7 @@
             preferredHeight += content.getPreferredHeight(width);
         }
 
-        preferredHeight += (padding.top + padding.bottom) + 4;
+        preferredHeight += (padding.top + padding.bottom) + 5;
 
         return preferredHeight;
     }
@@ -424,14 +433,23 @@
         int preferredWidth = 0;
         int preferredHeight = 0;
 
-        Window window = (Window)getComponent();
-        Component content = window.getContent();
-
         Dimensions preferredTitleBarSize = titleBarTablePane.getPreferredSize();
 
         preferredWidth = preferredTitleBarSize.width;
         preferredHeight = preferredTitleBarSize.height;
 
+        Frame frame = (Frame)getComponent();
+
+        MenuBar menuBar = frame.getMenuBar();
+        if (menuBar != null
+            && menuBar.isDisplayable()) {
+            Dimensions preferredMenuBarSize = menuBar.getPreferredSize();
+
+            preferredWidth = Math.max(preferredWidth, preferredMenuBarSize.width);
+            preferredHeight += preferredMenuBarSize.height;
+        }
+
+        Component content = frame.getContent();
         if (content != null
             && content.isDisplayable()) {
             Dimensions preferredContentSize = content.getPreferredSize();
@@ -441,13 +459,13 @@
         }
 
         preferredWidth += (padding.left + padding.right) + 2;
-        preferredHeight += (padding.top + padding.bottom) + 4;
+        preferredHeight += (padding.top + padding.bottom) + 5;
 
         return new Dimensions(preferredWidth, preferredHeight);
     }
 
     public void layout() {
-        Window window = (Window)getComponent();
+        Frame frame = (Frame)getComponent();
 
         int width = getWidth();
         int height = getHeight();
@@ -462,29 +480,45 @@
         resizeHandle.setLocation(width - resizeHandle.getWidth() - 2,
             height - resizeHandle.getHeight() - 2);
 
-        boolean maximized = window.isMaximized();
+        boolean maximized = frame.isMaximized();
         resizeHandle.setVisible(resizable
             && !maximized
-            && (window.isPreferredWidthSet()
-                || window.isPreferredHeightSet()));
+            && (frame.isPreferredWidthSet()
+                || frame.isPreferredHeightSet()));
 
-        // Size/position content
-        Component content = window.getContent();
+        // Size/position menu bar
+        int contentX = padding.left + 1;
+        int contentY = titleBarTablePane.getHeight() + 4;
+        int contentWidth = Math.max(width - (padding.left + padding.right + 2), 0);
+        int contentHeight = Math.max(height - (titleBarTablePane.getHeight()
+            + padding.top + padding.bottom + 5), 0);
+
+        MenuBar menuBar = frame.getMenuBar();
+        if (menuBar != null) {
+            menuBar.setLocation(1, contentY);
+
+            int menuBarWidth = width - 2;
+            if (menuBar.isDisplayable()) {
+                menuBar.setSize(menuBarWidth, menuBar.getPreferredHeight());
+            } else {
+                menuBar.setSize(menuBarWidth, 0);
+            }
 
-        if (content != null) {
-            if (content.isDisplayable()) {
-                content.setVisible(true);
+            contentY += menuBar.getHeight();
+            contentHeight -= menuBar.getHeight();
+        }
 
-                content.setLocation(padding.left + 1,
-                    titleBarTablePane.getHeight() + padding.top + 3);
+        contentY += padding.top;
 
-                int contentWidth = Math.max(width - (padding.left + padding.right + 2), 0);
-                int contentHeight = Math.max(height - (titleBarTablePane.getHeight()
-                    + padding.top + padding.bottom + 4), 0);
+        // Size/position content
+        Component content = frame.getContent();
+        if (content != null) {
+            content.setLocation(contentX, contentY);
 
+            if (content.isDisplayable()) {
                 content.setSize(contentWidth, contentHeight);
             } else {
-                content.setVisible(false);
+                content.setSize(contentWidth, 0);
             }
         }
     }
@@ -494,18 +528,18 @@
         // Call the base class to paint the background
         super.paint(graphics);
 
-        Window window = (Window)getComponent();
+        Frame frame = (Frame)getComponent();
 
         int width = getWidth();
         int height = getHeight();
         int titleBarHeight = titleBarTablePane.getHeight();
 
         // Draw the title area
-        Color titleBarBackgroundColor = window.isActive() ?
+        Color titleBarBackgroundColor = frame.isActive() ?
             this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
-        Color titleBarBorderColor = window.isActive() ?
+        Color titleBarBorderColor = frame.isActive() ?
             this.titleBarBorderColor : inactiveTitleBarBorderColor;
-        Color titleBarBevelColor = window.isActive() ?
+        Color titleBarBevelColor = frame.isActive() ?
             this.titleBarBevelColor : inactiveTitleBarBevelColor;
 
         graphics.setPaint(new GradientPaint(width / 2, 0, titleBarBevelColor,
@@ -614,18 +648,18 @@
     }
 
     private void updateMaximizedState() {
-        Window window = (Window)getComponent();
-        boolean maximized = window.isMaximized();
+        Frame frame = (Frame)getComponent();
+        boolean maximized = frame.isMaximized();
 
         if (!maximized) {
             maximizeButton.setButtonData(maximizeImage);
 
             if (restoreLocation != null) {
-                window.setLocation(restoreLocation.x, restoreLocation.y);
+                frame.setLocation(restoreLocation.x, restoreLocation.y);
             }
         } else {
             maximizeButton.setButtonData(restoreImage);
-            restoreLocation = window.getLocation();
+            restoreLocation = frame.getLocation();
         }
     }
 
@@ -634,35 +668,35 @@
         boolean consumed = super.mouseMove(component, x, y);
 
         if (Mouse.getCapturer() == component) {
-            Window window = (Window)getComponent();
-            Display display = window.getDisplay();
+            Frame frame = (Frame)getComponent();
+            Display display = frame.getDisplay();
 
-            Point location = window.mapPointToAncestor(display, x, y);
+            Point location = frame.mapPointToAncestor(display, x, y);
 
             // Pretend that the mouse can't move off screen (off the display)
             location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1),
                 Math.min(Math.max(location.y, 0), display.getHeight() - 1));
 
             if (dragOffset != null) {
-                // Move the window
-                window.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
+                // Move the frame
+                frame.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
             } else {
                 if (resizeOffset != null) {
-                    // Resize the window
+                    // Resize the frame
                     int preferredWidth = -1;
                     int preferredHeight = -1;
 
-                    if (window.isPreferredWidthSet()) {
-                        preferredWidth = Math.max(location.x - window.getX() + resizeOffset.x,
+                    if (frame.isPreferredWidthSet()) {
+                        preferredWidth = Math.max(location.x - frame.getX() + resizeOffset.x,
                             titleBarTablePane.getPreferredWidth(-1) + 2);
                     }
 
-                    if (window.isPreferredHeightSet()) {
-                        preferredHeight = Math.max(location.y - window.getY() + resizeOffset.y,
+                    if (frame.isPreferredHeightSet()) {
+                        preferredHeight = Math.max(location.y - frame.getY() + resizeOffset.y,
                             titleBarTablePane.getHeight() + resizeHandle.getHeight() + 7);
                     }
 
-                    window.setPreferredSize(preferredWidth, preferredHeight);
+                    frame.setPreferredSize(preferredWidth, preferredHeight);
                 }
             }
         } else {
@@ -696,8 +730,8 @@
     public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
         boolean consumed = super.mouseDown(component, button, x, y);
 
-        Window window = (Window)getComponent();
-        boolean maximized = window.isMaximized();
+        Frame frame = (Frame)getComponent();
+        boolean maximized = frame.isMaximized();
 
         if (button == Mouse.Button.LEFT
             && !maximized) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuBarSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuBarSkin.java?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuBarSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuBarSkin.java Fri Aug  7 14:18:34 2009
@@ -44,7 +44,6 @@
 
     public TerraMenuBarSkin() {
         TerraTheme theme = (TerraTheme)Theme.getTheme();
-        setBackgroundColor(theme.getColor(4));
 
         font = theme.getFont().deriveFont(Font.BOLD);
         color = theme.getColor(1);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java?rev=802018&r1=802017&r2=802018&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java Fri Aug  7 14:18:34 2009
@@ -154,10 +154,9 @@
             + padding.top + padding.bottom + 2;
 
         // Adjust for preferred aspect ratio
-        if (!Float.isNaN(minimumPreferredAspectRatio)) {
-            if ((float)preferredWidth / (float)preferredHeight < minimumPreferredAspectRatio) {
-                preferredWidth = (int)(preferredHeight * minimumPreferredAspectRatio);
-            }
+        if (!Float.isNaN(minimumPreferredAspectRatio)
+            && (float)preferredWidth / (float)preferredHeight < minimumPreferredAspectRatio) {
+            preferredWidth = (int)(preferredHeight * minimumPreferredAspectRatio);
         }
 
         return new Dimensions(preferredWidth, preferredHeight);

Added: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/MenuBarTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/MenuBarTest.java?rev=802018&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/MenuBarTest.java (added)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/MenuBarTest.java Fri Aug  7 14:18:34 2009
@@ -0,0 +1,81 @@
+/*
+ * 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.wtk.test;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Frame;
+import org.apache.pivot.wtk.MenuBar;
+import org.apache.pivot.wtk.MenuHandler;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtkx.WTKX;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class MenuBarTest implements Application {
+    private Frame frame = null;
+
+    @WTKX private TextInput textInput1 = null;
+    @WTKX private TextInput textInput2 = null;
+    @WTKX private TextInput textInput3 = null;
+
+    public void startup(Display display, Map<String, String> properties) throws Exception {
+        WTKXSerializer wtkxSerializer = new WTKXSerializer();
+        frame = (Frame)wtkxSerializer.readObject(this, "menu_bar_test.wtkx");
+        wtkxSerializer.bind(this, MenuBarTest.class);
+
+        // frame.setMenuBar(null);
+
+        MenuHandler menuHandler = new MenuHandler.Adapter() {
+            @Override
+            public void configureMenuBar(Component component, MenuBar menuBar) {
+                System.out.println("Configure menu bar: " + component);
+            }
+
+            @Override
+            public void cleanupMenuBar(Component component, MenuBar menuBar) {
+                System.out.println("Clean up menu bar: " + component);
+            }
+        };
+
+        textInput1.setMenuHandler(menuHandler);
+        textInput2.setMenuHandler(menuHandler);
+        textInput3.setMenuHandler(menuHandler);
+
+        frame.open(display);
+    }
+
+    public boolean shutdown(boolean optional) {
+        if (frame != null) {
+            frame.close();
+        }
+
+        return false;
+    }
+
+    public void suspend() {
+    }
+
+    public void resume() {
+    }
+
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(MenuBarTest.class, args);
+    }
+}

Added: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx?rev=802018&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx (added)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx Fri Aug  7 14:18:34 2009
@@ -0,0 +1,175 @@
+<?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="MenuBar Test" preferredWidth="320" preferredHeight="240"
+    styles="{padding:{top:0, left:4, bottom:4, right:4}}"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns="org.apache.pivot.wtk">
+    <menuBar>
+        <MenuBar xmlns:wtkx="http://pivot.apache.org/wtkx"
+            xmlns:content="org.apache.pivot.wtk.content"
+            xmlns="org.apache.pivot.wtk">
+            <items>
+                <MenuBar.Item buttonData="File">
+                    <menu>
+                        <Menu>
+                            <sections>
+                                <Menu.Section>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:ButtonData text="New"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:ButtonData text="Open"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                                <Menu.Section>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:ButtonData text="Close"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:ButtonData text="Close All"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                                <Menu.Section>
+                                    <Menu.Item enabled="false">
+                                        <buttonData>
+                                            <content:ButtonData text="Save"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:ButtonData text="Save As"/>
+                                        </buttonData>
+
+                                        <menu>
+                                            <Menu>
+                                                <sections>
+                                                    <Menu.Section>
+                                                        <Menu.Item buttonData="JPEG"/>
+                                                        <Menu.Item buttonData="PNG"/>
+                                                        <Menu.Item buttonData="GIF"/>
+                                                        <Menu.Item buttonData="PDF"/>
+                                                    </Menu.Section>
+                                                </sections>
+                                            </Menu>
+                                        </menu>
+                                    </Menu.Item>
+                                </Menu.Section>
+                            </sections>
+                        </Menu>
+                    </menu>
+                </MenuBar.Item>
+
+                <MenuBar.Item buttonData="Edit">
+                    <menu>
+                        <Menu>
+                            <sections>
+                                <Menu.Section>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Undo"
+                                                keyboardShortcut="CTRL-Z"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Redo"
+                                                keyboardShortcut="SHIFT-CTRL-Z"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                                <Menu.Section>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Cut"
+                                                keyboardShortcut="CTRL-X"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Copy"
+                                                keyboardShortcut="CTRL-C"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Paste"
+                                                keyboardShortcut="CTRL-V"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                                <Menu.Section>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Delete"
+                                                keyboardShortcut="DELETE"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                    <Menu.Item>
+                                        <buttonData>
+                                            <content:MenuItemData text="Select All"
+                                                keyboardShortcut="CTRL-A"/>
+                                        </buttonData>
+                                    </Menu.Item>
+                                </Menu.Section>
+                            </sections>
+                        </Menu>
+                    </menu>
+                </MenuBar.Item>
+
+                <MenuBar.Item buttonData="Window">
+                    <menu>
+                        <Menu>
+                            <sections>
+                                <Menu.Section>
+                                    <Menu.Item buttonData="Minimize"/>
+                                    <Menu.Item buttonData="Maximize"/>
+                                </Menu.Section>
+                            </sections>
+                        </Menu>
+                    </menu>
+                </MenuBar.Item>
+            </items>
+        </MenuBar>
+    </menuBar>
+
+    <content>
+        <Border styles="{padding:8}">
+            <content>
+                <Form>
+                    <sections>
+                        <Form.Section>
+                            <TextInput wtkx:id="textInput1" Form.label="Field 1"/>
+                            <TextInput wtkx:id="textInput2" Form.label="Field 2"/>
+                            <TextInput wtkx:id="textInput3" Form.label="Field 3"/>
+                        </Form.Section>
+                    </sections>
+                </Form>
+            </content>
+        </Border>
+    </content>
+</Frame>
+