Class ImageHyperlink

All Implemented Interfaces:
Drawable

public class ImageHyperlink extends Hyperlink
This class extends hyperlink widget by adding the capability to render an image relative to the text. If no text has been set, only image will be shown. Images for hover and active states can be set in addition to the normal state image.

When image is taller than the text, additional style can be provided to control vertical alignment (supported values are SWT.TOP, SWT.BOTTOM and SWT.CENTER).

The class does not need to be subclassed but it is allowed to do so if some aspect of the image hyperlink needs to be modified.

Styles:
SWT.WRAP, SWT.BOTTOM, SWT.TOP, SWT.MIDDLE, SWT.LEFT, SWT.RIGHT
Since:
3.0
  • Field Details

    • textSpacing

      public int textSpacing
      Amount of pixels between the image and the text (default is 5).
  • Constructor Details

    • ImageHyperlink

      public ImageHyperlink(Composite parent, int style)
      Creates the image hyperlink instance.
      Parameters:
      parent - the control parent
      style - the control style (SWT.WRAP, BOTTOM, TOP, MIDDLE, LEFT, RIGHT)
  • Method Details

    • paintHyperlink

      protected void paintHyperlink(GC gc)
      Description copied from class: Hyperlink
      Paints the hyperlink text.
      Overrides:
      paintHyperlink in class Hyperlink
      Parameters:
      gc - graphic context
    • paintHyperlink

      protected void paintHyperlink(GC gc, Rectangle bounds)
    • computeSize

      public Point computeSize(int wHint, int hHint, boolean changed)
      Computes the control size by reserving space for images in addition to text.
      Overrides:
      computeSize in class Hyperlink
      Parameters:
      wHint - width hint
      hHint - height hint
      changed - if true, any cached layout data should be computed anew
      Returns:
      the preferred size of the control.
      See Also:
    • handleEnter

      protected void handleEnter(Event e)
      Description copied from class: AbstractHyperlink
      Called when hyperlink is entered. Subclasses that override this method must call 'super'.
      Overrides:
      handleEnter in class AbstractHyperlink
    • handleExit

      protected void handleExit(Event e)
      Description copied from class: AbstractHyperlink
      Called when hyperlink is exited. Subclasses that override this method must call 'super'.
      Overrides:
      handleExit in class AbstractHyperlink
    • handleActivate

      protected void handleActivate(Event e)
      Description copied from class: AbstractHyperlink
      Called when hyperlink has been activated. Subclasses that override this method must call 'super'.
      Overrides:
      handleActivate in class AbstractHyperlink
    • getActiveImage

      public Image getActiveImage()
      Returns active image.
      Returns:
      active image or null if not set.
    • setActiveImage

      public void setActiveImage(Image activeImage)
      Sets the image to show when link is activated.
      Parameters:
      activeImage - image to set
    • getHoverImage

      public Image getHoverImage()
      Returns the hover image.
      Returns:
      hover image or null if not set.
    • setHoverImage

      public void setHoverImage(Image hoverImage)
      Sets the image to show when link is hover state (on mouse over).
      Parameters:
      hoverImage - image to set
    • getImage

      public Image getImage()
      Returns the image to show in the normal state.
      Returns:
      normal image or null if not set.
    • setImage

      public void setImage(Image image)
      Sets the image to show when link is in the normal state.
      Parameters:
      image - image to set
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from class: Control
      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.
      Overrides:
      setEnabled in class AbstractHyperlink
      Parameters:
      enabled - the new enabled state