Class MenuView
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class MenuView *Beta API*

public class netscape.application.MenuView
    extends netscape.application.View
{
    /* Fields
     */
    public final static int HORIZONTAL;
    public final static int VERTICAL;

    public MenuView child;
    public MenuView owner;

    /* Constructors
     */
    public MenuView();
    public MenuView(Menu);
    public MenuView(int, int, int, int);
    public MenuView(int, int, int, int, Menu);
    public MenuView(int, int, int, int, Menu, MenuView);

    /* Methods
     */
    public Color backgroundColor();
    public Border border();
    protected MenuView createMenuView(Menu);
    public void decode(Decoder);
    public void describeClassInfo(ClassInfo);
    public void deselectItem();
    public void drawItemAt(int);
    public void drawView(Graphics);
    public void encode(Encoder);
    public void finishDecoding();
    public void hide();
    public Rect interiorRect();
    public boolean isTransparent();
    public boolean isVisible();
    public MenuItem itemForPoint(int, int);
    public int itemHeight();
    public Menu menu();
    public int minItemHeight();
    public int minItemWidth();
    public Size minSize();
    public boolean mouseDown(MouseEvent);
    public void mouseDragged(MouseEvent);
    public void mouseEntered(MouseEvent);
    public void mouseExited(MouseEvent);
    public void mouseMoved(MouseEvent);
    public void mouseUp(MouseEvent);
    public MenuView owner();
    public Rect rectForItemAt(int);
    public void selectItem(MenuItem);
    public int selectedIndex();
    public MenuItem selectedItem();
    public void setItemHeight(int);
    public void setMenu(Menu);
    public void setOwner(MenuView);
    public void setTransparent(boolean);
    public void setType(int);
    public void show(RootView, MouseEvent);
    public int type();
    public boolean wantsAutoscrollEvents();
}
View subclass managing a Menu. There are two types of MenuViews, HORIZONTAL and VERTICAL. You set this type with the setType method to tell the MenuView how it should arrange its Menu's MenuItems for displaying. MenuViews arrange themselves hierarchically to mirror the structure of their respective Menus, using their owner and child instance variables for traversing. Thus, a top-level MenuView will have a null owner, and the lowest showing MenuView will have a null child. When a MenuView receives a MouseEvent that should show a submenu, a new MenuView is created with its Menu data set appropriately, and then that MenuView is instructed to show. Additionally, the behavior of MouseEvents on the MenuView differs if it manages a top-level Menu. Note that MenuViews manage an InternalWindow that they use to draw into, and this Window is never shown in MenuViews that are designated as static "menu bar" style MenuViews. You usually create a new MenuView with a given Menu, and then set it on a Window with setMenuView. These MenuViews must own a top-level Menu, and are usually of type HORIZONTAL.
See Also:
Menu, MenuItem

Fields

owner

  public MenuView owner

child

  public MenuView child

HORIZONTAL

  public final static int HORIZONTAL

VERTICAL

  public final static int VERTICAL

Constructors

MenuView

  public MenuView()
Constructs a MenuView with origin (0, 0) and zero width and height. This MenuView will create its own top-level Menu, will be of type HORIZONTAL, and will have no owner.

MenuView

  public MenuView(Menu aMenu)
Constructs a MenuView with origin (0, 0) and zero width and height. This MenuView will use aMenu to define its structure, and will determine its type by whether or not aMenu is top-level. This MenuView's owner will be null.

MenuView

  public MenuView(int x,
                  int y,
                  int width,
                  int height)
Constructs a MenuView with bounds (x, y, width, height). This MenuView will create its own top-level Menu, will be of type HORIZONTAL, and will have no owner.

MenuView

  public MenuView(int x,
                  int y,
                  int width,
                  int height,
                  Menu aMenu)
Constructs a MenuView with bounds (x, y, width, height). This MenuView will use aMenu to define its structure, and will determine its type by whether or not aMenu is top-level. This MenuView's owner will be null.

MenuView

  public MenuView(int x,
                  int y,
                  int width,
                  int height,
                  Menu aMenu,
                  MenuView anOwner)
Constructs a MenuView with bounds (x, y, width, height). This MenuView will use aMenu to define its structure, and will determine its type by whether or not aMenu is top-level. This MenuView will have anOwner as its owner.

Methods

setType

  public void setType(int aType)
Sets this MenuView to be of type aType, either HORIZONTAL or VERTICAL.

type

  public int type()
Returns this MenuView's type.
See Also:
setType

setMenu

  public void setMenu(Menu theMenu)
Sets the Menu this MenuView owns.

menu

  public Menu menu()
Returns the Menu this MenuView owns.

setOwner

  public void setOwner(MenuView menuView)
Sets menuView as the owner of this MenuView. A MenuView's owner is the MenuView that hierarchically displays this MenuView.

owner

  public MenuView owner()
