Class Gallery

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.nebula.widgets.gallery.Gallery
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class Gallery
extends org.eclipse.swt.widgets.Canvas

SWT Widget that displays an image gallery
see http://www.eclipse.org/nebula/widgets/gallery/gallery.php
This widget requires jdk-1.8+

Style VIRTUAL is used to create a Gallery whose GalleryItems are to be populated by the client on an on-demand basis instead of up-front. This can provide significant performance improvements for galleries that are very large or for which GalleryItem population is expensive (for example, retrieving values from an external source).

Here is an example of using a Gallery with style VIRTUAL:

 final Gallery gallery = new Gallery(parent, SWT.VIRTUAL | V_SCROLL | SWT.BORDER);
 gallery.setGroupRenderer(new DefaultGalleryGroupRenderer());
 gallery.setItemRenderer(new DefaultGalleryItemRenderer());
 gallery.setItemCount(1000000);
 gallery.addListener(SWT.SetData, new Listener() {
        public void handleEvent(Event event) {
                GalleryItem item = (GalleryItem) event.item;
                int index = gallery.indexOf(item);
                item.setText("Item " + index);
                System.out.println(item.getText());
        }
 });
 

Styles:
SINGLE, MULTI, VIRTUAL, V_SCROLL, H_SCROLL

Note: Only one of the styles SINGLE and MULTI may be specified.

Note: Only one of the styles V_SCROLL and H_SCROLL may be specified.

Events:
Selection, DefaultSelection, SetData, PaintItem

NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    (package private) int antialias
    Image quality : antialias
    protected static boolean DEBUG
    Used to enable debug logging in the Gallery widget.
    (package private) AbstractGalleryGroupRenderer groupRenderer  
    protected int higherQualityDelay  
    (package private) int interpolation
    Image quality : interpolation
    (package private) AbstractGalleryItemRenderer itemRenderer  
    (package private) GalleryItem[] items  
    protected int lastContentHeight  
    protected int lastContentWidth  
    protected int lastControlHeight  
    protected int lastControlWidth  
    (package private) int lastIndexOf  
    protected GalleryItem lastSingleClick
    Keeps track of the last selected item.
    protected int lastTranslateValue  
    (package private) boolean lowQualityOnUserAction
    Low quality on user action : decrease drawing quality on scrolling or resize.
    (package private) boolean multi
    Multi-selection flag
    (package private) java.lang.Runnable redrawTimer  
    protected int[] selectionFlags
    Selection bit flags.
    protected int translate
    Current translation (scroll bar position).
    (package private) boolean vertical
    Scrolling direction flag.
    (package private) boolean virtual
    Virtual mode flag.
    (package private) int virtualGroupDefaultItemCount  
    (package private) boolean virtualGroups
    Ultra virtual : non visible groups are not initialized.
    (package private) boolean virtualGroupsCompatibilityMode  

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    Gallery​(org.eclipse.swt.widgets.Composite parent, int style)
    Create a Gallery
  • Method Summary

    Modifier and Type Method Description
    protected void _addSelection​(GalleryItem item)  
    protected java.lang.Object[] _arrayAddItem​(java.lang.Object[] array, java.lang.Object object, int index)
    Adds an item to an array.
    protected int _arrayIndexOf​(int[] array, int value)  
    protected int _arrayIndexOf​(java.lang.Object[] array, java.lang.Object value)  
    protected int[] _arrayRemoveItem​(int[] array, int index)  
    protected java.lang.Object[] _arrayRemoveItem​(java.lang.Object[] array, int index)  
    protected void _deselectAll​(boolean notifyListeners)
    Deselects all items and send selection event depending on parameter.
    protected GalleryItem _getItem​(int index)
    Get the item at index.
    If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData is fired.
    This is the internal implementation of this method : checkWidget() is not used.
    protected GalleryItem _getItem​(int index, boolean create)
    Get the item at 'index'.
    If SWT.VIRTUAL is used, 'create' is true and the item has not been used yet, the item is created and a SWT.SetData is fired.
    protected GalleryItem _getItem​(GalleryItem parent, int index)
    This method is used by items to implement getItem( index )
    protected int _indexOf​(GalleryItem item)
    Returns the index of a GalleryItem when it is a root Item
    protected int _indexOf​(GalleryItem parentItem, GalleryItem item)
    Returns the index of a GalleryItem when it is not a root Item
    protected boolean _mouseDown​(org.eclipse.swt.widgets.Event event)
    Forward the mouseDown event to the corresponding group according to the mouse position.
    protected void _remove​(int index)  
    protected void _remove​(GalleryItem parent, int index)  
    protected void _removeSelection​(GalleryItem parent, GalleryItem item)  
    protected void _selectAll()  
    void _setGalleryItems​(GalleryItem[] items)  
    (package private) void _showItem​(GalleryItem item)  
    protected void addItem​(GalleryItem item, int position)  
    void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
    Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.
    void addTreeListener​(org.eclipse.swt.events.TreeListener listener)
    Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.
    void clear​(int index)
    Clear one item.
    void clear​(int index, boolean all)
    Clear one item and all its children if 'all' is true
    void clearAll()
    Clear all GalleryGroups
    void clearAll​(boolean all)
    Clear all Gallery items.
    If the Gallery is virtual, the item count is not reseted and all items will be created again at their first use.
    void deselectAll()
    Deselects all items.
    int getAntialias()  
    org.eclipse.swt.graphics.Color getBackground()  
    org.eclipse.swt.graphics.Color getBackground​(boolean galleryOnly)
    Returns the receiver's background color.
    org.eclipse.swt.graphics.Color getForeground()  
    org.eclipse.swt.graphics.Color getForeground​(boolean galleryOnly)
    Returns the receiver's foreground color.
    GalleryItem getGroup​(org.eclipse.swt.graphics.Point coords)
    Get group at pixel position (relative to client area).
    AbstractGalleryGroupRenderer getGroupRenderer()  
    int getHigherQualityDelay()  
    int getInterpolation()  
    GalleryItem getItem​(int index)
    Get the item at index.
    If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData event is fired.
    GalleryItem getItem​(org.eclipse.swt.graphics.Point coords)
    Get item at pixel position
    int getItemCount()
    Return the number of root-level items in the receiver.
    AbstractGalleryItemRenderer getItemRenderer()
    Get current item renderer
    GalleryItem[] getItems()  
    GalleryItem[] getSelection()  
    int getSelectionCount()  
    int getVirtualGroupDefaultItemCount()  
    int indexOf​(GalleryItem item)
    Returns the index of a GalleryItem.
    boolean isLowQualityOnUserAction()
    protected boolean isSelected​(GalleryItem item)  
    boolean isUseControlColors()  
    boolean isVertical()
    Checks if the Gallery was created with SWT.V_SCROLL (ie has a vertical scroll bar).
    boolean isVirtualGroups()  
    boolean isVirtualGroupsCompatibilityMode()  
    protected void notifySelectionListeners​(GalleryItem item, int index, boolean isDefault)
    Send a selection event for a gallery item
    protected void notifyTreeListeners​(GalleryItem item, boolean state)
    Send an Expand event for a GalleryItem
    (package private) void onDispose()
    Clean up the Gallery and renderers on dispose.
    (package private) void onMouseDoubleClick​(org.eclipse.swt.widgets.Event e)  
    (package private) void onMouseDown​(org.eclipse.swt.widgets.Event e)  
    (package private) void onMouseHandleLeft​(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)  
    (package private) void onMouseHandleRight​(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)
    Handle right click.
    (package private) void onMouseUp​(org.eclipse.swt.widgets.Event e)  
    (package private) void onPaint​(org.eclipse.swt.graphics.GC gc)  
    void redraw​(GalleryItem item)
    Redraw the item given as parameter.
    void refresh​(int index)
    Refresh item by firering SWT.SetData.
    void remove​(int index)  
    void remove​(GalleryItem item)  
    void removeAll()  
    void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
    Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
    void removeTreeListener​(org.eclipse.swt.events.SelectionListener listener)
    Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.
    protected void scrollHorizontal()  
    protected void scrollVertical()  
    void selectAll()
    Selects all of the items in the receiver.
    protected void sendPaintItemEvent​(org.eclipse.swt.widgets.Item item, int index, org.eclipse.swt.graphics.GC gc, int x, int y, int width, int height)
    Send SWT.PaintItem for one item.
    void setAntialias​(int antialias)
    Sets the gallery's anti-aliasing value to the parameter, which must be one of SWT.DEFAULT, SWT.OFF or SWT.ON.
    void setBackground​(org.eclipse.swt.graphics.Color color)  
    protected void setData​(GalleryItem galleryItem, int index)
    Sends SWT.SetData event.
    void setForeground​(org.eclipse.swt.graphics.Color color)  
    void setGroupRenderer​(AbstractGalleryGroupRenderer groupRenderer)  
    void setHigherQualityDelay​(int higherQualityDelay)
    Set the delay after the last user action before the redraw at higher quality is triggered
    void setInterpolation​(int interpolation)
    Sets the gallery's interpolation setting to the parameter, which must be one of SWT.DEFAULT, SWT.NONE, SWT.LOW or SWT.HIGH.
    void setItemCount​(int count)
    Sets the number of root-level items contained in the receiver.
    void setItemRenderer​(AbstractGalleryItemRenderer itemRenderer)
    Set item receiver.
    void setLowQualityOnUserAction​(boolean lowQualityOnUserAction)
    If set to true, the gallery will disable antialiasing and interpolation while the user is resizing or scrolling the gallery.
    protected void setSelected​(GalleryItem item, boolean selected, boolean notifyListeners)
    Toggle item selection status
    void setSelection​(GalleryItem[] items)  
    void setUseControlColors​(boolean useControlColors)
    Set useControlColors to true in order to get colors from parent Control (SWT default).
    void setVertical​(boolean vertical)
    Deprecated. 
    void setVirtualGroupDefaultItemCount​(int defaultItemCount)
    Set the item count used when a group is not yet initialized (with virtual groups).
    void setVirtualGroups​(boolean virtualGroups)
    Enable virtual groups
    void setVirtualGroupsCompatibilityMode​(boolean compatibilityMode)
    Enable the compatibility workaround for problems with the ultra virtual mode.
    void showItem​(GalleryItem item)
    Scroll the Gallery in order to make 'item' visible.
    protected void updateScrollBarsProperties()
    Move the scrollbar to reflect the current visible items position.
    protected void updateStructuralValues​(boolean keepLocation)
    protected void updateStructuralValues​(GalleryItem changedGroup, boolean keepLocation)
    Recalculate structural values using the group renderer
    Gallery and item size will be updated.

    Methods inherited from class org.eclipse.swt.widgets.Canvas

    drawBackground, getCaret, getIME, scroll, setCaret, setFont, 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, toString

    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, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, 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, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, 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, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Field Details

  • Constructor Details

    • Gallery

      public Gallery​(org.eclipse.swt.widgets.Composite parent, int style)
      Create a Gallery
      Parameters:
      parent -
      style - - SWT.VIRTUAL switches in virtual mode.
      SWT.V_SCROLL add vertical slider and switches to vertical mode.
      SWT.H_SCROLL add horizontal slider and switches to horizontal mode.
      if both V_SCROLL and H_SCROLL are specified, the gallery is in vertical mode by default. Mode can be changed afterward using setVertical
      SWT.MULTI allows only several items to be selected at the same time.
  • Method Details

    • getItemCount

      public int getItemCount()
      Return the number of root-level items in the receiver. Does not include children.
      Returns:
    • setItemCount

      public void setItemCount​(int count)
      Sets the number of root-level items contained in the receiver. Only work in VIRTUAL mode.
    • getItemRenderer

      public AbstractGalleryItemRenderer getItemRenderer()
      Get current item renderer
      Returns:
    • setItemRenderer

      public void setItemRenderer​(AbstractGalleryItemRenderer itemRenderer)
      Set item receiver. Usually, this does not trigger gallery update. redraw must be called right after setGroupRenderer to reflect this change.
      Parameters:
      itemRenderer -
    • addSelectionListener

      public void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.

      When widgetSelected is called, the item field of the event object is valid.

      Parameters:
      listener - the listener which should be notified
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
    • removeSelectionListener

      public void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
      Parameters:
      listener - the listener which should no longer be notified
      Throws:
      java.lang.IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the listener is null
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
      SelectionListener, addSelectionListener(SelectionListener)
    • removeTreeListener

      public void removeTreeListener​(org.eclipse.swt.events.SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when items in the receiver are expanded or collapsed.
      Parameters:
      listener -
    • addTreeListener

      public void addTreeListener​(org.eclipse.swt.events.TreeListener listener)
      Adds the listener to the collection of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface.
      Parameters:
      listener -
    • sendPaintItemEvent

      protected void sendPaintItemEvent​(org.eclipse.swt.widgets.Item item, int index, org.eclipse.swt.graphics.GC gc, int x, int y, int width, int height)
      Send SWT.PaintItem for one item.
      Parameters:
      item -
      index -
      gc -
      x -
      y -
    • isLowQualityOnUserAction

      public boolean isLowQualityOnUserAction()
      Returns:
    • setLowQualityOnUserAction

      public void setLowQualityOnUserAction​(boolean lowQualityOnUserAction)
      If set to true, the gallery will disable antialiasing and interpolation while the user is resizing or scrolling the gallery. This enables faster redraws at the cost of lower image quality. When every redraw is finished a last one will be issued using the default (higher) quality.
      Parameters:
      lowQualityOnUserAction -
      See Also:
      setHigherQualityDelay(int)
    • getHigherQualityDelay

      public int getHigherQualityDelay()
      Returns:
      See Also:
      setHigherQualityDelay(int)
    • setHigherQualityDelay

      public void setHigherQualityDelay​(int higherQualityDelay)
      Set the delay after the last user action before the redraw at higher quality is triggered
      Parameters:
      higherQualityDelay -
      See Also:
      setLowQualityOnUserAction(boolean)
    • getInterpolation

      public int getInterpolation()
      Returns:
      See Also:
      setInterpolation(int)
    • setInterpolation

      public void setInterpolation​(int interpolation)
      Sets the gallery's interpolation setting to the parameter, which must be one of SWT.DEFAULT, SWT.NONE, SWT.LOW or SWT.HIGH.
      Parameters:
      interpolation -
    • getAntialias

      public int getAntialias()
      Returns:
      See Also:
      setAntialias(int)
    • setAntialias

      public void setAntialias​(int antialias)
      Sets the gallery's anti-aliasing value to the parameter, which must be one of SWT.DEFAULT, SWT.OFF or SWT.ON.
      Parameters:
      antialias -
    • notifySelectionListeners

      protected void notifySelectionListeners​(GalleryItem item, int index, boolean isDefault)
      Send a selection event for a gallery item
      Parameters:
      item -
    • notifyTreeListeners

      protected void notifyTreeListeners​(GalleryItem item, boolean state)
      Send an Expand event for a GalleryItem
      Parameters:
      item -
      index -
    • showItem

      public void showItem​(GalleryItem item)
      Scroll the Gallery in order to make 'item' visible.
      Parameters:
      item - Item to show
    • _showItem

      void _showItem​(GalleryItem item)
    • setSelected

      protected void setSelected​(GalleryItem item, boolean selected, boolean notifyListeners)
      Toggle item selection status
      Parameters:
      item - Item which state is to be changed.
      selected - true is the item is now selected, false if it is now unselected.
      notifyListeners - If true, a selection event will be sent to all the current selection listeners.
    • _addSelection

      protected void _addSelection​(GalleryItem item)
    • _removeSelection

      protected void _removeSelection​(GalleryItem parent, GalleryItem item)
    • isSelected

      protected boolean isSelected​(GalleryItem item)
    • deselectAll

      public void deselectAll()
      Deselects all items.
    • _deselectAll

      protected void _deselectAll​(boolean notifyListeners)
      Deselects all items and send selection event depending on parameter.
      Parameters:
      notifyListeners - If true, a selection event will be sent to all the current selection listeners.
    • onMouseDoubleClick

      void onMouseDoubleClick​(org.eclipse.swt.widgets.Event e)
    • onMouseUp

      void onMouseUp​(org.eclipse.swt.widgets.Event e)
    • onDispose

      void onDispose()
      Clean up the Gallery and renderers on dispose.
    • onMouseDown

      void onMouseDown​(org.eclipse.swt.widgets.Event e)
    • onMouseHandleLeft

      void onMouseHandleLeft​(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)
    • onMouseHandleRight

      void onMouseHandleRight​(org.eclipse.swt.widgets.Event e, GalleryItem item, boolean down, boolean up)
      Handle right click.
      Parameters:
      e -
      item - : The item which is under the cursor or null
      down -
      up -
    • onPaint

      void onPaint​(org.eclipse.swt.graphics.GC gc)
    • refresh

      public void refresh​(int index)
      Refresh item by firering SWT.SetData.

      Currently not implemented.

      Parameters:
      index -
    • redraw

      public void redraw​(GalleryItem item)
      Redraw the item given as parameter.
      Parameters:
      item -
    • setData

      protected void setData​(GalleryItem galleryItem, int index)
      Sends SWT.SetData event. Used if SWT.VIRTUAL
      Parameters:
      galleryItem -
      index -
    • updateStructuralValues

      protected void updateStructuralValues​(boolean keepLocation)
      Recalculate structural values using the group renderer
      Gallery and item size will be updated.
      Parameters:
      keepLocation - if true, the current scrollbars position ratio is saved and restored even if the gallery size has changed. (Visible items stay visible)
    • updateStructuralValues

      protected void updateStructuralValues​(GalleryItem changedGroup, boolean keepLocation)
      Recalculate structural values using the group renderer
      Gallery and item size will be updated.
      Parameters:
      changedGroup - the group that was modified since the last layout. If the group renderer or more that one group have changed, use null as parameter (full update)
      keepLocation - if true, the current scrollbars position ratio is saved and restored even if the gallery size has changed. (Visible items stay visible)
    • updateScrollBarsProperties

      protected void updateScrollBarsProperties()
      Move the scrollbar to reflect the current visible items position.
      The bar which is moved depends of the current gallery scrolling : vertical or horizontal.
    • scrollVertical

      protected void scrollVertical()
    • scrollHorizontal

      protected void scrollHorizontal()
    • addItem

      protected void addItem​(GalleryItem item, int position)
    • getItem

      public GalleryItem getItem​(int index)
      Get the item at index.
      If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData event is fired.
      Parameters:
      index - index of the item.
      Returns:
      the GalleryItem or null if index is out of bounds
    • _getItem

      protected GalleryItem _getItem​(GalleryItem parent, int index)
      This method is used by items to implement getItem( index )
      Parameters:
      parent -
      index -
      Returns:
    • _getItem

      protected GalleryItem _getItem​(int index)
      Get the item at index.
      If SWT.VIRTUAL is used and the item has not been used yet, the item is created and a SWT.SetData is fired.
      This is the internal implementation of this method : checkWidget() is not used.
      Parameters:
      index -
      Returns:
      The item at 'index' (not null)
    • _getItem

      protected GalleryItem _getItem​(int index, boolean create)
      Get the item at 'index'.
      If SWT.VIRTUAL is used, 'create' is true and the item has not been used yet, the item is created and a SWT.SetData is fired.
      Parameters:
      index -
      create -
      Returns:
      The item at 'index' or null if there was no item and 'create' was false.
    • _mouseDown

      protected boolean _mouseDown​(org.eclipse.swt.widgets.Event event)
      Forward the mouseDown event to the corresponding group according to the mouse position.
      Parameters:
      event - The original MouseEvent
      Returns:
      true if Gallery should continue standard mouse click handling
    • getItem

      public GalleryItem getItem​(org.eclipse.swt.graphics.Point coords)
      Get item at pixel position
      Parameters:
      coords -
      Returns:
      GalleryItem or null
    • getGroup

      public GalleryItem getGroup​(org.eclipse.swt.graphics.Point coords)

      Get group at pixel position (relative to client area).

      This is an experimental API which is exposing an internal method, it may become deprecated at some point.

      Parameters:
      coords -
      Returns:
    • clearAll

      public void clearAll​(boolean all)
      Clear all Gallery items.
      If the Gallery is virtual, the item count is not reseted and all items will be created again at their first use.
      Parameters:
      all - If true, all children will be cleared. Only groups are cleared otherwise.
    • clearAll

      public void clearAll()
      Clear all GalleryGroups
    • clear

      public void clear​(int index)
      Clear one item.
      Parameters:
      index -
    • clear

      public void clear​(int index, boolean all)
      Clear one item and all its children if 'all' is true
      Parameters:
      index -
      all -
    • indexOf

      public int indexOf​(GalleryItem item)
      Returns the index of a GalleryItem.
      Parameters:
      parentItem -
      item -
      Returns:
    • _indexOf

      protected int _indexOf​(GalleryItem item)
      Returns the index of a GalleryItem when it is a root Item
      Parameters:
      parentItem -
      item -
      Returns:
    • _indexOf

      protected int _indexOf​(GalleryItem parentItem, GalleryItem item)
      Returns the index of a GalleryItem when it is not a root Item
      Parameters:
      parentItem -
      item -
      Returns:
    • getItems

      public GalleryItem[] getItems()
    • isUseControlColors

      public boolean isUseControlColors()
      Returns:
      true if Gallery uses parent colors.
      See Also:
      setUseControlColors(boolean)
    • setUseControlColors

      public void setUseControlColors​(boolean useControlColors)
      Set useControlColors to true in order to get colors from parent Control (SWT default). This may generate more objects on painting and slightly slow down the application. See Bug 279822 : https://bugs.eclipse.org/bugs/show_bug.cgi?id=279822 If enabled, you'll get new Color objects each time you call getXXXColor() on Gallery or GalleryItem. Default is false : colors are stored locally in Gallery, and you'll get the same object each time you call getXXXColor() on Gallery orGalleryItem. The Gallery may not catch color changes on parent control.
      Parameters:
      useControlColors -
    • getBackground

      public org.eclipse.swt.graphics.Color getBackground()
      Overrides:
      getBackground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.getBackground()
    • getBackground

      public org.eclipse.swt.graphics.Color getBackground​(boolean galleryOnly)
      Returns the receiver's background color.
      Parameters:
      galleryOnly - If TRUE, does not try to parent widget or Display defaults to guess the real background color. Note : FALSE is the default behavior.
      Returns:
      The background color or null if galleryOnly was used and the gallery has not foreground color set.
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getForeground

      public org.eclipse.swt.graphics.Color getForeground()
      Overrides:
      getForeground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.getForeground()
    • getForeground

      public org.eclipse.swt.graphics.Color getForeground​(boolean galleryOnly)
      Returns the receiver's foreground color.
      Parameters:
      galleryOnly - If TRUE, does not try to parent widget or Display defaults to guess the real foreground color. Note : FALSE is the default behavior.
      Returns:
      The foreground color or null if galleryOnly was used and the gallery has not foreground color set.
      Throws:
      org.eclipse.swt.SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setBackground

      public void setBackground​(org.eclipse.swt.graphics.Color color)
      Overrides:
      setBackground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setBackground(org.eclipse.swt.graphics .Color)
    • setForeground

      public void setForeground​(org.eclipse.swt.graphics.Color color)
      Overrides:
      setForeground in class org.eclipse.swt.widgets.Control
      See Also:
      Control.setForeground(org.eclipse.swt.graphics .Color)
    • isVertical

      public boolean isVertical()
      Checks if the Gallery was created with SWT.V_SCROLL (ie has a vertical scroll bar).
      Returns:
      true if the gallery has the SWT.V_SCROLL style.
    • setVertical

      public void setVertical​(boolean vertical)
      Deprecated.
      Parameters:
      vertical -
    • getGroupRenderer

      public AbstractGalleryGroupRenderer getGroupRenderer()
    • setGroupRenderer

      public void setGroupRenderer​(AbstractGalleryGroupRenderer groupRenderer)
    • getSelection

      public GalleryItem[] getSelection()
    • getSelectionCount

      public int getSelectionCount()
    • selectAll

      public void selectAll()
      Selects all of the items in the receiver.
    • _selectAll

      protected void _selectAll()
    • setSelection

      public void setSelection​(GalleryItem[] items)
    • removeAll

      public void removeAll()
    • remove

      public void remove​(int index)
    • remove

      public void remove​(GalleryItem item)
    • _remove

      protected void _remove​(int index)
    • _remove

      protected void _remove​(GalleryItem parent, int index)
    • _arrayRemoveItem

      protected java.lang.Object[] _arrayRemoveItem​(java.lang.Object[] array, int index)
    • _arrayAddItem

      protected java.lang.Object[] _arrayAddItem​(java.lang.Object[] array, java.lang.Object object, int index)
      Adds an item to an array.
      Parameters:
      array -
      object -
      index - : if index == -1, item is added at the end of the array.
      Returns:
    • _arrayIndexOf

      protected int _arrayIndexOf​(int[] array, int value)
    • _arrayIndexOf

      protected int _arrayIndexOf​(java.lang.Object[] array, java.lang.Object value)
    • _arrayRemoveItem

      protected int[] _arrayRemoveItem​(int[] array, int index)
    • _setGalleryItems

      public void _setGalleryItems​(GalleryItem[] items)
    • isVirtualGroups

      public boolean isVirtualGroups()
      Returns:
      See Also:
      setVirtualGroups(boolean)
    • setVirtualGroups

      public void setVirtualGroups​(boolean virtualGroups)
      Enable virtual groups

      When a gallery has the SWT.VIRTUAL flag, only items are initialized on display. All groups need to be initialized from the beginning to calculate the total size of the content.

      Virtual groups enable creating groups AND items lazily at the cost of a poor approximation of the total size of the content.

      While a group isn't initialized, the item count defined as default item count is used.

      When a group comes into view, it is initialized using the setData event, and the size of the gallery content is updated to match the real value.

      From the developer point of view, virtual groups uses exactly the same code as the standard virtual mode of SWT.

      This mode can create visual glitches with code that automatically scrolls the widget such as SAT Smooth Scrolling. In that case, you can enable the compatibility mode which is little less lazy that the default virtual groups, but still better than the standard virtual mode

      Parameters:
      virtualGroups -
      See Also:
      setVirtualGroupDefaultItemCount(int), setVirtualGroupsCompatibilityMode(boolean)
    • getVirtualGroupDefaultItemCount

      public int getVirtualGroupDefaultItemCount()
      Returns:
      See Also:
      setVirtualGroupDefaultItemCount(int)
    • isVirtualGroupsCompatibilityMode

      public boolean isVirtualGroupsCompatibilityMode()
      Returns:
      See Also:
      setVirtualGroupsCompatibilityMode(boolean)
    • setVirtualGroupsCompatibilityMode

      public void setVirtualGroupsCompatibilityMode​(boolean compatibilityMode)
      Enable the compatibility workaround for problems with the ultra virtual mode.
      Parameters:
      compatibilityMode -
      See Also:
      setVirtualGroups(boolean)
    • setVirtualGroupDefaultItemCount

      public void setVirtualGroupDefaultItemCount​(int defaultItemCount)
      Set the item count used when a group is not yet initialized (with virtual groups). Since the virtual groups make the size of the gallery change while scrolling, a fine tuned item count can improve the accuracy of the slider.
      Parameters:
      defaultItemCount -
      See Also:
      setVirtualGroups(boolean)