com.tensegrity.gui.swt.control.widgets
Class ImageWidget

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 bycom.tensegrity.gui.swt.control.widgets.ImageWidget
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, java.util.EventListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.internal.SWTEventListener

public class ImageWidget
extends org.eclipse.swt.widgets.Canvas
implements org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.MouseListener

This Canvas can be used in order to display icons or labels. Its advantage is that a border is drawn when the mouse cursor is over the image. It is for instance used to display icons in the repository panel as well as in the layout tools panel.

Note that the default background colors are SWT.COLOR_GRAY when the widget is pressed, SWT.COLOR_WHITE otherwise. It is possible to modify the background colors by means of the setPressedColor(Color) and setNotPressedColor(Color) methods.

One should call the dispose() method in order to free the operating system resources associated with the ImageWidget instance when it is no longer necessary.

Version:
$Id: ImageWidget.java,v 1.10 2005/06/09 09:47:27 SebastienGuyon Exp $
Author:
S�bastien Guyon

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
ImageWidget(org.eclipse.swt.widgets.Composite parent, int style, SwtIcon icon)
           Initializes this Canvas.
ImageWidget(org.eclipse.swt.widgets.Composite parent, SwtIcon icon)
          Initializes this Canvas with a style SWT.NONE.
 
Method Summary
 void dispose()
           
 void draw(org.eclipse.swt.graphics.GC gc)
           This method is used in order to draw the internal VisualGraphObjectSwtIcon representing this ImageWidget.
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
           
 void mouseDown(org.eclipse.swt.events.MouseEvent e)
           
 void mouseEnter(org.eclipse.swt.events.MouseEvent e)
           
 void mouseExit(org.eclipse.swt.events.MouseEvent e)
           
 void mouseHover(org.eclipse.swt.events.MouseEvent e)
           
 void mouseUp(org.eclipse.swt.events.MouseEvent e)
           
 void setImage(SwtIcon icon)
           Sets the image to display on this ImageWidget/code>.
 void setNotPressedColor(org.eclipse.swt.graphics.Color notPressed)
           Set the Color which will be used as background color when the widget is not pressed.
 void setPressedColor(org.eclipse.swt.graphics.Color pressed)
           Sets the Color which will be used as background color when the widget is pressed.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, 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, 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
 

Constructor Detail

ImageWidget

public ImageWidget(org.eclipse.swt.widgets.Composite parent,
                   SwtIcon icon)

Initializes this Canvas with a style SWT.NONE.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
icon - the SwtIcon to display within this Canvas

ImageWidget

public ImageWidget(org.eclipse.swt.widgets.Composite parent,
                   int style,
                   SwtIcon icon)

Initializes this Canvas.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
icon - the SwtIcon to display within this Canvas
Method Detail

mouseEnter

public void mouseEnter(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseEnter in interface org.eclipse.swt.events.MouseTrackListener

mouseExit

public void mouseExit(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseExit in interface org.eclipse.swt.events.MouseTrackListener

mouseHover

public void mouseHover(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseHover in interface org.eclipse.swt.events.MouseTrackListener

draw

public void draw(org.eclipse.swt.graphics.GC gc)

This method is used in order to draw the internal VisualGraphObjectSwtIcon representing this ImageWidget. The background color and the border vary depending on the mouse position and state.

Parameters:
gc - the graphics context used for the drawing

dispose

public void dispose()

setImage

public void setImage(SwtIcon icon)

Sets the image to display on this ImageWidget/code>.

Parameters:
icon - the image to display within this ImageWidget

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

setNotPressedColor

public void setNotPressedColor(org.eclipse.swt.graphics.Color notPressed)

Set the Color which will be used as background color when the widget is not pressed.

Parameters:
notPressed - the Color which will be used as background color when the widget is not pressed

setPressedColor

public void setPressedColor(org.eclipse.swt.graphics.Color pressed)

Sets the Color which will be used as background color when the widget is pressed.

Parameters:
pressed - the Color which will be used as background color when the widget is pressed


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.