i3mclient.i3m
Class CoolButton

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
                          |
                          +--org.eclipse.swt.widgets.Canvas
                                |
                                +--i3mclient.i3m.CoolButton
All Implemented Interfaces:
DisposeListener, Drawable, EventListener, MenuListener, MouseListener, MouseTrackListener, PaintListener, SelectionListener, org.eclipse.swt.internal.SWTEventListener

public class CoolButton
extends Canvas
implements PaintListener, MouseListener, MouseTrackListener, SelectionListener, MenuListener, DisposeListener

Own widget to have a button with image and text.

Author:
Dirk Plate

Field Summary
static int FLAT
          Identifies that the button is in flat state
static int NORMAL
          Identifies that the button is in normal state
static int PRESSED
          Identifies that the button is pressed
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CoolButton(Composite composite, int style)
          Constructor.
 
Method Summary
 void addMenuItem(String itemText, Image itemImage, Object name)
          Add a item to the popup-menu.
 void addSelectionListener(SelectionListener listener)
          Add a selection listener.
 Point computeMinSize()
          Return the minimal size of the button.
 Point computeSize(int wHint, int hHint, boolean changed)
          Return the size of the button.
 Image getImage()
           
 MenuItem getMenuItem(int index)
           
 String getText()
           
 void menuHidden(MenuEvent event)
           
 void menuShown(MenuEvent arg0)
           
 void mouseDoubleClick(MouseEvent arg0)
           
 void mouseDown(MouseEvent arg0)
           
 void mouseEnter(MouseEvent event)
           
 void mouseExit(MouseEvent event)
           
 void mouseHover(MouseEvent arg0)
           
 void mouseUp(MouseEvent arg0)
           
 void paintControl(PaintEvent event)
           
 void removeSelectionListener(SelectionListener listener)
          Remove a selection listener.
 void setImage(Image imageSet)
           
 void setText(String textSet)
           
 void widgetDefaultSelected(SelectionEvent arg0)
           
 void widgetDisposed(DisposeEvent arg0)
           
 void widgetSelected(SelectionEvent event)
           
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
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, getDisplay, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, 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, dispose, getData, getData, getStyle, notifyListeners, removeDisposeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static int NORMAL
Identifies that the button is in normal state


PRESSED

public static int PRESSED
Identifies that the button is pressed


FLAT

public static int FLAT
Identifies that the button is in flat state

Constructor Detail

CoolButton

public CoolButton(Composite composite,
                  int style)
Constructor.

Parameters:
composite - In this composite the button will be inserted
style - The SWT-style of the canvas (SWT.NONE is preferred)
Method Detail

paintControl

public void paintControl(PaintEvent event)
Specified by:
paintControl in interface PaintListener

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Return the size of the button.

Overrides:
computeSize in class Composite
Parameters:
wHint - the minimal width of button
hHint - the minimal height of button
changed - changed or not
Returns:
The size of the button

computeMinSize

public Point computeMinSize()
Return the minimal size of the button.

Returns:
The minimal size of the button

mouseDoubleClick

public void mouseDoubleClick(MouseEvent arg0)
Specified by:
mouseDoubleClick in interface MouseListener

mouseDown

public void mouseDown(MouseEvent arg0)
Specified by:
mouseDown in interface MouseListener

mouseUp

public void mouseUp(MouseEvent arg0)
Specified by:
mouseUp in interface MouseListener

mouseEnter

public void mouseEnter(MouseEvent event)
Specified by:
mouseEnter in interface MouseTrackListener

mouseExit

public void mouseExit(MouseEvent event)
Specified by:
mouseExit in interface MouseTrackListener

mouseHover

public void mouseHover(MouseEvent arg0)
Specified by:
mouseHover in interface MouseTrackListener

getImage

public Image getImage()
Returns:
The image on the button

getText

public String getText()
Returns:
The text on the button

setImage

public void setImage(Image imageSet)
Parameters:
imageSet - The image on the button

setText

public void setText(String textSet)
Parameters:
textSet - The text on the button

addMenuItem

public void addMenuItem(String itemText,
                        Image itemImage,
                        Object name)
Add a item to the popup-menu.

Parameters:
itemText - The text of the item
itemImage - The image left of the text
name - The name of the menu item

getMenuItem

public MenuItem getMenuItem(int index)
Parameters:
index - The index of the requested item
Returns:
The requested menu item

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Add a selection listener.

Parameters:
listener - The listener which should be added to the intern list

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Remove a selection listener.

Parameters:
listener - The listener which should be removed from the intern list

widgetSelected

public void widgetSelected(SelectionEvent event)
Specified by:
widgetSelected in interface SelectionListener

widgetDefaultSelected

public void widgetDefaultSelected(SelectionEvent arg0)
Specified by:
widgetDefaultSelected in interface SelectionListener

menuHidden

public void menuHidden(MenuEvent event)
Specified by:
menuHidden in interface MenuListener

menuShown

public void menuShown(MenuEvent arg0)
Specified by:
menuShown in interface MenuListener

widgetDisposed

public void widgetDisposed(DisposeEvent arg0)
Specified by:
widgetDisposed in interface DisposeListener