add mac dependent use of embedded menu bar rather than AWT toolbar for the non-embedd...
authorjprocter <Jim Procter>
Fri, 26 Oct 2007 16:30:33 +0000 (16:30 +0000)
committerjprocter <Jim Procter>
Fri, 26 Oct 2007 16:30:33 +0000 (16:30 +0000)
src/jalview/appletgui/AlignFrame.java

index 85e4a1a..7e706d5 100755 (executable)
@@ -125,17 +125,7 @@ public class AlignFrame
     alignPanel.idPanel.idCanvas.addKeyListener(this);
     alignPanel.scalePanel.addKeyListener(this);
     alignPanel.annotationPanel.addKeyListener(this);
-
-    if (embedded)
-    {
-      setEmbedded();
-    }
-    else
-    {
-      add(alignPanel, BorderLayout.CENTER);
-      jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
-                                       DEFAULT_HEIGHT);
-    }
+    createAlignFrameWindow(embedded, title);
     alignPanel.validate();
     alignPanel.paintAlignment(true);
   }
@@ -2799,10 +2789,15 @@ public class AlignFrame
     selectMenu.add(invertColSel);
     selectMenu.add(deleteGroups);
   }
-
-  public void setEmbedded()
+  /**
+   * This used to be called setEmbedded, but is now creates the 
+   * dropdown menus in a platform independent manner
+   * to avoid OSX/Mac menu appendage daftness.
+   *  
+   * @param reallyEmbedded true to attach the view to the applet area on the page rather than in a new window
+   */
+  public void createAlignFrameWindow(boolean reallyEmbedded, String title)
   {
-
     embeddedMenu = new Panel();
     embeddedEdit = new Label("Edit");
     embeddedSelect = new Label("Select");
@@ -2842,21 +2837,39 @@ public class AlignFrame
     embeddedColour.addMouseListener(this);
     embeddedCalculate.addMouseListener(this);
     embeddedHelp.addMouseListener(this);
-
-    fileMenu.remove(closeMenuItem);
-    fileMenu.remove(3); // Seperator
-
-    viewport.applet.setLayout(new BorderLayout());
-    viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
-    viewport.applet.add(statusBar, BorderLayout.SOUTH);
-
-    alignPanel.setSize(viewport.applet.getSize().width,
-                       viewport.applet.getSize().height
-                       - embeddedMenu.HEIGHT - statusBar.HEIGHT);
-
-    viewport.applet.add(alignPanel, BorderLayout.CENTER);
-    viewport.applet.validate();
-
+    if (reallyEmbedded)
+    {
+      // view cannot be closed if its actually on the page
+      fileMenu.remove(closeMenuItem);
+      fileMenu.remove(3); // Remove Seperator
+      // and actually add the components to the applet area
+      viewport.applet.setLayout(new BorderLayout());
+      viewport.applet.add(embeddedMenu, BorderLayout.NORTH);
+      viewport.applet.add(statusBar, BorderLayout.SOUTH);
+      alignPanel.setSize(viewport.applet.getSize().width,
+              viewport.applet.getSize().height
+              - embeddedMenu.HEIGHT - statusBar.HEIGHT);
+      viewport.applet.add(alignPanel, BorderLayout.CENTER);
+      viewport.applet.validate();
+    } else {
+      if (new jalview.util.Platform().isAMac())
+      {
+        // TODO: try to modify the embeddedMenu display so it looks like a real toolbar menu
+        // TODO: modify click/mouse handler for embeddedMenu so it behaves more like a real pulldown menu toolbar
+        setMenuBar(null);// alignFramMenuBar);
+        // add the components to the AlignFrame area.
+        add(embeddedMenu, BorderLayout.NORTH);
+        alignPanel.setSize(getSize().width,
+              getSize().height
+                - embeddedMenu.HEIGHT - statusBar.HEIGHT);
+        
+      }
+      add(statusBar, BorderLayout.SOUTH);
+      add(alignPanel, BorderLayout.CENTER);
+      // and register with the applet so it can pass external API calls to us
+      jalview.bin.JalviewLite.addFrame(this, title, DEFAULT_WIDTH,
+                                         DEFAULT_HEIGHT);
+    }
   }
 
   PopupMenu filePopup, editPopup, searchPopup,