Class ColorSelectionWidget

java.lang.Object
com.iizigo.swt.ColorSelectionWidget

public class ColorSelectionWidget extends Object
The color selection widget is a toolbar drop-down button that displays the color selection. If you press the drop-down button itself, the Color Dialog is shown to select the color.
Author:
Christopher Mindus
  • Constructor Summary

    Constructors
    Constructor
    Description
    ColorSelectionWidget(int color, boolean isTransparent, int backgroundColor, int transparentColor)
    Constructs the Color Selection Widget.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.swt.widgets.ToolItem
    createToolItem(org.eclipse.swt.widgets.ToolBar toolBar, int width, int height)
    Creates a toolbar item as widget.
    org.eclipse.swt.widgets.ToolBar
    createWidget(org.eclipse.swt.widgets.Composite parent, int width, int height)
    Creates a stand-alone widget for a dialog.
    Gets the attachment object.
    int
    Gets the selected color.
    void
    Hides the drop-down.
    void
    onNewColor(int color)
    A new color is set: set in preview.
    void
    Sets an attachment object.
    void
    setColor(int color)
    Sets a new color.
    void
    Sets the single selection listener.
    void
    setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.TableItem widget, int columnIndex, int width, int height, int margin)
    Assigns a widget to set the color into.
    void
    setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Widget widget, int width, int height, int margin)
    Assigns a widget to set the color into.
    void
    setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Widget widget, Runnable updater)
    Assigns a widget to set the color into with a callback to set the new color when changed.
    void
    Shows the drop-down with color selection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ColorSelectionWidget

      public ColorSelectionWidget(int color, boolean isTransparent, int backgroundColor, int transparentColor)
      Constructs the Color Selection Widget.
      Parameters:
      color - The color.
      isTransparent - Flag for transparency.
      backgroundColor - The background color, -1 for Widget color.
      transparentColor - The "transparency" color to use for GraphicsGC, -1 for none.
  • Method Details

    • setColor

      public void setColor(int color)
      Sets a new color.
    • setSelectionListener

      public void setSelectionListener(IColorSelectionWidget listener)
      Sets the single selection listener.
    • setAttachment

      public void setAttachment(Object o)
      Sets an attachment object.
    • getAttachment

      public Object getAttachment()
      Gets the attachment object.
    • createToolItem

      public org.eclipse.swt.widgets.ToolItem createToolItem(org.eclipse.swt.widgets.ToolBar toolBar, int width, int height)
      Creates a toolbar item as widget.
      Parameters:
      toolBar - The tool bar.
      width - The width of the preview image.
      height - The height of the preview image.
    • createWidget

      public org.eclipse.swt.widgets.ToolBar createWidget(org.eclipse.swt.widgets.Composite parent, int width, int height)
      Creates a stand-alone widget for a dialog. The widget is a tool bar containing a single drop-down tool item.
    • setWidget

      public void setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Widget widget, int width, int height, int margin)
      Assigns a widget to set the color into.
      Parameters:
      shell - The shell for the widget.
      widget - The widget, can be any widget supporting setImage().
      margin - The margin in the image, to force widget size larger, used e.g. for ToolItem's.
    • setWidget

      public void setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Widget widget, Runnable updater)
      Assigns a widget to set the color into with a callback to set the new color when changed.
      Parameters:
      shell - The shell for the widget.
      widget - The widget, can be any widget supporting setImage().
      updater - The updater.
    • setWidget

      public void setWidget(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.TableItem widget, int columnIndex, int width, int height, int margin)
      Assigns a widget to set the color into.
      Parameters:
      shell - The shell for the widget.
      widget - The TableItem widget with column image support.
      columnIndex - Column index, -1 to set the image for the TableItem directly.
      margin - The margin in the image, to force widget size larger, used e.g. for ToolItem's.
    • onNewColor

      public void onNewColor(int color)
      A new color is set: set in preview.
    • getColor

      public int getColor()
      Gets the selected color.
    • hideDropDown

      public void hideDropDown()
      Hides the drop-down.
    • showDropDown

      public void showDropDown()
      Shows the drop-down with color selection.