Package org.eclipse.ui.forms.widgets
Class ImageHyperlink
- All Implemented Interfaces:
Drawable
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 Summary
FieldsModifier and TypeFieldDescriptionintAmount of pixels between the image and the text (default is 5).Fields inherited from class org.eclipse.ui.forms.widgets.AbstractHyperlink
marginHeight, marginWidthFields inherited from class org.eclipse.swt.widgets.Widget
nativeZoom -
Constructor Summary
ConstructorsConstructorDescriptionImageHyperlink(Composite parent, int style) Creates the image hyperlink instance. -
Method Summary
Modifier and TypeMethodDescriptioncomputeSize(int wHint, int hHint, boolean changed) Computes the control size by reserving space for images in addition to text.Returns active image.Returns the hover image.getImage()Returns the image to show in the normal state.protected voidCalled when hyperlink has been activated.protected voidhandleEnter(Event e) Called when hyperlink is entered.protected voidhandleExit(Event e) Called when hyperlink is exited.protected voidpaintHyperlink(GC gc) Paints the hyperlink text.protected voidpaintHyperlink(GC gc, Rectangle bounds) voidsetActiveImage(Image activeImage) Sets the image to show when link is activated.voidsetEnabled(boolean enabled) Enables the receiver if the argument istrue, and disables it otherwise.voidsetHoverImage(Image hoverImage) Sets the image to show when link is hover state (on mouse over).voidSets the image to show when link is in the normal state.Methods inherited from class org.eclipse.ui.forms.widgets.Hyperlink
computeTextSize, getText, getToolTipText, initAccessible, isUnderlined, paintText, setText, setToolTipText, setUnderlined, shortenTextMethods inherited from class org.eclipse.ui.forms.widgets.AbstractHyperlink
addHyperlinkListener, getHref, getSelection, paint, removeHyperlinkListener, setHrefMethods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsModeMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Field Details
-
textSpacing
public int textSpacingAmount of pixels between the image and the text (default is 5).
-
-
Constructor Details
-
ImageHyperlink
Creates the image hyperlink instance.- Parameters:
parent- the control parentstyle- the control style (SWT.WRAP, BOTTOM, TOP, MIDDLE, LEFT, RIGHT)
-
-
Method Details
-
paintHyperlink
Description copied from class:HyperlinkPaints the hyperlink text.- Overrides:
paintHyperlinkin classHyperlink- Parameters:
gc- graphic context
-
paintHyperlink
-
computeSize
Computes the control size by reserving space for images in addition to text.- Overrides:
computeSizein classHyperlink- Parameters:
wHint- width hinthHint- height hintchanged- iftrue, any cached layout data should be computed anew- Returns:
- the preferred size of the control.
- See Also:
-
handleEnter
Description copied from class:AbstractHyperlinkCalled when hyperlink is entered. Subclasses that override this method must call 'super'.- Overrides:
handleEnterin classAbstractHyperlink
-
handleExit
Description copied from class:AbstractHyperlinkCalled when hyperlink is exited. Subclasses that override this method must call 'super'.- Overrides:
handleExitin classAbstractHyperlink
-
handleActivate
Description copied from class:AbstractHyperlinkCalled when hyperlink has been activated. Subclasses that override this method must call 'super'.- Overrides:
handleActivatein classAbstractHyperlink
-
getActiveImage
Returns active image.- Returns:
- active image or
nullif not set.
-
setActiveImage
Sets the image to show when link is activated.- Parameters:
activeImage- image to set
-
getHoverImage
Returns the hover image.- Returns:
- hover image or
nullif not set.
-
setHoverImage
Sets the image to show when link is hover state (on mouse over).- Parameters:
hoverImage- image to set
-
getImage
Returns the image to show in the normal state.- Returns:
- normal image or
nullif not set.
-
setImage
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:ControlEnables the receiver if the argument istrue, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Overrides:
setEnabledin classAbstractHyperlink- Parameters:
enabled- the new enabled state
-