org.eclipse.swt.widgets
Class Menu

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Menu

public class Menu
extends Widget

Safe:


Field Summary
(package private)  MenuItem cascade
           
 int handle
          Suppressed: the handle to the OS resource (Warning: This field is platform dependent)
(package private)  boolean hasLocation
           
(package private)  int hwndCB
           
(package private) static int ID_PPC
           
(package private) static int ID_SPBB
           
(package private) static int ID_SPBM
           
(package private) static int ID_SPMB
           
(package private) static int ID_SPMM
           
(package private) static int ID_SPSOFTKEY0
           
(package private) static int ID_SPSOFTKEY1
           
(package private)  int id0
           
(package private)  int id1
           
(package private)  Decorations parent
           
(package private)  int x
           
(package private)  int y
           
 
Fields inherited from class org.eclipse.swt.widgets.Widget
CANVAS, COMCTL32_MAJOR, COMCTL32_MINOR, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, DISPOSED, eventTable, HIDDEN, keys, MAJOR, MINOR, Mnemonic, state, style, values
 
Constructor Summary
  Menu(Control parent)
          Enabled: Constructs a new instance of this class given its parent, and sets the style for the instance so that the instance will be a popup menu on the given parent's shell.
  Menu(Decorations parent, int style)
          Enabled: Constructs a new instance of this class given its parent (which must be a Decorations) and a style value describing its behavior and appearance.
(package private) Menu(Decorations parent, int style, int handle)
           
  Menu(Menu parentMenu)
          Enabled: Constructs a new instance of this class given its parent (which must be a Menu) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent.
  Menu(MenuItem parentItem)
          Enabled: Constructs a new instance of this class given its parent (which must be a MenuItem) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent menu.
 
Method Summary
(package private)  void _setVisible(boolean visible)
           
 void addHelpListener(HelpListener listener)
          Enabled: Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in the HelpListener interface.
 void addMenuListener(MenuListener listener)
          Enabled: Adds the listener to the collection of listeners who will be notified when menus are hidden or shown, by sending it one of the messages defined in the MenuListener interface.
(package private) static Control checkNull(Control control)
           
(package private) static Menu checkNull(Menu menu)
           
(package private) static MenuItem checkNull(MenuItem item)
           
(package private) static int checkStyle(int style)
           
(package private)  void createHandle()
           
(package private)  void createItem(MenuItem item, int index)
           
(package private)  void createWidget()
           
(package private)  int defaultBackground()
           
(package private)  int defaultForeground()
           
(package private)  void destroyAccelerators()
           
(package private)  void destroyItem(MenuItem item)
           
(package private)  void destroyWidget()
          Destroys the widget in the operating system and releases the widget's handle.
 MenuItem getDefaultItem()
          Enabled: Returns the default menu item or null if none has been previously set.
 Display getDisplay()
          Suppressed:
 boolean getEnabled()
          Enabled: Returns true if the receiver is enabled, and false otherwise.
 MenuItem getItem(int index)
          Enabled: Returns the item at the given, zero-relative index in the receiver.
 int getItemCount()
          Enabled: Returns the number of items contained in the receiver.
 MenuItem[] getItems()
          Enabled: Returns an array of MenuItems which are the items in the receiver.
(package private)  int GetMenuItemCount(int handle)
           
(package private)  String getNameText()
           
 Decorations getParent()
          Suppressed: Returns the receiver's parent, which must be a Decorations.
 MenuItem getParentItem()
          Suppressed: Returns the receiver's parent item, which must be a MenuItem or null when the receiver is a root.
 Menu getParentMenu()
          Suppressed: Returns the receiver's parent item, which must be a Menu or null when the receiver is a root.
 Shell getShell()
          Suppressed: Returns the receiver's shell.
 boolean getVisible()
          Enabled: Returns true if the receiver is visible, and false otherwise.
 int indexOf(MenuItem item)
          Enabled: Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item.
 boolean isEnabled()
          Enabled: Returns true if the receiver is enabled and all of the receiver's ancestors are enabled, and false otherwise.
 boolean isVisible()
          Enabled: Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.
(package private)  void redraw()
           
(package private)  void releaseChild()
           
(package private)  void releaseHandle()
           
