Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.widgets
Class MenuItem  view MenuItem download MenuItem.java

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Item
          extended byorg.eclipse.swt.widgets.MenuItem

public class MenuItem
extends Item

Instances of this class represent a selectable user interface object that issues notification when pressed and released.

Styles:
CHECK, CASCADE, PUSH, RADIO, SEPARATOR
Events:
Arm, Help, Selection

Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR may be specified.

IMPORTANT: This class is not intended to be subclassed.


Field Summary
(package private)  int accelerator
           
(package private)  Menu menu
           
(package private)  Menu parent
           
 
Fields inherited from class org.eclipse.swt.widgets.Item
image, text
 
Fields inherited from class org.eclipse.swt.widgets.Widget
ACTIVATE, BUTTON_PRESS_EVENT, BUTTON_RELEASE_EVENT, CANVAS, CHANGED, CLICKED, COMMIT, CONFIGURE_EVENT, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_RANGE, DELETE_TEXT, DISABLED, display, DISPOSED, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPOSE_EVENT, FOCUS, FOCUS_IN_EVENT, FOCUS_OUT_EVENT, handle, HANDLE, HIDE, INSERT_TEXT, KEY_PRESS_EVENT, KEY_RELEASE_EVENT, KEYED_DATA, LEAVE_NOTIFY_EVENT, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MOTION_NOTIFY_EVENT, OBSCURED, POPUP_MENU, PREEDIT_CHANGED, REALIZE, ROW_ACTIVATED, SCROLL_CHILD, SELECT, SHOW, SHOW_HELP, SIZE_ALLOCATE, state, style, STYLE_SET, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TOGGLED, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT
 
Constructor Summary
MenuItem(Menu parent, int style)
          Constructs a new instance of this class given its parent (which must be a Menu) and a style value describing its behavior and appearance.
MenuItem(Menu parent, int style, int index)
          Constructs a new instance of this class given its parent (which must be a Menu), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.
 
Method Summary
(package private)  void addAccelerator(long accelGroup)
           
(package private)  void addAccelerators(long accelGroup)
           
 void addArmListener(org.eclipse.swt.events.ArmListener listener)
          Adds the listener to the collection of listeners who will be notified when the arm events are generated for the control, by sending it one of the messages defined in the ArmListener interface.
 void addHelpListener(org.eclipse.swt.events.HelpListener listener)
          Adds the listener to the collection of listeners who will be notified when the help events are generated for the control, by sending it one of the messages defined in the HelpListener interface.
 void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
          Adds the listener to the collection of listeners who will be notified when the control is selected, by sending it one of the messages defined in the SelectionListener interface.
(package private) static int checkStyle(int style)
           
(package private)  void createHandle(int index)
           
(package private)  void fixMenus(Decorations newParent)
           
 int getAccelerator()
          Return the widget accelerator.
(package private)  long getAccelGroup()
           
 boolean getEnabled()
          Returns true if the receiver is enabled, and false otherwise.
 Menu getMenu()
          Returns the receiver's cascade menu if it has one or null if it does not.
 Menu getParent()
          Returns the receiver's parent, which must be a Menu.
 boolean getSelection()
          Returns true if the receiver is selected, and false otherwise.
(package private)  long gtk_activate(long widget)
           
(package private)  long gtk_select(long item)
           
(package private)  long gtk_show_help(long widget, long helpType)
           
(package private)  void hookEvents()
           
 boolean isEnabled()
          Returns true if the receiver is enabled and all of the receiver's ancestors are enabled, and false otherwise.
(package private)  void releaseChild()
           
(package private)  void releaseWidget()
           
(package private)  void removeAccelerator(long accelGroup)
           
(package private)  void removeAccelerators(long accelGroup)
           
 void removeArmListener(org.eclipse.swt.events.ArmListener listener)
          Removes the listener from the collection of listeners who will be notified when the arm events are generated for the control.
 void removeHelpListener(org.eclipse.swt.events.HelpListener listener)
          Removes the listener from the collection of listeners who will be notified when the help events are generated for the control.
 void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
          Removes the listener from the collection of listeners who will be notified when the control is selected.
(package private)  void selectRadio()
           
 void setAccelerator(int accelerator)
          Sets the widget accelerator.
 void setEnabled(boolean enabled)
          Enables the receiver if the argument is true, and disables it otherwise.
 void setImage(org.eclipse.swt.graphics.Image image)
          Sets the image the receiver will display to the argument.
 void setMenu(Menu menu)
          Sets the receiver's pull down menu to the argument.
(package private)  boolean setRadioSelection(boolean value)
           
 void setSelection(boolean selected)
          Sets the selection state of the receiver.
 void setText(java.lang.String string)
          Sets the receiver's text.
