Class MenuView
All Packages Class Hierarchy This Package Previous Next Index
Class MenuView
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);
protected InternalWindow createMenuWindow();
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
protected InternalWindow createMenuWindow()
- Creates the InternalWindow that is used by this MenuView for
displaying its Menu's MenuItems. Note that toplevel MenuViews never
use an InternalWindow for drawing, so the returned Object is
ignored. Subclasses can override this
method to return their own custom subclass of InternalWindow.
public void setType(int aType)
- Sets this MenuView to be of type aType, either HORIZONTAL
or VERTICAL.
public int type()
- Returns this MenuView's type.
- See Also:
- setType
public void setMenu(Menu theMenu)
- Sets the Menu this MenuView owns.
public Menu menu()
- Returns the Menu this MenuView owns.
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.
public MenuView owner()
- Returns the owner of this MenuView.
- See Also:
- setOwner
public Color backgroundColor()
- Returns the background Color of the MenuView's Menu.
public Border border()
- Returns the Border of the MenuView's Menu.
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.
public boolean isTransparent()
- Overridden to return true if the MenuView is transparent.
- Overrides:
- isTransparent in class View
- See Also:
- setTransparent
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
public int itemHeight()
- Returns the MenuView's MenuItem height.
- See Also:
- setItemHeight
public int minItemHeight()
- Returns the largest minHeight() of all of the MenuView's
MenuItems.
public int minItemWidth()
- Returns the largest title width of all of the MenuView's MenuItems.
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
public MenuItem itemForPoint(int x,
int y)
- Returns the MenuItem at the coordinate (x, y).
public int selectedIndex()
- Returns the row of the selected MenuItem. If no MenuItem is selected,
returns -1.
public MenuItem selectedItem()
- Returns the selected MenuItem. If no MenuItem is selected, returns
null.
public void selectItem(MenuItem item)
- Selects item and deselects any other selected MenuItem.
public void deselectItem()
- Deselects any MenuItem that might be currently selected.
public Rect rectForItemAt(int index)
- Returns the Rect that describes the MenuItem at index.
public Rect interiorRect()
- Returns a Rect describing the MenuView's "interior," the MenuView's
bounds minus its left, right, top and bottom borders.
public void drawItemAt(int index)
- Calls draw() with the Rect for the MenuItem at the given row
index.
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.
public boolean mouseDown(MouseEvent event)
- Overridden to receive mouse clicks.
- Overrides:
- mouseDown in class View
public void mouseDragged(MouseEvent event)
- Overridden to receive mouse drag events.
- Overrides:
- mouseDragged in class View
public void mouseUp(MouseEvent event)
- Overridden to receive mouse up events.
- Overrides:
- mouseUp in class View
public void mouseEntered(MouseEvent event)
- Overridden to receive mouse entered events.
- Overrides:
- mouseEntered in class View
public void mouseMoved(MouseEvent event)
- Overridden to receive mouse moved events.
- Overrides:
- mouseMoved in class View
public void mouseExited(MouseEvent event)
- Overridden to receive mouse exited events.
- Overrides:
- mouseExited in class View
public void drawView(Graphics g)
- Overridden to draw this MenuView. This handles both top-level and
submenu type MenuViews.
- Overrides:
- drawView in class View
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 not call this method on
a MenuView that has been added to a Window with setMenuView.
You should only call this method directly on top-level
context-sensitive MenuViews. In this case, rootView is the view
in which to show the InternalWindow containing the context-sensitive MenuView.
event should be in the coordinate system of rootView and
the (x, y) values of the event become the origin of the InternalWindow.
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
public boolean isVisible()
- Returns true if this MenuView is visible by virtue of its
InternalWindow.
public boolean wantsAutoscrollEvents()
- Overriden to return true.
- Overrides:
- wantsAutoscrollEvents in class View
public void describeClassInfo(ClassInfo info)
- Describes the MenuView class' information.
- Overrides:
- describeClassInfo in class View
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the MenuView instance.
- Overrides:
- encode in class View
- See Also:
- decode
public void decode(Decoder decoder) throws CodingException
- Decodes the MenuView instance.
- Overrides:
- decode in class View
- See Also:
- decode
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 Oct 1997