(package private)  void releaseWidget()
           
 void removeHelpListener(HelpListener listener)
          Enabled: Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.
 void removeMenuListener(MenuListener listener)
          Enabled: Removes the listener from the collection of listeners who will be notified when the menu events are generated for the control.
 void setDefaultItem(MenuItem item)
          Enabled: Sets the default menu item to the argument or removes the default emphasis when the argument is null.
 void setEnabled(boolean enabled)
          Enabled: Enables the receiver if the argument is true, and disables it otherwise.
 void setLocation(int x, int y)
          Enabled: Sets the receiver's location to the point specified by the arguments which are relative to the display.
 void setLocation(Point location)
          Suppressed: Sets the receiver's location to the point specified by the arguments which are relative to the display.
 void setVisible(boolean visible)
          Enabled: Marks the receiver as visible if the argument is true, and marks it invisible otherwise.
(package private)  void update()
           
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkOrientation, checkParent, checkSubclass, checkWidget, dispose, error, filters, getData, getData, getName, getStyle, hooks, isDisposed, isListening, isValidSubclass, isValidThread, mbcsToWcs, mbcsToWcs, notifyListeners, postEvent, postEvent, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, toString, wcsToMbcs, wcsToMbcs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handle

public int handle
Suppressed: the handle to the OS resource (Warning: This field is platform dependent)


x

int x

y

int y

hwndCB

int hwndCB

id0

int id0

id1

int id1

hasLocation

boolean hasLocation

cascade

MenuItem cascade

parent

Decorations parent

ID_PPC

static final int ID_PPC

ID_SPMM

static final int ID_SPMM

ID_SPBM

static final int ID_SPBM

ID_SPMB

static final int ID_SPMB

ID_SPBB

static final int ID_SPBB

ID_SPSOFTKEY0

static final int ID_SPSOFTKEY0

ID_SPSOFTKEY1

static final int ID_SPSOFTKEY1
Constructor Detail

Menu

public Menu(Control parent)
Enabled: Constructs a new instance of this class given its parent, and sets the style for the instance so that the instance will be a popup menu on the given parent's shell.

Parameters:
parent - a control which will be the parent of the new instance (cannot be null)
See Also:
SWT.POP_UP, Widget.checkSubclass(), Widget.getStyle()

Menu

public Menu(Decorations parent,
            int style)
Enabled: Constructs a new instance of this class given its parent (which must be a Decorations) and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a decorations control which will be the parent of the new instance (cannot be null)
style - the style of menu to construct
See Also:
SWT.BAR, SWT.DROP_DOWN, SWT.POP_UP, Widget.checkSubclass(), Widget.getStyle()

Menu

public Menu(Menu parentMenu)
Enabled: Constructs a new instance of this class given its parent (which must be a Menu) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent.

See Also:
SWT.DROP_DOWN, Widget.checkSubclass(), Widget.getStyle()

Menu

public Menu(MenuItem parentItem)
Enabled: Constructs a new instance of this class given its parent (which must be a MenuItem) and sets the style for the instance so that the instance will be a drop-down menu on the given parent's parent menu.

See Also:
SWT.DROP_DOWN, Widget.checkSubclass(), Widget.getStyle()

Menu

Menu(Decorations parent,
     int style,
     int handle)
Method Detail

_setVisible

void _setVisible(boolean visible)

addHelpListener

