Package com.iizigo.swt
Class FlatToolbarButton
- 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
- org.eclipse.swt.custom.CLabel
- com.iizigo.swt.FlatToolbarButton
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class FlatToolbarButton extends org.eclipse.swt.custom.CLabel
A button that behaves like a flat button should do, i.e. also works under e.g. Windows 7, where the SWT.FLAT look doesn't work for SWT.PUSH. The button only has an image, no text.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, java.lang.String workBenchImage, IFlatToolbarButton listener)
Creates the toolbar button.FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, IFlatToolbarButton listener)
Creates the toolbar button.FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Image imageDisabled, IFlatToolbarButton listener)
Creates the toolbar button.FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Image imageHover, org.eclipse.swt.graphics.Image imageDisabled, IFlatToolbarButton listener)
Creates the toolbar button.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
Computes the size.boolean
getSelection()
Gets the current selection state when button is a toggle button.void
setDisabledImage(org.eclipse.swt.graphics.Image image)
The disabled image.void
setDoubleClickListener(java.lang.Runnable r)
Sets the double-click listener.void
setEnabled(boolean on)
Overrides the enabled method.void
setHoverImage(org.eclipse.swt.graphics.Image image)
The hover image.void
setImage(org.eclipse.swt.graphics.Image image)
Overrides setImage.void
setListener(IFlatToolbarButton listener)
Sets the listener.void
setSelection(boolean on)
Sets the selection state in case the button is used as a toggle button.Methods inherited from class org.eclipse.swt.custom.CLabel
getAlignment, getBottomMargin, getImage, getLeftMargin, getRightMargin, getStyle, getText, getToolTipText, getTopMargin, setAlignment, setBackground, setBackground, setBackground, setBackground, setBottomMargin, setFont, setLeftMargin, setMargins, setRightMargin, setText, setToolTipText, setTopMargin, shortenText
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setIME
Methods 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
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods 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, 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, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
Constructor Detail
FlatToolbarButton
public FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, java.lang.String workBenchImage, IFlatToolbarButton listener)
Creates the toolbar button.- Parameters:
parent
- The parent composite.workBenchImage
- The workbench image (dual), from org.eclipse.ui.ISharedImages.IMG_* (e.g. ISharedImages.IMG_TOOL_CUT).listener
- The button listener, can be null.- Throws:
java.lang.NullPointerException
- If image is null.
FlatToolbarButton
public FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, IFlatToolbarButton listener)
Creates the toolbar button.- Parameters:
parent
- The parent composite.image
- The normal image, cannot be null, also used as hover image.listener
- The button listener, can be null.- Throws:
java.lang.NullPointerException
- If image is null.
FlatToolbarButton
public FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Image imageDisabled, IFlatToolbarButton listener)
Creates the toolbar button.- Parameters:
parent
- The parent composite.image
- The normal image, cannot be null, also used as hover image.imageDisabled
- The disabled image, if null, a grayed normal image is used.listener
- The button listener, can be null.- Throws:
java.lang.NullPointerException
- If image is null.
FlatToolbarButton
public FlatToolbarButton(org.eclipse.swt.widgets.Composite parent, org.eclipse.swt.graphics.Image image, org.eclipse.swt.graphics.Image imageHover, org.eclipse.swt.graphics.Image imageDisabled, IFlatToolbarButton listener)
Creates the toolbar button.- Parameters:
parent
- The parent composite.image
- The normal image, cannot be null.imageHover
- The hover image, if null, the normal image is used.imageDisabled
- The disabled image, if null, a grayed normal image is used.listener
- The button listener, can be null.- Throws:
java.lang.NullPointerException
- If image is null.
Method Detail
setSelection
public void setSelection(boolean on)
Sets the selection state in case the button is used as a toggle button.
getSelection
public boolean getSelection()
Gets the current selection state when button is a toggle button.
setDoubleClickListener
public void setDoubleClickListener(java.lang.Runnable r)
Sets the double-click listener.
setListener
public void setListener(IFlatToolbarButton listener)
Sets the listener.
setEnabled
public void setEnabled(boolean on)
Overrides the enabled method.- Overrides:
setEnabled
in classorg.eclipse.swt.widgets.Control
setImage
public void setImage(org.eclipse.swt.graphics.Image image)
Overrides setImage.- Overrides:
setImage
in classorg.eclipse.swt.custom.CLabel
setDisabledImage
public void setDisabledImage(org.eclipse.swt.graphics.Image image)
The disabled image.
setHoverImage
public void setHoverImage(org.eclipse.swt.graphics.Image image)
The hover image.
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
Computes the size. The size is 23x20.- Overrides:
computeSize
in classorg.eclipse.swt.custom.CLabel