Returns the owner of this MenuView.
See Also:
setOwner

backgroundColor

  public Color backgroundColor()
Returns the background Color of the MenuView's Menu.

border

  public Border border()
Returns the Border of the MenuView's Menu.

setTransparent

  public void setTransparent(boolean flag)
Sets the MenuView to be transparent or opaque. This will also set the transparency for the InternalWindow this MenuView draws into.

isTransparent

  public boolean isTransparent()
Overridden to return true if the MenuView is transparent.
Overrides:
isTransparent in class View
See Also:
setTransparent

setItemHeight

  public void setItemHeight(int height)
Sets the height of each MenuItem in the MenuView. Each MenuItem has the same height. If height is 0, sets the height to minItemHeight().
See Also:
minItemHeight

itemHeight

  public int itemHeight()
Returns the MenuView's MenuItem height.
See Also:
setItemHeight

minItemHeight

  public int minItemHeight()
Returns the largest minHeight() of all of the MenuView's MenuItems.

minItemWidth

  public int minItemWidth()
Returns the largest title width of all of the MenuView's MenuItems.

minSize

  public Size minSize()
Overridden to return a Size consisting of the minimum width necessary to accommodate all the MenuItems and the itemHeight(). This Size will reflect whether or not this MenuView is of type HORIZONTAL or VERTICAL.
Overrides:
minSize in class View

itemForPoint

  public MenuItem itemForPoint(int x,
                               int y)
Returns the MenuItem at the coordinate (x, y).

selectedIndex

  public int selectedIndex()
Returns the row of the selected MenuItem. If no MenuItem is selected, returns -1.

selectedItem

  public MenuItem selectedItem()
Returns the selected MenuItem. If no MenuItem is selected, returns null.

selectItem

  public void selectItem(MenuItem item)
Selects item and deselects any other selected MenuItem.

deselectItem

  public void deselectItem()
Deselects any MenuItem that might be currently selected.

rectForItemAt

  public Rect rectForItemAt(int index)
Returns the Rect that describes the MenuItem at index.

interiorRect

  public Rect interiorRect()
Returns a Rect describing the MenuView's "interior," the MenuView's bounds minus its left, right, top and bottom borders.

drawItemAt

  public void drawItemAt(int index)
Calls draw() with the Rect for the MenuItem at the given row index.

createMenuView

  protected MenuView createMenuView(Menu theMenu)
Returns a MenuView with its structure defined by theMenu. Subclasses of MenuView should override this method to return their special subclass.

mouseDown

  public boolean mouseDown(MouseEvent event)
Overridden to receive mouse clicks.
Overrides:
mouseDown in class View

mouseDragged

  public void mouseDragged(MouseEvent event)
Overridden to receive mouse drag events.
Overrides:
mouseDragged in class View

mouseUp

  public void mouseUp(MouseEvent event)
Overridden to receive mouse up events.
Overrides:
mouseUp in class View

mouseEntered

  public void mouseEntered(MouseEvent event)
Overridden to receive mouse entered events.
Overrides:
mouseEntered in class View

mouseMoved

  public void mouseMoved(MouseEvent event)
Overridden to receive mouse moved events.
Overrides:
mouseMoved in class View

mouseExited

  public void mouseExited(MouseEvent event)
Overridden to receive mouse exited events.
Overrides:
mouseExited in class View

drawView

  public void drawView(Graphics g)
Overridden to draw this MenuView. This handles both top-level and submenu type MenuViews.
Overrides:
drawView in class View

show

  public void show(RootView rootView,
                   MouseEvent event)
Shows the InternalWindow that holds this MenuView. This method is automatically called by this MenuView's owner when it should show. You should only call this method directly on top-level context-sensitive MenuViews. You should not call this method on a MenuView that has been added to a Window with setMenuView.

hide

  public void hide()
Hides the InternalWindow that holds this MenuView. This method is automatically called by this MenuView's owner when it should hide.
See Also:
show

isVisible

  public boolean isVisible()
Returns true if this MenuView is visible by virtue of its InternalWindow.

wantsAutoscrollEvents

  public boolean wantsAutoscrollEvents()
Overriden to return true.
Overrides:
wantsAutoscrollEvents in class View

describeClassInfo

  public void describeClassInfo(ClassInfo info)
Describes the MenuView class' information.
Overrides:
describeClassInfo in class View
See Also:
describeClassInfo

encode

  public void encode(Encoder encoder) throws CodingException
Encodes the MenuView instance.
Overrides:
encode in class View
See Also:
decode

decode

  public void decode(Decoder decoder) throws CodingException
Decodes the MenuView instance.
Overrides:
decode in class View
See Also:
decode

finishDecoding

  public void finishDecoding() throws CodingException
Finishes the MenuView instance decoding.
Overrides:
finishDecoding in class View
See Also:
finishDecoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Apr 1997