Eclipse Platform
Release 3.1

org.eclipse.ui.forms.widgets
Class ImageHyperlink

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.eclipse.swt.widgets.Canvas
                      extended byorg.eclipse.ui.forms.widgets.AbstractHyperlink
                          extended byorg.eclipse.ui.forms.widgets.Hyperlink
                              extended byorg.eclipse.ui.forms.widgets.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 sublassed but it is allowed to do so if some aspect of the image hyperlink needs to be modified.

Since:
3.0

Field Summary
 int textSpacing
          Amount of pixels between the image and the text (default is 5).
 
Fields inherited from class org.eclipse.ui.forms.widgets.AbstractHyperlink
marginHeight, marginWidth
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
ImageHyperlink(Composite parent, int style)
          Creates the image hyperlink instance.
 
Method Summary
 Point computeSize(int wHint, int hHint, boolean changed)
          Computes the control size by reserving space for images in addition to text.
 Image getActiveImage()
          Returns active image.
 Image getHoverImage()
          Returns the hover image.
 Image getImage()
          Returns the image to show in the normal state.
protected  void handleActivate(Event e)
          Called when hyperlink has been activated.
protected  void handleEnter(Event e)
          Called when hyperlink is entered.
protected  void handleExit(Event e)
          Called when hyperlink is exited.
protected  void paintHyperlink(GC gc)
          Paints the hyperlink text.
 void setActiveImage(Image activeImage)
          Sets the image to show when link is activated.
 void setHoverImage(Image hoverImage)
          Sets the image to show when link is hover state (on mouse over).
 void setImage(Image image)
          Sets the image to show when link is in the normal state.
 
Methods inherited from class org.eclipse.ui.forms.widgets.Hyperlink
computeTextSize, getText, initAccessible, isUnderlined, paintText, setText, setUnderlined
 
Methods inherited from class org.eclipse.ui.forms.widgets.AbstractHyperlink
addHyperlinkListener, getHref, getSelection, paint, removeHyperlinkListener, setHref
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

textSpacing

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

Constructor Detail

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 Detail

paintHyperlink

protected void paintHyperlink(GC gc)
Description copied from class: Hyperlink
Paints the hyperlink text.

Overrides:
paintHyperlink in class Hyperlink
Parameters:
gc - graphic context

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

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 -

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 -

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 -

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.