OSDN Git Service

2003-06-27 Michael Koch <konqueror@gmx.de>
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / plaf / PopupMenuUI.java
index d1faa78..1871b9b 100644 (file)
@@ -1,5 +1,5 @@
 /* PopupMenuUI.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -37,40 +37,80 @@ exception statement from your version. */
 
 package javax.swing.plaf;
 
-// Imports
-import java.awt.event.*;
+import java.awt.event.MouseEvent;
+import javax.swing.JPopupMenu;
+import javax.swing.Popup;
+import javax.swing.PopupFactory;
+
 
 /**
- * PopupMenuUI
- * @author     Andrew Selkirk
- * @version    1.0
+ * An abstract base class for delegates that implement the pluggable
+ * look and feel for a <code>JPopupMenu</code>.
+ *
+ * @see javax.swing.JPopupMenu
+ *
+ * @author Andrew Selkirk (aselkirk@sympatico.ca)
+ * @author Sascha Brawer (brawer@dandelis.ch)
  */
-public abstract class PopupMenuUI extends ComponentUI {
-
-       //-------------------------------------------------------------
-       // Initialization ---------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * Constructor PopupMenuUI
-        */
-       public PopupMenuUI() {
-               // TODO
-       } // PopupMenuUI()
-
-
-       //-------------------------------------------------------------
-       // Methods ----------------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * isPopupTrigger
-        * @param event TODO
-        * @returns boolean
-        */
-       public boolean isPopupTrigger(MouseEvent event) {
-               return false; // TODO
-       } // isPopupTrigger()
-
-
-} // PopupMenuUI
+public abstract class PopupMenuUI
+  extends ComponentUI
+{
+  /**
+   * Constructs a new <code>PopupMenuUI</code>.
+   */
+  public PopupMenuUI()
+  {
+  }
+
+
+  /**
+   * Tests whether or not a mouse event triggers a popup menu.
+   *
+   * <p>The default implementation calls
+   * <code>event.isPopupTrigger()</code>, which checks for the gesture
+   * that is common for the platform on which the application runs. If
+   * a look and feel wants to employ non-standard conventions for
+   * triggering a popup menu, it can override this method.
+   *
+   * @param event the event to check.
+   *
+   * @return <code>true</code> if the event triggers a popup menu;
+   *         <code>false</code> otherwise.
+   *
+   * @since 1.3
+   */
+  public boolean isPopupTrigger(MouseEvent event)
+  {
+    return event.isPopupTrigger();
+  }
+
+
+  /**
+   * Creates a <code>Popup</code> for displaying the popup menu.  The
+   * default implementation uses the {@link javax.swing.PopupFactory}
+   * for retrieving a suitable <code>Popup</code>, but subclasses
+   * might want to override this method if a LookAndFeel needs special
+   * Popups.
+   *
+   * @param popup the <code>JPopupMenu</code> for whose display
+   *        a <code>Popup</code> is needed.
+   *
+   * @param x the horizontal position where the popup will be
+   *        displayed.
+   *
+   * @param y the vertical position where the popup will be
+   *        displayed.
+   *
+   * @return a <code>Popup</code> for showing and hiding
+   *         the menu.
+   *
+   * @since 1.4
+   */
+  public Popup getPopup(JPopupMenu popup, int x, int y)
+  {
+    return PopupFactory.getSharedInstance().getPopup(
+      /* origin/owner of the popup */ popup.getInvoker(),
+      /* contents */                  popup,
+      x, y);
+  }
+}