Class ColorSelectionWidget


  • public class ColorSelectionWidget
    extends java.lang.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 
      ConstructorDescription
      ColorSelectionWidget​(int color, boolean isTransparent, int backgroundColor, int transparentColor)
      Constructs the Color Selection Widget.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      org.eclipse.swt.widgets.ToolItemcreateToolItem​(org.eclipse.swt.widgets.ToolBar toolBar, int width, int height)
      Creates a toolbar item as widget.
      org.eclipse.swt.widgets.ToolBarcreateWidget​(org.eclipse.swt.widgets.Composite parent, int width, int height)
      Creates a stand-alone widget for a dialog.
      java.lang.ObjectgetAttachment()
      Gets the attachment object.
      intgetColor()
      Gets the selected color.
      voidhideDropDown()
      Hides the drop-down.
      voidonNewColor​(int color)
      A new color is set: set in preview.
      voidsetAttachment​(java.lang.Object o)
      Sets an attachment object.
      voidsetColor​(int color)
      Sets a new color.
      voidsetSelectionListener​(IColorSelectionWidget listener)
      Sets the single selection listener.
      voidsetWidget​(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.
      voidsetWidget​(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.
      voidsetWidget​(org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.widgets.Widget widget, java.lang.Runnable updater)
      Assigns a widget to set the color into with a callback to set the new color when changed.
      voidshowDropDown()
      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 Detail

      • 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 Detail

      • 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​(java.lang.Object o)
        Sets an attachment object.
      • getAttachment

        public java.lang.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,
                              java.lang.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.