Class RoundedToolItem

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Item
org.eclipse.nebula.widgets.opal.roundedtoolbar.RoundedToolItem

public class RoundedToolItem
extends org.eclipse.swt.widgets.Item
Instances of this class represent a selectable user interface object that represents a button in a rounded tool bar.
Styles:
CHECK, PUSH, RADIO, TOGGLE
Events:
Selection

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

See Also:
ToolBar, ToolItem snippets
  • Constructor Summary

    Constructors 
    Constructor Description
    RoundedToolItem​(RoundedToolbar parent)
    Constructs a new instance of this class given its parent (which must be a ToolBar) and a style value describing its behavior and appearance.
    RoundedToolItem​(RoundedToolbar parent, int style)
    Constructs a new instance of this class given its parent (which must be a ToolBar) and a style value describing its behavior and appearance.
  • Method Summary

    Modifier and Type Method Description
    void addListener​(int eventType, org.eclipse.swt.widgets.Listener listener)  
    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 the user, by sending it one of the messages defined in the SelectionListener interface.
    (package private) org.eclipse.swt.graphics.Point computeDefaultSize()  
    void dispose()  
    (package private) void drawButton​(org.eclipse.swt.graphics.GC gc, int x, int toolbarHeight, boolean isLast)  
    (package private) void fireSelectionEvent()  
    (package private) void forceSelection​(boolean newSelection)  
    int getAlignment()
    Returns a value which describes the position of the text in the receiver.
    org.eclipse.swt.graphics.Rectangle getBounds()
    Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell.
    org.eclipse.swt.graphics.Image getDisabledImage()  
    boolean getEnabled()
    Returns true if the receiver is enabled, and false otherwise.
    int getHeight()
    Returns the whole height of the widget.
    RoundedToolbar getParent()
    Returns the receiver's parent, which must be a RoundedToolBar.
    boolean getSelection()
    Returns true if the receiver is selected, and false otherwise.
    org.eclipse.swt.graphics.Image getSelectionImage()  
    org.eclipse.swt.graphics.Color getTextColor()
    Returns the color of the text when the button is enabled and not selected.
    org.eclipse.swt.graphics.Color getTextColorSelected()
    Returns the color of the text when the button is not selected.
    java.lang.String getTooltipText()
    Returns the receiver's tool tip text, or null if it has not been set.
    int getVerticalAlignment()
    Returns a value which describes the position of the text in the receiver.
    int getWidth()
    Returns the whole height of the widget.
    (package private) boolean isCheckbox()  
    (package private) boolean isDropDown()  
    boolean isEnabled()
    Returns true if the receiver is enabled, and false otherwise.
    (package private) boolean isPushButon()  
    (package private) boolean isRadio()  
    (package private) boolean isToogleButon()  
    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 by the user.
    void setAlignment​(int alignment)
    Controls how text will be displayed in the receiver.
    void setBounds​(org.eclipse.swt.graphics.Rectangle rectangle)
    Sets the receiver's size and location to the rectangular area specified by the argument.
    void setDisabledImage​(org.eclipse.swt.graphics.Image image)
    Sets the receiver's image to the argument when this is one is disabled, which may be null indicating that no image should be displayed.
    void setEnabled​(boolean enabled)
    Enables the receiver if the argument is true, and disables it otherwise.
    void setHeight​(int height)
    Sets the height of the receiver.
    void setSelection​(boolean selected)
    Sets the selection state of the receiver.
    void setSelectionImage​(org.eclipse.swt.graphics.Image image)
    Sets the receiver's image to the argument when this one is selected, which may be null indicating that no image should be displayed.
    void setTextColor​(org.eclipse.swt.graphics.Color textColor)
    Sets the receiver's text color to the argument, which may be null indicating that no image should be displayed.
    void setTextColorSelected​(org.eclipse.swt.graphics.Color textColor)
    Sets the receiver's text color to the argument when this one is selected, which may be null indicating that no image should be displayed.
    void setTooltipText​(java.lang.String string)
    Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.
    void setVerticalAlignment​(int verticalAlignment)
    Controls how text will be displayed in the receiver.
    void setWidth​(int width)
    Sets the width of the receiver.

    Methods inherited from class org.eclipse.swt.widgets.Item

    checkSubclass, getImage, getText, setImage, setText

    Methods inherited from class org.eclipse.swt.widgets.Widget

    addDisposeListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RoundedToolItem

      public RoundedToolItem​(RoundedToolbar parent)
      Constructs a new instance of this class given its parent (which must be a ToolBar) 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.

      Parameters:
      parent - a composite control which will be the parent of the new instance (cannot be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      org.eclipse.swt.SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
      See Also:
      Widget.getStyle()
    • RoundedToolItem

      public RoundedToolItem​(RoundedToolbar parent, int style)
      Constructs a new instance of this class given its parent (which must be a ToolBar) 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.

      Parameters:
      parent - a composite control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      org.eclipse.swt.SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
      See Also:
      Widget.getStyle()
  • Method Details

    • addListener

      public void addListener​(int eventType, org.eclipse.swt.widgets.Listener listener)
      Overrides:
      addListener in class org.eclipse.swt.widgets.Widget
      See Also:
      Widget.addListener(int, org.eclipse.swt.widgets.Listener)
    • 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 the user, by sending it one of the messages defined in the SelectionListener interface.

      widgetDefaultSelected is not called.

      Parameters:
      listener - the listener which should be notified when the control is selected by the user,
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
    • computeDefaultSize

      org.eclipse.swt.graphics.Point computeDefaultSize()
      Returns:
      the default size of the item
    • dispose

      public void dispose()
      Overrides:
      dispose in class org.eclipse.swt.widgets.Widget
      See Also:
      Widget.dispose()
    • drawButton

      void drawButton​(org.eclipse.swt.graphics.GC gc, int x, int toolbarHeight, boolean isLast)
    • fireSelectionEvent

      void fireSelectionEvent()
    • getAlignment

      public int getAlignment()
      Returns a value which describes the position of the text in the receiver. The value will be one of LEFT, RIGHT or CENTER.
      Returns:
      the alignment
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getBounds

      public org.eclipse.swt.graphics.Rectangle getBounds()
      Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null), unless the receiver is a shell. In this case, the location is relative to the display.
      Returns:
      the receiver's bounding rectangle
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getDisabledImage

      public org.eclipse.swt.graphics.Image getDisabledImage()
      Returns:
      the image displayed when the button is disabled
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • 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.
      Returns:
      the receiver's enabled state
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      isEnabled()
    • getHeight

      public int getHeight()
      Returns the whole height of the widget.
      Returns:
      the receiver's height
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getParent

      public RoundedToolbar getParent()
      Returns the receiver's parent, which must be a RoundedToolBar.
      Returns:
      the receiver's parent
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSelection

      public boolean getSelection()
      Returns true if the receiver is selected, and false otherwise.
      Returns:
      the selection state
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSelectionImage

      public org.eclipse.swt.graphics.Image getSelectionImage()
      Returns:
      the image displayed when the button is selected
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getTextColor

      public org.eclipse.swt.graphics.Color getTextColor()
      Returns the color of the text when the button is enabled and not selected.
      Returns:
      the receiver's text color
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getTextColorSelected

      public org.eclipse.swt.graphics.Color getTextColorSelected()
      Returns the color of the text when the button is not selected.
      Returns:
      the receiver's text color
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getTooltipText

      public java.lang.String getTooltipText()
      Returns the receiver's tool tip text, or null if it has not been set.
      Returns:
      the receiver's tool tip text
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getVerticalAlignment

      public int getVerticalAlignment()
      Returns a value which describes the position of the text in the receiver. The value will be one of TOP, BOTTOM or CENTER.
      Returns:
      the alignment
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getWidth

      public int getWidth()
      Returns the whole height of the widget.
      Returns:
      the receiver's height
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isEnabled

      public boolean isEnabled()
      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
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      getEnabled()
    • 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 by the user.
      Parameters:
      listener - the listener which should no longer be notified
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)
    • setAlignment

      public void setAlignment​(int alignment)
      Controls how text will be displayed in the receiver. The argument should be one of LEFT, RIGHT or CENTER.
      Parameters:
      alignment - the new alignment
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setBounds

      public void setBounds​(org.eclipse.swt.graphics.Rectangle rectangle)
      Sets the receiver's size and location to the rectangular area specified by the argument. The x and y fields of the rectangle are relative to the receiver's parent (or its display if its parent is null).

      Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.

      Parameters:
      rect - the new bounds for the receiver
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setDisabledImage

      public void setDisabledImage​(org.eclipse.swt.graphics.Image image)
      Sets the receiver's image to the argument when this is one is disabled, which may be null indicating that no image should be displayed.
      Parameters:
      image - the image to display on the receiver (may be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • 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.

      Parameters:
      enabled - the new enabled state
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setHeight

      public void setHeight​(int height)
      Sets the height of the receiver.

      Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.

      Parameters:
      height - the new width
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSelection

      public void setSelection​(boolean selected)
      Sets the selection state of the receiver.
      Parameters:
      selected - the new selection state
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSelectionImage

      public void setSelectionImage​(org.eclipse.swt.graphics.Image image)
      Sets the receiver's image to the argument when this one is selected, which may be null indicating that no image should be displayed.
      Parameters:
      image - the image to display on the receiver (may be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setTextColor

      public void setTextColor​(org.eclipse.swt.graphics.Color textColor)
      Sets the receiver's text color to the argument, which may be null indicating that no image should be displayed.
      Parameters:
      textColor - the text color to display on the receiver (may be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setTextColorSelected

      public void setTextColorSelected​(org.eclipse.swt.graphics.Color textColor)
      Sets the receiver's text color to the argument when this one is selected, which may be null indicating that no image should be displayed.
      Parameters:
      textColor - the text color to display on the receiver (may be null)
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setTooltipText

      public void setTooltipText​(java.lang.String string)
      Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.

      The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

      Parameters:
      string - the new tool tip text (or null)
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setVerticalAlignment

      public void setVerticalAlignment​(int verticalAlignment)
      Controls how text will be displayed in the receiver. The argument should be one of TOP, BOTTOM or CENTER.
      Parameters:
      alignment - the new alignment
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setWidth

      public void setWidth​(int width)
      Sets the width of the receiver.

      Note: Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.

      Parameters:
      width - the new width
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isToogleButon

      boolean isToogleButon()
    • isPushButon

      boolean isPushButon()
    • isCheckbox

      boolean isCheckbox()
    • isRadio

      boolean isRadio()
    • isDropDown

      boolean isDropDown()
    • forceSelection

      void forceSelection​(boolean newSelection)