public void addHelpListener(HelpListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when help events are generated for the control, by sending it one of the messages defined in the HelpListener interface.

Parameters:
listener - the listener which should be notified
See Also:
HelpListener, removeHelpListener(org.eclipse.swt.events.HelpListener)

addMenuListener

public void addMenuListener(MenuListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when menus are hidden or shown, by sending it one of the messages defined in the MenuListener interface.

Parameters:
listener - the listener which should be notified
See Also:
MenuListener, removeMenuListener(org.eclipse.swt.events.MenuListener)

checkNull

static Control checkNull(Control control)

checkNull

static Menu checkNull(Menu menu)

checkNull

static MenuItem checkNull(MenuItem item)

checkStyle

static int checkStyle(int style)

createHandle

void createHandle()

createItem

void createItem(MenuItem item,
                int index)

createWidget

void createWidget()

defaultBackground

int defaultBackground()

defaultForeground

int defaultForeground()

destroyAccelerators

void destroyAccelerators()

destroyItem

void destroyItem(MenuItem item)

destroyWidget

void destroyWidget()
Description copied from class: Widget
Destroys the widget in the operating system and releases the widget's handle. If the widget does not have a handle, this method may hide the widget, mark the widget as destroyed or do nothing, depending on the widget.

When a widget is destroyed in the operating system, its descendents are also destroyed by the operating system. This means that it is only necessary to call destroyWidget on the root of the widget tree.

This method is called after releaseWidget.

Overrides:
destroyWidget in class Widget
See Also:
Widget.dispose(), Widget.releaseChild(), Widget.releaseWidget(), Widget.releaseHandle()

getDefaultItem

public MenuItem getDefaultItem()
Enabled: Returns the default menu item or null if none has been previously set.

Returns:
the default menu item.

getDisplay

public Display getDisplay()
Suppressed:

Specified by:
getDisplay in class Widget
Returns:
the receiver's display

getEnabled

public boolean getEnabled()
Enabled: Returns true if the receiver is enabled, and false otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Returns:
the receiver's enabled state
See Also:
isEnabled()

getItem

public MenuItem getItem(int index)
Enabled: Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.

Parameters:
index - the index of the item to return
Returns:
the item at the given index

getItemCount

public int getItemCount()
Enabled: Returns the number of items contained in the receiver.

Returns:
the number of items

getItems

public MenuItem[] getItems()
Enabled: Returns an array of MenuItems which are the items in the receiver.

Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.

Returns:
the items in the receiver

GetMenuItemCount

int GetMenuItemCount(int handle)

getNameText

String getNameText()
Overrides:
getNameText in class Widget

getParent

public Decorations getParent()
Suppressed: Returns the receiver's parent, which must be a Decorations.

Returns:
the receiver's parent

getParentItem

public MenuItem getParentItem()
Suppressed: Returns the receiver's parent item, which must be a MenuItem or null when the receiver is a root.

Returns:
the receiver's parent item

getParentMenu

public Menu getParentMenu()
Suppressed: Returns the receiver's parent item, which must be a Menu or null when the receiver is a root.

Returns:
the receiver's parent item

getShell

public Shell getShell()
Suppressed: Returns the receiver's shell. For all controls other than shells, this simply returns the control's nearest ancestor shell. Shells return themselves, even if they are children of other shells.

Returns:
the receiver's shell
See Also:
getParent()

getVisible

public boolean getVisible()
Enabled: Returns true if the receiver is visible, and false otherwise.

If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.

Returns:
the receiver's visibility state

indexOf

public int indexOf(MenuItem item)
Enabled: Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. If no item is found, returns -1.

Parameters:
item - the search item
Returns:
the index of the item

isEnabled

public boolean isEnabled()
Enabled: Returns true if the receiver is enabled and all of the receiver's ancestors are enabled, and false otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Returns:
the receiver's enabled state
See Also:
getEnabled()

isVisible

public boolean isVisible()
Enabled: Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.

Returns:
the receiver's visibility state
See Also:
getVisible()

redraw

void redraw()

releaseChild

void releaseChild()
Overrides:
releaseChild in class Widget

releaseHandle

void releaseHandle()
Overrides:
releaseHandle in class Widget

releaseWidget

void releaseWidget()
Overrides:
releaseWidget in class Widget

removeHelpListener

public void removeHelpListener(HelpListener listener)
Enabled: Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.

Parameters:
listener - the listener which should be notified
See Also:
HelpListener, addHelpListener(org.eclipse.swt.events.HelpListener)

removeMenuListener

public void removeMenuListener(MenuListener listener)
Enabled: Removes the listener from the collection of listeners who will be notified when the menu events are generated for the control.

Parameters:
listener - the listener which should be notified
See Also:
MenuListener, addMenuListener(org.eclipse.swt.events.MenuListener)

setDefaultItem

public void setDefaultItem(MenuItem item)
Enabled: Sets the default menu item to the argument or removes the default emphasis when the argument is null.

Parameters:
item - the default menu item or null

setEnabled

public void setEnabled(boolean enabled)
Enabled: Enables the receiver if the argument is true, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Parameters:
enabled - the new enabled state

setLocation

public void setLocation(int x,
                        int y)
Enabled: Sets the receiver's location to the point specified by the arguments which are relative to the display.

Note: This is different from most widgets where the location of the widget is relative to the parent.

Parameters:
x - the new x coordinate for the receiver
y - the new y coordinate for the receiver

setLocation

public void setLocation(Point location)
Suppressed: Sets the receiver's location to the point specified by the arguments which are relative to the display.

Note: This is different from most widgets where the location of the widget is relative to the parent.

Parameters:
location - the new location for the receiver
Since:
2.1

setVisible

public void setVisible(boolean visible)
Enabled: Marks the receiver as visible if the argument is true, and marks it invisible otherwise.

If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed.

Parameters:
visible - the new visibility state

update

void update()


comments?