Class FlatToolbarButton

All Implemented Interfaces:
Drawable

public class FlatToolbarButton extends IZ_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 Details

    • FlatToolbarButton

      public FlatToolbarButton(Composite parent, 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:
      NullPointerException - If image is null.
    • FlatToolbarButton

      public FlatToolbarButton(Composite parent, 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:
      NullPointerException - If image is null.
    • FlatToolbarButton

      public FlatToolbarButton(Composite parent, Image image, 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:
      NullPointerException - If image is null.
    • FlatToolbarButton

      public FlatToolbarButton(Composite parent, Image image, Image imageHover, 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:
      NullPointerException - If image is null.
  • Method Details

    • 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(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 class Control
    • setImage

      public void setImage(Image image)
      Overrides setImage.
      Overrides:
      setImage in class CLabel
    • setDisabledImage

      public void setDisabledImage(Image image)
      The disabled image.
    • setHoverImage

      public void setHoverImage(Image image)
      The hover image.
    • computeSize

      public Point computeSize(int wHint, int hHint, boolean changed)
      Computes the size. The size is 23x20.
      Overrides:
      computeSize in class CLabel