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 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 ToolItem createToolItem(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 ToolBar createWidget(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(Shell shell, 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(Shell shell, 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(Shell shell, 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.