(package private)  void updateAccelerator(long accelGroup, boolean add)
           
 
Methods inherited from class org.eclipse.swt.widgets.Item
checkSubclass, getImage, getNameText, getText
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkBits, checkOrientation, checkParent, checkWidget, createWidget, deregister, destroyWidget, dispose, error, filterProc, filters, fixMnemonic, fontHeight, getData, getData, getDisplay, getName, getStyle, gtk_button_press_event, gtk_button_release_event, gtk_changed, gtk_clicked, gtk_commit, gtk_configure_event, gtk_delete_event, gtk_delete_range, gtk_delete_text, gtk_enter_notify_event, gtk_event_after, gtk_event, gtk_expose_event, gtk_focus_in_event, gtk_focus_out_event, gtk_focus, gtk_hide, gtk_insert_text, gtk_key_press_event, gtk_key_release_event, gtk_leave_notify_event, gtk_map_event, gtk_mnemonic_activate, gtk_motion_notify_event, gtk_popup_menu, gtk_preedit_changed, gtk_realize, gtk_row_activated, gtk_scroll_child, gtk_show, gtk_size_allocate, gtk_style_set, gtk_switch_page, gtk_test_collapse_row, gtk_test_expand_row, gtk_timer, gtk_toggled, gtk_unmap_event, gtk_unrealize, gtk_value_changed, gtk_visibility_notify_event, gtk_window_state_event, hooks, hoverProc, isDisposed, isListening, isValidSubclass, isValidThread, isValidWidget, menuPositionProc, mnemonicHit, mnemonicMatch, notifyListeners, pixbufCellDataProc, postEvent, postEvent, register, releaseHandle, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, setOrientation, shellMapProc, textCellDataProc, timerProc, topHandle, toString, translateTraversal, treeSelectionProc, windowProc, windowProc, windowProc, windowProc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

Menu parent

menu

Menu menu

accelerator

int accelerator
Constructor Detail

MenuItem

public MenuItem(Menu parent,
                int style)
Constructs a new instance of this class given its parent (which must be a Menu) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.

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.


MenuItem

public MenuItem(Menu parent,
                int style,
                int index)
Constructs a new instance of this class given its parent (which must be a Menu), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

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.

Method Detail

addAccelerator

void addAccelerator(long accelGroup)

addAccelerators

void addAccelerators(long accelGroup)

addArmListener

public void addArmListener(org.eclipse.swt.events.ArmListener listener)
Adds the listener to the collection of listeners who will be notified when the arm events are generated for the control, by sending it one of the messages defined in the ArmListener interface.


addHelpListener

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


addSelectionListener

public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected, by sending it one of the messages defined in the SelectionListener interface.

When widgetSelected is called, the stateMask field of the event object is valid. widgetDefaultSelected is not called.


checkStyle

static int checkStyle(int style)

createHandle

void createHandle(int index)
Overrides:
createHandle in class Widget

fixMenus

void fixMenus(Decorations newParent)

getAccelerator

public int getAccelerator()
Return the widget accelerator. An accelerator is the bit-wise OR of zero or more modifier masks and a key. Examples: SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2.


getAccelGroup

long getAccelGroup()

getEnabled

public boolean getEnabled()
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.


getMenu

public Menu getMenu()
Returns the receiver's cascade menu if it has one or null if it does not. Only CASCADE menu items can have a pull down menu. The sequence of key strokes, button presses and/or button releases that are used to request a pull down menu is platform specific.


getParent

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


getSelection

public boolean getSelection()
Returns true if the receiver is selected, and false otherwise.

When the receiver is of type CHECK or RADIO, it is selected when it is checked.


gtk_activate

long gtk_activate(long widget)
Overrides:
gtk_activate in class Widget

gtk_select

long gtk_select(long item)
Overrides:
gtk_select in class Widget

gtk_show_help

long gtk_show_help(long widget,
                   long helpType)
Overrides:
gtk_show_help in class Widget

hookEvents

void hookEvents()
Overrides:
hookEvents in class Widget

isEnabled

public boolean isEnabled()
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.


releaseChild

void releaseChild()
Overrides:
releaseChild in class Widget

releaseWidget

void releaseWidget()
Overrides:
releaseWidget in class Item

removeAccelerator

void removeAccelerator(long accelGroup)

removeAccelerators

void removeAccelerators(long accelGroup)

removeArmListener

public void removeArmListener(org.eclipse.swt.events.ArmListener listener)
Removes the listener from the collection of listeners who will be notified when the arm events are generated for the control.


removeHelpListener

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


removeSelectionListener

public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected.


selectRadio

void selectRadio()

setAccelerator

public void setAccelerator(int accelerator)
Sets the widget accelerator. An accelerator is the bit-wise OR of zero or more modifier masks and a key. Examples: SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2. SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2.


setEnabled

public void setEnabled(boolean 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.


setImage

public void setImage(org.eclipse.swt.graphics.Image image)
Sets the image the receiver will display to the argument.

Note: This feature is not available on all window systems (for example, Window NT), in which case, calling this method will silently do nothing.

Overrides:
setImage in class Item

setMenu

public void setMenu(Menu menu)
Sets the receiver's pull down menu to the argument. Only CASCADE menu items can have a pull down menu. The sequence of key strokes, button presses and/or button releases that are used to request a pull down menu is platform specific.


setRadioSelection

boolean setRadioSelection(boolean value)

setSelection

public void setSelection(boolean selected)
Sets the selection state of the receiver.

When the receiver is of type CHECK or RADIO, it is selected when it is checked.


setText

public void setText(java.lang.String string)
Sets the receiver's text. The string may include the mnemonic character and accelerator text.

Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, a selection event occurs. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

Accelerator text is indicated by the '\t' character. On platforms that support accelerator text, the text that follows the '\t' character is displayed to the user, typically indicating the key stroke that will cause the item to become selected. On most platforms, the accelerator text appears right aligned in the menu. Setting the accelerator text does not install the accelerator key sequence. The accelerator key sequence is installed using #setAccelerator.

Overrides:
setText in class Item

updateAccelerator

void updateAccelerator(long accelGroup,
                       boolean add)